all import changes

This commit is contained in:
Robin Müller 2023-02-01 16:25:17 +01:00
parent 6b657b5623
commit c8ea75b2ad
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
22 changed files with 203 additions and 212 deletions

View File

@ -1 +0,0 @@

View File

@ -1,2 +0,0 @@
class SetId:
HK = 3

View File

@ -4,8 +4,8 @@ import logging
from typing import cast
from eive_tmtc.tmtc.power.power import pack_power_commands
from eive_tmtc.pus_tc.devs.rtd import pack_rtd_commands
from eive_tmtc.pus_tc.devs.scex import pack_scex_cmds
from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands
from eive_tmtc.tmtc.payload.scex import pack_scex_cmds
from eive_tmtc.pus_tc.system.controllers import (
pack_cmd_ctrl_to_prompted_mode,
get_object_from_op_code,
@ -13,7 +13,6 @@ from eive_tmtc.pus_tc.system.controllers import (
from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands
from tmtccmd import DefaultProcedureInfo, TcHandlerBase
from tmtccmd.config import CoreServiceList
from tmtccmd.logging import get_console_logger
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.decorator import (
route_to_registered_service_handlers,
@ -65,11 +64,11 @@ from eive_tmtc.config.object_ids import (
get_object_ids,
)
from eive_tmtc.pus_tc.devs.tmp1075 import pack_tmp1075_test_into
from eive_tmtc.pus_tc.devs.gps import pack_gps_command
from eive_tmtc.pus_tc.devs.rad_sensor import pack_rad_sensor_test_into
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.tmtc.tcs.tmp1075 import pack_tmp1075_test_into
from eive_tmtc.tmtc.acs.gps import pack_gps_command
from eive_tmtc.tmtc.payload.rad_sensor import pack_rad_sensor_test_into
from eive_tmtc.tmtc.power.plpcdu import pack_pl_pcdu_commands
from eive_tmtc.tmtc.acs.str_img_helper import pack_str_img_helper_command
from eive_tmtc.pus_tc.system.proc import pack_proc_commands
import eive_tmtc.config.object_ids as oids

View File

@ -39,14 +39,16 @@ from eive_tmtc.tmtc.acs.imtq import pack_imtq_test_into, pack_dipole_command
from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands
from eive_tmtc.tmtc.acs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command
from eive_tmtc.pus_tc.devs.sus import SetId
from eive_tmtc.pus_tc.devs.bpx_batt import BpxSetId
from eive_tmtc.pus_tc.devs.rad_sensor import SetId as RadSetIds
from eive_tmtc.pus_tc.devs.mgms import MgmLis3SetId as MgmLis3SetIds_0_2
from eive_tmtc.pus_tc.devs.mgms import MgmRm3100SetId as MgmRm3100SetIds_1_3
from eive_tmtc.pus_tc.devs.gyros import AdisGyroSetId as AdisGyroSetIds_0_2
from eive_tmtc.pus_tc.devs.gyros import L3gGyroSetId as L3gGyroSetIds_1_3
from eive_tmtc.pus_tc.devs.gps import SetId as GpsSetIds
from eive_tmtc.tmtc.acs.sus import SetId
from eive_tmtc.tmtc.power.bpx_batt import BpxSetId
from eive_tmtc.tmtc.payload.rad_sensor import SetId as RadSetIds
from eive_tmtc.tmtc.acs.mgms import MgmLis3SetId as MgmLis3SetIds_0_2
from eive_tmtc.tmtc.acs.mgms import MgmRm3100SetId as MgmRm3100SetIds_1_3
from eive_tmtc.tmtc.acs.gyros import (
AdisGyroSetId as AdisGyroSetIds_0_2,
L3gGyroSetId as L3gGyroSetIds_1_3,
)
from eive_tmtc.tmtc.acs.gps import SetId as GpsSetIds
class OpCode:

View File

@ -1,68 +0,0 @@
import struct
from eive_tmtc.pus_tc.devs.bpx_batt import BpxSetId
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
HEADER_LIST = [
"Charge Current",
"Discharge Current",
"Heater Current",
"Battery Voltage",
"Batt Temp 1",
"Batt Temp 2",
"Batt Temp 3",
"Batt Temp 4",
"Reboot Counter",
"Boot Cause",
]
def handle_bpx_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer)
if set_id == BpxSetId.GET_HK_SET:
fmt_str = "!HHHHhhhhIB"
inc_len = struct.calcsize(fmt_str)
(
charge_current,
discharge_current,
heater_current,
batt_voltage,
batt_temp_1,
batt_temp_2,
batt_temp_3,
batt_temp_4,
reboot_cntr,
boot_cause,
) = struct.unpack(fmt_str, hk_data[0:inc_len])
content_list = [
charge_current,
discharge_current,
heater_current,
batt_voltage,
batt_temp_1,
batt_temp_2,
batt_temp_3,
batt_temp_4,
reboot_cntr,
boot_cause,
]
validity_buffer = hk_data[inc_len:]
pw.dlog(str(HEADER_LIST))
pw.dlog(str(content_list))
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
elif set_id == BpxSetId.GET_CFG_SET:
battheat_mode = hk_data[0]
battheat_low = struct.unpack("!b", hk_data[1:2])[0]
battheat_high = struct.unpack("!b", hk_data[2:3])[0]
header_list = [
"Battery Heater Mode",
"Battery Heater Low Limit",
"Battery Heater High Limit",
]
content_list = [battheat_mode, battheat_low, battheat_high]
validity_buffer = hk_data[3:]
pw.dlog(str(header_list))
pw.dlog(str(content_list))
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)

View File

@ -1,39 +0,0 @@
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
def handle_gps_data(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
pw.dlog(f"Received GPS data, HK data length {len(hk_data)}")
current_idx = 0
fmt_str = "!ddddBBBHBBBBBI"
inc_len = struct.calcsize(fmt_str)
(
lat,
long,
alt,
speed,
fix,
sats_in_use,
sats_in_view,
year,
month,
day,
hours,
minutes,
seconds,
unix_seconds,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
date_string = f"{day}.{month}.{year} {hours}:{minutes}:{seconds}"
pw.dlog(f"Lat: {lat} deg")
pw.dlog(f"Long: {long} deg")
pw.dlog(f"Altitude: {alt} m | Speed: {speed} m/s")
pw.dlog(
f"Fix Type: {fix} | Sats in View {sats_in_view} | Sats in Use {sats_in_use}"
)
pw.dlog(f"GNSS Date: {date_string}")
pw.dlog(f"Unix seconds {unix_seconds}")
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=14)

View File

@ -1,52 +0,0 @@
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from eive_tmtc.pus_tc.devs.plpcdu import SetId
ADC_CHANNELS_NAMED = [
"U BAT DIV 6",
"U NEG V FB",
"I HPA",
"U HPA DIV 6",
"I MPA",
"U MPA DIV 6",
"I TX",
"U TX DIV 6",
"I X8",
"U X8 DIV 6",
"I DRO",
"U DRO DIV 6",
]
def handle_plpcdu_hk(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.ADC:
pw = PrintWrapper(printer)
current_idx = 0
pw.dlog("Received PL PCDU ADC HK data")
channels = []
ch_print = "Channels Raw (hex): ["
for i in range(12):
channels.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
if i < 11:
ch_print += f"{channels[i]:06x},"
else:
ch_print += f"{channels[i]:06x}]"
current_idx += 2
processed_vals = []
for i in range(12):
processed_vals.append(
struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
temp = struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
current_idx += 4
pw.dlog(f"Temperature: {temp} C")
pw.dlog(ch_print)
for i in range(12):
pw.dlog(f"{ADC_CHANNELS_NAMED[i].ljust(24)} | {processed_vals[i]}")
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=3)

View File

@ -1,24 +0,0 @@
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from eive_tmtc.pus_tc.devs.rad_sensor import SetId
def handle_rad_sensor_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.HK:
pw = PrintWrapper(printer)
current_idx = 0
pw.dlog("Received Radiation Sensor HK data")
fmt_str = "!fHHHHHH"
inc_len = struct.calcsize(fmt_str)
(temp, ain0, ain1, ain4, ain5, ain6, ain7) = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
ain_dict = {0: ain0, 1: ain1, 4: ain4, 5: ain5, 6: ain6, 7: ain7}
pw.dlog(f"Temperature: {temp} C")
pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)")
for idx, val in ain_dict.items():
pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}")
current_idx += inc_len
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)

