2022-08-11 18:10:15 +02:00
|
|
|
from gomspace.gomspace_common import GsInfo
|
2022-08-25 16:14:21 +02:00
|
|
|
from tmtc.power.common_power import (
|
2022-08-11 18:10:15 +02:00
|
|
|
PowerOpCodes,
|
|
|
|
add_pdu1_common_defs,
|
|
|
|
add_pdu2_common_defs,
|
|
|
|
PowerInfo,
|
2022-08-18 11:09:35 +02:00
|
|
|
pdu1_cmds,
|
|
|
|
pdu2_cmds,
|
|
|
|
pdu1_req_hk_cmds,
|
|
|
|
pdu2_req_hk_cmds,
|
2022-08-26 23:52:47 +02:00
|
|
|
add_gomspace_cmd_defs,
|
2022-08-11 18:10:15 +02:00
|
|
|
)
|
2022-08-11 15:40:38 +02:00
|
|
|
from config.definitions import CustomServiceList
|
2022-08-18 11:09:35 +02:00
|
|
|
from tmtccmd import get_console_logger
|
2022-08-12 10:18:21 +02:00
|
|
|
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
|
2022-08-11 15:40:38 +02:00
|
|
|
|
2022-08-25 16:14:21 +02:00
|
|
|
from tmtc.power.p60dock import P60OpCodes, GomspaceOpCodes, P60Info
|
|
|
|
from tmtc.power.acu import add_acu_cmds
|
2022-08-12 10:18:21 +02:00
|
|
|
from tmtccmd.config.tmtc import tmtc_definitions_provider
|
2022-08-18 11:09:35 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
|
|
|
|
|
|
|
|
|
|
|
LOGGER = get_console_logger()
|
|
|
|
|
|
|
|
|
|
|
|
def pack_power_commands(q: DefaultPusQueueHelper, op_code: str):
|
|
|
|
pdu1_cmds(q, op_code)
|
|
|
|
pdu2_cmds(q, op_code)
|
|
|
|
if op_code in PowerOpCodes.INFO_CORE:
|
|
|
|
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
|
|
|
|
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
|
|
|
|
q.add_wait_seconds(3.0)
|
|
|
|
elif op_code in PowerOpCodes.INFO_AUX:
|
|
|
|
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
|
|
|
|
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
|
|
|
|
q.add_wait_seconds(3.0)
|
|
|
|
elif op_code in PowerOpCodes.INFO_ALL:
|
|
|
|
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
|
|
|
|
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0])
|
|
|
|
pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
|
|
|
|
pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0])
|
|
|
|
q.add_wait_seconds(3.0)
|
|
|
|
if q.empty():
|
|
|
|
LOGGER.info(f"Queue is empty, no stack for op code {op_code}")
|
2022-08-11 15:40:38 +02:00
|
|
|
|
|
|
|
|
2022-08-12 10:18:21 +02:00
|
|
|
@tmtc_definitions_provider
|
|
|
|
def add_p60_cmds(defs: TmtcDefinitionWrapper):
|
2022-08-11 15:40:38 +02:00
|
|
|
oce = OpCodeEntry()
|
2022-08-11 18:10:15 +02:00
|
|
|
oce.add(keys=P60OpCodes.STACK_3V3_ON, info=P60Info.STACK_3V3_ON)
|
|
|
|
oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF)
|
|
|
|
oce.add(keys=P60OpCodes.STACK_5V_ON, info=P60Info.STACK_5V_ON)
|
|
|
|
oce.add(keys=P60OpCodes.STACK_5V_OFF, info=P60Info.STACK_5V_OFF)
|
2022-08-26 23:52:47 +02:00
|
|
|
add_gomspace_cmd_defs(oce)
|
2022-08-11 15:40:38 +02:00
|
|
|
oce.add(keys=P60OpCodes.TEST, info="P60 Tests")
|
|
|
|
defs.add_service(
|
|
|
|
name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce
|
|
|
|
)
|
2022-08-11 14:45:24 +02:00
|
|
|
|
|
|
|
|
2022-08-12 10:18:21 +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)
|
|
|
|
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)
|
|
|
|
defs.add_service(
|
|
|
|
name=CustomServiceList.POWER.value,
|
|
|
|
info="Power Subsystem",
|
|
|
|
op_code_entry=oce,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-08-12 10:18:21 +02:00
|
|
|
@tmtc_definitions_provider
|
|
|
|
def add_pdu1_cmds(defs: TmtcDefinitionWrapper):
|
2022-08-11 15:40:38 +02:00
|
|
|
oce = OpCodeEntry()
|
2022-08-11 18:10:15 +02:00
|
|
|
add_pdu1_common_defs(oce)
|
2022-08-26 23:52:47 +02:00
|
|
|
add_gomspace_cmd_defs(oce)
|
2022-08-11 15:40:38 +02:00
|
|
|
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.PRINT_SWITCH_V_I,
|
|
|
|
info="PDU1: Print Switches, Voltages, Currents",
|
|
|
|
)
|
2022-08-24 11:19:49 +02:00
|
|
|
oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER)
|
|
|
|
|
2022-08-11 15:40:38 +02:00
|
|
|
defs.add_service(
|
|
|
|
name=CustomServiceList.PDU1.value,
|
|
|
|
info="PDU1 Device",
|
|
|
|
op_code_entry=oce,
|
|
|
|
)
|
2022-08-11 14:45:24 +02:00
|
|
|
|
|
|
|
|
2022-08-12 10:18:21 +02:00
|
|
|
@tmtc_definitions_provider
|
|
|
|
def add_pdu2_cmds(defs: TmtcDefinitionWrapper):
|
2022-08-11 15:40:38 +02:00
|
|
|
oce = OpCodeEntry()
|
2022-08-11 18:10:15 +02:00
|
|
|
add_pdu2_common_defs(oce)
|
2022-08-26 23:52:47 +02:00
|
|
|
add_gomspace_cmd_defs(oce)
|
2022-08-11 15:40:38 +02:00
|
|
|
oce.add(
|
|
|
|
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
|
|
|
|
info="PDU2: Print Switches, Voltages, Currents",
|
|
|
|
)
|
|
|
|
oce.add(
|
|
|
|
keys=GomspaceOpCodes.PRINT_LATCHUPS,
|
|
|
|
info="PDU2: Print Latchups",
|
|
|
|
)
|
|
|
|
defs.add_service(
|
|
|
|
name="pdu2",
|
|
|
|
info="PDU2 Device",
|
|
|
|
op_code_entry=oce,
|
2022-08-11 14:45:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-08-12 10:18:21 +02:00
|
|
|
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)
|