eive-tmtc/tmtc/power/common_power.py

158 lines
4.9 KiB
Python
Raw Normal View History

2022-08-11 18:10:15 +02:00
from gomspace.gomspace_common import (
pack_set_param_command,
Channel,
GomspaceOpCodes,
GsInfo,
2022-08-24 11:24:25 +02:00
GomspaceDeviceActionIds,
prompt_and_pack_set_param_command,
prompt_and_pack_get_param_command,
pack_request_config_command,
2022-08-11 18:10:15 +02:00
)
2022-08-11 15:40:38 +02:00
from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST
2022-08-11 18:10:15 +02:00
from tmtccmd.config import OpCodeEntry
2022-08-11 15:40:38 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2022-08-11 18:10:15 +02:00
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
generate_one_hk_command,
)
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
from tmtccmd.util import ObjectIdU32
2022-08-11 18:10:15 +02:00
class PowerInfo:
INFO_CORE = "Core Information"
INFO_AUX = "Auxiliary Information"
INFO_ALL = "All Information"
2022-08-11 15:40:38 +02:00
class PowerOpCodes:
# PDU 1
TCS_ON = ["tcs-on"]
TCS_OFF = ["tcs-off"]
SYRLINKS_ON = ["syrlinks-on"]
SYRLINKS_OFF = ["syrlinks-off"]
STAR_TRACKER_ON = ["str-on"]
STAR_TRACKER_OFF = ["str-off"]
MGT_ON = ["mgt-on"]
MGT_OFF = ["mgt-off"]
2022-08-11 18:10:15 +02:00
SUS_N_ON = ["sus-nom-on"]
SUS_N_OFF = ["sus-nom-off"]
SCEX_ON = ["scex-on"]
SCEX_OFF = ["scex-off"]
2022-08-11 15:40:38 +02:00
PLOC_ON = ["ploc-on"]
PLOC_OFF = ["ploc-off"]
ACS_A_ON = ["acs-a-on"]
ACS_A_OFF = ["acs-a-off"]
# PDU 2
PL_PCDU_VBAT_NOM_ON = ["plpcdu-vbat-nom-on"]
PL_PCDU_VBAT_NOM_OFF = ["plpcdu-vbat-nom-off"]
RW_ON = ["rw-on"]
RW_OFF = ["rw-off"]
HEATER_ON = ["heater-on"]
HEATER_OFF = ["heater-off"]
SUS_R_ON = ["sus-red-on"]
SUS_R_OFF = ["sus-red-off"]
SOLAR_ARRAY_DEPL_ON = ["sa-depl-on"]
SOLAR_ARRAY_DEPL_OFF = ["sa-depl-off"]
PL_PCDU_VBAT_RED_ON = ["plpcdu-vbat-red-on"]
PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbat-red-off"]
ACS_B_ON = ["acs-b-on"]
ACS_B_OFF = ["acs-b-off"]
2022-08-11 18:10:15 +02:00
PL_CAM_ON = ["cam-on"]
PL_CAM_OFF = ["cam-off"]
2022-08-11 15:40:38 +02:00
INFO_CORE = ["info"]
INFO_AUX = ["info-aux"]
INFO_ALL = ["info-all"]
def add_gomspace_cmds(
prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
objb = object_id.as_bytes
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
q.add_log_cmd(f"{prefix}: {GsInfo.PRINT_SWITCH_V_I}")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
)
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
q.add_log_cmd(f"{prefix}: {GsInfo.PRINT_LATCHUPS}")
q.add_pus_tc(
make_fsfw_action_cmd(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
)
if op_code in GomspaceOpCodes.SET_PARAM:
q.add_log_cmd(f"{prefix}: {GsInfo.SET_PARAMETER}")
prompt_and_pack_set_param_command(q, object_id)
if op_code in GomspaceOpCodes.GET_PARAM:
q.add_log_cmd(f"{prefix}: {GsInfo.GET_PARAMETER}")
prompt_and_pack_get_param_command(q, object_id)
if op_code in GomspaceOpCodes.REQUEST_CONFIG_TABLE:
q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_CONFIG_TABLE}")
q.add_pus_tc(pack_request_config_command(object_id.as_bytes))
2022-08-27 16:28:33 +02:00
def req_hk_cmds(
prefix: str,
q: DefaultPusQueueHelper,
op_code: str,
obj_id: bytes,
set_id_pair: [int, int],
):
2022-08-11 18:10:15 +02:00
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
2022-08-27 16:28:33 +02:00
q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_CORE_HK_ONCE}")
hk_sid = make_sid(object_id=obj_id, set_id=set_id_pair[0])
2022-08-11 18:10:15 +02:00
q.add_pus_tc(generate_one_diag_command(sid=hk_sid))
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
2022-08-27 16:28:33 +02:00
q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_AUX_HK_ONCE}")
hk_sid = make_sid(object_id=obj_id, set_id=set_id_pair[1])
2022-08-11 18:10:15 +02:00
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
2022-08-11 15:40:38 +02:00
def generic_on_cmd(
2022-08-11 18:10:15 +02:00
object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int
2022-08-11 15:40:38 +02:00
):
2022-08-11 18:10:15 +02:00
q.add_log_cmd(info_str + " on")
2022-08-11 15:40:38 +02:00
q.add_pus_tc(
pack_set_param_command(
2022-08-11 18:10:15 +02:00
object_id,
2022-08-11 15:40:38 +02:00
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
Channel.on,
)
)
def generic_off_cmd(
2022-08-11 18:10:15 +02:00
object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int
2022-08-11 15:40:38 +02:00
):
2022-08-11 18:10:15 +02:00
q.add_log_cmd(info_str + " off")
2022-08-11 15:40:38 +02:00
q.add_pus_tc(
pack_set_param_command(
2022-08-11 18:10:15 +02:00
object_id,
2022-08-11 15:40:38 +02:00
PDU_CONFIG_LIST[out_idx].parameter_address,
PDU_CONFIG_LIST[out_idx].parameter_size,
Channel.off,
)
)
2022-08-24 11:19:49 +02:00
def add_gomspace_cmd_defs(oce: OpCodeEntry):
oce.add(
keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE,
info=GsInfo.REQUEST_CORE_HK_ONCE,
)
oce.add(
keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE,
info=GsInfo.REQUEST_AUX_HK_ONCE,
)
oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER)
oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info=GsInfo.PRINT_LATCHUPS)
oce.add(keys=GomspaceOpCodes.SET_PARAM, info=GsInfo.SET_PARAMETER)
oce.add(keys=GomspaceOpCodes.REQUEST_CONFIG_TABLE, info=GsInfo.REQUEST_CONFIG_TABLE)