2022-05-18 14:32:35 +02:00
|
|
|
#ifndef FSFW_SRC_FSFW_TASKS_PERIODICTASKBASE_H_
|
|
|
|
#define FSFW_SRC_FSFW_TASKS_PERIODICTASKBASE_H_
|
|
|
|
|
2022-05-18 15:42:18 +02:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-05-18 14:32:35 +02:00
|
|
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
|
|
|
#include "fsfw/tasks/definitions.h"
|
|
|
|
|
|
|
|
class ExecutableObjectIF;
|
|
|
|
|
2022-05-18 15:42:18 +02:00
|
|
|
class PeriodicTaskBase : public PeriodicTaskIF {
|
|
|
|
public:
|
2022-05-19 00:44:34 +02:00
|
|
|
explicit PeriodicTaskBase(TaskPeriod period,
|
|
|
|
TaskDeadlineMissedFunction deadlineMissedFunc = nullptr);
|
2022-05-18 14:32:35 +02:00
|
|
|
|
|
|
|
ReturnValue_t addComponent(object_id_t object, uint8_t opCode) override;
|
|
|
|
ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) override;
|
|
|
|
|
2022-05-30 12:12:07 +02:00
|
|
|
ReturnValue_t addComponent(object_id_t object) override;
|
|
|
|
ReturnValue_t addComponent(ExecutableObjectIF* object) override;
|
|
|
|
|
2022-05-19 00:44:34 +02:00
|
|
|
[[nodiscard]] uint32_t getPeriodMs() const override;
|
2022-05-18 14:32:35 +02:00
|
|
|
|
2022-05-19 00:44:34 +02:00
|
|
|
[[nodiscard]] bool isEmpty() const override;
|
2022-05-18 14:32:35 +02:00
|
|
|
|
|
|
|
ReturnValue_t initObjsAfterTaskCreation();
|
|
|
|
|
2022-05-18 15:42:18 +02:00
|
|
|
protected:
|
2022-05-18 14:32:35 +02:00
|
|
|
//! Typedef for the List of objects. Will contain the objects to execute and their respective
|
|
|
|
//! operation codes
|
|
|
|
using ObjectList = std::vector<std::pair<ExecutableObjectIF*, uint8_t>>;
|
|
|
|
/**
|
|
|
|
* @brief This attribute holds a list of objects to be executed.
|
|
|
|
*/
|
|
|
|
ObjectList objectList;
|
|
|
|
|
|
|
|
/**
|
2022-05-18 15:42:18 +02:00
|
|
|
* @brief Period of task in floating point seconds
|
2022-05-18 14:32:35 +02:00
|
|
|
*/
|
2022-05-18 15:42:18 +02:00
|
|
|
TaskPeriod period;
|
2022-05-18 14:32:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The pointer to the deadline-missed function.
|
2022-05-18 15:42:18 +02:00
|
|
|
* @details
|
|
|
|
* This pointer stores the function that is executed if the task's deadline
|
|
|
|
* is missed. So, each may react individually on a timing failure.
|
|
|
|
* The pointer may be NULL, then nothing happens on missing the deadline.
|
|
|
|
* The deadline is equal to the next execution of the periodic task.
|
2022-05-18 14:32:35 +02:00
|
|
|
*/
|
2022-05-18 15:42:18 +02:00
|
|
|
TaskDeadlineMissedFunction dlmFunc = nullptr;
|
2022-05-18 14:32:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FSFW_SRC_FSFW_TASKS_PERIODICTASKBASE_H_ */
|