248 lines
9.9 KiB
C++
248 lines
9.9 KiB
C++
#include "linux/scheduling.h"
|
|
|
|
#include <bsp_hosted/fsfwconfig/pollingsequence/DummyPst.h>
|
|
#include <fsfw/objectmanager/ObjectManager.h>
|
|
#include <fsfw/objectmanager/ObjectManagerIF.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/utility/InitMission.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include "OBSWConfig.h"
|
|
#include "ObjectFactory.h"
|
|
#include "mission/core/scheduling.h"
|
|
#include "scheduling.h"
|
|
|
|
#ifdef LINUX
|
|
ServiceInterfaceStream sif::debug("DEBUG");
|
|
ServiceInterfaceStream sif::info("INFO");
|
|
ServiceInterfaceStream sif::warning("WARNING");
|
|
ServiceInterfaceStream sif::error("ERROR", false, false, true);
|
|
#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;
|
|
/* Instantiate global object manager and also create all objects */
|
|
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
|
|
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();
|
|
if (factory == nullptr) {
|
|
/* Should never happen ! */
|
|
return;
|
|
}
|
|
#if OBSW_PRINT_MISSED_DEADLINES == 1
|
|
void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline;
|
|
#else
|
|
void (*missedDeadlineFunc)(void) = nullptr;
|
|
#endif
|
|
|
|
/* TMTC Distribution */
|
|
PeriodicTaskIF* tmtcDistributor = factory->createPeriodicTask(
|
|
"DIST", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
|
ReturnValue_t result = tmtcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding CCSDS distributor failed" << std::endl;
|
|
}
|
|
result = tmtcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding PUS distributor failed" << std::endl;
|
|
}
|
|
result = tmtcDistributor->addComponent(objects::TM_FUNNEL);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding TM funnel failed" << std::endl;
|
|
}
|
|
result = tmtcDistributor->addComponent(objects::CFDP_DISTRIBUTOR);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding CFDP distributor failed" << std::endl;
|
|
}
|
|
result = tmtcDistributor->addComponent(objects::UDP_TMTC_SERVER);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding UDP server failed" << std::endl;
|
|
}
|
|
result = tmtcDistributor->addComponent(objects::TCP_TMTC_SERVER);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "adding TCP server failed" << std::endl;
|
|
}
|
|
|
|
PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask(
|
|
"UDP_POLLING", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
result = udpPollingTask->addComponent(objects::UDP_TMTC_POLLING_TASK);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "Add component UDP Polling failed" << std::endl;
|
|
}
|
|
PeriodicTaskIF* tcpPollingTask = factory->createPeriodicTask(
|
|
"TCP_POLLING", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
|
result = tcpPollingTask->addComponent(objects::TCP_TMTC_POLLING_TASK);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "Add component UDP Polling failed" << std::endl;
|
|
}
|
|
|
|
/* 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) {
|
|
sif::error << "Object add component failed" << std::endl;
|
|
}
|
|
|
|
PeriodicTaskIF* eventHandling = factory->createPeriodicTask(
|
|
"EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
|
result = eventHandling->addComponent(objects::EVENT_MANAGER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("EVENT_MNGR", objects::EVENT_MANAGER);
|
|
}
|
|
result = eventHandling->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
|
}
|
|
|
|
PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask(
|
|
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
|
}
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT);
|
|
}
|
|
result = pusHighPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING);
|
|
}
|
|
|
|
PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask(
|
|
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT);
|
|
}
|
|
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS);
|
|
}
|
|
|
|
PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask(
|
|
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc);
|
|
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST);
|
|
}
|
|
|
|
PeriodicTaskIF* thermalTask = factory->createPeriodicTask(
|
|
"THERMAL_CTL_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
|
|
result = thermalTask->addComponent(objects::CORE_CONTROLLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("Core controller dummy", objects::CORE_CONTROLLER);
|
|
}
|
|
|
|
result = thermalTask->addComponent(objects::THERMAL_CONTROLLER);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("THERMAL_CONTROLLER", objects::THERMAL_CONTROLLER);
|
|
}
|
|
|
|
FixedTimeslotTaskIF* pstTask = factory->createFixedTimeslotTask(
|
|
"DUMMY_PST", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
|
|
result = dummy_pst::pst(pstTask);
|
|
if (result != returnvalue::OK) {
|
|
sif::error << "Failed to add dummy pst to fixed timeslot task" << std::endl;
|
|
}
|
|
|
|
#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_PLOC_SUPERVISOR == 1
|
|
PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask(
|
|
"PLOC_SUPV_HELPER", 20, 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);
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
result = testTask->addComponent(objects::TEST_TASK);
|
|
if (result != returnvalue::OK) {
|
|
scheduling::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
|
}
|
|
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
|
|
|
PeriodicTaskIF* dummyTask = factory->createPeriodicTask(
|
|
"DUMMY_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
|
|
scheduling::scheduleTmpTempSensors(dummyTask);
|
|
scheduling::scheduleRtdSensors(dummyTask);
|
|
dummyTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF);
|
|
dummyTask->addComponent(objects::SUS_1_N_LOC_XBYFZM_PT_XB);
|
|
dummyTask->addComponent(objects::SUS_2_N_LOC_XFYBZB_PT_YB);
|
|
dummyTask->addComponent(objects::SUS_3_N_LOC_XFYBZF_PT_YF);
|
|
dummyTask->addComponent(objects::SUS_4_N_LOC_XMYFZF_PT_ZF);
|
|
dummyTask->addComponent(objects::SUS_5_N_LOC_XFYMZB_PT_ZB);
|
|
dummyTask->addComponent(objects::SUS_6_R_LOC_XFYBZM_PT_XF);
|
|
dummyTask->addComponent(objects::SUS_7_R_LOC_XBYBZM_PT_XB);
|
|
dummyTask->addComponent(objects::SUS_8_R_LOC_XBYBZB_PT_YB);
|
|
dummyTask->addComponent(objects::SUS_9_R_LOC_XBYBZB_PT_YF);
|
|
dummyTask->addComponent(objects::SUS_10_N_LOC_XMYBZF_PT_ZF);
|
|
dummyTask->addComponent(objects::SUS_11_R_LOC_XBYMZB_PT_ZB);
|
|
|
|
sif::info << "Starting tasks.." << std::endl;
|
|
tmtcDistributor->startTask();
|
|
udpPollingTask->startTask();
|
|
tcpPollingTask->startTask();
|
|
|
|
pusVerification->startTask();
|
|
eventHandling->startTask();
|
|
pusHighPrio->startTask();
|
|
pusMedPrio->startTask();
|
|
pusLowPrio->startTask();
|
|
|
|
pstTask->startTask();
|
|
thermalTask->startTask();
|
|
dummyTask->startTask();
|
|
#if OBSW_ADD_PLOC_SUPERVISOR == 1
|
|
supvHelperTask->startTask();
|
|
#endif
|
|
#if OBSW_ADD_PLOC_SUPERVISOR == 1 || OBSW_ADD_PLOC_MPSOC == 1
|
|
plTask->startTask();
|
|
#endif
|
|
#if OBSW_ADD_CFDP_COMPONENTS == 1
|
|
cfdpTask->startTask();
|
|
#endif
|
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
testTask->startTask();
|
|
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
|
|
|
sif::info << "Tasks started.." << std::endl;
|
|
}
|