2020-08-13 20:53:35 +02:00
|
|
|
#include "../../tasks/TaskFactory.h"
|
|
|
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
2018-07-13 15:56:37 +02:00
|
|
|
|
|
|
|
#include "PeriodicTask.h"
|
|
|
|
#include "FixedTimeslotTask.h"
|
|
|
|
|
2019-08-28 14:50:24 +02:00
|
|
|
|
2018-07-13 15:56:37 +02:00
|
|
|
TaskFactory* TaskFactory::factoryInstance = new TaskFactory();
|
|
|
|
|
|
|
|
TaskFactory::~TaskFactory() {
|
|
|
|
}
|
|
|
|
|
|
|
|
TaskFactory* TaskFactory::instance() {
|
|
|
|
return TaskFactory::factoryInstance;
|
|
|
|
}
|
2019-08-28 14:50:24 +02:00
|
|
|
/***
|
|
|
|
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
2020-02-15 15:37:00 +01:00
|
|
|
* High taskPriority_ number means high priority.
|
2019-08-28 14:50:24 +02:00
|
|
|
*/
|
2018-07-13 15:56:37 +02:00
|
|
|
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
|
|
|
|
TaskPriority taskPriority_, TaskStackSize stackSize_,
|
|
|
|
TaskPeriod period_,
|
|
|
|
TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
|
|
|
return (PeriodicTaskIF*) (new PeriodicTask(name_, taskPriority_, stackSize_,
|
|
|
|
period_, deadLineMissedFunction_));
|
|
|
|
}
|
2019-08-28 14:50:24 +02: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_) {
|
|
|
|
return (FixedTimeslotTaskIF*) (new FixedTimeslotTask(name_, taskPriority_,
|
|
|
|
stackSize_, period_, deadLineMissedFunction_));
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
|
|
|
|
if (task == NULL) {
|
|
|
|
//delete self
|
|
|
|
vTaskDelete(NULL);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
TaskFactory::TaskFactory() {
|
|
|
|
}
|