Merge branch 'master' into mueller_StoreAccessor
This commit is contained in:
commit
6c86cf88f3
@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file PollingSlot.cpp
|
|
||||||
* @brief This file defines the PollingSlot class.
|
|
||||||
* @date 19.12.2012
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FixedSequenceSlot.h"
|
|
||||||
#include "../objectmanager/SystemObjectIF.h"
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
|
||||||
int8_t setSequenceId, PeriodicTaskIF* executingTask) :
|
|
||||||
handler(NULL), pollingTimeMs(setTime), opcode(setSequenceId) {
|
|
||||||
handler = objectManager->get<ExecutableObjectIF>(handlerId);
|
|
||||||
handler->setTaskIF(executingTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
FixedSequenceSlot::~FixedSequenceSlot() {}
|
|
||||||
|
|
@ -8,7 +8,7 @@ const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE;
|
|||||||
FixedTimeslotTask::FixedTimeslotTask(TaskName name, TaskPriority setPriority,
|
FixedTimeslotTask::FixedTimeslotTask(TaskName name, TaskPriority setPriority,
|
||||||
TaskStackSize setStack, TaskPeriod overallPeriod,
|
TaskStackSize setStack, TaskPeriod overallPeriod,
|
||||||
void (*setDeadlineMissedFunc)()) :
|
void (*setDeadlineMissedFunc)()) :
|
||||||
started(false), handle(NULL), pst(overallPeriod * 1000) {
|
started(false), handle(nullptr), pst(overallPeriod * 1000) {
|
||||||
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
|
configSTACK_DEPTH_TYPE stackSize = setStack / sizeof(configSTACK_DEPTH_TYPE);
|
||||||
xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle);
|
xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle);
|
||||||
// All additional attributes are applied to the object.
|
// All additional attributes are applied to the object.
|
||||||
@ -62,8 +62,10 @@ 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) {
|
ExecutableObjectIF* handler =
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
objectManager->get<ExecutableObjectIF>(componentId);
|
||||||
|
if (handler != nullptr) {
|
||||||
|
pst.addSlot(componentId, slotTimeMs, executionStep, handler, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
// start time for the first entry.
|
// start time for the first entry.
|
||||||
auto slotListIter = pst.current;
|
auto slotListIter = pst.current;
|
||||||
|
|
||||||
|
pst.intializeSequenceAfterTaskCreation();
|
||||||
|
|
||||||
//The start time for the first entry is read.
|
//The start time for the first entry is read.
|
||||||
uint32_t intervalMs = slotListIter->pollingTimeMs;
|
uint32_t intervalMs = slotListIter->pollingTimeMs;
|
||||||
TickType_t interval = pdMS_TO_TICKS(intervalMs);
|
TickType_t interval = pdMS_TO_TICKS(intervalMs);
|
||||||
@ -143,10 +147,6 @@ void FixedTimeslotTask::checkMissedDeadline(const TickType_t xLastWakeTime,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FixedTimeslotTask::handleMissedDeadline() {
|
void FixedTimeslotTask::handleMissedDeadline() {
|
||||||
#ifdef DEBUG
|
|
||||||
sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) <<
|
|
||||||
" missed deadline!\n" << std::flush;
|
|
||||||
#endif
|
|
||||||
if(deadlineMissedFunc != nullptr) {
|
if(deadlineMissedFunc != nullptr) {
|
||||||
this->deadlineMissedFunc();
|
this->deadlineMissedFunc();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#ifndef FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#define FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
#include "FreeRTOSTaskIF.h"
|
#include "FreeRTOSTaskIF.h"
|
||||||
#include "../../devicehandlers/FixedSlotSequence.h"
|
#include "../../tasks/FixedSlotSequence.h"
|
||||||
#include "../../tasks/FixedTimeslotTaskIF.h"
|
#include "../../tasks/FixedTimeslotTaskIF.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>
|
||||||
|
|
||||||
@ -99,4 +98,4 @@ protected:
|
|||||||
void handleMissedDeadline();
|
void handleMissedDeadline();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ */
|
#endif /* FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ */
|
||||||
|
@ -133,10 +133,6 @@ TaskHandle_t PeriodicTask::getTaskHandle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PeriodicTask::handleMissedDeadline() {
|
void PeriodicTask::handleMissedDeadline() {
|
||||||
#ifdef DEBUG
|
|
||||||
sif::warning << "PeriodicTask: " << pcTaskGetName(NULL) <<
|
|
||||||
" missed deadline!\n" << std::flush;
|
|
||||||
#endif
|
|
||||||
if(deadlineMissedFunc != nullptr) {
|
if(deadlineMissedFunc != nullptr) {
|
||||||
this->deadlineMissedFunc();
|
this->deadlineMissedFunc();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
|
||||||
#include "FixedTimeslotTask.h"
|
#include "FixedTimeslotTask.h"
|
||||||
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
@ -39,13 +39,16 @@ uint32_t FixedTimeslotTask::getPeriodMs() const {
|
|||||||
|
|
||||||
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) {
|
ExecutableObjectIF* executableObject =
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
objectManager->get<ExecutableObjectIF>(componentId);
|
||||||
|
if (executableObject != nullptr) {
|
||||||
|
pst.addSlot(componentId, slotTimeMs, executionStep,
|
||||||
|
executableObject,this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
sif::error << "Component " << std::hex << componentId <<
|
sif::error << "Component " << std::hex << componentId <<
|
||||||
" not found, not adding it to pst" << std::endl;
|
" not found, not adding it to pst" << std::dec << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +61,9 @@ void FixedTimeslotTask::taskFunctionality() {
|
|||||||
if (!started) {
|
if (!started) {
|
||||||
suspend();
|
suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pst.intializeSequenceAfterTaskCreation();
|
||||||
|
|
||||||
//The start time for the first entry is read.
|
//The start time for the first entry is read.
|
||||||
uint64_t lastWakeTime = getCurrentMonotonicTimeMs();
|
uint64_t lastWakeTime = getCurrentMonotonicTimeMs();
|
||||||
uint64_t interval = pst.getIntervalToNextSlotMs();
|
uint64_t interval = pst.getIntervalToNextSlotMs();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
#ifndef FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
||||||
#define FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
#define FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
#include "../../tasks/FixedTimeslotTaskIF.h"
|
|
||||||
#include "../../devicehandlers/FixedSlotSequence.h"
|
|
||||||
#include "PosixThread.h"
|
#include "PosixThread.h"
|
||||||
|
#include "../../tasks/FixedTimeslotTaskIF.h"
|
||||||
|
#include "../../tasks/FixedSlotSequence.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
class FixedTimeslotTask: public FixedTimeslotTaskIF, public PosixThread {
|
class FixedTimeslotTask: public FixedTimeslotTaskIF, public PosixThread {
|
||||||
@ -74,4 +74,4 @@ private:
|
|||||||
bool started;
|
bool started;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */
|
#endif /* FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */
|
||||||
|
17
tasks/FixedSequenceSlot.cpp
Normal file
17
tasks/FixedSequenceSlot.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "FixedSequenceSlot.h"
|
||||||
|
#include "PeriodicTaskIF.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
||||||
|
int8_t setSequenceId, ExecutableObjectIF* executableObject,
|
||||||
|
PeriodicTaskIF* executingTask) : handlerId(handlerId),
|
||||||
|
pollingTimeMs(setTime), opcode(setSequenceId) {
|
||||||
|
if(executableObject == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->executableObject = executableObject;
|
||||||
|
this->executableObject->setTaskIF(executingTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
FixedSequenceSlot::~FixedSequenceSlot() {}
|
||||||
|
|
@ -1,39 +1,39 @@
|
|||||||
/**
|
#ifndef FSFW_TASKS_FIXEDSEQUENCESLOT_H_
|
||||||
* @file FixedSequenceSlot.h
|
#define FSFW_TASKS_FIXEDSEQUENCESLOT_H_
|
||||||
* @brief This file defines the PollingSlot class.
|
|
||||||
* @date 19.12.2012
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FIXEDSEQUENCESLOT_H_
|
|
||||||
#define FIXEDSEQUENCESLOT_H_
|
|
||||||
|
|
||||||
|
#include "ExecutableObjectIF.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../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
|
||||||
|
* The PollingSlot class is the representation of a single polling
|
||||||
* sequence table entry.
|
* sequence table entry.
|
||||||
|
* @author baetz
|
||||||
*/
|
*/
|
||||||
class FixedSequenceSlot {
|
class FixedSequenceSlot {
|
||||||
public:
|
public:
|
||||||
FixedSequenceSlot( object_id_t handlerId, uint32_t setTimeMs,
|
FixedSequenceSlot( object_id_t handlerId, uint32_t setTimeMs,
|
||||||
int8_t setSequenceId, PeriodicTaskIF* executingTask );
|
int8_t setSequenceId, ExecutableObjectIF* executableObject,
|
||||||
|
PeriodicTaskIF* executingTask);
|
||||||
virtual ~FixedSequenceSlot();
|
virtual ~FixedSequenceSlot();
|
||||||
|
|
||||||
|
object_id_t handlerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler identifies which device handler object is executed in this slot.
|
* @brief Handler identifies which object is executed in this slot.
|
||||||
*/
|
*/
|
||||||
ExecutableObjectIF* handler;
|
ExecutableObjectIF* executableObject = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This attribute defines when a device handler object is executed.
|
* @brief This attribute defines when a device handler object is executed.
|
||||||
*
|
* @details
|
||||||
* @details The pollingTime attribute identifies the time the handler is executed in ms.
|
* The pollingTime attribute identifies the time the handler is
|
||||||
* It must be smaller than the period length of the polling sequence.
|
* executed in ms. It must be smaller than the period length of the
|
||||||
|
* polling sequence.
|
||||||
*/
|
*/
|
||||||
uint32_t pollingTimeMs;
|
uint32_t pollingTimeMs;
|
||||||
|
|
||||||
@ -57,4 +57,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* FIXEDSEQUENCESLOT_H_ */
|
#endif /* FSFW_TASKS_FIXEDSEQUENCESLOT_H_ */
|
@ -1,5 +1,6 @@
|
|||||||
#include "FixedSlotSequence.h"
|
#include "FixedSlotSequence.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
|
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
|
||||||
lengthMs(setLengthMs) {
|
lengthMs(setLengthMs) {
|
||||||
@ -12,7 +13,7 @@ FixedSlotSequence::~FixedSlotSequence() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FixedSlotSequence::executeAndAdvance() {
|
void FixedSlotSequence::executeAndAdvance() {
|
||||||
current->handler->performOperation(current->opcode);
|
current->executableObject->performOperation(current->opcode);
|
||||||
// if (returnValue != RETURN_OK) {
|
// if (returnValue != RETURN_OK) {
|
||||||
// this->sendErrorMessage( returnValue );
|
// this->sendErrorMessage( returnValue );
|
||||||
// }
|
// }
|
||||||
@ -80,44 +81,82 @@ uint32_t FixedSlotSequence::getLengthMs() const {
|
|||||||
return this->lengthMs;
|
return this->lengthMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
||||||
|
int8_t executionStep, ExecutableObjectIF* executableObject,
|
||||||
|
PeriodicTaskIF* executingTask) {
|
||||||
|
this->slotList.insert(FixedSequenceSlot(componentId, slotTimeMs,
|
||||||
|
executionStep, executableObject, executingTask));
|
||||||
|
this->current = slotList.begin();
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t FixedSlotSequence::checkSequence() const {
|
ReturnValue_t FixedSlotSequence::checkSequence() const {
|
||||||
if(slotList.empty()) {
|
if(slotList.empty()) {
|
||||||
sif::error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
|
sif::error << "FixedSlotSequence::checkSequence:"
|
||||||
|
<< " Slot list is empty!" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto slotIt = slotList.begin();
|
if(customCheckFunction != nullptr) {
|
||||||
uint32_t count = 0;
|
ReturnValue_t result = customCheckFunction(slotList);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
// Continue for now but print error output.
|
||||||
|
sif::error << "FixedSlotSequence::checkSequence:"
|
||||||
|
<< " Custom check failed!" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t errorCount = 0;
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
while (slotIt != slotList.end()) {
|
for(const auto& slot: slotList) {
|
||||||
if (slotIt->handler == nullptr) {
|
if (slot.executableObject == nullptr) {
|
||||||
sif::error << "FixedSlotSequene::initialize: ObjectId does not exist!"
|
errorCount++;
|
||||||
<< std::endl;
|
}
|
||||||
count++;
|
else if (slot.pollingTimeMs < time) {
|
||||||
} else if (slotIt->pollingTimeMs < time) {
|
sif::error << "FixedSlotSequence::checkSequence: Time: "
|
||||||
sif::error << "FixedSlotSequence::initialize: Time: "
|
<< slot.pollingTimeMs << " is smaller than previous with "
|
||||||
<< slotIt->pollingTimeMs
|
<< time << std::endl;
|
||||||
<< " is smaller than previous with " << time << std::endl;
|
errorCount++;
|
||||||
count++;
|
}
|
||||||
} else {
|
else {
|
||||||
// All ok, print slot.
|
// All ok, print slot.
|
||||||
//info << "Current slot polling time: " << std::endl;
|
//sif::info << "Current slot polling time: " << std::endl;
|
||||||
//info << std::dec << slotIt->pollingTimeMs << std::endl;
|
//sif::info << std::dec << slotIt->pollingTimeMs << std::endl;
|
||||||
}
|
}
|
||||||
time = slotIt->pollingTimeMs;
|
time = slot.pollingTimeMs;
|
||||||
slotIt++;
|
|
||||||
}
|
}
|
||||||
//info << "Number of elements in slot list: "
|
//sif::info << "Number of elements in slot list: "
|
||||||
// << slotList.size() << std::endl;
|
// << slotList.size() << std::endl;
|
||||||
if (count > 0) {
|
if (errorCount > 0) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
|
||||||
int8_t executionStep, PeriodicTaskIF* executingTask) {
|
ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const {
|
||||||
this->slotList.insert(FixedSequenceSlot(componentId, slotTimeMs, executionStep,
|
std::set<ExecutableObjectIF*> uniqueObjects;
|
||||||
executingTask));
|
uint32_t count = 0;
|
||||||
this->current = slotList.begin();
|
for(const auto& slot: slotList) {
|
||||||
|
// Ensure that each unique object is initialized once.
|
||||||
|
if(uniqueObjects.find(slot.executableObject) == uniqueObjects.end()) {
|
||||||
|
ReturnValue_t result =
|
||||||
|
slot.executableObject->initializeAfterTaskCreation();
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
uniqueObjects.emplace(slot.executableObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count > 0) {
|
||||||
|
sif::error << "FixedSlotSequence::intializeSequenceAfterTaskCreation:"
|
||||||
|
"Counted " << count << " failed initializations!" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FixedSlotSequence::addCustomCheck(ReturnValue_t
|
||||||
|
(*customCheckFunction)(const SlotList&)) {
|
||||||
|
this->customCheckFunction = customCheckFunction;
|
||||||
}
|
}
|
@ -1,26 +1,30 @@
|
|||||||
#ifndef FRAMEWORK_DEVICEHANDLERS_FIXEDSLOTSEQUENCE_H_
|
#ifndef FSFW_TASKS_FIXEDSLOTSEQUENCE_H_
|
||||||
#define FRAMEWORK_DEVICEHANDLERS_FIXEDSLOTSEQUENCE_H_
|
#define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_
|
||||||
|
|
||||||
#include "FixedSequenceSlot.h"
|
#include "FixedSequenceSlot.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is the representation of a Polling Sequence Table in software.
|
* @brief This class is the representation of a
|
||||||
*
|
* Polling Sequence Table in software.
|
||||||
* @details
|
* @details
|
||||||
* The FixedSlotSequence object maintains the dynamic execution of
|
* The FixedSlotSequence object maintains the dynamic execution of
|
||||||
* device handler objects.
|
* objects with stricter timing requirements for the FixedTimeslotTask.
|
||||||
*
|
*
|
||||||
* The main idea is to create a list of device handlers, to announce all
|
* The main idea is to create a list of executable objects (for example
|
||||||
* handlers to thepolling sequence and to maintain a list of
|
* device handlers), to announce all handlers to the polling sequence and to
|
||||||
* polling slot objects. This slot list represents the Polling Sequence Table
|
* maintain a list of polling slot objects.
|
||||||
* in software.
|
* This slot list represents the Polling Sequence Table in software.
|
||||||
*
|
*
|
||||||
* Each polling slot contains information to indicate when and
|
* Each polling slot contains information to indicate when and
|
||||||
* which device handler shall be executed within a given polling period.
|
* which executable object shall be executed within a given polling period.
|
||||||
* The sequence is then executed by iterating through this slot list.
|
* When adding a slot, a pointer to the executing task, a pointer to the
|
||||||
* Handlers are invoking by calling a certain function stored in the handler list.
|
* executable object and a step number can be passed. The step number will be
|
||||||
|
* passed to the periodic handler.
|
||||||
|
* The sequence is executed by iterating through the slot sequence and
|
||||||
|
* executing the executable object in the correct timeslot.
|
||||||
*/
|
*/
|
||||||
class FixedSlotSequence {
|
class FixedSlotSequence {
|
||||||
public:
|
public:
|
||||||
@ -29,41 +33,44 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The constructor of the FixedSlotSequence object.
|
* @brief The constructor of the FixedSlotSequence object.
|
||||||
*
|
|
||||||
* @details The constructor takes two arguments, the period length and the init function.
|
|
||||||
*
|
|
||||||
* @param setLength The period length, expressed in ms.
|
* @param setLength The period length, expressed in ms.
|
||||||
*/
|
*/
|
||||||
FixedSlotSequence(uint32_t setLengthMs);
|
FixedSlotSequence(uint32_t setLengthMs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The destructor of the FixedSlotSequence object.
|
* @brief The destructor of the FixedSlotSequence object.
|
||||||
*
|
* @details
|
||||||
* @details The destructor frees all allocated memory by iterating through the slotList
|
* The destructor frees all allocated memory by iterating through the
|
||||||
* and deleting all allocated resources.
|
* slotList and deleting all allocated resources.
|
||||||
*/
|
*/
|
||||||
virtual ~FixedSlotSequence();
|
virtual ~FixedSlotSequence();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is a method to add an PollingSlot object to slotList.
|
* @brief This is a method to add an PollingSlot object to slotList.
|
||||||
*
|
*
|
||||||
* @details Here, a polling slot object is added to the slot list. It is appended
|
* @details
|
||||||
|
* Here, a polling slot object is added to the slot list. It is appended
|
||||||
* to the end of the list. The list is currently NOT reordered.
|
* to the end of the list. The list is currently NOT reordered.
|
||||||
* Afterwards, the iterator current is set to the beginning of the list.
|
* Afterwards, the iterator current is set to the beginning of the list.
|
||||||
* @param Object ID of the object to add
|
* @param handlerId ID of the object to add
|
||||||
* @param setTime Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask
|
* @param setTime
|
||||||
|
* Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask
|
||||||
* will be called inside the slot period.
|
* will be called inside the slot period.
|
||||||
* @param setSequenceId ID which can be used to distinguish
|
* @param setSequenceId
|
||||||
* different task operations
|
* ID which can be used to distinguish different task operations. This
|
||||||
|
* value will be passed to the executable function.
|
||||||
* @param
|
* @param
|
||||||
* @param
|
* @param
|
||||||
*/
|
*/
|
||||||
void addSlot(object_id_t handlerId, uint32_t setTime, int8_t setSequenceId,
|
void addSlot(object_id_t handlerId, uint32_t setTime, int8_t setSequenceId,
|
||||||
|
ExecutableObjectIF* executableObject,
|
||||||
PeriodicTaskIF* executingTask);
|
PeriodicTaskIF* executingTask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the current slot shall be executed immediately after the one before.
|
* @brief Checks if the current slot shall be executed immediately
|
||||||
* This allows to distinguish between grouped and not grouped handlers.
|
* after the one before.
|
||||||
|
* @details
|
||||||
|
* This allows to distinguish between grouped and separated handlers.
|
||||||
* @return - @c true if the slot has the same polling time as the previous
|
* @return - @c true if the slot has the same polling time as the previous
|
||||||
* - @c false else
|
* - @c false else
|
||||||
*/
|
*/
|
||||||
@ -125,12 +132,32 @@ public:
|
|||||||
SlotListIter current;
|
SlotListIter current;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate through slotList and check successful creation.
|
* @brief Check and initialize slot list.
|
||||||
|
* @details
|
||||||
* Checks if timing is ok (must be ascending) and if all handlers were found.
|
* Checks if timing is ok (must be ascending) and if all handlers were found.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t checkSequence() const;
|
ReturnValue_t checkSequence() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A custom check can be injected for the respective slot list.
|
||||||
|
* @details
|
||||||
|
* This can be used by the developer to check the validity of a certain
|
||||||
|
* sequence. The function will be run in the #checkSequence function.
|
||||||
|
* The general check will be continued for now if the custom check function
|
||||||
|
* fails but a diagnostic debug output will be given.
|
||||||
|
* @param customCheckFunction
|
||||||
|
*/
|
||||||
|
void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Perform any initialization steps required after the executing
|
||||||
|
* task has been created. This function should be called from the
|
||||||
|
* executing task!
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ReturnValue_t intializeSequenceAfterTaskCreation() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +173,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
SlotList slotList;
|
SlotList slotList;
|
||||||
|
|
||||||
|
ReturnValue_t (*customCheckFunction)(const SlotList&) = nullptr;
|
||||||
|
|
||||||
uint32_t lengthMs;
|
uint32_t lengthMs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FIXEDSLOTSEQUENCE_H_ */
|
#endif /* FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ */
|
Loading…
Reference in New Issue
Block a user