View File

@ -3,9 +3,9 @@ import logging
# from pus_tm.tcp_server_objects import TCP_SEVER_SENSOR_TEMPERATURES
from eive_tmtc.tmtc.acs.acs_ctrl import handle_raw_mgm_data, handle_acs_ctrl_hk_data
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.tmtc.power.plpcdu import handle_plpcdu_hk
from eive_tmtc.tmtc.payload.rad_sensor import handle_rad_sensor_data
from eive_tmtc.tmtc.acs.sus import handle_sus_hk
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.com.syrlinks_handler import handle_syrlinks_hk_data
@ -17,8 +17,8 @@ from tmtccmd.tm.pus_3_fsfw_hk import (
)
from tmtccmd.util.obj_id import ObjectIdU32, ObjectIdDictT
from eive_tmtc.pus_tm.devs.bpx_bat import handle_bpx_hk_data
from eive_tmtc.pus_tm.devs.gps import handle_gps_data
from eive_tmtc.tmtc.power.bpx_batt import handle_bpx_hk_data
from eive_tmtc.tmtc.acs.gps import handle_gps_data
from eive_tmtc.tmtc.acs.gyros import handle_gyros_hk_data
from eive_tmtc.tmtc.power.tm import (
handle_pdu_data,

View File

@ -1,11 +1,13 @@
import logging
import struct
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__)
@ -45,3 +47,38 @@ def pack_gps_command(object_id: bytes, q: DefaultPusQueueHelper, op_code: str):
q.add_pus_tc(
generate_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetId.HK))
)
def handle_gps_data(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
pw.dlog(f"Received GPS data, HK data length {len(hk_data)}")
current_idx = 0
fmt_str = "!ddddBBBHBBBBBI"
inc_len = struct.calcsize(fmt_str)
(
lat,
long,
alt,
speed,
fix,
sats_in_use,
sats_in_view,
year,
month,
day,
hours,
minutes,
seconds,
unix_seconds,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
date_string = f"{day}.{month}.{year} {hours}:{minutes}:{seconds}"
pw.dlog(f"Lat: {lat} deg")
pw.dlog(f"Long: {long} deg")
pw.dlog(f"Altitude: {alt} m | Speed: {speed} m/s")
pw.dlog(
f"Fix Type: {fix} | Sats in View {sats_in_view} | Sats in Use {sats_in_use}"
)
pw.dlog(f"GNSS Date: {date_string}")
pw.dlog(f"Unix seconds {unix_seconds}")
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=14)

View File

@ -1,7 +1,7 @@
import enum
import struct
import config.objects as obj_ids
import eive_tmtc.config.object_ids as obj_ids
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32

View File

@ -1,7 +1,7 @@
import enum
import struct
import config.object_id as obj_ids
import eive_tmtc.config.object_ids as obj_ids
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32

View File

@ -1,11 +1,14 @@
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.pus_tc.devs.sus import SetId
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId:
HK = 3
def handle_sus_hk(
object_id: ObjectIdU32, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int
):

View File

@ -8,6 +8,7 @@
import struct
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper
from spacepackets.ecss.tc import PusTelecommand
from eive_tmtc.pus_tc.service_200_mode import pack_mode_data, Mode
@ -16,6 +17,7 @@ from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId:
@ -95,3 +97,22 @@ def rad_sensor_mode_cmd(
q.add_log_cmd(f"Rad sensor: {info}")
mode_data = pack_mode_data(object_id.as_bytes, mode, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
def handle_rad_sensor_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.HK:
pw = PrintWrapper(printer)
current_idx = 0
pw.dlog("Received Radiation Sensor HK data")
fmt_str = "!fHHHHHH"
inc_len = struct.calcsize(fmt_str)
(temp, ain0, ain1, ain4, ain5, ain6, ain7) = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
ain_dict = {0: ain0, 1: ain1, 4: ain4, 5: ain5, 6: ain6, 7: ain7}
pw.dlog(f"Temperature: {temp} C")
pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)")
for idx, val in ain_dict.items():
pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}")
current_idx += inc_len
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)

