From f7d843131f284470080cf53181d18207b62252b9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 May 2022 10:50:44 +0200 Subject: [PATCH 1/3] new cfg class for procedures --- pus_tc/system/proc.py | 126 +++++++++++++----------------------------- 1 file changed, 39 insertions(+), 87 deletions(-) diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index 79e1e24..5ffcba9 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import List from config.definitions import CustomServiceList @@ -78,17 +79,31 @@ PROC_INFO_DICT = { 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], - # collection_time for KAI.MGT_FT_DP maybe be reduced as a full 120seconds is not needed after MGTs are tested + # collection_time for KAI.MGT_FT_DP maybe be reduced as a full 120 + # seconds is not needed after MGTs are tested KAI.MGT_FT_DP[0]: [OpCodes.MGT_FT_DP, KAI.MGT_FT_DP[1], 10.0, 10.0], KAI.SUS_FT[0]: [OpCodes.SUS_FT, KAI.SUS_FT[1], 120.0, 10.0], KAI.STR_FT[0]: [OpCodes.STR_FT, KAI.STR_FT[1], 120.0, 10.0], - # collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120seconds is not needed after RWs are tested + # collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120 + # seconds is not needed after RWs are tested KAI.RW_FT_ONE_RW[0]: [OpCodes.RW_FT_ONE_RW, KAI.RW_FT_ONE_RW[1], 10.0, 1.0], - # collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120seconds is not needed after RWs are tested + # collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120 + # seconds is not needed after RWs are tested KAI.RW_FT_TWO_RWS[0]: [OpCodes.RW_FT_TWO_RWS, KAI.RW_FT_TWO_RWS[1], 10.0, 1.0], } +class GenericHkListeningCfg: + def __init__(self, mgt: bool, one_rw: bool, two_rws: bool): + self.mgt = mgt + self.one_rw = one_rw + self.two_rws = two_rws + + @classmethod + def default(cls) -> GenericHkListeningCfg: + return GenericHkListeningCfg(False, False, False) + + def generic_print(tc_queue: TcQueueT, info: dict): tc_queue.appendleft( (QueueCommands.PRINT, f"Executing {info[1]} Procedure (OpCodes: {info[0]})") @@ -115,9 +130,7 @@ def pack_generic_hk_listening_cmds( proc_key: str, sid_list: list[bytearray], diag: bool, - mgt: bool, - one_rw: bool, - two_rws: bool, + cfg: GenericHkListeningCfg, ): info = PROC_INFO_DICT[proc_key] collection_time = info[2] @@ -132,18 +145,17 @@ def pack_generic_hk_listening_cmds( interval_seconds=info[3], ) - if mgt is True: + if cfg.mgt: activate_mgts_alternately( tc_queue=tc_queue, ) - elif one_rw is True: + elif cfg.one_rw: activate_all_rws_in_sequence( tc_queue=tc_queue, test_speed=20000, test_ramp_time=10000, init_ssc=0 ) - elif two_rws is True: + elif cfg.two_rws: activate_all_rws_two_consecutively(tc_queue=tc_queue, init_ssc=0) - else: pass @@ -170,9 +182,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) if op_code in OpCodes.CORE_FT: @@ -183,9 +193,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) if op_code in OpCodes.PCDU_FT: @@ -203,9 +211,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) if op_code in OpCodes.RAD_SEN_FT: @@ -216,9 +222,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) if op_code in OpCodes.TCS_FT_ON: @@ -250,9 +254,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -273,9 +275,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -302,9 +302,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="acs-off") @@ -318,14 +316,10 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): 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)) + cfg = GenericHkListeningCfg.default() + cfg.mgt = True pack_generic_hk_listening_cmds( - tc_queue=tc_queue, - proc_key=key, - sid_list=sid_list, - diag=False, - mgt=False, - one_rw=False, - two_rws=False, + tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, cfg=cfg ) pack_imtq_test_into(oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="0") @@ -347,9 +341,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=True, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_imtq_test_into(oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="0") @@ -384,9 +376,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="sus-off") @@ -401,9 +391,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="sus-off") @@ -420,9 +408,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_acs_command(tc_queue=tc_queue, op_code="sus-off") @@ -441,9 +427,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=False, + cfg=GenericHkListeningCfg.default(), ) pack_star_tracker_commands( @@ -478,9 +462,7 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=True, - two_rws=False, + cfg=GenericHkListeningCfg(mgt=False, one_rw=True, two_rws=False), ) # RW OFF pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="off") @@ -513,40 +495,12 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): proc_key=key, sid_list=sid_list, diag=False, - mgt=False, - one_rw=False, - two_rws=True, + cfg=GenericHkListeningCfg(mgt=False, one_rw=False, two_rws=True), ) # RW OFF pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="off") -""" -def listen_to_hk_for_x_seconds( - tc_queue: TcQueueT, - diag: bool, - device: str, - sid: bytes, - interval_seconds: float, - collection_time: float, -): - - 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() - ) -""" - - def enable_listen_to_hk_for_x_seconds( tc_queue: TcQueueT, diag: bool, @@ -561,8 +515,6 @@ def enable_listen_to_hk_for_x_seconds( for cmd in cmd_tuple: tc_queue.appendleft(cmd.pack_command_tuple()) - tc_queue.appendleft((QueueCommands.WAIT, 2.0)) - def disable_listen_to_hk_for_x_seconds( tc_queue: TcQueueT, From 851593a7bf127f9c884598ce496cbb009c40c377 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 May 2022 11:53:57 +0200 Subject: [PATCH 2/3] some improvements and updates --- config/object_ids.py | 2 +- pus_tc/devs/gps.py | 4 +- pus_tc/system/common.py | 8 +- pus_tc/system/controllers.py | 40 ++++++-- pus_tc/system/proc.py | 187 +++++++++++++++++++++++------------ pus_tc/tc_packer_hook.py | 8 +- pus_tm/hk_handling.py | 2 +- tmtccmd | 2 +- 8 files changed, 170 insertions(+), 83 deletions(-) diff --git a/config/object_ids.py b/config/object_ids.py index 60647bd..fcd9e9c 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -44,7 +44,7 @@ GYRO_0_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10]) GYRO_1_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11]) GYRO_2_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12]) GYRO_3_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13]) -GPS_HANDLER_0_ID = bytes([0x44, 0x13, 0x00, 0x45]) +GPS_CONTROLLER = bytes([0x44, 0x13, 0x00, 0x45]) GPS_HANDLER_1_ID = bytes([0x44, 0x13, 0x01, 0x46]) RW1_ID = bytes([0x44, 0x12, 0x00, 0x47]) RW2_ID = bytes([0x44, 0x12, 0x01, 0x48]) diff --git a/pus_tc/devs/gps.py b/pus_tc/devs/gps.py index 7cb8a3a..9f308ed 100644 --- a/pus_tc/devs/gps.py +++ b/pus_tc/devs/gps.py @@ -5,7 +5,7 @@ from tmtccmd.tc.definitions import TcQueueT from tmtccmd.tc.pus_8_funccmd import generate_action_command -from config.object_ids import GPS_HANDLER_1_ID, GPS_HANDLER_0_ID +from config.object_ids import GPS_HANDLER_1_ID, GPS_CONTROLLER class GpsOpCodes(enum.Enum): @@ -18,7 +18,7 @@ class SetIds: def pack_gps_command(object_id: bytes, tc_queue: TcQueueT, op_code: str): if op_code == GpsOpCodes.RESET_GNSS.value: - if object_id == GPS_HANDLER_0_ID: + if object_id == GPS_CONTROLLER: tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 0")) elif object_id == GPS_HANDLER_1_ID: tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 1")) diff --git a/pus_tc/system/common.py b/pus_tc/system/common.py index c712ea3..f6fc397 100644 --- a/pus_tc/system/common.py +++ b/pus_tc/system/common.py @@ -1,10 +1,16 @@ +from typing import Union + from tmtccmd.tc.definitions import TcQueueT, QueueCommands from spacepackets.ecss.tc import PusTelecommand from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices def command_mode( - object_id: bytes, mode: Modes, submode: int, tc_queue: TcQueueT, info: str + object_id: bytes, + mode: Union[int, Modes], + submode: int, + tc_queue: TcQueueT, + info: str, ): tc_queue.appendleft((QueueCommands.PRINT, info)) mode_data = pack_mode_data( diff --git a/pus_tc/system/controllers.py b/pus_tc/system/controllers.py index b7949d2..2f072cd 100644 --- a/pus_tc/system/controllers.py +++ b/pus_tc/system/controllers.py @@ -1,5 +1,7 @@ from tmtccmd.tc.definitions import TcQueueT from tmtccmd.config import QueueCommands +from tmtccmd.tc.pus_200_fsfw_modes import Modes +from tmtccmd.utility import ObjectId from .common import command_mode import config.object_ids as obj_ids @@ -8,8 +10,8 @@ from pus_tc.prompt_parameters import prompt_parameters class OpCodes: - THERMAL_CONTROLLER = [obj_ids.THERMAL_CONTROLLER_ID.hex(), "thermal_controller"] - CORE_CONTROLLER = [obj_ids.CORE_CONTROLLER_ID.hex(), "core_controller"] + THERMAL_CONTROLLER = [obj_ids.THERMAL_CONTROLLER_ID.hex(), "ctrl-th"] + CORE_CONTROLLER = [obj_ids.CORE_CONTROLLER_ID.hex(), "ctrl-core"] class Info: @@ -17,7 +19,7 @@ class Info: CORE_CONTROLLER = "ACS controller" -def pack_controller_commands(tc_queue: TcQueueT, op_code: str): +def pack_cmd_ctrl_to_prompted_mode(tc_queue: TcQueueT, object_id: ObjectId): parameters = prompt_parameters( [ {"name": "Mode", "defaultValue": "2"}, @@ -30,21 +32,41 @@ def pack_controller_commands(tc_queue: TcQueueT, op_code: str): mode = 0 submode = int(parameters["Submode"]) command_mode( - object_id=get_object_from_op_code(op_code), + object_id=object_id.as_bytes, mode=mode, submode=submode, tc_queue=tc_queue, - info=op_code + " to " + str(mode) + "," + str(submode), + info=f"Commanding {object_id} to {mode}, {submode}", ) - tc_queue.appendleft((QueueCommands.WAIT, 20)) +def pack_cmd_ctrl_to_off(tc_queue: TcQueueT, object_id: ObjectId): command_mode( - object_id=get_object_from_op_code(op_code), - mode=0, + object_id=object_id.as_bytes, + mode=Modes.OFF, submode=0, tc_queue=tc_queue, - info=op_code + " to 0,0", + info=f"Commanding {object_id} OFF", + ) + + +def pack_cmd_ctrl_to_on(tc_queue: TcQueueT, object_id: ObjectId): + command_mode( + object_id=object_id.as_bytes, + mode=Modes.ON, + submode=0, + tc_queue=tc_queue, + info=f"Commanding {object_id} ON", + ) + + +def pack_cmd_ctrl_to_nml(tc_queue: TcQueueT, object_id: ObjectId): + command_mode( + object_id=object_id.as_bytes, + mode=Modes.NORMAL, + submode=0, + tc_queue=tc_queue, + info=f"Commanding {object_id} NORMAL", ) diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index 5ffcba9..7c6a4b6 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -1,7 +1,11 @@ from __future__ import annotations + +import time from typing import List from config.definitions import CustomServiceList +from config.object_ids import get_object_ids +from pus_tc.system.tcs import pack_tcs_sys_commands from tmtccmd.config import ( QueueCommands, ServiceOpCodeDictT, @@ -9,25 +13,29 @@ from tmtccmd.config import ( add_service_op_code_entry, ) from tmtccmd.tc.definitions import TcQueueT +from tmtccmd.tc.pus_11_tc_sched import ( + generate_time_tagged_cmd, + generate_enable_tc_sched_cmd, + generate_reset_tc_sched_cmd, +) from tmtccmd.tc.pus_3_fsfw_hk import * import config.object_ids as oids +from pus_tc.system.tcs import OpCodes as TcsOpCodes from pus_tc.devs.bpx_batt import BpxSetIds from pus_tc.system.core import SetIds as CoreSetIds from gomspace.gomspace_common import SetIds as GsSetIds from pus_tc.devs.rad_sensor import SetIds as RadSetIds -from pus_tc.devs.mgms import MgmLis3SetIds as MgmSetIds_0_2 -from pus_tc.devs.mgms import MgmRm3100SetIds as MgmSetIds_1_3 -from pus_tc.devs.gyros import AdisGyroSetIds as GyroSetIds_0_2 -from pus_tc.devs.gyros import L3gGyroSetIds as GyroSetIds_1_3 +from pus_tc.devs.mgms import MgmLis3SetIds as MgmLis3SetIds_0_2 +from pus_tc.devs.mgms import MgmRm3100SetIds as MgmRm3100SetIds_1_3 +from pus_tc.devs.gyros import AdisGyroSetIds as AdisGyroSetIds_0_2 +from pus_tc.devs.gyros import L3gGyroSetIds as L3gGyroSetIds_1_3 from pus_tc.devs.gps import SetIds as GpsSetIds from pus_tc.devs.imtq import ImtqSetIds from pus_tc.devs.sus import SetIds from pus_tc.devs.star_tracker import SetIds as StrSetIds from pus_tc.devs.reaction_wheels import RwSetIds - -from pus_tc.system.tcs import pack_tcs_sys_commands -from pus_tc.system.controllers import pack_controller_commands +from pus_tc.system.controllers import pack_cmd_ctrl_to_off, pack_cmd_ctrl_to_nml from pus_tc.system.acs import pack_acs_command, pack_sus_cmds from pus_tc.devs.imtq import pack_imtq_test_into, pack_dipole_command from pus_tc.devs.star_tracker import pack_star_tracker_commands @@ -35,13 +43,13 @@ from pus_tc.devs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command class OpCodes: - HEATER = ["0", "heater"] + TV_SETUP_TCS_FT_ON = ["setup", "tcs-ft-on"] + RESET_SCHED = ["reset-sched", "rs"] + HEATER = ["heater"] BAT_FT = ["bat-ft"] CORE_FT = ["core-ft"] PCDU_FT = ["pcdu-ft"] RAD_SEN_FT = ["rad-sen-ft"] - TCS_FT_ON = ["tcs-ft-on"] - TCS_FT_OFF = ["tcs-ft-off"] ACS_FT = ["acs-ft"] MGT_FT = ["mgt-ft"] MGT_FT_DP = ["mgt-ft-dp"] @@ -49,16 +57,17 @@ class OpCodes: STR_FT = ["str-ft"] RW_FT_ONE_RW = ["rw-ft-one-rw"] RW_FT_TWO_RWS = ["rw-ft-two-rws"] + TV_TEARDOWN_TCS_FT_OFF = ["teardown", "tcs-ft-off"] class KeyAndInfo: + TV_SETUP_TCS_FT_ON = ["TCS Act.", "TCS functional test activation"] + RESET_SCHED = ["Reset Sched", "Reset/Clear TC schedule"] HEATER = ["Heater", "heater procedure"] BAT_FT = ["BPX Battery", "battery functional test"] CORE_FT = ["OBC", "OBC functional test"] PCDU_FT = ["PCDU", "PCDU functional test"] RAD_SEN_FT = ["Radiation Sensor", "Radiation Sensor functional test"] - TCS_FT_ON = ["TCS Act.", "TCS functional test activation"] - TCS_FT_OFF = ["TCS Deact.", "TCS functional test deactivation"] ACS_FT = ["ACS", "ACS functional test"] MGT_FT = ["MGT", "MGT functional test"] MGT_FT_DP = ["MGT dipole", "MGT functional test with dipole"] @@ -66,6 +75,7 @@ class KeyAndInfo: STR_FT = ["STR", "STR functional test"] RW_FT_ONE_RW = ["RW ONE RW", "RW functional test with one RW"] RW_FT_TWO_RWS = ["RW TWO RWS", "RW functional test with two RWs"] + TV_TEARDOWN_TCS_FT_OFF = ["TCS Deact.", "TCS functional test deactivation"] KAI = KeyAndInfo @@ -75,8 +85,13 @@ PROC_INFO_DICT = { KAI.CORE_FT[0]: [OpCodes.CORE_FT, KAI.CORE_FT[1], 120.0, 10.0], KAI.PCDU_FT[0]: [OpCodes.PCDU_FT, KAI.PCDU_FT[1], 120.0, 10.0], KAI.RAD_SEN_FT[0]: [OpCodes.RAD_SEN_FT, KAI.RAD_SEN_FT[1], 120.0, 10.0], - 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.TCS_FT_ON[0]: [OpCodes.TV_SETUP_TCS_FT_ON, KAI.TCS_FT_ON[1], 120.0, 10.0], + KAI.TV_TEARDOWN_TCS_FT_OFF[0]: [ + OpCodes.TV_TEARDOWN_TCS_FT_OFF, + KAI.TV_TEARDOWN_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], # collection_time for KAI.MGT_FT_DP maybe be reduced as a full 120 @@ -94,7 +109,8 @@ PROC_INFO_DICT = { class GenericHkListeningCfg: - def __init__(self, mgt: bool, one_rw: bool, two_rws: bool): + def __init__(self, mgt: bool = False, one_rw: bool = False, two_rws: bool = False): + self.use_tc_sched = False self.mgt = mgt self.one_rw = one_rw self.two_rws = two_rws @@ -111,7 +127,6 @@ def generic_print(tc_queue: TcQueueT, info: dict): def add_proc_cmds(cmd_dict: ServiceOpCodeDictT): - op_code_dict = dict() for proc_entry in PROC_INFO_DICT.values(): add_op_code_entry( @@ -144,6 +159,8 @@ def pack_generic_hk_listening_cmds( sid=sid, interval_seconds=info[3], ) + if not cfg.use_tc_sched: + tc_queue.appendleft((QueueCommands.WAIT, 2.0)) if cfg.mgt: activate_mgts_alternately( @@ -159,21 +176,41 @@ def pack_generic_hk_listening_cmds( else: pass - tc_queue.appendleft((QueueCommands.WAIT, collection_time)) - + if not cfg.use_tc_sched: + tc_queue.appendleft((QueueCommands.WAIT, collection_time)) + disable_cmd_list = [] for sid in sid_list: - disable_listen_to_hk_for_x_seconds( - diag=diag, - tc_queue=tc_queue, - device=proc_key, - sid=sid, + disable_cmd_list.append( + gen_disable_listen_to_hk_for_x_seconds( + diag=diag, + tc_queue=tc_queue, + device=proc_key, + sid=sid, + ) ) - + current_time = time.time() + current_time += collection_time + if not cfg.use_tc_sched: + for cmd in disable_cmd_list: + tc_queue.appendleft(cmd.pack_command_tuple()) + else: + for cmd in disable_cmd_list: + tc_queue.appendleft( + generate_time_tagged_cmd( + release_time=struct.pack("!I", current_time), + tc_to_insert=cmd, + ssc=0, + ) + ) sid_list.clear() def pack_proc_commands(tc_queue: TcQueueT, op_code: str): sid_list = [] + obj_id_dict = get_object_ids() + if op_code in OpCodes.RESET_SCHED: + tc_queue.appendleft((QueueCommands.PRINT, "Resetting/Clearing TC schedule")) + tc_queue.appendleft(generate_reset_tc_sched_cmd().pack_command_tuple()) 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)) @@ -225,30 +262,45 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): cfg=GenericHkListeningCfg.default(), ) - if op_code in OpCodes.TCS_FT_ON: + if op_code in OpCodes.TV_SETUP_TCS_FT_ON: + # Enable scheduling + tc_queue.appendleft(generate_enable_tc_sched_cmd().pack_command_tuple()) # check whether tcs_assembly also has to be commanded to NORMAL Mode - # pack_tcs_sys_commands(tc_queue=tc_queue, op_code="tcs-normal") - pack_controller_commands(tc_queue=tc_queue, op_code="thermal_controller") + pack_tcs_sys_commands( + tc_queue=tc_queue, op_code=TcsOpCodes.TCS_BOARD_ASS_NORMAL[0] + ) + pack_cmd_ctrl_to_nml( + tc_queue=tc_queue, object_id=obj_id_dict.get(oids.THERMAL_CONTROLLER_ID) + ) - if op_code in OpCodes.TCS_FT_OFF: - # check whether tcs_assembly also has to be commanded to OFF Mode - # pack_tcs_sys_commands(tc_queue=tc_queue, op_code="tcs-off") - pack_controller_commands(tc_queue=tc_queue, op_code="thermal_controller") + if op_code in OpCodes.TV_TEARDOWN_TCS_FT_OFF: + # TCS board shold always be on anyway, do not command it off here + pack_cmd_ctrl_to_off( + tc_queue=tc_queue, object_id=obj_id_dict.get(oids.THERMAL_CONTROLLER_ID) + ) if op_code in OpCodes.ACS_FT: key = KAI.ACS_FT[0] - + a_side_pairs = [ + (oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK), + (oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK), + (oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK), + (oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK), + (oids.GPS_CONTROLLER, GpsSetIds.HK), + ] + b_side_pairs = [ + (oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK), + (oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK), + (oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK), + (oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK), + (oids.GPS_CONTROLLER, GpsSetIds.HK), + ] pack_acs_command(tc_queue=tc_queue, op_code="acs-a") - # MGMs - sid_list.append(make_sid(oids.MGM_0_LIS3_HANDLER_ID, MgmSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.MGM_1_RM3100_HANDLER_ID, MgmSetIds_1_3.CORE_HK)) - # Gyros - sid_list.append(make_sid(oids.GYRO_0_ADIS_HANDLER_ID, GyroSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.GYRO_0_ADIS_HANDLER_ID, GyroSetIds_0_2.CFG_HK)) - sid_list.append(make_sid(oids.GYRO_1_L3G_HANDLER_ID, GyroSetIds_1_3.CORE_HK)) - # GNSS0 - sid_list.append(make_sid(oids.GPS_HANDLER_0_ID, GpsSetIds.HK)) + for a_side_dev in a_side_pairs: + oid = a_side_dev[0] + set_id = a_side_dev[1] + sid_list.append(make_sid(oid, set_id)) pack_generic_hk_listening_cmds( tc_queue=tc_queue, proc_key=key, @@ -261,13 +313,10 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): tc_queue.appendleft((QueueCommands.WAIT, 5.0)) pack_acs_command(tc_queue=tc_queue, op_code="acs-b") - # MGMs - sid_list.append(make_sid(oids.MGM_2_LIS3_HANDLER_ID, MgmSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.MGM_3_RM3100_HANDLER_ID, MgmSetIds_1_3.CORE_HK)) - # Gyros - sid_list.append(make_sid(oids.GYRO_2_ADIS_HANDLER_ID, GyroSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.GYRO_2_ADIS_HANDLER_ID, GyroSetIds_0_2.CFG_HK)) - sid_list.append(make_sid(oids.GYRO_3_L3G_HANDLER_ID, GyroSetIds_1_3.CORE_HK)) + for b_side_dev in b_side_pairs: + oid = b_side_dev[0] + set_id = b_side_dev[1] + sid_list.append(make_sid(oid, set_id)) # GNSS1 sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GpsSetIds.HK)) pack_generic_hk_listening_cmds( @@ -283,19 +332,31 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str): pack_acs_command(tc_queue=tc_queue, op_code="acs-d") # MGMs - sid_list.append(make_sid(oids.MGM_0_LIS3_HANDLER_ID, MgmSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.MGM_1_RM3100_HANDLER_ID, MgmSetIds_1_3.CORE_HK)) - sid_list.append(make_sid(oids.MGM_2_LIS3_HANDLER_ID, MgmSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.MGM_3_RM3100_HANDLER_ID, MgmSetIds_1_3.CORE_HK)) + sid_list.append(make_sid(oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK)) + sid_list.append( + make_sid(oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK) + ) + sid_list.append(make_sid(oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK)) + sid_list.append( + make_sid(oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK) + ) # Gyros - sid_list.append(make_sid(oids.GYRO_0_ADIS_HANDLER_ID, GyroSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.GYRO_0_ADIS_HANDLER_ID, GyroSetIds_0_2.CFG_HK)) - sid_list.append(make_sid(oids.GYRO_1_L3G_HANDLER_ID, GyroSetIds_1_3.CORE_HK)) - sid_list.append(make_sid(oids.GYRO_2_ADIS_HANDLER_ID, GyroSetIds_0_2.CORE_HK)) - sid_list.append(make_sid(oids.GYRO_2_ADIS_HANDLER_ID, GyroSetIds_0_2.CFG_HK)) - sid_list.append(make_sid(oids.GYRO_3_L3G_HANDLER_ID, GyroSetIds_1_3.CORE_HK)) + sid_list.append( + make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK) + ) + sid_list.append( + make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK) + ) + sid_list.append(make_sid(oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK)) + sid_list.append( + make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK) + ) + sid_list.append( + make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK) + ) + sid_list.append(make_sid(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK)) # GNSS0+1 - sid_list.append(make_sid(oids.GPS_HANDLER_0_ID, GpsSetIds.HK)) + sid_list.append(make_sid(oids.GPS_CONTROLLER, GpsSetIds.HK)) sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GpsSetIds.HK)) pack_generic_hk_listening_cmds( tc_queue=tc_queue, @@ -516,16 +577,14 @@ def enable_listen_to_hk_for_x_seconds( tc_queue.appendleft(cmd.pack_command_tuple()) -def disable_listen_to_hk_for_x_seconds( +def gen_disable_listen_to_hk_for_x_seconds( tc_queue: TcQueueT, diag: bool, device: str, sid: bytes, -): +) -> PusTelecommand: 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() - ) + return disable_periodic_hk_command(diag=diag, sid=sid, ssc=0) def activate_mgts_alternately( diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 137877b..752e19a 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -42,7 +42,7 @@ 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 pus_tc.system.controllers import pack_cmd_ctrl_to_prompted_mode from config.definitions import CustomServiceList from config.object_ids import ( get_object_ids, @@ -63,7 +63,7 @@ from config.object_ids import ( PLOC_SUPV_ID, STAR_TRACKER_ID, PLOC_MEMORY_DUMPER_ID, - GPS_HANDLER_0_ID, + GPS_CONTROLLER, GPS_HANDLER_1_ID, CCSDS_HANDLER_ID, PDEC_HANDLER_ID, @@ -208,7 +208,7 @@ def pack_service_queue_user( return pack_acs_command(tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.GPS_0.value: return pack_gps_command( - object_id=GPS_HANDLER_0_ID, tc_queue=service_queue, op_code=op_code + object_id=GPS_CONTROLLER, tc_queue=service_queue, op_code=op_code ) if service == CustomServiceList.GPS_1.value: return pack_gps_command( @@ -247,7 +247,7 @@ def pack_service_queue_user( tc_queue=service_queue, object_id=RW_ASSEMBLY, op_code=op_code ) if service == CustomServiceList.CONTROLLERS.value: - return pack_controller_commands(tc_queue=service_queue, op_code=op_code) + return pack_cmd_ctrl_to_prompted_mode(tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !") diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index cad39ab..40a74e4 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -95,7 +95,7 @@ def handle_regular_hk_print( return handle_raw_mtm_measurement(printer, hk_data) else: LOGGER.info("Service 3 TM: IMTQ handler reply with unknown set id") - if objb == obj_ids.GPS_HANDLER_0_ID or object_id == obj_ids.GPS_HANDLER_1_ID: + if objb == obj_ids.GPS_CONTROLLER or object_id == obj_ids.GPS_HANDLER_1_ID: handle_gps_data(printer=printer, hk_data=hk_data) if objb == obj_ids.BPX_HANDLER_ID: handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, printer=printer) diff --git a/tmtccmd b/tmtccmd index 2354f5d..eaed332 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 2354f5d2778c7681ddf6602766dd4e68b943e1c0 +Subproject commit eaed332a69885c19912827eb71440e8562935d36 From 44adf6cf1ecfdd10dba67739cec9bcf23327d159 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 May 2022 14:16:47 +0200 Subject: [PATCH 3/3] small fix --- pus_tc/system/proc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index 7c6a4b6..775d469 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -85,7 +85,7 @@ PROC_INFO_DICT = { KAI.CORE_FT[0]: [OpCodes.CORE_FT, KAI.CORE_FT[1], 120.0, 10.0], KAI.PCDU_FT[0]: [OpCodes.PCDU_FT, KAI.PCDU_FT[1], 120.0, 10.0], KAI.RAD_SEN_FT[0]: [OpCodes.RAD_SEN_FT, KAI.RAD_SEN_FT[1], 120.0, 10.0], - KAI.TCS_FT_ON[0]: [OpCodes.TV_SETUP_TCS_FT_ON, KAI.TCS_FT_ON[1], 120.0, 10.0], + KAI.TV_SETUP_TCS_FT_ON[0]: [OpCodes.TV_SETUP_TCS_FT_ON, KAI.TV_SETUP_TCS_FT_ON[1], 120.0, 10.0], KAI.TV_TEARDOWN_TCS_FT_OFF[0]: [ OpCodes.TV_TEARDOWN_TCS_FT_OFF, KAI.TV_TEARDOWN_TCS_FT_OFF[1],