diff --git a/eive_tmtc/pus_tc/devs/tmp1075.py b/eive_tmtc/pus_tc/devs/tmp1075.py index 0f6f403..37dcd1c 100644 --- a/eive_tmtc/pus_tc/devs/tmp1075.py +++ b/eive_tmtc/pus_tc/devs/tmp1075.py @@ -5,10 +5,13 @@ @author J. Meier @date 06.01.2021 """ +import enum + from spacepackets.ecss.tc import PusTelecommand from eive_tmtc.pus_tc.service_200_mode import pack_mode_data from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_modes import Mode +from tmtccmd.tc.pus_8_funccmd import make_action_id from tmtccmd.util import ObjectIdU32 @@ -28,9 +31,9 @@ class Tmp1075TestProcedure: set_mode_on = False # If mode is MODE_ON, temperature will only be read on command -class Tmp1075ActionId: - get_temp = bytearray([0x0, 0x0, 0x0, 0x01]) - start_adc_conversion = bytearray([0x0, 0x0, 0x0, 0x02]) +class Tmp1075ActionId(enum.IntEnum): + GET_TEMP = 1 + START_ADC_CONV = 2 def pack_tmp1075_test_into( @@ -42,11 +45,11 @@ def pack_tmp1075_test_into( obyt = object_id.as_bytes if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion: q.add_log_cmd("TMP1075: Starting new temperature conversion") - command = obyt + Tmp1075ActionId.start_adc_conversion + command = obyt + make_action_id(Tmp1075ActionId.GET_TEMP) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp: q.add_log_cmd("TMP1075: Read temperature") - command = obyt + Tmp1075ActionId.get_temp + command = obyt + make_action_id(Tmp1075ActionId.START_ADC_CONV) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if Tmp1075TestProcedure.set_mode_normal: diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 7195cdb..8d80392 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -9,6 +9,7 @@ from eive_tmtc.pus_tc.system.controllers import ( pack_cmd_ctrl_to_prompted_mode, get_object_from_op_code, ) +from eive_tmtc.tmtc.tcs import pack_tcs_sys_commands from tmtccmd import DefaultProcedureInfo, TcHandlerBase from tmtccmd.config import CoreServiceList from tmtccmd.logging import get_console_logger @@ -20,7 +21,6 @@ from tmtccmd.tc.decorator import ( from tmtccmd.tc.pus_5_event import ( pack_generic_service_5_test_into, ) -from tmtccmd.pus.pus_17_test import pack_service_17_ping_command from eive_tmtc.pus_tc.service_200_mode import pack_service_200_test_into from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds @@ -42,10 +42,8 @@ from eive_tmtc.pus_tc.devs.star_tracker import pack_star_tracker_commands from eive_tmtc.pus_tc.devs.syrlinks_hk_handler import pack_syrlinks_command from eive_tmtc.pus_tc.devs.gps import pack_gps_command from eive_tmtc.tmtc.acs.acs_board import pack_acs_command -from eive_tmtc.tmtc.acs.sus_board import pack_sus_cmds from eive_tmtc.pus_tc.devs.plpcdu import pack_pl_pcdu_commands from eive_tmtc.pus_tc.devs.str_img_helper import pack_str_img_helper_command -from eive_tmtc.pus_tc.system.tcs import pack_tcs_sys_commands from eive_tmtc.pus_tc.system.proc import pack_proc_commands from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import ( diff --git a/eive_tmtc/pus_tc/system/proc.py b/eive_tmtc/pus_tc/system/proc.py index 6fc3bdd..d078434 100644 --- a/eive_tmtc/pus_tc/system/proc.py +++ b/eive_tmtc/pus_tc/system/proc.py @@ -5,7 +5,6 @@ from datetime import timedelta from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import get_object_ids -from eive_tmtc.pus_tc.system.tcs import pack_tcs_sys_commands from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider @@ -19,7 +18,7 @@ from tmtccmd.tc.pus_11_tc_sched import ( from tmtccmd.tc.pus_3_fsfw_hk import * import eive_tmtc.config.object_ids as oids -from eive_tmtc.pus_tc.system.tcs import OpCode as TcsOpCodes +from eive_tmtc.tmtc.tcs import OpCode as TcsOpCodes, pack_tcs_sys_commands from eive_tmtc.pus_tc.devs.bpx_batt import BpxSetId from eive_tmtc.tmtc.core import SetId as CoreSetIds from eive_tmtc.tmtc.power.common_power import SetId as GsSetIds diff --git a/eive_tmtc/pus_tc/system/tcs.py b/eive_tmtc/pus_tc/system/tcs.py deleted file mode 100644 index cdd4353..0000000 --- a/eive_tmtc/pus_tc/system/tcs.py +++ /dev/null @@ -1,78 +0,0 @@ -import enum - -from eive_tmtc.config.definitions import CustomServiceList -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry -from tmtccmd.config.tmtc import tmtc_definitions_provider -from tmtccmd.tc import DefaultPusQueueHelper -from tmtccmd.tc.pus_200_fsfw_modes import Mode -from tmtccmd.tc.pus_3_fsfw_hk import ( - make_sid, - generate_one_hk_command, -) - -from eive_tmtc.tmtc.common import pack_mode_cmd_with_info -from eive_tmtc.config.object_ids import TCS_BOARD_ASS_ID, TCS_CONTROLLER - - -class OpCode: - TCS_BOARD_ASS_NORMAL = ["0", "normal"] - TCS_BOARD_ASS_OFF = ["1", "off"] - REQUEST_SENSOR_TEMP_SET = ["2", "temps"] - - -class Info: - REQUEST_SENSOR_TEMP_SET = "Request HK set of primary sensor temperatures" - TCS_BOARD_ASS_NORMAL = "Switching TCS board assembly on" - TCS_BOARD_ASS_OFF = "Switching TCS board assembly off" - - -class SetId(enum.IntEnum): - PRIMARY_SENSORS = 0 - DEVICE_SENSORS = 1 - SUS_TEMP_SENSORS = 2 - - -@tmtc_definitions_provider -def add_tcs_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add( - keys=OpCode.TCS_BOARD_ASS_NORMAL, - info=Info.TCS_BOARD_ASS_NORMAL, - ) - oce.add( - keys=OpCode.TCS_BOARD_ASS_OFF, - info=Info.TCS_BOARD_ASS_OFF, - ) - oce.add(keys=OpCode.REQUEST_SENSOR_TEMP_SET, info=Info.REQUEST_SENSOR_TEMP_SET) - defs.add_service( - name=CustomServiceList.TCS.value, - info="TCS Board Assembly", - op_code_entry=oce, - ) - - -def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str): - if op_code in OpCode.REQUEST_SENSOR_TEMP_SET: - sensor_set_sid = make_sid(TCS_CONTROLLER, SetId.PRIMARY_SENSORS) - q.add_log_cmd(Info.REQUEST_SENSOR_TEMP_SET) - q.add_pus_tc(generate_one_hk_command(sensor_set_sid)) - pack_tcs_ass_cmds(q, op_code) - - -def pack_tcs_ass_cmds(q: DefaultPusQueueHelper, op_code: str): - if op_code in OpCode.TCS_BOARD_ASS_NORMAL: - pack_mode_cmd_with_info( - object_id=TCS_BOARD_ASS_ID, - mode=Mode.NORMAL, - submode=0, - q=q, - info=Info.TCS_BOARD_ASS_NORMAL, - ) - if op_code in OpCode.TCS_BOARD_ASS_OFF: - pack_mode_cmd_with_info( - object_id=TCS_BOARD_ASS_ID, - mode=Mode.OFF, - submode=0, - q=q, - info=Info.TCS_BOARD_ASS_OFF, - ) diff --git a/eive_tmtc/pus_tm/hk_handling.py b/eive_tmtc/pus_tm/hk_handling.py index b7d7283..f8091ed 100644 --- a/eive_tmtc/pus_tm/hk_handling.py +++ b/eive_tmtc/pus_tm/hk_handling.py @@ -4,9 +4,9 @@ from eive_tmtc.tmtc.acs.acs_ctrl import handle_raw_mgm_data, handle_acs_ctrl_hk_ from eive_tmtc.pus_tm.devs.plpcdu import handle_plpcdu_hk from eive_tmtc.pus_tm.devs.rad_sensor import handle_rad_sensor_data from eive_tmtc.pus_tm.devs.sus import handle_sus_hk -from eive_tmtc.pus_tm.system.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.payload.ploc_supervisor import handle_supv_hk_data from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data +from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from tmtccmd.tm.pus_3_fsfw_hk import ( Service3Base, HkContentType, diff --git a/eive_tmtc/pus_tm/system/tcs.py b/eive_tmtc/tmtc/tcs.py similarity index 57% rename from eive_tmtc/pus_tm/system/tcs.py rename to eive_tmtc/tmtc/tcs.py index 0a51e8c..61cb2f1 100644 --- a/eive_tmtc/pus_tm/system/tcs.py +++ b/eive_tmtc/tmtc/tcs.py @@ -3,14 +3,103 @@ import pprint import struct from eive_tmtc.pus_tm.defs import PrintWrapper + +from eive_tmtc.config.definitions import CustomServiceList +from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config.tmtc import tmtc_definitions_provider +from tmtccmd.tc import DefaultPusQueueHelper +from tmtccmd.tc.pus_200_fsfw_modes import Mode +from tmtccmd.tc.pus_3_fsfw_hk import ( + make_sid, + generate_one_hk_command, +) + +from eive_tmtc.tmtc.common import pack_mode_cmd_with_info +from eive_tmtc.config.object_ids import TCS_BOARD_ASS_ID, TCS_CONTROLLER from tmtccmd.util import ObjectIdU32 from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter +class OpCode: + TCS_BOARD_ASS_NORMAL = ["0", "normal"] + TCS_BOARD_ASS_OFF = ["1", "off"] + REQUEST_PRIMARY_TEMP_SET = ["temp"] + REQUEST_DEVICE_TEMP_SET = ["temp_devs"] + REQUEST_DEVICE_SUS_SET = ["temp_sus"] + + +class Info: + REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures" + REQUEST_DEVICE_TEMP_SET = ( + "Request HK set of device sensor (not dedicated sensors) temperatures" + ) + REQUEST_DEVICE_SUS_SET = "Request HK set of the SUS temperatures" + TCS_BOARD_ASS_NORMAL = "Switching TCS board assembly on" + TCS_BOARD_ASS_OFF = "Switching TCS board assembly off" + + class SetId(enum.IntEnum): - SENSOR_TEMPERATURE_SET = 0 - DEVICE_TEMPERATURE_SET = 1 - SUS_TEMPERATURE_SET = 2 + PRIMARY_SENSORS = 0 + DEVICE_SENSORS = 1 + SUS_TEMP_SENSORS = 2 + + +@tmtc_definitions_provider +def add_tcs_cmds(defs: TmtcDefinitionWrapper): + oce = OpCodeEntry() + oce.add( + keys=OpCode.TCS_BOARD_ASS_NORMAL, + info=Info.TCS_BOARD_ASS_NORMAL, + ) + oce.add( + keys=OpCode.TCS_BOARD_ASS_OFF, + info=Info.TCS_BOARD_ASS_OFF, + ) + oce.add(keys=OpCode.REQUEST_PRIMARY_TEMP_SET, info=Info.REQUEST_PRIMARY_TEMP_SET) + oce.add(keys=OpCode.REQUEST_DEVICE_TEMP_SET, info=Info.REQUEST_DEVICE_TEMP_SET) + oce.add(keys=OpCode.REQUEST_DEVICE_SUS_SET, info=Info.REQUEST_DEVICE_SUS_SET) + defs.add_service( + name=CustomServiceList.TCS.value, + info="TCS Board Assembly", + op_code_entry=oce, + ) + + +def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str): + if op_code in OpCode.REQUEST_PRIMARY_TEMP_SET: + sensor_set_sid = make_sid(TCS_CONTROLLER, SetId.PRIMARY_SENSORS) + q.add_log_cmd(Info.REQUEST_PRIMARY_TEMP_SET) + q.add_pus_tc(generate_one_hk_command(sensor_set_sid)) + if op_code in OpCode.REQUEST_DEVICE_TEMP_SET: + q.add_log_cmd(Info.REQUEST_DEVICE_TEMP_SET) + q.add_pus_tc( + generate_one_hk_command(make_sid(TCS_CONTROLLER, SetId.DEVICE_SENSORS)) + ) + if op_code in OpCode.REQUEST_DEVICE_SUS_SET: + q.add_log_cmd(Info.REQUEST_DEVICE_SUS_SET) + q.add_pus_tc( + generate_one_hk_command(make_sid(TCS_CONTROLLER, SetId.SUS_TEMP_SENSORS)) + ) + pack_tcs_ass_cmds(q, op_code) + + +def pack_tcs_ass_cmds(q: DefaultPusQueueHelper, op_code: str): + if op_code in OpCode.TCS_BOARD_ASS_NORMAL: + pack_mode_cmd_with_info( + object_id=TCS_BOARD_ASS_ID, + mode=Mode.NORMAL, + submode=0, + q=q, + info=Info.TCS_BOARD_ASS_NORMAL, + ) + if op_code in OpCode.TCS_BOARD_ASS_OFF: + pack_mode_cmd_with_info( + object_id=TCS_BOARD_ASS_ID, + mode=Mode.OFF, + submode=0, + q=q, + info=Info.TCS_BOARD_ASS_OFF, + ) def handle_thermal_controller_hk_data( @@ -23,7 +112,7 @@ def handle_thermal_controller_hk_data( if TCP_TEMP_DEV_SERVER: TCP_TEMP_DEV_SERVER = TmTcpServer("localhost", 7306) """ - if set_id == SetId.SENSOR_TEMPERATURE_SET: + if set_id == SetId.PRIMARY_SENSORS: pw = PrintWrapper(printer) pw.dlog("Received sensor temperature data") @@ -58,7 +147,7 @@ def handle_thermal_controller_hk_data( # tcp_server_sensor_temperatures.report_parsed_hk_data( # object_id, set_id, parsed_data # ) - elif set_id == SetId.DEVICE_TEMPERATURE_SET: + elif set_id == SetId.DEVICE_SENSORS: pw = PrintWrapper(printer) pw.dlog("Received device temperature data") fmt_str = "!fhhhhiiiifffhffffffffffffff" @@ -99,7 +188,7 @@ def handle_thermal_controller_hk_data( # tcp_server_device_temperatures.report_parsed_hk_data( # object_id, set_id, parsed_data # ) - elif set_id == SetId.SUS_TEMPERATURE_SET: + elif set_id == SetId.SUS_TEMP_SENSORS: pass # pw = PrintWrapper(printer) # pw.dlog("Received SUS temperature data")