Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-message-format
Commits
bc7486ed
Commit
bc7486ed
authored
2 years ago
by
Trishna Saeharaseelan
Browse files
Options
Download
Email Patches
Plain Diff
refactor: schemas and added abstract message
parent
806f47dc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
222 additions
and
131 deletions
+222
-131
examples/hydrosurv_adapter/acknowledgement.json
examples/hydrosurv_adapter/acknowledgement.json
+1
-1
formats/__init__.py
formats/__init__.py
+64
-0
formats/acknowledgement.py
formats/acknowledgement.py
+3
-8
formats/message_wrapper.py
formats/message_wrapper.py
+60
-60
formats/mission_plan.py
formats/mission_plan.py
+4
-1
formats/observation.py
formats/observation.py
+30
-21
formats/planning_configuration.py
formats/planning_configuration.py
+4
-1
formats/platform_status.py
formats/platform_status.py
+14
-1
generate_swagger.py
generate_swagger.py
+42
-38
No files found.
examples/hydrosurv_adapter/acknowledgement.json
View file @
bc7486ed
...
...
@@ -8,5 +8,5 @@
"encoded"
:
false
,
"message_type"
:
"acknowledgement"
,
"acknowledged_message_ID"
:
"11111111-7bc8-11ed-a1eb-0242ac999999"
,
"status"
:
"
Approved and sent to platform
"
"status"
:
"
c2_received
"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
formats/__init__.py
View file @
bc7486ed
...
...
@@ -6,3 +6,67 @@ __all__ = [
for
x
in
os
.
listdir
(
os
.
path
.
dirname
(
__file__
))
if
x
.
endswith
(
".py"
)
and
x
!=
"__init__.py"
]
abstract_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/definitions/Metadata"
}],
"type"
:
"object"
,
"properties"
:
{
"payload"
:
{}
}
}
message_metadata
=
{
"type"
:
"object"
,
"discriminator"
:
{
"propertyName"
:
"message_type"
,
},
"properties"
:
{
"message_ID"
:
{
"type"
:
"string"
,
"description"
:
"An identifier for the type of message received."
,
"example"
:
"b427003c-0000-11aa-a1eb-bvcdfghjgfdd"
,
},
"timestamp"
:
{
"type"
:
"string"
,
"format"
:
"date-time"
,
"description"
:
"Timestamp of message"
,
"example"
:
"2022-11-16T00:00:00Z"
,
},
"message_type"
:
{
"type"
:
"string"
,
"description"
:
"Type of message"
,
"example"
:
"platform_status"
,
},
"version"
:
{
"type"
:
"number"
,
"format"
:
"float"
,
"description"
:
"Version of comms backbone message format protocol"
,
"example"
:
2.0
,
},
"source"
:
{
"type"
:
"string"
,
"description"
:
"The sender; Where is this message from"
,
"example"
:
"autonomy_engine"
,
},
"destination"
:
{
"type"
:
"string"
,
"description"
:
"Publisher topic; What is the destination"
+
" of this message"
,
"example"
:
"ah1"
,
},
"encoded"
:
{
"type"
:
"boolean"
,
"description"
:
"Indicate that message raw (encoded) or decoded. "
+
"Options: encoded=True, decoded=False"
,
"example"
:
False
,
},
"delivery_type"
:
{
"type"
:
"string"
,
"description"
:
"To publish or broadcast this message."
,
"enum"
:
[
"broadcast"
,
"publish"
],
"example"
:
"publish"
,
"default"
:
"publish"
,
},
},
"required"
:
[
"message_type"
],
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
formats/acknowledgement.py
View file @
bc7486ed
...
...
@@ -2,12 +2,9 @@
schemas: Acknowledgement status sent by the surface platform to report
receipt of message.
"""
# from openapi_schema_validator import validate
# from jsonschema import validate
from
formats
import
abstract_schema
acknowledgement_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"acknowledged_message_ID"
:
{
...
...
@@ -29,7 +26,5 @@ acknowledgement_schema = {
"required"
:
[
"acknowledged_message_ID"
,
"status"
],
}
# validate(
# {"acknowledged_message_ID": "string-type-id", "status": "c2_received"},
# acknowledgement_schema,
# )
full_acknowledgement_schema
=
abstract_schema
full_acknowledgement_schema
[
"properties"
][
"payload"
]
=
acknowledgement_schema
This diff is collapsed.
Click to expand it.
formats/message_wrapper.py
View file @
bc7486ed
"""
schemas: Message Wrapper is used to wrap all message types that contain
details of where the message is coming from, which end client is its
destination and the type of message.
"""
#
"""
#
schemas: Message Wrapper is used to wrap all message types that contain
#
details of where the message is coming from, which end client is its
#
destination and the type of message.
#
"""
message_wrapper_schema
=
{
"type"
:
"object"
,
"discriminator"
:
{
"propertyName"
:
"message_type"
,
},
"properties"
:
{
"message_ID"
:
{
"type"
:
"string"
,
"description"
:
"An identifier for the type of message received."
,
"example"
:
"b427003c-0000-11aa-a1eb-bvcdfghjgfdd"
,
},
"timestamp"
:
{
"type"
:
"string"
,
"format"
:
"date-time"
,
"description"
:
"Timestamp of message"
,
"example"
:
"2022-11-16T00:00:00Z"
,
},
"message_type"
:
{
"type"
:
"string"
,
"description"
:
"Type of message"
,
"example"
:
"platform_status"
,
},
"version"
:
{
"type"
:
"number"
,
"format"
:
"float"
,
"description"
:
"Version of comms backbone message format protocol"
,
"example"
:
2.0
,
},
"source"
:
{
"type"
:
"string"
,
"description"
:
"The sender; Where is this message from"
,
"example"
:
"autonomy_engine"
,
},
"destination"
:
{
"type"
:
"string"
,
"description"
:
"Publisher topic; What is the destination"
+
" of this message"
,
"example"
:
"ah1"
,
},
"encoded"
:
{
"type"
:
"boolean"
,
"description"
:
"Indicate that message raw (encoded) or decoded. "
+
"Options: encoded=True, decoded=False"
,
"example"
:
False
,
},
"delivery_type"
:
{
"type"
:
"string"
,
"description"
:
"To publish or broadcast this message."
,
"enum"
:
[
"broadcast"
,
"publish"
],
"example"
:
"publish"
,
"default"
:
"publish"
,
},
},
"required"
:
[
"message_type"
],
}
#
message_wrapper_schema = {
#
"type": "object",
#
"discriminator": {
#
"propertyName": "message_type",
#
},
#
"properties": {
#
"message_ID": {
#
"type": "string",
#
"description": "An identifier for the type of message received.",
#
"example": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd",
#
},
#
"timestamp": {
#
"type": "string",
#
"format": "date-time",
#
"description": "Timestamp of message",
#
"example": "2022-11-16T00:00:00Z",
#
},
#
"message_type": {
#
"type": "string",
#
"description": "Type of message",
#
"example": "platform_status",
#
},
#
"version": {
#
"type": "number",
#
"format": "float",
#
"description": "Version of comms backbone message format protocol",
#
"example": 2.0,
#
},
#
"source": {
#
"type": "string",
#
"description": "The sender; Where is this message from",
#
"example": "autonomy_engine",
#
},
#
"destination": {
#
"type": "string",
#
"description": "Publisher topic; What is the destination"
#
+ " of this message",
#
"example": "ah1",
#
},
#
"encoded": {
#
"type": "boolean",
#
"description": "Indicate that message raw (encoded) or decoded. "
#
+ "Options: encoded=True, decoded=False",
#
"example": False,
#
},
#
"delivery_type": {
#
"type": "string",
#
"description": "To publish or broadcast this message.",
#
"enum": ["broadcast", "publish"],
#
"example": "publish",
#
"default": "publish",
#
},
#
},
#
"required": ["message_type"],
#
}
This diff is collapsed.
Click to expand it.
formats/mission_plan.py
View file @
bc7486ed
...
...
@@ -3,6 +3,7 @@
sent to the respective platform's C2 to compile into a platform-specific
mission plan.
"""
from
formats
import
abstract_schema
action_schema
=
{
"type"
:
"object"
,
...
...
@@ -63,7 +64,6 @@ action_schema = {
}
mission_plan_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"autonomy_engine_plan_ID"
:
{
...
...
@@ -84,3 +84,6 @@ mission_plan_schema = {
},
"required"
:
[
"plan_ID"
,
"platform_ID"
,
"plan"
],
}
full_mission_plan_schema
=
abstract_schema
full_mission_plan_schema
[
"properties"
][
"payload"
]
=
mission_plan_schema
This diff is collapsed.
Click to expand it.
formats/observation.py
View file @
bc7486ed
...
...
@@ -2,6 +2,7 @@
schema: Observation Message sent by platforms when points of
interest are found.
"""
from
formats
import
abstract_schema
hits_schema
=
{
"type"
:
"object"
,
...
...
@@ -30,30 +31,38 @@ hits_schema = {
}
observation_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"platform_ID"
:
{
"type"
:
"integer"
,
"description"
:
"ID of platform to sending observations"
,
"example"
:
2
,
},
"points_of_interest"
:
{
"type"
:
"array"
,
"items"
:
hits_schema
,
"description"
:
"Points from features of interest identified by"
+
" platform if any found."
,
# TODO: DEFINE FORMAT.
},
"region_surveyed"
:
{
"type"
:
"null"
,
"description"
:
"Region surveyed by given platform."
+
" GEOJSON"
,
# TODO: DEFINE FORMAT.
"example"
:
""
,
},
"additional_data"
:
{
"description"
:
"Placeholder field for any additional data"
,
"example"
:
{
"sensor_payload"
:
False
},
"payload"
:
{
"type"
:
"object"
,
"properties"
:
{
"platform_ID"
:
{
"type"
:
"integer"
,
"description"
:
"ID of platform to sending observations"
,
"example"
:
2
,
},
"points_of_interest"
:
{
"type"
:
"array"
,
"items"
:
hits_schema
,
"description"
:
"Points from features of interest identified by"
+
" platform if any found."
,
# TODO: DEFINE FORMAT.
},
"region_surveyed"
:
{
# "type": "null",
"nullable"
:
True
,
"description"
:
"Region surveyed by given platform."
+
" GEOJSON"
,
# TODO: DEFINE FORMAT.
"example"
:
""
,
},
"additional_data"
:
{
"description"
:
"Placeholder field for any additional data"
,
"example"
:
{
"sensor_payload"
:
False
},
},
},
},
},
"required"
:
[
"platform_ID"
],
}
full_observation_schema
=
abstract_schema
full_observation_schema
[
"properties"
][
"payload"
]
=
observation_schema
This diff is collapsed.
Click to expand it.
formats/planning_configuration.py
View file @
bc7486ed
...
...
@@ -2,6 +2,7 @@
schemas: configuration sent to Autonomy Engine (i.e. during an emergency,
if a platform needs to be removed from the mission planning)
"""
from
formats
import
abstract_schema
emergency_schema
=
{
"type"
:
"object"
,
...
...
@@ -157,7 +158,6 @@ squad_metadata_schema = {
}
planning_configuration_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"planning_config_ID"
:
{
...
...
@@ -182,3 +182,6 @@ planning_configuration_schema = {
"exclusion_zones"
,
],
}
full_planning_configuration_schema
=
abstract_schema
full_planning_configuration_schema
[
"properties"
][
"payload"
]
=
planning_configuration_schema
This diff is collapsed.
Click to expand it.
formats/platform_status.py
View file @
bc7486ed
"""
schema: platform-specific decoded status message
"""
from
formats
import
abstract_schema
sensor_schema
=
{
"type"
:
"object"
,
"description"
:
"Scanning sensor on platform available"
...
...
@@ -26,7 +28,6 @@ sensor_schema = {
}
platform_status_message_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"platform_ID"
:
{
...
...
@@ -41,6 +42,14 @@ platform_status_message_schema = {
+
" platform or USBL"
,
"example"
:
"usbl"
,
},
"transmission_mode"
:
{
"type"
:
"string"
,
"enum"
:
[
"acoustics"
,
"iridium"
,
"wifi"
,
"starlink"
],
"description"
:
"Mode in which status message was transmitted"
+
" when on the surface (i.e. iridium/wifi) or underwater"
+
" (i.e. acoustics)"
,
"example"
:
"wifi"
,
},
"platform_timestamp"
:
{
"type"
:
"string"
,
"format"
:
"date-time"
,
...
...
@@ -173,3 +182,7 @@ platform_status_message_schema = {
"longitude"
,
],
}
full_platform_status_message_schema
=
abstract_schema
full_platform_status_message_schema
[
"properties"
][
"payload"
]
=
platform_status_message_schema
This diff is collapsed.
Click to expand it.
generate_swagger.py
View file @
bc7486ed
from
formats
.message_wrapper
import
message_
wrapper_schem
a
from
formats.mission_plan
import
mission_plan_schema
from
formats.observation
import
observation_schema
from
formats.planning_configuration
import
planning_configuration_schema
from
formats.platform_status
import
platform_status_message_schema
from
formats.acknowledgement
import
acknowledgement_schema
from
formats
import
message_
metadat
a
from
formats.mission_plan
import
full_
mission_plan_schema
from
formats.observation
import
full_
observation_schema
from
formats.planning_configuration
import
full_
planning_configuration_schema
from
formats.platform_status
import
full_
platform_status_message_schema
from
formats.acknowledgement
import
full_
acknowledgement_schema
from
flasgger
import
Swagger
from
flask
import
Flask
...
...
@@ -28,15 +28,15 @@ swagger_config = {
"model_filter"
:
lambda
tag
:
True
,
}
],
"components"
:
{
"
schema
s"
:
{
"Message"
:
message_wrapper_schem
a
,
"MissionPlan"
:
mission_plan_schema
,
"Observation"
:
observation_schema
,
"PlanningConfiguration"
:
planning_configuration_schema
,
"PlatformStatus"
:
platform_status_message_schema
,
"Acknowledgement"
:
acknowledgement_schema
,
}
#
"components": {
"
definition
s"
:
{
"Metadata"
:
message_metadat
a
,
"MissionPlan"
:
full_
mission_plan_schema
,
"Observation"
:
full_
observation_schema
,
"PlanningConfiguration"
:
full_
planning_configuration_schema
,
"PlatformStatus"
:
full_
platform_status_message_schema
,
"Acknowledgement"
:
full_
acknowledgement_schema
,
#
}
},
"paths"
:
{
"/all_messages"
:
{
...
...
@@ -49,26 +49,30 @@ swagger_config = {
"application/json"
:
{
"schema"
:
{
"oneOf"
:
[
{
"$ref"
:
"#/components/schemas/"
+
"Acknowledgement"
},
{
"$ref"
:
"#/components/schemas/"
+
"MissionPlan"
},
{
"$ref"
:
"#/components/schemas/"
+
"Observation"
},
{
"$ref"
:
"#/components/schemas/"
+
"PlanningConfiguration"
},
{
"$ref"
:
"#/components/schemas/"
+
"PlatformStatus"
},
full_mission_plan_schema
,
full_planning_configuration_schema
,
full_platform_status_message_schema
,
full_observation_schema
,
# {
# "$ref": "#/definitions/"
# + "Acknowledgement"
# },
# {
# "$ref": "#/definitions/"
# + "MissionPlan"
# },
# {
# "$ref": "#/definitions/"
# + "Observation"
# },
# {
# "$ref": "#/definitions/"
# + "PlanningConfiguration"
# },
# {
# "$ref": "#/definitions/"
# + "PlatformStatus"
# },
],
"discriminator"
:
{
"propertyName"
:
"message_type"
,
...
...
@@ -85,8 +89,8 @@ swagger_config = {
"consumes"
:
[
"application/json"
],
}
message_types
=
[
"Me
ssage
"
,
"Acknowledgement"
,
"Me
tadata
"
,
#
"Acknowledgement",
"MissionPlan"
,
"Observation"
,
"PlanningConfiguration"
,
...
...
@@ -104,7 +108,7 @@ for item in message_types:
"schema"
:
{
"allOf"
:
[
{
"$ref"
:
"#/
components/schema
s/"
+
item
,
"$ref"
:
"#/
definition
s/"
+
item
,
},
],
"discriminator"
:
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment