eive-obsw/bsp_q7s/core/InitMission.cpp

542 lines
22 KiB
C++
Raw Normal View History

2022-04-29 15:47:54 +02:00
#include "bsp_q7s/core/InitMission.h"
2020-09-30 17:17:01 +02:00
2022-05-12 12:35:05 +02:00
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
2022-01-18 11:41:19 +01:00
#include <iostream>
#include <vector>
2022-01-18 11:41:19 +01:00
#include "OBSWConfig.h"
2022-04-29 15:47:54 +02:00
#include "bsp_q7s/core/ObjectFactory.h"
2022-01-18 11:41:19 +01:00
#include "fsfw/objectmanager/ObjectManager.h"
2021-07-19 13:15:45 +02:00
#include "fsfw/objectmanager/ObjectManagerIF.h"
2022-01-18 11:41:19 +01:00
#include "fsfw/platform.h"
2022-08-24 17:27:47 +02:00
#include "fsfw/returnvalues/returnvalue.h"
2021-07-19 13:15:45 +02:00
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
#include "fsfw/tasks/TaskFactory.h"
2022-05-14 09:41:28 +02:00
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
2022-01-18 11:41:19 +01:00
#include "mission/utility/InitMission.h"
#include "pollingsequence/pollingSequenceFactory.h"
2020-09-30 17:17:01 +02:00
/* This is configured for linux without CR */
2021-07-19 13:15:45 +02:00
#ifdef PLATFORM_UNIX
2020-09-30 21:07:30 +02:00
ServiceInterfaceStream sif::debug("DEBUG");
ServiceInterfaceStream sif::info("INFO");
ServiceInterfaceStream sif::warning("WARNING");
2021-11-30 16:45:33 +01:00
ServiceInterfaceStream sif::error("ERROR");
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
2022-01-18 11:41:19 +01:00
ObjectManagerIF* objectManager = nullptr;
2020-09-30 17:17:01 +02:00
void initmission::initMission() {
2022-01-18 11:41:19 +01:00
sif::info << "Building global objects.." << std::endl;
2022-05-02 17:37:00 +02:00
try {
/* Instantiate global object manager and also create all objects */
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
} catch (const std::invalid_argument& e) {
sif::error << "initmission::initMission: Object Construction failed with an "
"invalid argument: "
<< e.what();
std::exit(1);
}
2022-01-18 11:41:19 +01:00
sif::info << "Initializing all objects.." << std::endl;
ObjectManager::instance()->initialize();
/* This function creates and starts all tasks */
initTasks();
2020-09-30 17:17:01 +02:00
}
void initmission::initTasks() {
2022-01-18 11:41:19 +01:00
TaskFactory* factory = TaskFactory::instance();
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-01-18 11:41:19 +01:00
if (factory == nullptr) {
/* Should never happen ! */
return;
}
#if OBSW_PRINT_MISSED_DEADLINES == 1
2022-01-18 11:41:19 +01:00
void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline;
#else
2022-01-18 11:41:19 +01:00
void (*missedDeadlineFunc)(void) = nullptr;
#endif
2022-01-18 11:41:19 +01:00
PeriodicTaskIF* coreController = factory->createPeriodicTask(
"CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
result = coreController->addComponent(objects::CORE_CONTROLLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER);
}
2021-07-08 12:11:24 +02:00
2022-01-18 11:41:19 +01:00
/* TMTC Distribution */
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR);
}
result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR);
}
result = tmTcDistributor->addComponent(objects::TM_FUNNEL);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL);
}
2021-09-28 14:58:12 +02:00
#if OBSW_ADD_TCPIP_BRIDGE == 1
2022-01-18 11:41:19 +01:00
// TMTC bridge
PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask(
"TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-05 13:19:20 +01:00
initmission::printAddObjectError("TMTC_BRIDGE", objects::TMTC_BRIDGE);
2022-01-18 11:41:19 +01:00
}
PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask(
"TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK);
}
2021-09-28 14:58:12 +02:00
#endif
#if OBSW_USE_CCSDS_IP_CORE == 1
2022-01-18 11:41:19 +01:00
PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask(
"CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER);
}
// Minimal distance between two received TCs amounts to 0.6 seconds
// If a command has not been read before the next one arrives, the old command will be
// overwritten by the PDEC.
PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask(
"PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER);
}
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
2021-09-29 14:47:20 +02:00
2022-01-24 16:33:22 +01:00
#if OBSW_ADD_ACS_HANDLERS == 1
2022-03-04 16:03:57 +01:00
PeriodicTaskIF* acsTask = factory->createPeriodicTask(
2022-05-14 09:41:28 +02:00
"ACS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
2022-03-04 16:03:57 +01:00
result = acsTask->addComponent(objects::GPS_CONTROLLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-22 19:15:13 +01:00
initmission::printAddObjectError("GPS_CTRL", objects::GPS_CONTROLLER);
2022-01-18 11:41:19 +01:00
}
2022-01-24 16:33:22 +01:00
#endif /* OBSW_ADD_ACS_HANDLERS */
2022-01-17 11:38:21 +01:00
2022-08-15 09:58:18 +02:00
acsTask->addComponent(objects::ACS_CONTROLLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-15 09:58:18 +02:00
initmission::printAddObjectError("ACS_CTRL", objects::ACS_CONTROLLER);
}
2022-03-22 19:15:13 +01:00
PeriodicTaskIF* sysTask = factory->createPeriodicTask(
"SYS_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
2022-05-19 15:28:02 +02:00
static_cast<void>(sysTask);
2022-05-07 13:38:09 +02:00
#if OBSW_ADD_ACS_HANDLERS == 1
2022-03-22 19:15:13 +01:00
result = sysTask->addComponent(objects::ACS_BOARD_ASS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
initmission::printAddObjectError("ACS_BOARD_ASS", objects::ACS_BOARD_ASS);
2022-03-22 10:15:04 +01:00
}
2022-04-24 12:34:08 +02:00
#endif /* OBSW_ADD_ACS_HANDLERS */
2022-05-11 01:02:29 +02:00
#if OBSW_ADD_RW == 1
result = sysTask->addComponent(objects::RW_ASS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-11 01:02:29 +02:00
initmission::printAddObjectError("RW_ASS", objects::RW_ASS);
}
#endif
#if OBSW_ADD_SUS_BOARD_ASS == 1
2022-03-22 19:15:13 +01:00
result = sysTask->addComponent(objects::SUS_BOARD_ASS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
initmission::printAddObjectError("SUS_BOARD_ASS", objects::SUS_BOARD_ASS);
2022-03-04 16:03:57 +01:00
}
#endif
2022-05-25 10:12:37 +02:00
result = sysTask->addComponent(objects::ACS_SUBSYSTEM);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("ACS_SUBSYSTEM", objects::ACS_SUBSYSTEM);
}
2022-05-14 09:41:28 +02:00
2022-05-27 13:44:40 +02:00
#if OBSW_ADD_RTD_DEVICES == 1
2022-05-14 11:34:25 +02:00
PeriodicTaskIF* tcsPollingTask = factory->createPeriodicTask(
2022-05-14 17:22:57 +02:00
"TCS_POLLING_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc);
2022-05-14 11:34:25 +02:00
result = tcsPollingTask->addComponent(objects::SPI_RTD_COM_IF);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-14 11:34:25 +02:00
initmission::printAddObjectError("SPI_RTD_POLLING", objects::SPI_RTD_COM_IF);
2022-03-22 19:15:13 +01:00
}
2022-05-25 10:12:37 +02:00
2022-05-14 09:41:28 +02:00
PeriodicTaskIF* tcsTask = factory->createPeriodicTask(
"TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
2022-05-14 09:41:28 +02:00
std::array<object_id_t, EiveMax31855::NUM_RTDS> rtdIds = {
objects::RTD_0_IC3_PLOC_HEATSPREADER,
objects::RTD_1_IC4_PLOC_MISSIONBOARD,
objects::RTD_2_IC5_4K_CAMERA,
objects::RTD_3_IC6_DAC_HEATSPREADER,
objects::RTD_4_IC7_STARTRACKER,
objects::RTD_5_IC8_RW1_MX_MY,
objects::RTD_6_IC9_DRO,
objects::RTD_7_IC10_SCEX,
objects::RTD_8_IC11_X8,
objects::RTD_9_IC12_HPA,
objects::RTD_10_IC13_PL_TX,
objects::RTD_11_IC14_MPA,
objects::RTD_12_IC15_ACU,
objects::RTD_13_IC16_PLPCDU_HEATSPREADER,
objects::RTD_14_IC17_TCS_BOARD,
objects::RTD_15_IC18_IMTQ,
};
2022-05-14 17:22:57 +02:00
tcsTask->addComponent(objects::TCS_BOARD_ASS);
2022-05-31 16:44:57 +02:00
tcsTask->addComponent(objects::THERMAL_CONTROLLER);
2022-05-14 09:41:28 +02:00
for (const auto& rtd : rtdIds) {
tcsTask->addComponent(rtd, DeviceHandlerIF::PERFORM_OPERATION);
tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_WRITE);
tcsTask->addComponent(rtd, DeviceHandlerIF::GET_WRITE);
tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_READ);
tcsTask->addComponent(rtd, DeviceHandlerIF::GET_READ);
2022-05-12 12:35:05 +02:00
}
2022-05-14 09:41:28 +02:00
#endif /* OBSW_ADD_RTD_DEVICES */
2022-01-17 11:38:21 +01:00
2022-01-18 11:41:19 +01:00
// FS task, task interval does not matter because it runs in permanent loop, priority low
// because it is a non-essential background task
PeriodicTaskIF* fsTask = factory->createPeriodicTask(
"FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER);
}
2021-12-06 19:36:21 +01:00
2021-12-22 16:06:30 +01:00
#if OBSW_ADD_STAR_TRACKER == 1
2022-02-05 13:19:20 +01:00
PeriodicTaskIF* strHelperTask = factory->createPeriodicTask(
"STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
2022-02-05 13:19:20 +01:00
result = strHelperTask->addComponent(objects::STR_HELPER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
initmission::printAddObjectError("STR_HELPER", objects::STR_HELPER);
2022-01-18 11:41:19 +01:00
}
2021-12-22 16:06:30 +01:00
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
2022-03-16 17:00:07 +01:00
#if OBSW_ADD_PLOC_MPSOC == 1
PeriodicTaskIF* mpsocHelperTask = factory->createPeriodicTask(
"PLOC_MPSOC_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = mpsocHelperTask->addComponent(objects::PLOC_MPSOC_HELPER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-16 17:00:07 +01:00
initmission::printAddObjectError("PLOC_MPSOC_HELPER", objects::PLOC_MPSOC_HELPER);
}
#endif /* OBSW_ADD_PLOC_MPSOC */
2022-04-10 18:46:39 +02:00
#if OBSW_ADD_PLOC_SUPERVISOR == 1
PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask(
"PLOC_SUPV_HELPER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
2022-04-10 18:46:39 +02:00
result = supvHelperTask->addComponent(objects::PLOC_SUPERVISOR_HELPER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-04-10 18:46:39 +02:00
initmission::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER);
}
#endif /* OBSW_ADD_PLOC_SUPERVISOR */
2021-08-17 17:48:51 +02:00
#if OBSW_TEST_CCSDS_BRIDGE == 1
2022-01-18 11:41:19 +01:00
PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask(
"PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE);
}
2021-05-16 19:22:04 +02:00
#endif
2022-01-18 11:41:19 +01:00
std::vector<PeriodicTaskIF*> pusTasks;
createPusTasks(*factory, missedDeadlineFunc, pusTasks);
std::vector<PeriodicTaskIF*> pstTasks;
createPstTasks(*factory, missedDeadlineFunc, pstTasks);
2021-09-13 18:07:07 +02:00
#if OBSW_ADD_TEST_CODE == 1
2022-01-18 11:41:19 +01:00
std::vector<PeriodicTaskIF*> testTasks;
createTestTasks(*factory, missedDeadlineFunc, testTasks);
#endif
2021-07-19 13:15:45 +02:00
2022-01-18 11:41:19 +01:00
auto taskStarter = [](std::vector<PeriodicTaskIF*>& taskVector, std::string name) {
for (const auto& task : taskVector) {
if (task != nullptr) {
task->startTask();
} else {
sif::error << "Task in vector " << name << " is invalid!" << std::endl;
}
}
};
2021-07-19 13:15:45 +02:00
2022-01-18 11:41:19 +01:00
sif::info << "Starting tasks.." << std::endl;
tmTcDistributor->startTask();
2021-09-28 14:58:12 +02:00
#if OBSW_ADD_TCPIP_BRIDGE == 1
2022-01-18 11:41:19 +01:00
tmtcBridgeTask->startTask();
tmtcPollingTask->startTask();
2021-09-28 14:58:12 +02:00
#endif
#if OBSW_USE_CCSDS_IP_CORE == 1
2022-01-18 11:41:19 +01:00
ccsdsHandlerTask->startTask();
pdecHandlerTask->startTask();
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
2022-01-18 11:41:19 +01:00
coreController->startTask();
2021-07-19 13:15:45 +02:00
2022-01-18 11:41:19 +01:00
taskStarter(pstTasks, "PST task vector");
taskStarter(pusTasks, "PUS task vector");
2021-09-13 18:07:07 +02:00
#if OBSW_ADD_TEST_CODE == 1
2022-01-18 11:41:19 +01:00
taskStarter(testTasks, "Test task vector");
2021-07-19 13:15:45 +02:00
#endif
2021-08-17 17:48:51 +02:00
#if OBSW_TEST_CCSDS_BRIDGE == 1
2022-01-18 11:41:19 +01:00
ptmeTestTask->startTask();
2021-07-19 13:15:45 +02:00
#endif
2022-01-18 11:41:19 +01:00
fsTask->startTask();
2021-12-22 16:06:30 +01:00
#if OBSW_ADD_STAR_TRACKER == 1
2022-03-28 17:38:57 +02:00
strHelperTask->startTask();
2021-12-22 16:06:30 +01:00
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
2022-05-27 13:44:40 +02:00
#if OBSW_ADD_ACS_HANDLERS == 1
2022-03-04 16:03:57 +01:00
acsTask->startTask();
2022-05-27 13:44:40 +02:00
#endif /* OBSW_ADD_ACS_HANDLERS == 1 */
2022-03-22 19:15:13 +01:00
sysTask->startTask();
2022-05-27 13:44:40 +02:00
#if OBSW_ADD_RTD_DEVICES == 1
2022-05-14 11:34:25 +02:00
tcsPollingTask->startTask();
2022-05-14 09:41:28 +02:00
tcsTask->startTask();
2022-05-27 13:44:40 +02:00
#endif /* OBSW_ADD_RTD_DEVICES == 1 */
2022-04-17 14:52:43 +02:00
#if OBSW_ADD_PLOC_SUPERVISOR == 1
supvHelperTask->startTask();
2022-04-17 14:52:43 +02:00
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
2022-01-18 11:41:19 +01:00
sif::info << "Tasks started.." << std::endl;
2021-07-19 13:15:45 +02:00
}
void initmission::createPstTasks(TaskFactory& factory,
2022-01-18 11:41:19 +01:00
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-01-18 11:41:19 +01:00
/* Polling Sequence Table Default */
2021-09-15 17:38:26 +02:00
#if OBSW_ADD_SPI_TEST_CODE == 0
2022-01-18 11:41:19 +01:00
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
2022-05-05 02:00:56 +02:00
"MAIN_SPI", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
result = pst::pstSpi(spiPst);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-14 09:38:58 +01:00
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "InitMission::initTasks: SPI PST is empty" << std::endl;
} else {
sif::error << "InitMission::initTasks: Creating SPI PST failed!" << std::endl;
2022-01-18 11:41:19 +01:00
}
} else {
taskVec.push_back(spiPst);
}
2021-07-19 13:15:45 +02:00
#endif
2022-05-05 02:00:56 +02:00
#if OBSW_ADD_RW == 1
FixedTimeslotTaskIF* rwPstTask = factory.createFixedTimeslotTask(
"RW_SPI", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 1.0, missedDeadlineFunc);
result = pst::pstSpiRw(rwPstTask);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-05 02:00:56 +02:00
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "InitMission::initTasks: SPI PST is empty" << std::endl;
} else {
sif::error << "InitMission::initTasks: Creating SPI PST failed!" << std::endl;
}
} else {
taskVec.push_back(rwPstTask);
}
#endif
2022-01-18 11:41:19 +01:00
FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask(
2022-05-05 02:00:56 +02:00
"UART_PST", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
result = pst::pstUart(uartPst);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-14 09:38:58 +01:00
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "InitMission::initTasks: UART PST is empty" << std::endl;
} else {
sif::error << "InitMission::initTasks: Creating UART PST failed!" << std::endl;
}
} else {
taskVec.push_back(uartPst);
2022-01-18 11:41:19 +01:00
}
2022-03-14 09:38:58 +01:00
2022-01-18 11:41:19 +01:00
FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask(
2022-05-05 02:00:56 +02:00
"GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.2, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
result = pst::pstGpio(gpioPst);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-14 09:38:58 +01:00
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "InitMission::initTasks: GPIO PST is empty" << std::endl;
} else {
sif::error << "InitMission::initTasks: Creating GPIO PST failed!" << std::endl;
}
} else {
taskVec.push_back(gpioPst);
2022-01-18 11:41:19 +01:00
}
2022-02-03 13:37:48 +01:00
#if OBSW_ADD_I2C_TEST_CODE == 0
2022-01-18 11:41:19 +01:00
FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask(
2022-05-05 02:00:56 +02:00
"I2C_PST", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
result = pst::pstI2c(i2cPst);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-14 09:38:58 +01:00
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "InitMission::initTasks: I2C PST is empty" << std::endl;
} else {
sif::error << "InitMission::initTasks: Creating I2C PST failed!" << std::endl;
}
} else {
taskVec.push_back(i2cPst);
2022-01-18 11:41:19 +01:00
}
2022-02-03 13:37:48 +01:00
#endif
2022-01-18 11:41:19 +01:00
2022-04-29 15:47:54 +02:00
#if OBSW_ADD_GOMSPACE_PCDU == 1
2022-01-18 11:41:19 +01:00
FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask(
"GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
result = pst::pstGompaceCan(gomSpacePstTask);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-03-14 09:38:58 +01:00
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl;
}
2022-01-18 11:41:19 +01:00
}
taskVec.push_back(gomSpacePstTask);
2022-04-29 15:47:54 +02:00
#endif
2021-07-19 13:15:45 +02:00
}
2022-01-18 11:41:19 +01:00
void initmission::createPusTasks(TaskFactory& factory,
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-01-18 11:41:19 +01:00
/* PUS Services */
PeriodicTaskIF* pusVerification = factory.createPeriodicTask(
"PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION);
}
taskVec.push_back(pusVerification);
PeriodicTaskIF* pusEvents = factory.createPeriodicTask(
"PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING);
}
result = pusEvents->addComponent(objects::EVENT_MANAGER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER);
}
taskVec.push_back(pusEvents);
PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask(
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
}
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT);
}
taskVec.push_back(pusHighPrio);
PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask(
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
2022-05-24 15:21:37 +02:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-24 15:21:37 +02:00
initmission::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING);
}
2022-01-18 11:41:19 +01:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
}
2022-05-24 15:21:37 +02:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_11_TC_SCHEDULER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-24 15:21:37 +02:00
initmission::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER);
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-24 15:21:37 +02:00
initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS);
2022-01-18 11:41:19 +01:00
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT);
}
2022-05-12 19:22:20 +02:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_201_HEALTH);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-05-12 19:22:20 +02:00
initmission::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH);
}
2022-01-18 11:41:19 +01:00
taskVec.push_back(pusMedPrio);
PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask(
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc);
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST);
}
result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER);
}
taskVec.push_back(pusLowPrio);
2021-07-19 13:15:45 +02:00
}
2022-01-18 11:41:19 +01:00
void initmission::createTestTasks(TaskFactory& factory,
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
2022-02-04 17:48:05 +01:00
#if OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-04 17:48:05 +01:00
static_cast<void>(result); // supress warning in case it is not used
2022-01-18 11:41:19 +01:00
PeriodicTaskIF* testTask = factory.createPeriodicTask(
"TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc);
2022-02-04 17:48:05 +01:00
2022-01-18 11:41:19 +01:00
result = testTask->addComponent(objects::TEST_TASK);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
}
2021-09-15 17:38:26 +02:00
#if OBSW_ADD_SPI_TEST_CODE == 1
2022-01-18 11:41:19 +01:00
result = testTask->addComponent(objects::SPI_TEST);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-01-18 11:41:19 +01:00
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
}
#endif
2022-02-03 13:37:48 +01:00
#if OBSW_ADD_I2C_TEST_CODE == 1
result = testTask->addComponent(objects::I2C_TEST);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-03 13:37:48 +01:00
initmission::printAddObjectError("I2C_TEST", objects::I2C_TEST);
}
#endif
2022-02-04 17:48:05 +01:00
#if OBSW_ADD_UART_TEST_CODE == 1
result = testTask->addComponent(objects::UART_TEST);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-04 17:48:05 +01:00
initmission::printAddObjectError("UART_TEST", objects::UART_TEST);
}
#endif
2022-01-18 11:41:19 +01:00
taskVec.push_back(testTask);
2022-02-04 17:48:05 +01:00
#endif // OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
2020-09-30 17:17:01 +02:00
}
2022-03-03 19:21:56 +01:00
/**
2022-03-28 13:54:46 +02:00
2022-03-03 19:21:56 +01:00
**/