eive-tmtc/eive_tmtc/tmtc/power/power.py

133 lines
4.7 KiB
Python
Raw Normal View History

2023-01-24 13:06:08 +01:00
import enum
2023-02-01 11:17:04 +01:00
import logging
2023-01-24 13:06:08 +01:00
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.power.common_power import (
2022-08-11 18:10:15 +02:00
PowerOpCodes,
PowerInfo,
add_gomspace_cmd_defs,
2022-08-31 21:15:31 +02:00
pack_reset_gnd_wdt_cmd,
2022-08-11 18:10:15 +02:00
)
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import (
2022-08-31 21:15:31 +02:00
P60_DOCK_HANDLER,
ACU_HANDLER_ID,
PDU_1_HANDLER_ID,
PDU_2_HANDLER_ID,
get_object_ids,
)
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.power.pdu1 import (
2022-10-18 10:44:32 +02:00
pdu1_req_hk_cmds,
2022-10-18 11:01:01 +02:00
pdu1_switch_cmds,
2022-10-18 10:44:32 +02:00
add_pdu1_common_defs,
add_pdu1_cmds,
)
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.power.pdu2 import (
2022-10-18 10:44:32 +02:00
pdu2_req_hk_cmds,
add_pdu2_common_defs,
2023-01-24 13:06:08 +01:00
pdu2_switch_cmds,
2022-10-18 10:44:32 +02:00
add_pdu2_cmds,
)
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
2022-12-22 16:12:31 +01:00
from eive_tmtc.config.object_ids import PCDU_HANDLER_ID
2022-08-11 15:40:38 +02:00
2023-01-16 14:13:06 +01:00
from eive_tmtc.tmtc.power.p60dock import P60OpCode, P60Info, p60_dock_req_hk_cmds
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.power.acu import add_acu_cmds, acu_req_hk_cmds
from tmtccmd.tc.pus_3_fsfw_hk import (
create_request_one_diag_command,
make_sid,
create_request_one_hk_command,
)
from tmtccmd.config.tmtc import tmtc_definitions_provider
2022-08-18 11:09:35 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2023-01-24 13:06:08 +01:00
class SetId(enum.IntEnum):
SWITCHER_SET = 0
2022-08-18 11:09:35 +02:00
2023-02-27 14:57:57 +01:00
class PcduSetIds(enum.IntEnum):
2022-12-22 16:12:31 +01:00
SWITCHER_SET = 0
2022-08-18 11:09:35 +02:00
def pack_power_commands(q: DefaultPusQueueHelper, op_code: str):
2022-10-18 11:01:01 +02:00
pdu1_switch_cmds(q, op_code)
2023-01-24 13:06:08 +01:00
pdu2_switch_cmds(q, op_code)
2022-12-22 16:12:31 +01:00
if op_code in PowerOpCodes.SWITCHER_HK:
q.add_log_cmd("Requesting switcher state HK")
q.add_pus_tc(
2023-02-14 16:16:20 +01:00
create_request_one_diag_command(
make_sid(PCDU_HANDLER_ID, PcduSetIds.SWITCHER_SET)
)
2022-12-22 16:12:31 +01:00
)
2022-08-18 11:09:35 +02:00
if op_code in PowerOpCodes.INFO_CORE:
2022-10-18 10:44:32 +02:00
pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
acu_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
2022-08-29 13:20:44 +02:00
q.add_wait_seconds(8.0)
2022-08-18 11:09:35 +02:00
elif op_code in PowerOpCodes.INFO_AUX:
2022-10-18 10:44:32 +02:00
pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
acu_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
2022-08-29 13:20:44 +02:00
q.add_wait_seconds(8.0)
2022-08-18 11:09:35 +02:00
elif op_code in PowerOpCodes.INFO_ALL:
2022-10-18 10:44:32 +02:00
pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
acu_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0])
acu_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0])
2022-08-29 13:20:44 +02:00
q.add_wait_seconds(8.0)
2022-08-31 21:15:31 +02:00
elif op_code in PowerOpCodes.RESET_ALL_GND_WDTS:
oids = get_object_ids()
pack_reset_gnd_wdt_cmd(q, "P60 Dock", oids[P60_DOCK_HANDLER])
pack_reset_gnd_wdt_cmd(q, "ACU", oids[ACU_HANDLER_ID])
pack_reset_gnd_wdt_cmd(q, "PDU1", oids[PDU_1_HANDLER_ID])
pack_reset_gnd_wdt_cmd(q, "PDU2", oids[PDU_2_HANDLER_ID])
2022-08-31 22:48:23 +02:00
q.add_wait_seconds(5.0)
2022-08-18 11:09:35 +02:00
if q.empty():
2023-02-01 15:58:34 +01:00
logging.getLogger(__name__).info(
f"Queue is empty, no stack for op code {op_code}"
)
2022-08-11 15:40:38 +02:00
@tmtc_definitions_provider
def add_p60_cmds(defs: TmtcDefinitionWrapper):
2022-08-11 15:40:38 +02:00
oce = OpCodeEntry()
2023-01-16 14:13:06 +01:00
oce.add(keys=P60OpCode.STACK_3V3_ON, info=P60Info.STACK_3V3_ON)
oce.add(keys=P60OpCode.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF)
oce.add(keys=P60OpCode.STACK_5V_ON, info=P60Info.STACK_5V_ON)
oce.add(keys=P60OpCode.STACK_5V_OFF, info=P60Info.STACK_5V_OFF)
add_gomspace_cmd_defs(oce)
2023-01-16 14:13:06 +01:00
oce.add(keys=P60OpCode.TEST, info="P60 Tests")
2022-08-11 15:40:38 +02:00
defs.add_service(
name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce
)
2022-08-11 14:45:24 +02:00
@tmtc_definitions_provider
def add_power_cmd_defs(defs: TmtcDefinitionWrapper):
2022-08-11 18:10:15 +02:00
oce = OpCodeEntry()
add_pdu1_common_defs(oce)
add_pdu2_common_defs(oce)
2022-12-22 16:12:31 +01:00
oce.add(keys=PowerOpCodes.SWITCHER_HK, info=PowerInfo.SWITCHER_HK)
2022-08-11 18:10:15 +02:00
oce.add(keys=PowerOpCodes.INFO_ALL, info=PowerInfo.INFO_ALL)
oce.add(keys=PowerOpCodes.INFO_CORE, info=PowerInfo.INFO_CORE)
oce.add(keys=PowerOpCodes.INFO_AUX, info=PowerInfo.INFO_AUX)
2022-08-31 21:15:31 +02:00
oce.add(keys=PowerOpCodes.RESET_ALL_GND_WDTS, info=PowerInfo.RESET_ALL_GND_WDTS)
2022-08-11 18:10:15 +02:00
defs.add_service(
name=CustomServiceList.POWER.value,
info="Power Subsystem",
op_code_entry=oce,
)
def add_pcdu_cmds(defs: TmtcDefinitionWrapper):
2022-08-11 15:40:38 +02:00
add_p60_cmds(defs)
add_pdu1_cmds(defs)
add_pdu2_cmds(defs)
add_acu_cmds(defs)