{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "JSON Schema for process data of a traffic controller.",
    "id": "http://schlothauer.de/schemas/lsa-process-data.json",
    "properties": {
        "detectorFlanks": {
            "description": "Detector flank occurences for the given timestamp offset. The encoding format for a detector flank is '<ObjNr>(+|-)<FractionalSeconds>'. The +/- part indicates a rising/falling flank. FractionalSeconds is the millisecond part of the given timestamp where flank occured. Example: ['2+100','2-900','4+700'].",
            "items": {
                "properties": {
                    "frac": {
                        "description": "fractional seconds",
                        "type": "integer"
                    },
                    "name": {
                        "description": "Name of the detector (optional).",
                        "type": "string"
                    },
                    "nr": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "type": "array"
        },
        "domainUUID": {
            "description": "RFC 4122 compliant universally unique identifier (UUID) for identifying the domain of the traffic controller.",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
            "type": "string"
        },
        "permissions": {
            "items": {
                "_format": "permission",
                "type": "string"
            },
            "type": "array",
            "_uniqueItems": true
        },
        "programNr": {
            "description": "Number of the signal program; only if changed",
            "type": "integer"
        },
        "signalChanges": {
            "description": "Signal changes for the given timestamp offset.",
            "items": {
                "properties": {
                    "code": {
                        "description": "OCIT signal code",
                        "type": "integer"
                    },
                    "name": {
                        "description": "Name of the signal group (optional).",
                        "type": "string"
                    },
                    "nr": {
                        "type": "integer"
                    }
                },
                "required": [
                    "nr",
                    "code"
                ],
                "type": "object"
            },
            "type": "array"
        },
        "telegrams": {
            "description": "Array with public transport telegrams.",
            "items": {
                "description": "Public transport telegram.",
                "properties": {
                    "abw": {
                        "description": "Fahrplanabweichung.",
                        "type": "integer"
                    },
                    "amliProperties": {
                        "description": "OevAmliTelegramm extension.",
                        "properties": {
                            "fahrzeit": {
                                "description": "Bei Abmeldung die echte Fahrzeit des OV von Anmeldung bis Abmeldung. Bei Anmeldung die theoretisch (berechnete) Fahrzeit des OV von Anmeldung bis Abmeldung (TWF).",
                                "type": "integer"
                            },
                            "gewPhase": {
                                "description": "Gewuenschte Phase (UE).",
                                "type": "integer"
                            },
                            "gruenAnfang": {
                                "description": "Gruenanfang der OV-Signalgruppe (GNA).",
                                "type": "integer"
                            },
                            "gruenEnde": {
                                "description": "Gruenende der OV-Signalgruppe (GNE).",
                                "type": "integer"
                            },
                            "laufPhase": {
                                "description": "Laufende Phase (PH).",
                                "type": "integer"
                            },
                            "modifikation": {
                                "description": "gibt an, ob OEPNV Modifikation durch Zentrale aktiv ist.",
                                "type": "boolean"
                            },
                            "relKnoten": {
                                "description": "relative UnitNr des beeinflussten Knotens.",
                                "type": "integer"
                            },
                            "signalplan": {
                                "description": "Laufender Signalplan (SP).",
                                "type": "integer"
                            },
                            "zeitschalter": {
                                "description": "Zeitschalterwert (TX).",
                                "type": "integer"
                            }
                        },
                        "type": "object"
                    },
                    "kurs": {
                        "type": "integer"
                    },
                    "linie": {
                        "description": "Number of the PT line.",
                        "type": "integer"
                    },
                    "mpNr": {
                        "description": "Number of the PT detection point.",
                        "type": "integer"
                    },
                    "prio": {
                        "description": "Priority.",
                        "type": "integer"
                    },
                    "richtung": {
                        "description": "Manual direction.",
                        "type": "integer"
                    },
                    "route": {
                        "type": "integer"
                    },
                    "zuglaenge": {
                        "description": "Vehicle length.",
                        "type": "integer"
                    }
                },
                "required": [
                    "mpNr",
                    "linie",
                    "kurs",
                    "route",
                    "prio",
                    "zuglaenge",
                    "richtung",
                    "abw"
                ],
                "type": "object"
            },
            "type": "array"
        },
        "timestamp": {
            "_format": "date-time",
            "description": "RFC 3339 compliant timestamp without fractional seconds. Example: '2017-04-05T12:30:00+01:00'.",
            "type": "string"
        },
        "tx": {
            "description": "Cycle second; starting with 0",
            "type": "integer"
        },
        "unitNr": {
            "description": "Unit number of the traffic controller. The unit number must be unique per domain.",
            "type": "integer"
        },
        "variables": {
            "items": {
                "properties": {
                    "name": {
                        "description": "Variable name.",
                        "type": "string"
                    },
                    "value": {
                        "description": "Variable value.",
                        "type": "string"
                    }
                },
                "required": [
                    "name",
                    "value"
                ],
                "type": "object"
            },
            "type": "array"
        }
    },
    "required": [
        "domainUUID",
        "unitNr",
        "timestamp",
        "tx"
    ],
    "type": "object"
}