2024-04-28 12:39:34 +02:00
|
|
|
import enum
|
2024-04-30 19:45:00 +02:00
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from spacepackets.ecss import PusTc
|
|
|
|
from tmtccmd.config import CmdTreeNode
|
2024-04-28 12:39:34 +02:00
|
|
|
from pydantic import BaseModel
|
2024-04-30 19:45:00 +02:00
|
|
|
from tmtccmd.tmtc import DefaultPusQueueHelper
|
|
|
|
|
|
|
|
from opssat_tmtc.common import EXPERIMENT_APID, UniqueId, make_action_cmd_header
|
2024-04-28 12:39:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ActionId(enum.IntEnum):
|
|
|
|
DEFAULT_SINGLE = 1
|
|
|
|
BALANCED_SINGLE = 2
|
|
|
|
DEFAULT_SINGLE_FLATSAT = 3
|
|
|
|
BALANCED_SNGLE_FLATSAT = 4
|
|
|
|
CUSTOM_PARAMS = 5
|
|
|
|
|
|
|
|
|
|
|
|
class CameraParameters(BaseModel):
|
|
|
|
R: int
|
|
|
|
G: int
|
|
|
|
B: int
|
|
|
|
N: int
|
|
|
|
P: bool
|
|
|
|
E: int
|
|
|
|
W: int
|
2024-04-30 19:45:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
def create_camera_node() -> CmdTreeNode:
|
|
|
|
cam_node = CmdTreeNode("cam", "OPS-SAT IMS1000 batch handler commands")
|
|
|
|
cam_node.add_child(
|
|
|
|
CmdTreeNode("default_single", "Default Single Image Camera Parameters")
|
|
|
|
)
|
|
|
|
cam_node.add_child(
|
|
|
|
CmdTreeNode("balanced_single", "Balanced Single Image Camera Parameters")
|
|
|
|
)
|
|
|
|
cam_node.add_child(
|
|
|
|
CmdTreeNode(
|
|
|
|
"default_single_flatsat",
|
|
|
|
"Default Single Image Camera Parameters for use on FlatSat",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
cam_node.add_child(
|
|
|
|
CmdTreeNode(
|
|
|
|
"balanced_single_flatsat",
|
|
|
|
"Balanced Single Image Camera Parameters for use on FlatSat",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
cam_node.add_child(
|
|
|
|
CmdTreeNode("custom_params", "Custom Camera Parameters as specified from file")
|
|
|
|
)
|
|
|
|
return cam_node
|
|
|
|
|
|
|
|
|
|
|
|
def create_cam_cmd(q: DefaultPusQueueHelper, cmd_path: List[str]):
|
|
|
|
|
|
|
|
assert len(cmd_path) >= 1
|
|
|
|
q.add_log_cmd(
|
|
|
|
"Sending PUS take image action request for command " + cmd_path[0] + " params."
|
|
|
|
)
|
|
|
|
data = bytearray()
|
|
|
|
if cmd_path[0] == "default_single":
|
|
|
|
data.extend(
|
|
|
|
make_action_cmd_header(UniqueId.CameraHandler, ActionId.DEFAULT_SINGLE)
|
|
|
|
)
|
|
|
|
elif cmd_path[0] == "balanced_single":
|
|
|
|
data.extend(
|
|
|
|
make_action_cmd_header(UniqueId.CameraHandler, ActionId.BALANCED_SINGLE)
|
|
|
|
)
|
|
|
|
elif cmd_path[0] == "default_single_flatsat":
|
|
|
|
data.extend(
|
|
|
|
make_action_cmd_header(
|
|
|
|
UniqueId.CameraHandler, ActionId.DEFAULT_SINGLE_FLATSAT
|
|
|
|
)
|
|
|
|
)
|
|
|
|
elif cmd_path[0] == "balanced_single_flatsat":
|
|
|
|
data.extend(
|
|
|
|
make_action_cmd_header(
|
|
|
|
UniqueId.CameraHandler, ActionId.BALANCED_SNGLE_FLATSAT
|
|
|
|
)
|
|
|
|
)
|
|
|
|
elif cmd_path[0] == "custom":
|
|
|
|
data.extend(
|
|
|
|
make_action_cmd_header(UniqueId.CameraHandler, ActionId.CUSTOM_PARAMS)
|
|
|
|
)
|
|
|
|
# TODO: Implement asking params from user.
|
|
|
|
|
|
|
|
# params = CameraParameters(8, 8, 8, 1, True, 200, 1000)
|
|
|
|
# data.extend(params.model_dump_json().encode())
|
|
|
|
raise NotImplementedError()
|
|
|
|
else:
|
|
|
|
raise ValueError("unknown camera action {}", cmd_path[0])
|
|
|
|
return q.add_pus_tc(
|
|
|
|
PusTc(service=8, subservice=128, apid=EXPERIMENT_APID, app_data=data)
|
|
|
|
)
|