Robin Mueller
c04936d0dc
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
587 lines
23 KiB
C++
587 lines
23 KiB
C++
#include "scheduling.h"
|
|
|
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
|
#include <fsfw/subsystem/Subsystem.h>
|
|
#include <linux/scheduling.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/returnvalue.h"
|
|
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
|
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
|
#include "fsfw/tasks/TaskFactory.h"
|
|
#include "mission/core/scheduling.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;
|
|
|
|
void scheduling::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 << "scheduling::initMission: Object Construction failed with an "
|
|
"invalid argument: "
|
|
<< e.what();
|
|
std::exit(1);
|
|
}
|
|
|
|
sif::info << "Initializing all objects.." << std::endl;
|
|
ObjectManager::instance()->initialize();
|
|
|
|
/* This function creates and starts all tasks */
|
|
initTasks();
|
|
}
|
|
|
|
void scheduling::initTasks() {
|
|
TaskFactory* factory = TaskFactory::instance();
|
|
ReturnValue_t result = returnvalue::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
|
|
|
|
#if OBSW_ADD_SA_DEPL == 1
|
|
// Could add this to the core controller but the core controller does so many thing that I would
|
|
// prefer to have the solar array deployment in a seprate task.
|
|
PeriodicTaskIF* solarArrayDeplTask = factory->createPeriodicTask(
|
|
"SOLAR_ARRAY_DEPL", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
|
|
result = solarArrayDeplTask->addComponent(objects::SOLAR_ARRAY_DEPL_HANDLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("SOLAR_ARRAY_DEPL", objects::SOLAR_ARRAY_DEPL_HANDLER);
|
|
}
|
|
#endif
|
|
|
|
PeriodicTaskIF* sysTask = factory->createPeriodicTask(
|
|
"CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
|
|
result = sysTask->addComponent(objects::CORE_CONTROLLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER);
|
|
}
|
|
result = sysTask->addComponent(objects::PL_SUBSYSTEM);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM);
|
|
}
|
|
|
|
/* TMTC Distribution */
|
|
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
|
|
"DIST", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
#if OBSW_ADD_TCPIP_SERVERS == 1
|
|
#if OBSW_ADD_TMTC_UDP_SERVER == 1
|
|
result = tmTcDistributor->addComponent(objects::UDP_TMTC_SERVER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("UDP_TMTC_SERVER", objects::UDP_TMTC_SERVER);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_TMTC_TCP_SERVER == 1
|
|
result = tmTcDistributor->addComponent(objects::TCP_TMTC_SERVER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TCP_TMTC_SERVER", objects::TCP_TMTC_SERVER);
|
|
}
|
|
#endif
|
|
#endif
|
|
result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR);
|
|
}
|
|
result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR);
|
|
}
|
|
result = tmTcDistributor->addComponent(objects::CFDP_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("CFDP_DISTRIBUTOR", objects::CFDP_DISTRIBUTOR);
|
|
}
|
|
result = tmTcDistributor->addComponent(objects::TM_FUNNEL);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL);
|
|
}
|
|
|
|
#if OBSW_ADD_TCPIP_SERVERS == 1
|
|
#if OBSW_ADD_TMTC_UDP_SERVER == 1
|
|
PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask(
|
|
"UDP_TMTC_POLLING", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
result = udpPollingTask->addComponent(objects::UDP_TMTC_POLLING_TASK);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("UDP_POLLING", objects::UDP_TMTC_POLLING_TASK);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_TMTC_TCP_SERVER == 1
|
|
PeriodicTaskIF* tcpPollingTask = factory->createPeriodicTask(
|
|
"TCP_TMTC_POLLING", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
result = tcpPollingTask->addComponent(objects::TCP_TMTC_POLLING_TASK);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("UDP_POLLING", objects::TCP_TMTC_POLLING_TASK);
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
PeriodicTaskIF* comTask = factory->createPeriodicTask(
|
|
"COM_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
|
|
result = comTask->addComponent(objects::COM_SUBSYSTEM);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("COM subsystem", objects::COM_SUBSYSTEM);
|
|
}
|
|
|
|
#if OBSW_ADD_CCSDS_IP_CORES == 1
|
|
result = comTask->addComponent(objects::CCSDS_HANDLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER);
|
|
}
|
|
|
|
// Runs in IRQ mode, frequency does not really matter
|
|
PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask(
|
|
"PDEC_HANDLER", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
|
|
result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER);
|
|
}
|
|
#endif /* OBSW_ADD_CCSDS_IP_CORE == 1 */
|
|
|
|
#if OBSW_ADD_CFDP_COMPONENTS == 1
|
|
PeriodicTaskIF* cfdpTask = factory->createPeriodicTask(
|
|
"CFDP Handler", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
|
|
result = cfdpTask->addComponent(objects::CFDP_HANDLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("CFDP Handler", objects::CFDP_HANDLER);
|
|
}
|
|
#endif
|
|
|
|
#if OBSW_ADD_GPS_CTRL == 1
|
|
PeriodicTaskIF* gpsTask = factory->createPeriodicTask(
|
|
"GPS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
|
|
result = gpsTask->addComponent(objects::GPS_CONTROLLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("GPS_CTRL", objects::GPS_CONTROLLER);
|
|
}
|
|
#endif /* OBSW_ADD_GPS_CTRL */
|
|
|
|
PeriodicTaskIF* acsSysTask = factory->createPeriodicTask(
|
|
"SYS_TASK", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
|
|
static_cast<void>(acsSysTask);
|
|
#if OBSW_ADD_ACS_BOARD == 1
|
|
result = acsSysTask->addComponent(objects::ACS_BOARD_ASS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("ACS_BOARD_ASS", objects::ACS_BOARD_ASS);
|
|
}
|
|
#endif /* OBSW_ADD_ACS_HANDLERS */
|
|
#if OBSW_ADD_RW == 1
|
|
result = acsSysTask->addComponent(objects::RW_ASS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("RW_ASS", objects::RW_ASS);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_SUS_BOARD_ASS == 1
|
|
result = acsSysTask->addComponent(objects::SUS_BOARD_ASS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("SUS_BOARD_ASS", objects::SUS_BOARD_ASS);
|
|
}
|
|
#endif
|
|
result = acsSysTask->addComponent(objects::ACS_SUBSYSTEM);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("ACS_SUBSYSTEM", objects::ACS_SUBSYSTEM);
|
|
}
|
|
|
|
#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(objects::SPI_RTD_COM_IF);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("SPI_RTD_POLLING", objects::SPI_RTD_COM_IF);
|
|
}
|
|
|
|
PeriodicTaskIF* tcsTask = factory->createPeriodicTask(
|
|
"TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
|
|
scheduling::scheduleRtdSensors(tcsTask);
|
|
#endif
|
|
|
|
PeriodicTaskIF* tcsSystemTask = factory->createPeriodicTask(
|
|
"TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc);
|
|
result = tcsSystemTask->addComponent(objects::TCS_SUBSYSTEM);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TCS_SUBSYSTEM", objects::TCS_SUBSYSTEM);
|
|
}
|
|
#if OBSW_ADD_RTD_DEVICES == 1
|
|
result = tcsSystemTask->addComponent(objects::TCS_BOARD_ASS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TCS_BOARD_ASS", objects::TCS_BOARD_ASS);
|
|
}
|
|
#endif /* OBSW_ADD_RTD_DEVICES */
|
|
#if OBSW_ADD_TCS_CTRL == 1
|
|
result = tcsSystemTask->addComponent(objects::THERMAL_CONTROLLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("THERMAL_CONTROLLER", objects::THERMAL_CONTROLLER);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_HEATERS == 1
|
|
result = tcsSystemTask->addComponent(objects::HEATER_HANDLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("HEATER_HANDLER", objects::HEATER_HANDLER);
|
|
}
|
|
#endif
|
|
|
|
#if OBSW_ADD_STAR_TRACKER == 1
|
|
PeriodicTaskIF* strHelperTask = factory->createPeriodicTask(
|
|
"STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
result = strHelperTask->addComponent(objects::STR_HELPER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("STR_HELPER", objects::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(objects::PLOC_MPSOC_HELPER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PLOC_MPSOC_HELPER", objects::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(objects::PLOC_SUPERVISOR_HELPER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER);
|
|
}
|
|
#endif /* OBSW_ADD_PLOC_SUPERVISOR */
|
|
|
|
PeriodicTaskIF* plTask = factory->createPeriodicTask(
|
|
"PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
|
|
scheduling::addMpsocSupvHandlers(plTask);
|
|
plTask->addComponent(objects::CAM_SWITCHER);
|
|
|
|
#if OBSW_ADD_SCEX_DEVICE == 1
|
|
PeriodicTaskIF* scexDevHandler;
|
|
PeriodicTaskIF* scexReaderTask;
|
|
scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask);
|
|
#endif
|
|
|
|
std::vector<PeriodicTaskIF*> pusTasks;
|
|
createPusTasks(*factory, missedDeadlineFunc, pusTasks);
|
|
std::vector<PeriodicTaskIF*> pstTasks;
|
|
createPstTasks(*factory, missedDeadlineFunc, pstTasks);
|
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
#if OBSW_TEST_CCSDS_BRIDGE == 1
|
|
PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask(
|
|
"PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE);
|
|
}
|
|
#endif
|
|
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_SERVERS == 1
|
|
#if OBSW_ADD_TMTC_UDP_SERVER == 1
|
|
udpPollingTask->startTask();
|
|
#endif
|
|
#if OBSW_ADD_TMTC_TCP_SERVER == 1
|
|
tcpPollingTask->startTask();
|
|
#endif
|
|
#endif
|
|
|
|
comTask->startTask();
|
|
#if OBSW_ADD_CCSDS_IP_CORES == 1
|
|
pdecHandlerTask->startTask();
|
|
#endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */
|
|
|
|
sysTask->startTask();
|
|
#if OBSW_ADD_SA_DEPL == 1
|
|
solarArrayDeplTask->startTask();
|
|
#endif
|
|
|
|
taskStarter(pstTasks, "PST task vector");
|
|
taskStarter(pusTasks, "PUS task vector");
|
|
#if OBSW_ADD_SCEX_DEVICE == 1
|
|
scexDevHandler->startTask();
|
|
scexReaderTask->startTask();
|
|
#endif
|
|
|
|
#if OBSW_TEST_CCSDS_BRIDGE == 1
|
|
ptmeTestTask->startTask();
|
|
#endif
|
|
|
|
#if OBSW_ADD_CFDP_COMPONENTS == 1
|
|
cfdpTask->startTask();
|
|
#endif
|
|
|
|
#if OBSW_ADD_STAR_TRACKER == 1
|
|
strHelperTask->startTask();
|
|
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
|
|
|
#if OBSW_ADD_GPS_CTRL == 1
|
|
gpsTask->startTask();
|
|
#endif
|
|
acsSysTask->startTask();
|
|
#if OBSW_ADD_RTD_DEVICES == 1
|
|
tcsPollingTask->startTask();
|
|
tcsTask->startTask();
|
|
#endif /* OBSW_ADD_RTD_DEVICES == 1 */
|
|
if (not tcsSystemTask->isEmpty()) {
|
|
tcsSystemTask->startTask();
|
|
}
|
|
#if OBSW_ADD_PLOC_SUPERVISOR == 1
|
|
supvHelperTask->startTask();
|
|
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
|
|
plTask->startTask();
|
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
taskStarter(testTasks, "Test task vector");
|
|
#endif
|
|
|
|
sif::info << "Tasks started.." << std::endl;
|
|
}
|
|
|
|
void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
|
std::vector<PeriodicTaskIF*>& taskVec) {
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
#ifdef RELEASE_BUILD
|
|
static constexpr float acsPstPeriod = 0.4;
|
|
#else
|
|
static constexpr float acsPstPeriod = 0.6;
|
|
#endif
|
|
FixedTimeslotTaskIF* acsPst = factory.createFixedTimeslotTask(
|
|
"ACS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc);
|
|
result = pst::pstAcs(acsPst);
|
|
if (result != returnvalue::OK) {
|
|
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
|
sif::warning << "scheduling::initTasks: ACS PST is empty" << std::endl;
|
|
} else {
|
|
sif::error << "scheduling::initTasks: Creating ACS PST failed!" << std::endl;
|
|
}
|
|
} else {
|
|
taskVec.push_back(acsPst);
|
|
}
|
|
|
|
/* Polling Sequence Table Default */
|
|
#if OBSW_ADD_SPI_TEST_CODE == 0
|
|
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
|
|
"MAIN_SPI", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
|
|
result = pst::pstSpiAndSyrlinks(spiPst);
|
|
if (result != returnvalue::OK) {
|
|
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
|
sif::warning << "scheduling::initTasks: SPI PST is empty" << std::endl;
|
|
} else {
|
|
sif::error << "scheduling::initTasks: Creating SPI PST failed!" << std::endl;
|
|
}
|
|
} else {
|
|
taskVec.push_back(spiPst);
|
|
}
|
|
#endif
|
|
|
|
#if OBSW_ADD_I2C_TEST_CODE == 0
|
|
FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask(
|
|
"I2C_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
|
|
result = pst::pstI2c(i2cPst);
|
|
if (result != returnvalue::OK) {
|
|
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
|
sif::warning << "scheduling::initTasks: I2C PST is empty" << std::endl;
|
|
} else {
|
|
sif::error << "scheduling::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", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
|
|
result = pst::pstGompaceCan(gomSpacePstTask);
|
|
if (result != returnvalue::OK) {
|
|
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
|
sif::error << "scheduling::initTasks: GomSpace PST initialization failed!" << std::endl;
|
|
}
|
|
}
|
|
taskVec.push_back(gomSpacePstTask);
|
|
#endif
|
|
}
|
|
|
|
void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
|
std::vector<PeriodicTaskIF*>& taskVec) {
|
|
ReturnValue_t result = returnvalue::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 != returnvalue::OK) {
|
|
scheduling::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 != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
|
}
|
|
result = pusEvents->addComponent(objects::EVENT_MANAGER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER);
|
|
}
|
|
taskVec.push_back(pusEvents);
|
|
|
|
PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask(
|
|
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
}
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::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 != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_11_TC_SCHEDULER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_201_HEALTH);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH);
|
|
}
|
|
// Used for connection tests, therefore use higher priority
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST);
|
|
}
|
|
taskVec.push_back(pusMedPrio);
|
|
|
|
PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask(
|
|
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc);
|
|
result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER);
|
|
}
|
|
taskVec.push_back(pusLowPrio);
|
|
}
|
|
|
|
void scheduling::createTestTasks(TaskFactory& factory,
|
|
TaskDeadlineMissedFunction missedDeadlineFunc,
|
|
std::vector<PeriodicTaskIF*>& taskVec) {
|
|
#if OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
|
|
ReturnValue_t result = returnvalue::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(objects::TEST_TASK);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
|
}
|
|
|
|
#if OBSW_ADD_SPI_TEST_CODE == 1
|
|
result = testTask->addComponent(objects::SPI_TEST);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_I2C_TEST_CODE == 1
|
|
result = testTask->addComponent(objects::I2C_TEST);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("I2C_TEST", objects::I2C_TEST);
|
|
}
|
|
#endif
|
|
#if OBSW_ADD_UART_TEST_CODE == 1
|
|
result = testTask->addComponent(objects::UART_TEST);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("UART_TEST", objects::UART_TEST);
|
|
}
|
|
#endif
|
|
|
|
taskVec.push_back(testTask);
|
|
|
|
#endif // OBSW_ADD_TEST_TASK == 1 && OBSW_ADD_TEST_CODE == 1
|
|
}
|
|
|
|
/**
|
|
▄ ▄
|
|
▌▒█ ▄▀▒▌
|
|
▌▒▒█ ▄▀▒▒▒▐
|
|
▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
|
|
▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
|
|
▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
|
|
▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌
|
|
▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
|
|
▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
|
|
▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌
|
|
▌▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐
|
|
▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
|
|
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐
|
|
▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌
|
|
▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐
|
|
▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌
|
|
▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
|
|
▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
|
|
▒▒▒▒▒▒▒▒▒▒▀▀
|
|
**/
|