{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://products.digiteqautomotive.com/schemas/screenlinq/COM.protocol.rx.0.5.schema.json",
	"title": "COM protocol received events",
	"description": "Part of event specification that describes the events received from the device.",
	"$defs": {

		"json": {
			"description": "Events describing common JSON errors.",
			"$anchor": "JSONSchema",
			"allOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"properties": {
									"number": {
										"enum": [0]
									}
								}
							}
						}
					},
					"then": {
						"data": {
							"type": "object"
						},
						"$ref": "#/$defs/JSON-buffer"
					},
					"else": {
						"properties": {
							"data": {
								"type": "array",
								"items": {
									"type": "object"
								}
							}
						},
						"$ref": "#/$defs/error-JSON"
					}
				}
			]
		},
		
		"error": {
			"$comment": "Correspondence between 'number' and 'message' in 'sort':",
			"description": "Events describing any error.",
			"$anchor": "CategoryError",
			"allOf": [
				{
					"if": {
						"properties": {
							"category": {
								"const": "system"
							}
						}
					},
					"then": false
				},
				{
					"if": {
						"properties": {
							"category": {
								"const": "HID"
							}
						}
					},
					"then": false
				},
				{
					"if": {
						"properties": {
							"category": {
								"const": "CAN"
							}
						}
					},
					"then": {
						"properties": {
							"sort": {
								"$ref": "#/$defs/error-CAN"
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"category": {
								"const": "user profiles"
							}
						}
					},
					"then": {
						"properties": {
							"sort": {
								"$ref": "#/$defs/error-UserProfiles"
							}
						}
					}
				}
			],
			"properties": {
				"data": {
					"description": "The object contained in the array that is wrong (according to the corresponding 'category')."
				}
			}
		},
		
		"system": {
			"description": "Events describing system and firmware.",
			"$anchor": "SystemSchema",
			"allOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "information"
							}
						}
					},
					"then": {
						"properties": {
							"data": {
								"items": {
									"$ref": "#/$defs/System-information"
								}
							}
						}
					}
				}
			]
		},
		
		"HID": {
			"description": "Events describing ISO TP HID protocol.",
			"$anchor": "HIDSchema",
			"allOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "input panel ready"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "HID input panel ready event allows only 'update' case.",
								"const": "update"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/HID-inputpanelready"
								}
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "feature list"
							}
						}
					},
					"then": {
						"properties": {
							"data": {
								"items": {
									"$ref": "#/$defs/HID-featurelist"
								}
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "touch"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "HID finger touch event allows only 'update' case.",
								"const": "update"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/HID-touch"
								}
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "event"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "HID finger gesture event allows only 'update' case.",
								"const": "update"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/HID-event"
								}
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "key"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "HID key event allows only 'update' case.",
								"const": "update"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/HID-key"
								}
							}
						}
					}
				},
				{
					"if": {
						"properties": {
							"sort": {
								"const": "slider"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "HID slider event allows only 'update' case.",
								"const": "update"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/HID-slider"
								}
							}
						}
					}
				}
			]
		},
		
		"CAN": {
			"description": "Events describing CAN simulation.",
			"$anchor": "CANSchema",
			"allOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "signal"
							}
						}
					},
					"then": {
						"properties": {
							"data": {
								"items": {
									"$ref": "#/$defs/CAN-signal"
								}
							}
						}
					}
				}
			]
		},
		
		"user-profiles": {
			"description": "Events describing download of display profiles.",
			"$anchor": "UserProfilesSchema",
			"allOf": [
				{
					"if": {
						"properties": {
							"sort": {
								"const": "download"
							}
						}
					},
					"then": {
						"properties": {
							"case": {
								"description": "User profiles download event allows only 'state' case.",
								"const": "state"
							},
							"data": {
								"items": {
									"$ref": "#/$defs/UserProfiles-download"
								}
							}
						}
					}
				}
			]
		},
		
		
		"JSON-buffer": {
			"description": "Report of not enough buffer space for JSON.",
			"properties": {
				"sort": {
					"properties": {
						"message": {
							"enum": ["the JSON being created too long", "command JSON too long"]
						}
					}
				},
				"data": {
					"properties": {
						"size": {
							"description": "Information about total buffer length available for rx/tx JSON [B].",
							"type": "integer"
						}
					}
				}
			}
		},
		
		"System-information": {
			"description": "Information about system and firmware.",
			"type": "object",
			"properties": {
				"item": {
					"description": "Kind of an information. One of {'hardware', 'firmware', 'JSON schema', ...}.",
					"type": "string"
				},
				"version": {
					"description": "Version of the kind.",
					"type": "object",
					"properties": {
						"major": {
							"description": "Major version.",
							"type": "integer"
						},
						"minor": {
							"description": "Minor version.",
							"type": "integer"
						},
						"note": {
							"description": "An additional note to the version, if any.",
							"type": "string"
						}
					}
				},
				"url": {
					"description": "URL with some related specification.",
					"type": "string",
					"format": "uri-reference"
				}
			}
		},
		
		"HID-inputpanelready": {
			"description": "HID input panel ready.",
			"type": "object",
			"properties": {
				"status": {
					"description": "Status information (wakeup type).",
					"type": "object",
					"properties": {
						"value" : {
							"description": "Numerical value of the status.",
							"type": "integer"
						},
						"interpretation": {
							"description": "Interpretation of the status (according to ISO TP HID), if available. One of {'normal start-up', 'wakeup or reset', ...} or key name of the key code that caused the wakeup.",
							"type": "string"
						}
					}
				}
			}
		},
		
		"HID-featurelist": {
			"description": "HID feature list.",
			"type": "object",
			"properties": {
				"id": {
					"description": "Feature ID.",
					"type": "object",
					"properties": {
						"feature" : {
							"description": "Numerical value of the feature ID.",
							"type": "integer"
						},
						"interpretation": {
							"description": "Interpretation of the ID (according to Feature List Table), if available.",
							"type": "string"
						}
					}
				},
				"value": {
					"description": "Feature value.",
					"type": "object",
					"properties": {
						"value" : {
							"description": "Numerical value of the feature value.",
							"type": "integer"
						},
						"interpretation": {
							"description": "Interpretation of the value (according to Feature List Table), if available.",
							"type": "string"
						}
					}
				}
			}
		},
		
		"HID-touch": {
			"description": "Finger touch event.",
			"type": "object",
			"properties": {
				"id": {
					"description": "ID of the finger.",
					"type": "integer"
				},
				"activity": {
					"description": "Kind of the finger touch event.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Code of the event kind (according to ISO TP HID). The number represents force of the finger pressure [100 mN]. Range <0,252>.",
							"type": "integer"
						},
						"interpretation": {
							"description": "Intepretation of the event code (according to ISO TP HID), if available. One of {'move', 'press', 'release', ...}.",
							"type": "string"
						}
					}
				},
				"location": {
					"description": "Coordinates of the event location.",
					"type": "object",
					"properties": {
						"plain": {
							"description": "Raw value obtained from ISO TP HID message.",
							"type": "object",
							"properties": {
								"x": {
									"description": "Coordinate x.",
									"type": "integer"
								},
								"y": {
									"description": "Coordinate y.",
									"type": "integer"
								}
							}								
						},
						"converted": {
							"description": "The value converted (by using multilication factor and geometric transformation - reflection and rotation), if multiplication factor available.",
							"type": "object",
							"properties": {
								"x": {
									"description": "Coordinate x.",
									"type": "integer"
								},
								"y": {
									"description": "Coordinate y.",
									"type": "integer"
								}
							}
						}
					}
				}
			}
		},
		
		"HID-event": {
			"description": "Finger gesture event.",
			"type": "object",
			"properties": {
				"activity": {
					"description": "Kind of the finger gesture event.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Code of the event kind (according to ISO TP HID).",
							"type": "integer"
						},
						"interpretation": {
							"description": "Intepretation of the event code (according to ISO TP HID), if available. One of {'release', 'click', 'press (one finger)', 'drag (one finger)', 'flick (one finger)', 'raw (two fingers)', 'press (two fingers)', 'rotate (two fingers)', 'drag (two fingers)', 'flick (two finger)', 'zoom (two fingers)', 'right (two fingers)', 'raw+ (two fingers)', 'error', ...}.",
							"type": "string"
						}
					}
				},
				"location": {
					"description": "Coordinates of the event location.",
					"type": "object",
					"properties": {
						"plain": {
							"description": "Raw value obtained from ISO TP HID message.",
							"type": "object",
							"properties": {
								"x": {
									"description": "Coordinate x.",
									"type": "integer"
								},
								"y": {
									"description": "Coordinate y.",
									"type": "integer"
								}
							}								
						},
						"converted": {
							"description": "The value converted (by using multilication factor and geometric transformation - reflection and rotation), if multiplication factor available.",
							"type": "object",
							"properties": {
								"x": {
									"description": "Coordinate x.",
									"type": "integer"
								},
								"y": {
									"description": "Coordinate y.",
									"type": "integer"
								}
							}
						}
					}
				},
				"parameter_1": {
					"description": "Parameter 1 of the finger gesture event.",
					"type": "object",
					"properties": {
						"value": {
							"description": "Unsigned numerical value of the parameter 1.",
							"type": "integer"
						}
					}
				},
				"parameter_2": {
					"description": "Parameter 2 of the finger gesture event.",
					"type": "object",
					"properties": {
						"value": {
							"description": "Unsigned numerical value of the parameter 2.",
							"type": "integer"
						}
					}
				}
			}
		},
		
		"HID-key": {
			"description": "Key event.",
			"type": "object",
			"properties": {
				"code": {
					"description": "Recognition of the key.",
					"type": "object",
					"properties": {
						"id" : {
							"description": "Code of the key.",
							"type": "integer"
						},
						"name": {
							"description": "Name of the key (according to ISO TP HID), if available. One of {'__reserved__', 'DDS', 'MEDIA', 'PHONE', 'NAV', 'TRAFFIC', 'CAR', 'SETUP', 'Softkey NV', 'Softkey SW', ''<'', 'Softkey NE', 'Softkey SE', 'RETURN', ''>'', 'EJECT', 'MAP', 'SOURCE', 'RADIO', 'MENU', 'TONE', 'MUTE', 'PTT', 'TP', 'TI', 'TPEG', 'SAT', 'SYSTEM', 'DMB', 'DisplayTaster1', 'Drive Select', ''1'', 'ON/OFF', ''3'', ''4'', ''5'', ''6'', ''2'', ''7'', ''8'', 'CLIMATE', 'SEAT', 'HYBRID', 'OFF ROAD', 'ASSIST', 'SK_WEST', 'SK_EAST', 'TP', 'HOR', 'INFO', 'List', 'SpoilerDeploy', 'SpoilerRetract, '<icon>', '', ...}.",
							"type": "string"
						}
					}
				},
				"activity": {
					"description": "Kind of the key event.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Code of the event kind (according to ISO TP HID).",
							"type": "integer"
						},
						"interpretation": {
							"description": "Intepretation of the event code (according to ISO TP HID), if available. One of {'released', 'pressed', 'pressed 2', 'approached', 'abandoned', 'virtual press', 'virtual release', ...}.",
							"type": "string"
						}
					}
				}
			}
		},
		
		"HID-slider": {
			"description": "Slider event.",
			"type": "object",
			"properties": {
				"id": {
					"description": "ID of the slider point.",
					"type": "integer"
				},
				"activity": {
					"description": "Kind of the slider event.",
					"type": "object",
					"properties": {
						"code": {
							"description": "Code of the event kind (according to ISO TP HID). The number represents force of the finger pressure [100 mN]. Range <0,252>.",
							"type": "integer"
						},
						"interpretation": {
							"description": "Intepretation of the event code (according to ISO TP HID), if available. One of {'move', 'press', 'release', ...}.",
							"type": "string"
						}
					}
				},
				"location": {
					"description": "Coordinate of the slider point event.",
					"type": "object",
					"properties": {
						"segment": {
							"description": "Number of the segment.",
							"type": "integer"
						},
						"x": {
							"description": "Coordinate x [px].",
							"type": "integer"
						}
					}
				}
			}
		},
		
		"CAN-signal": {
			"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"
						}
					}
				},
				"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 quantity.",
							"type": "object",
							"properties": {
								"numerical": {
									"description": "Numerical value of the physical quantity.",
									"type": "number"
								},
								"unit": {
									"description": "Unit of the physical quantity.",
									"type": "string"
								}
							}
						},
						"textual": {
							"description": "Textual interpretation of the signal value.",
							"type": "string"
						}
					}
				}
			},
			"required": ["identifier", "value"],
			"additionalProperties": false
		},
		
		"UserProfiles-download": {
			"description": "Download of display profiles.",
			"type": "object",
			"properties": {
				"profile": {
					"description": "Number of the display profile. Range <0,7>.",
					"type": "integer"
				},
				"edid": {
					"description": "EDID stored for the display profile. Note: base-64 encoded string.",
					"type": "string",
					"pattern": "^[A-Za-z0-9+/]{171}([A-Za-z0-9+/]{171})?={0,2}$"
				}
			}
		},
		
		
		"error-CAN": {
			"description": "Report of CAN errors.",
			"oneOf": [
				{
					"properties": {
						"number": {
							"const": 784
						},
						"message": {
							"const": "unrecognized element"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 785
						},
						"message": {
							"const": "invalid identifier"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 786
						},
						"message": {
							"const": "invalid identifier code"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 787
						},
						"message": {
							"const": "invalid identifier name"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 788
						},
						"message": {
							"const": "inconsistency between identifier code and name"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 789
						},
						"message": {
							"const": "identifier currently not active"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 790
						},
						"message": {
							"const": "invalid value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 791
						},
						"message": {
							"const": "missing value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 792
						},
						"message": {
							"const": "unexpected value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 793
						},
						"message": {
							"const": "invalid raw value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 794
						},
						"message": {
							"const": "invalid physical value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 795
						},
						"message": {
							"const": "invalid textual value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 796
						},
						"message": {
							"const": "inconsistency between raw, physical or textual value"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 797
						},
						"message": {
							"const": "too many executions being proceeded"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 798
						},
						"message": {
							"const": "operation not supported"
						}
					}
				}
			]
		},
		
		"error-UserProfiles": {
			"description": "Report of user profiles errors.",
			"oneOf": [
				{
					"properties": {
						"number": {
							"const": 1040
						},
						"message": {
							"const": "unrecognized element"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 1041
						},
						"message": {
							"const": "invalid profile"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 1042
						},
						"message": {
							"const": "invalid EDID"
						}
					}
				},
				{
					"properties": {
						"number": {
							"const": 1043
						},
						"message": {
							"const": "upload failed"
						}
					}
				}
			]
		},
		
		"error-JSON": {
			"description": "Report of common JSON errors.",
			"properties": {
				"sort": {
					"oneOf": [
						{
							"if": {
								"properties": {
									"number": {
										"const": 16
									},
									"message": {
										"const": "incorrect JSON format"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 17
									},
									"message": {
										"const": "disallowed element"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 18
									},
									"message": {
										"const": "unrecognized event category"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 19
									},
									"message": {
										"const": "unrecognized event case"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 20
									},
									"message": {
										"const": "unrecognized event type"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 21
									},
									"message": {
										"const": "unrecognized event data"
									}
								}
							},
							"then": true,
							"else": false
						},
						{
							"if": {
								"properties": {
									"number": {
										"const": 22
									},
									"message": {
										"const": "unfeasible category/case request"
									}
								}
							},
							"then": true,
							"else": false
						}
					]
				},
				"data": {
					"properties": {
						"position": {
							"description": "Information about position in the command JSON where the failure occured.",
							"type": "integer"
						},
						"json": {
							"description": "Part of JSON that caused the failure.",
							"type": "string"
						}
					}
				}
			}
		}
		
	}
}
