eive-obsw/bsp_q7s/core/InitMission.cpp
Ulrich Mohr 2800484f6b
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
changing mission dependend object IDs to FSFW_ENUM
2022-08-24 22:29:42 +02:00

686 lines
26 KiB
C++

#include "bsp_q7s/core/InitMission.h"
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
#include <iostream>
#include <vector>
#include "OBSWConfig.h"
#include "bsp_q7s/core/ObjectFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/platform.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
#include "fsfw/tasks/TaskFactory.h"
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
#include "mission/utility/InitMission.h"
#include "pollingsequence/pollingSequenceFactory.h"
/* This is configured for linux without CR */
#ifdef PLATFORM_UNIX
ServiceInterfaceStream sif::debug("DEBUG");
ServiceInterfaceStream sif::info("INFO");
ServiceInterfaceStream sif::warning("WARNING");
ServiceInterfaceStream sif::error("ERROR");
#else
ServiceInterfaceStream sif::debug("DEBUG", true);
ServiceInterfaceStream sif::info("INFO", true);
ServiceInterfaceStream sif::warning("WARNING", true);
ServiceInterfaceStream sif::error("ERROR", true, false, true);
#endif
ObjectManagerIF* objectManager = nullptr;
#ifdef FSFW_INTROSPECTION
void printEnum(ParameterIF* param) {
size_t i = 0;
for (auto iter : param->getEnumValues()) {
printf("---enum value %li: \"%s\"\n", iter, param->getEnumDescriptions()[i++]);
}
}
/*void printEnum(HousekeepingEntryIF* param) {
size_t i = 0;
for (auto iter : param->getEnumValues()) {
printf("---enum value %li: \"%s\"\n", iter, param->getEnumDescriptions()[i++]);
}
}
void printModes(HasModesIF* object) {
ModeHelperIF* modeHelper = object->getModeHelper();
auto modes = modeHelper->getModes();
for (auto mode : modes) {
auto submodes = modeHelper->getSubmodes(mode.first);
if (submodes.size() == 0) {
continue;
}
printf("-mode \"%s\" (%i) with \n", mode.second, mode.first);
for (auto submode : submodes) {
printf("--submode \"%s\" (%i)\n", submode.second, submode.first);
}
}
}*/
void printAction(HasActionsIF* actionIf) {
auto actionMap = actionIf->getActionHelper()->getActionMap();
for (auto iter = actionMap->begin(); iter != actionMap->end(); iter++) {
printf("-action \"%s\" (%i) with \n", iter->second->getName(), iter->second->getId());
auto parameterList = iter->second->getParameters();
for (ParameterIF* param : *parameterList) {
printf("--parameter \"%s\" %.3E, %.3E\n", param->getName(), param->getMinFloating(),
param->getMaxFloating());
if (param->getType() == Types::ENUM) {
printEnum(param);
}
}
}
}
/*
void printHousekeeping(HousekeepingIF* housekeepingIF) {
auto dataSets = housekeepingIF->getHousekeepingHelper()->getDataSets();
for (auto iter : *dataSets) {
printf("-SID \"%s\" (%i) with:\n", iter.second->getDescription(), iter.first);
for (HousekeepingEntryIF* param : *(iter.second->getVariables())) {
printf("--parameter \"%s\"\n", param->getName());
if (param->getType() == Types::ENUM) {
printEnum(param);
}
}
}
}
const char* getClassName(uint8_t classId) {
CLASS_ID::FwClassIds fwClassId(classId);
const char* description = fwClassId.getDescription();
if (description != nullptr) {
return description;
}
return "UNKNOWN";
}
void printReturnCodes() {
puts("\nReturnvalues");
for (auto iter : ReturnValueItems::returnValues) {
uint8_t classId = iter.first >> 8;
printf("-\"%s:%s\" (%04x)\n", getClassName(classId), iter.second, iter.first);
}
}
void printEvents() {
puts("\nEvents");
for (auto iter : EventItems::events) {
uint8_t classId = iter.first >> 8;
printf("-\"%s:%s\" (%06x)\n", getClassName(classId), iter.second, iter.first);
}
}*/
#endif
void initmission::initMission() {
sif::info << "Building global objects.." << std::endl;
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);
}
#ifdef FSFW_INTROSPECTION
sif::info << "Introspecting.." << std::endl;
ObjectManager::instance()->produce();
auto objectList = ObjectManager::instance()->getObjectList();
sif::info << "Looping.." << std::endl;
for (auto iter : *objectList) {
const char * name = "UNKNOWN";
commonObjects commonObjectId(iter.first);
if (commonObjectId.isValid()){
name = commonObjectId.getDescription();
}
systemObjects systemObject(iter.first);
if( systemObject.isValid()){
name = systemObject.getDescription();
}
printf("Object \"%s\" (0x%08x)\n", name, iter.first);
HasActionsIF* actionIf = dynamic_cast<HasActionsIF*>(iter.second);
if (actionIf != nullptr) {
printAction(actionIf);
}
/*HasModesIF* hasmodesIF = dynamic_cast<HasModesIF*>(iter.second);
if (hasmodesIF != nullptr) {
printModes(hasmodesIF);
}
HousekeepingIF* hasHousekeeping = dynamic_cast<HousekeepingIF*>(iter.second);
if (hasHousekeeping != nullptr) {
printHousekeeping(hasHousekeeping);
}*/
}
// printReturnCodes();
// printEvents();
exit(0);
#endif
sif::info << "Initializing all objects.." << std::endl;
ObjectManager::instance()->initialize();
/* This function creates and starts all tasks */
initTasks();
}
void initmission::initTasks() {
TaskFactory* factory = TaskFactory::instance();
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
if (factory == nullptr) {
/* Should never happen ! */
return;
}
#if OBSW_PRINT_MISSED_DEADLINES == 1
void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline;
#else
void (*missedDeadlineFunc)(void) = nullptr;
#endif
PeriodicTaskIF* coreController = factory->createPeriodicTask(
"CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
result = coreController->addComponent(commonObjects::CORE_CONTROLLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("CORE_CTRL", commonObjects::CORE_CONTROLLER);
}
/* TMTC Distribution */
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = tmTcDistributor->addComponent(commonObjects::CCSDS_PACKET_DISTRIBUTOR);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("CCSDS_DISTRIB", commonObjects::CCSDS_PACKET_DISTRIBUTOR);
}
result = tmTcDistributor->addComponent(commonObjects::PUS_PACKET_DISTRIBUTOR);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_PACKET_DISTRIB", commonObjects::PUS_PACKET_DISTRIBUTOR);
}
result = tmTcDistributor->addComponent(systemObjects::TM_FUNNEL);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("TM_FUNNEL", systemObjects::TM_FUNNEL);
}
#if OBSW_ADD_TCPIP_BRIDGE == 1
// TMTC bridge
PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask(
"TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = tmtcBridgeTask->addComponent(commonObjects::TMTC_BRIDGE);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("TMTC_BRIDGE", commonObjects::TMTC_BRIDGE);
}
PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask(
"TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = tmtcPollingTask->addComponent(commonObjects::TMTC_POLLING_TASK);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("UDP_POLLING", commonObjects::TMTC_POLLING_TASK);
}
#endif
#if OBSW_USE_CCSDS_IP_CORE == 1
PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask(
"CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = ccsdsHandlerTask->addComponent(commonObjects::CCSDS_HANDLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("CCSDS Handler", commonObjects::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(commonObjects::PDEC_HANDLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PDEC Handler", commonObjects::PDEC_HANDLER);
}
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
#if OBSW_ADD_ACS_HANDLERS == 1
PeriodicTaskIF* acsTask = factory->createPeriodicTask(
"ACS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
result = acsTask->addComponent(commonObjects::GPS_CONTROLLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("GPS_CTRL", commonObjects::GPS_CONTROLLER);
}
#endif /* OBSW_ADD_ACS_HANDLERS */
acsTask->addComponent(commonObjects::ACS_CONTROLLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("ACS_CTRL", commonObjects::ACS_CONTROLLER);
}
PeriodicTaskIF* sysTask = factory->createPeriodicTask(
"SYS_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
static_cast<void>(sysTask);
#if OBSW_ADD_ACS_HANDLERS == 1
result = sysTask->addComponent(commonObjects::ACS_BOARD_ASS);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("ACS_BOARD_ASS", commonObjects::ACS_BOARD_ASS);
}
#endif /* OBSW_ADD_ACS_HANDLERS */
#if OBSW_ADD_RW == 1
result = sysTask->addComponent(commonObjects::RW_ASS);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("RW_ASS", commonObjects::RW_ASS);
}
#endif
#if OBSW_ADD_SUS_BOARD_ASS == 1
result = sysTask->addComponent(commonObjects::SUS_BOARD_ASS);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SUS_BOARD_ASS", commonObjects::SUS_BOARD_ASS);
}
#endif
#if OBSW_ADD_RTD_DEVICES == 1
PeriodicTaskIF* tcsPollingTask = factory->createPeriodicTask(
"TCS_POLLING_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc);
result = tcsPollingTask->addComponent(systemObjects::SPI_RTD_COM_IF);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SPI_RTD_POLLING", systemObjects::SPI_RTD_COM_IF);
}
PeriodicTaskIF* tcsTask = factory->createPeriodicTask(
"TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
std::array<object_id_t, EiveMax31855::NUM_RTDS> rtdIds = {
commonObjects::RTD_0_IC3_PLOC_HEATSPREADER,
commonObjects::RTD_1_IC4_PLOC_MISSIONBOARD,
commonObjects::RTD_2_IC5_4K_CAMERA,
commonObjects::RTD_3_IC6_DAC_HEATSPREADER,
commonObjects::RTD_4_IC7_STARTRACKER,
commonObjects::RTD_5_IC8_RW1_MX_MY,
commonObjects::RTD_6_IC9_DRO,
commonObjects::RTD_7_IC10_SCEX,
commonObjects::RTD_8_IC11_X8,
commonObjects::RTD_9_IC12_HPA,
commonObjects::RTD_10_IC13_PL_TX,
commonObjects::RTD_11_IC14_MPA,
commonObjects::RTD_12_IC15_ACU,
commonObjects::RTD_13_IC16_PLPCDU_HEATSPREADER,
commonObjects::RTD_14_IC17_TCS_BOARD,
commonObjects::RTD_15_IC18_IMTQ,
};
tcsTask->addComponent(commonObjects::TCS_BOARD_ASS);
tcsTask->addComponent(commonObjects::THERMAL_CONTROLLER);
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);
}
#endif /* OBSW_ADD_RTD_DEVICES */
// 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(commonObjects::FILE_SYSTEM_HANDLER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("FILE_SYSTEM_TASK", commonObjects::FILE_SYSTEM_HANDLER);
}
#if OBSW_ADD_STAR_TRACKER == 1
PeriodicTaskIF* strHelperTask = factory->createPeriodicTask(
"STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = strHelperTask->addComponent(commonObjects::STR_HELPER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("STR_HELPER", commonObjects::STR_HELPER);
}
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
#if OBSW_ADD_PLOC_MPSOC == 1
PeriodicTaskIF* mpsocHelperTask = factory->createPeriodicTask(
"PLOC_MPSOC_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = mpsocHelperTask->addComponent(commonObjects::PLOC_MPSOC_HELPER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PLOC_MPSOC_HELPER", commonObjects::PLOC_MPSOC_HELPER);
}
#endif /* OBSW_ADD_PLOC_MPSOC */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask(
"PLOC_SUPV_HELPER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
result = supvHelperTask->addComponent(commonObjects::PLOC_SUPERVISOR_HELPER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PLOC_SUPV_HELPER", commonObjects::PLOC_SUPERVISOR_HELPER);
}
#endif /* OBSW_ADD_PLOC_SUPERVISOR */
#if OBSW_TEST_CCSDS_BRIDGE == 1
PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask(
"PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = ptmeTestTask->addComponent(commonObjects::CCSDS_IP_CORE_BRIDGE);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PTME_TEST", commonObjects::CCSDS_IP_CORE_BRIDGE);
}
#endif
std::vector<PeriodicTaskIF*> pusTasks;
createPusTasks(*factory, missedDeadlineFunc, pusTasks);
std::vector<PeriodicTaskIF*> pstTasks;
createPstTasks(*factory, missedDeadlineFunc, pstTasks);
#if OBSW_ADD_TEST_CODE == 1
std::vector<PeriodicTaskIF*> testTasks;
createTestTasks(*factory, missedDeadlineFunc, testTasks);
#endif
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;
}
}
};
sif::info << "Starting tasks.." << std::endl;
tmTcDistributor->startTask();
#if OBSW_ADD_TCPIP_BRIDGE == 1
tmtcBridgeTask->startTask();
tmtcPollingTask->startTask();
#endif
#if OBSW_USE_CCSDS_IP_CORE == 1
ccsdsHandlerTask->startTask();
pdecHandlerTask->startTask();
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
coreController->startTask();
taskStarter(pstTasks, "PST task vector");
taskStarter(pusTasks, "PUS task vector");
#if OBSW_ADD_TEST_CODE == 1
taskStarter(testTasks, "Test task vector");
#endif
#if OBSW_TEST_CCSDS_BRIDGE == 1
ptmeTestTask->startTask();
#endif
fsTask->startTask();
#if OBSW_ADD_STAR_TRACKER == 1
strHelperTask->startTask();
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
#if OBSW_ADD_ACS_HANDLERS == 1
acsTask->startTask();
#endif /* OBSW_ADD_ACS_HANDLERS == 1 */
sysTask->startTask();
#if OBSW_ADD_RTD_DEVICES == 1
tcsPollingTask->startTask();
tcsTask->startTask();
#endif /* OBSW_ADD_RTD_DEVICES == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
supvHelperTask->startTask();
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
sif::info << "Tasks started.." << std::endl;
}
void initmission::createPstTasks(TaskFactory& factory,
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
/* Polling Sequence Table Default */
#if OBSW_ADD_SPI_TEST_CODE == 0
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
"MAIN_SPI", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
result = pst::pstSpi(spiPst);
if (result != HasReturnvaluesIF::RETURN_OK) {
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(spiPst);
}
#endif
#if OBSW_ADD_RW == 1
FixedTimeslotTaskIF* rwPstTask = factory.createFixedTimeslotTask(
"RW_SPI", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 1.0, missedDeadlineFunc);
result = pst::pstSpiRw(rwPstTask);
if (result != HasReturnvaluesIF::RETURN_OK) {
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
FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask(
"UART_PST", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
result = pst::pstUart(uartPst);
if (result != HasReturnvaluesIF::RETURN_OK) {
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);
}
FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask(
"GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.2, missedDeadlineFunc);
result = pst::pstGpio(gpioPst);
if (result != HasReturnvaluesIF::RETURN_OK) {
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);
}
#if OBSW_ADD_I2C_TEST_CODE == 0
FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask(
"I2C_PST", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
result = pst::pstI2c(i2cPst);
if (result != HasReturnvaluesIF::RETURN_OK) {
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);
}
#endif
#if OBSW_ADD_GOMSPACE_PCDU == 1
FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask(
"GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
result = pst::pstGompaceCan(gomSpacePstTask);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl;
}
}
taskVec.push_back(gomSpacePstTask);
#endif
}
void initmission::createPusTasks(TaskFactory& factory,
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
/* 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);
}
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);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING);
}
result = pusEvents->addComponent(objects::EVENT_MANAGER);
if (result != HasReturnvaluesIF::RETURN_OK) {
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);
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);
}
taskVec.push_back(pusHighPrio);
PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask(
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING);
}
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_11_TC_SCHEDULER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER);
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS);
}
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_201_HEALTH);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH);
}
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);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST);
}
result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER);
}
taskVec.push_back(pusLowPrio);
}
void initmission::createTestTasks(TaskFactory& factory,
TaskDeadlineMissedFunction missedDeadlineFunc,
std::vector<PeriodicTaskIF*>& taskVec) {
#if OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
static_cast<void>(result); // supress warning in case it is not used
PeriodicTaskIF* testTask = factory.createPeriodicTask(
"TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc);
result = testTask->addComponent(commonObjects::TEST_TASK);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("TEST_TASK", commonObjects::TEST_TASK);
}
#if OBSW_ADD_SPI_TEST_CODE == 1
result = testTask->addComponent(commonObjects::SPI_TEST);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SPI_TEST", commonObjects::SPI_TEST);
}
#endif
#if OBSW_ADD_I2C_TEST_CODE == 1
result = testTask->addComponent(commonObjects::I2C_TEST);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("I2C_TEST", commonObjects::I2C_TEST);
}
#endif
#if OBSW_ADD_UART_TEST_CODE == 1
result = testTask->addComponent(commonObjects::UART_TEST);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("UART_TEST", commonObjects::UART_TEST);
}
#endif
taskVec.push_back(testTask);
#endif // OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
}
/**
▄ ▄
▌▒█ ▄▀▒▌
▌▒▒█ ▄▀▒▒▒▐
▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌
▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌
▌▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐
▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐
▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌
▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐
▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌
▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
▒▒▒▒▒▒▒▒▒▒▀▀
**/