compiles again

This commit is contained in:
Robin Müller 2024-11-05 17:02:45 +01:00
parent b1bd0d3af7
commit bc8aceb1dd
72 changed files with 654 additions and 885 deletions

View File

@ -123,7 +123,8 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
set(FSFW_TEST_TGT fsfw-tests)
set(FSFW_DUMMY_TGT fsfw-dummy)
add_library(${LIB_FSFW_NAME})
add_library(${LIB_FSFW_NAME} src/fsfw/datapoollocal/SharedPool.h
src/fsfw/datapoollocal/SharedPool.cpp)
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION

View File

@ -8,7 +8,8 @@ GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceC
CookieIF *comCookie, uint32_t transitionDelayMs)
: DeviceHandlerBase(objectId, deviceCommunication, comCookie),
transitionDelayMs(transitionDelayMs),
dataset(this) {}
sharedPool(DeviceHandlerBase::getObjectId()),
dataset(sharedPool) {}
GyroHandlerL3GD20H::~GyroHandlerL3GD20H() {}
@ -246,6 +247,8 @@ uint32_t GyroHandlerL3GD20H::getTransitionDelayMs(Mode_t from, Mode_t to) {
void GyroHandlerL3GD20H::setToGoToNormalMode(bool enable) { this->goNormalModeImmediately = true; }
// TODO
/*
ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &hkGenHelper) {
localDataPoolMap.emplace(l3gd20h::ANG_VELOC_X, new PoolEntry<float>({0.0}));
@ -256,6 +259,7 @@ ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &l
subdp::RegularHkPeriodicParams(dataset.getSid(), false, 10.0));
return returnvalue::OK;
}
*/
void GyroHandlerL3GD20H::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(l3gd20h::READ_REGS, 1, &dataset);

View File

@ -1,9 +1,9 @@
#ifndef MISSION_DEVICES_GYROL3GD20HANDLER_H_
#define MISSION_DEVICES_GYROL3GD20HANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <fsfw_hal/devicehandlers/devicedefinitions/gyroL3gHelpers.h>
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
#include "gyroL3gHelpers.h"
/**
* @brief Device Handler for the L3GD20H gyroscope sensor
@ -51,11 +51,12 @@ class GyroHandlerL3GD20H : public DeviceHandlerBase {
void fillCommandAndReplyMap() override;
void modeChanged() override;
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &hkGenHelper) override;
// ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
// PeriodicHkGenerationHelper &hkGenHelper) override;
private:
uint32_t transitionDelayMs = 0;
localpool::SharedPool sharedPool;
GyroPrimaryDataset dataset;
float absLimitX = l3gd20h::RANGE_DPS_00;

View File

@ -415,6 +415,7 @@ uint32_t MgmLIS3MDLHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { retur
void MgmLIS3MDLHandler::modeChanged(void) { internalState = InternalState::STATE_NONE; }
/*
ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) {
localDataPoolMap.emplace(mgmLis3::FIELD_STRENGTHS, &mgmXYZ);
@ -422,6 +423,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo
poolManager.setPeriodicFrequency(dataset.getSid(), 10'000);
return returnvalue::OK;
}
*/
void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLimit) {
this->absLimitX = xLimit;

View File

@ -1,7 +1,7 @@
#ifndef MISSION_DEVICES_MGMLIS3MDLHANDLER_H_
#define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_
#include <fsfw_hal/devicehandlers/devicedefinitions/mgmLis3Helpers.h>
#include "mgmLis3Helpers.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
@ -63,8 +63,8 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void fillCommandAndReplyMap() override;
void modeChanged(void) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) override;
// ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
// PeriodicHkGenerationHelper &poolManager) override;
private:
mgmLis3::MgmPrimaryDataset dataset;

View File

@ -9,7 +9,7 @@
MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF *comCookie, uint32_t transitionDelay)
: DeviceHandlerBase(objectId, deviceCommunication, comCookie),
primaryDataset(this),
primaryDataset(sharedPool),
transitionDelay(transitionDelay) {}
MgmRM3100Handler::~MgmRM3100Handler() {}
@ -307,12 +307,15 @@ void MgmRM3100Handler::fillCommandAndReplyMap() {
void MgmRM3100Handler::modeChanged() { internalState = InternalState::NONE; }
// TODO: Fix
/*
ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) {
localDataPoolMap.emplace(mgmRm3100::FIELD_STRENGTHS, &mgmXYZ);
poolManager.setPeriodicFrequency(primaryDataset.getSid(), 10'000);
return returnvalue::OK;
}
*/
uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) {
return this->transitionDelay;

View File

@ -1,7 +1,7 @@
#ifndef MISSION_DEVICES_MGMRM3100HANDLER_H_
#define MISSION_DEVICES_MGMRM3100HANDLER_H_
#include <fsfw_hal/devicehandlers/devicedefinitions/mgmRm3100Helpers.h>
#include "mgmRm3100Helpers.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
@ -52,8 +52,8 @@ class MgmRM3100Handler : public DeviceHandlerBase {
void fillCommandAndReplyMap() override;
void modeChanged(void) override;
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) override;
// ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
// PeriodicHkGenerationHelper &poolManager) override;
private:
enum class InternalState {

View File

@ -1,4 +1,4 @@
#include <fsfw_hal/devicehandlers/devicedefinitions/gyroL3gHelpers.h>
#include "gyroL3gHelpers.h"
float l3gd20h::ctrlReg4ToSensitivity(uint8_t reg) {
bool fsH = reg & l3gd20h::SET_FS_1;

View File

@ -1,8 +1,8 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include <cstdint>
@ -124,8 +124,8 @@ class GyroPrimaryDataset : public StaticLocalDataSet<5> {
setAllVariablesReadOnly();
}
/** Constructor for the data creator */
GyroPrimaryDataset(PeriodicHkGenerationIF* hkOwner)
: StaticLocalDataSet(hkOwner, l3gd20h::GYRO_DATASET_ID) {}
GyroPrimaryDataset(localpool::SharedPool& sharedPool)
: StaticLocalDataSet(sharedPool, l3gd20h::GYRO_DATASET_ID) {}
/* Angular velocities in degrees per second (DPS) */
lp_var_t<float> angVelocX = lp_var_t<float>(sid.objectId, l3gd20h::ANG_VELOC_X, this);

View File

@ -1,9 +1,9 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMLIS3HANDLERDEFS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMLIS3HANDLERDEFS_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include <cstdint>
@ -173,8 +173,8 @@ enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS = 0, TEMPERATURE_CELCIUS = 1, SET_IS
class MgmPrimaryDataset : public StaticLocalDataSet<4> {
public:
MgmPrimaryDataset(PeriodicHkGenerationIF* hkOwner)
: StaticLocalDataSet(hkOwner, MGM_DATA_SET_ID) {}
MgmPrimaryDataset(localpool::SharedPool& sharedPool)
: StaticLocalDataSet(sharedPool, MGM_DATA_SET_ID) {}
MgmPrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATA_SET_ID)) {}

View File

@ -1,10 +1,10 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include <cstdint>
@ -105,8 +105,8 @@ enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS = 0, VALID = 1 };
class Rm3100PrimaryDataset : public StaticLocalDataSet<3> {
public:
Rm3100PrimaryDataset(PeriodicHkGenerationIF* hkOwner)
: StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {}
Rm3100PrimaryDataset(localpool::SharedPool& sharedPool)
: StaticLocalDataSet(sharedPool, MGM_DATASET_ID) {}
Rm3100PrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {}

View File

@ -2,7 +2,7 @@
ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth)
: ControllerBase(objectId, commandQueueDepth),
poolManager(this, commandQueue),
hkHelper(this, commandQueue),
actionHelper(this, commandQueue) {}
ExtendedControllerBase::~ExtendedControllerBase() = default;
@ -25,7 +25,7 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa
if (result == returnvalue::OK) {
return result;
}
return poolManager.handleHousekeepingMessage(message);
return hkHelper.handleHousekeepingMessage(message);
}
void ExtendedControllerBase::handleQueue() {
@ -48,7 +48,7 @@ void ExtendedControllerBase::handleQueue() {
continue;
}
result = poolManager.handleHousekeepingMessage(&command);
result = hkHelper.handleHousekeepingMessage(&command);
if (result == returnvalue::OK) {
continue;
}
@ -72,11 +72,7 @@ ReturnValue_t ExtendedControllerBase::initialize() {
return result;
}
return poolManager.initialize(commandQueue);
}
ReturnValue_t ExtendedControllerBase::initializeAfterTaskCreation() {
//return poolManager.initializeAfterTaskCreation();
return hkHelper.initialize(commandQueue);
}
ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
@ -84,10 +80,10 @@ ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
performControlOperation(opCode);
/* We do this after performing control operation because variables will be set changed
in this function. */
poolManager.performHkOperation();
hkHelper.performHkOperation();
return returnvalue::OK;
}
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); }
PeriodicHkGenerationHelper *ExtendedControllerBase::getHkManagerHandle() { return &poolManager; }
// PeriodicHkGenerationHelper *ExtendedControllerBase::getHkManagerHandle() { return &hkHelper; }

View File

@ -3,8 +3,8 @@
#include "ControllerBase.h"
#include "fsfw/action.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
/**
* @brief Extends the basic ControllerBase with commonly used components
@ -27,10 +27,9 @@ class ExtendedControllerBase : public ControllerBase,
/* ExecutableObjectIF overrides */
ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initializeAfterTaskCreation() override;
protected:
PeriodicHkGenerationHelper poolManager;
PeriodicHkGenerationHelper hkHelper;
ActionHelper actionHelper;
/**
@ -49,17 +48,12 @@ class ExtendedControllerBase : public ControllerBase,
// Handle the four messages mentioned above
void handleQueue() override;
/* HasActionsIF overrides */
// HasActionsIF overrides
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
/* HasLocalDatapoolIF overrides */
PeriodicHkGenerationHelper* getHkManagerHandle() override;
// HasLocalDatapoolIF overrides
[[nodiscard]] object_id_t getObjectId() const override;
//[[nodiscard]] uint32_t getPeriodicOperationFrequency() const override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) override = 0;
// Mode abstract functions
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,

View File

@ -52,16 +52,6 @@ void* PoolEntry<T>::getRawData() {
return this->address;
}
template <typename T>
void PoolEntry<T>::setValid(bool isValid) {
this->valid = isValid;
}
template <typename T>
bool PoolEntry<T>::getValid() {
return valid;
}
template <typename T>
void PoolEntry<T>::print() {
const char* validString = nullptr;

View File

@ -104,16 +104,7 @@ class PoolEntry : public PoolEntryIF {
* @brief This operation returns a the address pointer casted to void*.
*/
void* getRawData();
/**
* @brief This method allows to set the valid information
* of the pool entry.
*/
void setValid(bool isValid);
/**
* @brief This method allows to get the valid information
* of the pool entry.
*/
bool getValid();
/**
* @brief This is a debug method that prints all values and the valid
* information to the screen. It prints all array entries in a row.

View File

@ -39,14 +39,7 @@ class PoolEntryIF {
* @brief This operation returns a the address pointer casted to void*.
*/
virtual void* getRawData() = 0;
/**
* @brief This method allows to set the valid information of the pool entry.
*/
virtual void setValid(bool isValid) = 0;
/**
* @brief This method allows to set the valid information of the pool entry.
*/
virtual bool getValid() = 0;
/**
* @brief This is a debug method that prints all values and the valid
* information to the screen. It prints all array entries in a row.

View File

@ -6,6 +6,7 @@
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapoollocal/LocalPoolVector.h"
#include "fsfw/datapoollocal/SharedLocalDataSet.h"
#include "fsfw/datapoollocal/SharedPool.h"
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#endif /* FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ */

View File

@ -1,7 +1,6 @@
#ifndef FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#define FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#pragma once
class PeriodicHkGenerationHelper;
class LocalPoolManager;
class MutexIF;
/**
@ -18,9 +17,7 @@ class AccessPoolManagerIF {
* This function is protected because it should only be used by the
* class imlementing the interface.
*/
virtual PeriodicHkGenerationHelper* getPoolManagerHandle() = 0;
virtual LocalPoolManager* getPoolManagerHandle() = 0;
protected:
};
#endif /* FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_ */

View File

@ -1,8 +1,8 @@
#include "fsfw/datapoollocal/LocalDataSet.h"
LocalDataSet::LocalDataSet(PeriodicHkGenerationIF *hkOwner, uint32_t setId,
LocalDataSet::LocalDataSet(localpool::SharedPool& sharedPool, uint32_t setId,
const size_t maxNumberOfVariables)
: LocalPoolDataSetBase(hkOwner, setId, nullptr, maxNumberOfVariables),
: LocalPoolDataSetBase(sharedPool, setId, nullptr, maxNumberOfVariables),
poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());
}

View File

