fsfw/unittests/mock/TestPoolOwner.cpp

76 lines
2.3 KiB
C++
Raw Normal View History

2024-11-07 12:26:00 +01:00
#include "TestPoolOwner.h"
#include <fsfw/datapool/PoolReadGuard.h>
using namespace lpool;
TestPoolOwner::TestPoolOwner(MessageQueueIF &queue, MessageQueueId_t hkDestId, object_id_t objectId)
: SystemObject(objectId),
hkHelper(this, &queue, hkDestId),
sharedPool(TestPoolOwner::getObjectId()),
set1(sharedPool, lpool::testSetId1),
set2(sharedPool, lpool::testSetId2),
queue(queue) {}
TestPoolOwner::~TestPoolOwner() = default;
ReturnValue_t TestPoolOwner::initialize() {
sharedPool.addPoolEntry(lpool::uint8VarId, &u8PoolEntry);
sharedPool.addPoolEntry(lpool::floatVarId, &floatPoolEntry);
sharedPool.addPoolEntry(lpool::uint32VarId, &u32PoolEntry);
sharedPool.addPoolEntry(lpool::uint16Vec3Id, &u16VecPoolEntry);
sharedPool.addPoolEntry(lpool::int64Vec2Id, &i64VecPoolEntry);
ReturnValue_t result = hkHelper.initialize(&queue);
if (result != returnvalue::OK) {
return result;
}
return SystemObject::initialize();
}
SharedPool *TestPoolOwner::getOptionalSharedPool() { return &sharedPool; }
ReturnValue_t TestPoolOwner::serializeHkDataset(structure_id_t structureId, uint8_t *buf,
size_t maxSize) {
return returnvalue::OK;
}
ReturnValue_t TestPoolOwner::specifyHkDatasets(std::vector<hk::SetSpecification> &setList) {
return returnvalue::OK;
}
ReturnValue_t TestPoolOwner::reset() {
ReturnValue_t status = returnvalue::OK;
{
PoolReadGuard readHelper(&set1);
if (readHelper.getReadResult() != returnvalue::OK) {
status = readHelper.getReadResult();
}
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);
}
{
PoolReadGuard readHelper(&testUint32);
if (readHelper.getReadResult() != returnvalue::OK) {
status = readHelper.getReadResult();
}
testUint32.value = 0;
}
{
PoolReadGuard readHelper(&testInt64Vec);
if (readHelper.getReadResult() != returnvalue::OK) {
status = readHelper.getReadResult();
}
testInt64Vec.value[0] = 0;
testInt64Vec.value[1] = 0;
}
return status;
}
void TestPoolOwner::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); }