""" schemas: configuration sent to Autonomy Engine (i.e. during an emergency, if a platform needs to be removed from the mission planning) """ # from . import api, full_message_schema, platform_schema # from flask_restx import fields emergency_schema = { "type": "object", "properties": { "safe_command": { "type": "string", "enum": ["go_home", "abort_now", "stop_mission"], "description": "Command/Action that is native to respective" + " partner's platform/C2", "example": "go_home", }, "latitude_waypoint": { "type": "number", "description": "X-coordinate safe place for respective platform", "example": -7.432, }, "longitude_waypoint": { "type": "number", "description": "Y-coordinate safe place for respective platform", "example": 50.365, }, "target_depth": { "type": "number", "description": "Z-coordinate safe place for respective platform" + " . If platform to NOT stay at depth, key in `0.0`", "example": 10, }, "additional_data": { "type": "null", "description": "Any addition fields/data to be added here", "example": {}, }, }, "required": ["latitude_waypoint", "longitude_waypoint", "target_depth"], } platform_schema = { "type": "object", "properties": { "platform_ID": { "type": "integer", "description": "Identifier for platform", "example": 23, }, "serial": { "type": "string", "description": "platform serial number", "example": "reav-60", }, "model": { "type": "string", "example": "reav", }, "emergency": emergency_schema, "min_altitude": { "type": "number", "description": "Minimum altitude set for squad.", "example": 15.2, }, "min_velocity": { "type": "number", "description": "Minimum velocity set for squad.", "example": 0.1, }, "max_velocity": { "type": "number", "description": "Maximum altitude set for squad.", "example": 0.9, }, "additional_data": { "type": "null", "description": "Any addition fields/data to be added here", "example": {"swath_width": 10.0, "scan_type": "DVL"}, }, }, "required": [ "platform_ID", "serial", "model", "emergency", "min_altitude", "min_velocity", "max_velocity", ], } region_schema = { "type": "object", "properties": { "geometry_coordinates": { "type": "array", # TODO: Check if config defn is right. "example": [ [ [-4.187143188645706, 50.37072283932642], [-4.202697005964865, 50.368816892405874], [-4.203156724702808, 50.365640144076906], [-4.19449868846155, 50.362267670845654], ] ], }, }, "description": "Using GEOJSON, exact 4-point region (rectangle shaped)", "required": ["geometry_coordinates"], } squad_metadata_schema = { "type": "object", "properties": { "squad_ID": { "type": "integer", "description": "Identifier of given squad", "example": 23, }, "no_of_platforms": { "type": "integer", "description": "Number of platforms", "example": 3, }, "platforms": { "type": "array", "items": platform_schema, "description": "Squad consists of these platforms", }, "squad_mission_type": { "type": "string", "enum": ["tracking", "survey", "inspection"], "description": "Mission of given squad: `tracking`, `survey`" + ", `inspection`", "example": "survey", }, "squad_state": { "type": "string", "description": "In execution, Waiting.. ", "example": False, }, "region_of_interest": region_schema, }, "required": [ "squad_ID", "no_of_platforms", "platforms", "squad_mission_type", "squad_state", "exclusion_zones", ], } planning_configuration_schema = { "allOf": [{"$ref": "#/components/schemas/Message"}], "type": "object", "properties": { "planning_config_ID": { "type": "integer", "description": "Unique identifier tagged to version of this" + " configuration plan", "example": 3, }, "exclusion_zones": { "type": "array", "items": region_schema, "description": "Exclusion zones for all platforms", }, "squads": { "type": "array", "items": squad_metadata_schema, }, }, "required": [ "config_ID", "squads", "exclusion_zones", ], } # region_schema = api.model( # "RegionSchema", # { # "region": fields.Raw( # required=True, # description="Using GEOJSON, exact region of " # + "interest in rectangle format polygon", # example={ # "type": "FeatureCollection", # "features": [ # { # "type": "Feature", # "properties": {}, # "geometry": { # "coordinates": [ # [ # [-4.187143188645706, 50.37072283932642], # [-4.202697005964865, 50.368816892405874], # [-4.203156724702808, 50.365640144076906], # [-4.19449868846155, 50.362267670845654], # ] # ], # "type": "Polygon", # }, # } # ], # }, # ), # }, # ) # squad_metadata_schema = api.model( # "SquadMetadataSchema", # { # "squad_ID": fields.Integer( # required=True, # description="Identifier of given squad", # example=23, # ), # "no_of_platforms": fields.Integer( # required=True, # description="Number of platforms", # example=3, # ), # "platforms": fields.List( # fields.Nested(platform_schema), # required=True, # description="Squad consists of these platforms", # ), # "squad_mission_type": fields.String( # required=True, # description="Mission of given squad: `tracking`, `survey`" # + ", `inspection`", # example="survey", # ), # "squad_state": fields.Boolean( # required=True, # description="In execution, Waiting.. ", # example=False, # ), # "region_of_interest": fields.List( # fields.Nested(region_schema), # required=False, # description="Region of interest and exclusion zones per squad.", # ), # "exclusion_zones": fields.List( # fields.Nested(region_schema), # required=True, # description="Exclusion zones exclusion zones per squad.", # ), # }, # ) # planning_configuration_schema = api.model( # "PlanningConfigurationSchema", # { # "message": fields.Nested( # full_message_schema, # required=True, # description="Message header", # ), # "ID": fields.Integer( # required=True, # description="Unique identifier tagged to version of this" # + " configuration plan", # example=3, # ), # "squads": fields.Nested( # squad_metadata_schema, # required=False, # description="Details of each squad", # ), # }, # )