WIP: somethings wrong.. #19
@ -16,6 +16,5 @@ FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
|
|||||||
handler->setTaskIF(executingTask);
|
handler->setTaskIF(executingTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixedSequenceSlot::~FixedSequenceSlot() {
|
FixedSequenceSlot::~FixedSequenceSlot() {}
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
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 sequence table entry.
|
* @details The PollingSlot class is the representation of a single polling
|
||||||
|
* sequence table entry.
|
||||||
*/
|
*/
|
||||||
class FixedSequenceSlot {
|
class FixedSequenceSlot {
|
||||||
public:
|
public:
|
||||||
@ -37,13 +38,19 @@ public:
|
|||||||
uint32_t pollingTimeMs;
|
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.
|
* called in the PST executable or the device handler object.
|
||||||
*/
|
*/
|
||||||
uint8_t opcode;
|
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 {
|
bool operator <(const FixedSequenceSlot & fixedSequenceSlot) const {
|
||||||
return pollingTimeMs < fixedSequenceSlot.pollingTimeMs;
|
return pollingTimeMs < fixedSequenceSlot.pollingTimeMs;
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,8 @@ FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
FixedSlotSequence::~FixedSlotSequence() {
|
FixedSlotSequence::~FixedSlotSequence() {
|
||||||
// This should call the destructor on each list entry.
|
// Call the destructor on each list entry.
|
||||||
slotList.clear();
|
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() {
|
void FixedSlotSequence::executeAndAdvance() {
|
||||||
@ -89,14 +83,15 @@ uint32_t FixedSlotSequence::getLengthMs() const {
|
|||||||
|
|
||||||
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 << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto slotIt = slotList.begin();
|
auto slotIt = slotList.begin();
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
while (slotIt != slotList.end()) {
|
while (slotIt != slotList.end()) {
|
||||||
if (slotIt->handler == NULL) {
|
if (slotIt->handler == nullptr) {
|
||||||
sif::error << "FixedSlotSequene::initialize: ObjectId does not exist!"
|
sif::error << "FixedSlotSequene::initialize: ObjectId does not exist!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
count++;
|
count++;
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
#include <framework/devicehandlers/FixedSequenceSlot.h>
|
#include <framework/devicehandlers/FixedSequenceSlot.h>
|
||||||
#include <framework/objectmanager/SystemObject.h>
|
#include <framework/objectmanager/SystemObject.h>
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
|
||||||
#include <list>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
using SlotList = std::multiset<FixedSequenceSlot>;
|
using SlotList = std::multiset<FixedSequenceSlot>;
|
||||||
@ -72,9 +71,10 @@ public:
|
|||||||
bool slotFollowsImmediately();
|
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.
|
* This method is vitally important for the operation of the PST.
|
||||||
* By fetching the polling time of the current slot and that of the
|
* 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)
|
* next one (or the first one, if the list end is reached)
|
||||||
@ -86,11 +86,15 @@ public:
|
|||||||
uint32_t getIntervalToNextSlotMs();
|
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
|
* @details
|
||||||
* of the current slot and that of the prevous one (or the last one, if the slot is the first one)
|
* This method is vitally important for the operation of the PST.
|
||||||
* it calculates and returns the interval in milliseconds that the handler execution shall be delayed.
|
* 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();
|
uint32_t getIntervalToPreviousSlotMs();
|
||||||
|
|
||||||
@ -100,20 +104,24 @@ public:
|
|||||||
uint32_t getLengthMs() const;
|
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
|
* @details
|
||||||
* handler address of the current slot in the handlerMap. Either the device handler's
|
* Within this method the device handler object to be executed is chosen by
|
||||||
* talkToInterface or its listenToInterface method is invoked, depending on the isTalking flag
|
* looking up the handler address of the current slot in the handlerMap.
|
||||||
* of the polling slot. After execution the iterator current is increased or, by reaching the
|
* Either the device handler's talkToInterface or its listenToInterface
|
||||||
* end of slotList, reset to the beginning.
|
* 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();
|
void executeAndAdvance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An iterator that indicates the current polling slot to execute.
|
* @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;
|
SlotListIter current;
|
||||||
|
|
||||||
@ -127,13 +135,15 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This list contains all PollingSlot objects, defining order and execution time of the
|
* @brief This list contains all PollingSlot objects, defining order and
|
||||||
* device handler objects.
|
* execution time of the device handler objects.
|
||||||
*
|
*
|
||||||
* @details The slot list is a std:list object that contains all created PollingSlot instances.
|
* @details
|
||||||
* They are NOT ordered automatically, so by adding entries, the correct order needs to be ensured.
|
* The slot list is a std:list object that contains all created
|
||||||
* By iterating through this list the polling sequence is executed. Two entries with identical
|
* PollingSlot instances. They are NOT ordered automatically, so by
|
||||||
* polling times are executed immediately one after another.
|
* 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;
|
SlotList slotList;
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ 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) {
|
if(slotTimeMs == 0) {
|
||||||
// FreeRTOS throws a sanity error for zero values, so we set
|
// 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;
|
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::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user