moved timeslot files to task folder
implmented setting task IF for regular periodic tasks
This commit is contained in:
parent
eb4ce980fe
commit
2de811e0af
@ -62,11 +62,6 @@ ReturnValue_t FixedTimeslotTask::startTask() {
|
|||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
||||||
if(slotTimeMs == 0) {
|
|
||||||
// FreeRTOS throws a sanity error for zero values, so we set
|
|
||||||
// the time to one millisecond.
|
|
||||||
slotTimeMs = 1;
|
|
||||||
}
|
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -101,7 +96,9 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
xLastWakeTime = xTaskGetTickCount();
|
xLastWakeTime = xTaskGetTickCount();
|
||||||
|
|
||||||
// wait for first entry's start time
|
// wait for first entry's start time
|
||||||
vTaskDelayUntil(&xLastWakeTime, interval);
|
if(interval > 0) {
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, interval);
|
||||||
|
}
|
||||||
|
|
||||||
/* Enter the loop that defines the task behavior. */
|
/* Enter the loop that defines the task behavior. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -137,3 +134,4 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
|||||||
vTaskDelay(pdMS_TO_TICKS(ms));
|
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
#include <framework/devicehandlers/FixedSlotSequence.h>
|
#include <framework/tasks/FixedSlotSequence.h>
|
||||||
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
|
|
||||||
@ -49,13 +49,13 @@ public:
|
|||||||
static uint32_t deadlineMissedCount;
|
static uint32_t deadlineMissedCount;
|
||||||
|
|
||||||
ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
||||||
int8_t executionStep);
|
int8_t executionStep) override;
|
||||||
|
|
||||||
uint32_t getPeriodMs() const;
|
uint32_t getPeriodMs() const override;
|
||||||
|
|
||||||
ReturnValue_t checkSequence() const;
|
ReturnValue_t checkSequence() const override;
|
||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms);
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
|
@ -70,9 +70,8 @@ void PeriodicTask::taskFunctionality() {
|
|||||||
xLastWakeTime = xTaskGetTickCount();
|
xLastWakeTime = xTaskGetTickCount();
|
||||||
/* Enter the loop that defines the task behavior. */
|
/* Enter the loop that defines the task behavior. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (ObjectList::iterator it = objectList.begin();
|
for (auto const& object: objectList) {
|
||||||
it != objectList.end(); ++it) {
|
object->performOperation();
|
||||||
(*it)->performOperation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If all operations are finished and the difference of the
|
/* If all operations are finished and the difference of the
|
||||||
@ -93,12 +92,17 @@ void PeriodicTask::taskFunctionality() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
ReturnValue_t PeriodicTask::addComponent(object_id_t object, bool setTaskIF) {
|
||||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||||
object);
|
object);
|
||||||
if (newObject == NULL) {
|
if (newObject == nullptr) {
|
||||||
|
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||||
|
"it implement ExecutableObjectIF" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
if(setTaskIF) {
|
||||||
|
newObject->setTaskIF(this);
|
||||||
|
}
|
||||||
objectList.push_back(newObject);
|
objectList.push_back(newObject);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
* The address of the task object is passed as an argument
|
* The address of the task object is passed as an argument
|
||||||
* to the system call.
|
* to the system call.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t startTask(void);
|
ReturnValue_t startTask() override;
|
||||||
/**
|
/**
|
||||||
* Adds an object to the list of objects to be executed.
|
* Adds an object to the list of objects to be executed.
|
||||||
* The objects are executed in the order added.
|
* The objects are executed in the order added.
|
||||||
@ -63,11 +63,12 @@ public:
|
|||||||
* -@c RETURN_OK on success
|
* -@c RETURN_OK on success
|
||||||
* -@c RETURN_FAILED if the object could not be added.
|
* -@c RETURN_FAILED if the object could not be added.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t addComponent(object_id_t object);
|
ReturnValue_t addComponent(object_id_t object,
|
||||||
|
bool setTaskIF = true) override;
|
||||||
|
|
||||||
uint32_t getPeriodMs() const;
|
uint32_t getPeriodMs() const override;
|
||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms);
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
TaskHandle_t handle;
|
TaskHandle_t handle;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define FRAMEWORK_OSAL_HOST_FIXEDTIMESLOTTASK_H_
|
#define FRAMEWORK_OSAL_HOST_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/devicehandlers/FixedSlotSequence.h>
|
#include <framework/tasks/FixedSlotSequence.h>
|
||||||
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
|
|
||||||
|
@ -24,9 +24,14 @@ void* PeriodicPosixTask::taskEntryPoint(void* arg) {
|
|||||||
ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
|
ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
|
||||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||||
object);
|
object);
|
||||||
if (newObject == NULL) {
|
if (newObject == nullptr) {
|
||||||
|
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||||
|
"it implements ExecutableObjectIF" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
if(setTaskIF) {
|
||||||
|
newObject->setTaskIF(this);
|
||||||
|
}
|
||||||
objectList.push_back(newObject);
|
objectList.push_back(newObject);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ public:
|
|||||||
* @param object Id of the object to add.
|
* @param object Id of the object to add.
|
||||||
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
|
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t addComponent(object_id_t object);
|
ReturnValue_t addComponent(object_id_t object,
|
||||||
|
bool setTaskIF = true) override;
|
||||||
|
|
||||||
uint32_t getPeriodMs() const;
|
uint32_t getPeriodMs() const;
|
||||||
|
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
/**
|
|
||||||
* @file PollingSlot.cpp
|
|
||||||
* @brief This file defines the PollingSlot class.
|
|
||||||
* @date 19.12.2012
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <framework/devicehandlers/FixedSequenceSlot.h>
|
|
||||||
#include <framework/objectmanager/SystemObjectIF.h>
|
#include <framework/objectmanager/SystemObjectIF.h>
|
||||||
|
#include <framework/tasks/FixedSequenceSlot.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
||||||
int8_t setSequenceId, PeriodicTaskIF* executingTask) :
|
int8_t setSequenceId, PeriodicTaskIF* executingTask) :
|
||||||
handler(NULL), pollingTimeMs(setTime), opcode(setSequenceId) {
|
pollingTimeMs(setTime), opcode(setSequenceId) {
|
||||||
handler = objectManager->get<ExecutableObjectIF>(handlerId);
|
handler = objectManager->get<ExecutableObjectIF>(handlerId);
|
||||||
handler->setTaskIF(executingTask);
|
if(executingTask != nullptr) {
|
||||||
|
handler->setTaskIF(executingTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FixedSequenceSlot::~FixedSequenceSlot() {}
|
FixedSequenceSlot::~FixedSequenceSlot() {}
|
@ -1,22 +1,17 @@
|
|||||||
/**
|
#ifndef FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_
|
||||||
* @file FixedSequenceSlot.h
|
#define FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_
|
||||||
* @brief This file defines the PollingSlot class.
|
|
||||||
* @date 19.12.2012
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FIXEDSEQUENCESLOT_H_
|
|
||||||
#define FIXEDSEQUENCESLOT_H_
|
|
||||||
|
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/tasks/ExecutableObjectIF.h>
|
#include <framework/tasks/ExecutableObjectIF.h>
|
||||||
class PeriodicTaskIF;
|
class PeriodicTaskIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is the representation of a single polling sequence table entry.
|
* @brief This class is the representation of a single polling sequence
|
||||||
*
|
* table entry.
|
||||||
* @details The PollingSlot class is the representation of a single polling
|
* @details
|
||||||
* sequence table entry.
|
* The PollingSlot class is the representation of a single polling
|
||||||
|
* sequence table entry.
|
||||||
|
* @author baetz
|
||||||
*/
|
*/
|
||||||
class FixedSequenceSlot {
|
class FixedSequenceSlot {
|
||||||
public:
|
public:
|
||||||
@ -27,7 +22,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Handler identifies which device handler object is executed in this slot.
|
* @brief Handler identifies which device handler object is executed in this slot.
|
||||||
*/
|
*/
|
||||||
ExecutableObjectIF* handler;
|
ExecutableObjectIF* handler = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This attribute defines when a device handler object is executed.
|
* @brief This attribute defines when a device handler object is executed.
|
||||||
@ -43,7 +38,7 @@ public:
|
|||||||
* @details The state of this value decides what communication routine is
|
* @details The state of this value decides what communication routine is
|
||||||
* called in the PST executable or the device handler object.
|
* called in the PST executable or the device handler object.
|
||||||
*/
|
*/
|
||||||
uint8_t opcode;
|
uint8_t opcode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Operator overload for the comparison operator to
|
* @brief Operator overload for the comparison operator to
|
@ -1,5 +1,5 @@
|
|||||||
#include <framework/devicehandlers/FixedSlotSequence.h>
|
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
#include <framework/tasks/FixedSlotSequence.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
|
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef FIXEDSLOTSEQUENCE_H_
|
#ifndef FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_
|
||||||
#define FIXEDSLOTSEQUENCE_H_
|
#define FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_
|
||||||
|
|
||||||
#include <framework/devicehandlers/FixedSequenceSlot.h>
|
|
||||||
#include <framework/objectmanager/SystemObject.h>
|
#include <framework/objectmanager/SystemObject.h>
|
||||||
|
#include <framework/tasks/FixedSequenceSlot.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
@ -12,11 +12,18 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF {
|
|||||||
public:
|
public:
|
||||||
virtual ~FixedTimeslotTaskIF() {}
|
virtual ~FixedTimeslotTaskIF() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an object with a slot time and the execution step to the task.
|
||||||
|
* The execution step shall be passed to the object.
|
||||||
|
* @param componentId
|
||||||
|
* @param slotTimeMs
|
||||||
|
* @param executionStep
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
virtual ReturnValue_t addSlot(object_id_t componentId,
|
virtual ReturnValue_t addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) = 0;
|
uint32_t slotTimeMs, int8_t executionStep) = 0;
|
||||||
|
/** Check whether the sequence is valid */
|
||||||
virtual ReturnValue_t checkSequence() const = 0;
|
virtual ReturnValue_t checkSequence() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_ */
|
#endif /* FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_ */
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#ifndef PERIODICTASKIF_H_
|
#ifndef FRAMEWORK_TASK_PERIODICTASKIF_H_
|
||||||
#define PERIODICTASKIF_H_
|
#define FRAMEWORK_TASK_PERIODICTASKIF_H_
|
||||||
|
|
||||||
#include <framework/objectmanager/SystemObjectIF.h>
|
#include <framework/objectmanager/SystemObjectIF.h>
|
||||||
|
#include <framework/timemanager/Clock.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
class ExecutableObjectIF;
|
class ExecutableObjectIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New version of TaskIF
|
* New version of TaskIF
|
||||||
* Follows RAII principles, i.e. there's no create or delete method.
|
* Follows RAII principles, i.e. there's no create or delete method.
|
||||||
@ -17,11 +19,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~PeriodicTaskIF() { }
|
virtual ~PeriodicTaskIF() { }
|
||||||
/**
|
/**
|
||||||
* @brief With the startTask method, a created task can be started for the first time.
|
* @brief With the startTask method, a created task can be started
|
||||||
|
* for the first time.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t startTask() = 0;
|
virtual ReturnValue_t startTask() = 0;
|
||||||
|
|
||||||
virtual ReturnValue_t addComponent(object_id_t object) {return HasReturnvaluesIF::RETURN_FAILED;};
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t addComponent(object_id_t object,
|
||||||
|
bool setTaskIF = true) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
};
|
||||||
|
|
||||||
virtual ReturnValue_t sleepFor(uint32_t ms) = 0;
|
virtual ReturnValue_t sleepFor(uint32_t ms) = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user