Merge branch 'mueller_FixedSequenceImprovements' into mueller_framework

This commit is contained in:
Robin Müller 2020-05-11 19:25:45 +02:00
commit e5c46c5ec1
5 changed files with 51 additions and 39 deletions

View File

@ -16,6 +16,5 @@ FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
handler->setTaskIF(executingTask);
}
FixedSequenceSlot::~FixedSequenceSlot() {
}
FixedSequenceSlot::~FixedSequenceSlot() {}

View File

@ -13,9 +13,10 @@
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 sequence table entry.
* @details The PollingSlot class is the representation of a single polling
* sequence table entry.
*/
class FixedSequenceSlot {
public:
@ -37,13 +38,19 @@ public:
uint32_t pollingTimeMs;
/**
* \brief This value defines the type of device communication.
* @brief This value defines the type of device communication.
*
* \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.
*/
uint8_t opcode;
/**
* @brief Operator overload for the comparison operator to
* allow sorting by polling time.
* @param fixedSequenceSlot
* @return
*/
bool operator <(const FixedSequenceSlot & fixedSequenceSlot) const {
return pollingTimeMs < fixedSequenceSlot.pollingTimeMs;
}

View File

@ -8,14 +8,8 @@ FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
}
FixedSlotSequence::~FixedSlotSequence() {
// This should call the destructor on each list entry.
// Call the destructor on each list entry.
slotList.clear();
// SlotListIter slotListIter = this->slotList.begin();
// //Iterate through slotList and delete all entries.
// while (slotListIter != this->slotList.end()) {
// delete (*slotIt);
// slotIt++;
// }
}
void FixedSlotSequence::executeAndAdvance() {
@ -89,14 +83,15 @@ uint32_t FixedSlotSequence::getLengthMs() const {
ReturnValue_t FixedSlotSequence::checkSequence() const {
if(slotList.empty()) {
sif::error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
sif::error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
auto slotIt = slotList.begin();
uint32_t count = 0;
uint32_t time = 0;
while (slotIt != slotList.end()) {
if (slotIt->handler == NULL) {
if (slotIt->handler == nullptr) {
sif::error << "FixedSlotSequene::initialize: ObjectId does not exist!"
<< std::endl;
count++;

View File

@ -3,8 +3,7 @@
#include <framework/devicehandlers/FixedSequenceSlot.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <list>
#include <set>
using SlotList = std::multiset<FixedSequenceSlot>;
@ -72,9 +71,10 @@ public:
bool slotFollowsImmediately();
/**
* \brief This method returns the time until the next software component is invoked.
* @brief This method returns the time until the next software
* component is invoked.
*
* \details
* @details
* This method is vitally important for the operation of the PST.
* By fetching the polling time of the current slot and that of the
* next one (or the first one, if the list end is reached)
@ -86,11 +86,15 @@ public:
uint32_t getIntervalToNextSlotMs();
/**
* \brief This method returns the time difference between the current slot and the previous slot
* @brief This method returns the time difference between the current
* slot and the previous slot
*
* \details This method is vitally important for the operation of the PST. By fetching the polling time
* of the current slot and that of the prevous one (or the last one, if the slot is the first one)
* it calculates and returns the interval in milliseconds that the handler execution shall be delayed.
* @details
* This method is vitally important for the operation of the PST.
* By fetching the polling time of the current slot and that of the previous
* one (or the last one, if the slot is the first one) it calculates and
* returns the interval in milliseconds that the handler execution shall
* be delayed.
*/
uint32_t getIntervalToPreviousSlotMs();
@ -100,20 +104,24 @@ public:
uint32_t getLengthMs() const;
/**
* \brief The method to execute the device handler entered in the current PollingSlot object.
* @brief The method to execute the device handler entered in the current
* PollingSlot object.
*
* \details Within this method the device handler object to be executed is chosen by looking up the
* handler address of the current slot in the handlerMap. Either the device handler's
* talkToInterface or its listenToInterface method is invoked, depending on the isTalking flag
* of the polling slot. After execution the iterator current is increased or, by reaching the
* end of slotList, reset to the beginning.
* @details
* Within this method the device handler object to be executed is chosen by
* looking up the handler address of the current slot in the handlerMap.
* Either the device handler's talkToInterface or its listenToInterface
* method is invoked, depending on the isTalking flag of the polling slot.
* After execution the iterator current is increased or, by reaching the
* end of slotList, reset to the beginning.
*/
void executeAndAdvance();
/**
* @brief An iterator that indicates the current polling slot to execute.
*
* @details This is an iterator for slotList and always points to the polling slot which is executed next.
* @details This is an iterator for slotList and always points to the
* polling slot which is executed next.
*/
SlotListIter current;
@ -127,13 +135,15 @@ public:
protected:
/**
* @brief This list contains all PollingSlot objects, defining order and execution time of the
* device handler objects.
* @brief This list contains all PollingSlot objects, defining order and
* execution time of the device handler objects.
*
* @details The slot list is a std:list object that contains all created PollingSlot instances.
* They are NOT ordered automatically, so by adding entries, the correct order needs to be ensured.
* By iterating through this list the polling sequence is executed. Two entries with identical
* polling times are executed immediately one after another.
* @details
* The slot list is a std:list object that contains all created
* PollingSlot instances. They are NOT ordered automatically, so by
* adding entries, the correct order needs to be ensured. By iterating
* through this list the polling sequence is executed. Two entries with
* identical polling times are executed immediately one after another.
*/
SlotList slotList;

View File

@ -57,6 +57,7 @@ ReturnValue_t FixedTimeslotTask::startTask() {
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
uint32_t slotTimeMs, int8_t executionStep) {
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
if(slotTimeMs == 0) {
// FreeRTOS throws a sanity error for zero values, so we set
@ -67,8 +68,8 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK;
}
sif::error << "Component " << std::hex << componentId
<< " not found, not adding it to pst" << std::endl;
sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}