continue refactoring
This commit is contained in:
@ -90,7 +90,7 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
|
||||
|
||||
void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
|
||||
|
||||
bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; }
|
||||
bool DeviceHandlerMock::getPeriodicReplyReceived() const { return periodicReplyReceived; }
|
||||
|
||||
ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) {
|
||||
return updatePeriodicReply(true, replyId);
|
||||
@ -109,7 +109,8 @@ ReturnValue_t DeviceHandlerMock::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerMock::serializeHkDataset(sid_t structureId, uint8_t *buf, size_t maxSize) {
|
||||
ReturnValue_t DeviceHandlerMock::serializeHkDataset(sid_t structureId, uint8_t *buf,
|
||||
size_t maxSize) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,19 @@
|
||||
|
||||
class DeviceHandlerMock : public DeviceHandlerBase {
|
||||
public:
|
||||
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||
static const DeviceCommandId_t PERIODIC_REPLY = 2;
|
||||
static constexpr DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||
static constexpr DeviceCommandId_t PERIODIC_REPLY = 2;
|
||||
|
||||
static const uint8_t SIMPLE_COMMAND_DATA = 1;
|
||||
static const uint8_t PERIODIC_REPLY_DATA = 2;
|
||||
static constexpr uint8_t SIMPLE_COMMAND_DATA = 1;
|
||||
static constexpr uint8_t PERIODIC_REPLY_DATA = 2;
|
||||
|
||||
DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
||||
FailureIsolationBase *fdirInstance);
|
||||
virtual ~DeviceHandlerMock();
|
||||
~DeviceHandlerMock() override;
|
||||
void changePeriodicReplyCountdown(uint32_t timeout);
|
||||
void changeSimpleCommandReplyCountdown(uint32_t timeout);
|
||||
void resetPeriodicReplyState();
|
||||
bool getPeriodicReplyReceived();
|
||||
bool getPeriodicReplyReceived() const;
|
||||
ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId);
|
||||
ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId);
|
||||
|
||||
@ -46,7 +46,7 @@ class DeviceHandlerMock : public DeviceHandlerBase {
|
||||
Countdown simpleCommandReplyTimeout = Countdown(1000);
|
||||
Countdown periodicReplyCountdown = Countdown(1000);
|
||||
|
||||
uint8_t commandBuffer[1];
|
||||
uint8_t commandBuffer[1]{};
|
||||
|
||||
bool periodicReplyReceived = false;
|
||||
};
|
||||
|
@ -1,11 +1,15 @@
|
||||
#include "LocalPoolOwnerBase.h"
|
||||
|
||||
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, object_id_t objectId)
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
|
||||
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, MessageQueueId_t hkDestId,
|
||||
object_id_t objectId)
|
||||
: SystemObject(objectId),
|
||||
queue(queue),
|
||||
sharedPool(getObjectId()),
|
||||
hkHelper(this, &queue),
|
||||
dataset(sharedPool, lpool::testSetId) {}
|
||||
hkHelper(this, &queue, hkDestId),
|
||||
sharedPool(LocalPoolOwnerBase::getObjectId()),
|
||||
set1(sharedPool, lpool::testSetId1),
|
||||
set2(sharedPool, lpool::testSetId2),
|
||||
queue(queue) {}
|
||||
|
||||
LocalPoolOwnerBase::~LocalPoolOwnerBase() = default;
|
||||
|
||||
@ -68,15 +72,15 @@ ReturnValue_t LocalPoolOwnerBase::reset() {
|
||||
// resetSubscriptionList();
|
||||
ReturnValue_t status = returnvalue::OK;
|
||||
{
|
||||
PoolReadGuard readHelper(&dataset);
|
||||
PoolReadGuard readHelper(&set1);
|
||||
if (readHelper.getReadResult() != returnvalue::OK) {
|
||||
status = readHelper.getReadResult();
|
||||
}
|
||||
dataset.localPoolVarUint8.value = 0;
|
||||
dataset.localPoolVarFloat.value = 0.0;
|
||||
dataset.localPoolUint16Vec.value[0] = 0;
|
||||
dataset.localPoolUint16Vec.value[1] = 0;
|
||||
dataset.localPoolUint16Vec.value[2] = 0;
|
||||
set1.localPoolVarUint8.value = 0;
|
||||
set1.localPoolVarFloat.value = 0.0;
|
||||
set1.localPoolUint16Vec.value[0] = 0;
|
||||
set1.localPoolUint16Vec.value[1] = 0;
|
||||
set1.localPoolUint16Vec.value[2] = 0;
|
||||
// dataset.setValidity(false, true);
|
||||
}
|
||||
|
||||
@ -101,28 +105,4 @@ ReturnValue_t LocalPoolOwnerBase::reset() {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool LocalPoolOwnerBase::changedDataSetCallbackWasCalled(sid_t &sid, store_address_t &storeId) {
|
||||
bool condition = false;
|
||||
if (not this->changedDatasetSid.notSet()) {
|
||||
condition = true;
|
||||
}
|
||||
sid = changedDatasetSid;
|
||||
storeId = storeIdForChangedSet;
|
||||
this->changedDatasetSid.raw = sid_t::INVALID_SID;
|
||||
this->storeIdForChangedSet = store_address_t::invalid();
|
||||
return condition;
|
||||
}
|
||||
|
||||
bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_address_t &storeId) {
|
||||
bool condition = false;
|
||||
if (not this->changedPoolVariableGpid.notSet()) {
|
||||
condition = true;
|
||||
}
|
||||
gpid = changedPoolVariableGpid;
|
||||
storeId = storeIdForChangedVariable;
|
||||
this->changedPoolVariableGpid.raw = gp_id_t::INVALID_GPID;
|
||||
this->storeIdForChangedVariable = store_address_t::invalid();
|
||||
return condition;
|
||||
}
|
||||
|
||||
void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); }
|
||||
|
@ -1,12 +1,11 @@
|
||||
#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/datapoollocal/LocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/StaticSharedDataset.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
@ -21,10 +20,14 @@ static constexpr lp_id_t uint32VarId = 2;
|
||||
static constexpr lp_id_t uint16Vec3Id = 3;
|
||||
static constexpr lp_id_t int64Vec2Id = 4;
|
||||
|
||||
static constexpr uint32_t testSetId = 0;
|
||||
static constexpr uint32_t testSetId0 = 0;
|
||||
static constexpr uint32_t testSetId1 = 1;
|
||||
static constexpr uint32_t testSetId2 = 2;
|
||||
static constexpr uint8_t dataSetMaxVariables = 10;
|
||||
|
||||
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId);
|
||||
static const auto testSid0 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0);
|
||||
static const auto testSid1 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1);
|
||||
static const auto testSid2 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId2);
|
||||
|
||||
static const gp_id_t uint8VarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint8VarId);
|
||||
static const gp_id_t floatVarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, floatVarId);
|
||||
@ -33,12 +36,12 @@ static const gp_id_t uint16Vec3Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BAS
|
||||
static const gp_id_t uint64Vec2Id = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, int64Vec2Id);
|
||||
} // namespace lpool
|
||||
|
||||
class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> {
|
||||
class LocalPoolStaticTestDataSet : public StaticSharedDataset<3> {
|
||||
public:
|
||||
LocalPoolStaticTestDataSet() : StaticLocalDataSet(lpool::testSid) {}
|
||||
LocalPoolStaticTestDataSet() : StaticSharedDataset(lpool::testSid1) {}
|
||||
|
||||
LocalPoolStaticTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
|
||||
: StaticLocalDataSet(sharedPool, setId) {}
|
||||
: StaticSharedDataset(sharedPool, setId) {}
|
||||
|
||||
lp_var_t<uint8_t> localPoolVarUint8 = lp_var_t<uint8_t>(lpool::uint8VarGpid, this);
|
||||
lp_var_t<float> localPoolVarFloat = lp_var_t<float>(lpool::floatVarGpid, this);
|
||||
@ -47,12 +50,12 @@ class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> {
|
||||
private:
|
||||
};
|
||||
|
||||
class LocalPoolTestDataSet : public LocalDataSet {
|
||||
class LocalPoolTestDataSet : public SharedDataSet {
|
||||
public:
|
||||
LocalPoolTestDataSet() : LocalDataSet(lpool::testSid, lpool::dataSetMaxVariables) {}
|
||||
LocalPoolTestDataSet() : SharedDataSet(lpool::testSid2, lpool::dataSetMaxVariables) {}
|
||||
|
||||
LocalPoolTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
|
||||
: LocalDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {}
|
||||
: SharedDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {}
|
||||
|
||||
lp_var_t<uint8_t> localPoolVarUint8 = lp_var_t<uint8_t>(lpool::uint8VarGpid, this);
|
||||
lp_var_t<float> localPoolVarFloat = lp_var_t<float>(lpool::floatVarGpid, this);
|
||||
@ -63,7 +66,7 @@ class LocalPoolTestDataSet : public LocalDataSet {
|
||||
|
||||
class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
public:
|
||||
explicit LocalPoolOwnerBase(MessageQueueIF& queue,
|
||||
explicit LocalPoolOwnerBase(MessageQueueIF& queue, MessageQueueId_t hkDestId,
|
||||
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
|
||||
~LocalPoolOwnerBase() override;
|
||||
@ -79,8 +82,6 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
|
||||
void setHkDestId(MessageQueueId_t id);
|
||||
|
||||
// ReturnValue_t initializeHkManagerAfterTaskCreation();
|
||||
|
||||
/** Command queue for housekeeping messages. */
|
||||
[[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); }
|
||||
|
||||
@ -91,25 +92,17 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
}
|
||||
|
||||
ReturnValue_t subscribePeriodicHk(bool enableReporting) {
|
||||
return hkHelper.enablePeriodicPacket(lpool::testSid, 200);
|
||||
return hkHelper.enablePeriodicPacket(lpool::testSid0, 50);
|
||||
}
|
||||
|
||||
ReturnValue_t reset();
|
||||
|
||||
bool changedDataSetCallbackWasCalled(sid_t& sid, store_address_t& storeId);
|
||||
bool changedVariableCallbackWasCalled(gp_id_t& gpid, store_address_t& storeId);
|
||||
|
||||
PeriodicHkGenerationHelper hkHelper;
|
||||
localpool::SharedPool sharedPool;
|
||||
LocalPoolTestDataSet dataset;
|
||||
LocalPoolTestDataSet set1;
|
||||
LocalPoolStaticTestDataSet set2;
|
||||
|
||||
private:
|
||||
sid_t changedDatasetSid;
|
||||
store_address_t storeIdForChangedSet;
|
||||
|
||||
gp_id_t changedPoolVariableGpid;
|
||||
store_address_t storeIdForChangedVariable;
|
||||
|
||||
PoolEntry<uint8_t> u8PoolEntry = PoolEntry<uint8_t>({0});
|
||||
PoolEntry<float> floatPoolEntry = PoolEntry<float>({0});
|
||||
PoolEntry<uint32_t> u32PoolEntry = PoolEntry<uint32_t>({0});
|
||||
|
Reference in New Issue
Block a user