diff --git a/config/definitions.py b/config/definitions.py index 7d88116..708701f 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -47,4 +47,6 @@ class CustomServiceList(enum.Enum): SUS_ASS = "sus-ass" TCS_ASS = "tcs-ass" TIME = "time" + PROCEDURE = "proc" + TVTTESTPROCEDURE = "tvtestproc" CONTROLLERS = "controllers" diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index c3dd7e8..2414fee 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -34,6 +34,7 @@ def get_eive_service_op_code_dict() -> ServiceOpCodeDictT: add_pdec_cmds(cmd_dict=service_op_code_dict) add_heater_cmds(cmd_dict=service_op_code_dict) add_tmp_sens_cmds(cmd_dict=service_op_code_dict) + add_proc_cmds(cmd_dict=service_op_code_dict) return service_op_code_dict @@ -946,6 +947,27 @@ def add_ploc_supv_cmds(cmd_dict: ServiceOpCodeDictT): ] = service_ploc_memory_dumper_tuple +def add_proc_cmds(cmd_dict: ServiceOpCodeDictT): + from pus_tc.system.proc import OpCodes, Info + + op_code_dict = dict() + add_op_code_entry(op_code_dict=op_code_dict, keys=OpCodes.HEATER, info=Info.HEATER) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.PROCEDURE.value, + info="Procedures", + op_code_entry=op_code_dict, + ) + op_code_dict = dict() + add_op_code_entry(op_code_dict=op_code_dict, keys=OpCodes.BAT_FT, info=Info.BAT_FT) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.PROCEDURE.value, + info="TV Test Procedures", + op_code_entry=op_code_dict, + ) + + def add_system_cmds(cmd_dict: ServiceOpCodeDictT): from pus_tc.system.acs import AcsOpCodes, SusOpCodes import pus_tc.system.tcs as tcs 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 new file mode 100644 index 0000000..0d3c136 --- /dev/null +++ b/pus_tc/system/proc.py @@ -0,0 +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, + 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 {device} Procedure ({device})") + ) + sid = make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET) + + listen_to_hk_for_x_seconds( + diag=False, + device=device, + sid=sid, + interval_seconds=10.0, + collection_time=120.0, + ) + + if op_code in OpCodes.PCDU_FT: + device = Info.PCDU_FT.split()[0] + tc_queue.appendleft( + (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() + ) diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 90340f4..c2e3f60 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -40,6 +40,7 @@ from pus_tc.system.acs import pack_acs_command, pack_sus_cmds from pus_tc.devs.plpcdu import pack_pl_pcdu_commands from pus_tc.devs.str_img_helper import pack_str_img_helper_command from pus_tc.system.tcs import pack_tcs_sys_commands +from pus_tc.system.proc import pack_proc_commands from pus_tc.system.controllers import pack_controller_commands from config.definitions import CustomServiceList from config.object_ids import ( @@ -221,6 +222,8 @@ def pack_service_queue_user( return pack_solar_array_deployment_test_into( object_id=SOLAR_ARRAY_DEPLOYMENT_ID, tc_queue=service_queue ) + if service == CustomServiceList.PROCEDURE.value: + return pack_proc_commands(tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.SUS_ASS.value: return pack_sus_cmds(tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.PL_PCDU.value: