fsfw/unittests/mock/TestPoolOwner.h
2024-11-07 12:26:00 +01:00

64 lines
2.1 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 subscribePeriodicHk(bool enableReporting) {
return hkHelper.enablePeriodicPacket(lpool::testSid0, 50);
}
ReturnValue_t reset();
hk::PeriodicHelper hkHelper;
SharedPool sharedPool;
LocalPoolTestDataSet set1;
StaticTestDataSet 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