{
  "type": "object",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "https://signalk.org/specification/1.5.1/schemas/groups/tanks.json#",
  "description": "A tank, named by a unique identifier",
  "definitions": {
    "tankCollection": {
      "patternProperties": {
        ".*": {
          "description": "Tank, one or many, within the vessel",
          "name": "Tank",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the tank. Useful if multiple tanks of a certain type are on board"
            },

            "type": {
              "type": "string",
              "description": "The type of tank",
              "enum": [
                "petrol",
                "fresh water",
                "greywater",
                "blackwater",
                "holding",
                "lpg",
                "diesel",
                "liveWell",
                "baitWell",
                "ballast",
                "rum"
              ]
            },

            "capacity": {
              "description": "Total capacity",
              "$ref": "../definitions.json#/definitions/numberValue",
              "units": "m3"
            },

            "currentLevel": {
              "description": "Level of fluid in tank 0-100%",
              "$ref": "../definitions.json#/definitions/numberValue",
              "units": "ratio"
            },

            "currentVolume": {
              "description": "Volume of fluid in tank",
              "units": "m3",
              "$ref": "../definitions.json#/definitions/numberValue"
            },
            "pressure": {
              "description": "Pressure of contents in tank, especially LPG/gas",
              "units": "Pa",
              "$ref": "../definitions.json#/definitions/numberValue"
            },
            "temperature": {
              "description": "Temperature of tank, especially cryogenic or LPG/gas",
              "units": "K",
              "$ref": "../definitions.json#/definitions/numberValue"
            },
            "viscosity": {
              "description": "Viscosity of the fluid, if applicable",
              "$ref": "../definitions.json#/definitions/numberValue",
              "units": "Pa/s"
            },
            "extinguishant": {
              "description": "The preferred extinguishant to douse a fire in this tank",
              "$ref": "../definitions.json#/definitions/stringValue"
            }
          }
        }
      }
    }
  },
  "properties": {
    "freshWater": {
      "description": "Fresh water tank (drinking)",
      "$ref": "#/definitions/tankCollection"
    },
    "wasteWater": {
      "description": "Waste water tank (grey water)",
      "$ref": "#/definitions/tankCollection"
    },
    "blackWater": {
      "description": "Black water tank (sewage)",
      "$ref": "#/definitions/tankCollection"
    },
    "fuel": {
      "description": "Fuel tank (petrol or diesel)",
      "$ref": "#/definitions/tankCollection"
    },
    "lubrication": {
      "description": "Lubrication tank (oil or grease)",
      "$ref": "#/definitions/tankCollection"
    },
    "liveWell": {
      "description": "Live tank (fish)",
      "$ref": "#/definitions/tankCollection"
    },
    "baitWell": {
      "description": "Bait tank",
      "$ref": "#/definitions/tankCollection"
    },
    "gas": {
      "description": "Lpg/propane and other gases",
      "$ref": "#/definitions/tankCollection"
    },
    "ballast": {
      "description": "Ballast tanks",
      "$ref": "#/definitions/tankCollection"
    }
  }
}
