From dbae41cb5810c45ee783080dd0c0f5580e258876 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 30 Jun 2022 21:49:25 +0200 Subject: [PATCH] scex continued --- pus_tc/devs/scex.py | 45 ++++++++++++++++++++++++++++++++++++----- template/scex_conf.json | 2 +- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/pus_tc/devs/scex.py b/pus_tc/devs/scex.py index 022414a..003a6eb 100644 --- a/pus_tc/devs/scex.py +++ b/pus_tc/devs/scex.py @@ -16,10 +16,10 @@ class OpCodes: PING = ["0", "ping"] ION_CMD = ["1", "ion"] TEMP_CMD = ["2", "temp"] - EXP_STATUS_CMD = ["3", "expStatus"] + EXP_STATUS_CMD = ["3", "expstatus"] - ONE_CELLS_CMD = ["4", "oneCell"] - ALL_CELLS_CMD = ["5", "allCells"] + ONE_CELLS_CMD = ["4", "onecell"] + ALL_CELLS_CMD = ["5", "allcells"] FRAM = ["6", "fram"] @@ -131,7 +131,6 @@ def pack_scex_cmds(tc_queue: TcQueueT, op_code: str): if USE_SCEX_CONF_FILE: with open("template/scex_conf.json") as json_file: json_data = json.load(json_file) - # print(json_data) first_dac = json_data["first_dac"] last_dac = json_data["last_dac"] res_switch1 = json_data["res_switch1"] @@ -141,7 +140,7 @@ def pack_scex_cmds(tc_queue: TcQueueT, op_code: str): dac_weight3 = json_data["dac_weight3"] # in app_data - app_data.extend(struct.pack("!H", first_dac)) + # app_data.extend(struct.pack("!H", first_dac)) append_16_bit_val(packet=app_data, val=first_dac[cn]) append_16_bit_val(packet=app_data, val=last_dac[cn]) append_16_bit_val(packet=app_data, val=res_switch1[cn]) @@ -154,6 +153,42 @@ def pack_scex_cmds(tc_queue: TcQueueT, op_code: str): command = generate_action_command(SCEX_HANDLER_ID, ActionIds.ONE_CELLS_CMD, app_data) tc_queue.appendleft(command.pack_command_tuple()) + if op_code in OpCodes.ALL_CELLS_CMD: + tc_queue.appendleft((QueueCommands.PRINT, Info.ALL_CELLS_CMD)) + app_data = bytearray() + + # cell number + cn = 0 + if USE_SCEX_CONF_FILE: + with open("template/scex_conf.json") as json_file: + json_data = json.load(json_file) + first_dac = json_data["first_dac"] + last_dac = json_data["last_dac"] + res_switch1 = json_data["res_switch1"] + res_switch2 = json_data["res_switch2"] + dac_weight1 = json_data["dac_weight1"] + dac_weight2 = json_data["dac_weight2"] + dac_weight3 = json_data["dac_weight3"] + + # in app_data + # app_data.extend(struct.pack("!H", first_dac)) + append_16_bit_val(packet=app_data, val=first_dac[cn]) + append_16_bit_val(packet=app_data, val=last_dac[cn]) + append_16_bit_val(packet=app_data, val=res_switch1[cn]) + append_16_bit_val(packet=app_data, val=res_switch2[cn]) + + app_data.append(dac_weight1[cn]) + app_data.append(dac_weight2[cn]) + app_data.append(dac_weight3[cn]) + + command = generate_action_command(SCEX_HANDLER_ID, ActionIds.ALL_CELLS_CMD, app_data) + tc_queue.appendleft(command.pack_command_tuple()) + + if op_code in OpCodes.FRAM: + tc_queue.appendleft((QueueCommands.PRINT, Info.FRAM)) + app_data = bytes([0]) + command = generate_action_command(SCEX_HANDLER_ID, ActionIds.FRAM, app_data) + tc_queue.appendleft(command.pack_command_tuple()) def append_16_bit_val(packet: bytearray, val: int): packet.append((val >> 8) & 0xFF) diff --git a/template/scex_conf.json b/template/scex_conf.json index ec82846..f30d4a2 100644 --- a/template/scex_conf.json +++ b/template/scex_conf.json @@ -5,5 +5,5 @@ "res_switch2": [15650, 15650, 15650, 13400, 15650, 13400, 13400, 13400, 13400, 13400], "dac_weight1": [35, 35, 35, 35, 35, 37, 37, 37, 37, 37], "dac_weight2": [30, 30, 30, 50, 30, 28, 28, 28, 28, 28], - "dac_weight3": [35, 35, 35, 35, 35, 35, 35, 35, 35, 35], + "dac_weight3": [35, 35, 35, 35, 35, 35, 35, 35, 35, 35] } \ No newline at end of file