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
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include <cstddef>
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../objectmanager/SystemObjectIF.h"
|
|
|
|
#include "../timemanager/Clock.h"
|
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.
|
2022-02-02 10:29:30 +01:00
|
|
|
*/
|
2018-07-12 16:29:32 +02:00
|
|
|
class PeriodicTaskIF {
|
2022-02-02 10:29:30 +01:00
|
|
|
public:
|
|
|
|
static const size_t MINIMUM_STACK_SIZE;
|
|
|
|
/**
|
|
|
|
* @brief A virtual destructor as it is mandatory for interfaces.
|
|
|
|
*/
|
|
|
|
virtual ~PeriodicTaskIF() {}
|
|
|
|
/**
|
|
|
|
* @brief With the startTask method, a created task can be started
|
|
|
|
* for the first time.
|
|
|
|
*/
|
|
|
|
virtual ReturnValue_t startTask() = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
/**
|
2022-03-28 13:50:42 +02:00
|
|
|
* Add a component (object) to a periodic task.
|
2022-02-02 10:29:30 +01:00
|
|
|
* @param object
|
2022-03-28 13:50:42 +02:00
|
|
|
* Add an object to the task. The object needs to implement ExecutableObjectIF
|
2022-02-02 10:29:30 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2022-05-14 09:40:31 +02:00
|
|
|
virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0) {
|
2022-02-02 10:29:30 +01:00
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
};
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-03-28 13:50:42 +02:00
|
|
|
/**
|
|
|
|
* Add an object to a periodic task.
|
|
|
|
* @param object
|
|
|
|
* Add an object to the task.
|
|
|
|
* @return
|
|
|
|
*/
|
2022-05-14 09:40:31 +02:00
|
|
|
virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode = 0) {
|
2022-03-28 13:50:42 +02:00
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
};
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
virtual ReturnValue_t sleepFor(uint32_t ms) = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
virtual uint32_t getPeriodMs() const = 0;
|
2022-05-14 09:40:31 +02:00
|
|
|
|
|
|
|
virtual bool isEmpty() const = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PERIODICTASKIF_H_ */
|