more similar to example now
This commit is contained in:
155
mission/core/InitMission.cpp
Normal file
155
mission/core/InitMission.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
#include "InitMission.h"
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
#include <config/objects/systemObjectList.h>
|
||||
#include <mission/core/ObjectFactory.h>
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/datapool/DataPool.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// This is configured for linux without \cr
|
||||
ServiceInterfaceStream sif::debug("DEBUG", false);
|
||||
ServiceInterfaceStream sif::info("INFO", false);
|
||||
ServiceInterfaceStream sif::warning("WARNING", false);
|
||||
ServiceInterfaceStream sif::error("ERROR", false, false, true);
|
||||
|
||||
ObjectManagerIF *objectManager = nullptr;
|
||||
|
||||
//Initialize Data Pool
|
||||
DataPool dataPool(nullptr);
|
||||
|
||||
void InitMission::initMission() {
|
||||
sif::info << "Building global objects.." << std::endl;
|
||||
/* Instantiate global object manager and also create all objects */
|
||||
objectManager = new ObjectManager(ObjectFactory::produce);
|
||||
sif::info << "Initializing all objects.." << std::endl;
|
||||
objectManager->initialize();
|
||||
|
||||
/* This function creates and starts all tasks */
|
||||
initTasks();
|
||||
}
|
||||
|
||||
void InitMission::initTasks(){
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* TmTcDistributor = TaskFactory::instance()->
|
||||
createPeriodicTask("DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.100, nullptr);
|
||||
ReturnValue_t result = TmTcDistributor->addComponent(
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
result = TmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
result = TmTcDistributor->addComponent(objects::TM_FUNNEL);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
/* UDP bridge */
|
||||
PeriodicTaskIF* UdpBridgeTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.2, nullptr);
|
||||
result = UdpBridgeTask->addComponent(objects::UDP_BRIDGE);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Add component UDP Unix Bridge failed" << std::endl;
|
||||
}
|
||||
PeriodicTaskIF* UdpPollingTask = TaskFactory::instance()->
|
||||
createPeriodicTask("UDP_POLLING", 80,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, nullptr);
|
||||
result = UdpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Add component UDP Polling failed" << std::endl;
|
||||
}
|
||||
|
||||
/* PUS Services */
|
||||
PeriodicTaskIF* PusVerification = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_VERIF_1", 40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
|
||||
result = PusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
PeriodicTaskIF* PusEvents = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_VERIF_1", 60,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
|
||||
result = PusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
PeriodicTaskIF* PusHighPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_HIGH_PRIO", 50,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.200, nullptr);
|
||||
result = PusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
result = PusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
PeriodicTaskIF* PusMedPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_HIGH_PRIO", 40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.8, nullptr);
|
||||
result = PusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
result = PusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
PeriodicTaskIF* PusLowPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUSB", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
1.6, nullptr);
|
||||
result = PusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
#if ADD_TEST_CODE == 1
|
||||
FixedTimeslotTaskIF* TestTimeslotTask = TaskFactory::instance()->
|
||||
createFixedTimeslotTask("PST_TEST_TASK", 10,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
|
||||
result = pst::pollingSequenceTestFunction(TestTimeslotTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::createTasks: Test PST initialization "
|
||||
<< "failed!" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Main thread sleep
|
||||
sif::info << "Starting tasks.." << std::endl;
|
||||
TmTcDistributor->startTask();
|
||||
UdpBridgeTask->startTask();
|
||||
UdpPollingTask->startTask();
|
||||
|
||||
PusVerification->startTask();
|
||||
PusEvents->startTask();
|
||||
PusHighPrio->startTask();
|
||||
PusMedPrio->startTask();
|
||||
PusLowPrio->startTask();
|
||||
#if ADD_TEST_CODE == 1
|
||||
TestTimeslotTask->startTask();
|
||||
#endif
|
||||
sif::info << "Tasks started.." << std::endl;
|
||||
}
|
||||
|
||||
|
9
mission/core/InitMission.h
Normal file
9
mission/core/InitMission.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef MISSION_CORE_INITMISSION_H_
|
||||
#define MISSION_CORE_INITMISSION_H_
|
||||
|
||||
namespace InitMission {
|
||||
void initMission();
|
||||
void initTasks();
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_INITMISSION_H_ */
|
124
mission/core/ObjectFactory.cpp
Normal file
124
mission/core/ObjectFactory.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <config/OBSWConfig.h>
|
||||
#include <config/objects/systemObjectList.h>
|
||||
#include <config/tmtc/apid.h>
|
||||
#include <config/tmtc/pusIds.h>
|
||||
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
#include <fsfw/storagemanager/PoolManager.h>
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/timemanager/TimeStamper.h>
|
||||
#include <fsfw/internalError/InternalErrorReporter.h>
|
||||
#include <fsfw/monitoring/MonitoringMessageContent.h>
|
||||
#include <fsfw/tcdistribution/CCSDSDistributor.h>
|
||||
#include <fsfw/tcdistribution/PUSDistributor.h>
|
||||
#include <fsfw/pus/Service1TelecommandVerification.h>
|
||||
#include <fsfw/pus/Service2DeviceAccess.h>
|
||||
#include <fsfw/pus/Service5EventReporting.h>
|
||||
#include <fsfw/pus/Service8FunctionManagement.h>
|
||||
#include <fsfw/pus/Service9TimeManagement.h>
|
||||
#include <fsfw/pus/Service17Test.h>
|
||||
#include <fsfw/pus/CService200ModeCommanding.h>
|
||||
#include <fsfw/osal/linux/TcUnixUdpPollingTask.h>
|
||||
#include <fsfw/osal/linux/TmTcUnixUdpBridge.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
|
||||
|
||||
#if ADD_TEST_CODE == 1
|
||||
#include <test/TestCookie.h>
|
||||
#include <test/TestDeviceHandler.h>
|
||||
#include <mission/test/TestTask.h>
|
||||
#include <test/TestEchoComIF.h>
|
||||
#endif
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds(){
|
||||
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
|
||||
PusServiceBase::packetDestination = objects::TM_FUNNEL;
|
||||
|
||||
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
|
||||
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
|
||||
|
||||
TmFunnel::downlinkDestination = objects::UDP_BRIDGE;
|
||||
// No storage object for now.
|
||||
TmFunnel::storageDestination = objects::NO_OBJECT;
|
||||
|
||||
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
|
||||
TmPacketStored::timeStamperId = objects::TIME_STAMPER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ObjectFactory::produce(){
|
||||
Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
/* Framework objects */
|
||||
new EventManager(objects::EVENT_MANAGER);
|
||||
new HealthTable(objects::HEALTH_TABLE);
|
||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER, 0, 0, 0);
|
||||
new TimeStamper(objects::TIME_STAMPER);
|
||||
|
||||
{
|
||||
static constexpr uint8_t NUMBER_OF_POOLS = 5;
|
||||
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
|
||||
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
|
||||
new PoolManager<NUMBER_OF_POOLS>(objects::TC_STORE, element_sizes,
|
||||
n_elements);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr uint8_t NUMBER_OF_POOLS = 5;
|
||||
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
|
||||
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
|
||||
new PoolManager<NUMBER_OF_POOLS>(objects::TM_STORE, element_sizes,
|
||||
n_elements);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr uint8_t NUMBER_OF_POOLS = 6;
|
||||
const uint16_t element_sizes[NUMBER_OF_POOLS] = {32, 64, 512,
|
||||
1024, 2048, 4096};
|
||||
const uint16_t n_elements[NUMBER_OF_POOLS] = {200, 100, 50, 25, 15, 5};
|
||||
new PoolManager<NUMBER_OF_POOLS>(objects::IPC_STORE, element_sizes,
|
||||
n_elements);
|
||||
}
|
||||
|
||||
new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR,
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
|
||||
|
||||
/* TMTC Reception via UDP socket */
|
||||
new TmFunnel(objects::TM_FUNNEL);
|
||||
new TmTcUnixUdpBridge(objects::UDP_BRIDGE,
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR,
|
||||
objects::TM_STORE, objects::TC_STORE);
|
||||
new TcUnixUdpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
||||
|
||||
|
||||
/* PUS stack */
|
||||
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL);
|
||||
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10);
|
||||
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50);
|
||||
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 10);
|
||||
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_9);
|
||||
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW,
|
||||
pus::PUS_SERVICE_17);
|
||||
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_200);
|
||||
|
||||
/* Test Device Handler */
|
||||
#if ADD_TEST_CODE == 1
|
||||
CookieIF* testCookie = new TestCookie(0);
|
||||
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
|
||||
new TestDevice(objects::TEST_DEVICE_HANDLER, objects::TEST_ECHO_COM_IF,
|
||||
testCookie, true);
|
||||
#endif
|
||||
}
|
17
mission/core/ObjectFactory.h
Normal file
17
mission/core/ObjectFactory.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* ObjectFactory.h
|
||||
*
|
||||
* Created on: Sep 22, 2020
|
||||
* Author: steffen
|
||||
*/
|
||||
|
||||
#ifndef MISSION_CORE_OBJECTFACTORY_H_
|
||||
#define MISSION_CORE_OBJECTFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void setStatics();
|
||||
void produce();
|
||||
};
|
||||
|
||||
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */
|
Reference in New Issue
Block a user