__init__.py 2.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
from flask_restx import fields
from . import api
import os


__all__ = [
    os.path.splitext(os.path.basename(x))[0]
    for x in os.listdir(os.path.dirname(__file__))
    if x.endswith(".py") and x != "__init__.py"
]

12 13
# TODO: Define units for all schemas

14
message_types = [
15
    "platform_status",
16 17 18 19 20
    "mission_plan_ecosub",
    "mission_plan_reav",
    "mission_plan_autosub",
]  # TODO: Add full range of message types once scoped out

21 22
full_message_schema = api.model(
    "FullMessageSchema",
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    {
        "timestamp": fields.DateTime(
            required=True,
            description="Timestamp of message",
            example="2022-11-16T00:00:00Z",
        ),
        "source": fields.String(
            required=True,
            description="Where is this message from",
            example="autonomy_engine",
        ),
        "destination": fields.String(
            required=True,
            description="What is the destination of this message",
            example="ah-1",
        ),
        "encoded": fields.Boolean(
            required=True,
            description="Indicate that message raw (encoded) or decoded. "
            + "Options: encoded=True, decoded=False",
            example=False,
        ),
        "type": fields.String(
            required=True,
            description="Type of message",
48
            example="platform_status",
49 50 51 52 53 54
        ),
        "payload": fields.Raw(
            required=True,
            description="Content of Message",
            # example="{}",
        ),
55
    },
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
)

constraints_schema = api.model(
    "ConstraintsSchema",
    {
        "min_altitude": fields.Float(
            required=True,
            description="Minimum altitude set for squad.",
            example=15.2,
        ),
        "min_velocity": fields.Float(
            required=True,
            description="Minimum velocity set for squad.",
            example=0.1,
        ),
        "max_velocity": fields.Float(
            required=True,
            description="Maximum altitude set for squad.",
            example=0.9,
75 76 77 78
        ),
    },
)

79 80
platform_schema = api.model(
    "PlatformSchema",
81
    {
82
        "platform_ID": fields.Integer(
83
            required=True,
84
            description="unique identifier for platform",
85 86 87 88
            example="ah-1",
        ),
        "serial": fields.Integer(
            required=True,
89
            description="platform serial number",
90 91 92 93
            example="ah-1",
        ),
        "model": fields.Integer(
            required=True,
94
            description="platform serial number",
95 96
            example="ah-1",
        ),
97
        "constraints": fields.Nested(constraints_schema),
98 99
        "active": fields.Boolean(
            required=False,
100
            description="When a platform is in deployment (executing a mission plan) this should be True",
101 102 103 104
            example=True,
        ),
    },
)