@ -20,9 +20,9 @@
*/
class LocalDataSet : public LocalPoolDataSetBase {
public:
LocalDataSet(PeriodicHkGenerationIF* hkOwner, uint32_t setId, const size_t maxSize);
LocalDataSet(localpool::SharedPool& sharedPool, uint32_t setId, size_t maxSize);
LocalDataSet(sid_t sid, const size_t maxSize);
LocalDataSet(sid_t sid, size_t maxSize);
virtual ~LocalDataSet();

View File

@ -10,29 +10,13 @@
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "internal/HasLocalDpIFUserAttorney.h"
LocalPoolDataSetBase::LocalPoolDataSetBase(PeriodicHkGenerationIF *hkOwner, uint32_t setId,
LocalPoolDataSetBase::LocalPoolDataSetBase(localpool::SharedPool &sharedPool, uint32_t setId,
PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables)
: base(registeredVariablesArray, maxNumberOfVariables) {
if (hkOwner == nullptr) {
// Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl;
#else
sif::printError(
"LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
"invalid!\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return;
}
AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
: base(registeredVariablesArray, maxNumberOfVariables), sharedPool(&sharedPool) {
mutexIfSingleDataCreator = sharedPool.getLocalPoolMutex();
if (accessor != nullptr) {
poolManager = accessor->getPoolManagerHandle();
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
}
this->sid.objectId = hkOwner->getObjectId();
this->sid.objectId = sharedPool.getOwnerId();
this->sid.ownerSetId = setId;
/* Data creators get a periodic helper for periodic HK data generation. */
@ -46,10 +30,9 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF **registere
: base(registeredVariablesArray, maxNumberOfVariables) {
auto *hkOwner = ObjectManager::instance()->get<PeriodicHkGenerationIF>(sid.objectId);
if (hkOwner != nullptr) {
AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
if (accessor != nullptr) {
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
poolManager = accessor->getPoolManagerHandle();
sharedPool = hkOwner->getOptionalSharedPool();
if (sharedPool != nullptr) {
mutexIfSingleDataCreator = sharedPool->getLocalPoolMutex();
}
}
@ -152,8 +135,8 @@ bool LocalPoolDataSetBase::getReportingEnabled() const { return reportingEnabled
sid_t LocalPoolDataSetBase::getSid() const { return sid; }
object_id_t LocalPoolDataSetBase::getCreatorObjectId() {
if (poolManager != nullptr) {
return poolManager->getCreatorObjectId();
if (sharedPool != nullptr) {
return sharedPool->getOwnerId();
}
return objects::NO_OBJECT;
}
@ -175,5 +158,10 @@ ReturnValue_t LocalPoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, uin
uint16_t LocalPoolDataSetBase::getFillCount() const { return base.getFillCount(); }
ReturnValue_t LocalPoolDataSetBase::registerVariable(PoolVariableIF *variable) {
base.registerVariable(variable);
return base.registerVariable(variable);
}
void LocalPoolDataSetBase::setContainer(PoolVariableIF **variablesContainer) {
return base.setContainer(variablesContainer);
}
PoolVariableIF **LocalPoolDataSetBase::getContainer() const { return base.getContainer(); }

View File

@ -6,6 +6,7 @@
#include "MarkChangedIF.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolDataSetBase.h"
#include "fsfw/datapoollocal/SharedPool.h"
#include "localPoolDefinitions.h"
class PeriodicHkGenerationHelper;
@ -51,7 +52,7 @@ class LocalPoolDataSetBase : public SerializeIF, public PoolDataSetIF {
* This constructor also initializes the components required for
* periodic handling.
*/
LocalPoolDataSetBase(PeriodicHkGenerationIF* hkOwner, uint32_t setId,
LocalPoolDataSetBase(localpool::SharedPool& sharedPool, uint32_t setId,
PoolVariableIF** registeredVariablesArray, size_t maxNumberOfVariables);
/**
@ -111,7 +112,6 @@ class LocalPoolDataSetBase : public SerializeIF, public PoolDataSetIF {
* by data consumers to prevent accidentally changing pool data.
*/
void setAllVariablesReadOnly();
void setValidityBufferGeneration(bool withValidityBuffer);
[[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
@ -180,21 +180,6 @@ class LocalPoolDataSetBase : public SerializeIF, public PoolDataSetIF {
*/
bool valid = false;
/**
* Can be used to mark the dataset as changed, which is used
* by the LocalDataPoolManager to send out update messages.
*/
bool changed = false;
/**
* Specify whether the validity buffer is serialized too when serializing
* or deserializing the packet. Each bit of the validity buffer will
* contain the validity state of the pool variables from left to right.
* The size of validity buffer thus will be ceil(N / 8) with N = number of
* pool variables.
*/
// bool withValidityBuffer = true;
/**
* @brief This is a small helper function to facilitate locking
* the global data pool.
@ -211,9 +196,7 @@ class LocalPoolDataSetBase : public SerializeIF, public PoolDataSetIF {
*/
ReturnValue_t unlockDataPool() override;
// PeriodicHousekeepingHelper* periodicHelper = nullptr;
// dur_millis_t collectionFrequency = 0;
PeriodicHkGenerationHelper* poolManager = nullptr;
localpool::SharedPool* sharedPool = nullptr;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ */

View File

@ -1,29 +1,20 @@
#include "fsfw/datapoollocal/LocalPoolObjectBase.h"
#include "fsfw/datapoollocal/AccessLocalPoolF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "internal/HasLocalDpIFUserAttorney.h"
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, PeriodicHkGenerationIF* hkOwner,
LocalPoolObjectBase::LocalPoolObjectBase(localpool::SharedPool& sharedPool, lp_id_t poolId,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
: localPoolId(poolId), readWriteMode(setReadWriteMode) {
: localPoolId(poolId), readWriteMode(setReadWriteMode), sharedPool(&sharedPool) {
if (poolId == PoolVariableIF::NO_PARAMETER) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
<< "which is the NO_PARAMETER value!" << std::endl;
#endif
}
if (hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool " << "owner is a invalid!"
<< std::endl;
#endif
return;
}
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
hkManager = poolManAccessor->getPoolManagerHandle();
if (dataSet != nullptr) {
dataSet->registerVariable(this);
@ -59,11 +50,6 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
return;
}
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
if (accessor != nullptr) {
hkManager = accessor->getPoolManagerHandle();
}
if (dataSet != nullptr) {
dataSet->registerVariable(this);
}
@ -75,10 +61,6 @@ lp_id_t LocalPoolObjectBase::getDataPoolId() const { return localPoolId; }
void LocalPoolObjectBase::setDataPoolId(lp_id_t poolId) { this->localPoolId = poolId; }
void LocalPoolObjectBase::setChanged(bool changed) { this->changed = changed; }
bool LocalPoolObjectBase::hasChanged() const { return changed; }
void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
this->readWriteMode = newReadWriteMode;
}

View File

@ -2,22 +2,21 @@
#define FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_
#include "MarkChangedIF.h"
#include "SharedPool.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "localPoolDefinitions.h"
class PeriodicHkGenerationHelper;
class DataSetIF;
class PeriodicHkGenerationIF;
/**
* @brief This class serves as a non-template base for pool objects like pool variables
* or pool vectors.
*/
class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF {
class LocalPoolObjectBase : public PoolVariableIF {
public:
LocalPoolObjectBase(lp_id_t poolId, PeriodicHkGenerationIF* hkOwner, DataSetIF* dataSet,
LocalPoolObjectBase(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode);
LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
@ -26,9 +25,6 @@ class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF {
void setReadWriteMode(pool_rwm_t newReadWriteMode) override;
pool_rwm_t getReadWriteMode() const override;
void setChanged(bool changed) override;
bool hasChanged() const override;
lp_id_t getDataPoolId() const override;
void setDataPoolId(lp_id_t poolId);
@ -38,16 +34,6 @@ class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF {
* the data pool id is stored.
*/
uint32_t localPoolId = PoolVariableIF::NO_PARAMETER;
/**
* @brief The valid information as it was stored in the data pool
* is copied to this attribute.
*/
bool valid = false;
/**
* @brief A local pool variable can be marked as changed.
*/
bool changed = false;
/**
* @brief The information whether the class is read-write or
@ -56,7 +42,7 @@ class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF {
ReadWriteMode_t readWriteMode = pool_rwm_t::VAR_READ_WRITE;
//! @brief Pointer to the class which manages the HK pool.
PeriodicHkGenerationHelper* hkManager = nullptr;
localpool::SharedPool* sharedPool = nullptr;
void reportReadCommitError(const char* variableType, ReturnValue_t error, bool read,
object_id_t objectId, lp_id_t lpId);

View File

@ -7,9 +7,9 @@
#include "../serialize/SerializeAdapter.h"
#include "../serviceinterface/ServiceInterface.h"
#include "AccessLocalPoolF.h"
#include "PeriodicHkGenerationIF.h"
#include "LocalPoolObjectBase.h"
#include "PeriodicHkGenerationHelper.h"
#include "PeriodicHkGenerationIF.h"
#include "internal/LocalDpManagerAttorney.h"
/**
@ -45,7 +45,7 @@ class LocalPoolVariable : public LocalPoolObjectBase {
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*/
LocalPoolVariable(PeriodicHkGenerationIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
LocalPoolVariable(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
@ -119,18 +119,6 @@ class LocalPoolVariable : public LocalPoolObjectBase {
ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief This commit function can be used to set the pool variable valid
* as well.
* @param setValid
* @param timeoutType
* @param timeoutMs
* @return
*/
ReturnValue_t commit(bool setValid,
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
LocalPoolVariable<T>& operator=(const T& newValue);
LocalPoolVariable<T>& operator=(const LocalPoolVariable<T>& newPoolVariable);

View File

@ -6,9 +6,9 @@
#endif
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(PeriodicHkGenerationIF* hkOwner, lp_id_t poolId,
inline LocalPoolVariable<T>::LocalPoolVariable(localpool::SharedPool& sharedPool, lp_id_t poolId,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
: LocalPoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {}
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
@ -24,10 +24,10 @@ inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId, DataSetIF*
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if (hkManager == nullptr) {
if (sharedPool == nullptr) {
return readWithoutLock();
}
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*sharedPool);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
@ -40,33 +40,27 @@ inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
targetObjectId, localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
return result;
}
this->value = *(poolEntry->getDataPtr());
this->valid = poolEntry->getValid();
return returnvalue::OK;
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if (hkManager == nullptr) {
if (sharedPool == nullptr) {
return commitWithoutLock();
}
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager);
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*sharedPool);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
@ -79,23 +73,17 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutTy
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
targetObjectId, localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId);
return result;
}
*(poolEntry->getDataPtr()) = this->value;
poolEntry->setValid(this->valid);
return returnvalue::OK;
}

View File

@ -47,7 +47,7 @@ class LocalPoolVector : public LocalPoolObjectBase {
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
*/
LocalPoolVector(PeriodicHkGenerationIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
LocalPoolVector(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**

View File

@ -6,10 +6,10 @@
#endif
template <typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(PeriodicHkGenerationIF* hkOwner, lp_id_t poolId,
DataSetIF* dataSet,
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(localpool::SharedPool& sharedPool,
lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
: LocalPoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {}
template <typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId,
@ -26,30 +26,24 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, Dat
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*sharedPool), timeoutType, timeoutMs);
return readWithoutLock();
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
targetObjectId, localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
memset(this->value, 0, vectorSize * sizeof(T));
if (result != returnvalue::OK) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId);
return result;
}
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
this->valid = poolEntry->getValid();
return returnvalue::OK;
}
@ -64,28 +58,22 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
MutexGuard mg(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
MutexGuard mg(LocalDpManagerAttorney::getMutexHandle(*sharedPool), timeoutType, timeoutMs);
return commitWithoutLock();
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
targetObjectId, localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId);
return result;
}
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
poolEntry->setValid(this->valid);
return returnvalue::OK;
}

View File

@ -18,40 +18,27 @@
object_id_t PeriodicHkGenerationHelper::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
PeriodicHkGenerationHelper::PeriodicHkGenerationHelper(PeriodicHkGenerationIF* owner,
MessageQueueIF* queueToUse,
bool appendValidityBuffer)
: appendValidityBuffer(appendValidityBuffer) {
MessageQueueIF* queueToUse) {
if (owner == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", returnvalue::FAILED,
"Invalid supplied owner");
return;
}
this->owner = owner;
mutex = MutexFactory::instance()->createMutex();
if (mutex == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", returnvalue::FAILED,
"Could not create mutex");
}
hkQueue = queueToUse;
}
PeriodicHkGenerationHelper::~PeriodicHkGenerationHelper() {
if (mutex != nullptr) {
MutexFactory::instance()->deleteMutex(mutex);
}
}
ReturnValue_t PeriodicHkGenerationHelper::initialize(MessageQueueIF* queueToUse) {
if (queueToUse == nullptr) {
/* Error, all destinations invalid */
// Error, all destinations invalid
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", QUEUE_OR_DESTINATION_INVALID);
}
hkQueue = queueToUse;
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore == nullptr) {
/* Error, all destinations invalid */
// Error, all destinations invalid
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", returnvalue::FAILED,
"Could not set IPC store.");
return returnvalue::FAILED;
@ -73,22 +60,10 @@ ReturnValue_t PeriodicHkGenerationHelper::initialize(MessageQueueIF* queueToUse)
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::initializeHousekeepingPoolEntriesOnce() {
if (not mapInitialized) {
ReturnValue_t result = owner->initializeLocalDataPool(localPoolMap, *this);
if (result == returnvalue::OK) {
mapInitialized = true;
}
return result;
}
printWarningOrError(sif::OutputTypes::OUT_WARNING, "initializeHousekeepingPoolEntriesOnce",
returnvalue::FAILED, "The map should only be initialized once");
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::performHkOperation() {
ReturnValue_t status = returnvalue::OK;
timeval now{};
Clock::getClockMonotonic(&now);
for (auto& setSpec : setList) {
switch (setSpec.reportingType) {
case (periodicHk::ReportingType::PERIODIC): {
@ -96,7 +71,7 @@ ReturnValue_t PeriodicHkGenerationHelper::performHkOperation() {
/* Periodic packets shall only be generated from datasets */
continue;
}
performPeriodicHkGeneration(setSpec);
performPeriodicHkGeneration(setSpec, now);
break;
}
default:
@ -104,48 +79,9 @@ ReturnValue_t PeriodicHkGenerationHelper::performHkOperation() {
return returnvalue::FAILED;
}
}
resetHkUpdateResetHelper();
return status;
}
ReturnValue_t PeriodicHkGenerationHelper::addUpdateToStore(HousekeepingSnapshot& updatePacket,
store_address_t& storeId) {
size_t updatePacketSize = updatePacket.getSerializedSize();
uint8_t* storePtr = nullptr;
ReturnValue_t result =
ipcStore->getFreeElement(&storeId, updatePacket.getSerializedSize(), &storePtr);
if (result != returnvalue::OK) {
return result;
}
size_t serializedSize = 0;
result = updatePacket.serialize(&storePtr, &serializedSize, updatePacketSize,
SerializeIF::Endianness::MACHINE);
return result;
;
}
/*
ReturnValue_t PeriodicHkGenerationHelper::subscribeForPeriodicPacket(subdp::ParamsBase& params) {
HkReceiver hkReceiver;
hkReceiver.dataId.sid = params.sid;
hkReceiver.reportingType = ReportingType::PERIODIC;
hkReceiver.dataType = DataType::DATA_SET;
if (params.receiver == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = params.receiver;
}
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid);
if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting);
}
hkReceivers.push_back(hkReceiver);
return returnvalue::OK;
}
*/
ReturnValue_t PeriodicHkGenerationHelper::handleHousekeepingMessage(CommandMessage* message) {
Command_t command = message->getCommand();
sid_t sid = HousekeepingMessage::getSid(message);
@ -172,7 +108,7 @@ ReturnValue_t PeriodicHkGenerationHelper::handleHousekeepingMessage(CommandMessa
case (HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
dur_millis_t newCollIntvl = 0;
HousekeepingMessage::getCollectionIntervalModificationCommand(message, newCollIntvl);
result = changeCollectionInterval(sid, newCollIntvl);
result = setCollectionInterval(sid, newCollIntvl);
break;
}
@ -198,44 +134,47 @@ ReturnValue_t PeriodicHkGenerationHelper::handleHousekeepingMessage(CommandMessa
return result;
}
ReturnValue_t PeriodicHkGenerationHelper::printPoolEntry(lp_id_t localPoolId) {
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "printPoolEntry",
localpool::POOL_ENTRY_NOT_FOUND);
return localpool::POOL_ENTRY_NOT_FOUND;
}
poolIter->second->print();
return returnvalue::OK;
}
MutexIF* PeriodicHkGenerationHelper::getMutexHandle() { return mutex; }
PeriodicHkGenerationIF* PeriodicHkGenerationHelper::getOwner() { return owner; }
ReturnValue_t PeriodicHkGenerationHelper::generateHousekeepingPacket(sid_t sid,
MessageQueueId_t destination) {
store_address_t storeId;
HousekeepingPacketDownlink hkPacket(sid, dataSet);
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
return DATASET_NOT_FOUND;
}
auto setSpec = optSetSpec.value();
uint8_t* dataPtr = nullptr;
const size_t maxSize = setSpec.size;
ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &dataPtr);
if (result != returnvalue::OK) {
return result;
}
result = owner->serializeDataset(sid, dataPtr, maxSize);
if (result != returnvalue::OK) {
return result;
}
HousekeepingPacketDownlink hkPacket(sid, dataPtr, maxSize);
size_t serializedSize = 0;
ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, &serializedSize);
result = hkPacket.serialize(&dataPtr, &serializedSize, maxSize, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK or serializedSize == 0) {
return result;
}
/* Now we set a HK message and send it the HK packet destination. */
// Now we set a HK message and send it the HK packet destination.
CommandMessage hkMessage;
HousekeepingMessage::setHkReportReply(&hkMessage, sid, storeId);
if (hkQueue == nullptr) {
/* Error, no queue available to send packet with. */
// Error, no queue available to send packet with.
printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
if (destination == MessageQueueIF::NO_QUEUE) {
if (hkDestinationId == MessageQueueIF::NO_QUEUE) {
/* Error, all destinations invalid */
// Error, all destinations invalid
printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
@ -247,73 +186,51 @@ ReturnValue_t PeriodicHkGenerationHelper::generateHousekeepingPacket(sid_t sid,
}
ReturnValue_t PeriodicHkGenerationHelper::serializeHkPacketIntoStore(
HousekeepingPacketDownlink& hkPacket, store_address_t& storeId, size_t* serializedSize) {
uint8_t* dataPtr = nullptr;
const size_t maxSize = hkPacket.getSerializedSize();
ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &dataPtr);
if (result != returnvalue::OK) {
return result;
}
HousekeepingPacketDownlink& hkPacket, store_address_t& storeId, size_t* serializedSize) {}
return hkPacket.serialize(&dataPtr, serializedSize, maxSize, SerializeIF::Endianness::NETWORK);
}
void PeriodicHkGenerationHelper::performPeriodicHkGeneration(SetSpecification& receiver) {
sid_t sid = receiver.dataId.sid;
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
DATASET_NOT_FOUND);
void PeriodicHkGenerationHelper::performPeriodicHkGeneration(periodicHk::SetSpecification& setSpec,
timeval& now) {
if (not setSpec.periodicCollectionEnabled) {
return;
}
if (not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet)) {
return;
}
// timeval now{};
Clock::getClockMonotonic(&now);
// PeriodicHousekeepingHelper* periodicHelper =
// LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
sid_t sid = setSpec.dataId.sid;
// if (periodicHelper == nullptr) {
/* Configuration error */
// return;
//}
// if (not periodicHelper->checkOpNecessary()) {
// return;
//}
ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true);
timeval diff = now - setSpec.lastGenerated;
dur_millis_t diffMillis = diff.tv_sec * 1000 + diff.tv_usec / 1000;
if (diffMillis > setSpec.collectionFrequency) {
ReturnValue_t result = generateHousekeepingPacket(sid);
setSpec.lastGenerated = now;
if (result != returnvalue::OK) {
/* Configuration error */
// Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed."
<< std::endl;
#else
sif::printWarning("LocalDataPoolManager::performPeriodicHkOperation: HK generation failed.\n");
sif::printWarning(
"LocalDataPoolManager::performPeriodicHkOperation: HK generation failed.\n");
#endif
return;
}
}
}
ReturnValue_t PeriodicHkGenerationHelper::togglePeriodicGeneration(sid_t sid, bool enable) {
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet == nullptr) {
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
DATASET_NOT_FOUND);
return DATASET_NOT_FOUND;
}
if ((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
optSetSpec.value().periodicCollectionEnabled = enable;
return returnvalue::OK;
}
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
return returnvalue::OK;
}
std::optional<periodicHk::SetSpecification> PeriodicHkGenerationHelper::getSetSpecification(sid_t structureId) {
std::optional<periodicHk::SetSpecification> PeriodicHkGenerationHelper::getSetSpecification(
sid_t structureId) {
for (auto& receiver : setList) {
if (receiver.dataId.sid == structureId) {
return receiver;
@ -322,8 +239,8 @@ ReturnValue_t PeriodicHkGenerationHelper::togglePeriodicGeneration(sid_t sid, bo
return std::nullopt;
}
ReturnValue_t PeriodicHkGenerationHelper::changeCollectionInterval(sid_t sid,
dur_millis_t newCollectionIntervalMs) {
ReturnValue_t PeriodicHkGenerationHelper::setCollectionInterval(
sid_t sid, dur_millis_t newCollectionIntervalMs) {
bool wasUpdated = false;
for (auto& receiver : setList) {
if (receiver.dataId.sid == sid) {
@ -332,15 +249,14 @@ ReturnValue_t PeriodicHkGenerationHelper::changeCollectionInterval(sid_t sid,
}
}
if (!wasUpdated) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",
DATASET_NOT_FOUND);
printWarningOrError(sif::OutputTypes::OUT_WARNING, "setCollectionInterval", DATASET_NOT_FOUND);
return DATASET_NOT_FOUND;
}
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::generateSetStructurePacket(sid_t sid) {
/* Get and check dataset first. */
// Get and check dataset first.
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
@ -349,28 +265,26 @@ ReturnValue_t PeriodicHkGenerationHelper::generateSetStructurePacket(sid_t sid)
}
auto setSpec = *optSetSpec;
bool reportingEnabled = setSpec.;
dur_millis_t collectionInterval = 0;
auto optCollectionInterval = getCollectionFrequency(sid);
if (optCollectionInterval.has_value()) {
collectionInterval = optCollectionInterval.value();
}
// Generate set packet which can be serialized.
HousekeepingSetPacket setPacket(sid, reportingEnabled, collectionInterval, dataSet);
size_t expectedSize = setPacket.getSerializedSize();
uint8_t* storePtr = nullptr;
store_address_t storeId;
ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize, &storePtr);
ReturnValue_t result = ipcStore->getFreeElement(&storeId, setSpec.size, &storePtr);
if (result != returnvalue::OK) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "generateSetStructurePacket",
returnvalue::FAILED, "Could not get free element from IPC store.");
return result;
}
dur_millis_t collectionInterval = 0;
HousekeepingSetPacket setPacket(sid, setSpec.periodicCollectionEnabled, collectionInterval);
if (result != returnvalue::OK) {
return result;
}
size_t expectedSize = setPacket.getSerializedSize();
// Serialize set packet into store.
size_t size = 0;
result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG);
result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
ipcStore->deleteData(storeId);
return result;
@ -391,7 +305,35 @@ ReturnValue_t PeriodicHkGenerationHelper::generateSetStructurePacket(sid_t sid)
return result;
}
MutexIF* PeriodicHkGenerationHelper::getLocalPoolMutex() { return this->mutex; }
ReturnValue_t PeriodicHkGenerationHelper::enablePeriodicPacket(
sid_t structureId, std::optional<dur_millis_t> frequencyMs) {
// Get and check dataset first.
auto optSetSpec = getSetSpecification(structureId);
if (!optSetSpec.has_value()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
DATASET_NOT_FOUND);
return DATASET_NOT_FOUND;
}
auto setSpec = optSetSpec.value();
setSpec.periodicCollectionEnabled = true;
if (frequencyMs) {
setSpec.collectionFrequency = frequencyMs.value();
}
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::disablePeriodicPacket(sid_t structureId) {
// Get and check dataset first.
auto optSetSpec = getSetSpecification(structureId);
if (!optSetSpec.has_value()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
DATASET_NOT_FOUND);
return DATASET_NOT_FOUND;
}
auto setSpec = optSetSpec.value();
setSpec.periodicCollectionEnabled = false;
return returnvalue::OK;
}
object_id_t PeriodicHkGenerationHelper::getCreatorObjectId() const { return owner->getObjectId(); }
@ -449,8 +391,6 @@ void PeriodicHkGenerationHelper::printWarningOrError(sif::OutputTypes outputType
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
}
PeriodicHkGenerationHelper* PeriodicHkGenerationHelper::getPoolManagerHandle() { return this; }
void PeriodicHkGenerationHelper::setHkDestinationId(MessageQueueId_t hkDestId) {
hkDestinationId = hkDestId;
}

View File

@ -56,28 +56,32 @@ namespace periodicHk {
/** The data pool manager will keep an internal map of HK receivers. */
struct SetSpecification {
SetSpecification(sid_t structureId, dur_millis_t collectionFrequency,
friend class ::PeriodicHkGenerationHelper;
public:
SetSpecification(sid_t structureId, size_t size, dur_millis_t collectionFrequency,
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE)
: dataId(DataId::forSetId(structureId)),
collectionFrequency(collectionFrequency),
size(size),
destinationQueue(destinationQueue) {};
/** Object ID of receiver */
// Object ID of receiver
object_id_t objectId = objects::NO_OBJECT;
DataType dataType = DataType::DATA_SET;
DataId dataId;
dur_millis_t collectionFrequency = 0;
size_t size = 0;
ReportingType reportingType = ReportingType::PERIODIC;
bool periodicCollectionEnabled = false;
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
};
}
class LocalPoolDataSetBase;
class HousekeepingSnapshot;
class PeriodicHkGenerationIF;
class LocalDataPool;
private:
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
bool periodicCollectionEnabled = false;
timeval lastGenerated{};
};
} // namespace periodicHk
/**
* @brief This class is the managing instance for the local data pool.
@ -103,8 +107,7 @@ class LocalDataPool;
* Each pool entry has a valid state too.
* @author R. Mueller
*/
class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF,
public AccessPoolManagerIF {
class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
//! Some classes using the pool manager directly need to access class internals of the
//! manager. The attorney provides granular control of access to these internals.
friend class LocalDpManagerAttorney;
@ -130,9 +133,7 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF,
* @param appendValidityBuffer Specify whether a buffer containing the
* validity state is generated when serializing or deserializing packets.
*/
PeriodicHkGenerationHelper(PeriodicHkGenerationIF* owner, MessageQueueIF* queueToUse,
bool appendValidityBuffer = true);
~PeriodicHkGenerationHelper() override;
PeriodicHkGenerationHelper(PeriodicHkGenerationIF* owner, MessageQueueIF* queueToUse);
void setHkDestinationId(MessageQueueId_t hkDestId);
@ -201,18 +202,15 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF,
*/
MutexIF* getMutexHandle();
PeriodicHkGenerationHelper* getPoolManagerHandle() override;
// PeriodicHkGenerationHelper* getPoolManagerHandle() override;
/**
* Set the periodic generation frequency without enabling the periodic generation of packets.
*/
ReturnValue_t setPeriodicFrequency(sid_t structureId, dur_millis_t frequencyMs) override;
ReturnValue_t enableRegularPeriodicPacket(sid_t structureId,
ReturnValue_t enablePeriodicPacket(sid_t structureId,
std::optional<dur_millis_t> frequencyMs) override;
ReturnValue_t disablePeriodicPacket(sid_t structureId) override;
ReturnValue_t changeCollectionInterval(sid_t sid,
dur_millis_t newCollectionIntervalMs);
ReturnValue_t setCollectionInterval(sid_t structureId, dur_millis_t newCollectionIntervalMs);
protected:
std::optional<periodicHk::SetSpecification> getSetSpecification(sid_t structureId);
@ -222,17 +220,9 @@ ReturnValue_t changeCollectionInterval(sid_t sid,
std::optional<dur_millis_t> getCollectionFrequency(sid_t structureId);
/** Core data structure for the actual pool data */
localpool::DataPool localPoolMap;
/** Every housekeeping data manager has a mutex to protect access
to it's data pool. */
MutexIF* mutex = nullptr;
/** The class which actually owns the manager (and its datapool). */
PeriodicHkGenerationIF* owner = nullptr;
uint8_t nonDiagnosticIntervalFactor = 0;
/** Default receiver for periodic HK packets */
static object_id_t defaultHkDestination;
MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE;
@ -242,13 +232,6 @@ ReturnValue_t changeCollectionInterval(sid_t sid,
SetList setList;
/** This is the map holding the actual data. Should only be initialized
* once ! */
bool mapInitialized = false;
/** This specifies whether a validity buffer is appended at the end
* of generated housekeeping packets. */
bool appendValidityBuffer = true;
/**
* @brief Queue used for communication, for example commands.
* Is also used to send messages. Can be set either in the constructor
@ -259,68 +242,22 @@ ReturnValue_t changeCollectionInterval(sid_t sid,
/** Global IPC store is used to store all packets. */
StorageManagerIF* ipcStore = nullptr;
/**
* Read a variable by supplying its local pool ID and assign the pool
* entry to the supplied PoolEntry pointer. The type of the pool entry
* is deduced automatically. This call is not thread-safe!
* For now, only classes designated by the LocalDpManagerAttorney may use this function.
* @tparam T Type of the pool entry
* @param localPoolId Pool ID of the variable to read
* @param poolVar [out] Corresponding pool entry will be assigned to the
* supplied pointer.
* @return
*/
template <class T>
ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T>** poolEntry);
/**
* This function is used to fill the local data pool map with pool
* entries. It should only be called once by the pool owner.
* @param localDataPoolMap
* @return
*/
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
MutexIF* getLocalPoolMutex() override;
ReturnValue_t serializeHkPacketIntoStore(HousekeepingPacketDownlink& hkPacket,
store_address_t& storeId, size_t* serializedSize);
void performPeriodicHkGeneration(periodicHk::SetSpecification& hkReceiver);
void performPeriodicHkGeneration(periodicHk::SetSpecification& hkReceiver, timeval& now);
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable);
ReturnValue_t generateSetStructurePacket(sid_t sid);
void handleChangeResetLogic(periodicHk::DataType type, periodicHk::DataId dataId, MarkChangedIF* toReset);
void resetHkUpdateResetHelper();
// void handleChangeResetLogic(periodicHk::DataType type, periodicHk::DataId dataId,
// MarkChangedIF* toReset);
// void resetHkUpdateResetHelper();
ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId);
// ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId);
void printWarningOrError(sif::OutputTypes outputType, const char* functionName,
ReturnValue_t errorCode = returnvalue::FAILED,
const char* errorPrint = nullptr);
};
template <class T>
inline ReturnValue_t PeriodicHkGenerationHelper::fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T>** poolEntry) {
if (poolEntry == nullptr) {
return returnvalue::FAILED;
}
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry",
localpool::POOL_ENTRY_NOT_FOUND);
return localpool::POOL_ENTRY_NOT_FOUND;
}
*poolEntry = dynamic_cast<PoolEntry<T>*>(poolIter->second);
if (*poolEntry == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry",
localpool::POOL_ENTRY_TYPE_CONFLICT);
return localpool::POOL_ENTRY_TYPE_CONFLICT;
}
return returnvalue::OK;
}
#endif /* FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */

View File

@ -57,20 +57,7 @@ class PeriodicHkGenerationIF {
virtual ReturnValue_t specifyDatasets(std::vector<periodicHk::SetSpecification>& setList) = 0;
/**
* Is used by pool owner to initialize the pool map once
* The manager instance shall also be passed to this function.
* It can be used to subscribe for periodic packets for for updates.
*/
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) = 0;
/**
* Returns the minimum sampling frequency in milliseconds, which will
* usually be the period the pool owner performs its periodic operation.
* @return
*/
//[[nodiscard]] virtual dur_millis_t getPeriodicOperationFrequency() const = 0;
virtual localpool::SharedPool* getOptionalSharedPool() = 0;
/**
* These function can be implemented by pool owner, if they are required
@ -90,9 +77,9 @@ class PeriodicHkGenerationIF {
* Returns the HK manager casted to the required interface by default.
* @return
*/
virtual PeriodicHkGenerationProviderIF* getSubscriptionInterface() {
return getHkManagerHandle();
}
// virtual PeriodicHkGenerationProviderIF* getSubscriptionInterface() {
// return getHkManagerHandle();
//}
protected:
/**
@ -100,7 +87,7 @@ class PeriodicHkGenerationIF {
* function will return a reference to the manager.
* @return
*/
virtual PeriodicHkGenerationHelper* getHkManagerHandle() = 0;
// virtual PeriodicHkGenerationHelper* getHkManagerHandle() = 0;
/**
* Accessor handle required for internal handling. Not intended for users and therefore
@ -109,7 +96,7 @@ class PeriodicHkGenerationIF {
* by default.
* @return
*/
virtual AccessPoolManagerIF* getAccessorHandle() { return getHkManagerHandle(); }
// virtual AccessPoolManagerIF* getAccessorHandle() { return getHkManagerHandle(); }
/**
* Similar to the function above, but used to get a local pool variable

View File

@ -50,8 +50,9 @@ class PeriodicHkGenerationProviderIF {
/**
* Set the periodic generation frequency without enabling the periodic generation of packets.
*/
virtual ReturnValue_t setPeriodicFrequency(sid_t structureId, dur_millis_t frequencyMs) = 0;
virtual ReturnValue_t enableRegularPeriodicPacket(sid_t structureId,
virtual ReturnValue_t setCollectionInterval(sid_t structureId,
dur_millis_t newCollectionIntervalMs) = 0;
virtual ReturnValue_t enablePeriodicPacket(sid_t structureId,
std::optional<dur_millis_t> frequencyMs) = 0;
virtual ReturnValue_t disablePeriodicPacket(sid_t structureId) = 0;
};

View File

@ -6,10 +6,10 @@ SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, sid_t sid, const si
datasetLock = MutexFactory::instance()->createMutex();
}
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, PeriodicHkGenerationIF *owner,
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, localpool::SharedPool& sharedPool,
uint32_t setId, const size_t maxSize)
: SystemObject(objectId),
LocalPoolDataSetBase(owner, setId, nullptr, maxSize),
LocalPoolDataSetBase(sharedPool, setId, nullptr, maxSize),
poolVarVector(maxSize) {
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();

View File

@ -19,11 +19,11 @@ class SharedLocalDataSet : public SystemObject,
public LocalPoolDataSetBase,
public SharedDataSetIF {
public:
SharedLocalDataSet(object_id_t objectId, PeriodicHkGenerationIF* owner, uint32_t setId,
const size_t maxSize);
SharedLocalDataSet(object_id_t objectId, sid_t sid, const size_t maxSize);
SharedLocalDataSet(object_id_t objectId, localpool::SharedPool& sharedPool, uint32_t setId,
size_t maxSize);
SharedLocalDataSet(object_id_t objectId, sid_t sid, size_t maxSize);
virtual ~SharedLocalDataSet();
~SharedLocalDataSet() override;
ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
dur_millis_t mutexTimeout = 20) override;

View File

@ -0,0 +1,35 @@
#include "SharedPool.h"
#include "FSFWConfig.h"
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/serviceinterface.h"
localpool::SharedPool::SharedPool(object_id_t ownerId) : ownerId(ownerId) {
mutex = MutexFactory::instance()->createMutex();
if (mutex == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "localpool::Manager: Mutex creation failed" << std::endl;
#else
sif::printError("localpool::Manager: Mutex creation failed");
#endif
}
}
localpool::SharedPool::~SharedPool() { MutexFactory::instance()->deleteMutex(mutex); }
object_id_t localpool::SharedPool::getOwnerId() const { return ownerId; }
void localpool::SharedPool::addPoolEntry(lp_id_t poolId, PoolEntryIF* entry) {
localPoolMap.emplace(poolId, entry);
}
MutexIF* localpool::SharedPool::getLocalPoolMutex() { return mutex; }
ReturnValue_t localpool::SharedPool::printPoolEntry(lp_id_t localPoolId) {
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
return localpool::POOL_ENTRY_NOT_FOUND;
}
poolIter->second->print();
return returnvalue::OK;
}

View File

@ -0,0 +1,63 @@
#pragma once
#include "AccessLocalPoolF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/ipc/MutexIF.h"
#include "localPoolDefinitions.h"
namespace localpool {
class SharedPool {
public:
explicit SharedPool(object_id_t ownerId);
~SharedPool();
[[nodiscard]] object_id_t getOwnerId() const;
/**
* Read a variable by supplying its local pool ID and assign the pool
* entry to the supplied PoolEntry pointer. The type of the pool entry
* is deduced automatically. This call is not thread-safe!
* For now, only classes designated by the LocalDpManagerAttorney may use this function.
* @tparam T Type of the pool entry
* @param localPoolId Pool ID of the variable to read
* @param poolVar [out] Corresponding pool entry will be assigned to the
* supplied pointer.
* @return
*/
template <class T>
ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T>** poolEntry);
ReturnValue_t printPoolEntry(lp_id_t localPoolId);
void addPoolEntry(lp_id_t poolId, PoolEntryIF* entry);
MutexIF* getLocalPoolMutex();
private:
object_id_t ownerId;
// Core data structure for the actual pool data
DataPool localPoolMap;
// Every housekeeping data manager has a mutex to protect access
// to it's data pool.
MutexIF* mutex = nullptr;
};
template <class T>
inline ReturnValue_t localpool::SharedPool::fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T>** poolEntry) {
if (poolEntry == nullptr) {
return returnvalue::FAILED;
}
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
return localpool::POOL_ENTRY_NOT_FOUND;
}
*poolEntry = dynamic_cast<PoolEntry<T>*>(poolIter->second);
if (*poolEntry == nullptr) {
return localpool::POOL_ENTRY_TYPE_CONFLICT;
}
return returnvalue::OK;
}
} // namespace localpool

View File

@ -31,8 +31,8 @@ class StaticLocalDataSet : public LocalPoolDataSetBase {
* @param hkOwner
* @param setId
*/
StaticLocalDataSet(PeriodicHkGenerationIF* hkOwner, uint32_t setId)
: LocalPoolDataSetBase(hkOwner, setId, nullptr, NUM_VARIABLES) {
StaticLocalDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
: LocalPoolDataSetBase(sharedPool, setId, nullptr, NUM_VARIABLES) {
this->setContainer(poolVarList.data());
}

View File

@ -1,8 +1,8 @@
#include "HasLocalDpIFManagerAttorney.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapoollocal/LocalPoolDataSetBase.h"
#include "fsfw/datapoollocal/LocalPoolObjectBase.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
LocalPoolObjectBase* HasLocalDpIFManagerAttorney::getPoolObjectHandle(
PeriodicHkGenerationIF* clientIF, lp_id_t localPoolId) {

View File

@ -2,7 +2,3 @@
#include "fsfw/datapoollocal/AccessLocalPoolF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
AccessPoolManagerIF* HasLocalDpIFUserAttorney::getAccessorHandle(PeriodicHkGenerationIF* clientIF) {
return clientIF->getAccessorHandle();
}

View File

@ -6,7 +6,7 @@ class AccessPoolManagerIF;
class HasLocalDpIFUserAttorney {
private:
static AccessPoolManagerIF* getAccessorHandle(PeriodicHkGenerationIF* clientIF);
// static AccessPoolManagerIF* getAccessorHandle(PeriodicHkGenerationIF* clientIF);
friend class LocalPoolObjectBase;
friend class LocalPoolDataSetBase;

View File

@ -2,6 +2,7 @@
#define FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_
#include "../PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/SharedPool.h"
/**
* @brief This is a helper class implements the Attorney-Client idiom for access to
@ -16,13 +17,13 @@
class LocalDpManagerAttorney {
private:
template <typename T>
static ReturnValue_t fetchPoolEntry(PeriodicHkGenerationHelper& manager, lp_id_t localPoolId,
static ReturnValue_t fetchPoolEntry(localpool::SharedPool& manager, lp_id_t localPoolId,
PoolEntry<T>** poolEntry) {
return manager.fetchPoolEntry(localPoolId, poolEntry);
}
static MutexIF* getMutexHandle(PeriodicHkGenerationHelper& manager) {
return manager.getMutexHandle();
static MutexIF* getMutexHandle(localpool::SharedPool& manager) {
return manager.getLocalPoolMutex();
}
template <typename T>

View File

@ -24,7 +24,6 @@ static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01)
/** This is the core data structure of the local data pools. Users should insert all desired
pool variables, using the std::map interface. */
using DataPool = std::map<lp_id_t, PoolEntryIF*>;
using DataPoolMapIter = DataPool::iterator;
} // namespace localpool

View File

@ -28,11 +28,12 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device
storedRawData(StorageManagerIF::INVALID_ADDRESS),
deviceCommunicationId(deviceCommunication),
comCookie(comCookie),
sharedPool(getObjectId()),
healthHelper(this, setObjectId),
modeHelper(this),
parameterHelper(this),
actionHelper(this, nullptr),
periodicHkHelper(this, nullptr),
hkHelper(this, nullptr),
childTransitionFailure(returnvalue::OK),
fdirInstance(fdirInstance),
defaultFDIRUsed(fdirInstance == nullptr),
@ -111,7 +112,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
doGetRead();
/* This will be performed after datasets have been updated by the
custom device implementation. */
periodicHkHelper.performHkOperation();
hkHelper.performHkOperation();
break;
default:
break;
@ -152,8 +153,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
if (rawDataReceiverId != objects::NO_OBJECT) {
auto* rawReceiver =
ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
auto* rawReceiver = ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
if (rawReceiver == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
@ -214,7 +214,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result;
}
result = periodicHkHelper.initialize(commandQueue);
result = hkHelper.initialize(commandQueue);
if (result != returnvalue::OK) {
return result;
}
@ -288,7 +288,7 @@ void DeviceHandlerBase::readCommandQueue() {
return;
}
result = periodicHkHelper.handleHousekeepingMessage(&command);
result = hkHelper.handleHousekeepingMessage(&command);
if (result == returnvalue::OK) {
return;
}
@ -1468,6 +1468,7 @@ Submode_t DeviceHandlerBase::getInitialSubmode() { return SUBMODE_NONE; }
void DeviceHandlerBase::performOperationHook() {}
/*
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) {
if (thermalStateCfg.has_value()) {
@ -1478,6 +1479,7 @@ ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& lo
}
return returnvalue::OK;
}
*/
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
// In this function, the task handle should be valid if the task
@ -1550,8 +1552,6 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch
}
}
PeriodicHkGenerationHelper* DeviceHandlerBase::getHkManagerHandle() { return &periodicHkHelper; }
MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyId) const {
auto commandIter = deviceCommandMap.find(replyId);
if (commandIter == deviceCommandMap.end()) {
@ -1608,3 +1608,5 @@ ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t ac
actionHelper.finish(success, commandIter->second.sendReplyTo, action, result);
return returnvalue::OK;
}
void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { return; }

View File

@ -11,8 +11,8 @@
#include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/health/HealthHelper.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/modes/HasModesIF.h"
@ -607,8 +607,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @param localDataPoolMap
* @return
*/
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) override;
// virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
// PeriodicHkGenerationHelper &poolManager) override;
/**
* @brief Set all datapool variables that are update periodically in
* normal mode invalid
@ -788,6 +788,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
/** Cookie used for communication */
CookieIF *comCookie;
localpool::SharedPool sharedPool;
/* Health helper for HasHealthIF */
HealthHelper healthHelper;
/* Mode helper for HasModesIF */
@ -797,7 +799,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
/* Action helper for HasActionsIF */
ActionHelper actionHelper;
/* Housekeeping Manager */
PeriodicHkGenerationHelper periodicHkHelper;
PeriodicHkGenerationHelper hkHelper;
/**
* @brief Information about commands
@ -1001,7 +1003,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* Required for HasLocalDataPoolIF, return a handle to the local pool manager.
* @return
*/
PeriodicHkGenerationHelper *getHkManagerHandle() override;
// PeriodicHkGenerationHelper *getHkManagerHandle() override;
const HasHealthIF *getOptHealthIF() const override;
const HasModesIF &getModeIF() const override;

View File

@ -10,7 +10,7 @@ FreshDeviceHandlerBase::FreshDeviceHandlerBase(DhbConfig config)
modeHelper(this),
healthHelper(this, getObjectId()),
paramHelper(this),
poolManager(this, nullptr),
hkHelper(this, nullptr),
fdirInstance(config.fdirInstance),
defaultFdirParent(config.defaultFdirParent) {
auto mqArgs = MqArgs(config.objectId, static_cast<void*>(this));
@ -33,7 +33,7 @@ ReturnValue_t FreshDeviceHandlerBase::performOperation(uint8_t opCode) {
handleQueue();
fdirInstance->checkForFailures();
performDeviceOperation(opCode);
poolManager.performHkOperation();
hkHelper.performHkOperation();
return returnvalue::OK;
}
@ -97,7 +97,7 @@ ReturnValue_t FreshDeviceHandlerBase::handleQueue() {
continue;
}
result = poolManager.handleHousekeepingMessage(&command);
result = hkHelper.handleHousekeepingMessage(&command);
if (result == returnvalue::OK) {
continue;
}
@ -128,7 +128,7 @@ ReturnValue_t FreshDeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenI
void FreshDeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; }
// Pool Manager overrides.
PeriodicHkGenerationHelper* FreshDeviceHandlerBase::getHkManagerHandle() { return &poolManager; }
// PeriodicHkGenerationHelper* FreshDeviceHandlerBase::getHkManagerHandle() { return &hkHelper; }
//[[nodiscard]] uint32_t FreshDeviceHandlerBase::getPeriodicOperationFrequency() const {
// return this->executingTask->getPeriodMs();
@ -174,7 +174,7 @@ ReturnValue_t FreshDeviceHandlerBase::initialize() {
return result;
}
result = poolManager.initialize(messageQueue);
result = hkHelper.initialize(messageQueue);
if (result != returnvalue::OK) {
return result;
}

View File

@ -1,8 +1,8 @@
#pragma once
#include "fsfw/action.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/fdir/FailureIsolationBase.h"
#include "fsfw/health/HasHealthIF.h"
@ -60,12 +60,12 @@ class FreshDeviceHandlerBase : public SystemObject,
protected:
// Pool Manager overrides.
PeriodicHkGenerationHelper* getHkManagerHandle() override;
// PeriodicHkGenerationHelper* getHkManagerHandle() override;
ActionHelper actionHelper;
ModeHelper modeHelper;
HealthHelper healthHelper;
ParameterHelper paramHelper;
PeriodicHkGenerationHelper poolManager;
PeriodicHkGenerationHelper hkHelper;
bool hasCustomFdir = false;
FailureIsolationBase* fdirInstance;
@ -116,8 +116,8 @@ class FreshDeviceHandlerBase : public SystemObject,
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) = 0;
// HK manager abstract functions.
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) override = 0;
// ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
// PeriodicHkGenerationHelper& poolManager) override = 0;
// Mode abstract functions
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,

View File

@ -60,8 +60,8 @@ void HousekeepingMessage::setCollectionIntervalModificationCommand(CommandMessag
setSid(command, sid);
}
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(const CommandMessage *command,
dur_millis_t& newCollectionIntervalMs) {
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
const CommandMessage *command, dur_millis_t &newCollectionIntervalMs) {
std::memcpy(&newCollectionIntervalMs, command->getData() + 2 * sizeof(uint32_t),
sizeof(newCollectionIntervalMs));

View File

@ -7,37 +7,14 @@
class HousekeepingSetPacket : public SerialLinkedListAdapter<SerializeIF> {
public:
HousekeepingSetPacket(sid_t sid, bool reportingEnabled, dur_millis_t collectionIntervalMs,
LocalPoolDataSetBase* dataSetPtr)
HousekeepingSetPacket(sid_t sid, bool reportingEnabled, dur_millis_t collectionIntervalMs)
: objectId(sid.objectId),
setId(sid.ownerSetId),
reportingEnabled(reportingEnabled),
collectionIntervalMs(collectionIntervalMs),
dataSet(dataSetPtr) {
collectionIntervalMs(collectionIntervalMs) {
setLinks();
}
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override {
ReturnValue_t result =
SerialLinkedListAdapter::serialize(buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
return result;
}
return dataSet->serializeLocalPoolIds(buffer, size, maxSize, streamEndianness);
}
[[nodiscard]] size_t getSerializedSize() const override {
size_t linkedSize = SerialLinkedListAdapter::getSerializedSize();
linkedSize += dataSet->getLocalPoolIdsSerializedSize();
return linkedSize;
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override {
return returnvalue::OK;
}
private:
void setLinks() {
setStart(&objectId);
@ -51,7 +28,6 @@ class HousekeepingSetPacket : public SerialLinkedListAdapter<SerializeIF> {
SerializeElement<uint32_t> setId;
SerializeElement<bool> reportingEnabled;
SerializeElement<uint32_t> collectionIntervalMs;
LocalPoolDataSetBase* dataSet;
};
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */

View File

@ -10,7 +10,8 @@ class InternalErrorDataset : public StaticLocalDataSet<3 * sizeof(uint32_t)> {
public:
static constexpr uint8_t ERROR_SET_ID = 0;
InternalErrorDataset(PeriodicHkGenerationIF* owner) : StaticLocalDataSet(owner, ERROR_SET_ID) {}
InternalErrorDataset(localpool::SharedPool& sharedPool)
: StaticLocalDataSet(sharedPool, ERROR_SET_ID) {}
InternalErrorDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ERROR_SET_ID)) {}

View File

@ -9,11 +9,12 @@ InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t m
bool enableSetByDefault,
dur_millis_t generationFrequency)
: SystemObject(setObjectId),
poolManager(this, commandQueue),
hkHelper(this, nullptr),
enableSetByDefault(enableSetByDefault),
generationFrequency(generationFrequency),
sharedPool(getObjectId()),
internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID),
internalErrorDataset(this) {
internalErrorDataset(sharedPool) {
commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
mutex = MutexFactory::instance()->createMutex();
auto mqArgs = MqArgs(setObjectId, this);
@ -34,7 +35,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
CommandMessage message;
ReturnValue_t result = commandQueue->receiveMessage(&message);
if (result != MessageQueueIF::EMPTY) {
poolManager.handleHousekeepingMessage(&message);
hkHelper.handleHousekeepingMessage(&message);
}
uint32_t newQueueHits = getAndResetQueueHits();
@ -69,7 +70,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
}
}
poolManager.performHkOperation();
hkHelper.performHkOperation();
return returnvalue::OK;
}
@ -130,15 +131,18 @@ MessageQueueId_t InternalErrorReporter::getCommandQueue() const {
return this->commandQueue->getId();
}
// TODO: Fix
/*
ReturnValue_t InternalErrorReporter::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, PeriodicHkGenerationHelper &poolManager) {
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
poolManager.enableRegularPeriodicPacket(internalErrorSid, generationFrequency);
poolManager.enablePeriodicPacket(internalErrorSid, generationFrequency);
internalErrorDataset.valid = false;
return returnvalue::OK;
}
*/
// dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const {
// return this->executingTask->getPeriodMs();
@ -151,7 +155,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(
void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTask = task; }
ReturnValue_t InternalErrorReporter::initialize() {
ReturnValue_t result = poolManager.initialize(commandQueue);
ReturnValue_t result = hkHelper.initialize(commandQueue);
if (result != returnvalue::OK) {
return result;
}
@ -167,7 +171,7 @@ void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType, ui
this->timeoutMs = timeoutMs;
}
PeriodicHkGenerationHelper *InternalErrorReporter::getHkManagerHandle() { return &poolManager; }
// PeriodicHkGenerationHelper *InternalErrorReporter::getHkManagerHandle() { return &poolManager; }
ReturnValue_t InternalErrorReporter::serializeDataset(sid_t structureId, uint8_t *buf,
size_t maxSize) {
@ -179,7 +183,10 @@ ReturnValue_t InternalErrorReporter::serializeDataset(sid_t structureId, uint8_t
ReturnValue_t InternalErrorReporter::specifyDatasets(
std::vector<periodicHk::SetSpecification> &setSpecification) {
setSpecification.emplace_back(internalErrorDataset.getSid(),
internalErrorDataset.getSerializedSize());
setSpecification.push_back(periodicHk::SetSpecification(internalErrorDataset.getSid(),
internalErrorDataset.getSerializedSize(),
generationFrequency));
return returnvalue::OK;
}
localpool::SharedPool *InternalErrorReporter::getOptionalSharedPool() { return &sharedPool; }

View File

@ -37,17 +37,15 @@ class InternalErrorReporter : public SystemObject,
virtual object_id_t getObjectId() const override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) override;
// virtual dur_millis_t getPeriodicOperationFrequency() const override;
virtual localpool::SharedPool* getOptionalSharedPool() override;
virtual ReturnValue_t serializeDataset(sid_t structureId, uint8_t* buf, size_t maxSize) override;
virtual ReturnValue_t specifyDatasets(
std::vector<periodicHk::SetSpecification>& setSpecification) override;
// virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
PeriodicHkGenerationHelper* getHkManagerHandle() override;
// PeriodicHkGenerationHelper* getHkManagerHandle() override;
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
@ -63,7 +61,8 @@ class InternalErrorReporter : public SystemObject,
protected:
MessageQueueIF* commandQueue;
PeriodicHkGenerationHelper poolManager;
localpool::SharedPool sharedPool;
PeriodicHkGenerationHelper hkHelper;
PeriodicTaskIF* executingTask = nullptr;

View File

@ -28,7 +28,7 @@ class FuseSet : public StaticLocalDataSet<6> {
public:
static constexpr uint8_t FUSE_SET_ID = 0;
FuseSet(PeriodicHkGenerationIF *owner) : StaticLocalDataSet(owner, FUSE_SET_ID) {}
FuseSet(localpool::SharedPool &sharedPool) : StaticLocalDataSet(sharedPool, FUSE_SET_ID) {}
FuseSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, FUSE_SET_ID)) {}

View File

@ -21,7 +21,8 @@ class PowerSensorSet : public StaticLocalDataSet<6> {
public:
static constexpr uint8_t POWER_SENSOR_SET_ID = 0;
PowerSensorSet(PeriodicHkGenerationIF *owner) : StaticLocalDataSet(owner, POWER_SENSOR_SET_ID) {}
PowerSensorSet(localpool::SharedPool &sharedPool)
: StaticLocalDataSet(sharedPool, POWER_SENSOR_SET_ID) {}
PowerSensorSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, POWER_SENSOR_SET_ID)) {}

View File

@ -14,7 +14,7 @@
#include "fsfw/storagemanager/StorageManagerIF.h"
/**
* @brief The LocalPool class provides an intermediate data storage with
* @brief The Manager class provides an intermediate data storage with
* a fixed pool size policy.
* @details
* The class implements the StorageManagerIF interface. While the total number
@ -62,7 +62,7 @@ class LocalPool : public SystemObject, public StorageManagerIF {
* many elements with that size are created on that page.
* All regions are to zero on start up.
* @param setObjectId The object identifier to be set. This allows for
* multiple instances of LocalPool in the system.
* multiple instances of Manager in the system.
* @param poolConfig
* This is a set of pairs to configure the number of pages in the pool,
* the size of an element on a page, the number of elements on a page
@ -79,7 +79,7 @@ class LocalPool : public SystemObject, public StorageManagerIF {
void setToSpillToHigherPools(bool enable);
/**
* @brief In the LocalPool's destructor all allocated memory is freed.
* @brief In the Manager's destructor all allocated memory is freed.
*/
~LocalPool() override;

View File

@ -13,10 +13,10 @@
* with a lock. The developer can lock the pool with the provided API
* if the lock needs to persists beyond the function call.
*
* Other than that, the class provides the same interface as the LocalPool
* Other than that, the class provides the same interface as the Manager
* class. The class is always registered as a system object as it is assumed
* it will always be used concurrently (if this is not the case, it is
* recommended to use the LocalPool class instead).
* recommended to use the Manager class instead).
* @author Bastian Baetz
*/
class PoolManager : public LocalPool {
@ -36,8 +36,8 @@ class PoolManager : public LocalPool {
void setMutexTimeout(uint32_t mutexTimeoutMs);
/**
* @brief LocalPool overrides for thread-safety. Decorator function
* which wraps LocalPool calls with a mutex protection.
* @brief Manager overrides for thread-safety. Decorator function
* which wraps Manager calls with a mutex protection.
*/
ReturnValue_t deleteData(store_address_t) override;
ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) override;

View File

@ -26,8 +26,7 @@ ReturnValue_t ThermalComponent::setTargetState(int8_t newState) {
switch (newState) {
case STATE_REQUEST_NON_OPERATIONAL:
targetState = newState;
// targetState.setValid(true);
targetState.commit(PoolVariableIF::VALID);
targetState.commit();
return returnvalue::OK;
default:
return ThermalComponentCore::setTargetState(newState);

View File

@ -1,4 +1,3 @@
add_subdirectory(devicehandlers)
add_subdirectory(common)
add_subdirectory(host)

View File

@ -1,5 +0,0 @@
target_sources(
${LIB_FSFW_NAME} PRIVATE GyroL3GD20Handler.cpp MgmRM3100Handler.cpp
MgmLIS3MDLHandler.cpp)
add_subdirectory(devicedefinitions)

View File

@ -1 +0,0 @@
target_sources(${LIB_FSFW_NAME} PRIVATE gyroL3gHelpers.cpp mgmLis3Helpers.cpp)

View File

@ -635,6 +635,7 @@ uint32_t TestDevice::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { retu
void TestDevice::enableFullDebugOutput(bool enable) { this->fullInfoPrintout = enable; }
/*
ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
namespace td = testdevice;
@ -643,11 +644,12 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData
localDataPoolMap.emplace(td::PoolIds::TEST_FLOAT_VEC_3_ID, new PoolEntry<float>({0.0, 0.0, 0.0}));
sid_t sid(this->getObjectId(), td::TEST_SET_ID);
/* Subscribe for periodic HK packets but do not enable reporting for now.
Non-diangostic with a period of one second */
// Subscribe for periodic HK packets but do not enable reporting for now.
//Non-diangostic with a period of one second
poolManager.subscribeForRegularPeriodicPacket({sid, false, 1.0});
return returnvalue::OK;
}
*/
ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId,
ParameterWrapper* parameterWrapper,

View File

@ -73,7 +73,7 @@ static constexpr uint8_t TEST_SET_ID = TEST_NORMAL_MODE_CMD;
class TestDataSet : public StaticLocalDataSet<3> {
public:
TestDataSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEST_SET_ID) {}
TestDataSet(localpool::SharedPool& owner) : StaticLocalDataSet(owner, TEST_SET_ID) {}
TestDataSet(object_id_t owner) : StaticLocalDataSet(sid_t(owner, TEST_SET_ID)) {}
lp_var_t<uint8_t> testUint8Var =

View File

@ -1,6 +1,6 @@
#include "CatchFactory.h"
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
// #include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
@ -57,7 +57,7 @@ void Factory::setStaticFrameworkObjectIds() {
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
PeriodicHkGenerationHelper::defaultHkDestination = objects::NO_OBJECT;
// PeriodicHkGenerationHelper::defaultHkDestination = objects::NO_OBJECT;
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
}

View File

@ -1,5 +1,5 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
// #include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/SharedLocalDataSet.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/globalfunctions/bitutility.h>
@ -18,8 +18,7 @@ using namespace returnvalue;
TEST_CASE("DataSetTest", "[DataSetTest]") {
auto queue = MessageQueueMock(1);
LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner.initializeHkManager() == OK);
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK);
poolOwner.initialize();
LocalPoolStaticTestDataSet localSet;
SECTION("BasicTest") {
@ -59,15 +58,15 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
/* Test read operation. Values should be all zeros */
PoolReadGuard readHelper(&localSet);
REQUIRE(readHelper.getReadResult() == returnvalue::OK);
CHECK(not localSet.isValid());
// CHECK(not localSet.isValid());
CHECK(localSet.localPoolVarUint8.value == 0);
CHECK(not localSet.localPoolVarUint8.isValid());
// CHECK(not localSet.localPoolVarUint8.isValid());
CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0));
CHECK(not localSet.localPoolVarUint8.isValid());
// CHECK(not localSet.localPoolVarUint8.isValid());
CHECK(localSet.localPoolUint16Vec.value[0] == 0);
CHECK(localSet.localPoolUint16Vec.value[1] == 0);
CHECK(localSet.localPoolUint16Vec.value[2] == 0);
CHECK(not localSet.localPoolVarUint8.isValid());
// CHECK(not localSet.localPoolVarUint8.isValid());
/* Now set new values, commit should be done by read helper automatically */
localSet.localPoolVarUint8 = 232;
@ -75,7 +74,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
localSet.localPoolUint16Vec.value[0] = 232;
localSet.localPoolUint16Vec.value[1] = 23923;
localSet.localPoolUint16Vec.value[2] = 1;
localSet.setValidity(true, true);
// localSet.setValidity(true, true);
}
/* Zero out some values for next test */
@ -92,18 +91,17 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
the values in the pool */
PoolReadGuard readHelper(&localSet);
REQUIRE(readHelper.getReadResult() == returnvalue::OK);
CHECK(localSet.isValid());
// CHECK(localSet.isValid());
CHECK(localSet.localPoolVarUint8.value == 232);
CHECK(localSet.localPoolVarUint8.isValid());
// CHECK(localSet.localPoolVarUint8.isValid());
CHECK(localSet.localPoolVarFloat.value == Catch::Approx(-2324.322));
CHECK(localSet.localPoolVarFloat.isValid());
// CHECK(localSet.localPoolVarFloat.isValid());
CHECK(localSet.localPoolUint16Vec.value[0] == 232);
CHECK(localSet.localPoolUint16Vec.value[1] == 23923);
CHECK(localSet.localPoolUint16Vec.value[2] == 1);
CHECK(localSet.localPoolUint16Vec.isValid());
// CHECK(localSet.localPoolUint16Vec.isValid());
/* Now we serialize these values into a buffer without the validity buffer */
localSet.setValidityBufferGeneration(false);
// Now we serialize these values into a buffer without the validity buffer
maxSize = localSet.getSerializedSize();
CHECK(maxSize == sizeof(uint8_t) + sizeof(uint16_t) * 3 + sizeof(float));
serSize = 0;
@ -138,9 +136,9 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(localSet.localPoolUint16Vec.value[1] == 0);
CHECK(localSet.localPoolUint16Vec.value[2] == 0);
/* Validity should be unchanged */
CHECK(localSet.localPoolVarUint8.isValid());
CHECK(localSet.localPoolVarFloat.isValid());
CHECK(localSet.localPoolUint16Vec.isValid());
// CHECK(localSet.localPoolVarUint8.isValid());
// CHECK(localSet.localPoolVarFloat.isValid());
// CHECK(localSet.localPoolUint16Vec.isValid());
/* Now we do the same process but with the validity buffer */
localSet.localPoolVarUint8 = 232;
@ -148,10 +146,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
localSet.localPoolUint16Vec.value[0] = 232;
localSet.localPoolUint16Vec.value[1] = 23923;
localSet.localPoolUint16Vec.value[2] = 1;
localSet.localPoolVarUint8.setValid(true);
localSet.localPoolVarFloat.setValid(false);
localSet.localPoolUint16Vec.setValid(true);
localSet.setValidityBufferGeneration(true);
// localSet.localPoolVarUint8.setValid(true);
// localSet.localPoolVarFloat.setValid(false);
// localSet.localPoolUint16Vec.setValid(true);
// localSet.setValidityBufferGeneration(true);
maxSize = localSet.getSerializedSize();
CHECK(maxSize == sizeof(uint8_t) + sizeof(uint16_t) * 3 + sizeof(float) + 1);
serSize = 0;
@ -195,9 +193,9 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(localSet.localPoolUint16Vec.value[0] == 0);
CHECK(localSet.localPoolUint16Vec.value[1] == 0);
CHECK(localSet.localPoolUint16Vec.value[2] == 0);
CHECK(not localSet.localPoolVarUint8.isValid());
CHECK(localSet.localPoolVarFloat.isValid());
CHECK(not localSet.localPoolUint16Vec.isValid());
// CHECK(not localSet.localPoolVarUint8.isValid());
// CHECK(localSet.localPoolVarFloat.isValid());
// CHECK(not localSet.localPoolUint16Vec.isValid());
}
/* Common fault test cases */
@ -210,7 +208,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
}
SECTION("MorePoolVariables") {
LocalDataSet set(&poolOwner, 2, 10);
LocalDataSet set(poolOwner.sharedPool, 2, 10);
/* Register same variables again to get more than 8 registered variables */
for (uint8_t idx = 0; idx < 8; idx++) {
@ -219,12 +217,12 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK);
REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK);
set.setValidityBufferGeneration(true);
// set.setValidityBufferGeneration(true);
{
PoolReadGuard readHelper(&localSet);
localSet.localPoolVarUint8.value = 42;
localSet.localPoolVarUint8.setValid(true);
localSet.localPoolUint16Vec.setValid(false);
// localSet.localPoolVarUint8.setValid(true);
// localSet.localPoolUint16Vec.setValid(false);
}
size_t maxSize = set.getSerializedSize();
@ -252,13 +250,13 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
size_t sizeToDeSerialize = serSize;
CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) ==
returnvalue::OK);
CHECK(localSet.localPoolVarUint8.isValid() == false);
CHECK(localSet.localPoolUint16Vec.isValid() == true);
// CHECK(localSet.localPoolVarUint8.isValid() == false);
// CHECK(localSet.localPoolUint16Vec.isValid() == true);
}
SECTION("SharedDataSet") {
object_id_t sharedSetId = objects::SHARED_SET_ID;
SharedLocalDataSet sharedSet(sharedSetId, &poolOwner, lpool::testSetId, 5);
SharedLocalDataSet sharedSet(sharedSetId, poolOwner.sharedPool, lpool::testSetId, 5);
localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE);
localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE);
CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK);
@ -277,6 +275,6 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(sharedSet.commit() == returnvalue::OK);
}
sharedSet.setReadCommitProtectionBehaviour(true);
// sharedSet.setReadCommitProtectionBehaviour(true);
}
}

