important logic fix

This commit is contained in:
Robin Müller 2021-01-10 14:27:57 +01:00
parent 1af28dd457
commit 69e931c07b
3 changed files with 48 additions and 7 deletions

View File

@ -322,12 +322,16 @@ void LocalDataPoolManager::handleChangeResetLogic(
continue;
}
// only one update recipient, we can reset changes status immediately.
if(changeInfo.updateCounter <= 1) {
toReset->setChanged(false);
}
if(changeInfo.currentUpdateCounter == 0) {
// All recipients have been notified, reset the changed flag.
if(changeInfo.currentUpdateCounter <= 1) {
toReset->setChanged(false);
changeInfo.currentUpdateCounter = 0;
}
// Not all recipiens have been notified yet, decrement.
else {
changeInfo.currentUpdateCounter--;
}

View File

@ -60,7 +60,25 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
CHECK(messageSent.getCommand() == static_cast<int>(
HousekeepingMessage::HK_REPORT));
// clear message to avoid memory leak, our mock won't do it for us (yet)
CommandMessageCleaner::clearCommandMessage(&messageSent);
// now subscribe for variable update as well
REQUIRE(not poolOwner->dataset.hasChanged());
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) ==
retval::CATCH_OK);
lp_var_t<uint8_t>* poolVar = dynamic_cast<lp_var_t<uint8_t>*>(
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
REQUIRE(poolVar != nullptr);
poolVar->setChanged(true);
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
CHECK(messageSent.getCommand() == static_cast<int>(
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
}
}

View File

@ -2,6 +2,7 @@
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/LocalDataSet.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/LocalPoolVector.h>
@ -18,15 +19,16 @@ static constexpr lp_id_t uint16Vec3Id = 3;
static constexpr lp_id_t int64Vec2Id = 4;
static constexpr uint32_t testSetId = 0;
static constexpr uint8_t dataSetMaxVariables = 10;
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE,
testSetId);
}
class LocalPoolTestDataSet: public StaticLocalDataSet<3> {
class LocalPoolTestDataSet: public LocalDataSet {
public:
LocalPoolTestDataSet(HasLocalDataPoolIF* owner, uint32_t setId):
StaticLocalDataSet(owner, setId) {
LocalDataSet(owner, setId, lpool::dataSetMaxVariables) {
}
ReturnValue_t assignPointers() {
@ -127,7 +129,24 @@ public:
virtual LocalPoolObjectBase* getPoolObjectHandle(
lp_id_t localPoolId) override {
return &testUint8;
if(localPoolId == lpool::uint8VarId) {
return &testUint8;
}
else if(localPoolId == lpool::uint16Vec3Id) {
return &testUint16Vec;
}
else if(localPoolId == lpool::floatVarId) {
return &testFloat;
}
else if(localPoolId == lpool::int64Vec2Id) {
return &testInt64Vec;
}
else if(localPoolId == lpool::uint32VarId) {
return &testUint32;
}
else {
return &testUint8;
}
}
MessageQueueMockBase* getMockQueueHandle() const {
@ -144,9 +163,9 @@ public:
false, objects::HK_RECEIVER_MOCK);
}
ReturnValue_t subscribeWrapperVariableUpdate() {
return hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) {
return hkManager.subscribeForVariableUpdateMessages(localPoolId,
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
}
LocalDataPoolManager hkManager;