{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fa-spec.com/spec/v1/addressmap.schema.json",
  "title": "spec-platform/v1 addressmap（メモリマップ）",
  "description": "PLC のデバイス範囲（plc）と、変数の一覧（variables）で表す。仕様の正は https://fa-spec.com/json-format の 3 章。",
  "allOf": [{ "$ref": "common.schema.json" }],
  "type": "object",
  "properties": {
    "kind": { "const": "addressmap" },
    "plc": {
      "type": "object",
      "description": "メーカーと機種、使えるデバイス範囲。",
      "properties": {
        "vendor": { "type": "string" },
        "model": { "type": "string" },
        "bitDev": { "type": "string", "description": "自動割付の既定の行き先（ビット。例 \"M\"）。" },
        "wordDev": { "type": "string", "description": "自動割付の既定の行き先（ワード。例 \"D\"）。" },
        "devices": {
          "type": "array",
          "description": "デバイスごとの範囲。",
          "items": {
            "type": "object",
            "properties": {
              "code": { "type": "string", "description": "デバイスの記号（例 \"D\"）。" },
              "name": { "type": "string", "description": "デバイスの名前（例 \"データレジスタ\"）。" },
              "style": { "enum": ["bit", "word", "chbit", "byte", "iec"], "description": "bit（1 点 1 ビット）/ word（1 点 16 ビット）/ chbit（R100 が 1 チャンネル目のビット 0）/ byte（マイコン）/ iec（IEC 61131-3）。" },
              "bits": { "type": "number" },
              "radix": { "enum": [8, 10, 16], "description": "番号の進数。8 は三菱 iQ-F の X / Y。" },
              "notation": { "enum": ["s7"], "description": "iec の書き方。s7 は Siemens（%M0.0、%MW10 の 10 はバイト番号）。" },
              "start": { "type": "number" },
              "end": { "type": "number" }
            }
          }
        }
      }
    },
    "devices": {
      "type": "array",
      "description": "機器と、その中のブロック。構成図の devices / blocks と同じ考え方。",
      "items": {
        "type": "object",
        "properties": {
          "id": { "$ref": "common.schema.json#/$defs/id" },
          "name": { "type": "string" },
          "comment": { "type": "string" },
          "blocks": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/block" } }
        }
      }
    },
    "variables": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/variable" }, "description": "変数の一覧。" },
    "settings": {
      "type": "object",
      "description": "コード生成の設定。",
      "properties": {
        "structName": { "type": "string" },
        "iecWordIndex": {}
      }
    }
  }
}
