2020-06-23 01:14:28 +02:00
|
|
|
#ifndef FRAMEWORK_TASK_PERIODICTASKIF_H_
|
|
|
|
#define FRAMEWORK_TASK_PERIODICTASKIF_H_
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
#include <framework/objectmanager/SystemObjectIF.h>
|
2020-06-23 01:14:28 +02:00
|
|
|
#include <framework/timemanager/Clock.h>
|
2018-07-13 18:28:26 +02:00
|
|
|
#include <cstddef>
|
2018-07-12 16:29:32 +02:00
|
|
|
class ExecutableObjectIF;
|
2020-06-23 01:14:28 +02:00
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
|
|
|
* New version of TaskIF
|
|
|
|
* Follows RAII principles, i.e. there's no create or delete method.
|
|
|
|
* Minimalistic.
|
|
|
|
*/
|
|
|
|
class PeriodicTaskIF {
|
|
|
|
public:
|
2018-07-13 18:28:26 +02:00
|
|
|
static const size_t MINIMUM_STACK_SIZE;
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
|
|
|
* @brief A virtual destructor as it is mandatory for interfaces.
|
|
|
|
*/
|
|
|
|
virtual ~PeriodicTaskIF() { }
|
|
|
|
/**
|
2020-06-23 01:14:28 +02:00
|
|
|
* @brief With the startTask method, a created task can be started
|
|
|
|
* for the first time.
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
|
|
|
virtual ReturnValue_t startTask() = 0;
|
|
|
|
|
2020-06-23 01:14:28 +02:00
|
|
|
/**
|
|
|
|
* Add a component (object) to a periodic task. The pointer to the
|
|
|
|
* task can be set optionally
|
|
|
|
* @param object
|
|
|
|
* Add an object to the task. The most important case is to add an
|
|
|
|
* executable object with a function which will be called regularly
|
|
|
|
* (see ExecutableObjectIF)
|
|
|
|
* @param setTaskIF
|
|
|
|
* Can be used to specify whether the task object pointer is passed
|
|
|
|
* to the component.
|
|
|
|
* @return
|
|
|
|
*/
|
2020-08-04 15:19:31 +02:00
|
|
|
virtual ReturnValue_t addComponent(object_id_t object) {
|
2020-06-23 01:14:28 +02:00
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
};
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
virtual ReturnValue_t sleepFor(uint32_t ms) = 0;
|
|
|
|
|
|
|
|
virtual uint32_t getPeriodMs() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* PERIODICTASKIF_H_ */
|