eive-obsw/mission/core/GenericFactory.cpp

175 lines
7.4 KiB
C++
Raw Normal View History

2020-11-20 18:10:39 +01:00
#include "GenericFactory.h"
2020-12-29 13:59:31 +01:00
2022-09-16 18:10:23 +02:00
#include <fsfw/cfdp/CfdpDistributor.h>
2022-09-16 12:14:27 +02:00
#include <fsfw/cfdp/handler/CfdpHandler.h>
2022-09-16 17:28:43 +02:00
#include <fsfw/cfdp/handler/RemoteConfigTableIF.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
2021-07-15 01:25:32 +02:00
#include <fsfw/internalerror/InternalErrorReporter.h>
2022-09-16 17:28:43 +02:00
#include <fsfw/ipc/QueueFactory.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/pus/CService200ModeCommanding.h>
2022-05-12 19:22:20 +02:00
#include <fsfw/pus/CService201HealthCommanding.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/pus/Service17Test.h>
#include <fsfw/pus/Service1TelecommandVerification.h>
2021-03-04 18:29:28 +01:00
#include <fsfw/pus/Service20ParameterManagement.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/pus/Service2DeviceAccess.h>
2022-01-17 15:58:27 +01:00
#include <fsfw/pus/Service3Housekeeping.h>
2020-11-20 18:10:39 +01:00
#include <fsfw/pus/Service5EventReporting.h>
#include <fsfw/pus/Service8FunctionManagement.h>
#include <fsfw/pus/Service9TimeManagement.h>
#include <fsfw/storagemanager/PoolManager.h>
2022-09-16 11:43:11 +02:00
#include <fsfw/tcdistribution/CcsdsDistributor.h>
2022-08-15 11:57:57 +02:00
#include <fsfw/tcdistribution/PusDistributor.h>
#include <fsfw/timemanager/CdsShortTimeStamper.h>
2022-09-16 12:14:27 +02:00
#include <fsfw_hal/host/HostFilesystem.h>
#include <mission/tmtc/TmFunnel.h>
2022-01-17 15:58:27 +01:00
2022-03-25 18:39:21 +01:00
#include "OBSWConfig.h"
2022-03-26 13:54:05 +01:00
#include "eive/definitions.h"
2022-05-26 11:46:28 +02:00
#include "fsfw/pus/Service11TelecommandScheduling.h"
2022-09-16 18:10:23 +02:00
#include "mission/cfdp/Config.h"
2022-01-17 15:58:27 +01:00
#include "objects/systemObjectList.h"
2022-03-25 18:39:21 +01:00
#include "tmtc/pusIds.h"
2020-11-20 18:10:39 +01:00
2021-09-28 14:58:12 +02:00
#if OBSW_ADD_TCPIP_BRIDGE == 1
2022-03-08 09:37:23 +01:00
#if OBSW_USE_TMTC_TCP_BRIDGE == 0
2021-09-28 14:58:12 +02:00
// UDP server includes
#include "fsfw/osal/common/UdpTcPollingTask.h"
2022-01-17 15:58:27 +01:00
#include "fsfw/osal/common/UdpTmTcBridge.h"
2021-09-28 14:58:12 +02:00
#else
// TCP server includes
#include "fsfw/osal/common/TcpTmTcBridge.h"
#include "fsfw/osal/common/TcpTmTcServer.h"
#endif
#endif
2020-12-29 13:59:31 +01:00
#if OBSW_ADD_TEST_CODE == 1
2021-09-28 14:58:12 +02:00
#include <test/testtasks/TestTask.h>
2020-11-25 16:17:16 +01:00
#endif
2020-11-20 18:10:39 +01:00
2022-03-26 14:08:34 +01:00
#ifndef OBSW_TM_TO_PTME
#define OBSW_TM_TO_PTME 0
#endif
2022-09-16 17:28:43 +02:00
namespace cfdp {
PacketInfoList<64> PACKET_LIST;
LostSegmentsList<128> LOST_SEGMENTS;
EntityId REMOTE_CFDP_ID(UnsignedByteField<uint16_t>(config::EIVE_GROUND_CFDP_ENTITY_ID));
RemoteEntityCfg GROUND_REMOTE_CFG(REMOTE_CFDP_ID);
OneRemoteConfigProvider REMOTE_CFG_PROVIDER(GROUND_REMOTE_CFG);
HostFilesystem HOST_FS;
EiveUserHandler USER_HANDLER(HOST_FS);
EiveFaultHandler EIVE_FAULT_HANDLER;
2022-09-16 18:10:23 +02:00
} // namespace cfdp
2022-09-16 17:28:43 +02:00
2022-05-02 17:37:00 +02:00
void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) {
2022-01-17 15:58:27 +01:00
// Framework objects
new EventManager(objects::EVENT_MANAGER);
2022-05-02 17:37:00 +02:00
auto healthTable = new HealthTable(objects::HEALTH_TABLE);
2022-05-17 13:35:21 +02:00
if (healthTable_ != nullptr) {
2022-05-02 17:37:00 +02:00
*healthTable_ = healthTable;
}
2022-01-17 15:58:27 +01:00
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
2022-08-16 17:09:46 +02:00
new VerificationReporter();
2022-08-15 11:57:57 +02:00
auto* timeStamper = new CdsShortTimeStamper(objects::TIME_STAMPER);
2022-09-16 12:14:27 +02:00
StorageManagerIF* tcStore;
StorageManagerIF* tmStore;
2022-01-17 15:58:27 +01:00
{
2022-09-16 18:16:52 +02:00
PoolManager::LocalPoolConfig poolCfg = {{200, 16}, {200, 32}, {150, 64},
{100, 128}, {100, 1024}, {100, 2048}};
2022-09-16 12:14:27 +02:00
tcStore = new PoolManager(objects::TC_STORE, poolCfg);
2022-01-17 15:58:27 +01:00
}
{
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64},
2022-09-16 18:16:52 +02:00
{100, 128}, {100, 1024}, {100, 2048}};
2022-09-16 12:14:27 +02:00
tmStore = new PoolManager(objects::TM_STORE, poolCfg);
2022-01-17 15:58:27 +01:00
}
{
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128},
{100, 256}, {50, 512}, {50, 1024}, {10, 2048}};
new PoolManager(objects::IPC_STORE, poolCfg);
}
2022-09-16 12:28:39 +02:00
auto* ccsdsDistrib =
new CcsdsDistributor(config::EIVE_PUS_APID, objects::CCSDS_PACKET_DISTRIBUTOR);
2022-09-16 12:22:46 +02:00
new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib);
2022-01-17 15:58:27 +01:00
2022-03-26 14:08:34 +01:00
uint8_t vc = 0;
#if OBSW_TM_TO_PTME == 1
vc = config::LIVE_TM;
#endif
2022-01-17 15:58:27 +01:00
// Every TM packet goes through this funnel
2022-09-16 12:14:27 +02:00
auto* funnel = new TmFunnel(objects::TM_FUNNEL, *timeStamper, 50, vc);
2022-01-17 15:58:27 +01:00
// PUS service stack
2022-09-16 12:22:46 +02:00
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, config::EIVE_PUS_APID,
2022-01-17 15:58:27 +01:00
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20);
2022-09-16 12:22:46 +02:00
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, config::EIVE_PUS_APID,
2022-01-17 15:58:27 +01:00
pus::PUS_SERVICE_2, 3, 10);
2022-09-16 12:22:46 +02:00
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, config::EIVE_PUS_APID,
2022-01-17 15:58:27 +01:00
pus::PUS_SERVICE_3);
new Service5EventReporting(
2022-09-16 12:28:39 +02:00
PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, config::EIVE_PUS_APID, pus::PUS_SERVICE_5),
15, 45);
2022-09-16 12:22:46 +02:00
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, config::EIVE_PUS_APID,
pus::PUS_SERVICE_8, 16, 60);
new Service9TimeManagement(
2022-09-16 12:22:46 +02:00
PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, config::EIVE_PUS_APID, pus::PUS_SERVICE_9));
2022-05-24 15:21:37 +02:00
2022-05-26 11:46:28 +02:00
new Service11TelecommandScheduling<common::OBSW_MAX_SCHEDULED_TCS>(
2022-09-16 12:22:46 +02:00
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, config::EIVE_PUS_APID, pus::PUS_SERVICE_11),
ccsdsDistrib);
2022-09-16 12:28:39 +02:00
new Service17Test(
PsbParams(objects::PUS_SERVICE_17_TEST, config::EIVE_PUS_APID, pus::PUS_SERVICE_17));
2022-09-16 12:22:46 +02:00
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, config::EIVE_PUS_APID,
2022-01-17 15:58:27 +01:00
pus::PUS_SERVICE_20);
2022-09-16 12:22:46 +02:00
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, config::EIVE_PUS_APID,
2022-05-12 19:22:20 +02:00
pus::PUS_SERVICE_200, 8);
2022-09-16 12:22:46 +02:00
new CService201HealthCommanding(objects::PUS_SERVICE_201_HEALTH, config::EIVE_PUS_APID,
2022-05-12 19:22:20 +02:00
pus::PUS_SERVICE_201);
2021-09-28 14:58:12 +02:00
#if OBSW_ADD_TCPIP_BRIDGE == 1
2022-03-08 09:37:23 +01:00
#if OBSW_USE_TMTC_TCP_BRIDGE == 0
2022-01-17 15:58:27 +01:00
auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
sif::info << "Created UDP server for TMTC commanding with listener port "
<< udpBridge->getUdpPort() << std::endl;
2021-09-28 14:58:12 +02:00
#else
2022-01-17 15:58:27 +01:00
auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE);
// TCP is stream based. Use packet ID as start marker when parsing for space packets
2022-09-16 18:10:23 +02:00
tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID, common::CFDP_PACKET_ID});
2022-01-17 15:58:27 +01:00
sif::info << "Created TCP server for TMTC commanding with listener port "
2021-09-28 14:58:12 +02:00
<< tcpServer->getTcpPort() << std::endl;
2022-04-26 10:37:25 +02:00
#if OBSW_TCP_SERVER_WIRETAPPING == 1
2022-03-27 13:07:18 +02:00
tcpServer->enableWiretapping(true);
2022-04-26 10:37:25 +02:00
#endif /* OBSW_TCP_SERVER_WIRETAPPING == 1 */
2021-09-28 14:58:12 +02:00
#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */
2022-05-25 13:14:36 +02:00
tmtcBridge->setMaxNumberOfPacketsStored(300);
2021-09-28 14:58:12 +02:00
#endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */
2022-09-16 12:14:27 +02:00
#if OBSW_ADD_CFDP_COMPONENTS == 1
2022-09-16 17:28:43 +02:00
using namespace cfdp;
2022-09-16 18:10:23 +02:00
MessageQueueIF* cfdpMsgQueue = QueueFactory::instance()->createMessageQueue(32);
CfdpDistribCfg distribCfg(objects::CFDP_DISTRIBUTOR, *tcStore, cfdpMsgQueue);
new CfdpDistributor(distribCfg);
2022-09-16 17:28:43 +02:00
auto* msgQueue = QueueFactory::instance()->createMessageQueue(32);
FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, *funnel, *tcStore, *tmStore, *msgQueue);
2022-09-16 12:22:46 +02:00
cfdp::IndicationCfg indicationCfg;
2022-09-16 17:28:43 +02:00
UnsignedByteField<uint16_t> apid(config::EIVE_LOCAL_CFDP_ENTITY_ID);
cfdp::EntityId localId(apid);
GROUND_REMOTE_CFG.defaultChecksum = cfdp::ChecksumType::CRC_32;
2022-09-16 18:10:23 +02:00
CfdpHandlerCfg cfdpCfg(localId, indicationCfg, USER_HANDLER, EIVE_FAULT_HANDLER, PACKET_LIST,
LOST_SEGMENTS, REMOTE_CFG_PROVIDER);
auto* cfdpHandler = new CfdpHandler(params, cfdpCfg);
2022-09-16 17:28:43 +02:00
// All CFDP packets arrive wrapped inside CCSDS space packets
CcsdsDistributorIF::DestInfo info("CFDP Destination", config::EIVE_CFDP_APID,
cfdpHandler->getRequestQueue(), true);
ccsdsDistrib->registerApplication(info);
2022-09-16 12:14:27 +02:00
#endif
2020-11-20 18:10:39 +01:00
}