Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions schemas/com.mbta.railds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/mbta/schemas/blob/main/schemas/com.mbta.railds.json",
"title": "RailDS Moxa Events",
"description": "RailDS events emitted by Moxa devices.",
"$ref": "cloudevents.json",
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "name of the event",
"$comment": "enforced to be a valid event name by the oneOf, below"
},
"specversion": {
"const": "1.0"
},
"source": {
"$ref": "cloudevents.json#/properties/source",
"description": "The Id of the device that emitted the event.",
"examples": ["/edge-collector/MOXA-101"]
},
"id": {
"type": "string",
"format": "uuid",
"minLength": 1,
"description": "A unique identifier for the event."
},
"time": {
"$ref": "#/$defs/timestamp"
},
"data": {
"type": "object",
"$comment": "data object is validated by each event's schema in the oneOf below",
"oneOf": [
{
"properties": {
"type": {
"const": "com.mbta.railds.switch-throw"
}
},
"$ref": "com.mbta.railds.switch-throw.v1.json#/"
},
{
"properties": {
"type": {
"const": "com.mbta.railds.measurement"
}
},
"$ref": "com.mbta.railds.measurement.v1.json#/"
}
]
}
},
"required": ["type", "specversion", "source", "id", "time", "data"],
"$defs": {
"timestamp": {
"type": "string",
"minLength": 20,
"$comment": "RFC3339 timestamp",
"format": "date-time",
"pattern": "^[0-9]{4}-[01][0-9]-[0-3][0-9]T[012][0-9]:[0-5][0-9]:[0-6][0-9](.[0-9]*)?(Z|[+-][012][0-9]:[0-5][0-9])$",
"examples": ["2023-01-20T09:30:00-05:00"]
}
}
}
91 changes: 91 additions & 0 deletions schemas/com.mbta.railds.measurement.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/mbta/schemas/blob/main/schemas/com.mbta.railds.measurement.v1.json",
"title": "Mikrolok Measurement Data",
"description": "Raw measurement data structure from Mikrolok devices before CloudEvents wrapping",
"type": "object",
"properties": {
"asset_id": {
"type": "string",
"description": "Identifier for the monitored asset"
},
"payload": {
"type": "object",
"description": "Payload containing events",
"properties": {
"events": {
"type": "array",
"description": "Array of measurement events",
"items": {
"type": "object",
"properties": {
"mlk_timestamp_utc": {
"type": "string",
"format": "date-time",
"description": "UTC timestamp from the MicroLok device"
},
"values": {
"type": "array",
"description": "Array of measurement values",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the measurement point"
},
"value": {
"type": "integer",
"description": "Measured value"
},
"value_type": {
"type": "string",
"description": "Type of the value",
"enum": ["boolean"]
},
"index": {
"type": "integer",
"description": "Index of the measurement point",
"minimum": 1
},
"old": {
"type": ["integer", "null"],
"description": "Previous value before change"
},
"operation": {
"type": "string",
"description": "Operation performed on the value",
"enum": ["clear", "set"]
},
"change_id": {
"type": "string",
"description": "Unique identifier for this change"
},
"updated_utc": {
"type": "string",
"format": "date-time",
"description": "UTC timestamp when value was updated"
}
},
"required": [
"name",
"value",
"value_type",
"index",
"old",
"operation",
"change_id",
"updated_utc"
]
}
}
},
"required": ["mlk_timestamp_utc", "values"]
}
}
},
"required": ["events"]
}
},
"required": ["asset_id", "payload"]
}
Loading
Loading