2018-07-12 16:29:32 +02:00
|
|
|
#ifndef FRAMEWORK_TASKS_TASKFACTORY_H_
|
|
|
|
#define FRAMEWORK_TASKS_TASKFACTORY_H_
|
|
|
|
|
2020-05-01 14:49:52 +02:00
|
|
|
#include <cstdlib>
|
2018-07-12 16:29:32 +02:00
|
|
|
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
|
|
|
#include <framework/tasks/Typedef.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Singleton Class that produces Tasks.
|
|
|
|
*/
|
2018-07-13 15:56:37 +02:00
|
|
|
class TaskFactory {
|
2018-07-12 16:29:32 +02:00
|
|
|
public:
|
|
|
|
virtual ~TaskFactory();
|
|
|
|
/**
|
|
|
|
* Returns the single instance of TaskFactory.
|
|
|
|
* The implementation of #instance is found in its subclasses.
|
|
|
|
* Thus, we choose link-time variability of the instance.
|
|
|
|
*/
|
|
|
|
static TaskFactory* instance();
|
|
|
|
|
|
|
|
/**
|
2020-05-31 00:23:38 +02:00
|
|
|
* Generic interface to create a periodic task
|
|
|
|
* @param name_ Name of the task
|
|
|
|
* @param taskPriority_ Priority of the task
|
|
|
|
* @param stackSize_ Stack size if the task
|
|
|
|
* @param periodInSeconds_ Period in seconds
|
|
|
|
* @param deadLineMissedFunction_ This function is called if a deadline was
|
|
|
|
* missed
|
|
|
|
* @return Pointer to the created periodic task class
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
2018-07-13 15:56:37 +02:00
|
|
|
PeriodicTaskIF* createPeriodicTask(TaskName name_,
|
|
|
|
TaskPriority taskPriority_, TaskStackSize stackSize_,
|
|
|
|
TaskPeriod periodInSeconds_,
|
|
|
|
TaskDeadlineMissedFunction deadLineMissedFunction_);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
/**
|
2020-05-31 00:23:38 +02:00
|
|
|
* Generic interface to create a fixed timeslot task
|
|
|
|
* @param name_ Name of the task
|
|
|
|
* @param taskPriority_ Priority of the task
|
|
|
|
* @param stackSize_ Stack size if the task
|
|
|
|
* @param periodInSeconds_ Period in seconds
|
|
|
|
* @param deadLineMissedFunction_ This function is called if a deadline was
|
|
|
|
* missed
|
|
|
|
* @return Pointer to the created periodic task class
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
2018-07-13 15:56:37 +02:00
|
|
|
FixedTimeslotTaskIF* createFixedTimeslotTask(TaskName name_,
|
|
|
|
TaskPriority taskPriority_, TaskStackSize stackSize_,
|
|
|
|
TaskPeriod periodInSeconds_,
|
|
|
|
TaskDeadlineMissedFunction deadLineMissedFunction_);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be called to delete a task
|
2020-05-01 14:49:52 +02:00
|
|
|
* @param task The pointer to the task that shall be deleted,
|
|
|
|
* NULL specifies current Task
|
2018-07-12 16:29:32 +02:00
|
|
|
* @return Success of deletion
|
|
|
|
*/
|
2018-07-13 15:56:37 +02:00
|
|
|
static ReturnValue_t deleteTask(PeriodicTaskIF* task = NULL);
|
|
|
|
|
2020-05-03 00:48:18 +02:00
|
|
|
/**
|
|
|
|
* Function to be called to delay current task
|
|
|
|
* @param delay The delay in milliseconds
|
|
|
|
* @return Success of deletion
|
|
|
|
*/
|
|
|
|
static ReturnValue_t delayTask(uint32_t delayMs);
|
2018-07-12 16:29:32 +02:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* External instantiation is not allowed.
|
|
|
|
*/
|
|
|
|
TaskFactory();
|
|
|
|
static TaskFactory* factoryInstance;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FRAMEWORK_TASKS_TASKFACTORY_H_ */
|