fsfw-example-common/example/core/GenericFactory.cpp

161 lines
6.9 KiB
C++
Raw Normal View History

2021-06-08 13:29:49 +02:00
#include "GenericFactory.h"
#include "OBSWConfig.h"
2022-05-20 08:42:41 +02:00
#include "common/definitions.h"
2021-10-17 23:21:38 +02:00
#include "example/test/FsfwExampleTask.h"
#include "example/test/FsfwReaderTask.h"
2022-05-05 20:55:28 +02:00
#include "example/utility/TmFunnel.h"
#include "fsfw/FSFW.h"
2022-09-08 17:39:16 +02:00
#include "fsfw/cfdp/CfdpDistributor.h"
2021-06-08 13:29:49 +02:00
#include "fsfw/devicehandlers/CookieIF.h"
#include "fsfw/events/EventManager.h"
#include "fsfw/health/HealthTable.h"
2021-07-14 00:54:06 +02:00
#include "fsfw/internalerror/InternalErrorReporter.h"
2022-09-08 17:39:16 +02:00
#include "fsfw/ipc/QueueFactory.h"
2021-06-08 13:29:49 +02:00
#include "fsfw/pus/CService200ModeCommanding.h"
2022-05-20 08:36:12 +02:00
#include "fsfw/pus/Service11TelecommandScheduling.h"
2021-06-08 13:29:49 +02:00
#include "fsfw/pus/Service17Test.h"
#include "fsfw/pus/Service1TelecommandVerification.h"
#include "fsfw/pus/Service20ParameterManagement.h"
#include "fsfw/pus/Service2DeviceAccess.h"
#include "fsfw/pus/Service3Housekeeping.h"
#include "fsfw/pus/Service5EventReporting.h"
#include "fsfw/pus/Service8FunctionManagement.h"
#include "fsfw/pus/Service9TimeManagement.h"
2022-08-01 11:11:30 +02:00
#include "fsfw/tcdistribution/CcsdsDistributor.h"
2022-07-27 11:33:40 +02:00
#include "fsfw/tcdistribution/PusDistributor.h"
2022-07-25 10:18:38 +02:00
#include "fsfw/timemanager/CdsShortTimeStamper.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
2022-05-05 20:55:28 +02:00
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
#include "fsfw_tests/integration/controller/TestController.h"
#include "fsfw_tests/integration/devices/TestCookie.h"
#include "fsfw_tests/integration/devices/TestDeviceHandler.h"
#include "fsfw_tests/integration/devices/TestEchoComIF.h"
#include "fsfw_tests/internal/InternalUnitTester.h"
#include "objects/systemObjectList.h"
#include "tmtc/apid.h"
2021-06-08 13:29:49 +02:00
2022-09-08 17:39:16 +02:00
void ObjectFactory::produceGenericObjects(TmFunnel **tmFunnel, StorageManagerIF &tcStore) {
2021-06-08 13:29:49 +02:00
#if OBSW_ADD_CORE_COMPONENTS == 1
2022-05-05 20:55:28 +02:00
/* Framework objects */
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
2022-08-08 12:32:06 +02:00
auto *stamperAndReader = new CdsShortTimeStamper(objects::TIME_STAMPER);
2022-08-16 17:13:05 +02:00
new VerificationReporter();
2022-08-08 12:32:06 +02:00
auto *ccsdsDistrib = new CcsdsDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
new PusDistributor(apid::APID, objects::PUS_DISTRIBUTOR, ccsdsDistrib);
*tmFunnel = new TmFunnel(*stamperAndReader, objects::TM_FUNNEL);
2021-06-08 13:29:49 +02:00
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
2022-05-05 20:55:28 +02:00
/* PUS stack */
2021-06-08 13:29:49 +02:00
#if OBSW_ADD_PUS_STACK == 1
2022-08-08 12:32:06 +02:00
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::APID,
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 5);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::APID, pus::PUS_SERVICE_2, 3,
10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
new Service5EventReporting(
PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::APID, pus::PUS_SERVICE_5), 20, 40);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::APID,
pus::PUS_SERVICE_8, 3, 10);
new Service9TimeManagement(
PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID, pus::PUS_SERVICE_9));
new Service17Test(PsbParams(objects::PUS_SERVICE_17_TEST, apid::APID, pus::PUS_SERVICE_17));
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::APID,
pus::PUS_SERVICE_20);
#if OBSW_ADD_CORE_COMPONENTS == 1
2022-05-20 08:58:42 +02:00
new Service11TelecommandScheduling<cfg::OBSW_MAX_SCHEDULED_TCS>(
2022-07-27 11:33:40 +02:00
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, apid::APID, pus::PUS_SERVICE_11),
2022-05-22 15:30:08 +02:00
ccsdsDistrib);
#endif
2022-05-05 20:55:28 +02:00
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::APID,
pus::PUS_SERVICE_200);
2021-06-08 13:29:49 +02:00
#endif /* OBSW_ADD_PUS_STACK == 1 */
2022-09-08 17:39:16 +02:00
#if OBSW_ADD_CFDP_COMPONENTS == 1
MessageQueueIF *cfdpMsgQueue = QueueFactory::instance()->createMessageQueue(5);
CfdpDistribCfg cfg(objects::CFDP_DISTRIBUTOR, tcStore, cfdpMsgQueue);
new CfdpDistributor(cfg);
#endif
2021-06-08 13:29:49 +02:00
#if OBSW_ADD_TASK_EXAMPLE == 1
2022-05-05 20:55:28 +02:00
/* Demo objects */
new FsfwExampleTask(objects::TEST_DUMMY_1);
new FsfwExampleTask(objects::TEST_DUMMY_2);
new FsfwExampleTask(objects::TEST_DUMMY_3);
2021-06-08 13:29:49 +02:00
2022-05-05 20:55:28 +02:00
bool enablePrintout = false;
2021-06-30 09:59:55 +02:00
#if OBSW_TASK_EXAMPLE_PRINTOUT == 1
2022-05-05 20:55:28 +02:00
enablePrintout = true;
2021-06-08 13:29:49 +02:00
#endif
2022-05-05 20:55:28 +02:00
new FsfwReaderTask(objects::TEST_DUMMY_4, enablePrintout);
2021-06-08 13:29:49 +02:00
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
#if OBSW_DEVICE_HANDLER_PRINTOUT == 1
2022-05-05 20:55:28 +02:00
bool enableInfoPrintout = true;
2021-06-08 13:29:49 +02:00
#else
2022-05-05 20:55:28 +02:00
bool enableInfoPrintout = false;
2021-06-08 13:29:49 +02:00
#endif /* OBSW_DEVICE_HANDLER_PRINTOUT == 1 */
2022-05-05 20:55:28 +02:00
/* Demo device handler object */
size_t expectedMaxReplyLen = 64;
2022-08-08 12:32:06 +02:00
CookieIF *testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0),
expectedMaxReplyLen);
2022-05-05 20:55:28 +02:00
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
2022-08-08 12:32:06 +02:00
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_1),
expectedMaxReplyLen);
new TestDevice(objects::TEST_DEVICE_HANDLER_1, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_1, enableInfoPrintout);
2022-05-05 20:55:28 +02:00
2022-08-08 12:32:06 +02:00
new TestAssembly(objects::TEST_ASSEMBLY, objects::NO_OBJECT, objects::TEST_DEVICE_HANDLER_0,
2022-05-05 20:55:28 +02:00
objects::TEST_DEVICE_HANDLER_1);
2021-06-08 13:29:49 +02:00
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
2022-05-05 20:55:28 +02:00
/* Demo controller object */
2021-06-08 13:29:49 +02:00
#if OBSW_ADD_CONTROLLER_DEMO == 1
#if OBSW_CONTROLLER_PRINTOUT == 1
#endif
2022-05-05 20:55:28 +02:00
new TestController(objects::TEST_CONTROLLER, objects::NO_OBJECT);
2021-06-08 13:29:49 +02:00
#endif /* OBSW_ADD_CONTROLLER_DEMO == 1 */
2021-07-14 10:24:24 +02:00
#if OBSW_PERFORM_INTERNAL_UNITTEST == 1
2022-05-05 20:55:28 +02:00
InternalUnitTester::TestConfig testCfg;
testCfg.testArrayPrinter = false;
2021-08-10 11:22:52 +02:00
#if defined FSFW_OSAL_HOST
2022-05-05 20:55:28 +02:00
// Not implemented yet for hosted OSAL (requires C++20)
testCfg.testSemaphores = false;
2021-08-10 11:22:52 +02:00
#endif
2022-05-05 20:55:28 +02:00
InternalUnitTester unittester;
unittester.performTests(testCfg);
2021-07-14 10:24:24 +02:00
#endif /* OBSW_PERFORM_INTERNAL_UNITTEST == 1 */
2021-06-08 13:29:49 +02:00
}
void Factory::setStaticFrameworkObjectIds() {
2022-05-05 20:55:28 +02:00
MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
2021-06-08 13:29:49 +02:00
2022-05-05 20:55:28 +02:00
TmFunnel::downlinkDestination = objects::DOWNLINK_DESTINATION;
// No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT;
2021-06-08 13:29:49 +02:00
2022-07-27 11:33:40 +02:00
PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_DISTRIBUTOR;
PusServiceBase::PACKET_DESTINATION = objects::TM_FUNNEL;
2021-06-08 13:29:49 +02:00
2022-05-05 20:55:28 +02:00
CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
2021-06-08 13:29:49 +02:00
2022-07-27 11:33:40 +02:00
VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
2021-06-08 13:29:49 +02:00
}