diff --git a/pus_tc/devs/imtq.py b/pus_tc/devs/imtq.py index 7c1f136..3784167 100644 --- a/pus_tc/devs/imtq.py +++ b/pus_tc/devs/imtq.py @@ -211,7 +211,6 @@ def pack_imtq_test_into( z_dipole = 0 duration = 0 # ms command = pack_dipole_command(object_id, x_dipole, y_dipole, z_dipole, duration) - command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "0" or op_code == "8": @@ -225,7 +224,7 @@ def pack_imtq_test_into( def pack_dipole_command( object_id: bytearray, x_dipole: int, y_dipole: int, z_dipole: int, duration: int -) -> bytearray: +) -> PusTelecommand: """This function packs the command causing the ISIS IMTQ to generate a dipole. @param object_id The object id of the IMTQ handler. @param x_dipole The dipole of the x coil in 10^-4*Am^2 (max. 2000) @@ -242,4 +241,5 @@ def pack_dipole_command( command.extend(y_dipole.to_bytes(length=2, byteorder="big")) command.extend(z_dipole.to_bytes(length=2, byteorder="big")) command.extend(duration.to_bytes(length=2, byteorder="big")) + command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) return command diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index a6aeda8..b1a5e78 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -29,6 +29,7 @@ from pus_tc.devs.imtq import ImtqSetIds from pus_tc.system.tcs import pack_tcs_sys_commands from pus_tc.system.controllers import pack_controller_commands from pus_tc.system.acs import pack_acs_command +from pus_tc.devs.imtq import pack_dipole_command class OpCodes: @@ -67,6 +68,8 @@ PROC_INFO_DICT = { KAI.TCS_FT_ON[0]: [OpCodes.TCS_FT_ON, KAI.TCS_FT_ON[1], 120.0, 10.0], KAI.TCS_FT_OFF[0]: [OpCodes.TCS_FT_OFF, KAI.TCS_FT_OFF[1], 120.0, 10.0], KAI.ACS_FT[0]: [OpCodes.ACS_FT, KAI.ACS_FT[1], 120.0, 10.0], + KAI.MGT_FT[0]: [OpCodes.MGT_FT, KAI.MGT_FT[1], 120.0, 10.0], + KAI.MGT_FT_DP[0]: [OpCodes.MGT_FT_DP, KAI.MGT_FT_DP[1], 120.0, 10.0], } @@ -77,7 +80,7 @@ def generic_print(tc_queue: TcQueueT, info: dict): def pack_generic_hk_listening_cmds( - tc_queue: TcQueueT, proc_key: str, sid_list: list[bytearray], diag: bool + tc_queue: TcQueueT, proc_key: str, sid_list: list[bytearray], diag: bool, mgt: bool, ): info = PROC_INFO_DICT[proc_key] collection_time = info[2] @@ -92,6 +95,15 @@ def pack_generic_hk_listening_cmds( interval_seconds=info[3], ) + if mgt is True: + activate_mgts_alternately( + tc_queue=tc_queue, + ) + + else: + pass + +# collection_time maybe be reduced as a full 120seconds is not needed after MGTs are tested tc_queue.appendleft((QueueCommands.WAIT, collection_time)) for sid in sid_list: @@ -105,32 +117,20 @@ def pack_generic_hk_listening_cmds( sid_list.clear() -""" OLD - listen_to_hk_for_x_seconds( - diag=diag, - tc_queue=tc_queue, - device=proc_key, - sid=sid, - interval_seconds=info[3], - collection_time=info[2], - ) -""" - - def pack_proc_commands(tc_queue: TcQueueT, op_code: str): sid_list = [] if op_code in OpCodes.BAT_FT: key = KAI.BAT_FT[0] sid_list.append(make_sid(oids.BPX_HANDLER_ID, BpxSetIds.GET_HK_SET)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) if op_code in OpCodes.CORE_FT: key = KAI.CORE_FT[0] sid_list.append(make_sid(oids.CORE_CONTROLLER_ID, CoreSetIds.HK)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) if op_code in OpCodes.PCDU_FT: @@ -144,14 +144,14 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): sid_list.append(make_sid(oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_AUX)) sid_list.append(make_sid(oids.ACU_HANDLER_ID, GsSetIds.ACU_AUX)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) if op_code in OpCodes.RAD_SEN_FT: key = KAI.RAD_SEN_FT[0] sid_list.append(make_sid(oids.RAD_SENSOR_ID, RadSetIds.RAD_SEN_CORE)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) if op_code in OpCodes.TCS_FT_ON: @@ -177,7 +177,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): # GNSS0 sid_list.append(make_sid(oids.GPS_HANDLER_0_ID, GnssSetIds_0.CORE_HK)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -194,7 +194,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): # GNSS1 sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GnssSetIds_1.CORE_HK)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -217,7 +217,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): sid_list.append(make_sid(oids.GPS_HANDLER_0_ID, GnssSetIds_0.CORE_HK)) sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GnssSetIds_1.CORE_HK)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -225,27 +225,37 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): if op_code in OpCodes.MGT_FT: key = KAI.MGT_FT[0] +# missing imtq to ON +# mgt 1: imtq und hk + + # MISSING: imtq board activation to ON (implementation pending by Jakob) + sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET)) sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET)) sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=False ) - # mgt 1: imtq und hk - # mgt 2.: imtq + dual side + dipole + # MISSING: imtq board deactivation to OFF (implementation pending by Jakob) + +# missing imtq to ON +# mgt 2.: imtq + dual side + dipole if op_code in OpCodes.MGT_FT_DP: - key = KAI.MGT_FT[0] - pack_acs_command(tc_queue=tc_queue, op_code="acs-a") + key = KAI.MGT_FT_DP[0] + pack_acs_command(tc_queue=tc_queue, op_code="acs-d") + + # MISSING: imtq board activation to ON (implementation pending by Jakob) sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET)) sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET)) sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET)) pack_generic_hk_listening_cmds( - tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, mgt=True ) + # MISSING: imtq board deactivation to OFF (implementation pending by Jakob) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -301,3 +311,31 @@ def disable_listen_to_hk_for_x_seconds( disable_periodic_hk_command(diag=diag, sid=sid, ssc=0).pack_command_tuple() ) + +def activate_mgts_alternately( + tc_queue: TcQueueT, +): + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=2000, y_dipole=0, z_dipole=0, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0)) + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=-2000, y_dipole=0, z_dipole=0, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0)) + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=0, y_dipole=2000, z_dipole=0, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0)) + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=0, y_dipole=-2000, z_dipole=0, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0)) + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=0, y_dipole=0, z_dipole=2000, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0)) + + command = pack_dipole_command(object_id=oids.IMTQ_HANDLER_ID, x_dipole=0, y_dipole=0, z_dipole=-2000, duration=30000) + tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.WAIT, 10.0))