took over changed for fixed slot sequence

This commit is contained in:
Robin Müller 2020-09-04 14:28:43 +02:00
parent 403d83f32c
commit 31c16382fc
5 changed files with 80 additions and 51 deletions

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
#ifndef FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
#define FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
#include "../../osal/FreeRTOS/FreeRTOSTaskIF.h"
#include "FreeRTOSTaskIF.h"
#include "../../tasks/FixedSlotSequence.h"
#include "../../tasks/FixedTimeslotTaskIF.h"
#include "../../tasks/Typedef.h"
@ -98,4 +98,4 @@ protected:
void handleMissedDeadline();
};
#endif /* POLLINGTASK_H_ */
#endif /* FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ */

View File

@ -1,5 +1,5 @@
#include "../objectmanager/SystemObjectIF.h"
#include "../tasks/FixedSequenceSlot.h"
#include "FixedSequenceSlot.h"
#include "PeriodicTaskIF.h"
#include <cstddef>
FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,

View File

@ -1,8 +1,9 @@
#ifndef FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_
#define FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_
#ifndef FSFW_TASKS_FIXEDSEQUENCESLOT_H_
#define FSFW_TASKS_FIXEDSEQUENCESLOT_H_
#include "ExecutableObjectIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "../tasks/ExecutableObjectIF.h"
class PeriodicTaskIF;
/**
@ -56,4 +57,4 @@ public:
};
#endif /* FIXEDSEQUENCESLOT_H_ */
#endif /* FSFW_TASKS_FIXEDSEQUENCESLOT_H_ */

View File

@ -1,5 +1,5 @@
#include "FixedSlotSequence.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../tasks/FixedSlotSequence.h"
#include <cstdlib>
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
@ -91,21 +91,31 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs,
ReturnValue_t FixedSlotSequence::checkSequence() const {
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;
}
uint32_t count = 0;
if(customCheckFunction != nullptr) {
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;
for(const auto& slot: slotList) {
if (slot.executableObject == nullptr) {
count++;
errorCount++;
}
else if (slot.pollingTimeMs < time) {
sif::error << "FixedSlotSequence::initialize: Time: "
sif::error << "FixedSlotSequence::checkSequence: Time: "
<< slot.pollingTimeMs << " is smaller than previous with "
<< time << std::endl;
count++;
errorCount++;
}
else {
// All ok, print slot.
@ -117,7 +127,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
}
//sif::info << "Number of elements in slot list: "
// << slotList.size() << std::endl;
if (count > 0) {
if (errorCount > 0) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
@ -145,3 +155,8 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const {
}
return HasReturnvaluesIF::RETURN_OK;
}
void FixedSlotSequence::addCustomCheck(ReturnValue_t
(*customCheckFunction)(const SlotList&)) {
this->customCheckFunction = customCheckFunction;
}

View File

@ -1,26 +1,30 @@
#ifndef FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_
#define FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_
#ifndef FSFW_TASKS_FIXEDSLOTSEQUENCE_H_
#define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_
#include "FixedSequenceSlot.h"
#include "../objectmanager/SystemObject.h"
#include "../tasks/FixedSequenceSlot.h"
#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
* 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
* handlers to thepolling sequence and to maintain a list of
* polling slot objects. This slot list represents the Polling Sequence Table
* in software.
* The main idea is to create a list of executable objects (for example
* device handlers), to announce all handlers to the polling sequence and to
* maintain a list of polling slot objects.
* This slot list represents the Polling Sequence Table in software.
*
* Each polling slot contains information to indicate when and
* which device handler shall be executed within a given polling period.
* The sequence is then executed by iterating through this slot list.
* Handlers are invoking by calling a certain function stored in the handler list.
* which executable object shall be executed within a given polling period.
* When adding a slot, a pointer to the executing task, a pointer to the
* 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 {
public:
@ -29,41 +33,44 @@ public:
/**
* @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.
*/
FixedSlotSequence(uint32_t setLengthMs);
/**
* @brief The destructor of the FixedSlotSequence object.
*
* @details The destructor frees all allocated memory by iterating through the slotList
* and deleting all allocated resources.
* @details
* The destructor frees all allocated memory by iterating through the
* slotList and deleting all allocated resources.
*/
virtual ~FixedSlotSequence();
/**
* @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
* to the end of the list. The list is currently NOT reordered.
* Afterwards, the iterator current is set to the beginning of the list.
* @param Object ID of the object to add
* @param setTime Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask
* will be called inside the slot period.
* @param setSequenceId ID which can be used to distinguish
* different task operations
* @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.
* Afterwards, the iterator current is set to the beginning of the list.
* @param handlerId ID of the object to add
* @param setTime
* Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask
* will be called inside the slot period.
* @param setSequenceId
* ID which can be used to distinguish different task operations. This
* value will be passed to the executable function.
* @param
* @param
*/
void addSlot(object_id_t handlerId, uint32_t setTime, int8_t setSequenceId,
ExecutableObjectIF* executableObject, PeriodicTaskIF* executingTask);
ExecutableObjectIF* executableObject,
PeriodicTaskIF* executingTask);
/**
* Checks if the current slot shall be executed immediately after the one before.
* This allows to distinguish between grouped and not grouped handlers.
* @brief Checks if the current slot shall be executed immediately
* 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
* - @c false else
*/
@ -128,12 +135,18 @@ public:
* @brief Check and initialize slot list.
* @details
* Checks if timing is ok (must be ascending) and if all handlers were found.
* Also calls any initialization steps which are required after task
* creation.
* @return
*/
ReturnValue_t checkSequence() const;
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:
@ -151,9 +164,9 @@ protected:
*/
SlotList slotList;
uint32_t lengthMs;
ReturnValue_t (*customCheckFunction)(const SlotList&) = nullptr;
bool isEmpty = false;
uint32_t lengthMs;
};
#endif /* FIXEDSLOTSEQUENCE_H_ */
#endif /* FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ */