cleaned up a bit

This commit is contained in:
Robin Müller 2022-05-24 17:04:03 +02:00
parent 0c9547eb3a
commit 96c6feb746
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -190,45 +190,6 @@ def add_pl_pcdu_cmds(cmd_dict: ServiceOpCodeDictT):
) )
def submode_mask_to_submode(on_tgt: NormalSubmodesMask) -> int:
if on_tgt == NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON:
return 1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
if on_tgt == NormalSubmodesMask.DRO_ON:
return 1 << NormalSubmodesMask.DRO_ON | (
1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
)
if on_tgt == NormalSubmodesMask.X8_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
)
if on_tgt == NormalSubmodesMask.TX_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
)
if on_tgt == NormalSubmodesMask.MPA_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
)
if on_tgt == NormalSubmodesMask.HPA_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
| (1 << NormalSubmodesMask.HPA_ON)
)
def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str): def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.SWITCH_ON: if op_code in OpCodes.SWITCH_ON:
pack_pl_pcdu_mode_cmd( pack_pl_pcdu_mode_cmd(
@ -283,21 +244,20 @@ def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str):
submode=submode_mask_to_submode(NormalSubmodesMask.HPA_ON), submode=submode_mask_to_submode(NormalSubmodesMask.HPA_ON),
) )
if op_code in OpCodes.SWITCH_HPA_ON_PROC: if op_code in OpCodes.SWITCH_HPA_ON_PROC:
while True: hpa_on_procedure(tc_queue)
delay_dro_to_x8 = input(
"Please specify delay between DRO and switching " if op_code in OpCodes.INJECT_ALL_ON_FAILURE:
"on X8 [default 900]: " pack_failure_injection_cmd(
tc_queue=tc_queue,
param_id=ParamIds.INJECT_ALL_ON_FAILURE,
print_str="All On",
) )
if delay_dro_to_x8 == "":
def hpa_on_procedure(tc_queue: TcQueueT):
delay_dro_to_x8 = request_wait_time()
if delay_dro_to_x8 is None:
delay_dro_to_x8 = 900 delay_dro_to_x8 = 900
break
if delay_dro_to_x8.isdigit():
print("Invalid value, not a number")
continue
delay_dro_to_x8 = int(delay_dro_to_x8)
if delay_dro_to_x8 < 0:
print("Invalid number")
break
tc_queue.appendleft( tc_queue.appendleft(
( (
QueueCommands.PRINT, QueueCommands.PRINT,
@ -416,13 +376,6 @@ def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str):
) )
tc_queue.appendleft(tagged_hpa_cmd.pack_command_tuple()) tc_queue.appendleft(tagged_hpa_cmd.pack_command_tuple())
if op_code in OpCodes.INJECT_ALL_ON_FAILURE:
pack_failure_injection_cmd(
tc_queue=tc_queue,
param_id=ParamIds.INJECT_ALL_ON_FAILURE,
print_str="All On",
)
def request_wait_time() -> Optional[float]: def request_wait_time() -> Optional[float]:
while True: while True:
@ -440,6 +393,45 @@ def request_wait_time() -> Optional[float]:
return wait_time return wait_time
def submode_mask_to_submode(on_tgt: NormalSubmodesMask) -> int:
if on_tgt == NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON:
return 1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
if on_tgt == NormalSubmodesMask.DRO_ON:
return 1 << NormalSubmodesMask.DRO_ON | (
1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
)
if on_tgt == NormalSubmodesMask.X8_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
)
if on_tgt == NormalSubmodesMask.TX_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
)
if on_tgt == NormalSubmodesMask.MPA_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
)
if on_tgt == NormalSubmodesMask.HPA_ON:
return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
| (1 << NormalSubmodesMask.HPA_ON)
)
def pack_wait_time_cmd(tc_queue: TcQueueT, param_id: int, print_str: str): def pack_wait_time_cmd(tc_queue: TcQueueT, param_id: int, print_str: str):
wait_time = request_wait_time() wait_time = request_wait_time()
tc_queue.appendleft( tc_queue.appendleft(