{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lzxindustries.net/eis/data/row_budget.schema.json",
  "title": "EIS row budget",
  "description": "Annex L worksheet: per row, the sources of each power domain and each module's draw per domain (ASM-001). tools/row_budget.py also reads the earlier form (bus, supply, i_plus12_a per module) for this edition.",
  "type": "object",
  "required": [
    "eis_edition",
    "rows"
  ],
  "properties": {
    "eis_edition": {
      "type": "string",
      "minLength": 1
    },
    "instrument_name": {
      "type": "string"
    },
    "rows": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/row"
      }
    }
  },
  "$defs": {
    "rail_currents": {
      "type": "object",
      "description": "Current per rail in A, keyed by the rail names of data/power_domains.json (plus12, minus12, plus5; v12)",
      "additionalProperties": {
        "type": "number",
        "minimum": 0
      }
    },
    "row": {
      "type": "object",
      "required": [
        "id",
        "width_hp",
        "clear_depth_mm",
        "sources",
        "modules"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "width_hp": {
          "type": "integer",
          "minimum": 1,
          "description": "ENC-001"
        },
        "clear_depth_mm": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "ENC-001"
        },
        "video_reference": {
          "type": "string",
          "enum": [
            "none",
            "VID-75"
          ]
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/source"
          }
        },
        "modules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/module_draw"
          }
        }
      }
    },
    "source": {
      "type": "object",
      "required": [
        "domain",
        "name",
        "total_a"
      ],
      "properties": {
        "domain": {
          "type": "string",
          "description": "A domain id from data/power_domains.json"
        },
        "name": {
          "type": "string",
          "description": "bus board, supply, DC distribution, ..."
        },
        "total_a": {
          "$ref": "#/$defs/rail_currents",
          "description": "Its published total per rail (PWR-002)"
        },
        "outlets": {
          "type": "integer",
          "minimum": 1
        },
        "each_a": {
          "oneOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "$ref": "#/$defs/rail_currents"
            }
          ],
          "description": "The limit at each outlet, per rail (PWR-002; a bus board header at most 2 A, BUS-012)"
        },
        "ripple_mvpp": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Published ripple and noise (SUP-001)"
        }
      }
    },
    "module_draw": {
      "type": "object",
      "required": [
        "name",
        "hp",
        "depth_mm",
        "draw"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "hp": {
          "type": "integer",
          "minimum": 1
        },
        "depth_mm": {
          "type": "number",
          "minimum": 0
        },
        "draw": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/rail_currents"
          },
          "description": "Per domain, the module's published current per rail (PWR-001)"
        },
        "plan_minus12_from_plus12": {
          "type": "boolean",
          "description": "Plan −12 V at 50 % of +12 V when the module publishes none (8.1)"
        }
      }
    }
  }
}