View File

@ -1,5 +1,5 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/globalfunctions/timevalOperations.h>
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
@ -23,8 +23,8 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
auto hkReceiver = HkReceiverMock(hkDest);
auto queue = MessageQueueMock(3);
LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner.initializeHkManager() == returnvalue::OK);
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == returnvalue::OK);
REQUIRE(poolOwner.initialize() == returnvalue::OK);
MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle();
@ -33,37 +33,37 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
poolOwnerMock.setDefaultDestination(defaultDestId);
poolOwner.setHkDestId(hkDest);
auto* hkMan = poolOwner.getHkManagerHandle();
CommandMessage messageSent;
// TODO: Fix
/*
SECTION("Basic Test") {
{
/* For code coverage, should not crash */
// For code coverage, should not crash
PeriodicHkGenerationHelper manager(nullptr, nullptr);
}
auto owner = poolOwner.poolManager.getOwner();
auto owner = poolOwner.hkHelper.getOwner();
REQUIRE(owner != nullptr);
CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
/* Subscribe for message generation on update. */
// Subscribe for message generation on update.
REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == returnvalue::OK);
/* Subscribe for an update message. */
/// Subscribe for an update message.
poolOwner.dataset.setChanged(true);
/* Now the update message should be generated. */
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
// Now the update message should be generated.
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
/* Should have been reset. */
// Should have been reset.
CHECK(poolOwner.dataset.hasChanged() == false);
poolOwnerMock.clearMessages(true);
/* Set changed again, result should be the same. */
// Set changed again, result should be the same.
poolOwner.dataset.setChanged(true);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent() == true);
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
@ -72,10 +72,10 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
poolOwnerMock.clearMessages(true);
/* Now subscribe for set update HK as well. */
// Now subscribe for set update HK as well.
REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK);
poolOwner.dataset.setChanged(true);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent() == true);
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
// first message sent should be the update notification
@ -84,12 +84,12 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
REQUIRE(poolOwnerMock.getNextSentMessageToDefaultDest(messageSent) == returnvalue::OK);
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::HK_REPORT));
/* Clear message to avoid memory leak, our mock won't do it for us (yet) */
// Clear message to avoid memory leak, our mock won't do it for us (yet)
CommandMessageCleaner::clearCommandMessage(&messageSent);
}
SECTION("SetSnapshotUpdateTest") {
/* Set the variables in the set to certain values. These are checked later. */
// Set the variables in the set to certain values. These are checked later.
{
PoolReadGuard readHelper(&poolOwner.dataset);
REQUIRE(readHelper.getReadResult() == returnvalue::OK);
@ -100,22 +100,22 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
poolOwner.dataset.localPoolUint16Vec.value[2] = 42932;
}
/* Subscribe for snapshot generation on update. */
// Subscribe for snapshot generation on update.
REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == returnvalue::OK);
poolOwner.dataset.setChanged(true);
/* Store current time, we are going to check the (approximate) time equality later */
// Store current time, we are going to check the (approximate) time equality later
timeval now{};
Clock::getClock_timeval(&now);
/* Trigger generation of snapshot */
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
// Trigger generation of snapshot
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
/* Check that snapshot was generated */
// Check that snapshot was generated
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_SET));
/* Now we deserialize the snapshot into a new dataset instance */
// Now we deserialize the snapshot into a new dataset instance
CCSDSTime::CDS_short cdsShort{};
LocalPoolTestDataSet newSet;
HousekeepingSnapshot snapshot(&cdsShort, &newSet);
@ -130,17 +130,17 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
CHECK(newSet.localPoolUint16Vec.value[0] == 0);
CHECK(newSet.localPoolUint16Vec.value[1] == 0);
CHECK(newSet.localPoolUint16Vec.value[2] == 0);
/* Fill the dataset and timestamp */
// Fill the dataset and timestamp
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
/* Now we check that the snapshot is actually correct */
// Now we check that the snapshot is actually correct
CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242));
CHECK(newSet.localPoolVarUint8 == 5);
CHECK(newSet.localPoolUint16Vec.value[0] == 2);
CHECK(newSet.localPoolUint16Vec.value[1] == 32);
CHECK(newSet.localPoolUint16Vec.value[2] == 42932);
/* Now we check that both times are equal */
// Now we check that both times are equal
timeval timeFromHK{};
auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort);
CHECK(result == returnvalue::OK);
@ -149,11 +149,11 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
}
SECTION("VariableSnapshotTest") {
/* Acquire subscription interface */
// Acquire subscription interface
PeriodicHkGenerationProviderIF* subscriptionIF = poolOwner.getSubscriptionInterface();
REQUIRE(subscriptionIF != nullptr);
/* Subscribe for variable snapshot */
// Subscribe for variable snapshot
REQUIRE(poolOwner.subscribeWrapperVariableSnapshot(subscriberId, lpool::uint8VarId) ==
returnvalue::OK);
auto poolVar =
@ -167,22 +167,22 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
}
poolVar->setChanged(true);
/* Store current time, we are going to check the (approximate) time equality later */
// Store current time, we are going to check the (approximate) time equality later
CCSDSTime::CDS_short timeCdsNow{};
timeval now{};
Clock::getClock_timeval(&now);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
/* Check update snapshot was sent. */
// Check update snapshot was sent.
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
/* Should have been reset. */
// Should have been reset.
CHECK(poolVar->hasChanged() == false);
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE));
/* Now we deserialize the snapshot into a new dataset instance */
// Now we deserialize the snapshot into a new dataset instance
CCSDSTime::CDS_short cdsShort{};
lp_var_t<uint8_t> varCopy = lp_var_t<uint8_t>(lpool::uint8VarGpid);
HousekeepingSnapshot snapshot(&cdsShort, &varCopy);
@ -193,12 +193,12 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
const uint8_t* readOnlyPtr = accessorPair.second.data();
size_t sizeToDeserialize = accessorPair.second.size();
CHECK(varCopy.value == 0);
/* Fill the dataset and timestamp */
// Fill the dataset and timestamp
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
CHECK(varCopy.value == 25);
/* Now we check that both times are equal */
// Now we check that both times are equal
timeval timeFromHK{};
auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort);
CHECK(result == returnvalue::OK);
@ -207,11 +207,11 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
}
SECTION("VariableNotificationTest") {
/* Acquire subscription interface */
// Acquire subscription interface
PeriodicHkGenerationProviderIF* subscriptionIF = poolOwner.getSubscriptionInterface();
REQUIRE(subscriptionIF != nullptr);
/* Subscribe for variable update */
// Subscribe for variable update
REQUIRE(poolOwner.subscribeWrapperVariableUpdate(subscriberId, lpool::uint8VarId) ==
returnvalue::OK);
auto* poolVar =
@ -219,25 +219,25 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
REQUIRE(poolVar != nullptr);
poolVar->setChanged(true);
REQUIRE(poolVar->hasChanged() == true);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
/* Check update notification was sent. */
// Check update notification was sent.
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
/* Should have been reset. */
// Should have been reset.
CHECK(poolVar->hasChanged() == false);
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
/* Now subscribe for the dataset update (HK and update) again with subscription interface */
// Now subscribe for the dataset update (HK and update) again with subscription interface
REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT,
subscriberId, false) == returnvalue::OK);
REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK);
poolOwner.dataset.setChanged(true);
poolOwnerMock.clearMessages();
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
/* Now two messages should be sent. */
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
// Now two messages should be sent.
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
poolOwnerMock.clearMessages(true);
@ -245,8 +245,8 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
poolOwner.dataset.setChanged(true);
poolOwnerMock.clearMessages(true);
poolVar->setChanged(true);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
/* Now three messages should be sent. */
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
// Now three messages should be sent.
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 3);
CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2);
@ -267,20 +267,20 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
}
SECTION("PeriodicHKAndMessaging") {
/* Now we subcribe for a HK periodic generation. Even when it's difficult to simulate
the temporal behaviour correctly the HK manager should generate a HK packet
immediately and the periodic helper depends on HK op function calls anyway instead of
using the clock, so we could also just call performHkOperation multiple times */
//Now we subcribe for a HK periodic generation. Even when it's difficult to simulate
//the temporal behaviour correctly the HK manager should generate a HK packet
//immediately and the periodic helper depends on HK op function calls anyway instead of
//using the clock, so we could also just call performHkOperation multiple times
REQUIRE(poolOwner.subscribePeriodicHk(true) == returnvalue::OK);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
/* Now HK packet should be sent as message immediately. */
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
// Now HK packet should be sent as message immediately.
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid);
REQUIRE(setHandle != nullptr);
CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
CHECK(poolOwner.hkHelper.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
@ -289,41 +289,41 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
CHECK(setHandle->getReportingEnabled() == true);
CommandMessage hkCmd;
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(setHandle->getReportingEnabled() == false);
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(setHandle->getReportingEnabled() == true);
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(setHandle->getReportingEnabled() == false);
REQUIRE(poolOwnerMock.wasMessageSent());
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK_THAT(poolOwner.dataset.getCollectionInterval(), Catch::Matchers::WithinAbs(0.4, 0.01));
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid);
REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
/* Now HK packet should be sent as message. */
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
// Now HK packet should be sent as message.
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
@ -331,63 +331,64 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid);
sid_t sidToCheck;
store_address_t storeId;
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true);
CHECK(sidToCheck == lpool::testSid);
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid);
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
REQUIRE(poolOwnerMock.wasMessageSent());
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
poolOwnerMock.clearMessages();
HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid);
gp_id_t gpidToCheck;
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true);
CHECK(gpidToCheck == lpool::uint8VarGpid);
HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid,
store_address_t::invalid());
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true);
CHECK(sidToCheck == lpool::testSid);
HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid,
store_address_t::invalid());
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true);
CHECK(gpidToCheck == lpool::uint8VarGpid);
poolOwner.poolManager.printPoolEntry(lpool::uint8VarId);
poolOwner.hkHelper.printPoolEntry(lpool::uint8VarId);
}
/* we need to reset the subscription list because the pool owner
is a global object. */
// we need to reset the subscription list because the pool owner
//is a global object.
CHECK(poolOwner.reset() == returnvalue::OK);
poolOwnerMock.clearMessages(true);
*/
}

