2020-12-29 13:59:31 +01:00
|
|
|
#include "InitMission.h"
|
|
|
|
#include "ObjectFactory.h"
|
|
|
|
#include <OBSWConfig.h>
|
2020-09-30 17:17:01 +02:00
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
#include <mission/utility/InitMission.h>
|
|
|
|
|
2020-09-30 17:17:01 +02:00
|
|
|
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
|
|
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
|
|
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <fsfw/objectmanager/ObjectManager.h>
|
|
|
|
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
|
|
|
#include <fsfw/tasks/PeriodicTaskIF.h>
|
|
|
|
#include <fsfw/tasks/TaskFactory.h>
|
2021-03-07 14:06:29 +01:00
|
|
|
#include <fsfwconfig/pollingsequence/pollingSequenceFactory.h>
|
2020-09-30 17:17:01 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
/* This is configured for linux without CR */
|
2020-09-30 21:07:30 +02:00
|
|
|
#ifdef LINUX
|
|
|
|
ServiceInterfaceStream sif::debug("DEBUG");
|
|
|
|
ServiceInterfaceStream sif::info("INFO");
|
|
|
|
ServiceInterfaceStream sif::warning("WARNING");
|
2020-09-30 17:17:01 +02:00
|
|
|
ServiceInterfaceStream sif::error("ERROR", false, false, true);
|
2020-09-30 21:07:30 +02:00
|
|
|
#else
|
|
|
|
ServiceInterfaceStream sif::debug("DEBUG", true);
|
|
|
|
ServiceInterfaceStream sif::info("INFO", true);
|
|
|
|
ServiceInterfaceStream sif::warning("WARNING", true);
|
|
|
|
ServiceInterfaceStream sif::error("ERROR", true, false, true);
|
|
|
|
#endif
|
2020-09-30 17:17:01 +02:00
|
|
|
|
|
|
|
ObjectManagerIF *objectManager = nullptr;
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
void initmission::initMission() {
|
|
|
|
sif::info << "Building global objects.." << std::endl;
|
|
|
|
/* Instantiate global object manager and also create all objects */
|
2020-09-30 17:17:01 +02:00
|
|
|
objectManager = new ObjectManager(ObjectFactory::produce);
|
|
|
|
sif::info << "Initializing all objects.." << std::endl;
|
|
|
|
objectManager->initialize();
|
|
|
|
|
|
|
|
/* This function creates and starts all tasks */
|
|
|
|
initTasks();
|
|
|
|
}
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
void initmission::initTasks() {
|
|
|
|
TaskFactory* factory = TaskFactory::instance();
|
|
|
|
if(factory == nullptr) {
|
|
|
|
/* Should never happen ! */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#if OBSW_PRINT_MISSED_DEADLINES == 1
|
|
|
|
void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline;
|
|
|
|
#else
|
|
|
|
void (*missedDeadlineFunc) (void) = nullptr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* TMTC Distribution */
|
|
|
|
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
|
|
|
|
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
|
|
ReturnValue_t result = tmTcDistributor->addComponent(
|
|
|
|
objects::CCSDS_PACKET_DISTRIBUTOR);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR);
|
|
|
|
}
|
|
|
|
result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR);
|
|
|
|
}
|
|
|
|
result = tmTcDistributor->addComponent(objects::TM_FUNNEL);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL);
|
|
|
|
}
|
|
|
|
|
2020-09-30 17:17:01 +02:00
|
|
|
/* UDP bridge */
|
2021-03-05 12:57:42 +01:00
|
|
|
PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask(
|
|
|
|
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
|
|
result = udpBridgeTask->addComponent(objects::UDP_BRIDGE);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("UDP_BRIDGE", objects::UDP_BRIDGE);
|
|
|
|
}
|
|
|
|
PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask(
|
|
|
|
"UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
|
|
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("UDP_POLLING", objects::UDP_POLLING_TASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PUS Services */
|
|
|
|
PeriodicTaskIF* pusVerification = factory->createPeriodicTask(
|
|
|
|
"PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
|
|
|
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
PeriodicTaskIF* pusEvents = factory->createPeriodicTask(
|
|
|
|
"PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
|
|
|
result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
|
|
|
}
|
|
|
|
|
|
|
|
PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask(
|
|
|
|
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
|
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
|
|
}
|
|
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT);
|
|
|
|
}
|
|
|
|
|
|
|
|
PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask(
|
|
|
|
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
|
|
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
|
|
}
|
|
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING);
|
|
|
|
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) {
|
|
|
|
initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT);
|
|
|
|
}
|
|
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS);
|
|
|
|
}
|
|
|
|
|
|
|
|
PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask(
|
|
|
|
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc);
|
|
|
|
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST);
|
|
|
|
}
|
|
|
|
|
2021-04-15 13:17:15 +02:00
|
|
|
#if TE0720 == 0
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
//TODO: Add handling of missed deadlines
|
|
|
|
/* Polling Sequence Table Default */
|
2021-04-02 15:14:08 +02:00
|
|
|
#if Q7S_ADD_SPI_TEST == 0
|
2021-03-05 12:57:42 +01:00
|
|
|
FixedTimeslotTaskIF * pollingSequenceTableTaskDefault = factory->createFixedTimeslotTask(
|
|
|
|
"PST_TASK_DEFAULT", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0,
|
|
|
|
missedDeadlineFunc);
|
|
|
|
result = pst::pollingSequenceInitDefault(pollingSequenceTableTaskDefault);
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
|
|
|
}
|
2021-04-02 15:14:08 +02:00
|
|
|
#endif
|
2020-12-10 10:01:45 +01:00
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
FixedTimeslotTaskIF* gomSpacePstTask = factory->
|
|
|
|
createFixedTimeslotTask("GS_PST_TASK", 50,
|
2021-04-29 17:45:19 +02:00
|
|
|
PeriodicTaskIF::MINIMUM_STACK_SIZE*8, 1.0, missedDeadlineFunc);
|
2021-03-05 12:57:42 +01:00
|
|
|
result = pst::gomspacePstInit(gomSpacePstTask);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl;
|
|
|
|
}
|
2021-04-15 13:17:15 +02:00
|
|
|
|
|
|
|
#else
|
2021-05-12 13:06:56 +02:00
|
|
|
FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask(
|
2021-05-12 16:38:20 +02:00
|
|
|
"PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0,
|
2021-04-15 13:17:15 +02:00
|
|
|
missedDeadlineFunc);
|
2021-05-12 13:06:56 +02:00
|
|
|
result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720);
|
2021-04-15 13:17:15 +02:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl;
|
|
|
|
}
|
2021-02-14 09:25:40 +01:00
|
|
|
#endif
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
2021-04-02 15:14:08 +02:00
|
|
|
PeriodicTaskIF* testTask = factory->createPeriodicTask(
|
|
|
|
"TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc);
|
2021-03-05 12:57:42 +01:00
|
|
|
result = testTask->addComponent(objects::TEST_TASK);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
|
|
|
}
|
2021-04-02 15:14:08 +02:00
|
|
|
|
|
|
|
#if Q7S_ADD_SPI_TEST == 1
|
|
|
|
result = testTask->addComponent(objects::SPI_TEST);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
|
|
|
}
|
|
|
|
#endif
|
2021-03-05 12:57:42 +01:00
|
|
|
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
2021-02-14 09:25:40 +01:00
|
|
|
#if TE0720 == 1 && TEST_LIBGPIOD == 1
|
2021-03-05 12:57:42 +01:00
|
|
|
result = testTask->addComponent(objects::LIBGPIOD_TEST);
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST);
|
2021-02-14 09:25:40 +01:00
|
|
|
}
|
2021-03-05 12:57:42 +01:00
|
|
|
#endif /* TE0720 == 1 && TEST_LIBGPIOD == 1 */
|
2020-09-30 17:17:01 +02:00
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
sif::info << "Starting tasks.." << std::endl;
|
|
|
|
tmTcDistributor->startTask();
|
|
|
|
udpBridgeTask->startTask();
|
|
|
|
udpPollingTask->startTask();
|
2020-09-30 17:17:01 +02:00
|
|
|
|
2021-04-26 17:50:36 +02:00
|
|
|
#if TE0720 == 0 && Q7S_ADD_SPI_TEST == 0
|
2021-03-05 12:57:42 +01:00
|
|
|
gomSpacePstTask->startTask();
|
|
|
|
pollingSequenceTableTaskDefault->startTask();
|
2021-04-26 17:50:36 +02:00
|
|
|
#elif TE0720 == 1 && Q7S_ADD_SPI_TEST == 0
|
2021-05-12 13:06:56 +02:00
|
|
|
pollingSequenceTaskTE0720->startTask();
|
2021-04-02 15:14:08 +02:00
|
|
|
#endif
|
2020-12-09 12:00:24 +01:00
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
pusVerification->startTask();
|
|
|
|
pusEvents->startTask();
|
|
|
|
pusHighPrio->startTask();
|
|
|
|
pusMedPrio->startTask();
|
|
|
|
pusLowPrio->startTask();
|
2020-12-04 14:14:08 +01:00
|
|
|
|
2021-04-02 15:14:08 +02:00
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
2021-03-05 12:57:42 +01:00
|
|
|
testTask->startTask();
|
2021-04-02 15:14:08 +02:00
|
|
|
#endif
|
2021-03-05 12:57:42 +01:00
|
|
|
sif::info << "Tasks started.." << std::endl;
|
2020-09-30 17:17:01 +02:00
|
|
|
}
|