header update

This commit is contained in:
Robin Müller 2020-08-27 16:13:36 +02:00
parent 89d3fe5095
commit 4530b19548

View File

@ -1,128 +1,126 @@
#ifndef FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_ #ifndef FSFW_OSAL_FREERTOS_PERIODICTASK_H_
#define FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_ #define FSFW_OSAL_FREERTOS_PERIODICTASK_H_
#include "../../osal/FreeRTOS/FreeRTOSTaskIF.h" #include "FreeRTOSTaskIF.h"
#include "../../objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include "../../tasks/PeriodicTaskIF.h" #include "../../tasks/PeriodicTaskIF.h"
#include "../../tasks/Typedef.h" #include "../../tasks/Typedef.h"
#include <freertos/FreeRTOS.h>
#include <freertos/FreeRTOS.h> #include <freertos/task.h>
#include <freertos/task.h>
#include <vector>
#include <vector>
class ExecutableObjectIF;
class ExecutableObjectIF;
/**
/** * @brief This class represents a specialized task for
* @brief This class represents a specialized task for * periodic activities of multiple objects.
* periodic activities of multiple objects. * @ingroup task_handling
* @ingroup task_handling */
*/ class PeriodicTask: public PeriodicTaskIF, public FreeRTOSTaskIF {
class PeriodicTask: public PeriodicTaskIF, public FreeRTOSTaskIF { public:
public: /**
/** * Keep in Mind that you need to call before this vTaskStartScheduler()!
* Keep in Mind that you need to call before this vTaskStartScheduler()! * A lot of task parameters are set in "FreeRTOSConfig.h".
* A lot of task parameters are set in "FreeRTOSConfig.h". * @details
* TODO: why does this need to be called before vTaskStartScheduler? * The class is initialized without allocated objects.
* @details * These need to be added with #addComponent.
* The class is initialized without allocated objects. * @param priority
* These need to be added with #addComponent. * Sets the priority of a task. Values depend on freeRTOS configuration,
* @param priority * high number means high priority.
* Sets the priority of a task. Values depend on freeRTOS configuration, * @param stack_size
* high number means high priority. * The stack size reserved by the operating system for the task.
* @param stack_size * @param setPeriod
* The stack size reserved by the operating system for the task. * The length of the period with which the task's
* @param setPeriod * functionality will be executed. It is expressed in clock ticks.
* The length of the period with which the task's * @param setDeadlineMissedFunc
* functionality will be executed. It is expressed in clock ticks. * The function pointer to the deadline missed function that shall
* @param setDeadlineMissedFunc * be assigned.
* The function pointer to the deadline missed function that shall */
* be assigned. PeriodicTask(TaskName name, TaskPriority setPriority,
*/ TaskStackSize setStack, TaskPeriod setPeriod,
PeriodicTask(TaskName name, TaskPriority setPriority, TaskDeadlineMissedFunction deadlineMissedFunc);
TaskStackSize setStack, TaskPeriod setPeriod, /**
TaskDeadlineMissedFunction deadlineMissedFunc); * @brief Currently, the executed object's lifetime is not coupled with
/** * the task object's lifetime, so the destructor is empty.
* @brief Currently, the executed object's lifetime is not coupled with */
* the task object's lifetime, so the destructor is empty. virtual ~PeriodicTask(void);
*/
virtual ~PeriodicTask(void); /**
* @brief The method to start the task.
/** * @details The method starts the task with the respective system call.
* @brief The method to start the task. * Entry point is the taskEntryPoint method described below.
* @details The method starts the task with the respective system call. * The address of the task object is passed as an argument
* Entry point is the taskEntryPoint method described below. * to the system call.
* The address of the task object is passed as an argument */
* to the system call. ReturnValue_t startTask() override;
*/ /**
ReturnValue_t startTask() override; * Adds an object to the list of objects to be executed.
/** * The objects are executed in the order added.
* Adds an object to the list of objects to be executed. * @param object Id of the object to add.
* The objects are executed in the order added. * @return
* @param object Id of the object to add. * -@c RETURN_OK on success
* @return * -@c RETURN_FAILED if the object could not be added.
* -@c RETURN_OK on success */
* -@c RETURN_FAILED if the object could not be added. ReturnValue_t addComponent(object_id_t object) override;
*/
ReturnValue_t addComponent(object_id_t object) override; uint32_t getPeriodMs() const override;
uint32_t getPeriodMs() const override; ReturnValue_t sleepFor(uint32_t ms) override;
ReturnValue_t sleepFor(uint32_t ms) override; TaskHandle_t getTaskHandle() override;
protected:
TaskHandle_t getTaskHandle() override; bool started;
protected: TaskHandle_t handle;
bool started;
TaskHandle_t handle; //! Typedef for the List of objects.
typedef std::vector<ExecutableObjectIF*> ObjectList;
//! Typedef for the List of objects. /**
typedef std::vector<ExecutableObjectIF*> ObjectList; * @brief This attribute holds a list of objects to be executed.
/** */
* @brief This attribute holds a list of objects to be executed. ObjectList objectList;
*/ /**
ObjectList objectList; * @brief The period of the task.
/** * @details
* @brief The period of the task. * The period determines the frequency of the task's execution.
* @details * It is expressed in clock ticks.
* The period determines the frequency of the task's execution. */
* It is expressed in clock ticks. TaskPeriod period;
*/ /**
TaskPeriod period; * @brief The pointer to the deadline-missed function.
/** * @details
* @brief The pointer to the deadline-missed function. * This pointer stores the function that is executed if the task's deadline
* @details * is missed so each may react individually on a timing failure.
* This pointer stores the function that is executed if the task's deadline * The pointer may be NULL, then nothing happens on missing the deadline.
* is missed so each may react individually on a timing failure. * The deadline is equal to the next execution of the periodic task.
* The pointer may be NULL, then nothing happens on missing the deadline. */
* The deadline is equal to the next execution of the periodic task. void (*deadlineMissedFunc)(void);
*/ /**
void (*deadlineMissedFunc)(void); * @brief This is the function executed in the new task's context.
/** * @details
* @brief This is the function executed in the new task's context. * It converts the argument back to the thread object type and copies the
* @details * class instance to the task context. The taskFunctionality method is
* It converts the argument back to the thread object type and copies the * called afterwards.
* class instance to the task context. The taskFunctionality method is * @param A pointer to the task object itself is passed as argument.
* called afterwards. */
* @param A pointer to the task object itself is passed as argument.
*/ static void taskEntryPoint(void* argument);
/**
static void taskEntryPoint(void* argument); * @brief The function containing the actual functionality of the task.
/** * @details
* @brief The function containing the actual functionality of the task. * The method sets and starts the task's period, then enters a loop that is
* @details * repeated as long as the isRunning attribute is true. Within the loop,
* The method sets and starts the task's period, then enters a loop that is * all performOperation methods of the added objects are called.
* repeated as long as the isRunning attribute is true. Within the loop, * Afterwards the checkAndRestartPeriod system call blocks the task until
* all performOperation methods of the added objects are called. * the next period.
* Afterwards the checkAndRestartPeriod system call blocks the task until * On missing the deadline, the deadlineMissedFunction is executed.
* the next period. */
* On missing the deadline, the deadlineMissedFunction is executed. void taskFunctionality(void);
*/
void taskFunctionality(void); void checkMissedDeadline(const TickType_t xLastWakeTime,
const TickType_t interval);
void checkMissedDeadline(const TickType_t xLastWakeTime, void handleMissedDeadline();
const TickType_t interval); };
void handleMissedDeadline();
}; #endif /* FSFW_OSAL_FREERTOS_PERIODICTASK_H_ */
#endif /* PERIODICTASK_H_ */