add new commands to test new feature

This commit is contained in:
Robin Müller 2023-11-27 12:01:03 +01:00
parent 99c6c8bbd0
commit 228065bf3b
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -44,21 +44,25 @@ class OpCode:
NORMAL_TX = "nml_tx" NORMAL_TX = "nml_tx"
NORMAL_MPA = "nml_mpa" NORMAL_MPA = "nml_mpa"
NORMAL_HPA = "nml_hpa" NORMAL_HPA = "nml_hpa"
NORMAL_CUSTOM = "nml_custom"
ENABLE_HK = "enable_hk" ENABLE_HK = "enable_hk"
DISABLE_HK = "disable_hk" DISABLE_HK = "disable_hk"
REQ_OS_HK = "hk_os" REQ_OS_HK = "hk_os"
DISABLE_ORDER_CHECKING = "disable_order_checking"
ENABLE_ORDER_CHECKING = "enable_order_checking"
UPDATE_I_UPPER_LIMIT = "update_i_upper_limit" UPDATE_I_UPPER_LIMIT = "update_i_upper_limit"
UPDATE_V_LOWER_LIMIT = "update_v_lower_limit" UPDATE_V_LOWER_LIMIT = "update_v_lower_limit"
UPDATE_V_UPPER_LIMIT = "update_v_upper_limit" UPDATE_V_UPPER_LIMIT = "update_v_upper_limit"
INJECT_SSR_TO_DRO_FAILURE = ["10", "inject_ssr_dro_fault"] INJECT_SSR_TO_DRO_FAILURE = "inject_ssr_dro_fault"
INJECT_DRO_TO_X8_FAILURE = ["11", "inject_dro_x8_fault"] INJECT_DRO_TO_X8_FAILURE = "inject_dro_x8_fault"
INJECT_X8_TO_TX_FAILURE = ["12", "inject_x8_tx_fault"] INJECT_X8_TO_TX_FAILURE = "inject_x8_tx_fault"
INJECT_TX_TO_MPA_FAILURE = ["13", "inject_tx_mpa_fault"] INJECT_TX_TO_MPA_FAILURE = "inject_tx_mpa_fault"
INJECT_MPA_TO_HPA_FAILURE = ["14", "inject_mpa_hpa_fault"] INJECT_MPA_TO_HPA_FAILURE = "inject_mpa_hpa_fault"
INJECT_ALL_ON_FAILURE = ["15", "inject_all_on_fault"] INJECT_ALL_ON_FAILURE = "inject_all_on_fault"
class Info: class Info:
@ -71,6 +75,7 @@ class Info:
NORMAL_TX = f"{NORMAL}, TX on" NORMAL_TX = f"{NORMAL}, TX on"
NORMAL_MPA = f"{NORMAL}, MPA on" NORMAL_MPA = f"{NORMAL}, MPA on"
NORMAL_HPA = f"{NORMAL}, HPA on" NORMAL_HPA = f"{NORMAL}, HPA on"
NORMAL_CUSTOM = f"{NORMAL}, Custom Channel Settings"
REQ_OS_HK = "Request One Shot HK" REQ_OS_HK = "Request One Shot HK"
SWITCH_HPA_ON_PROC = "Switch HPA on procedure" SWITCH_HPA_ON_PROC = "Switch HPA on procedure"
ENABLE_HK = "Enable HK" ENABLE_HK = "Enable HK"
@ -78,6 +83,8 @@ class Info:
UPDATE_I_UPPER_LIMIT = "Update upper current parameter" UPDATE_I_UPPER_LIMIT = "Update upper current parameter"
UPDATE_V_LOWER_LIMIT = "Update lower voltage parameter" UPDATE_V_LOWER_LIMIT = "Update lower voltage parameter"
UPDATE_V_UPPER_LIMIT = "Update upper voltage parameter" UPDATE_V_UPPER_LIMIT = "Update upper voltage parameter"
DISABLE_ORDER_CHECKING = "Disable order checks"
ENABLE_ORDER_CHECKING = "Enable order checks"
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -164,6 +171,8 @@ class ParamId(enum.IntEnum):
INJECT_MPA_TO_HPA_FAILURE = 34 INJECT_MPA_TO_HPA_FAILURE = 34
INJECT_ALL_ON_FAILURE = 35 INJECT_ALL_ON_FAILURE = 35
DISABLE_ORDER_CHECK_CHANNELS = 40
class DevSelect(enum.IntEnum): class DevSelect(enum.IntEnum):
SSR_NEG_V = 0 SSR_NEG_V = 0
@ -186,6 +195,7 @@ def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCode.NORMAL_TX, info=Info.NORMAL_TX) oce.add(keys=OpCode.NORMAL_TX, info=Info.NORMAL_TX)
oce.add(keys=OpCode.NORMAL_MPA, info=Info.NORMAL_MPA) oce.add(keys=OpCode.NORMAL_MPA, info=Info.NORMAL_MPA)
oce.add(keys=OpCode.NORMAL_HPA, info=Info.NORMAL_HPA) oce.add(keys=OpCode.NORMAL_HPA, info=Info.NORMAL_HPA)
oce.add(keys=OpCode.NORMAL_CUSTOM, info=Info.NORMAL_CUSTOM)
oce.add(keys=OpCode.REQ_OS_HK, info=Info.REQ_OS_HK) oce.add(keys=OpCode.REQ_OS_HK, info=Info.REQ_OS_HK)
oce.add(keys=OpCode.ENABLE_HK, info=Info.ENABLE_HK) oce.add(keys=OpCode.ENABLE_HK, info=Info.ENABLE_HK)
oce.add(keys=OpCode.UPDATE_V_LOWER_LIMIT, info=Info.UPDATE_V_LOWER_LIMIT) oce.add(keys=OpCode.UPDATE_V_LOWER_LIMIT, info=Info.UPDATE_V_LOWER_LIMIT)
@ -212,6 +222,8 @@ def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper):
info="Inject failure in MPA to HPA transition", info="Inject failure in MPA to HPA transition",
) )
oce.add(keys=OpCode.INJECT_ALL_ON_FAILURE, info="Inject failure in all on mode") oce.add(keys=OpCode.INJECT_ALL_ON_FAILURE, info="Inject failure in all on mode")
oce.add(keys=OpCode.DISABLE_ORDER_CHECKING, info=Info.DISABLE_ORDER_CHECKING)
oce.add(keys=OpCode.ENABLE_ORDER_CHECKING, info=Info.ENABLE_ORDER_CHECKING)
defs.add_service(CustomServiceList.PL_PCDU.value, "PL PCDU", oce) defs.add_service(CustomServiceList.PL_PCDU.value, "PL PCDU", oce)
@ -282,6 +294,14 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here.
mode=Mode.NORMAL, mode=Mode.NORMAL,
submode=submode_mask_to_submode(NormalSubmodesMask.HPA_ON), submode=submode_mask_to_submode(NormalSubmodesMask.HPA_ON),
) )
if op_code == OpCode.NORMAL_CUSTOM:
pack_pl_pcdu_mode_cmd(
q=q,
info=Info.NORMAL_CUSTOM,
mode=Mode.NORMAL,
submode=prompt_custom_normal_submode(),
)
if op_code == OpCode.REQ_OS_HK: if op_code == OpCode.REQ_OS_HK:
q.add_log_cmd(f"PL PCDU: {Info.REQ_OS_HK}") q.add_log_cmd(f"PL PCDU: {Info.REQ_OS_HK}")
q.add_pus_tc( q.add_pus_tc(
@ -289,6 +309,26 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here.
sid=make_sid(object_id=PL_PCDU_ID, set_id=SetId.ADC) sid=make_sid(object_id=PL_PCDU_ID, set_id=SetId.ADC)
) )
) )
if op_code == OpCode.DISABLE_ORDER_CHECKING:
q.add_log_cmd(Info.DISABLE_ORDER_CHECKING)
q.add_pus_tc(
create_load_param_cmd(
create_scalar_boolean_parameter(
PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, False
)
)
)
if op_code == OpCode.ENABLE_ORDER_CHECKING:
q.add_log_cmd(Info.ENABLE_ORDER_CHECKING)
q.add_pus_tc(
create_load_param_cmd(
create_scalar_boolean_parameter(
PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, True
)
)
)
if op_code == OpCode.UPDATE_I_UPPER_LIMIT: if op_code == OpCode.UPDATE_I_UPPER_LIMIT:
q.add_log_cmd(Info.UPDATE_I_UPPER_LIMIT) q.add_log_cmd(Info.UPDATE_I_UPPER_LIMIT)
print("Select device to update lower current limit for: ") print("Select device to update lower current limit for: ")
@ -635,3 +675,30 @@ def dev_select_to_upper_u_update_param_id(dev_select: DevSelect) -> ParamId:
if param_id is None: if param_id is None:
raise ValueError("invalid parameter ID") raise ValueError("invalid parameter ID")
return param_id return param_id
def prompt_custom_normal_submode() -> int:
print("Prompting custom submode.")
submode = 0
def prompt_channel(submode: int, channel_str: str, mask: NormalSubmodesMask) -> int:
while True:
channel_on = input(f" {channel_str} ON? [y/n]: ")
if channel_on in ["y", "1", "yes"]:
submode |= 1 << mask
elif channel_on in ["n", "0", "no"]:
break
else:
_LOGGER.warning("invalid input, try again")
continue
return submode
submode = prompt_channel(
submode, "SSR", NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
)
submode = prompt_channel(submode, "DRO", NormalSubmodesMask.DRO_ON)
submode = prompt_channel(submode, "TX", NormalSubmodesMask.TX_ON)
submode = prompt_channel(submode, "X8", NormalSubmodesMask.X8_ON)
submode = prompt_channel(submode, "MPA", NormalSubmodesMask.MPA_ON)
submode = prompt_channel(submode, "HPA", NormalSubmodesMask.HPA_ON)
return submode