refactored a lot

This commit is contained in:
Robin Müller 2021-06-18 16:28:53 +02:00
parent 600046a54f
commit a3941d7f3b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 39 additions and 18 deletions

View File

@ -0,0 +1 @@
PUS_APID = 0xef

View File

@ -11,6 +11,8 @@ from tmtccmd.pus_tm.service_3_base import Service3Base
from tmtccmd.ecss.conf import PusVersion
from tmtccmd.utility.tmtc_printer import TmTcPrinter
from config.definitions import PUS_APID
class FsfwHookBase(TmTcHookBase):
@ -28,7 +30,7 @@ class FsfwHookBase(TmTcHookBase):
def add_globals_pre_args_parsing(self, gui: bool = False):
from tmtccmd.config.globals import set_default_globals_pre_args_parsing
set_default_globals_pre_args_parsing(
gui=gui, pus_tm_version=PusVersion.PUS_C, pus_tc_version=PusVersion.PUS_C, apid=0xef
gui=gui, pus_tm_version=PusVersion.PUS_C, pus_tc_version=PusVersion.PUS_C, apid=PUS_APID
)
def add_globals_post_args_parsing(self, args: argparse.Namespace):
@ -50,10 +52,6 @@ class FsfwHookBase(TmTcHookBase):
from pus_tc.tc_packing import pack_service_queue_user
pack_service_queue_user(service=service, op_code=op_code, service_queue=service_queue)
def tm_user_factory_hook(self, raw_tm_packet: bytearray) -> Optional[PusTelemetry]:
from pus_tm.factory_hook import tm_user_factory_hook
return tm_user_factory_hook(raw_tm_packet=raw_tm_packet)
def get_object_ids(self) -> Dict[bytes, list]:
from config.object_ids import get_object_ids
return get_object_ids()

View File

@ -14,27 +14,39 @@ from tmtccmd.pus_tm.service_8_functional_cmd import Service8TM
from tmtccmd.pus_tm.service_17_test import Service17TM
from tmtccmd.pus_tm.service_20_parameters import Service20TM
from tmtccmd.pus_tm.service_200_mode import Service200TM
from tmtccmd.utility.tmtc_printer import TmTcPrinter
from config.definitions import PUS_APID
LOGGER = get_logger()
def tm_user_factory_hook(raw_tm_packet: bytearray) -> PusTelemetry:
def ccsds_tm_handler(apid: int, raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter) -> None:
if apid == PUS_APID:
pus_packet_factory(raw_tm_packet=raw_tm_packet, tmtc_printer=tmtc_printer)
def pus_packet_factory(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter):
service_type = raw_tm_packet[7]
tm_packet = None
if service_type == 1:
return Service1TM(raw_tm_packet)
tm_packet = Service1TM(raw_tm_packet)
if service_type == 2:
return Service2TM(raw_tm_packet)
tm_packet = Service2TM(raw_tm_packet)
if service_type == 3:
return Service3TM(raw_tm_packet)
tm_packet = Service3TM(raw_tm_packet)
if service_type == 8:
return Service8TM(raw_tm_packet)
tm_packet = Service8TM(raw_tm_packet)
if service_type == 5:
return Service5TM(raw_tm_packet)
tm_packet = Service5TM(raw_tm_packet)
if service_type == 17:
return Service17TM(raw_tm_packet)
tm_packet = Service17TM(raw_tm_packet)
if service_type == 20:
return Service20TM(raw_tm_packet)
tm_packet = Service20TM(raw_tm_packet)
if service_type == 200:
return Service200TM(raw_tm_packet)
LOGGER.info("The service " + str(service_type) + " is not implemented in Telemetry Factory")
return PusTelemetry(raw_tm_packet)
tm_packet = Service200TM(raw_tm_packet)
if tm_packet is None:
LOGGER.info("The service " + str(service_type) + " is not implemented in Telemetry Factory")
tm_packet = PusTelemetry(raw_tm_packet)
tmtc_printer.print_telemetry(packet=tm_packet)

View File

@ -27,9 +27,16 @@ limitations under the License.
@author R. Mueller
"""
import sys
from tmtccmd.config.definitions import CoreGlobalIds
from tmtccmd.core.globals_manager import get_global
from config.hook_implementation import FsfwHookBase
from config.definitions import PUS_APID
from pus_tm.factory_hook import ccsds_tm_handler
try:
from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander
from tmtccmd.runner import run_tmtc_commander, initialize_tmtc_commander, add_ccsds_handler
from tmtccmd.ccsds.handler import CcsdsTmHandler
except ImportError as error:
run_tmtc_commander = None
initialize_tmtc_commander = None
@ -42,6 +49,9 @@ except ImportError as error:
def main():
hook_obj = FsfwHookBase()
initialize_tmtc_commander(hook_object=hook_obj)
ccsds_handler = CcsdsTmHandler(tmtc_printer=None)
ccsds_handler.add_tm_handler(apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50)
add_ccsds_handler(ccsds_handler)
run_tmtc_commander(use_gui=False, app_name="TMTC Commander FSFW")

@ -1 +1 @@
Subproject commit 9415eac9eeb17dffed31f3a7a1ef849902eeb5c1
Subproject commit 2bc1ad63657ba0f34b52f95acbbc8063030a6e64