Commit a0d9c041 authored by Dan Jones's avatar Dan Jones
Browse files

Merge branch '43-spine-support' into 'dev'

Resolve "SPINE Support"

Closes #43

See merge request !29
{
"header": {
"message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd",
"timestamp": "2022-11-16T00:00:00Z",
"version": 1,
"source": "hydrosurv_adapter",
"destination": "soar.hydrosurv.reav60.usvdecibel.from_platform.alert",
"delivery_type": "publish",
"encoded": false
},
"payload": {
"message_type": "alert",
"platform_ID": "usvdecibel",
"code": 345,
"platform_timestamp": "2022-12-21T00:00:00Z",
"subsystem": "Onboard Fault Monitor",
"summary": "Steering Damage - Port Side",
"details": "Discrepancy between rudder and actuator positions : Rudder Pos=10.31°, Steering Actuator Pos=28.65°, Discrepancy=18.33°",
"severity": "Alarm"
}
}
\ No newline at end of file
{
"header":{
"header": {
"message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd",
"timestamp": "2022-11-16T00:00:00Z",
"version": 2,
......@@ -8,11 +8,15 @@
"delivery_type": "publish",
"encoded": false
},
"payload":{
"payload": {
"message_type": "platform_status",
"autonomy_engine_plan_ID": 1,
"status_source": "onboard_platform",
"battery_remaining_capacity": 80.2,
"battery_output": 3.8,
"fuel_volume": 13.2,
"fuel_remaining_capacity": 65.3,
"endurance": 3.4,
"heading": 310.0,
"health_status": false,
"latitude": 178.2,
......
"""
schemas: Alert message sent on fault detection
"""
alert_schema = {
"type": "object",
"properties": {
"message_type": {
"type": "string",
"description": "Type of message",
"example": "alert",
"enum": ["alert"],
},
"code": {
"type": "integer",
"description": "Alert code",
"example": 345,
},
"platform_ID": {
"type": "string",
"description": "Unique identifier for this platform",
"example": "usvdecibel",
},
"platform_timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp for onboard platform status message",
"example": "2022-12-21T00:00:00Z",
},
"subsystem": {
"type": "string",
"description": "System that generated the alert",
"example": "Onboard Fault Monitor",
},
"summary": {
"type": "string",
"description": "High level description of the alert",
"example": "Steering Damage - Port Side",
},
"details": {
"type": "string",
"description": "Detailed reason for the alert ",
"example": "Discrepancy between rudder and actuator positions"
+ " : Rudder Pos=10.31°, Steering Actuator Pos=28.65°, Discrepancy=18.33°",
},
"severity": {
"type": "string",
"description": "Severity level of alert",
"example": "Alarm",
"enum": ["Emergency", "Alarm", "Warning", "Caution"],
},
},
"required": [
"message_type",
"platform_ID",
"code",
"severity",
],
}
......@@ -170,6 +170,31 @@ platform_status_schema = {
"description": "Battery remaining % provided by respective C2",
"example": 80.2,
},
"battery_output": {
"type": "number",
"format": "float",
"description": "Battery output in kW",
"example": 80.2,
},
"fuel_remaining_capacity": {
"type": "number",
"format": "float",
"description": "Percentage remaining capacity",
"example": 80.2,
},
"fuel_volume": {
"type": "number",
"format": "float",
"description": "Litres of liquid fuel",
"example": 12.5,
},
"endurance": {
"type": "number",
"format": "float",
"description": "Estimate of hours of operation remaining "
+ "based on present output or performance",
"example": 7.4,
},
"sensor_config": sensor_schema,
},
"required": [
......
......@@ -9,6 +9,7 @@ from formats.platform_status_encoded import platform_status_encoded_schema
from formats.survey import survey_schema
from formats.survey_encoded import survey_encoded_schema
from formats.acknowledgement import acknowledgement_schema
from formats.alert import alert_schema
from flasgger import Swagger
from flask import Flask
......@@ -55,6 +56,7 @@ swagger_config = {
"discriminator": {
"propertyName": "message_type",
"mapping": {
"alert": "#/components/schemas/alert",
"mission_plan": "#/components/schemas/mission_plan",
"mission_plan_encoded": "#/components/schemas/"
+ "mission_plan_encoded",
......@@ -72,6 +74,7 @@ swagger_config = {
},
},
"oneOf": [
{"$ref": "#/components/schemas/alert"},
{"$ref": "#/components/schemas/acknowledgement"},
{"$ref": "#/components/schemas/mission_plan"},
{"$ref": "#/components/schemas/mission_plan_encoded"},
......@@ -95,6 +98,7 @@ swagger_config = {
"survey": survey_schema,
"survey_encoded": survey_encoded_schema,
"acknowledgement": acknowledgement_schema,
"alert": alert_schema,
}
},
}
......
This diff is collapsed.
......@@ -11,6 +11,9 @@ const validateSchema = (schema) => {
const validator = new OpenAPISchemaValidator({ version: 3 });
let validation = validator.validate(schema);
validation.valid = (validation.errors.length === 0);
if (!validation.valid) {
console.log('errors', validation.errors);
}
return validation;
};
......
......@@ -454,6 +454,7 @@ platform_status_schema = {
"type": "string",
"description": "Type of message",
"example": "platform_status",
"enum": ["platform_status"],
},
"platform_ID": {
"type": "string",
......@@ -486,7 +487,7 @@ platform_status_schema = {
"description": "Current state executed by platform. E.g. "
+ "STOP, IDLE, ABORT.",
"example": "ABORT",
},
}, # TODO: Define enum with potential STATES of each platform
"autonomy_engine_plan_ID": {
"type": "integer",
"description": "Last mission plan ID (according to Autonomy"
......@@ -496,13 +497,13 @@ platform_status_schema = {
"latitude": {
"type": "number",
"format": "float",
"description": "Latitude in decimal degrees.",
"description": "Latitude (Y-coordinate) in decimal degrees.",
"example": 178.2,
},
"longitude": {
"type": "number",
"format": "float",
"description": "Longitude in decimal degrees.",
"description": "Longitude (X-coordinate) in decimal degrees.",
"example": -10.122,
},
"depth": {
......@@ -516,7 +517,7 @@ platform_status_schema = {
"type": "number",
"format": "float",
"description": "Target altitude in metres",
"example": 20,
"example": 20.0,
},
"mission_track_ID": {
"type": "integer",
......@@ -542,7 +543,7 @@ platform_status_schema = {
"example": 124.3,
},
"water_current_velocity": {
"format": "string",
"type": "string",
"description": "Water current magnitude and direction",
"example": "124.3NE",
},
......@@ -561,8 +562,8 @@ platform_status_schema = {
},
"health_status": {
"type": "boolean",
"description": "Health status where 0 is OK, 1 is platform"
+ " has an ERROR",
"description": "Health status where 0 is OK, 1 is platform has"
+ " an ERROR",
"example": False,
},
"localisation_north_error": {
......@@ -576,7 +577,7 @@ platform_status_schema = {
"type": "number",
"format": "float",
"description": "Difference in EAST between deadreckoning"
+ " and USBL update.",
+ "and USBL update.",
"example": 0.000129,
},
"usbl_fix_seconds_ago": {
......@@ -591,6 +592,37 @@ platform_status_schema = {
"description": "Battery remaining % provided by respective C2",
"example": 80.2,
},
# Battery power (kw / float)
"battery_output": { # changed from battery_power
"type": "number",
"format": "float",
"description": "Battery output in kW",
"example": 80.2,
},
# Bunkers remaining capacity (litres, float)
# Bunkers percentage full (percentage, float)
# battery_remaining_capacity is % full if we want both these fields
# these names are going to cause confusion
"fuel_remaining_capacity": {
"type": "number",
"format": "float",
"description": "Percentage remaining capacity",
"example": 80.2,
},
"fuel_volume": {
"type": "number",
"format": "float",
"description": "Litres of liquid fuel",
"example": 12.5,
},
# Endurance (hours, float)
"endurance": {
"type": "number",
"format": "float",
"description": "Estimate of hours of operation remaining "
+ "based on present output or performance",
"example": 7.4,
},
"sensor_config": sensor_schema,
},
"required": [
......@@ -602,3 +634,59 @@ platform_status_schema = {
"longitude",
],
}
alert_schema = {
"type": "object",
"properties": {
"message_type": {
"type": "string",
"description": "Type of message",
"example": "alert",
"enum": ["alert"],
},
"code": { # changed from alert_ID because reasons
"type": "integer",
"description": "Alert code",
"example": 345,
},
"platform_ID": {
"type": "string",
"description": "Unique identifier for this platform",
"example": "usvdecibel",
},
"platform_timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp for onboard platform status message",
"example": "2022-12-21T00:00:00Z",
},
"subsystem": { # changed from suggested "source" could be device / subsystem or something
"type": "string",
"description": "System that generated the alert",
"example": "Onboard Fault Monitor",
},
"summary": {
"type": "string",
"description": "High level description of the alert",
"example": "Steering Damage - Port Side",
},
"details": {
"type": "string",
"description": "Detailed reason for the alert ",
"example": "Discrepancy between rudder and actuator positions"
+ " : Rudder Pos=10.31°, Steering Actuator Pos=28.65°, Discrepancy=18.33°",
},
"severity": {
"type": "string",
"description": "Severity level of alert",
"example": "Alarm",
"enum": ["Emergency", "Alarm", "Warning", "Caution"],
},
},
"required": [
"message_type",
"platform_ID",
"code",
"severity",
],
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment