reduced code duplication

This commit is contained in:
Markus Kranz 2022-05-27 19:32:02 +02:00
parent 79e0838473
commit 27b41c0a48

View File

@ -235,14 +235,21 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.PCDU_FT: if op_code in OpCodes.PCDU_FT:
key = KAI.PCDU_FT[0] key = KAI.PCDU_FT[0]
sid_list.append(make_sid(oids.P60_DOCK_HANDLER, GsSetIds.P60_CORE)) pcdu_pairs = [
sid_list.append(make_sid(oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_CORE)) (oids.P60_DOCK_HANDLER, GsSetIds.P60_CORE),
sid_list.append(make_sid(oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_CORE)) (oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_CORE),
sid_list.append(make_sid(oids.ACU_HANDLER_ID, GsSetIds.ACU_CORE)) (oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_CORE),
sid_list.append(make_sid(oids.P60_DOCK_HANDLER, GsSetIds.P60_AUX)) (oids.ACU_HANDLER_ID, GsSetIds.ACU_CORE),
sid_list.append(make_sid(oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_AUX)) (oids.P60_DOCK_HANDLER, GsSetIds.P60_AUX),
sid_list.append(make_sid(oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_AUX)) (oids.PDU_1_HANDLER_ID, GsSetIds.PDU_1_AUX),
sid_list.append(make_sid(oids.ACU_HANDLER_ID, GsSetIds.ACU_AUX)) (oids.PDU_2_HANDLER_ID, GsSetIds.PDU_2_AUX),
(oids.ACU_HANDLER_ID, GsSetIds.ACU_AUX),
]
for pcdu_dev in pcdu_pairs:
oid = pcdu_dev[0]
set_id = pcdu_dev[1]
sid_list.append(make_sid(oid, set_id))
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, tc_queue=tc_queue,
proc_key=key, proc_key=key,
@ -295,8 +302,9 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK), (oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK),
(oids.GPS_CONTROLLER, GpsSetIds.HK), (oids.GPS_CONTROLLER, GpsSetIds.HK),
] ]
d_side_pairs = a_side_pairs + b_side_pairs
pack_acs_command(tc_queue=tc_queue, op_code="acs-a") pack_acs_command(tc_queue=tc_queue, op_code="acs-a")
# MGMs
for a_side_dev in a_side_pairs: for a_side_dev in a_side_pairs:
oid = a_side_dev[0] oid = a_side_dev[0]
set_id = a_side_dev[1] set_id = a_side_dev[1]
@ -331,33 +339,11 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
tc_queue.appendleft((QueueCommands.WAIT, 5.0)) tc_queue.appendleft((QueueCommands.WAIT, 5.0))
pack_acs_command(tc_queue=tc_queue, op_code="acs-d") pack_acs_command(tc_queue=tc_queue, op_code="acs-d")
# MGMs for d_side_dev in d_side_pairs:
sid_list.append(make_sid(oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK)) oid = d_side_dev[0]
sid_list.append( set_id = d_side_dev[1]
make_sid(oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK) sid_list.append(make_sid(oid, set_id))
)
sid_list.append(make_sid(oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK))
sid_list.append(
make_sid(oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK)
)
# Gyros
sid_list.append(
make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK)
)
sid_list.append(
make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK)
)
sid_list.append(make_sid(oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK))
sid_list.append(
make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK)
)
sid_list.append(
make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK)
)
sid_list.append(make_sid(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK))
# GNSS0+1
sid_list.append(make_sid(oids.GPS_CONTROLLER, GpsSetIds.HK))
sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GpsSetIds.HK))
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, tc_queue=tc_queue,
proc_key=key, proc_key=key,
@ -370,13 +356,19 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.MGT_FT: if op_code in OpCodes.MGT_FT:
key = KAI.MGT_FT[0] key = KAI.MGT_FT[0]
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),
]
# mgt 1: imtq und hk # mgt 1: imtq und hk
pack_imtq_test_into(oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="2") pack_imtq_test_into(oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="2")
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET)) for imtq_dev in imtq_pairs:
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET)) oid = imtq_dev[0]
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET)) set_id = imtq_dev[1]
sid_list.append(make_sid(oid, set_id))
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, cfg=GenericHkListeningCfg.default() tc_queue=tc_queue, proc_key=key, sid_list=sid_list, diag=False, cfg=GenericHkListeningCfg.default()
) )
@ -385,6 +377,26 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.MGT_FT_DP: if op_code in OpCodes.MGT_FT_DP:
key = KAI.MGT_FT_DP[0] key = KAI.MGT_FT_DP[0]
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
pack_acs_command(tc_queue=tc_queue, op_code="acs-d") pack_acs_command(tc_queue=tc_queue, op_code="acs-d")
# mgt 2.: imtq + dual side + dipole # mgt 2.: imtq + dual side + dipole
@ -392,42 +404,13 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
object_id=oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="2" object_id=oids.IMTQ_HANDLER_ID, tc_queue=tc_queue, op_code="2"
) )
# MGMs for d_side_and_imtq_dev in d_side_and_imtq_pairs:
sid_list.append(make_sid(oids.MGM_0_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK)) oid = d_side_and_imtq_dev[0]
sid_list.append( set_id = d_side_and_imtq_dev[1]
make_sid(oids.MGM_1_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK) sid_list.append(make_sid(oid, set_id))
)
sid_list.append(make_sid(oids.MGM_2_LIS3_HANDLER_ID, MgmLis3SetIds_0_2.CORE_HK))
sid_list.append(
make_sid(oids.MGM_3_RM3100_HANDLER_ID, MgmRm3100SetIds_1_3.CORE_HK)
)
# Gyros
sid_list.append(
make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK)
)
sid_list.append(
make_sid(oids.GYRO_0_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK)
)
sid_list.append(make_sid(oids.GYRO_1_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK))
sid_list.append(
make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CORE_HK)
)
sid_list.append(
make_sid(oids.GYRO_2_ADIS_HANDLER_ID, AdisGyroSetIds_0_2.CFG_HK)
)
sid_list.append(make_sid(oids.GYRO_3_L3G_HANDLER_ID, L3gGyroSetIds_1_3.CORE_HK))
# GNSS0+1
sid_list.append(make_sid(oids.GPS_CONTROLLER, GpsSetIds.HK))
sid_list.append(make_sid(oids.GPS_HANDLER_1_ID, GpsSetIds.HK))
# IMTQ
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET))
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.CAL_MTM_SET))
sid_list.append(make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.RAW_MTM_SET))
cfg = GenericHkListeningCfg.default() cfg = GenericHkListeningCfg.default()
cfg.mgt = True cfg.mgt = True
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, tc_queue=tc_queue,
proc_key=key, proc_key=key,
@ -528,27 +511,33 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.RW_FT_ONE_RW: if op_code in OpCodes.RW_FT_ONE_RW:
key = KAI.RW_FT_ONE_RW[0] key = KAI.RW_FT_ONE_RW[0]
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),
]
# RW NORMAL # RW NORMAL
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="nml") pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="nml")
# RW HK für alle RWs nur einzeln # RW HK für alle RWs nur einzeln
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.STATUS_SET_ID)) for rw_dev in rw_pairs:
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.TEMPERATURE_SET_ID)) oid = rw_dev[0]
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.LAST_RESET)) set_id = rw_dev[1]
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.TM_SET)) sid_list.append(make_sid(oid, set_id))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.TM_SET))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.TM_SET))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.TM_SET))
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, tc_queue=tc_queue,
proc_key=key, proc_key=key,
@ -562,26 +551,32 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
# ass command with 2 rws to speed # ass command with 2 rws to speed
if op_code in OpCodes.RW_FT_TWO_RWS: if op_code in OpCodes.RW_FT_TWO_RWS:
key = KAI.RW_FT_TWO_RWS[0] key = KAI.RW_FT_TWO_RWS[0]
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),
]
# RW NORMAL # RW NORMAL
pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="nml") pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, tc_queue=tc_queue, op_code="nml")
# RW # RW
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.STATUS_SET_ID)) for rw_dev in rw_pairs:
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.TEMPERATURE_SET_ID)) oid = rw_dev[0]
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.LAST_RESET)) set_id = rw_dev[1]
sid_list.append(make_sid(oids.RW1_ID, RwSetIds.TM_SET)) sid_list.append(make_sid(oid, set_id))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW2_ID, RwSetIds.TM_SET))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW3_ID, RwSetIds.TM_SET))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.STATUS_SET_ID))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.TEMPERATURE_SET_ID))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.LAST_RESET))
sid_list.append(make_sid(oids.RW4_ID, RwSetIds.TM_SET))
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, tc_queue=tc_queue,
proc_key=key, proc_key=key,