From 24de9510381694f4d829aa5af99e51e01ff021a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Sep 2023 14:27:14 +0200 Subject: [PATCH] reduce duplicate code --- bsp_q7s/em/emObjectFactory.cpp | 9 +-------- bsp_q7s/fmObjectFactory.cpp | 13 +------------ bsp_q7s/objectFactory.cpp | 15 +++++++++++++++ bsp_q7s/objectFactory.h | 1 + mission/sysDefs.h | 4 ++-- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 97ed4c0a..223d27dc 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -162,15 +162,8 @@ void ObjectFactory::produce(void* args) { CcsdsComponentArgs ccsdsArgs(*gpioComIF, *ipcStore, *tmStore, stores, *pusFunnel, *cfdpFunnel, &ipCoreHandler); createCcsdsComponents(ccsdsArgs); -#if OBSW_TM_TO_PTME == 1 - if (ccsdsArgs.normalLiveTmDest != MessageQueueIF::NO_QUEUE) { - pusFunnel->addLiveDestinationByRawId("VC0 NORMAL LIVE TM", ccsdsArgs.normalLiveTmDest, 0); - } - if (ccsdsArgs.cfdpLiveTmDest != MessageQueueIF::NO_QUEUE) { - cfdpFunnel->addLiveDestinationByRawId("VC0 CFDP LIVE TM", ccsdsArgs.cfdpLiveTmDest, 0); - } -#endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ + /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 createTestComponents(gpioComIF); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index bff510d7..68589752 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -108,18 +108,7 @@ void ObjectFactory::produce(void* args) { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #if OBSW_ADD_CCSDS_IP_CORES == 1 - CcsdsIpCoreHandler* ipCoreHandler = nullptr; - CcsdsComponentArgs ccsdsArgs(*gpioComIF, *ipcStore, *tmStore, stores, *pusFunnel, *cfdpFunnel, - &ipCoreHandler); - createCcsdsComponents(ccsdsArgs); -#if OBSW_TM_TO_PTME == 1 - if (ccsdsArgs.normalLiveTmDest != MessageQueueIF::NO_QUEUE) { - pusFunnel->addLiveDestinationByRawId("VC0 NORMAL LIVE TM", ccsdsArgs.normalLiveTmDest, 0); - } - if (ccsdsArgs.cfdpLiveTmDest != MessageQueueIF::NO_QUEUE) { - cfdpFunnel->addLiveDestinationByRawId("VC0 CFDP LIVE TM", ccsdsArgs.cfdpLiveTmDest, 0); - } -#endif + createCcsdsIpCoreComponents(); #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ #if OBSW_ADD_SCEX_DEVICE == 1 diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index 2522a7c0..f54e8dce 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -1057,3 +1057,18 @@ ReturnValue_t ObjectFactory::readFirmwareVersion() { } return returnvalue::OK; } + +ReturnValue_t ObjectFactory::readCcsdsIpCoreComponents(CcsdsComponentArgs& ccsdsArgs) { + CcsdsIpCoreHandler* ipCoreHandler = nullptr; + ReturnValue_t result = createCcsdsComponents(ccsdsArgs); +#if OBSW_TM_TO_PTME == 1 + if (ccsdsArgs.normalLiveTmDest != MessageQueueIF::NO_QUEUE) { + ccsdsArgs.pusFunnel.addLiveDestinationByRawId("VC0 NORMAL LIVE TM", ccsdsArgs.normalLiveTmDest, + 0); + } + if (ccsdsArgs.cfdpLiveTmDest != MessageQueueIF::NO_QUEUE) { + ccsdsArgs.cfdpFunnel.addLiveDestinationByRawId("VC0 CFDP LIVE TM", ccsdsArgs.cfdpLiveTmDest, 0); + } +#endif + return result; +} diff --git a/bsp_q7s/objectFactory.h b/bsp_q7s/objectFactory.h index bccbdd17..60a2ff6d 100644 --- a/bsp_q7s/objectFactory.h +++ b/bsp_q7s/objectFactory.h @@ -83,6 +83,7 @@ void createTestComponents(LinuxLibgpioIF* gpioComIF); void createPlI2cResetGpio(LinuxLibgpioIF* gpioComIF); void testAcsBrdAss(AcsBoardAssembly* assAss); +ReturnValue_t readCcsdsIpCoreComponents(CcsdsComponentArgs& args); }; // namespace ObjectFactory diff --git a/mission/sysDefs.h b/mission/sysDefs.h index e1259c5c..b7cbd4e0 100644 --- a/mission/sysDefs.h +++ b/mission/sysDefs.h @@ -1,8 +1,6 @@ #ifndef MISSION_SYSDEFS_H_ #define MISSION_SYSDEFS_H_ -#include "eive/eventSubsystemIds.h" - #include #include #include @@ -11,6 +9,8 @@ #include #include +#include "eive/eventSubsystemIds.h" + namespace signals { extern std::atomic_bool CFDP_CHANNEL_THROTTLE_SIGNAL;