separate request wait time function

This commit is contained in:
Robin Mueller 2022-03-01 18:00:39 +01:00
parent 2c96b9ed4c
commit a9a6468718
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -1,4 +1,5 @@
import enum
from typing import Optional
from tmtccmd.config import QueueCommands
from tmtccmd.tc.definitions import TcQueueT
@ -13,6 +14,7 @@ from config.object_ids import PL_PCDU_ID
LOGGER = get_console_logger()
class OpCodes:
SWITCH_ADC_ON = ["0", "switch-adc-on"]
SWITCH_ALL_ON = ["1", "switch-all-on"]
@ -49,18 +51,9 @@ def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str):
tc_queue.appendleft(mode_cmd.pack_command_tuple())
if op_code in OpCodes.UPDATE_DRO_TO_X8_WAIT:
tc_queue.appendleft((QueueCommands.PRINT, "Updating DRO to X8 wait time"))
while True:
wait_time = input("Please enter DRO to X8 wait time in seconds, x to cancel")
if wait_time.lower() == "x":
return
if not wait_time.isnumeric():
LOGGER.warning("Invalid input")
continue
wait_time = float(wait_time)
if wait_time <= 0:
LOGGER.warning("Invalid input")
else:
break
wait_time = request_wait_time()
if wait_time is None:
return
param_data = pack_scalar_double_param_app_data(
object_id=PL_PCDU_ID,
domain_id=0,
@ -69,3 +62,18 @@ def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str):
)
cmd = pack_fsfw_load_param_cmd(ssc=0, app_data=param_data)
tc_queue.appendleft(cmd.pack_command_tuple())
def request_wait_time() -> Optional[float]:
while True:
wait_time = input("Please enter DRO to X8 wait time in seconds, x to cancel")
if wait_time.lower() == "x":
return None
if not wait_time.isnumeric():
LOGGER.warning("Invalid input")
continue
wait_time = float(wait_time)
if wait_time <= 0:
LOGGER.warning("Invalid input")
else:
return wait_time