old API
This commit is contained in:
parent
927508e65d
commit
8bc51b293b
@ -26,7 +26,9 @@ class SwitchNumbers:
|
|||||||
|
|
||||||
|
|
||||||
class OpCodes:
|
class OpCodes:
|
||||||
HEATER_CMD = ["0", "heater-cmd"]
|
HEATER_CMD = ["0", "switch-cmd"]
|
||||||
|
HEATER_EXT_CTRL = ["1", "heater-ext-ctrl"]
|
||||||
|
HEATER_FAULTY_CMD = ["2", "set-faulty"]
|
||||||
|
|
||||||
|
|
||||||
class Info:
|
class Info:
|
||||||
@ -50,45 +52,48 @@ def add_heater_cmds(cmd_dict: ServiceOpCodeDictT):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def pack_heater_cmds(object_id: bytearray, tc_queue: TcQueueT):
|
def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
|
||||||
tc_queue.appendleft((QueueCommands.PRINT, "Heater Switching"))
|
if op_code in OpCodes.HEATER_CMD:
|
||||||
while True:
|
tc_queue.appendleft((QueueCommands.PRINT, "Heater Switching"))
|
||||||
heater_number = input("Type number of heater to switch [0-7]: ")
|
while True:
|
||||||
if not heater_number.isdigit():
|
heater_number = input("Type number of heater to switch [0-7]: ")
|
||||||
print("Heater number not a digit")
|
if not heater_number.isdigit():
|
||||||
continue
|
print("Heater number not a digit")
|
||||||
heater_number = int(heater_number)
|
continue
|
||||||
if heater_number >= SwitchNumbers.NUMBER_OF_SWITCHES or heater_number < 0:
|
heater_number = int(heater_number)
|
||||||
print("Invalid heater switch number")
|
if heater_number >= SwitchNumbers.NUMBER_OF_SWITCHES or heater_number < 0:
|
||||||
continue
|
print("Invalid heater switch number")
|
||||||
break
|
continue
|
||||||
while True:
|
break
|
||||||
action = input("Turn switch on or off? (0 - off, 1 - on): ")
|
while True:
|
||||||
if not action.isdigit():
|
action = input("Turn switch on or off? (0 - off, 1 - on): ")
|
||||||
print("Switch action not valid")
|
if not action.isdigit():
|
||||||
continue
|
print("Switch action not valid")
|
||||||
action = int(action)
|
continue
|
||||||
if action != 0 and action != 1:
|
action = int(action)
|
||||||
print("Invalid action defined. Must be 0 (off) or 1 (on")
|
if action != 0 and action != 1:
|
||||||
continue
|
print("Invalid action defined. Must be 0 (off) or 1 (on")
|
||||||
break
|
continue
|
||||||
if action == 1:
|
break
|
||||||
act_str = "on"
|
if action == 1:
|
||||||
else:
|
act_str = "on"
|
||||||
act_str = "off"
|
else:
|
||||||
debug_string = f"Switching heater {heater_number} {act_str}"
|
act_str = "off"
|
||||||
tc_queue.appendleft((QueueCommands.PRINT, debug_string))
|
debug_string = f"Switching heater {heater_number} {act_str}"
|
||||||
command = pack_switch_heater_command(object_id, heater_number, action)
|
tc_queue.appendleft((QueueCommands.PRINT, debug_string))
|
||||||
tc_queue.appendleft(command.pack_command_tuple())
|
command = pack_switch_heater_command(object_id, heater_number, action)
|
||||||
|
tc_queue.appendleft(command.pack_command_tuple())
|
||||||
|
if op_code in OpCodes.HEATER_EXT_CTRL:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def pack_switch_heater_command(
|
def pack_switch_heater_command(
|
||||||
object_id: bytes, switch_nr: int, switch_action: int
|
object_id: bytes, switch_nr: int, switch_action: int
|
||||||
) -> PusTelecommand:
|
) -> PusTelecommand:
|
||||||
"""Function to generate the command switch a heater
|
"""Function to generate a heater switch command.
|
||||||
@param object_id The object id of the HeaterHandler object.
|
:param object_id: The object id of the HeaterHandler object.
|
||||||
@param switch_nr The switch number identifying the heater to switch
|
:param switch_nr: The switch number identifying the heater to switch
|
||||||
@param switch_action Action to perform. 0 - Sets switch off, 1 - Sets switch on.
|
:param switch_action: Action to perform. 0 - Sets switch off, 1 - Sets switch on.
|
||||||
"""
|
"""
|
||||||
command = bytearray()
|
command = bytearray()
|
||||||
command.append(switch_nr)
|
command.append(switch_nr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user