eive-tmtc/pus_tc/system/proc.py

858 lines
26 KiB
Python
Raw Normal View History

2022-05-27 10:50:44 +02:00
from __future__ import annotations
2022-05-27 11:53:57 +02:00
import time
2022-07-04 17:59:09 +02:00
from datetime import timedelta
2022-05-25 15:21:50 +02:00
from typing import List
2022-05-25 13:32:18 +02:00
from config.definitions import CustomServiceList
2022-05-27 11:53:57 +02:00
from config.object_ids import get_object_ids
from pus_tc.system.tcs import pack_tcs_sys_commands
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
2022-07-04 17:59:09 +02:00
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2022-05-27 11:53:57 +02:00
from tmtccmd.tc.pus_11_tc_sched import (
generate_time_tagged_cmd,
generate_enable_tc_sched_cmd,
generate_reset_tc_sched_cmd,
)
2022-05-18 20:00:59 +02:00
from tmtccmd.tc.pus_3_fsfw_hk import *
2022-05-23 18:33:35 +02:00
2022-05-19 18:47:23 +02:00
import config.object_ids as oids
2022-05-27 11:53:57 +02:00
from pus_tc.system.tcs import OpCodes as TcsOpCodes
2022-05-18 20:00:59 +02:00
from pus_tc.devs.bpx_batt import BpxSetIds
2022-05-19 18:47:23 +02:00
from pus_tc.system.core import SetIds as CoreSetIds
2022-05-19 18:14:38 +02:00
from gomspace.gomspace_common import SetIds as GsSetIds
2022-05-23 15:28:41 +02:00
from pus_tc.devs.rad_sensor import SetIds as RadSetIds
2022-05-27 11:53:57 +02:00
from pus_tc.devs.mgms import MgmLis3SetIds as MgmLis3SetIds_0_2
from pus_tc.devs.mgms import MgmRm3100SetIds as MgmRm3100SetIds_1_3
from pus_tc.devs.gyros import AdisGyroSetIds as AdisGyroSetIds_0_2
from pus_tc.devs.gyros import L3gGyroSetIds as L3gGyroSetIds_1_3
2022-05-25 13:49:51 +02:00
from pus_tc.devs.gps import SetIds as GpsSetIds
2022-05-23 15:28:41 +02:00
from pus_tc.devs.imtq import ImtqSetIds
2022-05-25 11:10:57 +02:00
from pus_tc.devs.sus import SetIds
from pus_tc.devs.star_tracker import SetIds as StrSetIds
2022-05-25 10:03:47 +02:00
from pus_tc.devs.reaction_wheels import RwSetIds
2022-05-27 11:53:57 +02:00
from pus_tc.system.controllers import pack_cmd_ctrl_to_off, pack_cmd_ctrl_to_nml
2022-05-24 18:13:17 +02:00
from pus_tc.system.acs import pack_acs_command, pack_sus_cmds
2022-05-24 18:34:25 +02:00
from pus_tc.devs.imtq import pack_imtq_test_into, pack_dipole_command
from pus_tc.devs.star_tracker import pack_star_tracker_commands
2022-05-25 10:03:47 +02:00
from pus_tc.devs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command
2022-05-24 18:34:25 +02:00
2022-05-18 18:39:18 +02:00
class OpCodes:
"""FT: Functional Test"""
2022-08-12 22:33:16 +02:00
2022-05-27 15:29:39 +02:00
TV_SETUP_TCS_FT_ON = ["s", "tcs-ft-on"]
2022-05-27 11:53:57 +02:00
RESET_SCHED = ["reset-sched", "rs"]
HEATER = ["heater"]
2022-05-18 20:00:59 +02:00
BAT_FT = ["bat-ft"]
2022-05-19 18:47:23 +02:00
CORE_FT = ["core-ft"]
2022-05-19 18:14:38 +02:00
PCDU_FT = ["pcdu-ft"]
2022-05-20 16:40:58 +02:00
RAD_SEN_FT = ["rad-sen-ft"]
2022-05-23 11:53:31 +02:00
ACS_FT = ["acs-ft"]
2022-05-23 15:28:41 +02:00
MGT_FT = ["mgt-ft"]
MGT_FT_DP = ["mgt-ft-dp"]
2022-05-24 18:13:17 +02:00
SUS_FT = ["sus-ft"]
STR_FT = ["str-ft"]
2022-05-25 10:03:47 +02:00
RW_FT_ONE_RW = ["rw-ft-one-rw"]
RW_FT_TWO_RWS = ["rw-ft-two-rws"]
2022-05-27 15:29:39 +02:00
TV_TEARDOWN_TCS_FT_OFF = ["t", "tcs-ft-off"]
2022-05-18 18:39:18 +02:00
2022-05-19 18:47:23 +02:00
class KeyAndInfo:
2022-05-27 11:53:57 +02:00
TV_SETUP_TCS_FT_ON = ["TCS Act.", "TCS functional test activation"]
RESET_SCHED = ["Reset Sched", "Reset/Clear TC schedule"]
2022-05-19 18:47:23 +02:00
HEATER = ["Heater", "heater procedure"]
BAT_FT = ["BPX Battery", "battery functional test"]
CORE_FT = ["OBC", "OBC functional test"]
2022-05-20 16:40:58 +02:00
PCDU_FT = ["PCDU", "PCDU functional test"]
RAD_SEN_FT = ["Radiation Sensor", "Radiation Sensor functional test"]
2022-05-23 11:53:31 +02:00
ACS_FT = ["ACS", "ACS functional test"]
2022-05-23 15:28:41 +02:00
MGT_FT = ["MGT", "MGT functional test"]
MGT_FT_DP = ["MGT dipole", "MGT functional test with dipole"]
2022-05-24 18:13:17 +02:00
SUS_FT = ["SUS", "SUS functional test"]
STR_FT = ["STR", "STR functional test"]
2022-05-25 10:03:47 +02:00
RW_FT_ONE_RW = ["RW ONE RW", "RW functional test with one RW"]
RW_FT_TWO_RWS = ["RW TWO RWS", "RW functional test with two RWs"]
2022-05-27 11:53:57 +02:00
TV_TEARDOWN_TCS_FT_OFF = ["TCS Deact.", "TCS functional test deactivation"]
2022-05-19 18:47:23 +02:00
KAI = KeyAndInfo
PROC_INFO_DICT = {
2022-07-04 15:22:53 +02:00
KAI.TV_SETUP_TCS_FT_ON[0]: [
OpCodes.TV_SETUP_TCS_FT_ON,
KAI.TV_SETUP_TCS_FT_ON[1],
120.0,
10.0,
],
2022-05-27 11:53:57 +02:00
KAI.TV_TEARDOWN_TCS_FT_OFF[0]: [
OpCodes.TV_TEARDOWN_TCS_FT_OFF,
KAI.TV_TEARDOWN_TCS_FT_OFF[1],
120.0,
10.0,
],
2022-05-27 15:29:39 +02:00
KAI.BAT_FT[0]: [OpCodes.BAT_FT, KAI.BAT_FT[1], 120.0, 10.0],
KAI.CORE_FT[0]: [OpCodes.CORE_FT, KAI.CORE_FT[1], 120.0, 10.0],
KAI.PCDU_FT[0]: [OpCodes.PCDU_FT, KAI.PCDU_FT[1], 120.0, 10.0],
KAI.RAD_SEN_FT[0]: [OpCodes.RAD_SEN_FT, KAI.RAD_SEN_FT[1], 120.0, 10.0],
2022-05-23 15:28:41 +02:00
KAI.ACS_FT[0]: [OpCodes.ACS_FT, KAI.ACS_FT[1], 120.0, 10.0],
KAI.MGT_FT[0]: [OpCodes.MGT_FT, KAI.MGT_FT[1], 120.0, 10.0],
2022-05-27 10:50:44 +02:00
# collection_time for KAI.MGT_FT_DP maybe be reduced as a full 120
# seconds is not needed after MGTs are tested
2022-05-25 10:03:47 +02:00
KAI.MGT_FT_DP[0]: [OpCodes.MGT_FT_DP, KAI.MGT_FT_DP[1], 10.0, 10.0],
2022-05-24 18:13:17 +02:00
KAI.SUS_FT[0]: [OpCodes.SUS_FT, KAI.SUS_FT[1], 120.0, 10.0],
KAI.STR_FT[0]: [OpCodes.STR_FT, KAI.STR_FT[1], 120.0, 10.0],
2022-05-27 10:50:44 +02:00
# collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120
# seconds is not needed after RWs are tested
KAI.RW_FT_ONE_RW[0]: [OpCodes.RW_FT_ONE_RW, KAI.RW_FT_ONE_RW[1], 10.0, 1.0],
2022-05-27 10:50:44 +02:00
# collection_time for KAI.RW_FT_ONE_RW maybe be reduced as a full 120
# seconds is not needed after RWs are tested
2022-05-25 13:32:18 +02:00
KAI.RW_FT_TWO_RWS[0]: [OpCodes.RW_FT_TWO_RWS, KAI.RW_FT_TWO_RWS[1], 10.0, 1.0],
2022-05-19 18:47:23 +02:00
}
2022-05-27 10:50:44 +02:00
class GenericHkListeningCfg:
2022-05-27 11:53:57 +02:00
def __init__(self, mgt: bool = False, one_rw: bool = False, two_rws: bool = False):
self.use_tc_sched = False
2022-05-27 10:50:44 +02:00
self.mgt = mgt
self.one_rw = one_rw
self.two_rws = two_rws
@classmethod
def default(cls) -> GenericHkListeningCfg:
return GenericHkListeningCfg(False, False, False)
2022-08-08 16:32:18 +02:00
def generic_print(q: DefaultPusQueueHelper, info: dict):
2022-07-04 17:59:09 +02:00
q.add_log_cmd(f"Executing {info[1]} Procedure (OpCodes: {info[0]})")
2022-05-19 18:47:23 +02:00
@tmtc_definitions_provider
def add_proc_cmds(defs: TmtcDefinitionWrapper):
2022-07-05 02:12:54 +02:00
oce = OpCodeEntry()
2022-05-25 13:32:18 +02:00
for proc_entry in PROC_INFO_DICT.values():
2022-07-05 02:12:54 +02:00
oce.add(keys=proc_entry[0], info=proc_entry[1])
defs.add_service(
2022-05-25 13:32:18 +02:00
name=CustomServiceList.PROCEDURE.value,
info="TV Test Procedures",
2022-07-05 02:12:54 +02:00
op_code_entry=oce,
2022-05-25 13:32:18 +02:00
)
2022-05-19 18:47:23 +02:00
def pack_generic_hk_listening_cmds(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper,
2022-05-24 17:24:09 +02:00
proc_key: str,
sid_list: list[bytearray],
2022-05-31 17:55:53 +02:00
diag_list: list[bool],
2022-05-27 10:50:44 +02:00
cfg: GenericHkListeningCfg,
2022-05-19 18:47:23 +02:00
):
2022-05-20 16:40:58 +02:00
info = PROC_INFO_DICT[proc_key]
2022-05-24 15:26:08 +02:00
collection_time = info[2]
2022-07-04 17:59:09 +02:00
generic_print(q=q, info=info)
2022-05-24 14:58:13 +02:00
2022-05-31 17:55:53 +02:00
for i in range(len(sid_list)):
2022-05-24 14:58:13 +02:00
enable_listen_to_hk_for_x_seconds(
2022-05-31 17:55:53 +02:00
diag=diag_list[i],
2022-07-04 17:59:09 +02:00
q=q,
2022-05-24 14:58:13 +02:00
device=proc_key,
2022-05-31 17:55:53 +02:00
sid=sid_list[i],
2022-05-24 14:58:13 +02:00
interval_seconds=info[3],
)
2022-05-27 11:53:57 +02:00
if not cfg.use_tc_sched:
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(2.0)
2022-05-24 14:58:13 +02:00
2022-05-27 10:50:44 +02:00
if cfg.mgt:
2022-07-04 17:59:09 +02:00
activate_mgts_alternately(q)
2022-05-27 10:50:44 +02:00
elif cfg.one_rw:
2022-05-25 15:21:50 +02:00
activate_all_rws_in_sequence(
2022-07-04 17:59:09 +02:00
q=q, test_speed=20000, test_ramp_time=10000, init_ssc=0
2022-05-25 10:03:47 +02:00
)
2022-05-27 10:50:44 +02:00
elif cfg.two_rws:
2022-07-04 17:59:09 +02:00
activate_all_rws_two_consecutively(q=q)
else:
pass
2022-05-27 11:53:57 +02:00
if not cfg.use_tc_sched:
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(collection_time)
2022-05-27 11:53:57 +02:00
disable_cmd_list = []
2022-05-31 17:55:53 +02:00
for i in range(len(sid_list)):
2022-05-27 11:53:57 +02:00
disable_cmd_list.append(
gen_disable_listen_to_hk_for_x_seconds(
2022-05-31 17:55:53 +02:00
diag=diag_list[i],
2022-07-04 17:59:09 +02:00
q=q,
2022-05-27 11:53:57 +02:00
device=proc_key,
2022-05-31 17:55:53 +02:00
sid=sid_list[i],
2022-05-27 11:53:57 +02:00
)
2022-05-24 15:26:08 +02:00
)
2022-06-03 11:51:03 +02:00
if cfg.one_rw or cfg.two_rws:
2022-07-04 17:59:09 +02:00
activate_all_rws_in_sequence(q=q, test_speed=0, test_ramp_time=5000, init_ssc=0)
q.add_wait_seconds(60.0)
2022-05-27 11:53:57 +02:00
current_time = time.time()
current_time += collection_time
if not cfg.use_tc_sched:
for cmd in disable_cmd_list:
2022-07-04 17:59:09 +02:00
q.add_pus_tc(cmd)
2022-05-27 11:53:57 +02:00
else:
for cmd in disable_cmd_list:
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
2022-05-27 11:53:57 +02:00
generate_time_tagged_cmd(
2022-07-04 17:59:09 +02:00
release_time=struct.pack("!I", int(current_time)), tc_to_insert=cmd
2022-05-27 11:53:57 +02:00
)
)
2022-06-02 18:51:40 +02:00
if not cfg.use_tc_sched:
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(60.0)
2022-05-24 15:26:08 +02:00
sid_list.clear()
2022-05-31 17:55:53 +02:00
diag_list.clear()
2022-05-24 15:26:08 +02:00
2022-05-24 14:58:13 +02:00
2022-08-08 16:32:18 +02:00
def pack_proc_commands(q: DefaultPusQueueHelper, op_code: str):
2022-05-24 14:58:13 +02:00
sid_list = []
2022-05-27 11:53:57 +02:00
obj_id_dict = get_object_ids()
if op_code in OpCodes.RESET_SCHED:
2022-07-04 17:59:09 +02:00
q.add_log_cmd("Resetting/Clearing TC schedule")
q.add_pus_tc(generate_reset_tc_sched_cmd())
2022-05-18 20:00:59 +02:00
if op_code in OpCodes.BAT_FT:
2022-05-19 18:47:23 +02:00
key = KAI.BAT_FT[0]
2022-05-24 15:26:08 +02:00
sid_list.append(make_sid(oids.BPX_HANDLER_ID, BpxSetIds.GET_HK_SET))
2022-05-31 17:55:53 +02:00
diag_list = [False]
2022-05-20 16:40:58 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-20 16:40:58 +02:00
)
if op_code in OpCodes.CORE_FT:
key = KAI.CORE_FT[0]
2022-05-24 15:26:08 +02:00
sid_list.append(make_sid(oids.CORE_CONTROLLER_ID, CoreSetIds.HK))
2022-05-31 17:55:53 +02:00
diag_list = [False]
2022-05-19 18:47:23 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-18 20:00:59 +02:00
)
2022-05-19 18:14:38 +02:00
if op_code in OpCodes.PCDU_FT:
2022-05-19 18:47:23 +02:00
key = KAI.PCDU_FT[0]
2022-05-27 19:32:02 +02:00
pcdu_pairs = [
(oids.P60_DOCK_HANDLER, GsSetIds.P60_CORE),
(oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_CORE),
(oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_CORE),
(oids.ACU_HANDLER_ID, GsSetIds.ACU_CORE),
(oids.P60_DOCK_HANDLER, GsSetIds.P60_AUX),
(oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_AUX),
(oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_AUX),
(oids.ACU_HANDLER_ID, GsSetIds.ACU_AUX),
]
2022-05-31 17:55:53 +02:00
diag_list = [
False,
True,
True,
True,
False,
False,
False,
False,
]
2022-05-27 19:32:02 +02:00
for pcdu_dev in pcdu_pairs:
oid = pcdu_dev[0]
set_id = pcdu_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-20 16:40:58 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-24 14:58:13 +02:00
)
2022-05-20 16:40:58 +02:00
if op_code in OpCodes.RAD_SEN_FT:
2022-05-23 11:53:31 +02:00
key = KAI.RAD_SEN_FT[0]
2022-05-25 15:31:45 +02:00
sid_list.append(make_sid(oids.RAD_SENSOR_ID, RadSetIds.HK))
2022-05-31 17:55:53 +02:00
diag_list = [False]
2022-05-20 16:40:58 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-20 16:40:58 +02:00
)
2022-05-27 11:53:57 +02:00
if op_code in OpCodes.TV_SETUP_TCS_FT_ON:
# Enable scheduling
2022-07-04 17:59:09 +02:00
q.add_pus_tc(generate_enable_tc_sched_cmd())
2022-05-24 17:24:09 +02:00
# check whether tcs_assembly also has to be commanded to NORMAL Mode
2022-07-04 17:59:09 +02:00
pack_tcs_sys_commands(q=q, op_code=TcsOpCodes.TCS_BOARD_ASS_NORMAL[0])
pack_cmd_ctrl_to_nml(q=q, object_id=obj_id_dict.get(oids.THERMAL_CONTROLLER_ID))
2022-05-20 16:40:58 +02:00
2022-05-27 11:53:57 +02:00
if op_code in OpCodes.TV_TEARDOWN_TCS_FT_OFF:
2022-05-30 09:25:57 +02:00
# TCS board should always be on anyway, do not command it off here
2022-07-04 17:59:09 +02:00
pack_cmd_ctrl_to_off(q=q, object_id=obj_id_dict.get(oids.THERMAL_CONTROLLER_ID))
2022-05-20 16:40:58 +02:00
2022-05-23 11:53:31 +02:00
if op_code in OpCodes.ACS_FT:
key = KAI.ACS_FT[0]
2022-05-27 11:53:57 +02:00
a_side_pairs = [
(oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK),
(oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK),
(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK),
(oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK),
(oids.GPS_CONTROLLER, GpsSetIds.HK),
]
b_side_pairs = [
(oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK),
(oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK),
(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK),
(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK),
(oids.GPS_CONTROLLER, GpsSetIds.HK),
]
2022-05-27 19:32:02 +02:00
d_side_pairs = a_side_pairs + b_side_pairs
2022-07-04 15:22:53 +02:00
diag_list = [False, False, True, False, False]
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="acs-a")
2022-05-27 19:32:02 +02:00
2022-05-27 11:53:57 +02:00
for a_side_dev in a_side_pairs:
oid = a_side_dev[0]
set_id = a_side_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-23 15:28:41 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-23 15:28:41 +02:00
)
2022-05-23 11:53:31 +02:00
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="acs-off")
q.add_wait_seconds(5.0)
pack_acs_command(q=q, op_code="acs-b")
2022-05-23 11:53:31 +02:00
2022-06-02 18:51:40 +02:00
sid_list.clear()
2022-07-04 15:22:53 +02:00
diag_list = [False, False, True, False, False]
2022-06-02 18:51:40 +02:00
2022-05-27 11:53:57 +02:00
for b_side_dev in b_side_pairs:
oid = b_side_dev[0]
set_id = b_side_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-23 15:28:41 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-23 15:28:41 +02:00
)
2022-05-23 11:53:31 +02:00
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="acs-off")
q.add_wait_seconds(5.0)
pack_acs_command(q=q, op_code="acs-d")
2022-05-23 11:53:31 +02:00
2022-06-02 18:51:40 +02:00
sid_list.clear()
2022-05-27 19:32:02 +02:00
for d_side_dev in d_side_pairs:
oid = d_side_dev[0]
set_id = d_side_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-06-02 18:51:40 +02:00
diag_list = [
False,
False,
2022-06-03 11:51:03 +02:00
True,
2022-06-02 18:51:40 +02:00
False,
False,
False,
False,
2022-06-03 11:51:03 +02:00
True,
2022-06-02 18:51:40 +02:00
False,
2022-06-07 17:49:16 +02:00
False,
2022-06-02 18:51:40 +02:00
]
2022-05-23 15:28:41 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-23 15:28:41 +02:00
)
2022-05-23 11:53:31 +02:00
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="acs-off")
2022-05-23 11:53:31 +02:00
2022-05-23 15:28:41 +02:00
if op_code in OpCodes.MGT_FT:
key = KAI.MGT_FT[0]
2022-05-27 19:32:02 +02:00
imtq_pairs = [
(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET),
(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET),
(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET),
]
2022-05-31 17:55:53 +02:00
diag_list = [
2022-06-03 18:04:59 +02:00
True,
True,
True,
2022-05-31 17:55:53 +02:00
]
2022-05-23 15:28:41 +02:00
2022-06-03 18:04:59 +02:00
# Command MGT to mode on
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="1")
q.add_wait_seconds(5.0)
2022-06-03 18:04:59 +02:00
# Command MGT to normal mode
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="2")
2022-05-27 19:32:02 +02:00
for imtq_dev in imtq_pairs:
oid = imtq_dev[0]
set_id = imtq_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-23 15:28:41 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-07-04 15:22:53 +02:00
proc_key=key,
sid_list=sid_list,
diag_list=diag_list,
cfg=GenericHkListeningCfg.default(),
2022-05-23 15:28:41 +02:00
)
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="0")
2022-05-23 15:28:41 +02:00
2022-05-23 16:42:27 +02:00
if op_code in OpCodes.MGT_FT_DP:
key = KAI.MGT_FT_DP[0]
2022-05-27 19:32:02 +02:00
a_side_pairs = [
(oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK),
(oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK),
(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK),
(oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK),
(oids.GPS_CONTROLLER, GpsSetIds.HK),
]
b_side_pairs = [
(oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK),
(oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK),
(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK),
(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK),
(oids.GPS_CONTROLLER, GpsSetIds.HK),
]
imtq_pairs = [
(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET),
(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET),
(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET),
]
d_side_and_imtq_pairs = a_side_pairs + b_side_pairs + imtq_pairs
2022-05-31 17:55:53 +02:00
diag_list = [
False,
False,
2022-06-03 18:04:59 +02:00
True,
2022-05-31 17:55:53 +02:00
False,
False,
False,
False,
2022-06-03 18:04:59 +02:00
True,
2022-06-07 17:49:16 +02:00
False,
False,
2022-06-03 18:04:59 +02:00
True,
True,
True,
2022-05-31 17:55:53 +02:00
]
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="acs-d")
2022-06-03 18:04:59 +02:00
# Command MGT to mode on
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="1")
q.add_wait_seconds(20.0)
2022-06-03 18:04:59 +02:00
# Command MGT to normal mode
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="2")
2022-05-23 16:42:27 +02:00
2022-05-27 19:32:02 +02:00
for d_side_and_imtq_dev in d_side_and_imtq_pairs:
oid = d_side_and_imtq_dev[0]
set_id = d_side_and_imtq_dev[1]
sid_list.append(make_sid(oid, set_id))
cfg = GenericHkListeningCfg.default()
cfg.mgt = True
2022-05-23 16:42:27 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
cfg=cfg,
2022-05-23 16:42:27 +02:00
)
2022-07-04 17:59:09 +02:00
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="0")
pack_acs_command(q=q, op_code="acs-off")
2022-05-23 15:28:41 +02:00
2022-05-24 18:13:17 +02:00
if op_code in OpCodes.SUS_FT:
key = KAI.SUS_FT[0]
2022-07-04 17:59:09 +02:00
pack_sus_cmds(q=q, op_code="sus-nom")
2022-05-24 18:13:17 +02:00
2022-05-25 11:16:24 +02:00
sus_n_ids = [
oids.SUS_0_N_LOC_XFYFZM_PT_XF,
oids.SUS_1_N_LOC_XBYFZM_PT_XB,
oids.SUS_2_N_LOC_XFYBZB_PT_YB,
oids.SUS_3_N_LOC_XFYBZF_PT_YF,
oids.SUS_4_N_LOC_XMYFZF_PT_ZF,
oids.SUS_5_N_LOC_XFYMZB_PT_ZB,
]
sus_r_ids = [
oids.SUS_6_R_LOC_XFYBZM_PT_XF,
oids.SUS_7_R_LOC_XBYBZM_PT_XB,
oids.SUS_8_R_LOC_XBYBZB_PT_YB,
oids.SUS_9_R_LOC_XBYBZB_PT_YF,
oids.SUS_10_R_LOC_XMYBZF_PT_ZF,
oids.SUS_11_R_LOC_XBYMZB_PT_ZB,
]
2022-05-31 17:55:53 +02:00
diag_list = [
2022-06-03 11:51:03 +02:00
True,
True,
True,
True,
True,
True,
2022-05-31 17:55:53 +02:00
]
2022-05-24 18:13:17 +02:00
# SUSs
2022-05-25 11:16:24 +02:00
for nom_sus in sus_n_ids:
sid_list.append(make_sid(nom_sus, SetIds.HK))
2022-05-24 18:13:17 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-24 18:13:17 +02:00
)
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="sus-off")
q.add_wait_seconds(5.0)
pack_sus_cmds(q=q, op_code="sus-red")
2022-05-24 18:13:17 +02:00
2022-06-03 11:51:03 +02:00
diag_list = [
True,
True,
True,
True,
True,
True,
]
2022-05-24 18:13:17 +02:00
# SUSs
2022-05-25 11:16:24 +02:00
for red_sus in sus_r_ids:
sid_list.append(make_sid(red_sus, SetIds.HK))
2022-05-24 18:13:17 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-24 18:13:17 +02:00
)
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="sus-off")
q.add_wait_seconds(5.0)
pack_sus_cmds(q=q, op_code="sus-d")
2022-05-24 18:13:17 +02:00
# SUSs
2022-05-25 11:16:24 +02:00
for nom_sus in sus_n_ids:
sid_list.append(make_sid(nom_sus, SetIds.HK))
for red_sus in sus_r_ids:
sid_list.append(make_sid(red_sus, SetIds.HK))
2022-06-03 11:51:03 +02:00
diag_list = [
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
True,
]
2022-05-24 18:13:17 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
2022-05-24 18:13:17 +02:00
)
2022-07-04 17:59:09 +02:00
pack_acs_command(q=q, op_code="sus-off")
2022-05-24 18:13:17 +02:00
if op_code in OpCodes.STR_FT:
key = KAI.STR_FT[0]
2022-07-04 17:59:09 +02:00
pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, op_code="2")
# STR
sid_list.append(make_sid(oids.STAR_TRACKER_ID, StrSetIds.TEMPERATURE))
2022-05-31 17:55:53 +02:00
diag_list = [False]
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg.default(),
)
2022-07-04 17:59:09 +02:00
pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, op_code="3")
2022-05-25 10:03:47 +02:00
if op_code in OpCodes.RW_FT_ONE_RW:
key = KAI.RW_FT_ONE_RW[0]
2022-05-27 19:32:02 +02:00
rw_pairs = [
(oids.RW1_ID, RwSetIds.STATUS_SET_ID),
(oids.RW1_ID, RwSetIds.LAST_RESET),
(oids.RW1_ID, RwSetIds.TM_SET),
(oids.RW2_ID, RwSetIds.STATUS_SET_ID),
(oids.RW2_ID, RwSetIds.LAST_RESET),
(oids.RW2_ID, RwSetIds.TM_SET),
(oids.RW3_ID, RwSetIds.STATUS_SET_ID),
(oids.RW3_ID, RwSetIds.LAST_RESET),
(oids.RW3_ID, RwSetIds.TM_SET),
(oids.RW4_ID, RwSetIds.STATUS_SET_ID),
(oids.RW4_ID, RwSetIds.LAST_RESET),
(oids.RW4_ID, RwSetIds.TM_SET),
]
2022-05-31 17:55:53 +02:00
diag_list = [
2022-06-02 18:51:40 +02:00
True,
2022-05-31 17:55:53 +02:00
False,
False,
2022-06-02 18:51:40 +02:00
True,
2022-05-31 17:55:53 +02:00
False,
False,
2022-06-02 18:51:40 +02:00
True,
2022-05-31 17:55:53 +02:00
False,
False,
2022-06-02 18:51:40 +02:00
True,
2022-05-31 17:55:53 +02:00
False,
False,
]
2022-05-25 11:10:57 +02:00
# RW NORMAL
2022-07-04 17:59:09 +02:00
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="nml")
2022-05-25 10:03:47 +02:00
# RW HK für alle RWs nur einzeln
2022-05-27 19:32:02 +02:00
for rw_dev in rw_pairs:
oid = rw_dev[0]
set_id = rw_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-25 10:03:47 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg(mgt=False, one_rw=True, two_rws=False),
2022-05-25 10:03:47 +02:00
)
2022-05-25 11:10:57 +02:00
# RW OFF
2022-07-04 17:59:09 +02:00
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="off")
2022-05-25 10:03:47 +02:00
2022-05-25 11:10:57 +02:00
# ass command with 2 rws to speed
2022-05-25 10:13:31 +02:00
if op_code in OpCodes.RW_FT_TWO_RWS:
key = KAI.RW_FT_TWO_RWS[0]
2022-05-27 19:32:02 +02:00
rw_pairs = [
(oids.RW1_ID, RwSetIds.STATUS_SET_ID),
(oids.RW1_ID, RwSetIds.TEMPERATURE_SET_ID),
(oids.RW1_ID, RwSetIds.LAST_RESET),
(oids.RW1_ID, RwSetIds.TM_SET),
(oids.RW2_ID, RwSetIds.STATUS_SET_ID),
(oids.RW2_ID, RwSetIds.TEMPERATURE_SET_ID),
(oids.RW2_ID, RwSetIds.LAST_RESET),
(oids.RW2_ID, RwSetIds.TM_SET),
(oids.RW3_ID, RwSetIds.STATUS_SET_ID),
(oids.RW3_ID, RwSetIds.TEMPERATURE_SET_ID),
(oids.RW3_ID, RwSetIds.LAST_RESET),
(oids.RW3_ID, RwSetIds.TM_SET),
(oids.RW4_ID, RwSetIds.STATUS_SET_ID),
(oids.RW4_ID, RwSetIds.TEMPERATURE_SET_ID),
(oids.RW4_ID, RwSetIds.LAST_RESET),
(oids.RW4_ID, RwSetIds.TM_SET),
]
2022-05-31 17:55:53 +02:00
diag_list = [
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
]
2022-05-25 11:10:57 +02:00
# RW NORMAL
2022-07-04 17:59:09 +02:00
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="nml")
2022-05-25 10:03:47 +02:00
# RW
2022-05-27 19:32:02 +02:00
for rw_dev in rw_pairs:
oid = rw_dev[0]
set_id = rw_dev[1]
sid_list.append(make_sid(oid, set_id))
2022-05-25 10:03:47 +02:00
pack_generic_hk_listening_cmds(
2022-07-04 17:59:09 +02:00
q=q,
2022-05-25 11:10:57 +02:00
proc_key=key,
sid_list=sid_list,
2022-05-31 17:55:53 +02:00
diag_list=diag_list,
2022-05-27 10:50:44 +02:00
cfg=GenericHkListeningCfg(mgt=False, one_rw=False, two_rws=True),
2022-05-25 10:03:47 +02:00
)
2022-05-25 11:10:57 +02:00
# RW OFF
2022-07-04 17:59:09 +02:00
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="off")
2022-05-25 10:03:47 +02:00
2022-05-24 14:58:13 +02:00
def enable_listen_to_hk_for_x_seconds(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper,
2022-05-24 14:58:13 +02:00
diag: bool,
device: str,
sid: bytes,
interval_seconds: float,
):
2022-07-04 17:59:09 +02:00
q.add_log_cmd(f"Enabling periodic HK for {device}")
2022-05-24 14:58:13 +02:00
cmd_tuple = enable_periodic_hk_command_with_interval(
diag=diag, sid=sid, interval_seconds=interval_seconds, ssc=0
)
for cmd in cmd_tuple:
2022-07-04 17:59:09 +02:00
q.add_pus_tc(cmd)
generate_time_tagged_cmd(
struct.pack("!I", int(round(time.time() + interval_seconds))),
2022-08-12 22:33:16 +02:00
gen_disable_listen_to_hk_for_x_seconds(q, diag, device, sid),
)
2022-05-24 14:58:13 +02:00
2022-05-27 11:53:57 +02:00
def gen_disable_listen_to_hk_for_x_seconds(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper,
2022-05-24 14:58:13 +02:00
diag: bool,
device: str,
sid: bytes,
2022-05-27 11:53:57 +02:00
) -> PusTelecommand:
2022-07-04 17:59:09 +02:00
q.add_log_cmd(f"Disabling periodic HK for {device}")
return disable_periodic_hk_command(diag=diag, sid=sid)
2022-05-24 14:58:13 +02:00
def activate_mgts_alternately(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper,
):
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=2000,
y_dipole=0,
z_dipole=0,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=-2000,
y_dipole=0,
z_dipole=0,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=0,
y_dipole=2000,
z_dipole=0,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=0,
y_dipole=-2000,
z_dipole=0,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=0,
y_dipole=0,
z_dipole=2000,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
q.add_pus_tc(
pack_dipole_command(
object_id=oids.IMTQ_HANDLER_ID,
x_dipole=0,
y_dipole=0,
z_dipole=-2000,
duration=30000,
)
2022-05-24 17:24:09 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(40.0)
2022-05-25 10:03:47 +02:00
2022-08-08 16:32:18 +02:00
def rw_speed_cmd_single(
q: DefaultPusQueueHelper, oid: bytes, speed: int, ramp_time: int
):
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
pack_set_speed_command(object_id=oid, speed=speed, ramp_time_ms=ramp_time)
2022-05-25 10:03:47 +02:00
)
2022-07-04 17:59:09 +02:00
q.add_wait(timedelta(seconds=70.0))
q.add_pus_tc(pack_set_speed_command(object_id=oid, speed=0, ramp_time_ms=ramp_time))
2022-05-25 10:03:47 +02:00
2022-05-25 15:21:50 +02:00
def rw_speed_up_cmd_consec(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper, obids: List[bytes], speed: int, ramp_time: int
2022-07-04 17:59:09 +02:00
):
2022-05-25 15:21:50 +02:00
for oid in obids:
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
pack_set_speed_command(object_id=oid, speed=speed, ramp_time_ms=ramp_time)
2022-05-25 15:21:50 +02:00
)
2022-08-08 16:32:18 +02:00
def rw_speed_down_cmd_consec(
q: DefaultPusQueueHelper, obids: List[bytes], ramp_time: int
):
2022-05-25 15:21:50 +02:00
for oid in obids:
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
pack_set_speed_command(object_id=oid, speed=0, ramp_time_ms=ramp_time)
2022-05-25 15:21:50 +02:00
)
def activate_all_rws_in_sequence(
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper, init_ssc: int, test_speed: int, test_ramp_time: int
2022-07-04 17:59:09 +02:00
):
2022-05-25 15:21:50 +02:00
new_ssc = init_ssc
# RW1 speed cmd
2022-07-04 17:59:09 +02:00
q.add_wait(timedelta(seconds=58.0))
rw_speed_cmd_single(q, oids.RW1_ID, test_speed, test_ramp_time)
q.add_wait_seconds(30.0)
rw_speed_cmd_single(q, oids.RW2_ID, test_speed, test_ramp_time)
q.add_wait_seconds(30.0)
rw_speed_cmd_single(q, oids.RW3_ID, test_speed, test_ramp_time)
q.add_wait_seconds(30.0)
rw_speed_cmd_single(q, oids.RW4_ID, test_speed, test_ramp_time)
q.add_wait_seconds(30.0)
2022-05-25 15:21:50 +02:00
return new_ssc
2022-05-25 10:03:47 +02:00
2022-08-08 16:32:18 +02:00
def activate_all_rws_two_consecutively(q: DefaultPusQueueHelper):
2022-05-25 10:03:47 +02:00
# RW1+3 speed cmd
2022-07-04 17:59:09 +02:00
q.add_wait_seconds(5.0)
rw_speed_up_cmd_consec(q, [oids.RW1_ID, oids.RW3_ID], -20000, 10000)
q.add_wait_seconds(70.0)
rw_speed_down_cmd_consec(q, [oids.RW1_ID, oids.RW3_ID], 10000)
q.add_wait_seconds(15.0)
2022-05-25 10:03:47 +02:00
# RW2+4 speed cmd
2022-07-04 17:59:09 +02:00
rw_speed_up_cmd_consec(q, [oids.RW2_ID, oids.RW4_ID], -20000, 10000)
q.add_wait_seconds(70.0)
rw_speed_down_cmd_consec(q, [oids.RW2_ID, oids.RW4_ID], 10000)
q.add_wait_seconds(15.0)