View File

@ -1,4 +1,4 @@
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <catch2/catch_test_macros.hpp>
@ -12,8 +12,7 @@ using namespace returnvalue;
TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
auto queue = MessageQueueMock(1);
LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner.initializeHkManager() == OK);
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK);
REQUIRE(poolOwner.initialize() == OK);
SECTION("Basic Tests") {
/* very basic test. */
@ -25,10 +24,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
REQUIRE(testVariable.commit() == returnvalue::OK);
REQUIRE(testVariable.read() == returnvalue::OK);
REQUIRE(testVariable.value == 5);
CHECK(not testVariable.isValid());
testVariable.setValid(true);
CHECK(testVariable.isValid());
CHECK(testVariable.commit(true) == returnvalue::OK);
CHECK(testVariable.commit() == returnvalue::OK);
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
@ -38,10 +34,6 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
CHECK(testVariable.getDataPoolId() == 22);
testVariable.setDataPoolId(lpool::uint8VarId);
testVariable.setChanged(true);
CHECK(testVariable.hasChanged());
testVariable.setChanged(false);
gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId);
REQUIRE(testVariable2.read() == returnvalue::OK);
@ -105,6 +97,5 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") {
lp_var_t<uint8_t> invalidObjectVar = lp_var_t<uint8_t>(0xffffffff, lpool::uint8VarId);
gp_id_t globPoolId(0xffffffff, lpool::uint8VarId);
lp_var_t<uint8_t> invalidObjectVar2 = lp_var_t<uint8_t>(globPoolId);
lp_var_t<uint8_t> invalidObjectVar3 = lp_var_t<uint8_t>(nullptr, lpool::uint8VarId);
}
}

