{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://products.digiteqautomotive.com/schemas/screenlinq/COM.protocol.tx.0.5.schema.json",
	"title": "COM protocol transmitted events",
	"description": "Part of event specification that describes the events transmitted to the device.",
	"$defs": {
		
		"#UserProfileId": {
			"description": "Defines an integer in range <0,7>. Only those values can be used as profile id.",
			"type": "integer",
			"minimum": 0,
			"maximum": 7
		},
		
		
		
		"system": {
			"description": "Events describing system and firmware.",
			"$anchor": "SystemSchema",
			"anyOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "information"
							}
						}
					},
					"then": {
						"properties": {
							"data": false
						}
					},
					"else": false
				}
			]
		},
				
		"HID": {
			"description": "Events describing ISO TP HID protocol.",
			"$anchor": "HIDSchema",
			"anyOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "feature list"
							}
						}
					},
					"then": {
						"properties": {
							"data": false
						}
					},
					"else": false
				},
				{
					"if": {
						"properties": {
							"sort": {
								"enum": ["input panel ready", "touch", "event", "key", "slider"]
							}
						}
					},
					"then": false,
					"else": false
				}
			]
		},
		
		"CAN": {
			"description": "Events describing CAN simulation.",
			"$anchor": "CANSchema",
			"anyOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "signal"
							},
							"case": {
								"const": "get"
							}
						}
					},
					"then": {
						"properties": {
							"data": {
								"items": {
									"$ref": "#/$defs/CAN-signal-get"
								}
							}
						}
					},
					"else": false
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "signal"
							},
							"case": {
								"const": "set"
							}
						}
					},
					"then": {
						"properties": {
							"data": {
								"items": {
									"$ref": "#/$defs/CAN-signal-set"
								}
							}
						}
					},
					"else": false
				}
			]
		},
		
		"user-profiles": {
			"description": "Events describing reset and upload of display profiles.",
			"$anchor": "UserProfilesSchema",
			"anyOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "reset"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "User profiles reset event allows only 'set' case.",
								"const": "set"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/UserProfiles-reset"
								}
							}
						}
					},
					"else": false
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "upload"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "User profiles upload event allows only 'set' case.",
								"const": "set"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/UserProfiles-upload"
								}
							}
						}
					},
					"else": false
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "download"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "User profiles download event allows only 'get' case.",
								"const": "get"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/UserProfiles-download"
								}
							}
						}
					},
					"else": false
				}
			]
		},
		
		
		"CAN-signal-get": {
			"description": "Getting of CAN simulation signal.", 
			"type": "object",
			"properties": {
				"identifier": {
					"description": "Identifier of the CAN signal.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Order of the signal.",
							"type": "integer"
						},
						"name": {
							"description": "Name of the signal.",
							"type": "string",
							"minLength": 1
						}
					},
					"minProperties": 1,
					"additionalProperties": false
				}
			},
			"required": ["identifier"],
			"additionalProperties": false
		},
		
		"CAN-signal-set": {
			"description": "Setting of CAN simulation signal.", 
			"type": "object",
			"properties": {
				"identifier": {
					"description": "Identifier of the CAN signal.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Order of the signal.",
							"type": "integer"
						},
						"name": {
							"description": "Name of the signal.",
							"type": "string",
							"minLength": 1
						}
					},
					"minProperties": 1,
					"additionalProperties": false
				},
				"value": {
					"description": "Value of the CAN signal.",
					"type": "object",
					"properties": {
						"raw": {
							"description": "Raw value of the signal.",
							"type": "integer"
						},
						"physical": {
							"description": "Signal transformed to its physical value.",
							"type": "number"
						},
						"textual": {
							"description": "Textual interpretation of the signal value.",
							"type": "string",
							"minLength": 1
						}
					},
					"minProperties": 1,
					"additionalProperties": false
				}
			},
			"required": ["identifier", "value"],
			"additionalProperties": false
		},
		
		"UserProfiles-reset": {
			"description": "Reset of display profiles.",
			"type": "object",
			"properties": {
				"profile": {
					"description": "Number of the display profile.",
					"$ref": "#/$defs/#UserProfileId"
				},
				"edid": false
			},
			"required": ["profile"],
			"additionalProperties": false
		},
		
		"UserProfiles-upload": {
			"description": "Upload of display profiles.",
			"type": "object",
			"properties": {
				"profile": {
					"description": "Number of the display profile.",
					"$ref": "#/$defs/#UserProfileId"
				},
				"edid": {
					"description": "EDID to be stored for the display profile. Note: base-64 encoded string; original data length has to be 128 bytes or 256 bytes.",
					"type": "string",
					"pattern": "^AP///////w[A-D][A-Za-z0-9+/]{160}(={1}|[A-Za-z0-9+/]{171}={2})$"
				}
			},
			"required": ["profile", "edid"],
			"additionalProperties": false
		},
		
		"UserProfiles-download": {
			"description": "Download of display profiles.",
			"type": "object",
			"properties": {
				"profile": {
					"description": "Number of the display profile. Range <0,7>.",
					"type": "integer",
					"minimum": 0,
					"maximum": 7
				},
				"edid": false
			},
			"required": ["profile"],
			"additionalProperties": false
		}
	}
}
