fsfw/src/fsfw/osal/freertos/TaskFactory.cpp

59 lines
1.6 KiB
C++
Raw Normal View History

2021-07-14 00:54:39 +02:00
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/osal/freertos/PeriodicTask.h"
#include "fsfw/osal/freertos/FixedTimeslotTask.h"
2018-07-13 15:56:37 +02:00
2021-07-14 00:54:39 +02:00
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
2018-07-13 15:56:37 +02:00
TaskFactory* TaskFactory::factoryInstance = new TaskFactory();
TaskFactory::~TaskFactory() {
}
TaskFactory* TaskFactory::instance() {
return TaskFactory::factoryInstance;
}
2020-12-14 11:17:22 +01:00
2018-07-13 15:56:37 +02:00
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
TaskPriority taskPriority_, TaskStackSize stackSize_,
TaskPeriod period_,
TaskDeadlineMissedFunction deadLineMissedFunction_) {
2020-12-14 11:17:22 +01:00
return dynamic_cast<PeriodicTaskIF*>(new PeriodicTask(name_, taskPriority_,
stackSize_, period_, deadLineMissedFunction_));
2018-07-13 15:56:37 +02:00
}
2020-12-14 11:17:22 +01:00
/**
* Keep in Mind that you need to call before this vTaskStartScheduler()!
*/
2018-07-13 15:56:37 +02:00
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,
TaskPriority taskPriority_, TaskStackSize stackSize_,
TaskPeriod period_,
TaskDeadlineMissedFunction deadLineMissedFunction_) {
2020-12-14 11:17:22 +01:00
return dynamic_cast<FixedTimeslotTaskIF*>(new FixedTimeslotTask(name_,
taskPriority_,stackSize_, period_, deadLineMissedFunction_));
2018-07-13 15:56:37 +02:00
}
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
2020-12-14 11:17:22 +01:00
if (task == nullptr) {
2018-07-13 15:56:37 +02:00
//delete self
2020-12-14 11:17:22 +01:00
vTaskDelete(nullptr);
2018-07-13 15:56:37 +02:00
return HasReturnvaluesIF::RETURN_OK;
} else {
//TODO not implemented
return HasReturnvaluesIF::RETURN_FAILED;
}
}
ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) {
vTaskDelay(pdMS_TO_TICKS(delayMs));
return HasReturnvaluesIF::RETURN_OK;
}
void TaskFactory::printMissedDeadline() {
/* TODO: Implement */
return;
}
2018-07-13 15:56:37 +02:00
TaskFactory::TaskFactory() {
}