From d53e26b589c663b83e60594105c68a681c37a108 Mon Sep 17 00:00:00 2001 From: Markus Kranz Date: Thu, 19 May 2022 18:14:38 +0200 Subject: [PATCH] switch to generic hk function --- pus_tc/devs/p60dock.py | 3 -- pus_tc/system/proc.py | 86 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/pus_tc/devs/p60dock.py b/pus_tc/devs/p60dock.py index 03bbd5b..be71cac 100644 --- a/pus_tc/devs/p60dock.py +++ b/pus_tc/devs/p60dock.py @@ -16,9 +16,6 @@ from gomspace.gomspace_common import * from config.object_ids import P60_DOCK_HANDLER -HK_SET_ID = 0x3 - - class P60OpCodes: STACK_3V3_ON = ["stack-3v3-on", "1"] STACK_3V3_OFF = ["stack-3v3-off", "2"] diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index 0893469..0d3c136 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -1,42 +1,96 @@ from tmtccmd.config import QueueCommands from tmtccmd.tc.definitions import TcQueueT from tmtccmd.tc.pus_3_fsfw_hk import * -from config.object_ids import BPX_HANDLER_ID +from config.object_ids import ( + BPX_HANDLER_ID, + P60_DOCK_HANDLER, + PDU_1_HANDLER_ID, + PDU_2_HANDLER_ID, + ACU_HANDLER_ID, +) from pus_tc.devs.bpx_batt import BpxSetIds +from gomspace.gomspace_common import SetIds as GsSetIds class OpCodes: HEATER = ["0", "heater"] BAT_FT = ["bat-ft"] + PCDU_FT = ["pcdu-ft"] class Info: HEATER = "heater procedure" BAT_FT = "battery functional test" + PCDU_FT = "pcdu functional test" def pack_proc_commands(tc_queue: TcQueueT, op_code: str): if op_code in OpCodes.BAT_FT: + device = Info.BAT_FT.split()[0] tc_queue.appendleft( - ( - QueueCommands.PRINT, - f"Executing Battery functional test Procedure ({OpCodes.BAT_FT})", - ) + (QueueCommands.PRINT, f"Executing {device} Procedure ({device})") ) - tc_queue.appendleft((QueueCommands.PRINT, f"Enabling periodic HK for Battery")) - cmd_tuple = enable_periodic_hk_command_with_interval( + sid = make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET) + + listen_to_hk_for_x_seconds( diag=False, - sid=make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET), + device=device, + sid=sid, interval_seconds=10.0, - ssc=0, + collection_time=120.0, ) - for cmd in cmd_tuple: - tc_queue.appendleft(cmd.pack_command_tuple()) - tc_queue.appendleft((QueueCommands.WAIT, 120.0)) - tc_queue.appendleft((QueueCommands.PRINT, "Disabling periodic HK for Battery")) + + if op_code in OpCodes.PCDU_FT: + device = Info.PCDU_FT.split()[0] tc_queue.appendleft( - disable_periodic_hk_command( - diag=False, sid=make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET), ssc=0 - ).pack_command_tuple() + (QueueCommands.PRINT, f"Executing {device} Procedure ({device})") ) + sid = make_sid(P60_DOCK_HANDLER, GsSetIds.P60_CORE) + + listen_to_hk_for_x_seconds( + diag=False, + device=device, + sid=sid, + interval_seconds=10.0, + collection_time=120.0, + ) + pass + + +def listen_to_hk_for_x_seconds( + tc_queue: TcQueueT, + diag: bool, + device: str, + sid: bytes, + interval_seconds: float, + collection_time: float, +): + """ + enable_periodic_hk_command_with_interval( + diag: bool, sid: bytes, interval_seconds: float, ssc: int + """ + """ + function with periodic HK generation + interval_seconds = at which rate HK is saved + collection_time = how long the HK is saved for + device = for which device the HK is saved + functional_test = + diagnostic Hk = yes diagnostic or no diagnostic + sid = structural ID for specific device + device Hk set ID + """ + + tc_queue.appendleft((QueueCommands.PRINT, f"Enabling periodic HK for {device}")) + cmd_tuple = enable_periodic_hk_command_with_interval( + diag=diag, sid=sid, interval_seconds=interval_seconds, ssc=0 + ) + for cmd in cmd_tuple: + tc_queue.appendleft(cmd.pack_command_tuple()) + + tc_queue.appendleft((QueueCommands.WAIT, collection_time)) + + tc_queue.appendleft((QueueCommands.PRINT, f"Disabling periodic HK for {device}")) + tc_queue.appendleft( + disable_periodic_hk_command(diag=diag, sid=sid, ssc=0).pack_command_tuple() + )