{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "urn:exploder-kit:scenario:1",
 "title": "A traffic scenario",
 "description": "sim/scenarios/*.json: movers with their classes, identity sensors and routes on named runways, taxiways and roads, the reports it schedules, and the exceptions it is meant to raise, in order. Everything simulated.",
 "type": "object",
 "required": [
  "id",
  "name",
  "simulated",
  "duration_s",
  "expect",
  "movers"
 ],
 "properties": {
  "id": {
   "type": "string",
   "pattern": "^[a-z0-9-]+$"
  },
  "name": {
   "type": "string"
  },
  "about": {
   "type": "string"
  },
  "simulated": {
   "const": true
  },
  "duration_s": {
   "type": "number",
   "minimum": 1
  },
  "active_runway": {
   "type": "string"
  },
  "expect": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "event",
     "mover"
    ],
    "properties": {
     "event": {
      "type": "string"
     },
     "mover": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   }
  },
  "reports": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "t",
     "rule",
     "where"
    ],
    "properties": {
     "t": {
      "type": "number"
     },
     "rule": {
      "type": "string"
     },
     "at": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2
     },
     "where": {
      "type": "string"
     },
     "fixture": {
      "type": "object",
      "required": [
       "runway",
       "side",
       "index"
      ],
      "properties": {
       "runway": {
        "type": "string"
       },
       "side": {
        "enum": [
         1,
         -1
        ]
       },
       "index": {
        "type": "integer",
        "minimum": 0
       }
      }
     }
    },
    "anyOf": [
     {
      "required": [
       "at"
      ]
     },
     {
      "required": [
       "fixture"
      ]
     }
    ]
   }
  },
  "movers": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "required": [
     "id",
     "class",
     "sensor",
     "route"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "callsign": {
      "type": "string"
     },
     "class": {
      "type": "string"
     },
     "tag": {
      "type": "string"
     },
     "appears": {
      "enum": [
       "start",
       "on_read"
      ]
     },
     "start_s": {
      "type": "number"
     },
     "cleared": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "sensor": {
      "oneOf": [
       {
        "type": "null"
       },
       {
        "type": "object",
        "required": [
         "id",
         "type"
        ],
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "pattern": "^sensor\\."
         }
        }
       }
      ]
     },
     "route": {
      "type": "array",
      "minItems": 1,
      "prefixItems": [
       {
        "type": "object",
        "required": [
         "at"
        ],
        "properties": {
         "at": {
          "type": "string",
          "pattern": "^(rwy|rwyend|twy|lane|stand|node|gate|svc|final|climb|pt):.+$"
         }
        }
       }
      ],
      "items": {
       "type": "object",
       "properties": {
        "to": {
         "type": "string",
         "pattern": "^(rwy|rwyend|twy|lane|stand|node|gate|svc|final|climb|pt):.+$"
        },
        "speed": {},
        "unit": {
         "enum": [
          "kt",
          "mph"
         ]
        },
        "ways": {
         "type": "array"
        },
        "via": {
         "type": "array"
        },
        "hold_s": {
         "type": "number"
        },
        "air": {
         "type": "boolean"
        },
        "alt_ft": {},
        "say": {
         "type": "string"
        },
        "ref": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  }
 }
}