eive-obsw/bsp_hosted/objectFactory.cpp

122 lines
4.6 KiB
C++
Raw Normal View History

2023-09-06 13:40:38 +02:00
#include "objectFactory.h"
2020-11-20 18:10:39 +01:00
2022-11-24 11:22:55 +01:00
#include <fsfw/power/DummyPowerSwitcher.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h>
2022-06-17 08:31:36 +02:00
#include <mission/controller/ThermalController.h>
2023-03-26 16:58:05 +02:00
#include <mission/genericFactory.h>
2022-11-02 14:03:54 +01:00
#include <mission/tmtc/TmFunnelHandler.h>
2022-01-17 15:58:27 +01:00
#include <objects/systemObjectList.h>
2022-12-14 09:53:38 +01:00
#include "../mission/utility/DummySdCardManager.h"
2022-01-17 15:58:27 +01:00
#include "OBSWConfig.h"
#include "fsfw/platform.h"
2023-02-22 21:46:56 +01:00
#include "fsfw/power/PowerSwitchIF.h"
2022-05-05 16:55:08 +02:00
#include "fsfw_tests/integration/task/TestTask.h"
2020-11-20 18:10:39 +01:00
2022-12-02 16:47:28 +01:00
#if OBSW_ADD_TMTC_UDP_SERVER == 1
2021-07-26 13:51:00 +02:00
#include "fsfw/osal/common/UdpTcPollingTask.h"
#include "fsfw/osal/common/UdpTmTcBridge.h"
2022-12-02 16:47:28 +01:00
#endif
#if OBSW_ADD_TMTC_TCP_SERVER == 1
2021-07-26 13:51:00 +02:00
#include "fsfw/osal/common/TcpTmTcBridge.h"
#include "fsfw/osal/common/TcpTmTcServer.h"
#endif
2020-11-20 18:10:39 +01:00
#if OBSW_ADD_TEST_CODE == 1
#include <test/testtasks/TestTask.h>
#endif
#include <dummies/AcuDummy.h>
2022-06-17 08:31:36 +02:00
#include <dummies/CoreControllerDummy.h>
2022-10-10 17:40:30 +02:00
2023-03-31 13:21:38 +02:00
#include "dummies/helperFactory.h"
2022-07-14 17:35:49 +02:00
#ifdef PLATFORM_UNIX
#include <fsfw_hal/linux/serial/SerialComIF.h>
#include <fsfw_hal/linux/serial/SerialCookie.h>
#include "devices/gpioIds.h"
#include "fsfw_hal/linux/gpio/Gpio.h"
2023-03-26 16:58:05 +02:00
#include "linux/payload/PlocMpsocHandler.h"
2023-05-15 16:49:16 +02:00
#include "linux/payload/PlocMpsocSpecialComHelper.h"
2023-03-26 16:58:05 +02:00
#include "linux/payload/PlocSupervisorHandler.h"
#include "linux/payload/PlocSupvUartMan.h"
#include "test/gpio/DummyGpioIF.h"
#endif
2022-01-17 15:58:27 +01:00
void Factory::setStaticFrameworkObjectIds() {
2022-08-16 17:09:46 +02:00
PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_PACKET_DISTRIBUTOR;
2022-11-15 16:44:07 +01:00
PusServiceBase::PACKET_DESTINATION = objects::PUS_TM_FUNNEL;
2020-11-20 18:10:39 +01:00
2022-01-17 15:58:27 +01:00
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
2022-11-15 16:44:07 +01:00
CommandingServiceBase::defaultPacketDestination = objects::PUS_TM_FUNNEL;
2020-11-20 18:10:39 +01:00
2022-08-16 17:09:46 +02:00
VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
2020-11-20 18:10:39 +01:00
}
2022-01-17 15:58:27 +01:00
void ObjectFactory::produce(void* args) {
Factory::setStaticFrameworkObjectIds();
2022-11-02 14:03:54 +01:00
PusTmFunnel* pusFunnel;
CfdpTmFunnel* cfdpFunnel;
2023-03-09 20:38:50 +01:00
StorageManagerIF* tmStore;
StorageManagerIF* ipcStore;
2023-09-06 13:40:38 +02:00
PersistentTmStores persistentStores{};
2023-05-24 11:53:07 +02:00
bool enableHkSets = false;
#if OBSW_ENABLE_PERIODIC_HK == 1
enableHkSets = true;
#endif
2022-12-14 09:53:38 +01:00
auto sdcMan = new DummySdCardManager("/tmp");
2023-03-09 20:38:50 +01:00
ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel, *sdcMan, &ipcStore,
2023-09-06 13:40:38 +02:00
&tmStore, persistentStores, 120, enableHkSets, false);
2020-11-20 18:10:39 +01:00
new TmFunnelHandler(objects::LIVE_TM_TASK, *pusFunnel, *cfdpFunnel);
2022-11-24 19:41:57 +01:00
auto* dummyGpioIF = new DummyGpioIF();
2022-11-24 11:22:55 +01:00
auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
2023-02-22 19:14:35 +01:00
std::vector<ReturnValue_t> switcherList;
auto initVal = PowerSwitchIF::SWITCH_OFF;
for (unsigned i = 0; i < 18; i++) {
switcherList.emplace_back(initVal);
}
dummySwitcher->setInitialSwitcherList(switcherList);
#ifdef PLATFORM_UNIX
new SerialComIF(objects::UART_COM_IF);
#if OBSW_ADD_PLOC_MPSOC == 1
std::string mpscoDev = "";
auto mpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, mpscoDev, uart::PLOC_MPSOC_BAUD,
mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL);
mpsocCookie->setNoFixedSizeReply();
2023-05-15 16:49:16 +02:00
auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER);
new PlocMpsocHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie,
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, dummyGpioIF),
objects::PLOC_SUPERVISOR_HANDLER);
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
2022-11-15 16:00:32 +01:00
std::string plocSupvString = "/dev/ploc_supv";
auto supervisorCookie =
2022-11-15 17:40:19 +01:00
new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, plocSupvString, uart::PLOC_SUPV_BAUD,
supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL);
supervisorCookie->setNoFixedSizeReply();
2022-11-15 17:24:38 +01:00
auto supvHelper = new PlocSupvUartManager(objects::PLOC_SUPERVISOR_HELPER);
2022-11-16 15:25:29 +01:00
new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, supervisorCookie,
Gpio(gpioIds::ENABLE_SUPV_UART, dummyGpioIF), pcdu::PDU1_CH6_PLOC_12V,
*supvHelper);
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
#endif
dummy::DummyCfg cfg;
2023-08-16 13:35:09 +02:00
cfg.addPlPcduDummy = true;
cfg.addCamSwitcherDummy = true;
2023-05-24 11:53:07 +02:00
dummy::createDummies(cfg, *dummySwitcher, dummyGpioIF, enableHkSets);
2022-11-24 19:41:57 +01:00
HeaterHandler* heaterHandler = nullptr;
2022-11-25 10:13:24 +01:00
// new ThermalController(objects::THERMAL_CONTROLLER);
2022-11-24 19:41:57 +01:00
ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler);
2022-11-25 10:13:24 +01:00
if (heaterHandler == nullptr) {
2022-11-24 19:41:57 +01:00
sif::error << "HeaterHandler could not be created" << std::endl;
2022-11-25 10:13:24 +01:00
} else {
2023-07-03 17:32:35 +02:00
ObjectFactory::createThermalController(*heaterHandler, true);
2022-11-24 19:41:57 +01:00
}
2022-01-17 15:58:27 +01:00
new TestTask(objects::TEST_TASK);
2020-11-20 18:10:39 +01:00
}