eive-tmtc/eive_tmtc/pus_tc/system/tcs.py

79 lines
2.3 KiB
Python
Raw Normal View History

2022-08-11 19:18:01 +02:00
import enum
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
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_hk_command,
)
2022-03-22 19:29:55 +01:00
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
from eive_tmtc.config.object_ids import TCS_BOARD_ASS_ID, TCS_CONTROLLER
2022-03-22 19:29:55 +01:00
2023-01-16 14:13:06 +01:00
class OpCode:
2022-09-30 14:22:13 +02:00
TCS_BOARD_ASS_NORMAL = ["0", "normal"]
TCS_BOARD_ASS_OFF = ["1", "off"]
REQUEST_SENSOR_TEMP_SET = ["2", "temps"]
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"
2023-01-16 14:13:06 +01:00
class SetId(enum.IntEnum):
2022-08-11 19:18:01 +02:00
PRIMARY_SENSORS = 0
DEVICE_SENSORS = 1
SUS_TEMP_SENSORS = 2
@tmtc_definitions_provider
def add_tcs_cmds(defs: TmtcDefinitionWrapper):
2022-08-12 08:45:51 +02:00
oce = OpCodeEntry()
oce.add(
2023-01-16 14:13:06 +01:00
keys=OpCode.TCS_BOARD_ASS_NORMAL,
2022-08-12 08:45:51 +02:00
info=Info.TCS_BOARD_ASS_NORMAL,
)
oce.add(
2023-01-16 14:13:06 +01:00
keys=OpCode.TCS_BOARD_ASS_OFF,
2022-08-12 08:45:51 +02:00
info=Info.TCS_BOARD_ASS_OFF,
)
2023-01-16 14:13:06 +01:00
oce.add(keys=OpCode.REQUEST_SENSOR_TEMP_SET, info=Info.REQUEST_SENSOR_TEMP_SET)
2022-08-12 08:45:51 +02:00
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):
2023-01-16 14:13:06 +01:00
if op_code in OpCode.REQUEST_SENSOR_TEMP_SET:
sensor_set_sid = make_sid(TCS_CONTROLLER, SetId.PRIMARY_SENSORS)
2022-08-11 19:18:01 +02:00
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):
2023-01-16 14:13:06 +01:00
if op_code in OpCode.TCS_BOARD_ASS_NORMAL:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
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,
)
2023-01-16 14:13:06 +01:00
if op_code in OpCode.TCS_BOARD_ASS_OFF:
2022-10-04 14:46:00 +02:00
pack_mode_cmd_with_info(
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,
)