eive-tmtc/pus_tc/system/tcs.py

80 lines
2.3 KiB
Python
Raw Normal View History

2022-08-11 19:18:01 +02:00
import enum
2022-08-12 08:45:51 +02:00
from config.definitions import CustomServiceList
from tmtccmd.config import TmTcDefWrapper, OpCodeEntry
2022-08-12 10:04:08 +02:00
from tmtccmd.config.tmtc import register_tmtc_definitions
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_modes import Modes
2022-08-11 19:18:01 +02:00
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
generate_one_hk_command,
)
2022-03-22 19:29:55 +01:00
from .common import command_mode
2022-08-11 19:18:01 +02:00
from config.object_ids import TCS_BOARD_ASS_ID, TCS_CONTROLLER
2022-03-22 19:29:55 +01:00
class OpCodes:
TCS_BOARD_ASS_NORMAL = ["0", "tcs-normal"]
TCS_BOARD_ASS_OFF = ["1", "tcs-off"]
2022-08-12 08:45:51 +02:00
REQUEST_SENSOR_TEMP_SET = ["2", "temp-hk"]
2022-03-22 19:29:55 +01:00
class Info:
2022-08-11 19:18:01 +02:00
REQUEST_SENSOR_TEMP_SET = "Request HK set of primary sensor temperatures"
2022-03-22 19:29:55 +01:00
TCS_BOARD_ASS_NORMAL = "Switching TCS board assembly on"
TCS_BOARD_ASS_OFF = "Switching TCS board assembly off"
2022-08-11 19:18:01 +02:00
class SetIds(enum.IntEnum):
PRIMARY_SENSORS = 0
DEVICE_SENSORS = 1
SUS_TEMP_SENSORS = 2
2022-08-12 10:04:08 +02:00
@register_tmtc_definitions
2022-08-12 08:45:51 +02:00
def add_tcs_cmds(defs: TmTcDefWrapper):
oce = OpCodeEntry()
oce.add(
keys=OpCodes.TCS_BOARD_ASS_NORMAL,
info=Info.TCS_BOARD_ASS_NORMAL,
)
oce.add(
keys=OpCodes.TCS_BOARD_ASS_OFF,
info=Info.TCS_BOARD_ASS_OFF,
)
oce.add(keys=OpCodes.REQUEST_SENSOR_TEMP_SET, info=Info.REQUEST_SENSOR_TEMP_SET)
defs.add_service(
name=CustomServiceList.TCS.value,
info="TCS Board Assembly",
op_code_entry=oce,
)
2022-08-08 16:32:18 +02:00
def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str):
2022-08-12 08:45:51 +02:00
if op_code in OpCodes.REQUEST_SENSOR_TEMP_SET:
2022-08-11 19:18:01 +02:00
sensor_set_sid = make_sid(TCS_CONTROLLER, SetIds.PRIMARY_SENSORS)
q.add_log_cmd(Info.REQUEST_SENSOR_TEMP_SET)
q.add_pus_tc(generate_one_hk_command(sensor_set_sid))
2022-08-12 08:45:51 +02:00
pack_tcs_ass_cmds(q, op_code)
def pack_tcs_ass_cmds(q: DefaultPusQueueHelper, op_code: str):
2022-03-22 19:29:55 +01:00
if op_code in OpCodes.TCS_BOARD_ASS_NORMAL:
command_mode(
2022-03-22 19:29:55 +01:00
object_id=TCS_BOARD_ASS_ID,
mode=Modes.NORMAL,
submode=0,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 19:29:55 +01:00
info=Info.TCS_BOARD_ASS_NORMAL,
)
if op_code in OpCodes.TCS_BOARD_ASS_OFF:
command_mode(
2022-03-22 19:29:55 +01:00
object_id=TCS_BOARD_ASS_ID,
2022-03-22 20:35:24 +01:00
mode=Modes.OFF,
2022-03-22 19:29:55 +01:00
submode=0,
2022-07-04 17:59:09 +02:00
q=q,
2022-03-22 19:29:55 +01:00
info=Info.TCS_BOARD_ASS_OFF,
)