Feature: MGM base cmds #143

Merged
mkranz merged 2 commits from feature_mgm_base_cmds into main 2023-02-28 10:11:01 +01:00
3 changed files with 54 additions and 0 deletions
Showing only changes of commit 0ce32521f4 - Show all commits

View File

@ -37,6 +37,7 @@ class CustomServiceList(str, enum.Enum):
ACU = "acu"
ACS = "acs"
GYRO = "gyro"
MGMS = "mgms"
COM_SS = "com"
BPX_BATTERY = "bpx"
HEATER = "heater"

View File

@ -4,6 +4,7 @@ import logging
from typing import cast
from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd
from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd
from eive_tmtc.tmtc.power.power import pack_power_commands
from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands
from eive_tmtc.tmtc.payload.scex import pack_scex_cmds
@ -135,6 +136,8 @@ def handle_default_procedure(
return pack_single_rw_test_into(
object_id=RW4_ID, rw_idx=4, q=queue_helper, op_code=op_code
)
if service == CustomServiceList.MGMS.value:
return handle_mgm_cmd(q=queue_helper, op_code=op_code)
if service == CustomServiceList.RAD_SENSOR.value:
object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID))
return pack_rad_sensor_test_into(

View File

@ -1,13 +1,25 @@
import enum
import struct
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config import OpCodeEntry
import eive_tmtc.config.object_ids as obj_ids
from eive_tmtc.config.object_ids import MGM_0_LIS3_HANDLER_ID, MGM_1_RM3100_HANDLER_ID, MGM_2_LIS3_HANDLER_ID, MGM_3_RM3100_HANDLER_ID
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider, TmtcDefinitionWrapper
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class OpCode:
NORMAL = "normal"
OFF = "off"
class MgmLis3SetId(enum.IntEnum):
CORE_HK = 0
@ -16,6 +28,36 @@ class MgmRm3100SetId(enum.IntEnum):
CORE_HK = 0
class MgmSel(enum.IntEnum):
MGM_0_LIS3 = 0
MGM_1_RM3100 = 1
MGM_2_LIS3 = 2
MGM_3_RM3100 = 3
MGM_SEL_DICT = {
MgmSel.MGM_0_LIS3: ("MGM_0_LIS3", MGM_0_LIS3_HANDLER_ID),
MgmSel.MGM_1_RM3100: ("MGM_1_RM3100", MGM_1_RM3100_HANDLER_ID),
MgmSel.MGM_2_LIS3: ("MGM_2_LIS3", MGM_2_LIS3_HANDLER_ID),
MgmSel.MGM_3_RM3100: ("MGM_3_RM3100", MGM_3_RM3100_HANDLER_ID),
}
def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str):
print("Please select the MGM Device")
for (k, v) in MGM_SEL_DICT.items():
print(f"{k}: {v[0]}")
sel_idx = int(input("Select MGM device by index: "))
mgm_info = MGM_SEL_DICT[MgmSel(sel_idx)]
mgm_obj_id = mgm_info[1]
if op_code == OpCode.NORMAL:
q.add_log_cmd(f"Gyro {mgm_info[0]} NORMAL mode")
q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.NORMAL, 0))
if op_code == OpCode.OFF:
q.add_log_cmd(f"Gyro {mgm_info[0]} OFF mode")
q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.OFF, 0))
def handle_mgm_hk_data(
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
@ -61,3 +103,11 @@ def handle_mgm_rm3100_hk_data(
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)
@tmtc_definitions_provider
def add_mgm_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(keys=OpCode.NORMAL, info="Normal Mode")
oce.add(keys=OpCode.OFF, info="Off Mode")
defs.add_service(CustomServiceList.MGMS, info="MGMs", op_code_entry=oce)