View File

@ -1,3 +1,6 @@
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from spacepackets.ecss import PusTelecommand
from eive_tmtc.config.definitions import CustomServiceList
@ -13,6 +16,7 @@ from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservices
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class BpxSetId:
@ -105,3 +109,66 @@ def pack_bpx_commands(p: ServiceProviderParams):
q.add_pus_tc(
create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.REBOOT)
)
HEADER_LIST = [
"Charge Current",
"Discharge Current",
"Heater Current",
"Battery Voltage",
"Batt Temp 1",
"Batt Temp 2",
"Batt Temp 3",
"Batt Temp 4",
"Reboot Counter",
"Boot Cause",
]
def handle_bpx_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer)
if set_id == BpxSetId.GET_HK_SET:
fmt_str = "!HHHHhhhhIB"
inc_len = struct.calcsize(fmt_str)
(
charge_current,
discharge_current,
heater_current,
batt_voltage,
batt_temp_1,
batt_temp_2,
batt_temp_3,
batt_temp_4,
reboot_cntr,
boot_cause,
) = struct.unpack(fmt_str, hk_data[0:inc_len])
content_list = [
charge_current,
discharge_current,
heater_current,
batt_voltage,
batt_temp_1,
batt_temp_2,
batt_temp_3,
batt_temp_4,
reboot_cntr,
boot_cause,
]
validity_buffer = hk_data[inc_len:]
pw.dlog(str(HEADER_LIST))
pw.dlog(str(content_list))
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
elif set_id == BpxSetId.GET_CFG_SET:
battheat_mode = hk_data[0]
battheat_low = struct.unpack("!b", hk_data[1:2])[0]
battheat_high = struct.unpack("!b", hk_data[2:3])[0]
header_list = [
"Battery Heater Mode",
"Battery Heater Low Limit",
"Battery Heater High Limit",
]
content_list = [battheat_mode, battheat_low, battheat_high]
validity_buffer = hk_data[3:]
pw.dlog(str(header_list))
pw.dlog(str(content_list))
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)

View File

@ -5,6 +5,7 @@ import time
from typing import Optional
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.config import TmtcDefinitionWrapper
from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider
@ -27,6 +28,7 @@ from tmtccmd.tc.pus_20_fsfw_param import (
)
from spacepackets.ecss.tc import PusTelecommand
from eive_tmtc.config.object_ids import PL_PCDU_ID
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__)
@ -448,3 +450,50 @@ def pack_pl_pcdu_mode_cmd(
service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=mode_data
)
)
ADC_CHANNELS_NAMED = [
"U BAT DIV 6",
"U NEG V FB",
"I HPA",
"U HPA DIV 6",
"I MPA",
"U MPA DIV 6",
"I TX",
"U TX DIV 6",
"I X8",
"U X8 DIV 6",
"I DRO",
"U DRO DIV 6",
]
def handle_plpcdu_hk(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.ADC:
pw = PrintWrapper(printer)
current_idx = 0
pw.dlog("Received PL PCDU ADC HK data")
channels = []
ch_print = "Channels Raw (hex): ["
for i in range(12):
channels.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
if i < 11:
ch_print += f"{channels[i]:06x},"
else:
ch_print += f"{channels[i]:06x}]"
current_idx += 2
processed_vals = []
for i in range(12):
processed_vals.append(
struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
temp = struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
current_idx += 4
pw.dlog(f"Temperature: {temp} C")
pw.dlog(ch_print)
for i in range(12):
pw.dlog(f"{ADC_CHANNELS_NAMED[i].ljust(24)} | {processed_vals[i]}")
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=3)

View File

@ -2,7 +2,6 @@ from typing import Optional
import struct
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tc.devs.pdec_handler import CommandId
from spacepackets.ecss import PusTelecommand
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider