eive-tmtc/eive_tmtc/pus_tc/procedure_packer.py

220 lines
9.2 KiB
Python
Raw Normal View History

2021-09-13 18:06:25 +02:00
"""Hook function which packs telecommands based on service and operation code string
2020-12-17 17:50:00 +01:00
"""
from typing import cast
2021-03-19 17:39:52 +01:00
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.power.power import pack_power_commands
from eive_tmtc.pus_tc.devs.rtd import pack_rtd_commands
from eive_tmtc.pus_tc.devs.scex import pack_scex_cmds
from eive_tmtc.pus_tc.system.controllers import (
2022-08-08 16:32:18 +02:00
pack_cmd_ctrl_to_prompted_mode,
get_object_from_op_code,
)
2023-01-31 15:44:09 +01:00
from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands
2022-08-18 14:08:05 +02:00
from tmtccmd import DefaultProcedureInfo, TcHandlerBase
2022-07-04 15:22:53 +02:00
from tmtccmd.config import CoreServiceList
2022-04-05 00:51:52 +02:00
from tmtccmd.logging import get_console_logger
2022-08-12 22:33:16 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2022-08-18 14:08:05 +02:00
from tmtccmd.tc.decorator import (
route_to_registered_service_handlers,
ServiceProviderParams,
)
2022-07-04 15:22:53 +02:00
from tmtccmd.tc.pus_5_event import (
pack_generic_service_5_test_into,
)
2021-03-19 17:39:52 +01:00
2022-11-29 16:53:29 +01:00
from eive_tmtc.pus_tc.service_200_mode import pack_service_200_test_into
from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds
from eive_tmtc.tmtc.power.pdu2 import pack_pdu2_commands
from eive_tmtc.tmtc.power.pdu1 import pack_pdu1_commands
from eive_tmtc.tmtc.power.acu import pack_acu_commands
from eive_tmtc.tmtc.acs.imtq import pack_imtq_test_into
2023-01-31 15:44:09 +01:00
from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.acs.reaction_wheels import (
pack_single_rw_test_into,
pack_rw_ass_cmds,
)
from eive_tmtc.tmtc.payload.ploc_memory_dumper import pack_ploc_memory_dumper_cmd
2023-01-25 14:14:22 +01:00
from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_test
2023-01-11 14:19:47 +01:00
from eive_tmtc.tmtc.core import pack_core_commands
from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands
2023-01-25 14:14:22 +01:00
from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command
2022-11-29 16:53:29 +01:00
from eive_tmtc.tmtc.acs.acs_board import pack_acs_command
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import (
2022-01-18 14:03:56 +01:00
P60_DOCK_HANDLER,
PDU_1_HANDLER_ID,
PDU_2_HANDLER_ID,
ACU_HANDLER_ID,
TMP_1075_1_HANDLER_ID,
TMP_1075_2_HANDLER_ID,
HEATER_CONTROLLER_ID,
2022-01-18 14:03:56 +01:00
IMTQ_HANDLER_ID,
RW1_ID,
RW2_ID,
RW3_ID,
RW4_ID,
RAD_SENSOR_ID,
STAR_TRACKER_ID,
PLOC_MEMORY_DUMPER_ID,
CCSDS_HANDLER_ID,
PDEC_HANDLER_ID,
STR_IMG_HELPER_ID,
SYRLINKS_HANDLER_ID,
2022-05-05 01:21:57 +02:00
RW_ASSEMBLY,
2022-05-23 18:25:25 +02:00
get_object_ids,
2022-01-18 14:03:56 +01:00
)
2023-01-31 15:46:49 +01:00
from eive_tmtc.pus_tc.devs.tmp1075 import pack_tmp1075_test_into
from eive_tmtc.pus_tc.devs.gps import pack_gps_command
from eive_tmtc.pus_tc.devs.rad_sensor import pack_rad_sensor_test_into
from eive_tmtc.pus_tc.devs.plpcdu import pack_pl_pcdu_commands
from eive_tmtc.pus_tc.devs.str_img_helper import pack_str_img_helper_command
from eive_tmtc.pus_tc.system.proc import pack_proc_commands
2022-11-29 16:53:29 +01:00
import eive_tmtc.config.object_ids as oids
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdU32
2020-12-17 17:50:00 +01:00
2021-06-28 19:06:09 +02:00
LOGGER = get_console_logger()
2020-12-17 17:50:00 +01:00
2022-08-08 16:32:18 +02:00
def handle_default_procedure(
2022-08-18 14:08:05 +02:00
tc_base: TcHandlerBase,
info: DefaultProcedureInfo,
queue_helper: DefaultPusQueueHelper,
2022-08-08 16:32:18 +02:00
):
2022-07-04 15:22:53 +02:00
service = info.service
op_code = info.op_code
2022-05-23 11:24:55 +02:00
obj_id_man = get_object_ids()
2021-05-17 17:42:04 +02:00
if service == CoreServiceList.SERVICE_5.value:
2022-07-04 15:22:53 +02:00
return pack_generic_service_5_test_into(q=queue_helper)
if service == CoreServiceList.SERVICE_200.value:
2022-08-12 22:33:16 +02:00
return pack_service_200_test_into(q=queue_helper)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.P60DOCK.value:
object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER))
2022-07-04 15:22:53 +02:00
return pack_p60dock_cmds(object_id=object_id, q=queue_helper, op_code=op_code)
2022-05-23 17:50:08 +02:00
if service == CustomServiceList.RTD.value:
2022-07-04 15:22:53 +02:00
return pack_rtd_commands(object_id=None, q=queue_helper, op_code=op_code)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.PDU1.value:
object_id = cast(ObjectIdU32, obj_id_man.get(PDU_1_HANDLER_ID))
2022-07-04 15:22:53 +02:00
return pack_pdu1_commands(object_id=object_id, q=queue_helper, op_code=op_code)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.PDU2.value:
object_id = cast(ObjectIdU32, obj_id_man.get(PDU_2_HANDLER_ID))
2022-07-04 15:22:53 +02:00
return pack_pdu2_commands(object_id=object_id, q=queue_helper, op_code=op_code)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.ACU.value:
object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID))
2022-07-04 15:22:53 +02:00
return pack_acu_commands(object_id=object_id, q=queue_helper, op_code=op_code)
2022-08-12 08:45:51 +02:00
if service == CustomServiceList.TCS.value:
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.TMP1075_1.value:
object_id = cast(ObjectIdU32, obj_id_man.get(TMP_1075_1_HANDLER_ID))
2022-01-18 14:03:56 +01:00
return pack_tmp1075_test_into(
2022-07-04 15:22:53 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.TMP1075_2.value:
object_id = cast(ObjectIdU32, obj_id_man.get(TMP_1075_2_HANDLER_ID))
2022-01-18 14:03:56 +01:00
return pack_tmp1075_test_into(
2022-07-04 15:22:53 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-03-19 17:39:52 +01:00
if service == CustomServiceList.HEATER.value:
object_id = HEATER_CONTROLLER_ID
2022-07-04 15:22:53 +02:00
return pack_heater_cmds(object_id=object_id, q=queue_helper, op_code=op_code)
2021-03-26 13:56:02 +01:00
if service == CustomServiceList.IMTQ.value:
object_id = cast(ObjectIdU32, obj_id_man.get(IMTQ_HANDLER_ID))
2022-07-04 15:22:53 +02:00
return pack_imtq_test_into(object_id=object_id, q=queue_helper, op_code=op_code)
2021-06-29 09:51:54 +02:00
if service == CustomServiceList.REACTION_WHEEL_1.value:
2022-01-18 14:03:56 +01:00
return pack_single_rw_test_into(
2022-07-04 15:22:53 +02:00
object_id=RW1_ID, rw_idx=1, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-06-29 09:51:54 +02:00
if service == CustomServiceList.REACTION_WHEEL_2.value:
2022-01-18 14:03:56 +01:00
return pack_single_rw_test_into(
2022-07-04 15:22:53 +02:00
object_id=RW2_ID, rw_idx=2, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-06-29 09:51:54 +02:00
if service == CustomServiceList.REACTION_WHEEL_3.value:
2022-01-18 14:03:56 +01:00
return pack_single_rw_test_into(
2022-07-04 15:22:53 +02:00
object_id=RW3_ID, rw_idx=3, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-06-29 09:51:54 +02:00
if service == CustomServiceList.REACTION_WHEEL_4.value:
2022-01-18 14:03:56 +01:00
return pack_single_rw_test_into(
2022-07-04 15:22:53 +02:00
object_id=RW4_ID, rw_idx=4, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
if service == CustomServiceList.RAD_SENSOR.value:
object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID))
2021-09-08 13:20:22 +02:00
return pack_rad_sensor_test_into(
2022-07-04 15:22:53 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2021-09-08 13:20:22 +02:00
)
2021-08-16 10:03:40 +02:00
if service == CustomServiceList.STAR_TRACKER.value:
object_id = cast(ObjectIdU32, obj_id_man.get(STAR_TRACKER_ID))
2021-12-02 08:01:18 +01:00
return pack_star_tracker_commands(
2022-07-04 17:59:09 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2021-12-02 08:01:18 +01:00
)
if service == CustomServiceList.STR_IMG_HELPER.value:
object_id = cast(ObjectIdU32, obj_id_man.get(STR_IMG_HELPER_ID))
2021-12-02 08:01:18 +01:00
return pack_str_img_helper_command(
2022-07-04 17:59:09 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2021-09-08 13:20:22 +02:00
)
2021-08-03 15:28:28 +02:00
if service == CustomServiceList.CORE.value:
2022-07-04 17:59:09 +02:00
return pack_core_commands(q=queue_helper, op_code=op_code)
2021-08-31 11:17:01 +02:00
if service == CustomServiceList.PLOC_MEMORY_DUMPER.value:
object_id = cast(ObjectIdU32, obj_id_man.get(PLOC_MEMORY_DUMPER_ID))
2021-09-08 13:20:22 +02:00
return pack_ploc_memory_dumper_cmd(
2022-07-04 17:59:09 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2021-09-08 13:20:22 +02:00
)
2022-08-11 18:10:15 +02:00
if service == CustomServiceList.POWER.value:
return pack_power_commands(queue_helper, op_code)
2021-09-13 18:06:25 +02:00
if service == CustomServiceList.ACS.value:
2022-07-04 17:59:09 +02:00
return pack_acs_command(q=queue_helper, op_code=op_code)
2022-05-24 01:49:57 +02:00
if service == CustomServiceList.GPS_CTRL.value:
2022-01-18 14:03:56 +01:00
return pack_gps_command(
2022-07-04 17:59:09 +02:00
object_id=oids.GPS_CONTROLLER, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-11-24 15:56:25 +01:00
if service == CustomServiceList.CCSDS_HANDLER.value:
2023-01-24 19:07:11 +01:00
object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID))
2022-01-18 14:03:56 +01:00
return pack_ccsds_handler_test(
2023-01-24 19:07:11 +01:00
object_id=object_id, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-11-24 15:56:25 +01:00
if service == CustomServiceList.PDEC_HANDLER.value:
2022-01-18 14:03:56 +01:00
return pack_ccsds_handler_test(
2022-07-04 17:59:09 +02:00
object_id=PDEC_HANDLER_ID, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2021-12-02 09:25:31 +01:00
if service == CustomServiceList.SYRLINKS.value:
2022-08-18 11:09:35 +02:00
object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID))
2022-01-18 14:03:56 +01:00
return pack_syrlinks_command(
2022-08-18 11:09:35 +02:00
object_id=object_id, q=queue_helper, op_code=op_code
2022-01-18 14:03:56 +01:00
)
2022-05-18 18:39:18 +02:00
if service == CustomServiceList.PROCEDURE.value:
2022-07-04 17:59:09 +02:00
return pack_proc_commands(q=queue_helper, op_code=op_code)
2022-02-25 19:25:14 +01:00
if service == CustomServiceList.PL_PCDU.value:
2022-07-04 17:59:09 +02:00
return pack_pl_pcdu_commands(q=queue_helper, op_code=op_code)
2022-03-22 19:29:55 +01:00
if service == CustomServiceList.TCS_ASS.value:
2022-07-04 17:59:09 +02:00
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
2022-05-10 18:34:15 +02:00
if service == CustomServiceList.RW_ASSEMBLY.value:
2022-08-08 16:32:18 +02:00
return pack_rw_ass_cmds(q=queue_helper, object_id=RW_ASSEMBLY, op_code=op_code)
if service == CustomServiceList.CONTROLLERS.value:
2022-08-18 14:08:05 +02:00
from tmtcc import TcHandler
tc_handler = cast(TcHandler, tc_base)
return pack_cmd_ctrl_to_prompted_mode(
2022-08-18 14:08:05 +02:00
q=queue_helper,
object_id=get_object_from_op_code(op_code),
gui=tc_handler.gui,
)
2022-06-21 15:21:55 +02:00
if service == CustomServiceList.SCEX.value:
2022-09-27 17:35:58 +02:00
return pack_scex_cmds(
ServiceProviderParams(
handler_base=tc_base,
op_code=op_code,
info=info,
queue_helper=queue_helper,
)
)
2022-08-18 14:08:05 +02:00
if not route_to_registered_service_handlers(
service,
ServiceProviderParams(
handler_base=tc_base,
op_code=op_code,
info=info,
queue_helper=queue_helper,
),
):
2022-08-12 22:33:16 +02:00
LOGGER.warning(f"Invalid Service {service}")