TCS CTRL Info Set #215

Merged
meggert merged 6 commits from tcs-ctrl-info-set into main 2023-07-11 09:31:50 +02:00
3 changed files with 72 additions and 14 deletions
Showing only changes of commit e27ad147d4 - Show all commits

View File

@ -12,3 +12,16 @@ class CtrlSetId(enum.IntEnum):
class TcsSubmode(enum.IntEnum):
DEFAULT = 0
NO_HEATER_CTRL = 1
class Heater(enum.IntEnum):
HEATER_0_PLOC_PROC_BRD = 0
HEATER_1_PCDU_BRD = 1
HEATER_2_ACS_BRD = 2
HEATER_3_OBC_BRD = 3
HEATER_4_CAMERA = 4
HEATER_5_STR = 5
HEATER_6_DRO = 6
HEATER_7_SYRLINKS = 7
NUMBER_OF_SWITCHES = 8
NONE = 0xFF

View File

@ -7,6 +7,7 @@ import enum
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import get_object_ids
from eive_tmtc.tmtc.tcs.defs import Heater
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
@ -20,18 +21,6 @@ from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
from spacepackets.ecss.tc import PusTelecommand
class Heater(enum.IntEnum):
HEATER_0_PLOC_PROC_BRD = 0
HEATER_1_PCDU_BRD = 1
HEATER_2_ACS_BRD = 2
HEATER_3_OBC_BRD = 3
HEATER_4_CAMERA = 4
HEATER_5_STR = 5
HEATER_6_DRO = 6
HEATER_7_SYRLINKS = 7
NUMBER_OF_SWITCHES = 8
HEATER_LOCATION = [
"PLOC Processing Board",
"PCDU PDU",

View File

@ -1,8 +1,11 @@
import dataclasses
import datetime
import enum
import logging
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.tmtc.tcs.defs import Heater
from tmtccmd.fsfw import validity_buffer_list
from tmtccmd.util import ObjectIdU32
from .defs import CtrlSetId
@ -40,6 +43,17 @@ class ThermalComponent(enum.IntEnum):
NUM_ENTRIES = 24
@dataclasses.dataclass
class TcsCtrlComponentInfo:
component: ThermalComponent
# Heater on or off?
state: bool
used_sensor_idx: int
used_heater: Heater
start_time: datetime.datetime
end_time: datetime.datetime
def handle_thermal_controller_hk_data(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes
):
@ -149,7 +163,49 @@ def handle_thermal_controller_hk_data(
current_draw = struct.unpack("!H", hk_data[8:10])[0]
print(f"Heater Power Channel Current Draw: {current_draw} mA")
elif set_id == CtrlSetId.TCS_CTRL_INFO:
pw.dlog("Received TCS CTRL set")
pass
pw.dlog("Received TCS CTRL information set")
current_idx = 0
heater_states = hk_data[0 : ThermalComponent.NUM_ENTRIES]
current_idx += ThermalComponent.NUM_ENTRIES
used_sensor_idx = hk_data[
current_idx : current_idx + ThermalComponent.NUM_ENTRIES
]
current_idx += ThermalComponent.NUM_ENTRIES
used_heater_idx = hk_data[
current_idx : current_idx + ThermalComponent.NUM_ENTRIES
]
current_idx += ThermalComponent.NUM_ENTRIES
start_and_end_time_fmt_str = "!IIIIIIIIIIIIIIIIIIIIIIII"
data_len = struct.calcsize(start_and_end_time_fmt_str)
start_times = struct.unpack(
start_and_end_time_fmt_str, hk_data[current_idx : current_idx + data_len]
)
current_idx += data_len
end_times = struct.unpack(
start_and_end_time_fmt_str, hk_data[current_idx : current_idx + data_len]
)
current_idx += data_len
component_list = []
for i in range(ThermalComponent.NUM_ENTRIES):
info = TcsCtrlComponentInfo(
component=ThermalComponent(i),
state=bool(heater_states[i]),
used_sensor_idx=used_sensor_idx[i],
used_heater=Heater(used_heater_idx[i]),
start_time=datetime.datetime.fromtimestamp(
start_times[i], datetime.timezone.utc
),
end_time=datetime.datetime.fromtimestamp(
end_times[i], datetime.timezone.utc
),
)
component_str = f"{info.component!r}".ljust(46)
state_str = "ON" if info.state else "OFF"
pw.dlog(
f"{component_str}: {state_str.ljust(4)} | Sensor Index "
f"{info.used_sensor_idx} | {info.used_heater!r} | Start "
f"{info.start_time} | End {info.end_time}"
)
component_list.append(info)
else:
_LOGGER.warning(f"Unimplemented set ID {set_id}")