#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ #define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ #include #include #include #include #include #include #include #include #include "fsfw/datapool/PoolEntry.h" #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" namespace lpool { static constexpr lp_id_t uint8VarId = 0; static constexpr lp_id_t floatVarId = 1; 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 uint8_t dataSetMaxVariables = 10; static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId); 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); static const gp_id_t uint32Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint32VarId); static const gp_id_t uint16Vec3Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint16Vec3Id); static const gp_id_t uint64Vec2Id = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, int64Vec2Id); } // namespace lpool class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> { public: LocalPoolStaticTestDataSet() : StaticLocalDataSet(lpool::testSid) {} LocalPoolStaticTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId) : StaticLocalDataSet(sharedPool, setId) {} lp_var_t localPoolVarUint8 = lp_var_t(lpool::uint8VarGpid, this); lp_var_t localPoolVarFloat = lp_var_t(lpool::floatVarGpid, this); lp_vec_t localPoolUint16Vec = lp_vec_t(lpool::uint16Vec3Gpid, this); private: }; class LocalPoolTestDataSet : public LocalDataSet { public: LocalPoolTestDataSet() : LocalDataSet(lpool::testSid, lpool::dataSetMaxVariables) {} LocalPoolTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId) : LocalDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {} lp_var_t localPoolVarUint8 = lp_var_t(lpool::uint8VarGpid, this); lp_var_t localPoolVarFloat = lp_var_t(lpool::floatVarGpid, this); lp_vec_t localPoolUint16Vec = lp_vec_t(lpool::uint16Vec3Gpid, this); private: }; class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF { public: explicit LocalPoolOwnerBase(MessageQueueIF& queue, object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE); ~LocalPoolOwnerBase() override; [[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); } ReturnValue_t serializeDataset(sid_t structureId, uint8_t* buf, size_t maxSize) override; ReturnValue_t specifyDatasets(std::vector& setList) override; localpool::SharedPool* getOptionalSharedPool() override; ReturnValue_t initialize() override; void setHkDestId(MessageQueueId_t id); // ReturnValue_t initializeHkManagerAfterTaskCreation(); /** Command queue for housekeeping messages. */ [[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); } LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; [[nodiscard]] MessageQueueMock& getMockQueueHandle() const { return dynamic_cast(queue); } ReturnValue_t subscribePeriodicHk(bool enableReporting) { return hkHelper.enablePeriodicPacket(lpool::testSid, 200); } 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; private: sid_t changedDatasetSid; store_address_t storeIdForChangedSet; gp_id_t changedPoolVariableGpid; store_address_t storeIdForChangedVariable; PoolEntry u8PoolEntry = PoolEntry({0}); PoolEntry floatPoolEntry = PoolEntry({0}); PoolEntry u32PoolEntry = PoolEntry({0}); PoolEntry u16VecPoolEntry = PoolEntry({0, 0, 0}); PoolEntry i64VecPoolEntry = PoolEntry({0, 0}); lp_var_t testUint8 = lp_var_t(sharedPool, lpool::uint8VarId); lp_var_t testFloat = lp_var_t(sharedPool, lpool::floatVarId); lp_var_t testUint32 = lp_var_t(sharedPool, lpool::uint32VarId); lp_vec_t testUint16Vec = lp_vec_t(sharedPool, lpool::uint16Vec3Id); lp_vec_t testInt64Vec = lp_vec_t(sharedPool, lpool::int64Vec2Id); MessageQueueIF& queue; bool initialized = false; bool initializedAfterTaskCreation = false; }; #endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */