eive-obsw/bsp_q7s/core/scheduling.cpp

634 lines
25 KiB
C++
Raw Normal View History

2022-11-25 11:04:33 +01:00
#include "scheduling.h"
2020-09-30 17:17:01 +02:00
2022-05-12 12:35:05 +02:00
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
2023-01-28 14:49:28 +01:00
#include <fsfw/subsystem/Subsystem.h>
2022-11-16 15:03:10 +01:00
#include <linux/scheduling.h>
2022-05-12 12:35:05 +02:00
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"
#include "mission/core/pollingSeqTables.h"
2022-11-25 10:37:10 +01:00
#include "mission/core/scheduling.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"
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
2022-11-25 11:04:33 +01:00
void scheduling::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) {
2022-11-25 11:04:33 +01:00
sif::error << "scheduling::initMission: Object Construction failed with an "
2022-05-02 17:37:00 +02:00
"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
}
2022-11-25 11:04:33 +01:00
void scheduling::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-10-26 15:47:23 +02:00
#if OBSW_ADD_SA_DEPL == 1
2022-10-12 13:29:38 +02:00
// 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) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("SOLAR_ARRAY_DEPL", objects::SOLAR_ARRAY_DEPL_HANDLER);
2022-10-12 13:29:38 +02:00
}
2022-10-26 15:47:23 +02:00
#endif
2021-07-08 12:11:24 +02:00
2023-02-10 18:07:44 +01:00
PeriodicTaskIF* coreCtrlTask = factory->createPeriodicTask(
2022-11-03 22:59:51 +01:00
"CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
2023-02-10 18:07:44 +01:00
result = coreCtrlTask->addComponent(objects::CORE_CONTROLLER);
2022-11-03 22:59:51 +01:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER);
2022-11-03 22:59:51 +01:00
}
2022-01-18 11:41:19 +01:00
/* TMTC Distribution */
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
2022-10-12 13:29:38 +02:00
"DIST", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
2022-12-02 13:55:19 +01:00
#if OBSW_ADD_TCPIP_SERVERS == 1
#if OBSW_ADD_TMTC_UDP_SERVER == 1
result = tmTcDistributor->addComponent(objects::UDP_TMTC_SERVER);
2022-10-12 13:29:38 +02:00
if (result != returnvalue::OK) {
2022-12-02 13:55:19 +01:00
scheduling::printAddObjectError("UDP_TMTC_SERVER", objects::UDP_TMTC_SERVER);
2022-10-12 13:29:38 +02:00
}
2022-12-02 13:55:19 +01:00
#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
2022-10-12 13:29:38 +02:00
#endif
2022-01-18 11:41:19 +01:00
result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR);
2022-01-18 11:41:19 +01:00
}
result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR);
2022-01-18 11:41:19 +01:00
}
2022-09-16 18:10:23 +02:00
result = tmTcDistributor->addComponent(objects::CFDP_DISTRIBUTOR);
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("CFDP_DISTRIBUTOR", objects::CFDP_DISTRIBUTOR);
2022-09-16 18:10:23 +02:00
}
2022-12-02 13:55:19 +01:00
#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);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-12-02 13:55:19 +01:00
scheduling::printAddObjectError("UDP_POLLING", objects::TCP_TMTC_POLLING_TASK);
2022-01-18 11:41:19 +01:00
}
2021-09-28 14:58:12 +02:00
#endif
2022-12-02 13:55:19 +01:00
#endif
2023-02-10 18:07:44 +01:00
PeriodicTaskIF* genericSysTask = factory->createPeriodicTask(
"SYSTEM_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc);
result = genericSysTask->addComponent(objects::EIVE_SYSTEM);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("EIVE_SYSTEM", objects::EIVE_SYSTEM);
}
result = genericSysTask->addComponent(objects::COM_SUBSYSTEM);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("COM_SUBSYSTEM", objects::COM_SUBSYSTEM);
}
2023-03-01 18:06:36 +01:00
result = genericSysTask->addComponent(objects::SYRLINKS_ASSY);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("SYRLINKS_ASSY", objects::SYRLINKS_ASSY);
2023-02-10 18:07:44 +01:00
}
result = genericSysTask->addComponent(objects::PL_SUBSYSTEM);
2023-01-27 15:19:09 +01:00
if (result != returnvalue::OK) {
2023-02-10 18:07:44 +01:00
scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM);
2023-01-27 15:19:09 +01:00
}
2023-02-14 11:32:03 +01:00
result = genericSysTask->addComponent(objects::INTERNAL_ERROR_REPORTER);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER);
}
result = genericSysTask->addComponent(objects::PUS_SERVICE_17_TEST);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST);
}
2023-02-02 17:06:26 +01:00
2023-01-27 15:19:09 +01:00
#if OBSW_ADD_CCSDS_IP_CORES == 1
2023-02-10 18:07:44 +01:00
result = genericSysTask->addComponent(objects::CCSDS_HANDLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER);
2022-01-18 11:41:19 +01:00
}
2022-11-03 22:59:51 +01:00
// Runs in IRQ mode, frequency does not really matter
2022-01-18 11:41:19 +01:00
PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask(
2022-11-02 19:15:07 +01:00
"PDEC_HANDLER", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER);
2022-01-18 11:41:19 +01:00
}
2023-03-09 20:25:43 +01:00
2023-03-10 02:05:51 +01:00
#endif /* OBSW_ADD_CCSDS_IP_CORE == 1 */
2023-03-09 20:25:43 +01:00
// All the TM store tasks run in permanent loops, frequency does not matter
PeriodicTaskIF* liveTmTask =
2023-03-10 19:42:36 +01:00
factory->createPeriodicTask("LIVE_TM", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
2023-03-09 20:25:43 +01:00
result = liveTmTask->addComponent(objects::LIVE_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("LIVE_TM", objects::LIVE_TM_TASK);
}
PeriodicTaskIF* logTmTask = factory->createPeriodicTask(
2023-03-10 19:42:36 +01:00
"LOG_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
2023-03-09 20:25:43 +01:00
result = logTmTask->addComponent(objects::LOG_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("LOG_STORE_AND_TM", objects::LOG_STORE_AND_TM_TASK);
}
PeriodicTaskIF* hkTmTask = factory->createPeriodicTask(
2023-03-10 19:42:36 +01:00
"HK_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
2023-03-09 20:25:43 +01:00
result = hkTmTask->addComponent(objects::HK_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("HK_STORE_AND_TM", objects::HK_STORE_AND_TM_TASK);
}
PeriodicTaskIF* cfdpTmTask = factory->createPeriodicTask(
2023-03-10 19:42:36 +01:00
"CFDP_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
2023-03-09 20:25:43 +01:00
result = cfdpTmTask->addComponent(objects::CFDP_STORE_AND_TM_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("CFDP_STORE_AND_TM", objects::CFDP_STORE_AND_TM_TASK);
}
2021-09-29 14:47:20 +02:00
2022-09-16 17:28:43 +02:00
#if OBSW_ADD_CFDP_COMPONENTS == 1
PeriodicTaskIF* cfdpTask = factory->createPeriodicTask(
2022-09-16 18:10:23 +02:00
"CFDP Handler", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
2022-09-16 17:28:43 +02:00
result = cfdpTask->addComponent(objects::CFDP_HANDLER);
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("CFDP Handler", objects::CFDP_HANDLER);
2022-09-16 17:28:43 +02:00
}
#endif
2023-02-06 10:20:22 +01:00
PeriodicTaskIF* gpsTask = factory->createPeriodicTask(
"GPS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
result = gpsTask->addComponent(objects::GPS_CONTROLLER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("GPS_CTRL", objects::GPS_CONTROLLER);
2022-01-18 11:41:19 +01:00
}
2022-01-17 11:38:21 +01:00
2023-02-26 14:55:33 +01:00
#if OBSW_ADD_ACS_BOARD == 1
PeriodicTaskIF* acsBrdPolling = factory->createPeriodicTask(
"ACS_BOARD_POLLING", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
result = acsBrdPolling->addComponent(objects::ACS_BOARD_POLLING_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("ACS_BOARD_POLLING", objects::ACS_BOARD_POLLING_TASK);
}
#endif
2023-02-16 16:08:17 +01:00
#if OBSW_ADD_RW == 1
PeriodicTaskIF* rwPolling = factory->createPeriodicTask(
2023-02-20 19:08:04 +01:00
"RW_POLLING_TASK", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
2023-02-16 17:57:21 +01:00
result = rwPolling->addComponent(objects::RW_POLLING_TASK);
2023-02-16 16:08:17 +01:00
if (result != returnvalue::OK) {
2023-02-16 17:57:21 +01:00
scheduling::printAddObjectError("RW_POLLING_TASK", objects::RW_POLLING_TASK);
2023-02-16 16:08:17 +01:00
}
#endif
2023-02-19 12:25:26 +01:00
#if OBSW_ADD_MGT == 1
PeriodicTaskIF* imtqPolling = factory->createPeriodicTask(
2023-02-20 19:08:04 +01:00
"IMTQ_POLLING_TASK", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
2023-02-19 12:25:26 +01:00
result = imtqPolling->addComponent(objects::IMTQ_POLLING);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("IMTQ_POLLING_TASK", objects::IMTQ_POLLING);
}
#endif
2023-02-16 16:08:17 +01:00
2023-03-01 16:36:21 +01:00
#if OBSW_ADD_SUN_SENSORS == 1
PeriodicTaskIF* susPolling = factory->createPeriodicTask(
"SUS_POLLING_TASK", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
result = susPolling->addComponent(objects::SUS_POLLING_TASK);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("SUS_POLLING_TASK", objects::SUS_POLLING_TASK);
}
#endif
2022-10-12 13:29:38 +02:00
PeriodicTaskIF* acsSysTask = factory->createPeriodicTask(
2023-02-10 18:07:44 +01:00
"ACS_SYS_TASK", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc);
result = acsSysTask->addComponent(objects::ACS_SUBSYSTEM);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("ACS_SUBSYSTEM", objects::ACS_SUBSYSTEM);
}
2023-03-02 16:09:49 +01:00
result = acsSysTask->addComponent(objects::IMTQ_ASSY);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("IMTQ_ASSY", objects::IMTQ_ASSY);
}
2022-10-12 13:29:38 +02:00
result = acsSysTask->addComponent(objects::ACS_BOARD_ASS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("ACS_BOARD_ASS", objects::ACS_BOARD_ASS);
2022-03-22 10:15:04 +01:00
}
2023-03-02 17:08:44 +01:00
result = acsSysTask->addComponent(objects::RW_ASSY);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2023-03-02 17:08:44 +01:00
scheduling::printAddObjectError("RW_ASS", objects::RW_ASSY);
2022-05-11 01:02:29 +02:00
}
2022-10-12 13:29:38 +02:00
result = acsSysTask->addComponent(objects::SUS_BOARD_ASS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("SUS_BOARD_ASS", objects::SUS_BOARD_ASS);
2022-03-04 16:03:57 +01:00
}
2023-03-06 15:51:53 +01:00
result = acsSysTask->addComponent(objects::STR_ASSY);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("STR_ASSY", objects::STR_ASSY);
}
2022-05-14 09:41:28 +02:00
2022-10-12 13:21:58 +02:00
PeriodicTaskIF* tcsSystemTask = factory->createPeriodicTask(
2023-02-13 15:37:42 +01:00
"TCS_TASK", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc);
scheduling::scheduleRtdSensors(tcsSystemTask);
2023-01-23 11:31:15 +01:00
result = tcsSystemTask->addComponent(objects::TCS_SUBSYSTEM);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("TCS_SUBSYSTEM", objects::TCS_SUBSYSTEM);
}
2022-10-12 13:21:58 +02:00
result = tcsSystemTask->addComponent(objects::TCS_BOARD_ASS);
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("TCS_BOARD_ASS", objects::TCS_BOARD_ASS);
2022-10-12 13:21:58 +02:00
}
2022-09-16 14:01:54 +02:00
#if OBSW_ADD_TCS_CTRL == 1
2022-10-12 13:21:58 +02:00
result = tcsSystemTask->addComponent(objects::THERMAL_CONTROLLER);
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("THERMAL_CONTROLLER", objects::THERMAL_CONTROLLER);
2022-10-12 13:21:58 +02:00
}
2022-09-16 14:01:54 +02:00
#endif
2022-10-26 15:47:23 +02:00
#if OBSW_ADD_HEATERS == 1
2022-10-12 13:21:58 +02:00
result = tcsSystemTask->addComponent(objects::HEATER_HANDLER);
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("HEATER_HANDLER", objects::HEATER_HANDLER);
2022-10-12 13:21:58 +02:00
}
2022-10-26 15:47:23 +02:00
#endif
2022-10-10 17:40:30 +02: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) {
2022-11-16 15:03:10 +01:00
scheduling::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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PLOC_MPSOC_HELPER", objects::PLOC_MPSOC_HELPER);
2022-03-16 17:00:07 +01:00
}
#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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER);
2022-04-10 18:46:39 +02:00
}
#endif /* OBSW_ADD_PLOC_SUPERVISOR */
PeriodicTaskIF* plTask = factory->createPeriodicTask(
2023-02-14 11:32:03 +01:00
"PL_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
2022-11-10 14:08:44 +01:00
plTask->addComponent(objects::CAM_SWITCHER);
2023-02-14 11:32:03 +01:00
scheduling::addMpsocSupvHandlers(plTask);
scheduling::scheduleScexDev(plTask);
#if OBSW_ADD_SCEX_DEVICE == 1
PeriodicTaskIF* scexReaderTask;
2023-02-14 11:32:03 +01:00
scheduling::scheduleScexReader(*factory, scexReaderTask);
#endif
2021-05-16 19:22:04 +02:00
2022-01-18 11:41:19 +01:00
std::vector<PeriodicTaskIF*> pusTasks;
createPusTasks(*factory, missedDeadlineFunc, pusTasks);
std::vector<PeriodicTaskIF*> pstTasks;
2023-02-08 16:45:19 +01:00
AcsPstCfg cfg;
createPstTasks(*factory, missedDeadlineFunc, pstTasks, cfg);
2021-09-13 18:07:07 +02:00
#if OBSW_ADD_TEST_CODE == 1
2022-11-10 14:08:44 +01:00
#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) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE);
2022-11-10 14:08:44 +01:00
}
#endif
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
2022-12-02 13:55:19 +01:00
#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
2021-09-28 14:58:12 +02:00
#endif
2023-02-10 18:07:44 +01:00
genericSysTask->startTask();
#if OBSW_ADD_CCSDS_IP_CORES == 1
2022-01-18 11:41:19 +01:00
pdecHandlerTask->startTask();
2023-03-10 02:05:51 +01:00
#endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */
2023-03-09 20:25:43 +01:00
liveTmTask->startTask();
logTmTask->startTask();
hkTmTask->startTask();
cfdpTmTask->startTask();
2023-02-10 18:07:44 +01:00
coreCtrlTask->startTask();
2022-10-26 15:47:23 +02:00
#if OBSW_ADD_SA_DEPL == 1
2022-10-13 18:15:28 +02:00
solarArrayDeplTask->startTask();
2022-10-26 15:47:23 +02:00
#endif
2023-02-26 14:55:33 +01:00
#if OBSW_ADD_ACS_BOARD == 1
acsBrdPolling->startTask();
#endif
2023-02-19 12:25:26 +01:00
#if OBSW_ADD_MGT == 1
imtqPolling->startTask();
#endif
2023-03-01 16:36:21 +01:00
#if OBSW_ADD_SUN_SENSORS == 1
susPolling->startTask();
#endif
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");
#if OBSW_ADD_SCEX_DEVICE == 1
scexReaderTask->startTask();
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-09-16 17:28:43 +02:00
#if OBSW_ADD_CFDP_COMPONENTS == 1
cfdpTask->startTask();
#endif
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 */
2023-02-16 16:08:17 +01:00
#if OBSW_ADD_RW == 1
rwPolling->startTask();
#endif
2023-02-06 10:20:22 +01:00
gpsTask->startTask();
2022-10-12 13:29:38 +02:00
acsSysTask->startTask();
2022-10-26 15:47:23 +02:00
if (not tcsSystemTask->isEmpty()) {
tcsSystemTask->startTask();
}
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-11-30 18:08:16 +01:00
plTask->startTask();
#if OBSW_ADD_TEST_CODE == 1
taskStarter(testTasks, "Test task vector");
#endif
2022-01-18 11:41:19 +01:00
sif::info << "Tasks started.." << std::endl;
2021-07-19 13:15:45 +02:00
}
2022-11-25 11:04:33 +01:00
void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
2023-02-08 16:45:19 +01:00
std::vector<PeriodicTaskIF*>& taskVec, AcsPstCfg cfg) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2023-02-02 17:06:26 +01:00
#ifdef RELEASE_BUILD
static constexpr float acsPstPeriod = 0.4;
#else
2023-02-23 17:06:36 +01:00
static constexpr float acsPstPeriod = 0.4;
#endif
2023-02-14 10:59:35 +01:00
FixedTimeslotTaskIF* acsTcsPst = factory.createFixedTimeslotTask(
2023-02-20 19:08:04 +01:00
"ACS_TCS_PST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc);
2023-02-14 10:59:35 +01:00
result = pst::pstTcsAndAcs(acsTcsPst, cfg);
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) {
2023-02-02 17:06:26 +01:00
sif::warning << "scheduling::initTasks: ACS PST is empty" << std::endl;
2022-03-14 09:38:58 +01:00
} else {
2023-02-02 17:06:26 +01:00
sif::error << "scheduling::initTasks: Creating ACS PST failed!" << std::endl;
2022-01-18 11:41:19 +01:00
}
} else {
2023-02-14 10:59:35 +01:00
taskVec.push_back(acsTcsPst);
2022-01-18 11:41:19 +01:00
}
2021-07-19 13:15:45 +02:00
2023-02-02 17:06:26 +01:00
/* Polling Sequence Table Default */
#if OBSW_ADD_SPI_TEST_CODE == 0
2023-03-13 11:34:51 +01:00
FixedTimeslotTaskIF* syrlinksPst = factory.createFixedTimeslotTask(
"SYRLINKS", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
result = pst::pstSyrlinks(syrlinksPst);
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) {
2022-11-25 11:04:33 +01:00
sif::warning << "scheduling::initTasks: SPI PST is empty" << std::endl;
2022-05-05 02:00:56 +02:00
} else {
2022-11-25 11:04:33 +01:00
sif::error << "scheduling::initTasks: Creating SPI PST failed!" << std::endl;
2022-05-05 02:00:56 +02:00
}
} else {
2023-03-13 11:34:51 +01:00
taskVec.push_back(syrlinksPst);
2022-05-05 02:00:56 +02:00
}
#endif
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(
2023-03-14 13:12:42 +01:00
"I2C_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.4, missedDeadlineFunc);
2023-03-17 16:27:00 +01:00
result = pst::pstI2cProcessingSystem(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) {
2022-11-25 11:04:33 +01:00
sif::warning << "scheduling::initTasks: I2C PST is empty" << std::endl;
2022-03-14 09:38:58 +01:00
} else {
2022-11-25 11:04:33 +01:00
sif::error << "scheduling::initTasks: Creating I2C PST failed!" << std::endl;
2022-03-14 09:38:58 +01:00
}
} 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
FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask(
2023-03-14 13:12:42 +01:00
"GS_PST_TASK", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
2022-01-18 11:41:19 +01:00
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) {
2022-11-25 11:04:33 +01:00
sif::error << "scheduling::initTasks: GomSpace PST initialization failed!" << std::endl;
2022-03-14 09:38:58 +01:00
}
2022-01-18 11:41:19 +01:00
}
taskVec.push_back(gomSpacePstTask);
2021-07-19 13:15:45 +02:00
}
2022-11-25 11:04:33 +01:00
void scheduling::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 */
2023-02-14 11:32:03 +01:00
PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask(
"PUS_HIGH_PRIO", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
result = pusHighPrio->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION);
2022-01-18 11:41:19 +01:00
}
2023-02-14 11:32:03 +01:00
result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING);
2022-01-18 11:41:19 +01:00
}
2023-02-14 11:32:03 +01:00
result = pusHighPrio->addComponent(objects::EVENT_MANAGER);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER);
2022-01-18 11:41:19 +01:00
}
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT);
2022-01-18 11:41:19 +01:00
}
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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING);
2022-05-24 15:21:37 +02:00
}
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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
2022-01-18 11:41:19 +01:00
}
2023-03-07 15:34:08 +01:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_15_TM_STORAGE);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("PUS_15", objects::PUS_SERVICE_15_TM_STORAGE);
}
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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER);
2022-05-24 15:21:37 +02:00
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-11-16 15:03:10 +01:00
scheduling::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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT);
2022-01-18 11:41:19 +01:00
}
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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH);
2022-05-12 19:22:20 +02:00
}
2023-02-14 11:32:03 +01:00
result = pusMedPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
2022-11-02 19:35:35 +01:00
if (result != returnvalue::OK) {
2023-02-14 11:32:03 +01:00
scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
2022-11-02 19:35:35 +01:00
}
2022-01-18 11:41:19 +01:00
taskVec.push_back(pusMedPrio);
2021-07-19 13:15:45 +02:00
}
2022-11-25 11:04:33 +01:00
void scheduling::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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("TEST_TASK", objects::TEST_TASK);
2022-01-18 11:41:19 +01:00
}
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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("SPI_TEST", objects::SPI_TEST);
2022-01-18 11:41:19 +01:00
}
#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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("I2C_TEST", objects::I2C_TEST);
2022-02-03 13:37:48 +01:00
}
#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-11-16 15:03:10 +01:00
scheduling::printAddObjectError("UART_TEST", objects::UART_TEST);
2022-02-04 17:48:05 +01:00
}
#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
**/