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
Show 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 @@
...
@@ -8,5 +8,5 @@
"encoded"
:
false
,
"encoded"
:
false
,
"message_type"
:
"acknowledgement"
,
"message_type"
:
"acknowledgement"
,
"acknowledged_message_ID"
:
"11111111-7bc8-11ed-a1eb-0242ac999999"
,
"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__ = [
...
@@ -6,3 +6,67 @@ __all__ = [
for
x
in
os
.
listdir
(
os
.
path
.
dirname
(
__file__
))
for
x
in
os
.
listdir
(
os
.
path
.
dirname
(
__file__
))
if
x
.
endswith
(
".py"
)
and
x
!=
"__init__.py"
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 @@
...
@@ -2,12 +2,9 @@
schemas: Acknowledgement status sent by the surface platform to report
schemas: Acknowledgement status sent by the surface platform to report
receipt of message.
receipt of message.
"""
"""
# from openapi_schema_validator import validate
from
formats
import
abstract_schema
# from jsonschema import validate
acknowledgement_schema
=
{
acknowledgement_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"acknowledged_message_ID"
:
{
"acknowledged_message_ID"
:
{
...
@@ -29,7 +26,5 @@ acknowledgement_schema = {
...
@@ -29,7 +26,5 @@ acknowledgement_schema = {
"required"
:
[
"acknowledged_message_ID"
,
"status"
],
"required"
:
[
"acknowledged_message_ID"
,
"status"
],
}
}
# validate(
full_acknowledgement_schema
=
abstract_schema
# {"acknowledged_message_ID": "string-type-id", "status": "c2_received"},
full_acknowledgement_schema
[
"properties"
][
"payload"
]
=
acknowledgement_schema
# 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
#
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
#
details of where the message is coming from, which end client is its
destination and the type of message.
#
destination and the type of message.
"""
#
"""
message_wrapper_schema
=
{
#
message_wrapper_schema = {
"type"
:
"object"
,
#
"type": "object",
"discriminator"
:
{
#
"discriminator": {
"propertyName"
:
"message_type"
,
#
"propertyName": "message_type",
},
#
},
"properties"
:
{
#
"properties": {
"message_ID"
:
{
#
"message_ID": {
"type"
:
"string"
,
#
"type": "string",
"description"
:
"An identifier for the type of message received."
,
#
"description": "An identifier for the type of message received.",
"example"
:
"b427003c-0000-11aa-a1eb-bvcdfghjgfdd"
,
#
"example": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd",
},
#
},
"timestamp"
:
{
#
"timestamp": {
"type"
:
"string"
,
#
"type": "string",
"format"
:
"date-time"
,
#
"format": "date-time",
"description"
:
"Timestamp of message"
,
#
"description": "Timestamp of message",
"example"
:
"2022-11-16T00:00:00Z"
,
#
"example": "2022-11-16T00:00:00Z",
},
#
},
"message_type"
:
{
#
"message_type": {
"type"
:
"string"
,
#
"type": "string",
"description"
:
"Type of message"
,
#
"description": "Type of message",
"example"
:
"platform_status"
,
#
"example": "platform_status",
},
#
},
"version"
:
{
#
"version": {
"type"
:
"number"
,
#
"type": "number",
"format"
:
"float"
,
#
"format": "float",
"description"
:
"Version of comms backbone message format protocol"
,
#
"description": "Version of comms backbone message format protocol",
"example"
:
2.0
,
#
"example": 2.0,
},
#
},
"source"
:
{
#
"source": {
"type"
:
"string"
,
#
"type": "string",
"description"
:
"The sender; Where is this message from"
,
#
"description": "The sender; Where is this message from",
"example"
:
"autonomy_engine"
,
#
"example": "autonomy_engine",
},
#
},
"destination"
:
{
#
"destination": {
"type"
:
"string"
,
#
"type": "string",
"description"
:
"Publisher topic; What is the destination"
#
"description": "Publisher topic; What is the destination"
+
" of this message"
,
#
+ " of this message",
"example"
:
"ah1"
,
#
"example": "ah1",
},
#
},
"encoded"
:
{
#
"encoded": {
"type"
:
"boolean"
,
#
"type": "boolean",
"description"
:
"Indicate that message raw (encoded) or decoded. "
#
"description": "Indicate that message raw (encoded) or decoded. "
+
"Options: encoded=True, decoded=False"
,
#
+ "Options: encoded=True, decoded=False",
"example"
:
False
,
#
"example": False,
},
#
},
"delivery_type"
:
{
#
"delivery_type": {
"type"
:
"string"
,
#
"type": "string",
"description"
:
"To publish or broadcast this message."
,
#
"description": "To publish or broadcast this message.",
"enum"
:
[
"broadcast"
,
"publish"
],
#
"enum": ["broadcast", "publish"],
"example"
:
"publish"
,
#
"example": "publish",
"default"
:
"publish"
,
#
"default": "publish",
},
#
},
},
#
},
"required"
:
[
"message_type"
],
#
"required": ["message_type"],
}
#
}
This diff is collapsed.
Click to expand it.
formats/mission_plan.py
View file @
bc7486ed
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
sent to the respective platform's C2 to compile into a platform-specific
sent to the respective platform's C2 to compile into a platform-specific
mission plan.
mission plan.
"""
"""
from
formats
import
abstract_schema
action_schema
=
{
action_schema
=
{
"type"
:
"object"
,
"type"
:
"object"
,
...
@@ -63,7 +64,6 @@ action_schema = {
...
@@ -63,7 +64,6 @@ action_schema = {
}
}
mission_plan_schema
=
{
mission_plan_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"autonomy_engine_plan_ID"
:
{
"autonomy_engine_plan_ID"
:
{
...
@@ -84,3 +84,6 @@ mission_plan_schema = {
...
@@ -84,3 +84,6 @@ mission_plan_schema = {
},
},
"required"
:
[
"plan_ID"
,
"platform_ID"
,
"plan"
],
"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 @@
...
@@ -2,6 +2,7 @@
schema: Observation Message sent by platforms when points of
schema: Observation Message sent by platforms when points of
interest are found.
interest are found.
"""
"""
from
formats
import
abstract_schema
hits_schema
=
{
hits_schema
=
{
"type"
:
"object"
,
"type"
:
"object"
,
...
@@ -30,7 +31,9 @@ hits_schema = {
...
@@ -30,7 +31,9 @@ hits_schema = {
}
}
observation_schema
=
{
observation_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"payload"
:
{
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"platform_ID"
:
{
"platform_ID"
:
{
...
@@ -45,7 +48,8 @@ observation_schema = {
...
@@ -45,7 +48,8 @@ observation_schema = {
+
" platform if any found."
,
# TODO: DEFINE FORMAT.
+
" platform if any found."
,
# TODO: DEFINE FORMAT.
},
},
"region_surveyed"
:
{
"region_surveyed"
:
{
"type"
:
"null"
,
# "type": "null",
"nullable"
:
True
,
"description"
:
"Region surveyed by given platform."
"description"
:
"Region surveyed by given platform."
+
" GEOJSON"
,
# TODO: DEFINE FORMAT.
+
" GEOJSON"
,
# TODO: DEFINE FORMAT.
"example"
:
""
,
"example"
:
""
,
...
@@ -55,5 +59,10 @@ observation_schema = {
...
@@ -55,5 +59,10 @@ observation_schema = {
"example"
:
{
"sensor_payload"
:
False
},
"example"
:
{
"sensor_payload"
:
False
},
},
},
},
},
},
},
"required"
:
[
"platform_ID"
],
"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 @@
...
@@ -2,6 +2,7 @@
schemas: configuration sent to Autonomy Engine (i.e. during an emergency,
schemas: configuration sent to Autonomy Engine (i.e. during an emergency,
if a platform needs to be removed from the mission planning)
if a platform needs to be removed from the mission planning)
"""
"""
from
formats
import
abstract_schema
emergency_schema
=
{
emergency_schema
=
{
"type"
:
"object"
,
"type"
:
"object"
,
...
@@ -157,7 +158,6 @@ squad_metadata_schema = {
...
@@ -157,7 +158,6 @@ squad_metadata_schema = {
}
}
planning_configuration_schema
=
{
planning_configuration_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"planning_config_ID"
:
{
"planning_config_ID"
:
{
...
@@ -182,3 +182,6 @@ planning_configuration_schema = {
...
@@ -182,3 +182,6 @@ planning_configuration_schema = {
"exclusion_zones"
,
"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
schema: platform-specific decoded status message
"""
"""
from
formats
import
abstract_schema
sensor_schema
=
{
sensor_schema
=
{
"type"
:
"object"
,
"type"
:
"object"
,
"description"
:
"Scanning sensor on platform available"
"description"
:
"Scanning sensor on platform available"
...
@@ -26,7 +28,6 @@ sensor_schema = {
...
@@ -26,7 +28,6 @@ sensor_schema = {
}
}
platform_status_message_schema
=
{
platform_status_message_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/components/schemas/Message"
}],
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"platform_ID"
:
{
"platform_ID"
:
{
...
@@ -41,6 +42,14 @@ platform_status_message_schema = {
...
@@ -41,6 +42,14 @@ platform_status_message_schema = {
+
" platform or USBL"
,
+
" platform or USBL"
,
"example"
:
"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"
:
{
"platform_timestamp"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"format"
:
"date-time"
,
"format"
:
"date-time"
,
...
@@ -173,3 +182,7 @@ platform_status_message_schema = {
...
@@ -173,3 +182,7 @@ platform_status_message_schema = {
"longitude"
,
"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
import
message_
metadat
a
from
formats.mission_plan
import
mission_plan_schema
from
formats.mission_plan
import
full_
mission_plan_schema
from
formats.observation
import
observation_schema
from
formats.observation
import
full_
observation_schema
from
formats.planning_configuration
import
planning_configuration_schema
from
formats.planning_configuration
import
full_
planning_configuration_schema
from
formats.platform_status
import
platform_status_message_schema
from
formats.platform_status
import
full_
platform_status_message_schema
from
formats.acknowledgement
import
acknowledgement_schema
from
formats.acknowledgement
import
full_
acknowledgement_schema
from
flasgger
import
Swagger
from
flasgger
import
Swagger
from
flask
import
Flask
from
flask
import
Flask
...
@@ -28,15 +28,15 @@ swagger_config = {
...
@@ -28,15 +28,15 @@ swagger_config = {
"model_filter"
:
lambda
tag
:
True
,
"model_filter"
:
lambda
tag
:
True
,
}
}
],
],
"components"
:
{
#
"components": {
"
schema
s"
:
{
"
definition
s"
:
{
"Message"
:
message_wrapper_schem
a
,
"Metadata"
:
message_metadat
a
,
"MissionPlan"
:
mission_plan_schema
,
"MissionPlan"
:
full_
mission_plan_schema
,
"Observation"
:
observation_schema
,
"Observation"
:
full_
observation_schema
,
"PlanningConfiguration"
:
planning_configuration_schema
,
"PlanningConfiguration"
:
full_
planning_configuration_schema
,
"PlatformStatus"
:
platform_status_message_schema
,
"PlatformStatus"
:
full_
platform_status_message_schema
,
"Acknowledgement"
:
acknowledgement_schema
,
"Acknowledgement"
:
full_
acknowledgement_schema
,
}
#
}
},
},
"paths"
:
{
"paths"
:
{
"/all_messages"
:
{
"/all_messages"
:
{
...
@@ -49,26 +49,30 @@ swagger_config = {
...
@@ -49,26 +49,30 @@ swagger_config = {
"application/json"
:
{
"application/json"
:
{
"schema"
:
{
"schema"
:
{
"oneOf"
:
[
"oneOf"
:
[
{
full_mission_plan_schema
,
"$ref"
:
"#/components/schemas/"
full_planning_configuration_schema
,
+
"Acknowledgement"
full_platform_status_message_schema
,
},
full_observation_schema
,
{
# {
"$ref"
:
"#/components/schemas/"
# "$ref": "#/definitions/"
+
"MissionPlan"
# + "Acknowledgement"
},
# },
{
# {
"$ref"
:
"#/components/schemas/"
# "$ref": "#/definitions/"
+
"Observation"
# + "MissionPlan"
},
# },
{
# {
"$ref"
:
"#/components/schemas/"
# "$ref": "#/definitions/"
+
"PlanningConfiguration"
# + "Observation"
},
# },
{
# {
"$ref"
:
"#/components/schemas/"
# "$ref": "#/definitions/"
+
"PlatformStatus"
# + "PlanningConfiguration"
},
# },
# {
# "$ref": "#/definitions/"
# + "PlatformStatus"
# },
],
],
"discriminator"
:
{
"discriminator"
:
{
"propertyName"
:
"message_type"
,
"propertyName"
:
"message_type"
,
...
@@ -85,8 +89,8 @@ swagger_config = {
...
@@ -85,8 +89,8 @@ swagger_config = {
"consumes"
:
[
"application/json"
],
"consumes"
:
[
"application/json"
],
}
}
message_types
=
[
message_types
=
[
"Me
ssage
"
,
"Me
tadata
"
,
"Acknowledgement"
,
#
"Acknowledgement",
"MissionPlan"
,
"MissionPlan"
,
"Observation"
,
"Observation"
,
"PlanningConfiguration"
,
"PlanningConfiguration"
,
...
@@ -104,7 +108,7 @@ for item in message_types:
...
@@ -104,7 +108,7 @@ for item in message_types:
"schema"
:
{
"schema"
:
{
"allOf"
:
[
"allOf"
:
[
{
{
"$ref"
:
"#/
components/schema
s/"
+
item
,
"$ref"
:
"#/
definition
s/"
+
item
,
},
},
],
],
"discriminator"
:
{
"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