2021-01-28 11:28:28 +01:00
|
|
|
#include "FixedTimeslotTask.h"
|
|
|
|
#include "PeriodicTask.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
#include "InitTask.h"
|
2018-07-13 18:28:26 +02:00
|
|
|
#include "RtemsBasic.h"
|
2021-01-28 11:28:28 +01:00
|
|
|
|
|
|
|
#include "../../tasks/TaskFactory.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
//TODO: Different variant than the lazy loading in QueueFactory. What's better and why?
|
|
|
|
TaskFactory* TaskFactory::factoryInstance = new TaskFactory();
|
|
|
|
|
|
|
|
TaskFactory::~TaskFactory() {
|
|
|
|
}
|
|
|
|
|
|
|
|
TaskFactory* TaskFactory::instance() {
|
|
|
|
return TaskFactory::factoryInstance;
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:28:28 +01:00
|
|
|
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_,
|
|
|
|
TaskStackSize stackSize_,TaskPeriod periodInSeconds_,
|
|
|
|
TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
2018-07-12 16:29:32 +02:00
|
|
|
rtems_interval taskPeriod = periodInSeconds_ * Clock::getTicksPerSecond();
|
|
|
|
|
2021-01-28 11:28:28 +01:00
|
|
|
return static_cast<PeriodicTaskIF*>(new PeriodicTask(name_, taskPriority_, stackSize_,
|
|
|
|
taskPeriod,deadLineMissedFunction_));
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:28:28 +01:00
|
|
|
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,
|
|
|
|
TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,
|
|
|
|
TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
2018-07-12 16:29:32 +02:00
|
|
|
rtems_interval taskPeriod = periodInSeconds_ * Clock::getTicksPerSecond();
|
2021-01-28 11:28:28 +01:00
|
|
|
return static_cast<FixedTimeslotTaskIF*>(new FixedTimeslotTask(name_, taskPriority_,
|
|
|
|
stackSize_, taskPeriod, deadLineMissedFunction_));
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
|
|
|
|
//TODO not implemented
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
}
|
|
|
|
|
2018-07-13 18:28:26 +02:00
|
|
|
ReturnValue_t TaskFactory::delayTask(uint32_t delayMs){
|
|
|
|
rtems_task_wake_after(RtemsBasic::convertMsToTicks(delayMs));
|
|
|
|
//Only return value is "RTEMS_SUCCESSFUL - always successful" so it has been neglected
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
TaskFactory::TaskFactory() {
|
|
|
|
}
|