2022-06-21 16:49:11 +02:00
|
|
|
import enum
|
|
|
|
|
|
|
|
from config.definitions import CustomServiceList
|
|
|
|
from tmtccmd.tc.pus_8_funccmd import generate_action_command
|
|
|
|
from tmtccmd.config import QueueCommands, ServiceOpCodeDictT, add_op_code_entry, add_service_op_code_entry
|
|
|
|
from tmtccmd.tc.definitions import TcQueueT
|
|
|
|
from config.object_ids import SCEX_HANDLER_ID
|
|
|
|
|
|
|
|
|
|
|
|
class OpCodes:
|
|
|
|
PING = ["0", "ping"]
|
|
|
|
|
|
|
|
|
|
|
|
class ActionIds(enum.IntEnum):
|
|
|
|
PING = 7
|
2022-06-21 18:15:17 +02:00
|
|
|
ION_CMD = 4
|
2022-06-21 16:49:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Info:
|
|
|
|
PING = "Send Ping command"
|
|
|
|
|
|
|
|
|
|
|
|
def add_scex_cmds(cmd_dict: ServiceOpCodeDictT):
|
|
|
|
op_code_dict = dict()
|
|
|
|
add_op_code_entry(
|
|
|
|
op_code_dict=op_code_dict, keys=OpCodes.PING, info=Info.PING
|
|
|
|
)
|
2022-06-21 18:15:17 +02:00
|
|
|
|
|
|
|
# ion
|
|
|
|
op_code_dict = dict()
|
|
|
|
add_op_code_entry(
|
|
|
|
op_code_dict=op_code_dict, keys=OpCodes.ION, info=Info.ION
|
|
|
|
)
|
|
|
|
|
2022-06-21 16:49:11 +02:00
|
|
|
add_service_op_code_entry(
|
|
|
|
srv_op_code_dict=cmd_dict,
|
|
|
|
name=CustomServiceList.SCEX.value,
|
|
|
|
info="SCEX Device",
|
|
|
|
op_code_entry=op_code_dict
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-06-21 18:15:17 +02:00
|
|
|
"""
|
|
|
|
#in app_data
|
|
|
|
app_data.extend(struct.pack("!H", first_dac))
|
|
|
|
append_16_bit_val(packet=packet, val=CFG.exp_cfg.first_dac[cn])
|
|
|
|
append_16_bit_val(packet=packet, val=CFG.exp_cfg.last_dac[cn])
|
|
|
|
append_16_bit_val(packet=packet, val=CFG.exp_cfg.res_switch1[cn])
|
|
|
|
append_16_bit_val(packet=packet, val=CFG.exp_cfg.res_switch2[cn])
|
|
|
|
|
|
|
|
packet.append(CFG.exp_cfg.dac_weight1[cn])
|
|
|
|
packet.append(CFG.exp_cfg.dac_weight2[cn])
|
|
|
|
packet.append(CFG.exp_cfg.dac_weight3[cn])
|
|
|
|
"""
|
2022-06-21 16:49:11 +02:00
|
|
|
def pack_scex_cmds(tc_queue: TcQueueT, op_code: str):
|
|
|
|
if op_code in OpCodes.PING:
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, Info.PING))
|
|
|
|
app_data = bytes([0])
|
|
|
|
command = generate_action_command(SCEX_HANDLER_ID, ActionIds.PING, app_data)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-06-21 18:15:17 +02:00
|
|
|
if op_code in OpCodes.ION:
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, Info.ION))
|
|
|
|
app_data = bytes([0])
|
|
|
|
command = generate_action_command(SCEX_HANDLER_ID, ActionIds.ION, app_data)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-06-21 16:49:11 +02:00
|
|
|
|
2022-06-21 18:15:17 +02:00
|
|
|
# one cell
|
|
|
|
if op_code in OpCodes.ION:
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, Info.ION))
|
|
|
|
app_data = bytearray([0])
|
|
|
|
#todo cell number
|
|
|
|
app_data.extend(struct.pack("!H", first_dac)) #aus json holen
|
|
|
|
command = generate_action_command(SCEX_HANDLER_ID, ActionIds.ION, app_data)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|