View File

@ -1,4 +1,4 @@
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <catch2/catch_test_macros.hpp>
@ -12,8 +12,7 @@ using namespace returnvalue;
TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") {
auto queue = MessageQueueMock(1);
LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner.initializeHkManager() == OK);
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK);
REQUIRE(poolOwner.initialize() == OK);
SECTION("BasicTest") {
// very basic test.
@ -25,7 +24,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") {
testVector.value[2] = 32023;
REQUIRE(testVector.commit(true) == returnvalue::OK);
CHECK(testVector.isValid());
// CHECK(testVector.isValid());
testVector.value[0] = 0;
testVector.value[1] = 0;

View File

@ -31,8 +31,8 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
task.startTask();
MessageQueueIF* testQueue = QueueFactory::instance()->createMessageQueue(1);
MessageQueueIF* hkQueue = QueueFactory::instance()->createMessageQueue(1);
internalErrorReporter->getSubscriptionInterface()->subscribeForSetUpdateMessage(
InternalErrorDataset::ERROR_SET_ID, objects::NO_OBJECT, hkQueue->getId(), true);
// internalErrorReporter->getSubscriptionInterface()->subscribeForSetUpdateMessage(
// InternalErrorDataset::ERROR_SET_ID, objects::NO_OBJECT, hkQueue->getId(), true);
auto* ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
SECTION("MessageQueueFull") {
CommandMessage message;
@ -46,6 +46,8 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
then remeber the queueHit count and force another hit */
internalErrorReporter->queueMessageNotSent();
internalErrorReporter->performOperation(0);
// TODO: Fix test
/*
{
CommandMessage hkMessage;
result = hkQueue->receiveMessage(&hkMessage);
@ -114,6 +116,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
REQUIRE(result == returnvalue::OK);
internalErrorReporter->performOperation(0);
}
*/
}
QueueFactory::instance()->deleteMessageQueue(testQueue);
QueueFactory::instance()->deleteMessageQueue(hkQueue);

View File

@ -108,3 +108,14 @@ ReturnValue_t DeviceHandlerMock::initialize() {
setMode(MODE_ON);
return result;
}
ReturnValue_t DeviceHandlerMock::serializeDataset(sid_t structureId, uint8_t *buf, size_t maxSize) {
return returnvalue::OK;
}
ReturnValue_t DeviceHandlerMock::specifyDatasets(
std::vector<periodicHk::SetSpecification> &setList) {
return returnvalue::OK;
}
localpool::SharedPool *DeviceHandlerMock::getOptionalSharedPool() { return nullptr; }

View File

@ -23,6 +23,12 @@ class DeviceHandlerMock : public DeviceHandlerBase {
ReturnValue_t initialize() override;
ReturnValue_t serializeDataset(sid_t structureId, uint8_t *buf, size_t maxSize) override;
ReturnValue_t specifyDatasets(std::vector<periodicHk::SetSpecification> &setList) override;
localpool::SharedPool *getOptionalSharedPool() override;
protected:
void doStartUp() override;
void doShutDown() override;

View File

@ -3,19 +3,38 @@
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, object_id_t objectId)
: SystemObject(objectId),
queue(queue),
poolManager(this, &queue),
dataset(this, lpool::testSetId) {}
sharedPool(getObjectId()),
hkHelper(this, &queue),
dataset(sharedPool, lpool::testSetId) {}
LocalPoolOwnerBase::~LocalPoolOwnerBase() = default;
ReturnValue_t LocalPoolOwnerBase::initializeHkManager() {
if (not initialized) {
initialized = true;
return poolManager.initialize(&queue);
ReturnValue_t LocalPoolOwnerBase::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();
}
localpool::SharedPool *LocalPoolOwnerBase::getOptionalSharedPool() { return &sharedPool; }
ReturnValue_t LocalPoolOwnerBase::serializeDataset(sid_t structureId, uint8_t *buf,
size_t maxSize) {
return returnvalue::OK;
}
ReturnValue_t LocalPoolOwnerBase::specifyDatasets(
std::vector<periodicHk::SetSpecification> &setList) {
return returnvalue::OK;
}
/*
ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
PeriodicHkGenerationHelper &poolManager) {
// Default initialization empty for now.
@ -27,6 +46,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &l
localDataPoolMap.emplace(lpool::int64Vec2Id, &i64VecPoolEntry);
return returnvalue::OK;
}
*/
LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) {
if (localPoolId == lpool::uint8VarId) {
@ -93,14 +113,6 @@ bool LocalPoolOwnerBase::changedDataSetCallbackWasCalled(sid_t &sid, store_addre
return condition;
}
/*
void LocalPoolOwnerBase::handleChangedDataset(sid_t sid, store_address_t storeId,
bool *clearMessage) {
this->changedDatasetSid = sid;
this->storeIdForChangedSet = storeId;
}
*/
bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_address_t &storeId) {
bool condition = false;
if (not this->changedPoolVariableGpid.notSet()) {
@ -113,20 +125,4 @@ bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_a
return condition;
}
ReturnValue_t LocalPoolOwnerBase::initializeHkManagerAfterTaskCreation() {
if (not initializedAfterTaskCreation) {
initializedAfterTaskCreation = true;
return poolManager.initializeAfterTaskCreation();
}
return returnvalue::OK;
}
/*
void LocalPoolOwnerBase::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool *clearMessage) {
this->changedPoolVariableGpid = globPoolId;
this->storeIdForChangedVariable = storeId;
}
*/
void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { poolManager.setHkDestinationId(id); }
void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); }

View File

@ -2,10 +2,10 @@
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.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/ipc/QueueFactory.h>
#include <fsfw/objectmanager/SystemObject.h>
@ -37,8 +37,8 @@ class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> {
public:
LocalPoolStaticTestDataSet() : StaticLocalDataSet(lpool::testSid) {}
LocalPoolStaticTestDataSet(PeriodicHkGenerationIF* owner, uint32_t setId)
: StaticLocalDataSet(owner, setId) {}
LocalPoolStaticTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
: StaticLocalDataSet(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);
@ -51,8 +51,8 @@ class LocalPoolTestDataSet : public LocalDataSet {
public:
LocalPoolTestDataSet() : LocalDataSet(lpool::testSid, lpool::dataSetMaxVariables) {}
LocalPoolTestDataSet(PeriodicHkGenerationIF* owner, uint32_t setId)
: LocalDataSet(owner, setId, lpool::dataSetMaxVariables) {}
LocalPoolTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
: LocalDataSet(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);
@ -70,31 +70,20 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
[[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); }
ReturnValue_t initializeHkManager();
ReturnValue_t serializeDataset(sid_t structureId, uint8_t* buf, size_t maxSize) override;
ReturnValue_t specifyDatasets(std::vector<periodicHk::SetSpecification>& setList) override;
localpool::SharedPool* getOptionalSharedPool() override;
ReturnValue_t initialize() override;
void setHkDestId(MessageQueueId_t id);
ReturnValue_t initializeHkManagerAfterTaskCreation();
// ReturnValue_t initializeHkManagerAfterTaskCreation();
/** Command queue for housekeeping messages. */
[[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); }
// This is called by initializeAfterTaskCreation of the HK manager.
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
PeriodicHkGenerationHelper& poolManager) override;
PeriodicHkGenerationHelper* getHkManagerHandle() override { return &poolManager; }
//[[nodiscard]] dur_millis_t getPeriodicOperationFrequency() const override { return 200; }
/**
* This function is used by the pool manager to get a valid dataset
* from a SID
* @param sid Corresponding structure ID
* @return
*/
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override { return &dataset; }
LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override;
[[nodiscard]] MessageQueueMock& getMockQueueHandle() const {
@ -102,64 +91,22 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
}
ReturnValue_t subscribePeriodicHk(bool enableReporting) {
return poolManager.enableRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(lpool::testSid, enableReporting, 0.2));
}
ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) {
return poolManager.subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT,
receiverId, false);
}
ReturnValue_t subscribeWrapperSetUpdateSnapshot(MessageQueueId_t receiverId) {
return poolManager.subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT,
receiverId, true);
}
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false,
AcceptsHkPacketsIF* receiver = nullptr) {
if (diagnostics) {
auto params = subdp::DiagnosticsHkUpdateParams(lpool::testSid, true);
if (receiver != nullptr) {
params.receiver = receiver->getHkQueue();
}
return poolManager.subscribeForDiagUpdatePacket(params);
} else {
auto params = subdp::RegularHkUpdateParams(lpool::testSid, true);
if (receiver != nullptr) {
params.receiver = receiver->getHkQueue();
}
return poolManager.subscribeForRegularUpdatePacket(params);
}
}
ReturnValue_t subscribeWrapperVariableUpdate(MessageQueueId_t receiverId, lp_id_t localPoolId) {
return poolManager.subscribeForVariableUpdateMessage(localPoolId, MessageQueueIF::NO_QUEUE,
receiverId, false);
}
ReturnValue_t subscribeWrapperVariableSnapshot(MessageQueueId_t receiverId, lp_id_t localPoolId) {
return poolManager.subscribeForVariableUpdateMessage(localPoolId, MessageQueueIF::NO_QUEUE,
receiverId, true);
return hkHelper.enablePeriodicPacket(lpool::testSid, 200);
}
ReturnValue_t reset();
// void resetSubscriptionList() { poolManager.clearReceiversList(); }
bool changedDataSetCallbackWasCalled(sid_t& sid, store_address_t& storeId);
bool changedVariableCallbackWasCalled(gp_id_t& gpid, store_address_t& storeId);
PeriodicHkGenerationHelper poolManager;
PeriodicHkGenerationHelper hkHelper;
localpool::SharedPool sharedPool;
LocalPoolTestDataSet dataset;
private:
// void handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) override;
sid_t changedDatasetSid;
store_address_t storeIdForChangedSet;
// void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
// bool* clearMessage) override;
gp_id_t changedPoolVariableGpid;
store_address_t storeIdForChangedVariable;
@ -169,11 +116,11 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
PoolEntry<uint16_t> u16VecPoolEntry = PoolEntry<uint16_t>({0, 0, 0});
PoolEntry<int64_t> i64VecPoolEntry = PoolEntry<int64_t>({0, 0});
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId);
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId);
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId);
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this, lpool::uint16Vec3Id);
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this, lpool::int64Vec2Id);
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(sharedPool, lpool::uint8VarId);
lp_var_t<float> testFloat = lp_var_t<float>(sharedPool, lpool::floatVarId);
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(sharedPool, lpool::uint32VarId);
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(sharedPool, lpool::uint16Vec3Id);
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(sharedPool, lpool::int64Vec2Id);
MessageQueueIF& queue;