added more files
This commit is contained in:
5
bsp_linux/core/CMakeLists.txt
Normal file
5
bsp_linux/core/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
InitMission.cpp
|
||||
ObjectFactory.cpp
|
||||
)
|
241
bsp_linux/core/InitMission.cpp
Normal file
241
bsp_linux/core/InitMission.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include <bsp_linux/fsfwconfig/objects/systemObjectList.h>
|
||||
#include <bsp_linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h>
|
||||
|
||||
#include <mission/utility/TaskCreation.h>
|
||||
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include <fsfw/ipc/MessageQueueSenderIF.h>
|
||||
#include <fsfw/ipc/CommandMessage.h>
|
||||
#include <fsfw/modes/ModeMessage.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <mission/assemblies/TestAssembly.h>
|
||||
|
||||
void InitMission::createTasks() {
|
||||
TaskFactory* taskFactory = TaskFactory::instance();
|
||||
if(taskFactory == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* distributerTask = taskFactory->
|
||||
createPeriodicTask("DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
ReturnValue_t result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR);
|
||||
}
|
||||
result = distributerTask->addComponent(objects::PUS_DISTRIBUTOR);
|
||||
if (result!=HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS distributor", objects::PUS_DISTRIBUTOR);
|
||||
}
|
||||
result = distributerTask->addComponent(objects::TM_FUNNEL);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("TM funnel", objects::TM_FUNNEL);
|
||||
}
|
||||
|
||||
/* UDP bridge */
|
||||
PeriodicTaskIF* udpBridgeTask = taskFactory->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = udpBridgeTask->addComponent(objects::UDP_BRIDGE);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("UDP bridge", objects::UDP_BRIDGE);
|
||||
}
|
||||
/* UDP polling task */
|
||||
PeriodicTaskIF* udpPollingTask = taskFactory->createPeriodicTask(
|
||||
"UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.1, nullptr);
|
||||
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("UDP polling", objects::UDP_POLLING_TASK);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* eventTask = taskFactory->createPeriodicTask(
|
||||
"EVENT_MGMT", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.1, nullptr);
|
||||
result = eventTask->addComponent(objects::EVENT_MANAGER);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
task::printInitError("Event Manager", objects::EVENT_MANAGER);
|
||||
}
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||
FixedTimeslotTaskIF* timeslotDemoTask = taskFactory->createFixedTimeslotTask
|
||||
("PST_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, nullptr);
|
||||
result = pst::pollingSequenceExamples(timeslotDemoTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "InitMission::createTasks: Timeslot demo task"
|
||||
<<" initialization failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("InitMission::createTasks: Timeslot demo task"
|
||||
" initialization failed!\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
PeriodicTaskIF* readerTask = taskFactory->
|
||||
createPeriodicTask("READER_TASK", 40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = readerTask->addComponent(objects::TEST_DUMMY_4);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("Dummy 4", objects::TEST_DUMMY_4);
|
||||
}
|
||||
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
||||
|
||||
#if OBSW_ADD_PUS_STACK == 1
|
||||
/* PUS Services */
|
||||
PeriodicTaskIF* pusVerification = taskFactory->createPeriodicTask(
|
||||
"PUS_VERIF_1", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 1", objects::PUS_SERVICE_1_VERIFICATION);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusHighPrio = taskFactory->createPeriodicTask(
|
||||
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
}
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
task::printInitError("PUS 5",objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
}
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 9", objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusMedPrio = taskFactory->createPeriodicTask(
|
||||
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, nullptr);
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
}
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 20", objects::PUS_SERVICE_20_PARAMETERS);
|
||||
}
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 200", objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusLowPrio = taskFactory->createPeriodicTask(
|
||||
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, nullptr);
|
||||
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("PUS 17", objects::PUS_SERVICE_17_TEST);
|
||||
}
|
||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
FixedTimeslotTaskIF* testDeviceTask = taskFactory->createFixedTimeslotTask(
|
||||
"PST_TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = pst::pollingSequenceDevices(testDeviceTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "InitMission::createTasks: Test PST initialization failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("InitMission::createTasks: Test PST initialization failed!\n\r");
|
||||
#endif
|
||||
}
|
||||
PeriodicTaskIF* assemblyTask = taskFactory->createPeriodicTask("ASS_TASK", 30,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, nullptr);
|
||||
if(assemblyTask == nullptr){
|
||||
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
||||
}
|
||||
result = assemblyTask->addComponent(objects::TEST_ASSEMBLY);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
||||
}
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
#if OBSW_ADD_CONTROLLER_DEMO == 1
|
||||
PeriodicTaskIF* controllerTask = taskFactory->createPeriodicTask(
|
||||
"TEST_CTRL", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, nullptr);
|
||||
result = controllerTask->addComponent(objects::TEST_CONTROLLER);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("Controller Task", objects::TEST_CONTROLLER);
|
||||
}
|
||||
#endif /* OBSW_ADD_CONTROLLER_DEMO == 1 */
|
||||
|
||||
PeriodicTaskIF* testTask = taskFactory->createPeriodicTask(
|
||||
"TEST", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = testTask->addComponent(objects::TEST_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("Test Task", objects::TEST_TASK);
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Starting tasks.." << std::endl;
|
||||
#else
|
||||
sif::printInfo("Starting tasks..\n");
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
distributerTask->startTask();
|
||||
udpBridgeTask->startTask();
|
||||
udpPollingTask->startTask();
|
||||
eventTask->startTask();
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
#if OBSW_ADD_PUS_STACK == 1
|
||||
pusVerification->startTask();
|
||||
pusHighPrio->startTask();
|
||||
pusMedPrio->startTask();
|
||||
pusLowPrio->startTask();
|
||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||
|
||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||
timeslotDemoTask->startTask();
|
||||
readerTask->startTask();
|
||||
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
testDeviceTask->startTask();
|
||||
assemblyTask->startTask();
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
#if OBSW_ADD_CONTROLLER_DEMO == 1
|
||||
controllerTask->startTask();
|
||||
#endif /* OBSW_ADD_CONTROLLER_DEMO == 1 */
|
||||
|
||||
testTask->startTask();
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Tasks started.." << std::endl;
|
||||
#else
|
||||
sif::printInfo("Tasks started..\n");
|
||||
#endif
|
||||
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO
|
||||
HasModesIF* assembly = ObjectManager::instance()->get<HasModesIF>(objects::TEST_ASSEMBLY);
|
||||
if (assembly == nullptr){
|
||||
return;
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Waiting 5 Seconds and then command Test Assembly to Normal, Dual" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Waiting 5 Seconds and then command Test Assembly to Normal, Dual \n");
|
||||
#endif
|
||||
|
||||
TaskFactory::delayTask(5000);
|
||||
CommandMessage modeMessage;
|
||||
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
||||
DeviceHandlerIF::MODE_NORMAL, TestAssembly::submodes::DUAL);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Commanding Test Assembly to Normal, Dual \n");
|
||||
#endif
|
||||
MessageQueueSenderIF::sendMessage(assembly->getCommandQueue(), &modeMessage,
|
||||
MessageQueueIF::NO_QUEUE);
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO */
|
||||
}
|
8
bsp_linux/core/InitMission.h
Normal file
8
bsp_linux/core/InitMission.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef MISSION_CORE_INITMISSION_H_
|
||||
#define MISSION_CORE_INITMISSION_H_
|
||||
|
||||
namespace InitMission {
|
||||
void createTasks();
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_INITMISSION_H_ */
|
57
bsp_linux/core/ObjectFactory.cpp
Normal file
57
bsp_linux/core/ObjectFactory.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include <bsp_linux/core/ObjectFactory.h>
|
||||
#include <bsp_linux/fsfwconfig/objects/systemObjectList.h>
|
||||
#include <bsp_linux/fsfwconfig/tmtc/apid.h>
|
||||
#include <bsp_linux/fsfwconfig/tmtc/pusIds.h>
|
||||
|
||||
#include <test/TestTask.h>
|
||||
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <mission/core/GenericFactory.h>
|
||||
|
||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <fsfw/monitoring/MonitoringMessageContent.h>
|
||||
#include <fsfw/storagemanager/PoolManager.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
#include <fsfw/osal/common/UdpTcPollingTask.h>
|
||||
#include <fsfw/osal/common/UdpTmTcBridge.h>
|
||||
|
||||
|
||||
void ObjectFactory::produce(void* args) {
|
||||
/* Located inside the GenericFactory source file */
|
||||
Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{16, 100},{32, 50}, {64, 25}, {128,15}, {1024, 5}
|
||||
};
|
||||
new PoolManager(objects::TC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{16, 100},{32, 50}, {64, 25}, {128,15}, {1024, 5}
|
||||
};
|
||||
new PoolManager(objects::TM_STORE, poolCfg);
|
||||
}
|
||||
|
||||
{
|
||||
LocalPool::LocalPoolConfig poolCfg = {
|
||||
{16, 100},{32, 50}, {64, 25}, {128,15}, {1024, 5}
|
||||
};
|
||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
/* TMTC Reception via UDP socket */
|
||||
auto tmtcBridge = new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_DISTRIBUTOR);
|
||||
tmtcBridge->setMaxNumberOfPacketsStored(20);
|
||||
new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
ObjectFactory::produceGenericObjects();
|
||||
new TestTask(objects::TEST_TASK, false);
|
||||
}
|
10
bsp_linux/core/ObjectFactory.h
Normal file
10
bsp_linux/core/ObjectFactory.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef MISSION_CORE_OBJECTFACTORY_H_
|
||||
#define MISSION_CORE_OBJECTFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void setStatics();
|
||||
void produce(void* args);
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */
|
Reference in New Issue
Block a user