__init__.py 2.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
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"
]

message_types = [
    "platform_status",
    "mission_plan_ecosub",
    "mission_plan_reav",
    "mission_plan_autosub",
]  # TODO: Add full range of message types once scoped out

message_header_schema = api.model(
    "MessageHeader",
    {
        "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",
            example="platform_status",
        ),
        # "payload":# TODO: schema applicable changes according to "type"
    },
)

platform_schema = api.model(
    "PlatformSchema",
    {
        "platform_ID": fields.Integer(
            required=True,
            description="unique identifier for platform",
            example="ah-1",
        ),
        "serial": fields.Integer(
            required=True,
            description="platform serial number",
            example="ah-1",
        ),
        "model": fields.Integer(
            required=True,
            description="platform serial number",
            example="ah-1",
        ),
        "active": fields.Boolean(
            required=False,
            description="platform in mission",
            example=True,
        ),
    },
)
# TODO: Add generic positions schema
# TODO: Define units for all schemas