fsfw/unittests/mock/TestPoolOwner.h

65 lines
2.2 KiB
C++

#pragma once
#include <fsfw/housekeeping/GeneratesPeriodicHkIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include "poolDefinitions.h"
namespace lpool {
class TestPoolOwner : public SystemObject, public hk::GeneratesPeriodicHkIF {
public:
explicit TestPoolOwner(MessageQueueIF& queue, MessageQueueId_t hkDestId,
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE);
~TestPoolOwner() override;
[[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); }
ReturnValue_t serializeHkDataset(structure_id_t structureId, uint8_t* buf,
size_t maxSize) override;
ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setList) override;
SharedPool* getOptionalSharedPool() override;
ReturnValue_t initialize() override;
void setHkDestId(MessageQueueId_t id);
/** Command queue for housekeeping messages. */
[[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); }
[[nodiscard]] MessageQueueMock& getMockQueueHandle() const {
return dynamic_cast<MessageQueueMock&>(queue);
}
ReturnValue_t enablePeriodicHk(dp::structure_id_t structureId, dur_millis_t frequencyMs) {
return hkHelper.enablePeriodicPacket(structureId, frequencyMs);
}
ReturnValue_t reset();
hk::PeriodicHelper hkHelper;
SharedPool sharedPool;
Dataset set0;
StaticTestDataset set1;
TestDataset set2;
private:
PoolEntry<uint8_t> u8PoolEntry = PoolEntry<uint8_t>({0});
PoolEntry<float> floatPoolEntry = PoolEntry<float>({0});
PoolEntry<uint32_t> u32PoolEntry = PoolEntry<uint32_t>({0});
PoolEntry<uint16_t> u16VecPoolEntry = PoolEntry<uint16_t>({0, 0, 0});
PoolEntry<int64_t> i64VecPoolEntry = PoolEntry<int64_t>({0, 0});
dp::u8_t testUint8{sharedPool, lpool::uint8VarId};
dp::f32_t testFloat{sharedPool, lpool::floatVarId};
dp::u32_t testUint32{sharedPool, lpool::uint32VarId};
vec_t<uint16_t, 3> testUint16Vec{sharedPool, lpool::uint16Vec3Id};
vec_t<int64_t, 2> testInt64Vec{sharedPool, lpool::int64Vec2Id};
MessageQueueIF& queue;
bool initialized = false;
bool initializedAfterTaskCreation = false;
};
} // namespace lpool