IMTQ updates

This commit is contained in:
Robin Müller 2023-03-04 17:05:11 +01:00
parent 94ae2d16e2
commit 09c694cf9c
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -41,7 +41,8 @@ class OpCode:
NORMAL = "normal"
OFF = "off"
SET_DIPOLE = "set_dipole"
REQUEST_ENG_HK_NO_TORQUE = "hk_os_eng_hk"
REQUEST_ENG_HK_NO_TORQUE = "hk_os_eng_hk_no_torque"
REQUEST_ENG_HK_WITH_TORQUE = "hk_os_eng_hk_with_torque"
REQUEST_MGM_RAW_NO_TORQUE = "hk_os_mgm_raw_no_torque"
ENABLE_MGM_RAW_NO_TORQUE = "enb_mgm_raw_no_torque"
DISABLE_MGM_RAW_NO_TORQUE = "dis_mgm_raw_no_torque"
@ -50,6 +51,8 @@ class OpCode:
DISABLE_MGM_RAW_WITH_TORQUE = "dis_mgm_raw_with_torque"
ENABLE_ENG_HK_NO_TORQUE = "enb_eng_hk_no_torque"
DISABLE_ENG_HK_NO_TORQUE = "dis_eng_hk_no_torque"
ENABLE_ENG_HK_WITH_TORQUE = "enb_eng_hk_with_torque"
DISABLE_ENG_HK_WITH_TORQUE = "dis_eng_hk_with_torque"
POS_X_SELF_TEST = "self_test_pos_x"
NEG_X_SELF_TEST = "self_test_neg_x"
POS_Y_SELF_TEST = "self_test_pos_y"
@ -96,6 +99,14 @@ def add_imtq_cmds(defs: TmtcDefinitionWrapper):
oce.add(OpCode.ON, "Mode On")
oce.add(OpCode.NORMAL, "Mode Normal")
oce.add(OpCode.REQUEST_ENG_HK_NO_TORQUE, "Request Engineering HK One Shot")
oce.add(
OpCode.REQUEST_ENG_HK_WITH_TORQUE,
"Request Engineering HK One Shot during Torque",
)
oce.add(OpCode.ENABLE_ENG_HK_NO_TORQUE, "Enable ENG HK not torque")
oce.add(OpCode.ENABLE_ENG_HK_WITH_TORQUE, "Enable ENG HK with torque")
oce.add(OpCode.DISABLE_ENG_HK_NO_TORQUE, "Disable ENG HK not torque")
oce.add(OpCode.DISABLE_ENG_HK_WITH_TORQUE, "Disable ENG HK with torque")
oce.add(
OpCode.REQUEST_MGM_RAW_NO_TORQUE, "Request MGM Raw Without Torque HK One Shot"
)
@ -250,8 +261,35 @@ def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_cod
True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE)
)
)
if op_code == OpCode.REQUEST_ENG_HK_WITH_TORQUE:
q.add_log_cmd("IMTQ: Get engineering hk set with torque")
q.add_pus_tc(
create_request_one_diag_command(
sid=make_sid(
object_id=object_id.as_bytes,
set_id=ImtqSetId.ENG_HK_SET_WITH_TORQUE,
)
)
)
if op_code == OpCode.ENABLE_ENG_HK_WITH_TORQUE:
q.add_log_cmd("IMTQ: Enable ENG HK with torque")
interval = float(input("Please enter collection interval in seconds: "))
cmds = create_enable_periodic_hk_command_with_interval(
diag=True,
sid=make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE),
interval_seconds=interval,
)
for cmd in cmds:
q.add_pus_tc(cmd)
if op_code == OpCode.DISABLE_ENG_HK_WITH_TORQUE:
q.add_log_cmd("IMTQ: Disable ENG HK with Torque")
q.add_pus_tc(
create_disable_periodic_hk_command(
True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE)
)
)
if op_code == OpCode.REQUEST_ENG_HK_NO_TORQUE:
q.add_log_cmd("IMTQ: Get engineering hk set")
q.add_log_cmd("IMTQ: Get engineering hk set (no torque)")
q.add_pus_tc(
generate_one_diag_command(
sid=make_sid(
@ -392,19 +430,15 @@ def handle_imtq_hk(printer: FsfwTmTcPrinter, hk_data: bytes, set_id: int):
if (set_id >= ImtqSetId.POSITIVE_X_TEST) and (set_id <= ImtqSetId.NEGATIVE_Z_TEST):
return handle_self_test_data(printer, hk_data)
elif set_id == ImtqSetId.ENG_HK_NO_TORQUE:
_LOGGER.info("Found engineering HK without torque")
return handle_eng_set(printer, hk_data)
return handle_eng_set(printer, hk_data, False)
elif set_id == ImtqSetId.ENG_HK_SET_WITH_TORQUE:
_LOGGER.info("Found engineering HK during torque")
return handle_eng_set(printer, hk_data)
return handle_eng_set(printer, hk_data, True)
elif set_id == ImtqSetId.CAL_MTM_SET:
return handle_calibrated_mtm_measurement(printer, hk_data)
elif set_id == ImtqSetId.RAW_MTM_NO_TORQUE:
_LOGGER.info("Found raw MTM measurement without torque")
return handle_raw_mtm_measurement(printer, hk_data)
return handle_raw_mtm_measurement(printer, hk_data, False)
elif set_id == ImtqSetId.RAW_MTM_WITH_TORQUE:
_LOGGER.info("Found raw MTM measurement during torque")
return handle_raw_mtm_measurement(printer, hk_data)
return handle_raw_mtm_measurement(printer, hk_data, True)
elif set_id == ImtqSetId.STATUS_SET:
return handle_status_set(printer, hk_data)
else:
@ -449,8 +483,9 @@ def unpack_eng_hk(hk_data: bytes) -> List:
return content_list
def handle_eng_set(printer: FsfwTmTcPrinter, hk_data: bytes):
def handle_eng_set(printer: FsfwTmTcPrinter, hk_data: bytes, torque_on: bool):
pw = PrintWrapper(printer)
pw.dlog(f"Found engineering HK. Torque Status: {torque_on}")
content_list = unpack_eng_hk(hk_data)
validity_buffer = hk_data[32:]
@ -491,8 +526,11 @@ def handle_calibrated_mtm_measurement(printer: FsfwTmTcPrinter, hk_data: bytes):
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
def handle_raw_mtm_measurement(printer: FsfwTmTcPrinter, hk_data: bytes):
def handle_raw_mtm_measurement(
printer: FsfwTmTcPrinter, hk_data: bytes, torque_status: bool
):
pw = PrintWrapper(printer)
pw.dlog(f"Found raw MTM measurement. Torque Status: {torque_status}")
header_list = [
"Raw MTM X [nT]",
"Raw MTM Y [nT]",