fsfw-example-hosted/bsp_hosted/core/ObjectFactory.cpp

81 lines
3.0 KiB
C++
Raw Normal View History

2021-06-08 13:36:08 +02:00
#include "ObjectFactory.h"
2022-05-05 20:55:48 +02:00
2022-09-08 16:26:47 +02:00
#include "CfdpHandler.h"
2022-05-05 20:55:48 +02:00
#include "OBSWConfig.h"
2022-05-20 08:59:25 +02:00
#include "bsp_hosted/fsfwconfig/objects/systemObjectList.h"
#include "commonConfig.h"
2022-05-05 20:55:48 +02:00
#include "example/core/GenericFactory.h"
#include "example/test/FsfwTestTask.h"
#include "example/utility/TmFunnel.h"
2022-05-20 08:59:25 +02:00
#include "fsfw/storagemanager/PoolManager.h"
#include "fsfw/tmtcservices/CommandingServiceBase.h"
2022-09-08 16:26:47 +02:00
#include "fsfw_hal/host/HostFilesystem.h"
2022-05-05 20:55:48 +02:00
#if OBSW_USE_TCP_SERVER == 0
2021-06-08 13:36:08 +02:00
#include <fsfw/osal/common/UdpTcPollingTask.h>
#include <fsfw/osal/common/UdpTmTcBridge.h>
#else
#include "fsfw/osal/common/TcpTmTcBridge.h"
2022-05-05 20:55:48 +02:00
#include "fsfw/osal/common/TcpTmTcServer.h"
#endif
2021-06-08 13:36:08 +02:00
void ObjectFactory::produce(void* args) {
2022-05-05 20:55:48 +02:00
Factory::setStaticFrameworkObjectIds();
2022-09-08 16:26:47 +02:00
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
2021-06-08 13:36:08 +02:00
#if OBSW_ADD_CORE_COMPONENTS == 1
2022-05-05 20:55:48 +02:00
{
2022-05-20 08:59:25 +02:00
LocalPool::LocalPoolConfig poolCfg = {{16, 100}, {32, 50}, {64, 40},
{128, 30}, {1024, 20}, {2048, 10}};
2022-09-08 16:26:47 +02:00
tcStore = new PoolManager(objects::TC_STORE, poolCfg);
2022-05-05 20:55:48 +02:00
}
2021-06-08 13:36:08 +02:00
2022-05-05 20:55:48 +02:00
{
2022-05-20 08:59:25 +02:00
LocalPool::LocalPoolConfig poolCfg = {{16, 100}, {32, 50}, {64, 40},
{128, 30}, {1024, 20}, {2048, 10}};
2022-09-08 16:26:47 +02:00
tmStore = new PoolManager(objects::TM_STORE, poolCfg);
2022-05-05 20:55:48 +02:00
}
2021-06-08 13:36:08 +02:00
2022-05-05 20:55:48 +02:00
{
2022-05-20 08:59:25 +02:00
LocalPool::LocalPoolConfig poolCfg = {{16, 100}, {32, 50}, {64, 40},
{128, 30}, {1024, 20}, {2048, 10}};
2022-05-05 20:55:48 +02:00
new PoolManager(objects::IPC_STORE, poolCfg);
}
2022-09-08 16:26:47 +02:00
TmFunnel* funnel;
2022-09-08 17:39:59 +02:00
ObjectFactory::produceGenericObjects(&funnel, *tcStore);
2022-05-05 20:55:48 +02:00
// TMTC Reception via TCP/IP socket
#if OBSW_USE_TCP_SERVER == 0
auto tmtcBridge = new UdpTmTcBridge(objects::TCPIP_TMTC_BRIDGE, objects::CCSDS_DISTRIBUTOR);
tmtcBridge->setMaxNumberOfPacketsStored(50);
sif::info << "Opening UDP TMTC server on port " << tmtcBridge->getUdpPort() << std::endl;
new UdpTcPollingTask(objects::TCPIP_TMTC_POLLING_TASK, objects::TCPIP_TMTC_BRIDGE);
#else
2022-05-05 20:55:48 +02:00
auto tmtcBridge = new TcpTmTcBridge(objects::TCPIP_TMTC_BRIDGE, objects::CCSDS_DISTRIBUTOR);
tmtcBridge->setMaxNumberOfPacketsStored(50);
auto tmtcServer = new TcpTmTcServer(objects::TCPIP_TMTC_POLLING_TASK, objects::TCPIP_TMTC_BRIDGE);
sif::info << "Opening TCP TMTC server on port " << tmtcServer->getTcpPort() << std::endl;
#endif
2021-06-08 13:36:08 +02:00
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
2022-05-05 20:55:48 +02:00
bool periodicEvent = false;
2021-06-30 10:00:20 +02:00
#if OBSW_TASK_PERIODIC_EVENT == 1
2022-05-05 20:55:48 +02:00
periodicEvent = true;
2021-06-30 10:00:20 +02:00
#endif
2022-05-05 20:55:48 +02:00
new FsfwTestTask(objects::TEST_TASK, periodicEvent);
2022-09-08 17:39:59 +02:00
#if OBSW_ADD_CFDP_COMPONENTS == 1
2022-09-08 16:26:47 +02:00
auto* hostFs = new HostFilesystem();
FsfwHandlerParams params(objects::CFDP_HANDLER, *hostFs, *funnel, *tcStore, *tmStore);
cfdp::IndicationCfg indicationCfg;
UnsignedByteField<uint16_t> apid(COMMON_APID);
cfdp::EntityId localId(apid);
2022-09-08 17:39:59 +02:00
cfdp::RemoteEntityCfg remoteCfg;
cfdp::OneRemoteConfigProvider remoteCfgProvider(remoteCfg);
cfdp::PacketInfoList<64> packetList;
cfdp::LostSegmentsList<128> lostSegments;
CfdpHandlerCfg cfg(localId, indicationCfg, packetList, lostSegments, remoteCfgProvider);
new CfdpHandler(params, cfg);
#endif
2021-06-08 13:36:08 +02:00
}