210 lines
9.0 KiB
Python
210 lines
9.0 KiB
Python
"""Hook function which packs telecommands based on service and operation code string
|
|
"""
|
|
import logging
|
|
from typing import cast
|
|
|
|
from eive_tmtc.tmtc.acs.gyros import handle_gyr_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
|
|
from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands
|
|
from tmtccmd import DefaultProcedureInfo, TcHandlerBase
|
|
from tmtccmd.config import CoreServiceList
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
|
from tmtccmd.tc.decorator import (
|
|
route_to_registered_service_handlers,
|
|
ServiceProviderParams,
|
|
)
|
|
|
|
from eive_tmtc.tmtc.misc.s200_test 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
|
|
from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds
|
|
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
|
|
from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_test
|
|
from eive_tmtc.tmtc.core import pack_core_commands
|
|
from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands
|
|
from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command
|
|
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 (
|
|
P60_DOCK_HANDLER,
|
|
PDU_1_HANDLER_ID,
|
|
PDU_2_HANDLER_ID,
|
|
ACU_HANDLER_ID,
|
|
TMP1075_HANDLER_TCS_BRD_0_ID,
|
|
TMP1075_HANDLER_TCS_BRD_1_ID,
|
|
TMP1075_HANDLER_PLPCDU_0_ID,
|
|
TMP1075_HANDLER_IF_BRD_ID,
|
|
HEATER_CONTROLLER_ID,
|
|
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,
|
|
RW_ASSEMBLY,
|
|
get_object_ids,
|
|
)
|
|
|
|
from eive_tmtc.tmtc.tcs.tmp1075 import pack_tmp1075_test_into
|
|
from eive_tmtc.tmtc.acs.gps import pack_gps_command
|
|
from eive_tmtc.tmtc.payload.rad_sensor import pack_rad_sensor_test_into
|
|
from eive_tmtc.tmtc.power.plpcdu import pack_pl_pcdu_commands
|
|
from eive_tmtc.tmtc.acs.str_img_helper import pack_str_img_helper_command
|
|
from eive_tmtc.pus_tc.system.proc import pack_proc_commands
|
|
|
|
import eive_tmtc.config.object_ids as oids
|
|
from tmtccmd.util import ObjectIdU32
|
|
|
|
from eive_tmtc.utility.input_helper import InputHelper
|
|
|
|
|
|
def handle_default_procedure(
|
|
tc_base: TcHandlerBase,
|
|
info: DefaultProcedureInfo,
|
|
queue_helper: DefaultPusQueueHelper,
|
|
):
|
|
service = info.service
|
|
op_code = info.op_code
|
|
obj_id_man = get_object_ids()
|
|
if service == CoreServiceList.SERVICE_200.value:
|
|
return pack_service_200_test_into(q=queue_helper)
|
|
if service == CustomServiceList.P60DOCK.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER))
|
|
return pack_p60dock_cmds(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.RTD.value:
|
|
return pack_rtd_commands(object_id=None, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.PDU1.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(PDU_1_HANDLER_ID))
|
|
return pack_pdu1_commands(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.PDU2.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(PDU_2_HANDLER_ID))
|
|
return pack_pdu2_commands(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.ACU.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID))
|
|
return pack_acu_commands(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.TCS.value:
|
|
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.TMP1075.value:
|
|
menu_dict = {
|
|
"0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID),
|
|
"1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID),
|
|
"2": ("TMP1075 PL PCDU 0", TMP1075_HANDLER_PLPCDU_0_ID),
|
|
"4": ("TMP1075 IF Board", TMP1075_HANDLER_IF_BRD_ID),
|
|
}
|
|
input_helper = InputHelper(menu_dict)
|
|
tmp_select = input_helper.get_key()
|
|
object_id = obj_id_man.get(menu_dict[tmp_select][1])
|
|
return pack_tmp1075_test_into(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.HEATER.value:
|
|
object_id = HEATER_CONTROLLER_ID
|
|
return pack_heater_cmds(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.IMTQ.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(IMTQ_HANDLER_ID))
|
|
return pack_imtq_test_into(object_id=object_id, q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.REACTION_WHEEL_1.value:
|
|
return pack_single_rw_test_into(
|
|
object_id=RW1_ID, rw_idx=1, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.REACTION_WHEEL_2.value:
|
|
return pack_single_rw_test_into(
|
|
object_id=RW2_ID, rw_idx=2, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.REACTION_WHEEL_3.value:
|
|
return pack_single_rw_test_into(
|
|
object_id=RW3_ID, rw_idx=3, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.REACTION_WHEEL_4.value:
|
|
return pack_single_rw_test_into(
|
|
object_id=RW4_ID, rw_idx=4, 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(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.STAR_TRACKER.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(STAR_TRACKER_ID))
|
|
return pack_star_tracker_commands(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.STR_IMG_HELPER.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(STR_IMG_HELPER_ID))
|
|
return pack_str_img_helper_command(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.CORE.value:
|
|
return pack_core_commands(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.PLOC_MEMORY_DUMPER.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(PLOC_MEMORY_DUMPER_ID))
|
|
return pack_ploc_memory_dumper_cmd(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.POWER.value:
|
|
return pack_power_commands(queue_helper, op_code)
|
|
if service == CustomServiceList.ACS.value:
|
|
return pack_acs_command(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.GPS_CTRL.value:
|
|
return pack_gps_command(
|
|
object_id=oids.GPS_CONTROLLER, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.CCSDS_HANDLER.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID))
|
|
return pack_ccsds_handler_test(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.PDEC_HANDLER.value:
|
|
return pack_ccsds_handler_test(
|
|
object_id=PDEC_HANDLER_ID, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.SYRLINKS.value:
|
|
object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID))
|
|
return pack_syrlinks_command(
|
|
object_id=object_id, q=queue_helper, op_code=op_code
|
|
)
|
|
if service == CustomServiceList.GYRO.value:
|
|
return handle_gyr_cmd(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.PROCEDURE.value:
|
|
return pack_proc_commands(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.PL_PCDU.value:
|
|
return pack_pl_pcdu_commands(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.TCS_ASS.value:
|
|
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
|
|
if service == CustomServiceList.RW_ASSEMBLY.value:
|
|
return pack_rw_ass_cmds(q=queue_helper, object_id=RW_ASSEMBLY, op_code=op_code)
|
|
if service == CustomServiceList.SCEX.value:
|
|
return pack_scex_cmds(
|
|
ServiceProviderParams(
|
|
handler_base=tc_base,
|
|
op_code=op_code,
|
|
info=info,
|
|
queue_helper=queue_helper,
|
|
)
|
|
)
|
|
if not route_to_registered_service_handlers(
|
|
service,
|
|
ServiceProviderParams(
|
|
handler_base=tc_base,
|
|
op_code=op_code,
|
|
info=info,
|
|
queue_helper=queue_helper,
|
|
),
|
|
):
|
|
logging.getLogger(__name__).warning(f"Invalid Service {service}")
|