added a generic way to add a custom check
This commit is contained in:
parent
b8754fbc16
commit
4d7d48e8ca
@ -91,21 +91,31 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
uint32_t time = 0;
|
||||||
for(const auto& slot: slotList) {
|
for(const auto& slot: slotList) {
|
||||||
if (slot.executableObject == nullptr) {
|
if (slot.executableObject == nullptr) {
|
||||||
count++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
else if (slot.pollingTimeMs < time) {
|
else if (slot.pollingTimeMs < time) {
|
||||||
sif::error << "FixedSlotSequence::initialize: Time: "
|
sif::error << "FixedSlotSequence::checkSequence: Time: "
|
||||||
<< slot.pollingTimeMs << " is smaller than previous with "
|
<< slot.pollingTimeMs << " is smaller than previous with "
|
||||||
<< time << std::endl;
|
<< time << std::endl;
|
||||||
count++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// All ok, print slot.
|
// All ok, print slot.
|
||||||
@ -117,7 +127,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
|
|||||||
}
|
}
|
||||||
//sif::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;
|
||||||
@ -145,3 +155,8 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const {
|
|||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedSlotSequence::addCustomCheck(ReturnValue_t
|
||||||
|
(*customCheckFunction)(const SlotList&)) {
|
||||||
|
this->customCheckFunction = customCheckFunction;
|
||||||
|
}
|
||||||
|
@ -139,6 +139,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t checkSequence() const;
|
ReturnValue_t checkSequence() const;
|
||||||
|
|
||||||
|
void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform any initialization steps required after the executing
|
* @brief Perform any initialization steps required after the executing
|
||||||
* task has been created. This function should be called from the
|
* task has been created. This function should be called from the
|
||||||
@ -162,6 +164,8 @@ protected:
|
|||||||
*/
|
*/
|
||||||
SlotList slotList;
|
SlotList slotList;
|
||||||
|
|
||||||
|
ReturnValue_t (*customCheckFunction)(const SlotList&) = nullptr;
|
||||||
|
|
||||||
uint32_t lengthMs;
|
uint32_t lengthMs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user