{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/vtcfg-v19.0.0.json",
  "$ref": "#/definitions/vtcfg",
  "type": "object",
  "title": "VT System Configuration",
  "description": "VT System Configuration.",
  "definitions": {
    "vtcfg": {
      "type": "object",
      "properties": {
        "version": {
          "title": "Version",
          "description": "Version of the YAML file format, e.g. 19.0.0.",
          "type": "string"
        },
        "modules": {
          "title": "Modules",
          "description": "List of VT System Modules.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Module"
          }
        },
        "vts-control-window": {
          "$ref": "#/definitions/VtsControlWindow"
        }
      },
      "required": ["version"],
      "additionalProperties": false
    },
    "Module": {
      "title": "VT System Module",
      "description": "Describes a VT System module.",
      "type": "object",
      "properties": {
        "type": {
          "title": "ModuleType",
          "description": "Type of the VT System Module, e.g. 1004.",
          "type": "integer",
          "examples": [1004, 2516, 7001]
        },
        "module-channel": {
          "$ref": "#/definitions/ModuleChannel"
        },
        "channels": {
          "title": "Channel",
          "description": "Describes a single channel.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Channel"
          }
        },
        "constraints": {
          "title": "Constraints",
          "description": "Describes the constraints for all channels of the module.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Constraint"
          }
        },
        "gui-labels": {
          "title": "GUI Labels",
          "description": "Specifies the labels shown in the VT System Control Window (only for CANoe DE).",
          "type": "array",
          "items": {
            "$ref": "#/definitions/GUILabel"
          }
        },
        "mdid": {
          "title": "MDID",
          "description": "Unique module identifier.",
          "type": "string"
        },
        "vdid": {
          "title": "VDID",
          "description": "Unique module identifier.",
          "type": "string"
        },
        "interface": {
          "title": "Interface",
          "description": "Interface version of the module's firmware.",
          "type": "integer",
          "examples": [0],
          "default": 0
        },
        "vendor-id": {
          "title": "Vendor ID",
          "description": "Identifiers the vendor of this VT System module.",
          "type": "integer",
          "examples": [5],
          "default": 5
        },
        "module-specific-settings": {
          "$ref": "#/definitions/ModuleSpecificSettings"
        }
      },
      "required": ["type", "module-channel"],
      "additionalProperties": false
    },
    "Channel": {
      "title": "VT System Channel",
      "description": "Describes a channel of a VT System module.",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "User defined channel name.",
          "type": "string",
          "pattern": "^[a-zA-Z_][0-9a-zA-Z_]*$",
          "examples": ["MyName"]
        },
        "active-values": {
          "title": "Active Values",
          "description": "A list of activated measurement values.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ChannelActiveValue"
          }
        },
        "start-values": {
          "title": "Start Values",
          "description": "A list of start value settings.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/StartValue"
          }
        },
        "comment": {
          "title": "Comment",
          "description": "User defined comment for this channel.",
          "type": "string",
          "examples": ["My comment"]
        },
        "start-state-enabled": {
          "title": "Start State Enabled",
          "description": "A flag indicating if the start state settings are actually applied.",
          "type": "boolean"
        }
      },
      "required": ["name"],
      "additionalProperties": false
    },
    "ChannelActiveValue": {
      "title": "Channel Active Value",
      "description": "Active measurement value on a channel.",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "Name of the value.",
          "type": "string",
          "examples": ["CurVoltage", "StimulationRunning"]
        },
        "cycle-time": {
          "title": "Cycle Time",
          "description": "Transmission cycle time for this value (e.g. 10ms).",
          "type": "string",
          "examples": ["10ms", "1s"]
        },
        "integration-time": {
          "title": "Integration Time",
          "description": "Integration time of this value (e.g. 10ms).",
          "type": "string",
          "examples": ["100ms"]
        }
      },
      "required": ["name"],
      "additionalProperties": false
    },
    "StartValue": {
      "title": "Start Value",
      "description": "Describes a start value setting.",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "Name of the start value.",
          "type": "string"
        },
        "value": {
          "$ref": "#/definitions/Value"
        }
      },
      "required": ["name", "value"],
      "additionalProperties": false
    },
    "Constraint": {
      "title": "Constraint",
      "description": "Describes a constraint.",
      "type": "object",
      "properties": {
        "value": {
          "title": "Value",
          "description": "The value that shall be constrained.",
          "type": "string",
          "examples": ["RelayBusBar1A"]
        },
        "channel": {
          "title": "Channel",
          "description": "The channel number this constraint belongs to (1 ... n).",
          "type": "integer",
          "examples": [1, 2, 3, 4]
        },
        "conditions": {
          "title": "Conditions",
          "description": "List of constraint conditions.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Condition"
          }
        }
      },
      "required": ["value", "channel", "conditions"],
      "additionalProperties": false
    },
    "Condition": {
      "title": "Condition",
      "description": "Describes a constraint condition.",
      "type": "object",
      "properties": {
        "operation": {
          "title": "Operation",
          "description": "The operation that is to be constrained.",
          "type": "string",
          "enum": ["open", "close", "configured"],
          "examples": ["open", "close"]
        },
        "sysvar": {
          "title": "System Variable",
          "description": "The system variable that is to be evaluated.",
          "type": "string",
          "examples": ["MynameSpace::MySysvar"]
        },
        "operator": {
          "title": "Operator",
          "description": "The operator that is used for comparison.",
          "type": "string",
          "enum": [
            "less-than",
            "less-or-equal",
            "equal",
            "not-equal",
            "greater-than",
            "greater-or-equal",
            "open",
            "close",
            "forbidden",
            "configured"
          ],
          "examples": ["less-than", "less-or-equal", "not-equal", "forbidden"]
        },
        "operand": {
          "title": "Operand",
          "description": "The operand that is used for comparison.",
          "type": "number",
          "examples": [42]
        }
      },
      "required": ["operator"],
      "additionalProperties": false
    },
    "GUILabel": {
      "title": "GUI Label",
      "description": "Describes a label in the VT System Control Window (only CANoe DE).",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "Name of the label (must match any of the predefined label names).",
          "type": "string"
        },
        "text": {
          "title": "Text",
          "description": "User defined text to show in the label.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            }
          ]
        }
      },
      "required": ["name", "text"],
      "additionalProperties": false
    },
    "ModuleChannel": {
      "title": "Module Channel",
      "description": "Describes the module channel of a VT System Module.",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "User defined channel name.",
          "type": "string",
          "pattern": "^[a-zA-Z_][0-9a-zA-Z_]*$"
        },
        "comment": {
          "title": "Comment",
          "description": "User defined comment.",
          "type": "string",
          "examples": ["My Comment"]
        },
        "start-state-enabled": {
          "title": "Start State Enabled",
          "description": "A flag indicating if the start state is actually applied.",
          "type": "boolean"
        },
        "active-values": {
          "title": "Active Values",
          "description": "A list of active measurement values.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ModuleChannelActiveValue"
          }
        },
        "start-values": {
          "title": "Start Values",
          "description": "A list of start values.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/StartValue"
          }
        }
      },
      "required": ["name"],
      "additionalProperties": false
    },
    "ModuleChannelActiveValue": {
      "title": "Module Channel Active Value",
      "description": "Describes a active measurement value on a module channel.",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "description": "Name of the measurement value to activate.",
          "type": "string"
        },
        "cycle-time": {
          "title": "Cycle Time",
          "description": "Transmission cycle time of the measurement value (e.g. 10ms).",
          "type": "string",
          "examples": ["1ms", "10ms", "50ms", "1s"]
        },
        "integration-time": {
          "title": "Integration Time",
          "description": "Integration time of this value (e.g. 10ms).",
          "type": "string",
          "examples": ["100ms"]
        }
      },
      "required": ["name"],
      "additionalProperties": false
    },
    "ModuleSpecificSettings": {
      "title": "Module Specific Settings",
      "description": "Additional settings, which are required for certain modules only.",
      "type": "object",
      "properties": {
        "supply-voltage": {
          "title": "Supply Voltage",
          "description": "VT2710: Supply voltage.",
          "type": "number",
          "examples": [3.3]
        },
        "supply-voltage-lvds": {
          "title": "Supply Voltage For LVDS",
          "description": "VT2710: Supply voltage for LVDS.",
          "type": "number",
          "examples": [3.3]
        },
        "supply-voltage-lvds-enabled": {
          "title": "LVDS Supply Voltage Enabled",
          "description": "VT2710: Enables the LVDS supply voltage.",
          "type": "boolean"
        },
        "lvds-connector-usage-1": {
          "title": "LVDS Connector Usage 1",
          "description": "VT2710: Sets the usage mode for LVDS connector 1.",
          "type": "string",
          "enum": ["fpga", "canoe"],
          "examples": ["canoe"]
        },
        "lvds-connector-usage-2": {
          "title": "LVDS Connector Usage 2",
          "description": "VT2710: Sets the usage mode for LVDS connector 2.",
          "type": "string",
          "enum": ["fpga", "canoe"],
          "examples": ["canoe"]
        },
        "connectors": {
          "title": "Connectors",
          "description": "VT2710: List of connector descriptions.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Connector"
          }
        },
        "smart-charging-mode": {
          "title": "Smart Charging Mode",
          "description": "VT5201: smart charging mode for this module.",
          "type": "string",
          "enum": ["evse", "ev", "legacy"],
          "examples": ["evse"]
        },
        "piggy-type": {
          "title": "Piggy Type",
          "description": "VT6306: Type of piggy to use.",
          "type": "string",
          "enum": ["none", "psi5-sent", "eth-100-base-t1", "eth-1000-base-t1"],
          "examples": ["eth-1000-base-t1"]
        }
      },
      "additionalProperties": false
    },
    "Connector": {
      "title": "Connector",
      "description": "Configures a VT2710 connector.",
      "type": "object",
      "properties": {
        "supply-mode": {
          "title": "Supply Mode",
          "description": "Defines the supply mode for this VT2710 connector.",
          "type": "string",
          "enum": ["internal", "external"]
        },
        "int-to-ext": {
          "title": "Internal To External",
          "description": "A flag indicating if the internal voltage is also sent to the external voltage pins.",
          "type": "boolean"
        },
        "pins": {
          "title": "Pins",
          "description": "A list of pin configurations.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Pin"
          }
        }
      },
      "required": ["supply-mode", "int-to-ext", "pins"],
      "additionalProperties": false
    },
    "Pin": {
      "title": "Pin",
      "description": "Contains settings for a VT2710 pin.",
      "type": "object",
      "properties": {
        "dio-direction": {
          "$ref": "#/definitions/DioDirection"
        },
        "user-fpga-mode": {
          "$ref": "#/definitions/UserFPGAMode"
        },
        "used-for": {
          "$ref": "#/definitions/UsedFor"
        }
      },
      "required": ["dio-direction", "user-fpga-mode", "used-for"],
      "additionalProperties": false
    },
    "VtsControlWindow": {
      "title": "VT System Control Window",
      "description": "Section with internal settings for the VT System Control Window (only CANoe DE).",
      "type": "object",
      "properties": {
        "flip-rack-order": {
          "title": "Flip Rack Order",
          "description": "Flag to invert the rendering order of racks in the GUI.",
          "type": "boolean"
        },
        "serialized-config": {
          "title": "Serialized Config",
          "description": "Internal configuration string.",
          "type": "string"
        }
      },
      "required": ["flip-rack-order", "serialized-config"],
      "additionalProperties": false
    },
    "DioDirection": {
      "title": "DIO Direction",
      "description": "Direction of a DIO pin.",
      "type": "string",
      "enum": ["input", "output", "mixed"]
    },
    "UsedFor": {
      "title": "Used For",
      "description": "Function assignment for a VT2710 pin.",
      "type": "string",
      "enum": ["spi", "i2c", "dio", "rs232", "rs485", "uart", "fpga"]
    },
    "UserFPGAMode": {
      "title": "User FPGA Mode",
      "description": "Specifies the FPGA mode for a VT2710 pin.",
      "type": "string",
      "enum": ["din", "dout", "i2c", "rs232", "rs485"]
    },
    "Value": {
      "title": "Value",
      "description": "Value to set the start value to.",
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "string"
        }
      ]
    }
  }
}
