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-05-18 15:42:18 +02:00
|
|
|
#include <cstddef>
|
|
|
|
|
2022-05-18 14:32:35 +02:00
|
|
|
#include "fsfw/objectmanager/SystemObjectIF.h"
|
|
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
2022-02-02 10:29:30 +01: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.
|
|
|
|
*/
|
2022-05-19 00:44:34 +02:00
|
|
|
virtual ~PeriodicTaskIF() = default;
|
2022-02-02 10:29:30 +01:00
|
|
|
/**
|
|
|
|
* @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-05-18 14:32:35 +02:00
|
|
|
* Adds an object to the list of objects to be executed.
|
|
|
|
* The objects are executed in the order added. The object needs to implement
|
|
|
|
* ExecutableObjectIF
|
|
|
|
* @param object Id of the object to add.
|
|
|
|
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
|
2022-02-02 10:29:30 +01:00
|
|
|
*/
|
2022-05-14 09:38:59 +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
|
|
|
/**
|
2022-05-18 14:32:35 +02:00
|
|
|
* Adds an object to the list of objects to be executed.
|
|
|
|
* The objects are executed in the order added.
|
|
|
|
* @param object pointer to the object to add.
|
|
|
|
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
|
2022-03-28 13:50:42 +02:00
|
|
|
*/
|
2022-05-14 09:38:59 +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:38:59 +02:00
|
|
|
|
|
|
|
virtual bool isEmpty() const = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PERIODICTASKIF_H_ */
|