From b2bab4c964848d6f78a6f44525166dcf24cc46b6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Oct 2022 17:26:43 +0200 Subject: [PATCH] some more cleaning up --- .run/IMTQ Dipole.run.xml | 24 +++++++++++++++++++++ pus_tc/cmd_definitions.py | 20 ------------------ pus_tc/procedure_packer.py | 4 ++-- pus_tc/system/proc.py | 9 ++++---- pus_tm/action_reply_handler.py | 2 +- pus_tm/hk_handling.py | 4 ++-- tmtc/acs/__init__.py | 0 {pus_tc/devs => tmtc/acs}/imtq.py | 35 ++++++++++++++++++++++++++++--- tmtc/{ => acs}/reaction_wheels.py | 0 9 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 .run/IMTQ Dipole.run.xml create mode 100644 tmtc/acs/__init__.py rename {pus_tc/devs => tmtc/acs}/imtq.py (88%) rename tmtc/{ => acs}/reaction_wheels.py (100%) diff --git a/.run/IMTQ Dipole.run.xml b/.run/IMTQ Dipole.run.xml new file mode 100644 index 0000000..b027275 --- /dev/null +++ b/.run/IMTQ Dipole.run.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index f9fe83e..31a26cf 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -185,26 +185,6 @@ def add_time_cmds(defs: TmtcDefinitionWrapper): ) -@tmtc_definitions_provider -def add_imtq_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add("0", "Mode Off") - oce.add("1", "Mode On") - oce.add("2", "Mode Normal") - oce.add("3", "IMTQ perform pos X self test") - oce.add("4", "IMTQ perform neg X self test") - oce.add("5", "IMTQ perform pos Y self test") - oce.add("6", "IMTQ perform neg Y self test") - oce.add("7", "IMTQ perform pos Z self test") - oce.add("8", "IMTQ perform neg Z self test") - oce.add("9", "IMTQ command dipole") - oce.add("10", "IMTQ get commanded dipole") - oce.add("11", "IMTQ get engineering hk set") - oce.add("12", "IMTQ get calibrated MTM measurement one shot") - oce.add("13", "IMTQ get raw MTM measurement one shot") - defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce) - - @tmtc_definitions_provider def add_system_cmds(defs: TmtcDefinitionWrapper): from pus_tc.system.acs import AcsOpCodes, SusOpCodes diff --git a/pus_tc/procedure_packer.py b/pus_tc/procedure_packer.py index 6b4767f..a788af3 100644 --- a/pus_tc/procedure_packer.py +++ b/pus_tc/procedure_packer.py @@ -27,10 +27,10 @@ from tmtc.power.p60dock import pack_p60dock_cmds from tmtc.power.pdu2 import pack_pdu2_commands from tmtc.power.pdu1 import pack_pdu1_commands from tmtc.power.acu import pack_acu_commands -from pus_tc.devs.imtq import pack_imtq_test_into +from tmtc.acs.imtq import pack_imtq_test_into from pus_tc.devs.tmp1075 import pack_tmp1075_test_into from pus_tc.devs.heater import pack_heater_cmds -from tmtc.reaction_wheels import pack_single_rw_test_into, pack_rw_ass_cmds +from tmtc.acs.reaction_wheels import pack_single_rw_test_into, pack_rw_ass_cmds from pus_tc.devs.rad_sensor import pack_rad_sensor_test_into from tmtc.ploc_memory_dumper import pack_ploc_memory_dumper_cmd from pus_tc.devs.ccsds_handler import pack_ccsds_handler_test diff --git a/pus_tc/system/proc.py b/pus_tc/system/proc.py index 5eeaa21..081419f 100644 --- a/pus_tc/system/proc.py +++ b/pus_tc/system/proc.py @@ -2,7 +2,6 @@ from __future__ import annotations import time from datetime import timedelta -from typing import List from config.definitions import CustomServiceList from config.object_ids import get_object_ids @@ -30,15 +29,15 @@ 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.syrlinks_hk_handler import SetIds as SyrlinksSetIds from pus_tc.devs.gps import SetIds as GpsSetIds -from pus_tc.devs.imtq import ImtqSetIds +from tmtc.acs.imtq import ImtqSetIds from pus_tc.devs.sus import SetIds from pus_tc.devs.star_tracker import SetIds as StrSetIds -from tmtc.reaction_wheels import RwSetIds, rw_speed_up_cmd_consec +from tmtc.acs.reaction_wheels import RwSetIds, rw_speed_up_cmd_consec 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 tmtc.acs.imtq import pack_imtq_test_into, pack_dipole_command from pus_tc.devs.star_tracker import pack_star_tracker_commands -from tmtc.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command +from tmtc.acs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command class OpCodes: diff --git a/pus_tm/action_reply_handler.py b/pus_tm/action_reply_handler.py index 520ae26..cb07dc4 100644 --- a/pus_tm/action_reply_handler.py +++ b/pus_tm/action_reply_handler.py @@ -1,6 +1,6 @@ import struct from config.object_ids import * -from pus_tc.devs.imtq import ImtqActionIds +from tmtc.acs.imtq import ImtqActionIds from pus_tm.defs import PrintWrapper from tmtc.ploc_mpsoc import PlocReplyIds from tmtc.ploc_supervisor import SupvActionIds diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 4be8f0d..24b0475 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -6,7 +6,7 @@ from pus_tm.devs.rad_sensor import handle_rad_sensor_data from pus_tm.devs.sus import handle_sus_hk from pus_tm.system.tcs import handle_thermal_controller_hk_data from tmtc.ploc_supervisor import handle_supv_hk_data -from tmtc.reaction_wheels import handle_rw_hk_data +from tmtc.acs.reaction_wheels import handle_rw_hk_data from tmtccmd.tm.pus_3_fsfw_hk import ( Service3Base, HkContentType, @@ -26,7 +26,7 @@ from pus_tm.devs.imtq_mgt import ( ) from tmtc.power.tm import handle_pdu_data, handle_p60_hk_data, handle_acu_hk_data from pus_tm.devs.syrlinks import handle_syrlinks_hk_data -from pus_tc.devs.imtq import ImtqSetIds +from tmtc.acs.imtq import ImtqSetIds from pus_tm.defs import FsfwTmTcPrinter from pus_tm.system.core import handle_core_hk_data from pus_tm.devs.mgms import handle_mgm_hk_data diff --git a/tmtc/acs/__init__.py b/tmtc/acs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pus_tc/devs/imtq.py b/tmtc/acs/imtq.py similarity index 88% rename from pus_tc/devs/imtq.py rename to tmtc/acs/imtq.py index 46f532d..2287ce9 100644 --- a/pus_tc/devs/imtq.py +++ b/tmtc/acs/imtq.py @@ -7,7 +7,13 @@ """ import struct +from config.definitions import CustomServiceList from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.config.tmtc import ( + tmtc_definitions_provider, + OpCodeEntry, + TmtcDefinitionWrapper, +) from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_3_fsfw_hk import ( make_sid, @@ -22,6 +28,7 @@ class OpCodes: ON = ["on"] NORMAL = ["normal"] OFF = ["off"] + SET_DIPOLE = ["set_dipole"] class ImtqSetIds: @@ -50,6 +57,26 @@ class ImtqActionIds: read_self_test_results = bytearray([0x0, 0x0, 0x0, 0x0D]) +@tmtc_definitions_provider +def add_imtq_cmds(defs: TmtcDefinitionWrapper): + oce = OpCodeEntry() + oce.add(OpCodes.OFF, "Mode Off") + oce.add(OpCodes.ON, "Mode On") + oce.add(OpCodes.NORMAL, "Mode Normal") + oce.add("3", "IMTQ perform pos X self test") + oce.add("4", "IMTQ perform neg X self test") + oce.add("5", "IMTQ perform pos Y self test") + oce.add("6", "IMTQ perform neg Y self test") + oce.add("7", "IMTQ perform pos Z self test") + oce.add("8", "IMTQ perform neg Z self test") + oce.add(OpCodes.SET_DIPOLE, "IMTQ command dipole") + oce.add("10", "IMTQ get commanded dipole") + oce.add("11", "IMTQ get engineering hk set") + oce.add("12", "IMTQ get calibrated MTM measurement one shot") + oce.add("13", "IMTQ get raw MTM measurement one shot") + defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce) + + def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): q.add_log_cmd( f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}" @@ -140,9 +167,7 @@ def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_cod sid = make_sid(object_id.as_bytes, ImtqSetIds.NEGATIVE_Z_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == "9": - q.add_log_cmd("IMTQ: Commanding dipole") - + if op_code in OpCodes.SET_DIPOLE: x_dipole = int(input("Specify X dipole [range [0, 2000] * 10^-4 * Am^2]: ")) y_dipole = int(input("Specify Y dipole [range [0, 2000] * 10^-4 * Am^2]: ")) z_dipole = int(input("Specify Z dipole [range [0, 2000] * 10^-4 * Am^2]: ")) @@ -152,6 +177,10 @@ def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_cod f"0 for continuous generation until update]: " ) ) + dur_str = "infinite" if duration == 0 else str(duration) + q.add_log_cmd( + f"IMTQ: Commanding dipole X={x_dipole}, Y={y_dipole}, Z={y_dipole}, duration={dur_str}" + ) q.add_pus_tc( pack_dipole_command( object_id.as_bytes, x_dipole, y_dipole, z_dipole, duration diff --git a/tmtc/reaction_wheels.py b/tmtc/acs/reaction_wheels.py similarity index 100% rename from tmtc/reaction_wheels.py rename to tmtc/acs/reaction_wheels.py