From 228065bf3b4654b0c9d01f20c2785958fe95766a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Nov 2023 12:01:03 +0100 Subject: [PATCH 1/3] add new commands to test new feature --- eive_tmtc/tmtc/payload/plpcdu.py | 79 +++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/eive_tmtc/tmtc/payload/plpcdu.py b/eive_tmtc/tmtc/payload/plpcdu.py index a5cbef0..bfb6ebb 100644 --- a/eive_tmtc/tmtc/payload/plpcdu.py +++ b/eive_tmtc/tmtc/payload/plpcdu.py @@ -44,21 +44,25 @@ class OpCode: NORMAL_TX = "nml_tx" NORMAL_MPA = "nml_mpa" NORMAL_HPA = "nml_hpa" + NORMAL_CUSTOM = "nml_custom" ENABLE_HK = "enable_hk" DISABLE_HK = "disable_hk" 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_V_LOWER_LIMIT = "update_v_lower_limit" UPDATE_V_UPPER_LIMIT = "update_v_upper_limit" - INJECT_SSR_TO_DRO_FAILURE = ["10", "inject_ssr_dro_fault"] - INJECT_DRO_TO_X8_FAILURE = ["11", "inject_dro_x8_fault"] - INJECT_X8_TO_TX_FAILURE = ["12", "inject_x8_tx_fault"] - INJECT_TX_TO_MPA_FAILURE = ["13", "inject_tx_mpa_fault"] - INJECT_MPA_TO_HPA_FAILURE = ["14", "inject_mpa_hpa_fault"] - INJECT_ALL_ON_FAILURE = ["15", "inject_all_on_fault"] + INJECT_SSR_TO_DRO_FAILURE = "inject_ssr_dro_fault" + INJECT_DRO_TO_X8_FAILURE = "inject_dro_x8_fault" + INJECT_X8_TO_TX_FAILURE = "inject_x8_tx_fault" + INJECT_TX_TO_MPA_FAILURE = "inject_tx_mpa_fault" + INJECT_MPA_TO_HPA_FAILURE = "inject_mpa_hpa_fault" + INJECT_ALL_ON_FAILURE = "inject_all_on_fault" class Info: @@ -71,6 +75,7 @@ class Info: NORMAL_TX = f"{NORMAL}, TX on" NORMAL_MPA = f"{NORMAL}, MPA on" NORMAL_HPA = f"{NORMAL}, HPA on" + NORMAL_CUSTOM = f"{NORMAL}, Custom Channel Settings" REQ_OS_HK = "Request One Shot HK" SWITCH_HPA_ON_PROC = "Switch HPA on procedure" ENABLE_HK = "Enable HK" @@ -78,6 +83,8 @@ class Info: UPDATE_I_UPPER_LIMIT = "Update upper current parameter" UPDATE_V_LOWER_LIMIT = "Update lower 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): @@ -164,6 +171,8 @@ class ParamId(enum.IntEnum): INJECT_MPA_TO_HPA_FAILURE = 34 INJECT_ALL_ON_FAILURE = 35 + DISABLE_ORDER_CHECK_CHANNELS = 40 + class DevSelect(enum.IntEnum): 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_MPA, info=Info.NORMAL_MPA) 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.ENABLE_HK, info=Info.ENABLE_HK) 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", ) 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) @@ -282,6 +294,14 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. mode=Mode.NORMAL, 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: q.add_log_cmd(f"PL PCDU: {Info.REQ_OS_HK}") 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) ) ) + 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: q.add_log_cmd(Info.UPDATE_I_UPPER_LIMIT) 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: raise ValueError("invalid parameter 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 -- 2.43.0 From 4ae659cb4ebcc2b929c5a056666a84f268dd96a8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Nov 2023 12:01:45 +0100 Subject: [PATCH 2/3] changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c41217e..b68c4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ list yields a list of all related PRs for each release. # [unreleased] +## Added + +- Added new commands to disable channel order checks partially for the payload PCDU normal modes. + # [v5.10.1] 2023-10-27 - Minor improvements, update event translation. -- 2.43.0 From 62b16028e662ab3dc6ec2f8b54732220e3ef8378 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Nov 2023 12:18:39 +0100 Subject: [PATCH 3/3] small fix and tweak --- eive_tmtc/tmtc/payload/plpcdu.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eive_tmtc/tmtc/payload/plpcdu.py b/eive_tmtc/tmtc/payload/plpcdu.py index bfb6ebb..362f8b2 100644 --- a/eive_tmtc/tmtc/payload/plpcdu.py +++ b/eive_tmtc/tmtc/payload/plpcdu.py @@ -314,7 +314,7 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. q.add_pus_tc( create_load_param_cmd( create_scalar_boolean_parameter( - PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, False + PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, True ) ) ) @@ -324,7 +324,7 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. q.add_pus_tc( create_load_param_cmd( create_scalar_boolean_parameter( - PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, True + PL_PCDU_ID, 0, ParamId.DISABLE_ORDER_CHECK_CHANNELS, False ) ) ) @@ -687,18 +687,19 @@ def prompt_custom_normal_submode() -> int: if channel_on in ["y", "1", "yes"]: submode |= 1 << mask elif channel_on in ["n", "0", "no"]: - break + pass else: _LOGGER.warning("invalid input, try again") continue + break 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, "TX", NormalSubmodesMask.TX_ON) submode = prompt_channel(submode, "MPA", NormalSubmodesMask.MPA_ON) submode = prompt_channel(submode, "HPA", NormalSubmodesMask.HPA_ON) return submode -- 2.43.0