continue update

This commit is contained in:
Robin Müller 2024-11-06 16:55:09 +01:00
parent 79dca64cf3
commit 3c1072d7c9
Signed by: muellerr
GPG Key ID: A649FB78196E3849
83 changed files with 1185 additions and 1347 deletions

View File

@ -123,11 +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}
src/fsfw/datapoollocal/SharedPool.h src/fsfw/datapoollocal/SharedPool.cpp
src/fsfw/serialize/SerializableList.h
src/fsfw/serialize/SerializableListElement.h)
add_library(${LIB_FSFW_NAME} src/fsfw/housekeeping/PeriodicHkHelperIF.h
src/fsfw/housekeeping/definitions.h)
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION
@ -145,7 +142,7 @@ if(FSFW_BUILD_TESTS)
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT} unittests/serialize/testList.cpp)
add_executable(${FSFW_TEST_TGT})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
TRUE)

View File

@ -1,10 +1,10 @@
#include "HasLocalDpIFManagerAttorney.h"
#include "fsfw/datapoollocal/LocalPoolObjectBase.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/datapool/LocalPoolObjectBase.h"
#include "fsfw/housekeeping/GeneratesPeriodicHkIF.h"
LocalPoolObjectBase* HasLocalDpIFManagerAttorney::getPoolObjectHandle(
PeriodicHkGenerationIF* clientIF, lp_id_t localPoolId) {
PeriodicHkGenerationIF* clientIF, dp::lp_id_t localPoolId) {
return clientIF->getPoolObjectHandle(localPoolId);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include <fsfw/housekeeping/PeriodicHkHelper.h>
#include "fsfw/datapool/definitions.h"
class PeriodicHkGenerationIF;
class LocalPoolDataSetBase;
class LocalPoolObjectBase;
class HasLocalDpIFManagerAttorney {
static LocalPoolObjectBase* getPoolObjectHandle(PeriodicHkGenerationIF* clientIF,
dp::lp_id_t localPoolId);
static object_id_t getObjectId(PeriodicHkGenerationIF* clientIF);
friend class hk::PeriodicHelper;
};

View File

@ -0,0 +1 @@
#include "HasLocalDpIFUserAttorney.h"

View File

@ -43,18 +43,4 @@ struct DiagnosticsHkUpdateParams : public ParamsBase {
};
} // namespace subdp
class PeriodicHkGenerationProviderIF {
public:
virtual ~PeriodicHkGenerationProviderIF() = default;
/**
* Set the periodic generation frequency without enabling the periodic generation of packets.
*/
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;
};
#endif /* FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ */

View File

@ -1,6 +1,6 @@
#include "fsfw/datapoollocal/SharedLocalDataset.h"
#include "fsfw/datapool/SharedLocalDataset.h"
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, sid_t sid, const size_t maxSize)
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, structure_id_t sid, const size_t maxSize)
: SystemObject(objectId), SharedDatasetBase(sid, nullptr, maxSize), poolVarVector(maxSize) {
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();

View File

@ -1,13 +1,15 @@
#ifndef FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_
#define FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_
#pragma once
#include <vector>
#include "../datapool/SharedDataSetIF.h"
#include "../objectmanager/SystemObject.h"
#include "SharedDatasetBase.h"
#include "fsfw/datapool/SharedDataSetIF.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "SharedSetBase.h"
#include "SharedPool.h"
/**
namespace datapool {
/**
* This local dataset variation can be used if the dataset is used concurrently across
* multiple threads. It provides a lock in addition to all other functionalities provided
* by the LocalPoolDataSetBase class.
@ -15,9 +17,9 @@
* The user is completely responsible for locking and unlocking the dataset when using the
* shared dataset.
*/
class SharedLocalDataset : public SystemObject, public SharedDatasetBase, public SharedDataSetIF {
class SharedLocalDataset : public SystemObject, public SharedSetBase, public SharedDataSetIF {
public:
SharedLocalDataset(object_id_t objectId, localpool::SharedPool& sharedPool, uint32_t setId,
SharedLocalDataset(object_id_t objectId, SharedPool& sharedPool, uint32_t setId,
size_t maxSize);
SharedLocalDataset(object_id_t objectId, sid_t sid, size_t maxSize);
@ -32,4 +34,4 @@ class SharedLocalDataset : public SystemObject, public SharedDatasetBase, public
std::vector<PoolVariableIF*> poolVarVector;
};
#endif /* FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ */
}

View File

@ -7,7 +7,6 @@ add_subdirectory(cfdp)
add_subdirectory(container)
add_subdirectory(controller)
add_subdirectory(datapool)
add_subdirectory(datapoollocal)
add_subdirectory(devicehandlers)
add_subdirectory(events)
add_subdirectory(fdir)

View File

@ -10,16 +10,12 @@ ExtendedControllerBase::~ExtendedControllerBase() = default;
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
/* Needs to be overriden and implemented by child class. */
// Needs to be overriden and implemented by child class.
return returnvalue::OK;
}
object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); }
// uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const {
// return this->executingTask->getPeriodMs();
//}
ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *message) {
ReturnValue_t result = actionHelper.handleActionMessage(message);
if (result == returnvalue::OK) {
@ -78,12 +74,10 @@ ReturnValue_t ExtendedControllerBase::initialize() {
ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
handleQueue();
performControlOperation(opCode);
/* We do this after performing control operation because variables will be set changed
in this function. */
// We do this after performing control operation because variables will be set changed
// in this function.
hkHelper.performHkOperation();
return returnvalue::OK;
}
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); }
// PeriodicHkGenerationHelper *ExtendedControllerBase::getHkManagerHandle() { return &hkHelper; }
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); }

View File

@ -1,10 +1,11 @@
#ifndef FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_
#define FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_
#include <fsfw/housekeeping/GeneratesPeriodicHkIF.h>
#include "ControllerBase.h"
#include "fsfw/action.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/housekeeping/PeriodicHkHelper.h"
/**
* @brief Extends the basic ControllerBase with commonly used components
@ -15,9 +16,9 @@
*/
class ExtendedControllerBase : public ControllerBase,
public HasActionsIF,
public PeriodicHkGenerationIF {
public hk::GeneratesPeriodicHkIF {
public:
ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth = 3);
explicit ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth = 3);
~ExtendedControllerBase() override;
/* SystemObjectIF overrides */
@ -29,7 +30,7 @@ class ExtendedControllerBase : public ControllerBase,
ReturnValue_t performOperation(uint8_t opCode) override;
protected:
PeriodicHkGenerationHelper hkHelper;
hk::PeriodicHelper hkHelper;
ActionHelper actionHelper;
/**

11
src/fsfw/datapool.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
#define FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
// Collected related headers
#include "fsfw/datapool/LocalPoolVector.h"
#include "fsfw/datapool/PoolVariable.h"
#include "fsfw/datapool/SharedPool.h"
#include "fsfw/datapool/SharedSet.h"
#include "fsfw/datapool/StaticSharedSet.h"
#endif /* FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ */

View File

@ -1 +1,6 @@
target_sources(${LIB_FSFW_NAME} PRIVATE PoolDataSetBase.cpp PoolEntry.cpp)
target_sources(
${LIB_FSFW_NAME}
PRIVATE PoolDataSetBase.cpp PoolEntry.cpp SharedPool.cpp SharedSet.cpp
SharedSetBase.cpp LocalPoolObjectBase.cpp)
add_subdirectory(internal)

View File

@ -1,13 +1,11 @@
#include "fsfw/datapoollocal/LocalPoolObjectBase.h"
#include "fsfw/datapool/LocalPoolObjectBase.h"
#include "fsfw/datapoollocal/AccessLocalPoolF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/housekeeping/PeriodicHkHelper.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "internal/HasLocalDpIFUserAttorney.h"
LocalPoolObjectBase::LocalPoolObjectBase(localpool::SharedPool& sharedPool, lp_id_t poolId,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
using namespace dp;
PoolObjectBase::PoolObjectBase(SharedPool& sharedPool, dp::lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: localPoolId(poolId), readWriteMode(setReadWriteMode), sharedPool(&sharedPool) {
if (poolId == PoolVariableIF::NO_PARAMETER) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -21,8 +19,8 @@ LocalPoolObjectBase::LocalPoolObjectBase(localpool::SharedPool& sharedPool, lp_i
}
}
LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
PoolObjectBase::PoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: localPoolId(poolId), readWriteMode(setReadWriteMode) {
if (poolId == PoolVariableIF::NO_PARAMETER) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -35,7 +33,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
"which is the NO_PARAMETER value!\n");
#endif
}
auto* hkOwner = ObjectManager::instance()->get<PeriodicHkGenerationIF>(poolOwner);
auto* hkOwner = ObjectManager::instance()->get<hk::GeneratesPeriodicHkIF>(poolOwner);
if (hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner
@ -56,18 +54,18 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
}
}
pool_rwm_t LocalPoolObjectBase::getReadWriteMode() const { return readWriteMode; }
pool_rwm_t PoolObjectBase ::getReadWriteMode() const { return readWriteMode; }
lp_id_t LocalPoolObjectBase::getDataPoolId() const { return localPoolId; }
lp_id_t PoolObjectBase ::getDataPoolId() const { return localPoolId; }
void LocalPoolObjectBase::setDataPoolId(lp_id_t poolId) { this->localPoolId = poolId; }
void PoolObjectBase::setDataPoolId(lp_id_t poolId) { this->localPoolId = poolId; }
void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
void PoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
this->readWriteMode = newReadWriteMode;
}
void LocalPoolObjectBase::reportReadCommitError(const char* variableType, ReturnValue_t error,
bool read, object_id_t objectId, lp_id_t lpId) {
void PoolObjectBase::reportReadCommitError(const char* variableType, ReturnValue_t error, bool read,
object_id_t objectId, lp_id_t lpId) {
#if FSFW_DISABLE_PRINTOUT == 0
const char* variablePrintout = variableType;
if (variablePrintout == nullptr) {

View File

@ -1,32 +1,31 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_
#pragma once
#include "MarkChangedIF.h"
#include "SharedPool.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/datapool/definitions.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "localPoolDefinitions.h"
class DataSetIF;
namespace datapool {
/**
* @brief This class serves as a non-template base for pool objects like pool variables
* or pool vectors.
*/
class LocalPoolObjectBase : public PoolVariableIF {
class PoolObjectBase : public PoolVariableIF {
public:
LocalPoolObjectBase(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode);
PoolObjectBase(dp::SharedPool& sharedPool, dp::lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode);
LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
PoolObjectBase(object_id_t poolOwner, dp::lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
void setReadWriteMode(pool_rwm_t newReadWriteMode) override;
pool_rwm_t getReadWriteMode() const override;
[[nodiscard]] pool_rwm_t getReadWriteMode() const override;
lp_id_t getDataPoolId() const override;
void setDataPoolId(lp_id_t poolId);
[[nodiscard]] lp_id_t getDataPoolId() const override;
void setDataPoolId(dp::lp_id_t poolId);
protected:
/**
@ -42,10 +41,10 @@ class LocalPoolObjectBase : public PoolVariableIF {
ReadWriteMode_t readWriteMode = pool_rwm_t::VAR_READ_WRITE;
//! @brief Pointer to the class which manages the HK pool.
localpool::SharedPool* sharedPool = nullptr;
dp::SharedPool* sharedPool = nullptr;
void reportReadCommitError(const char* variableType, ReturnValue_t error, bool read,
object_id_t objectId, lp_id_t lpId);
object_id_t objectId, dp::lp_id_t lpId);
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_ */
} // namespace datapool

View File

@ -1,14 +1,15 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_
#pragma once
#include <fsfw/ipc/MutexGuard.h>
#include <misc/archive/HasLocalDpIFManagerAttorney.h>
#include "../datapool/DataSetIF.h"
#include "../datapool/PoolEntry.h"
#include "../datapool/PoolVariableIF.h"
#include "../datapoollocal/PeriodicHkGenerationHelper.h"
#include "../serialize/SerializeAdapter.h"
#include "../serviceinterface/ServiceInterface.h"
#include "LocalPoolObjectBase.h"
#include "internal/LocalDpManagerAttorney.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
namespace datapool {
/**
* @brief This is the access class for array-type data pool entries.
@ -24,16 +25,16 @@
* @tparam T
* This template parameter specifies the data type of an array entry. Currently,
* all plain data types are supported, but in principle any type is possible.
* @tparam vector_size
* @tparam N
* This template parameter specifies the vector size of this entry. Using a
* template parameter for this is not perfect, but avoids
* dynamic memory allocation.
* @ingroup data_pool
*/
template <typename T, uint16_t vectorSize>
class LocalPoolVector : public LocalPoolObjectBase {
template <typename T, size_t N>
class PoolVector : public PoolObjectBase {
public:
LocalPoolVector() = delete;
PoolVector() = delete;
/**
* This constructor is used by the data creators to have pool variable
* instances which can also be stored in datasets.
@ -47,8 +48,9 @@ class LocalPoolVector : public LocalPoolObjectBase {
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
*/
LocalPoolVector(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
PoolVector(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE)
: PoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {}
/**
* This constructor is used by data users like controllers to have
@ -64,8 +66,8 @@ class LocalPoolVector : public LocalPoolObjectBase {
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
*/
LocalPoolVector(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
PoolVector(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* Variation which takes the unique global identifier of a local pool
* vector.
@ -73,8 +75,10 @@ class LocalPoolVector : public LocalPoolObjectBase {
* @param dataSet
* @param setReadWriteMode
*/
LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
PoolVector(g_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE)
: PoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet, setReadWriteMode) {
}
/**
* @brief This is the local copy of the data pool entry.
@ -82,27 +86,80 @@ class LocalPoolVector : public LocalPoolObjectBase {
* The user can work on this attribute just like he would on a local
* array of this type.
*/
T value[vectorSize] = {};
T value[N] = {};
/**
* @brief The classes destructor is empty.
* @details If commit() was not called, the local value is
* discarded and not written back to the data pool.
*/
~LocalPoolVector() {};
~PoolVector() override {};
/**
* @brief The operation returns the number of array entries
* in this variable.
*/
uint8_t getSize() { return vectorSize; }
size_t getSize() { return N; }
T& operator[](size_t i);
const T& operator[](size_t i) const;
T& operator[](size_t i) {
if (i < N) {
return value[i];
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PoolVector: Invalid index. Setting or returning"
" last value!"
<< std::endl;
#else
sif::printWarning(
"PoolVector: Invalid index. Setting or returning"
" last value!\n");
#endif
return value[N - 1];
}
const T& operator[](size_t i) const {
if (i < N) {
return value[i];
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PoolVector: Invalid index. Setting or returning"
" last value!"
<< std::endl;
#else
sif::printWarning(
"PoolVector: Invalid index. Setting or returning"
" last value!\n");
#endif
return value[N - 1];
}
ReturnValue_t serialize(uint8_t** buffer, size_t* size, const size_t maxSize,
SerializeIF::Endianness streamEndiannes) const override;
size_t getSerializedSize() const override;
SerializeIF::Endianness streamEndianness) const override {
ReturnValue_t result = returnvalue::FAILED;
for (uint16_t i = 0; i < N; i++) {
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
break;
}
}
return result;
}
[[nodiscard]] size_t getSerializedSize() const override {
return N * SerializeAdapter::getSerializedSize(value);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override;
SerializeIF::Endianness streamEndianness) override {
ReturnValue_t result = returnvalue::FAILED;
for (uint16_t i = 0; i < N; i++) {
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness);
if (result != returnvalue::OK) {
break;
}
}
return result;
}
/**
* @brief This is a call to read the array's values
@ -118,7 +175,10 @@ class LocalPoolVector : public LocalPoolObjectBase {
* at once to avoid the overhead of unnecessary lock und unlock operations.
*/
ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
uint32_t timeoutMs = 20) override {
MutexGuard mg(sharedPool->getPoolMutex(), timeoutType, timeoutMs);
return readWithoutLock();
}
/**
* @brief The commit call copies the array values back to the data pool.
@ -129,15 +189,11 @@ class LocalPoolVector : public LocalPoolObjectBase {
* It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations.
*/
ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief This commit call also sets the validity of the pool entry.
* @details
*/
ReturnValue_t commit(bool valid, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
ReturnValue_t commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) override {
MutexGuard mg(sharedPool->getPoolMutex(), timeoutType, timeoutMs);
return commitWithoutLock();
}
ReturnValue_t commit() { return commit(MutexIF::TimeoutType::WAITING, 20); }
protected:
/**
@ -148,7 +204,22 @@ class LocalPoolVector : public LocalPoolObjectBase {
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t readWithoutLock() override;
ReturnValue_t readWithoutLock() override {
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = sharedPool->fetchPoolEntry(localPoolId, &poolEntry);
memset(this->value, 0, N * sizeof(T));
if (result != returnvalue::OK) {
return result;
}
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
return returnvalue::OK;
}
/**
* @brief Like #commit, but without a lock protection of the global pool.
* @details
@ -157,19 +228,36 @@ class LocalPoolVector : public LocalPoolObjectBase {
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t commitWithoutLock() override;
ReturnValue_t commitWithoutLock() override {
if (readWriteMode == pool_rwm_t::VAR_READ) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = sharedPool->fetchPoolEntry(localPoolId, &poolEntry);
if (result != returnvalue::OK) {
return result;
}
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
return returnvalue::OK;
}
private:
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout
template <typename U, uint16_t otherSize>
friend std::ostream& operator<<(std::ostream& out, const LocalPoolVector<U, otherSize>& var);
std::ostream& operator<<(std::ostream& out, const PoolVector<T, N>& var) {
out << "Vector: [";
for (int i = 0; i < N; i++) {
out << var.value[i];
if (i < N - 1) {
out << ", ";
}
}
out << "]";
return out;
}
#endif
};
#include "LocalPoolVector.tpp"
template <typename T, size_t N>
using vec_t = PoolVector<T, N>;
template <typename T, uint16_t vectorSize>
using lp_vec_t = LocalPoolVector<T, vectorSize>;
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_ */
} // namespace datapool

View File

View File

@ -1,11 +1,14 @@
#ifndef FSFW_DATAPOOL_POOLDATASETBASE_H_
#define FSFW_DATAPOOL_POOLDATASETBASE_H_
#pragma once
#include "PoolDataSetIF.h"
#include "PoolVariableIF.h"
#include "fsfw/ipc/MutexIF.h"
#include "fsfw/serialize/SerializeIF.h"
namespace datapool {
class SharedSetBase;
}
/**
* @brief The DataSetBase class manages a set of locally checked out variables.
* @details
@ -30,7 +33,7 @@
* @ingroup data_pool
*/
class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
friend class SharedDatasetBase;
friend class datapool::SharedSetBase;
public:
/**
@ -169,6 +172,4 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, uint32_t timeoutMs = 20);
ReturnValue_t handleUnreadDatasetCommit(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, uint32_t timeoutMs = 20);
};
#endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */
};

View File

@ -0,0 +1,342 @@
#pragma once
#include <fsfw/datapool/internal/SharedPoolAttorney.h>
#include "FSFWConfig.h"
#include "LocalPoolObjectBase.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/serialize/SerializeAdapter.h"
namespace datapool {
/**
* @brief Local Pool Variable class which is used to access the local pools.
* @details
* This class is not stored in the map. Instead, it is used to access
* the pool entries by using a pointer to the map storing the pool
* entries. It can also be used to organize these pool entries into data sets.
*
* @tparam T The template parameter sets the type of the variable. Currently,
* all plain data types are supported, but in principle any type is possible.
* @ingroup data_pool
*/
template <typename T>
class PoolVariable : public PoolObjectBase {
public:
//! Default ctor is forbidden.
PoolVariable() = delete;
/**
* This constructor is used by the data creators to have pool variable
* instances which can also be stored in datasets.
*
* It does not fetch the current value from the data pool, which
* has to be done by calling the read() operation.
* Datasets can be used to access multiple local pool entries in an
* efficient way. A pointer to a dataset can be passed to register
* the pool variable in that dataset directly.
* @param poolId ID of the local pool entry.
* @param hkOwner Pointer of the owner. This will generally be the calling
* class itself which passes "this".
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*/
PoolVariable(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* This constructor is used by data users like controllers to have
* access to the local pool variables of data creators by supplying
* the respective creator object ID.
*
* It does not fetch the current value from the data pool, which
* has to be done by calling the read() operation.
* Datasets can be used to access multiple local pool entries in an
* efficient way. A pointer to a dataset can be passed to register
* the pool variable in that dataset directly.
* @param poolId ID of the local pool entry.
* @param hkOwner object ID of the pool owner.
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*
*/
PoolVariable(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* Variation which takes the global unique identifier of a pool variable.
* @param globalPoolId
* @param dataSet
* @param setReadWriteMode
*/
PoolVariable(g_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
virtual ~PoolVariable() {};
/**
* @brief This is the local copy of the data pool entry.
* @details The user can work on this attribute
* just like he would on a simple local variable.
*/
T value = 0;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override;
/**
* @brief This is a call to read the array's values
* from the global data pool.
* @details
* When executed, this operation tries to fetch the pool entry with matching
* data pool id from the data pool and copies all array values and the valid
* information to its local attributes.
* In case of a failure (wrong type, size or pool id not found), the
* variable is set to zero and invalid.
* The read call is protected with a lock.
* It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations.
*
*/
ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief The commit call copies the array values back to the data pool.
* @details
* It checks type and size, as well as if the variable is writable. If so,
* the value is copied and the local valid flag is written back as well.
* The read call is protected with a lock.
* It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations.
*/
ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
PoolVariable<T>& operator=(const T& newValue);
PoolVariable<T>& operator=(const PoolVariable<T>& newPoolVariable);
//! Explicit type conversion operator. Allows casting the class to
//! its template type to perform operations on value.
explicit operator T() const;
bool operator==(const PoolVariable<T>& other) const;
bool operator==(const T& other) const;
bool operator!=(const PoolVariable<T>& other) const;
bool operator!=(const T& other) const;
bool operator<(const PoolVariable<T>& other) const;
bool operator<(const T& other) const;
bool operator>(const PoolVariable<T>& other) const;
bool operator>(const T& other) const;
protected:
/**
* @brief Like #read, but without a lock protection of the global pool.
* @details
* The operation does NOT provide any mutual exclusive protection by itself.
* This can be used if the lock is handled externally to avoid the overhead
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t readWithoutLock() override;
/**
* @brief Like #commit, but without a lock protection of the global pool.
* @details
* The operation does NOT provide any mutual exclusive protection by itself.
* This can be used if the lock is handled externally to avoid the overhead
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t commitWithoutLock() override;
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout
template <typename U>
friend std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<U>& var);
#endif
};
template <typename T>
PoolVariable<T>::PoolVariable(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: PoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {}
template <typename T>
PoolVariable<T>::PoolVariable(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: PoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template <typename T>
PoolVariable<T>::PoolVariable(g_id_t globalPoolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
: PoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet, setReadWriteMode) {}
template <typename T>
ReturnValue_t PoolVariable<T>::read(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
if (sharedPool == nullptr) {
return readWithoutLock();
}
MutexIF* mutex = sharedPool->getPoolMutex();
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
}
result = readWithoutLock();
mutex->unlockMutex();
return result;
}
template <typename T>
inline ReturnValue_t PoolVariable<T>::readWithoutLock() {
if (sharedPool == nullptr) {
return PoolVariableIF::INVALID_SHARED_POOL;
}
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
if (ReturnValue_t result = sharedPool->fetchPoolEntry(localPoolId, &poolEntry);
result != returnvalue::OK) {
return result;
}
this->value = *(poolEntry->getDataPtr());
return returnvalue::OK;
}
template <typename T>
inline ReturnValue_t PoolVariable<T>::commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
if (sharedPool == nullptr) {
return commitWithoutLock();
}
MutexIF* mutex = sharedPool->getPoolMutex();
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
}
result = commitWithoutLock();
mutex->unlockMutex();
return result;
}
template <typename T>
ReturnValue_t PoolVariable<T>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = sharedPool->fetchPoolEntry(localPoolId, &poolEntry);
if (result != returnvalue::OK) {
return result;
}
*(poolEntry->getDataPtr()) = this->value;
return returnvalue::OK;
}
template <typename T>
ReturnValue_t PoolVariable<T>::serialize(uint8_t** buffer, size_t* size, const size_t max_size,
SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value, buffer, size, max_size, streamEndianness);
}
template <typename T>
size_t PoolVariable<T>::getSerializedSize() const {
return SerializeAdapter::getSerializedSize(&value);
}
template <typename T>
ReturnValue_t PoolVariable<T>::deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
template <typename T>
inline std::ostream& operator<<(std::ostream& out, const PoolVariable<T>& var) {
out << var.value;
return out;
}
#endif
template <typename T>
PoolVariable<T>::operator T() const {
return value;
}
template <typename T>
PoolVariable<T>& PoolVariable<T>::operator=(const T& newValue) {
value = newValue;
return *this;
}
template <typename T>
PoolVariable<T>& PoolVariable<T>::operator=(const PoolVariable<T>& newPoolVariable) {
value = newPoolVariable.value;
return *this;
}
template <typename T>
bool PoolVariable<T>::operator==(const PoolVariable<T>& other) const {
return this->value == other.value;
}
template <typename T>
bool PoolVariable<T>::operator==(const T& other) const {
return this->value == other;
}
template <typename T>
bool PoolVariable<T>::operator!=(const PoolVariable& other) const {
return not(*this == other);
}
template <typename T>
bool PoolVariable<T>::operator!=(const T& other) const {
return not(*this == other);
}
template <typename T>
bool PoolVariable<T>::operator<(const PoolVariable<T>& other) const {
return this->value < other.value;
}
template <typename T>
bool PoolVariable<T>::operator<(const T& other) const {
return this->value < other;
}
template <typename T>
bool PoolVariable<T>::operator>(const PoolVariable<T>& other) const {
return not(*this < other);
}
template <typename T>
bool PoolVariable<T>::operator>(const T& other) const {
return not(*this < other);
}
template <class T>
using var_t = PoolVariable<T>;
using bool_t = PoolVariable<uint8_t>;
using u8_t = PoolVariable<uint8_t>;
using u16_t = PoolVariable<uint16_t>;
using u32_t = PoolVariable<uint32_t>;
using u64_t = PoolVariable<uint64_t>;
using i8_t = PoolVariable<int8_t>;
using i16_t = PoolVariable<int16_t>;
using i32_t = PoolVariable<int32_t>;
using i64_t = PoolVariable<int64_t>;
using f32_t = PoolVariable<float>;
using f64_t = PoolVariable<double>;
} // namespace datapool

View File

@ -0,0 +1 @@
#pragma once

View File

@ -4,7 +4,8 @@
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/serviceinterface.h"
localpool::SharedPool::SharedPool(object_id_t ownerId) : ownerId(ownerId) {
using namespace dp;
SharedPool::SharedPool(object_id_t ownerId) : ownerId(ownerId) {
mutex = MutexFactory::instance()->createMutex();
if (mutex == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -15,20 +16,20 @@ localpool::SharedPool::SharedPool(object_id_t ownerId) : ownerId(ownerId) {
}
}
localpool::SharedPool::~SharedPool() { MutexFactory::instance()->deleteMutex(mutex); }
SharedPool::~SharedPool() { MutexFactory::instance()->deleteMutex(mutex); }
object_id_t localpool::SharedPool::getOwnerId() const { return ownerId; }
object_id_t SharedPool::getOwnerId() const { return ownerId; }
void localpool::SharedPool::addPoolEntry(lp_id_t poolId, PoolEntryIF* entry) {
void SharedPool::addPoolEntry(lp_id_t poolId, PoolEntryIF* entry) {
localPoolMap.emplace(poolId, entry);
}
MutexIF* localpool::SharedPool::getLocalPoolMutex() { return mutex; }
MutexIF* SharedPool::getPoolMutex() { return mutex; }
ReturnValue_t localpool::SharedPool::printPoolEntry(lp_id_t localPoolId) {
ReturnValue_t SharedPool::printPoolEntry(lp_id_t localPoolId) {
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
return localpool::POOL_ENTRY_NOT_FOUND;
return POOL_ENTRY_NOT_FOUND;
}
poolIter->second->print();
return returnvalue::OK;

View File

@ -1,11 +1,10 @@
#pragma once
#include "AccessLocalPoolF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/datapool/definitions.h"
#include "fsfw/ipc/MutexIF.h"
#include "localPoolDefinitions.h"
namespace localpool {
namespace datapool {
class SharedPool {
public:
@ -29,7 +28,7 @@ class SharedPool {
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();
MutexIF* getPoolMutex();
private:
object_id_t ownerId;
@ -42,22 +41,22 @@ class SharedPool {
};
template <class T>
inline ReturnValue_t localpool::SharedPool::fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T>** poolEntry) {
inline ReturnValue_t datapool::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;
return POOL_ENTRY_NOT_FOUND;
}
*poolEntry = dynamic_cast<PoolEntry<T>*>(poolIter->second);
if (*poolEntry == nullptr) {
return localpool::POOL_ENTRY_TYPE_CONFLICT;
return POOL_ENTRY_TYPE_CONFLICT;
}
return returnvalue::OK;
}
} // namespace localpool
} // namespace datapool

View File

@ -0,0 +1,16 @@
#include "SharedSet.h"
using namespace dp;
SharedSet::SharedSet(dp::SharedPool& sharedPool, uint32_t setId, const size_t maxNumberOfVariables)
: SharedSetBase(sharedPool, setId, nullptr, maxNumberOfVariables),
poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());
}
SharedSet::SharedSet(dp::structure_id_t sid, const size_t maxNumberOfVariables)
: SharedSetBase(sid, nullptr, maxNumberOfVariables), poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());
}
SharedSet::~SharedSet() = default;

View File

@ -1,10 +1,11 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALDATASET_H_
#define FSFW_DATAPOOLLOCAL_LOCALDATASET_H_
#pragma once
#include <vector>
#include "SharedDatasetBase.h"
#include "SharedPool.h"
#include "SharedSetBase.h"
namespace datapool {
/**
* @brief This dataset type can be used to group related pool variables if the number of
* variables should not be fixed.
@ -18,20 +19,20 @@
* @tparam capacity Capacity of the static dataset, which is usually known
* beforehand.
*/
class SharedDataSet : public SharedDatasetBase {
class SharedSet : public SharedSetBase {
public:
SharedDataSet(localpool::SharedPool& sharedPool, uint32_t setId, size_t maxSize);
SharedSet(SharedPool& sharedPool, uint32_t setId, size_t maxSize);
SharedDataSet(sid_t sid, size_t maxSize);
SharedSet(sid_t sid, size_t maxSize);
~SharedDataSet() override;
~SharedSet() override;
//! Copying forbidden for now.
SharedDataSet(const SharedDataSet&) = delete;
SharedDataSet& operator=(const SharedDataSet&) = delete;
SharedSet(const SharedSet&) = delete;
SharedSet& operator=(const SharedSet&) = delete;
private:
std::vector<PoolVariableIF*> poolVarList;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALDATASET_H_ */
} // namespace datapool

View File

@ -1,44 +1,48 @@
#include "SharedSetBase.h"
#include <fsfw/housekeeping/GeneratesPeriodicHkIF.h>
#include <cmath>
#include "fsfw/datapoollocal.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/datapool.h"
#include "fsfw/globalfunctions/bitutility.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
SharedDatasetBase::SharedDatasetBase(localpool::SharedPool &sharedPool, uint32_t setId,
PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables)
using namespace datapool;
SharedSetBase::SharedSetBase(SharedPool &sharedPool, uint32_t setId,
PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables)
: base(registeredVariablesArray, maxNumberOfVariables), sharedPool(&sharedPool) {
mutexIfSingleDataCreator = sharedPool.getLocalPoolMutex();
mutexIfSingleDataCreator = sharedPool.getPoolMutex();
this->sid.objectId = sharedPool.getOwnerId();
this->sid.ownerSetId = setId;
}
SharedDatasetBase::SharedDatasetBase(sid_t sid, PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables)
SharedSetBase::SharedSetBase(structure_id_t sid, PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables)
: base(registeredVariablesArray, maxNumberOfVariables) {
auto *hkOwner = ObjectManager::instance()->get<PeriodicHkGenerationIF>(sid.objectId);
auto *hkOwner = ObjectManager::instance()->get<hk::GeneratesPeriodicHkIF>(sid.objectId);
if (hkOwner != nullptr) {
sharedPool = hkOwner->getOptionalSharedPool();
if (sharedPool != nullptr) {
mutexIfSingleDataCreator = sharedPool->getLocalPoolMutex();
mutexIfSingleDataCreator = sharedPool->getPoolMutex();
}
}
this->sid = sid;
}
SharedDatasetBase::SharedDatasetBase(PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables,
bool protectEveryReadCommitCall)
SharedSetBase::SharedSetBase(PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables, bool protectEveryReadCommitCall)
: base(registeredVariablesArray, maxNumberOfVariables) {
base.setReadCommitProtectionBehaviour(protectEveryReadCommitCall);
}
SharedDatasetBase::~SharedDatasetBase() {
SharedSetBase::~SharedSetBase() {
// In case set was read but not comitted, we commit all variables with an invalid state
if (base.state == PoolDataSetBase::States::STATE_SET_WAS_READ) {
for (uint16_t count = 0; count < base.getFillCount(); count++) {
@ -49,27 +53,25 @@ SharedDatasetBase::~SharedDatasetBase() {
}
}
ReturnValue_t SharedDatasetBase::lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
ReturnValue_t SharedSetBase::lockDataPool(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
if (mutexIfSingleDataCreator != nullptr) {
return mutexIfSingleDataCreator->lockMutex(timeoutType, timeoutMs);
}
return returnvalue::OK;
}
ReturnValue_t SharedDatasetBase::unlockDataPool() {
ReturnValue_t SharedSetBase::unlockDataPool() {
if (mutexIfSingleDataCreator != nullptr) {
return mutexIfSingleDataCreator->unlockMutex();
}
return returnvalue::OK;
}
ReturnValue_t SharedDatasetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *size,
size_t maxSize,
SerializeIF::Endianness streamEndianness,
bool serializeFillCount) const {
ReturnValue_t SharedSetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness,
bool serializeFillCount) const {
/* Serialize fill count as uint8_t */
uint8_t fillCount = this->getFillCount();
auto fillCount = this->getFillCount();
if (serializeFillCount) {
SerializeAdapter::serialize(&fillCount, buffer, size, maxSize, streamEndianness);
}
@ -92,68 +94,68 @@ ReturnValue_t SharedDatasetBase::serializeLocalPoolIds(uint8_t **buffer, size_t
return returnvalue::OK;
}
uint8_t SharedDatasetBase::getLocalPoolIdsSerializedSize(bool serializeFillCount) const {
size_t SharedSetBase::getLocalPoolIdsSerializedSize(bool serializeFillCount) const {
if (serializeFillCount) {
return base.getFillCount() * sizeof(lp_id_t) + sizeof(uint8_t);
return base.getFillCount() * sizeof(lp_id_t) + sizeof(u8_t);
} else {
return base.getFillCount() * sizeof(lp_id_t);
}
}
size_t SharedDatasetBase::getSerializedSize() const { return base.getSerializedSize(); }
size_t SharedSetBase::getSerializedSize() const { return base.getSerializedSize(); }
ReturnValue_t SharedDatasetBase::deSerialize(const uint8_t **buffer, size_t *size,
SerializeIF::Endianness streamEndianness) {
ReturnValue_t SharedSetBase::deSerialize(const uint8_t **buffer, size_t *size,
SerializeIF::Endianness streamEndianness) {
return base.deSerialize(buffer, size, streamEndianness);
}
ReturnValue_t SharedDatasetBase::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
ReturnValue_t SharedSetBase::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
return base.serialize(buffer, size, maxSize, streamEndianness);
}
[[nodiscard]] ReturnValue_t SharedDatasetBase::serialize(
[[nodiscard]] ReturnValue_t SharedSetBase::serialize(
uint8_t *buffer, size_t &serLen, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
return SerializeIF::serialize(buffer, serLen, maxSize, streamEndianness);
}
void SharedDatasetBase::setReportingEnabled(bool reportingEnabled) {
void SharedSetBase::setReportingEnabled(bool reportingEnabled) {
this->reportingEnabled = reportingEnabled;
}
bool SharedDatasetBase::getReportingEnabled() const { return reportingEnabled; }
bool SharedSetBase::getReportingEnabled() const { return reportingEnabled; }
sid_t SharedDatasetBase::getSid() const { return sid; }
structure_id_t SharedSetBase::getSid() const { return sid; }
object_id_t SharedDatasetBase::getCreatorObjectId() {
object_id_t SharedSetBase::getCreatorObjectId() {
if (sharedPool != nullptr) {
return sharedPool->getOwnerId();
}
return objects::NO_OBJECT;
}
void SharedDatasetBase::setAllVariablesReadOnly() {
void SharedSetBase::setAllVariablesReadOnly() {
for (size_t idx = 0; idx < this->getFillCount(); idx++) {
base.registeredVariables[idx]->setReadWriteMode(pool_rwm_t::VAR_READ);
}
}
void SharedDatasetBase::printSet() { return; }
void SharedSetBase::printSet() { return; }
ReturnValue_t SharedDatasetBase::read(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
ReturnValue_t SharedSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
return base.read(timeoutType, timeoutMs);
}
ReturnValue_t SharedDatasetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
ReturnValue_t SharedSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
return base.commit(timeoutType, timeoutMs);
}
uint16_t SharedDatasetBase::getFillCount() const { return base.getFillCount(); }
uint16_t SharedSetBase::getFillCount() const { return base.getFillCount(); }
ReturnValue_t SharedDatasetBase::registerVariable(PoolVariableIF *variable) {
ReturnValue_t SharedSetBase::registerVariable(PoolVariableIF *variable) {
return base.registerVariable(variable);
}
void SharedDatasetBase::setContainer(PoolVariableIF **variablesContainer) {
void SharedSetBase::setContainer(PoolVariableIF **variablesContainer) {
return base.setContainer(variablesContainer);
}
PoolVariableIF **SharedDatasetBase::getContainer() const { return base.getContainer(); }
PoolVariableIF **SharedSetBase::getContainer() const { return base.getContainer(); }

View File

@ -1,18 +1,16 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_
#pragma once
#include <vector>
#include "MarkChangedIF.h"
#include "SharedPool.h"
#include "definitions.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolDataSetBase.h"
#include "fsfw/datapoollocal/SharedPool.h"
#include "localPoolDefinitions.h"
class PeriodicHkGenerationHelper;
class PeriodicHkGenerationIF;
class PeriodicHousekeepingHelper;
namespace datapool {
/**
* @brief The LocalDataSet class manages a set of locally checked out
* variables for local data pools
@ -41,8 +39,8 @@ class PeriodicHousekeepingHelper;
*
* @ingroup data_pool
*/
class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
friend class PeriodicHousekeepingHelper;
class SharedSetBase : public SerializeIF, public PoolDataSetIF {
// friend class PeriodicHousekeepingHelper;
public:
/**
@ -51,8 +49,8 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
* This constructor also initializes the components required for
* periodic handling.
*/
SharedDatasetBase(localpool::SharedPool& sharedPool, uint32_t setId,
PoolVariableIF** registeredVariablesArray, size_t maxNumberOfVariables);
SharedSetBase(SharedPool& sharedPool, uint32_t setId, PoolVariableIF** registeredVariablesArray,
size_t maxNumberOfVariables);
/**
* @brief Constructor for users of the local pool data, which need
@ -65,8 +63,7 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
* @param registeredVariablesArray
* @param maxNumberOfVariables
*/
SharedDatasetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
size_t maxNumberOfVariables);
SharedSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, size_t maxNumberOfVariables);
/**
* @brief Simple constructor, if the dataset is not the owner by
@ -86,8 +83,8 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
* multiple creators, this flag can be set to protect all read and
* commit calls separately.
*/
SharedDatasetBase(PoolVariableIF** registeredVariablesArray, size_t maxNumberOfVariables,
bool protectEveryReadCommitCall = true);
SharedSetBase(PoolVariableIF** registeredVariablesArray, size_t maxNumberOfVariables,
bool protectEveryReadCommitCall = true);
/**
* @brief The destructor automatically manages writing the valid
@ -97,13 +94,13 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
* the destructor parses all variables that are still registered to the set.
* For each, the valid flag in the data pool is set to "invalid".
*/
~SharedDatasetBase() override;
~SharedSetBase() override;
/* The copy constructor and assingment constructor are forbidden for now.
The use-cases are limited and the first step would be to implement them properly for the
base class */
SharedDatasetBase(const SharedDatasetBase& otherSet) = delete;
const SharedDatasetBase& operator=(const SharedDatasetBase& otherSet) = delete;
SharedSetBase(const SharedSetBase& otherSet) = delete;
const SharedSetBase& operator=(const SharedSetBase& otherSet) = delete;
/**
* Helper functions used to set all currently contained variables to read-only.
@ -121,14 +118,14 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
[[nodiscard]] sid_t getSid() const;
[[nodiscard]] dp::sid_t getSid() const;
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness,
bool serializeFillCount = true) const;
[[nodiscard]] uint8_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const;
[[nodiscard]] size_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const;
object_id_t getCreatorObjectId();
@ -141,7 +138,7 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
* returns 0.0
* @return
*/
float getCollectionInterval() const;
[[nodiscard]] float getCollectionInterval() const;
/**
* @brief Can be overwritten by a specific implementation of a dataset to print the set.
@ -160,8 +157,8 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
PoolVariableIF** getContainer() const;
protected:
// I am tired of inheritance trees. This is the better solution, even if it means a bit more code.
PoolDataSetBase base;
sid_t sid;
//! This mutex is used if the data is created by one object only.
MutexIF* mutexIfSingleDataCreator = nullptr;
@ -195,7 +192,7 @@ class SharedDatasetBase : public SerializeIF, public PoolDataSetIF {
*/
ReturnValue_t unlockDataPool() override;
localpool::SharedPool* sharedPool = nullptr;
dp::SharedPool* sharedPool = nullptr;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ */
} // namespace datapool

View File

@ -2,11 +2,9 @@
#include <array>
#include "../objectmanager/SystemObjectIF.h"
#include "LocalPoolVariable.h"
#include "LocalPoolVector.h"
#include "SharedDatasetBase.h"
#include "SharedSetBase.h"
namespace datapool {
/**
* @brief This dataset type can be used to group related pool variables if the number of
* variables is fixed.
@ -20,8 +18,8 @@
* @tparam NUM_VARIABLES Capacity of the static dataset, which is usually known
* beforehand.
*/
template <uint8_t NUM_VARIABLES>
class StaticSharedDataset : public SharedDatasetBase {
template <size_t NUM_VARIABLES>
class StaticSharedSet : public datapool::SharedSetBase {
public:
/**
* Constructor used by data owner and creator like device handlers.
@ -30,8 +28,8 @@ class StaticSharedDataset : public SharedDatasetBase {
* @param sharedPool Shared pool this dataset will read from or write to.
* @param setId
*/
StaticSharedDataset(localpool::SharedPool& sharedPool, uint32_t setId)
: SharedDatasetBase(sharedPool, setId, nullptr, NUM_VARIABLES) {
StaticSharedSet(SharedPool& sharedPool, const uint32_t setId)
: SharedSetBase(sharedPool, setId, nullptr, NUM_VARIABLES) {
this->setContainer(poolVarList.data());
}
@ -39,10 +37,12 @@ class StaticSharedDataset : public SharedDatasetBase {
* Constructor used by data users like controllers.
* @param sid
*/
explicit StaticSharedDataset(sid_t sid) : SharedDatasetBase(sid, nullptr, NUM_VARIABLES) {
explicit StaticSharedSet(const structure_id_t sid) : SharedSetBase(sid, nullptr, NUM_VARIABLES) {
this->setContainer(poolVarList.data());
}
private:
std::array<PoolVariableIF*, NUM_VARIABLES> poolVarList = {};
};
};
} // namespace datapool

View File

@ -1,5 +1,4 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDEFINITIONS_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLDEFINITIONS_H_
#pragma once
#include <cstdint>
#include <map>
@ -8,12 +7,13 @@
#include "../objectmanager/SystemObjectIF.h"
#include "../objectmanager/frameworkObjects.h"
namespace datapool {
/**
* @brief Type definition for local pool entries.
*/
using lp_id_t = uint32_t;
namespace localpool {
static constexpr uint32_t INVALID_LPID = -1;
static constexpr uint8_t INTERFACE_ID = CLASS_ID::LOCAL_POOL_OWNER_IF;
@ -25,19 +25,17 @@ static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01)
pool variables, using the std::map interface. */
using DataPool = std::map<lp_id_t, PoolEntryIF*>;
} // namespace localpool
/**
* Used as a unique identifier for data sets. Consists of 4 byte object ID and 4 byte set ID.
*/
union sid_t {
union structure_id_t {
static constexpr uint64_t INVALID_SID = -1;
static constexpr uint32_t INVALID_OBJECT_ID = objects::NO_OBJECT;
static constexpr uint32_t INVALID_SET_ID = -1;
sid_t() : raw(INVALID_SID) {}
structure_id_t() : raw(INVALID_SID) {}
sid_t(object_id_t objectId, uint32_t setId) : objectId(objectId), ownerSetId(setId) {}
structure_id_t(object_id_t objectId, uint32_t setId) : objectId(objectId), ownerSetId(setId) {}
struct {
object_id_t objectId;
@ -55,23 +53,24 @@ union sid_t {
bool notSet() const { return raw == INVALID_SID; }
bool operator==(const sid_t& other) const { return raw == other.raw; }
bool operator==(const structure_id_t& other) const { return raw == other.raw; }
bool operator!=(const sid_t& other) const { return not(raw == other.raw); }
bool operator!=(const structure_id_t& other) const { return not(raw == other.raw); }
};
using sid_t = structure_id_t;
/**
* Used as a global unique identifier for local pool variables. Consists of 4 byte object ID
* and 4 byte local pool ID.
*/
union gp_id_t {
union g_id_t {
static constexpr uint64_t INVALID_GPID = -1;
static constexpr uint32_t INVALID_OBJECT_ID = objects::NO_OBJECT;
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;
gp_id_t() : raw(INVALID_GPID) {}
g_id_t() : raw(INVALID_GPID) {}
gp_id_t(object_id_t objectId, lp_id_t localPoolId)
g_id_t(object_id_t objectId, lp_id_t localPoolId)
: objectId(objectId), localPoolId(localPoolId) {}
struct {
@ -83,9 +82,11 @@ union gp_id_t {
bool notSet() const { return raw == INVALID_GPID; }
bool operator==(const gp_id_t& other) const { return raw == other.raw; }
bool operator==(const g_id_t& other) const { return raw == other.raw; }
bool operator!=(const gp_id_t& other) const { return not(raw == other.raw); }
bool operator!=(const g_id_t& other) const { return not(raw == other.raw); }
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDEFINITIONS_H_ */
} // namespace datapool
namespace dp = datapool;

View File

@ -0,0 +1 @@
target_sources(${LIB_FSFW_NAME} PRIVATE)

View File

@ -1,6 +1,6 @@
#pragma once
#include "fsfw/datapoollocal/SharedDatasetBase.h"
#include "fsfw/datapool/SharedSetBase.h"
class LocalPoolDataSetAttorney {
static void setReportingEnabled(SharedDatasetBase& set, bool enabled) {

View File

@ -1,9 +1,8 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_
#define FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_
#pragma once
#include "../PeriodicHkGenerationHelper.h"
#include "fsfw/datapoollocal/SharedPool.h"
#include "fsfw/datapool/SharedPool.h"
namespace datapool {
/**
* @brief This is a helper class implements the Attorney-Client idiom for access to
* LocalDataPoolManager internals
@ -14,17 +13,15 @@
* an explicit subset of the pool manager private/protected functions.
* See: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Friendship_and_the_Attorney-Client
*/
class LocalDpManagerAttorney {
class SharedPoolAttorney {
private:
template <typename T>
static ReturnValue_t fetchPoolEntry(localpool::SharedPool& manager, lp_id_t localPoolId,
static ReturnValue_t fetchPoolEntry(SharedPool& manager, lp_id_t localPoolId,
PoolEntry<T>** poolEntry) {
return manager.fetchPoolEntry(localPoolId, poolEntry);
}
static MutexIF* getMutexHandle(localpool::SharedPool& manager) {
return manager.getLocalPoolMutex();
}
static MutexIF* getMutexHandle(SharedPool& manager) { return manager.getPoolMutex(); }
template <typename T>
friend class LocalPoolVariable;
@ -32,4 +29,4 @@ class LocalDpManagerAttorney {
friend class LocalPoolVector;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_ */
} // namespace datapool

View File

@ -1,11 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
#define FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_
/* Collected related headers */
#include "fsfw/datapoollocal/LocalDataSet.h"
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapoollocal/LocalPoolVector.h"
#include "fsfw/datapoollocal/SharedLocalDataset.h"
#include "fsfw/datapoollocal/SharedPool.h"
#endif /* FSFW_DATAPOOLLOCAL_DATAPOOLLOCAL_H_ */

View File

@ -1,6 +0,0 @@
target_sources(
${LIB_FSFW_NAME}
PRIVATE PeriodicHkGenerationHelper.cpp LocalDataSet.cpp SharedDatasetBase.cpp
LocalPoolObjectBase.cpp SharedLocalDataset.cpp)
add_subdirectory(internal)

View File

@ -1,15 +0,0 @@
#include "fsfw/datapoollocal/LocalDataSet.h"
SharedDataSet::SharedDataSet(localpool::SharedPool& sharedPool, uint32_t setId,
const size_t maxNumberOfVariables)
: SharedDatasetBase(sharedPool, setId, nullptr, maxNumberOfVariables),
poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());
}
SharedDataSet::SharedDataSet(sid_t sid, const size_t maxNumberOfVariables)
: SharedDatasetBase(sid, nullptr, maxNumberOfVariables), poolVarList(maxNumberOfVariables) {
this->setContainer(poolVarList.data());
}
SharedDataSet::~SharedDataSet() {}

View File

@ -1,185 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#include "../datapool/DataSetIF.h"
#include "../datapool/PoolVariableIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "../serialize/SerializeAdapter.h"
#include "../serviceinterface/ServiceInterface.h"
#include "AccessLocalPoolF.h"
#include "LocalPoolObjectBase.h"
#include "PeriodicHkGenerationHelper.h"
#include "PeriodicHkGenerationIF.h"
#include "internal/LocalDpManagerAttorney.h"
/**
* @brief Local Pool Variable class which is used to access the local pools.
* @details
* This class is not stored in the map. Instead, it is used to access
* the pool entries by using a pointer to the map storing the pool
* entries. It can also be used to organize these pool entries into data sets.
*
* @tparam T The template parameter sets the type of the variable. Currently,
* all plain data types are supported, but in principle any type is possible.
* @ingroup data_pool
*/
template <typename T>
class LocalPoolVariable : public LocalPoolObjectBase {
public:
//! Default ctor is forbidden.
LocalPoolVariable() = delete;
/**
* This constructor is used by the data creators to have pool variable
* instances which can also be stored in datasets.
*
* It does not fetch the current value from the data pool, which
* has to be done by calling the read() operation.
* Datasets can be used to access multiple local pool entries in an
* efficient way. A pointer to a dataset can be passed to register
* the pool variable in that dataset directly.
* @param poolId ID of the local pool entry.
* @param hkOwner Pointer of the owner. This will generally be the calling
* class itself which passes "this".
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*/
LocalPoolVariable(localpool::SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* This constructor is used by data users like controllers to have
* access to the local pool variables of data creators by supplying
* the respective creator object ID.
*
* It does not fetch the current value from the data pool, which
* has to be done by calling the read() operation.
* Datasets can be used to access multiple local pool entries in an
* efficient way. A pointer to a dataset can be passed to register
* the pool variable in that dataset directly.
* @param poolId ID of the local pool entry.
* @param hkOwner object ID of the pool owner.
* @param dataSet The data set in which the variable shall register itself.
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*
*/
LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* Variation which takes the global unique identifier of a pool variable.
* @param globalPoolId
* @param dataSet
* @param setReadWriteMode
*/
LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
virtual ~LocalPoolVariable() {};
/**
* @brief This is the local copy of the data pool entry.
* @details The user can work on this attribute
* just like he would on a simple local variable.
*/
T value = 0;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override;
/**
* @brief This is a call to read the array's values
* from the global data pool.
* @details
* When executed, this operation tries to fetch the pool entry with matching
* data pool id from the data pool and copies all array values and the valid
* information to its local attributes.
* In case of a failure (wrong type, size or pool id not found), the
* variable is set to zero and invalid.
* The read call is protected with a lock.
* It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations.
*
*/
ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief The commit call copies the array values back to the data pool.
* @details
* It checks type and size, as well as if the variable is writable. If so,
* the value is copied and the local valid flag is written back as well.
* The read call is protected with a lock.
* It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations.
*/
ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
LocalPoolVariable<T>& operator=(const T& newValue);
LocalPoolVariable<T>& operator=(const LocalPoolVariable<T>& newPoolVariable);
//! Explicit type conversion operator. Allows casting the class to
//! its template type to perform operations on value.
explicit operator T() const;
bool operator==(const LocalPoolVariable<T>& other) const;
bool operator==(const T& other) const;
bool operator!=(const LocalPoolVariable<T>& other) const;
bool operator!=(const T& other) const;
bool operator<(const LocalPoolVariable<T>& other) const;
bool operator<(const T& other) const;
bool operator>(const LocalPoolVariable<T>& other) const;
bool operator>(const T& other) const;
protected:
/**
* @brief Like #read, but without a lock protection of the global pool.
* @details
* The operation does NOT provide any mutual exclusive protection by itself.
* This can be used if the lock is handled externally to avoid the overhead
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t readWithoutLock() override;
/**
* @brief Like #commit, but without a lock protection of the global pool.
* @details
* The operation does NOT provide any mutual exclusive protection by itself.
* This can be used if the lock is handled externally to avoid the overhead
* of consecutive lock und unlock operations.
* Declared protected to discourage free public usage.
*/
ReturnValue_t commitWithoutLock() override;
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout
template <typename U>
friend std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<U>& var);
#endif
};
#include "LocalPoolVariable.tpp"
template <class T>
using lp_var_t = LocalPoolVariable<T>;
using lp_bool_t = LocalPoolVariable<uint8_t>;
using lp_uint8_t = LocalPoolVariable<uint8_t>;
using lp_uint16_t = LocalPoolVariable<uint16_t>;
using lp_uint32_t = LocalPoolVariable<uint32_t>;
using lp_uint64_t = LocalPoolVariable<uint64_t>;
using lp_int8_t = LocalPoolVariable<int8_t>;
using lp_int16_t = LocalPoolVariable<int16_t>;
using lp_int32_t = LocalPoolVariable<int32_t>;
using lp_int64_t = LocalPoolVariable<int64_t>;
using lp_float_t = LocalPoolVariable<float>;
using lp_double_t = LocalPoolVariable<double>;
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */

View File

@ -1,177 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#error Include LocalPoolVariable.h before LocalPoolVariable.tpp!
#endif
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(localpool::SharedPool& sharedPool, lp_id_t poolId,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {}
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template <typename T>
inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
setReadWriteMode) {}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if (sharedPool == nullptr) {
return readWithoutLock();
}
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*sharedPool);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
}
result = readWithoutLock();
mutex->unlockMutex();
return result;
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if (sharedPool == nullptr) {
return PoolVariableIF::INVALID_SHARED_POOL;
}
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
return result;
}
this->value = *(poolEntry->getDataPtr());
return returnvalue::OK;
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if (sharedPool == nullptr) {
return commitWithoutLock();
}
MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*sharedPool);
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != returnvalue::OK) {
return result;
}
result = commitWithoutLock();
mutex->unlockMutex();
return result;
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if (readWriteMode == pool_rwm_t::VAR_READ) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
return result;
}
*(poolEntry->getDataPtr()) = this->value;
return returnvalue::OK;
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::serialize(
uint8_t** buffer, size_t* size, const size_t max_size,
SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value, buffer, size, max_size, streamEndianness);
}
template <typename T>
inline size_t LocalPoolVariable<T>::getSerializedSize() const {
return SerializeAdapter::getSerializedSize(&value);
}
template <typename T>
inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
template <typename T>
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVariable<T>& var) {
out << var.value;
return out;
}
#endif
template <typename T>
inline LocalPoolVariable<T>::operator T() const {
return value;
}
template <typename T>
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(const T& newValue) {
value = newValue;
return *this;
}
template <typename T>
inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator=(
const LocalPoolVariable<T>& newPoolVariable) {
value = newPoolVariable.value;
return *this;
}
template <typename T>
inline bool LocalPoolVariable<T>::operator==(const LocalPoolVariable<T>& other) const {
return this->value == other.value;
}
template <typename T>
inline bool LocalPoolVariable<T>::operator==(const T& other) const {
return this->value == other;
}
template <typename T>
inline bool LocalPoolVariable<T>::operator!=(const LocalPoolVariable<T>& other) const {
return not(*this == other);
}
template <typename T>
inline bool LocalPoolVariable<T>::operator!=(const T& other) const {
return not(*this == other);
}
template <typename T>
inline bool LocalPoolVariable<T>::operator<(const LocalPoolVariable<T>& other) const {
return this->value < other.value;
}
template <typename T>
inline bool LocalPoolVariable<T>::operator<(const T& other) const {
return this->value < other;
}
template <typename T>
inline bool LocalPoolVariable<T>::operator>(const LocalPoolVariable<T>& other) const {
return not(*this < other);
}
template <typename T>
inline bool LocalPoolVariable<T>::operator>(const T& other) const {
return not(*this < other);
}
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */

View File

@ -1,165 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
#endif
template <typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(localpool::SharedPool& sharedPool,
lp_id_t poolId, DataSetIF* dataSet,
pool_rwm_t 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,
DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template <typename T, uint16_t vectorSize>
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode)
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
setReadWriteMode) {}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
uint32_t 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) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
memset(this->value, 0, vectorSize * sizeof(T));
if (result != returnvalue::OK) {
return result;
}
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
return returnvalue::OK;
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
// this->setValid(valid);
return commit(timeoutType, timeoutMs);
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
uint32_t 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) {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result =
LocalDpManagerAttorney::fetchPoolEntry(*sharedPool, localPoolId, &poolEntry);
if (result != returnvalue::OK) {
return result;
}
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
return returnvalue::OK;
}
template <typename T, uint16_t vectorSize>
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) {
if (i < vectorSize) {
return value[i];
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!"
<< std::endl;
#else
sif::printWarning(
"LocalPoolVector: Invalid index. Setting or returning"
" last value!\n");
#endif
return value[vectorSize - 1];
}
template <typename T, uint16_t vectorSize>
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const {
if (i < vectorSize) {
return value[i];
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!"
<< std::endl;
#else
sif::printWarning(
"LocalPoolVector: Invalid index. Setting or returning"
" last value!\n");
#endif
return value[vectorSize - 1];
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = returnvalue::FAILED;
for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
break;
}
}
return result;
}
template <typename T, uint16_t vectorSize>
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
return vectorSize * SerializeAdapter::getSerializedSize(value);
}
template <typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) {
ReturnValue_t result = returnvalue::FAILED;
for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness);
if (result != returnvalue::OK) {
break;
}
}
return result;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
template <typename T, uint16_t vectorSize>
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) {
out << "Vector: [";
for (int i = 0; i < vectorSize; i++) {
out << var.value[i];
if (i < vectorSize - 1) {
out << ", ";
}
}
out << "]";
return out;
}
#endif
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */

View File

@ -1,124 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_
#define FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_
#include <map>
#include "PeriodicHkGenerationHelper.h"
#include "fsfw/datapool/PoolEntryIF.h"
#include "fsfw/housekeeping/HousekeepingMessage.h"
#include "fsfw/ipc/MessageQueueSenderIF.h"
#include "fsfw/serviceinterface.h"
#include "localPoolDefinitions.h"
class AccessPoolManagerIF;
class PeriodicHkGenerationProviderIF;
class LocalPoolDataSetBase;
class LocalPoolObjectBase;
/**
* @brief This interface is implemented by classes which posses a local data pool (not
* the managing class). It defines the relationship between the local data pool owner and the
* LocalDataPoolManager.
* @details
* Any class implementing this interface shall also have a LocalDataPoolManager member class which
* contains the actual pool data structure and exposes the public interface for it.
*
* The local data pool can be accessed using helper classes by using the
* LocalPoolVariable, LocalPoolVector or LocalDataSet classes. Every local pool variable can
* be uniquely identified by a global pool ID (gp_id_t) and every dataset tied
* to a pool manager can be uniqely identified by a global structure ID (sid_t).
*
* All software objects which want to use the local pool of another object shall also use this
* interface, for example to get a handle to the subscription interface. The interface
* can be retrieved using the object manager, provided the target object is a SystemObject.
* For example, the following line of code can be used to retrieve the interface
*
* HasLocalDataPoolIF* poolIF = ObjectManager::instance()->
* get<HasLocalDataPoolIF>(objects::SOME_OBJECT);
* if(poolIF != nullptr) {
* doSomething()
* }
*/
class PeriodicHkGenerationIF {
friend class HasLocalDpIFManagerAttorney;
friend class HasLocalDpIFUserAttorney;
public:
virtual ~PeriodicHkGenerationIF() = default;
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;
[[nodiscard]] virtual object_id_t getObjectId() const = 0;
/** Command queue for housekeeping messages. */
[[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0;
virtual ReturnValue_t serializeHkDataset(sid_t structureId, uint8_t* buf, size_t maxSize) = 0;
virtual ReturnValue_t specifyHkDatasets(std::vector<periodicHk::SetSpecification>& setList) = 0;
virtual localpool::SharedPool* getOptionalSharedPool() = 0;
/**
* These function can be implemented by pool owner, if they are required
* and used by the housekeeping message interface.
* */
virtual ReturnValue_t addDataSet(sid_t sid) { return returnvalue::FAILED; };
virtual ReturnValue_t removeDataSet(sid_t sid) { return returnvalue::FAILED; };
virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) {
return returnvalue::FAILED;
};
/**
* This function can be used by data pool consumers to retrieve a handle
* which allows subscriptions to dataset and variable updates in form of messages.
* The consumers can then read the most recent variable value by calling read with
* an own pool variable or set instance or using the deserialized snapshot data.
* Returns the HK manager casted to the required interface by default.
* @return
*/
// virtual PeriodicHkGenerationProviderIF* getSubscriptionInterface() {
// return getHkManagerHandle();
//}
protected:
/**
* Every class implementing this interface should have a local data pool manager. This
* function will return a reference to the manager.
* @return
*/
// virtual PeriodicHkGenerationHelper* getHkManagerHandle() = 0;
/**
* Accessor handle required for internal handling. Not intended for users and therefore
* declared protected. Users should instead use pool variables, sets or the subscription
* interface to access pool entries. Returns the HK manager casted to a different interface
* by default.
* @return
*/
// virtual AccessPoolManagerIF* getAccessorHandle() { return getHkManagerHandle(); }
/**
* Similar to the function above, but used to get a local pool variable
* handle. This is only needed for update notifications, so it is not
* defined as abstract. This function is protected to prevent users from
* using raw pool variable pointers which could not be thread-safe.
* Users should use the #ProvidesDataPoolSubscriptionIF.
* @param localPoolId
* @return
*/
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. "
"Returning nullptr!"
<< std::endl;
#else
sif::printWarning(
"HasLocalDataPoolIF::getPoolObjectHandle: "
"Not overriden. Returning nullptr!\n");
#endif
return nullptr;
}
};
#endif /* FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ */

View File

@ -1,2 +0,0 @@
target_sources(${LIB_FSFW_NAME} PRIVATE HasLocalDpIFUserAttorney.cpp
HasLocalDpIFManagerAttorney.cpp)

View File

@ -1,19 +0,0 @@
#ifndef FSFW_DATAPOOLLOCAL_HASLOCALDPIFMANAGERATTORNEY_H_
#define FSFW_DATAPOOLLOCAL_HASLOCALDPIFMANAGERATTORNEY_H_
#include "fsfw/datapoollocal/localPoolDefinitions.h"
class PeriodicHkGenerationIF;
class LocalPoolDataSetBase;
class LocalPoolObjectBase;
class HasLocalDpIFManagerAttorney {
static LocalPoolObjectBase* getPoolObjectHandle(PeriodicHkGenerationIF* clientIF,
lp_id_t localPoolId);
static object_id_t getObjectId(PeriodicHkGenerationIF* clientIF);
friend class PeriodicHkGenerationHelper;
};
#endif /* FSFW_DATAPOOLLOCAL_HASLOCALDPIFMANAGERATTORNEY_H_ */

View File

@ -1,4 +0,0 @@
#include "HasLocalDpIFUserAttorney.h"
#include "fsfw/datapoollocal/AccessLocalPoolF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"

View File

@ -1,11 +1,10 @@
#include "DeviceHandlerBase.h"
#include "fsfw/datapool/PoolReadGuard.h"
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapool/PoolVariable.h"
#include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h"
#include "fsfw/devicehandlers/DeviceTmReportingWrapper.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/housekeeping/HousekeepingMessage.h"
#include "fsfw/ipc/MessageQueueMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
@ -413,7 +412,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s
}
ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(
DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, SharedDatasetBase* replyDataSet,
DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, dp::SharedSetBase* replyDataSet,
size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId,
Countdown* countdown) {
// No need to check, as we may try to insert multiple times.
@ -428,7 +427,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(
ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
uint16_t maxDelayCycles,
SharedDatasetBase* dataSet, size_t replyLen,
dp::SharedSetBase* dataSet, size_t replyLen,
bool periodic, Countdown* countdown) {
DeviceReplyInfo info;
info.maxDelayCycles = maxDelayCycles;
@ -529,7 +528,7 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI
}
ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId,
SharedDatasetBase* dataSet) {
dp::SharedSetBase* dataSet) {
auto replyIter = deviceReplyMap.find(replyId);
if (replyIter == deviceReplyMap.end()) {
return returnvalue::FAILED;
@ -1611,4 +1610,4 @@ ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t ac
void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { return; }
PeriodicHkGenerationHelper& DeviceHandlerBase::getHkHelper() { return hkHelper; }
hk::PeriodicHelper& DeviceHandlerBase::getHkHelper() { return hkHelper; }

View File

@ -1,6 +1,8 @@
#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
#include <fsfw/housekeeping/PeriodicHkHelper.h>
#include <map>
#include <optional>
@ -10,9 +12,6 @@
#include "DeviceHandlerThermalSet.h"
#include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.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"
@ -20,7 +19,6 @@
#include "fsfw/parameters/ParameterHelper.h"
#include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
@ -88,7 +86,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
public ModeTreeChildIF,
public ModeTreeConnectionIF,
public ReceivesParameterMessagesIF,
public PeriodicHkGenerationIF {
public hk::GeneratesPeriodicHkIF {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
@ -109,7 +107,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
void setCustomFdir(FailureIsolationBase *fdir);
void setPowerSwitcher(PowerSwitchIF *switcher);
PeriodicHkGenerationHelper &getHkHelper();
hk::PeriodicHelper &getHkHelper();
/**
* extending the modes of DeviceHandler IF for internal state machine
@ -508,7 +506,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* - @c returnvalue::FAILED else.
*/
ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles,
SharedDatasetBase *replyDataSet = nullptr,
dp::SharedSetBase *replyDataSet = nullptr,
size_t replyLen = 0, bool periodic = false,
bool hasDifferentReplyId = false,
DeviceCommandId_t replyId = 0,
@ -529,7 +527,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* - @c returnvalue::FAILED else.
*/
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles,
SharedDatasetBase *dataSet = nullptr, size_t replyLen = 0,
dp::SharedSetBase *dataSet = nullptr, size_t replyLen = 0,
bool periodic = false, Countdown *countdown = nullptr);
/**
@ -582,7 +580,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @details
* Used by the local data pool manager.
*/
ReturnValue_t setReplyDataset(DeviceCommandId_t replyId, SharedDatasetBase *dataset);
ReturnValue_t setReplyDataset(DeviceCommandId_t replyId, dp::SharedSetBase *dataset);
/**
* Get the time needed to transit from modeFrom to modeTo.
@ -790,7 +788,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
/** Cookie used for communication */
CookieIF *comCookie;
localpool::SharedPool sharedPool;
dp::SharedPool sharedPool;
/* Health helper for HasHealthIF */
HealthHelper healthHelper;
@ -801,7 +799,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
/* Action helper for HasActionsIF */
ActionHelper actionHelper;
/* Housekeeping Manager */
PeriodicHkGenerationHelper hkHelper;
hk::PeriodicHelper hkHelper;
/**
* @brief Information about commands
@ -849,7 +847,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
//! The dataset used to access housekeeping data related to the
//! respective device reply. Will point to a dataset held by
//! the child handler (if one is specified)
SharedDatasetBase *dataSet = nullptr;
dp::SharedSetBase *dataSet = nullptr;
//! The command that expects this reply.
DeviceCommandMap::iterator command;
//! Instead of using delayCycles to specify the maximum time to wait for the device reply, it

View File

@ -2,11 +2,11 @@
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_
#include "../action/HasActionsIF.h"
#include "../datapoollocal/localPoolDefinitions.h"
#include "../events/Event.h"
#include "../ipc/MessageQueueSenderIF.h"
#include "../modes/HasModesIF.h"
#include "DeviceHandlerMessage.h"
#include "fsfw/datapool/definitions.h"
/**
* This is used to uniquely identify commands that are sent to a device
@ -120,10 +120,10 @@ class DeviceHandlerIF {
NOTHING //!< Do nothing.
};
static constexpr uint32_t DEFAULT_THERMAL_SET_ID = sid_t::INVALID_SET_ID - 1;
static constexpr uint32_t DEFAULT_THERMAL_SET_ID = dp::sid_t::INVALID_SET_ID - 1;
static constexpr lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = localpool::INVALID_LPID - 2;
static constexpr lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = localpool::INVALID_LPID - 1;
static constexpr dp::lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = dp::INVALID_LPID - 2;
static constexpr dp::lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = dp::INVALID_LPID - 1;
/**
* Default Destructor
@ -138,8 +138,8 @@ class DeviceHandlerIF {
};
struct ThermalStateCfg {
lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID;
lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID;
dp::lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID;
dp::lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID;
uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID;
};

View File

@ -1,29 +1,29 @@
#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_
#include <fsfw/datapoollocal/StaticSharedDataset.h>
#include <fsfw/datapool/StaticSharedSet.h>
#include <fsfw/housekeeping/GeneratesPeriodicHkIF.h>
#include "../datapoollocal/LocalPoolVariable.h"
#include "../datapoollocal/SharedLocalDataset.h"
#include "DeviceHandlerIF.h"
#include "fsfw/datapool/PoolVariable.h"
class DeviceHandlerThermalSet : public StaticSharedDataset<2> {
class DeviceHandlerThermalSet : public dp::StaticSharedSet<2> {
public:
DeviceHandlerThermalSet(PeriodicHkGenerationIF* hkOwner, ThermalStateCfg cfg)
DeviceHandlerThermalSet(hk::GeneratesPeriodicHkIF* hkOwner, ThermalStateCfg cfg)
: DeviceHandlerThermalSet(hkOwner->getObjectId(), cfg) {}
DeviceHandlerThermalSet(object_id_t deviceHandler, ThermalStateCfg cfg)
: StaticSharedDataset(sid_t(deviceHandler, cfg.thermalSetId)),
: StaticSharedSet(dp::structure_id_t(deviceHandler, cfg.thermalSetId)),
thermalStatePoolId(cfg.thermalStatePoolId),
heaterRequestPoolId(cfg.thermalRequestPoolId) {}
const lp_id_t thermalStatePoolId;
const lp_id_t heaterRequestPoolId;
const dp::lp_id_t thermalStatePoolId;
const dp::lp_id_t heaterRequestPoolId;
lp_var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState =
lp_var_t<DeviceHandlerIF::dh_thermal_state_t>(sid.objectId, thermalStatePoolId, this);
lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
lp_var_t<DeviceHandlerIF::dh_heater_request_t>(sid.objectId, heaterRequestPoolId, this);
dp::var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState =
dp::var_t<DeviceHandlerIF::dh_thermal_state_t>(sid.objectId, thermalStatePoolId, this);
dp::var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
dp::var_t<DeviceHandlerIF::dh_heater_request_t>(sid.objectId, heaterRequestPoolId, this);
};
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */

View File

@ -1,12 +1,13 @@
#pragma once
#include <fsfw/housekeeping/PeriodicHkHelper.h>
#include "fsfw/action.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"
#include "fsfw/health/HealthHelper.h"
#include "fsfw/housekeeping/GeneratesPeriodicHkIF.h"
#include "fsfw/modes/HasModesIF.h"
#include "fsfw/objectmanager.h"
#include "fsfw/parameters/ParameterHelper.h"
@ -34,7 +35,7 @@ class FreshDeviceHandlerBase : public SystemObject,
public ModeTreeConnectionIF,
public HasActionsIF,
public ReceivesParameterMessagesIF,
public PeriodicHkGenerationIF {
public hk::GeneratesPeriodicHkIF {
public:
explicit FreshDeviceHandlerBase(DhbConfig config);
~FreshDeviceHandlerBase() override;
@ -61,7 +62,7 @@ class FreshDeviceHandlerBase : public SystemObject,
ModeHelper modeHelper;
HealthHelper healthHelper;
ParameterHelper paramHelper;
PeriodicHkGenerationHelper hkHelper;
hk::PeriodicHelper hkHelper;
bool hasCustomFdir = false;
FailureIsolationBase* fdirInstance;

View File

@ -1 +1,2 @@
target_sources(${LIB_FSFW_NAME} PRIVATE HousekeepingMessage.cpp)
target_sources(${LIB_FSFW_NAME} PRIVATE HousekeepingMessage.cpp
PeriodicHkHelper.cpp)

View File

@ -0,0 +1,64 @@
#pragma once
#include <fsfw/datapool/SharedPool.h>
#include <vector>
#include "definitions.h"
#include "fsfw/datapool/definitions.h"
namespace hk {
/**
* @brief This interface is implemented by classes which posses a local data pool (not
* the managing class). It defines the relationship between the local data pool owner and the
* LocalDataPoolManager.
* @details
* Any class implementing this interface shall also have a LocalDataPoolManager member class which
* contains the actual pool data structure and exposes the public interface for it.
*
* The local data pool can be accessed using helper classes by using the
* LocalPoolVariable, LocalPoolVector or LocalDataSet classes. Every local pool variable can
* be uniquely identified by a global pool ID (gp_id_t) and every dataset tied
* to a pool manager can be uniqely identified by a global structure ID (sid_t).
*
* All software objects which want to use the local pool of another object shall also use this
* interface, for example to get a handle to the subscription interface. The interface
* can be retrieved using the object manager, provided the target object is a SystemObject.
* For example, the following line of code can be used to retrieve the interface
*
* HasLocalDataPoolIF* poolIF = ObjectManager::instance()->
* get<HasLocalDataPoolIF>(objects::SOME_OBJECT);
* if(poolIF != nullptr) {
* doSomething()
* }
*/
class GeneratesPeriodicHkIF {
public:
[[nodiscard]] virtual object_id_t getObjectId() const = 0;
/** Command queue for housekeeping messages. */
[[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0;
virtual datapool::SharedPool* getOptionalSharedPool() = 0;
protected:
virtual ~GeneratesPeriodicHkIF() = default;
static constexpr uint32_t INVALID_LPID = dp::INVALID_LPID;
virtual ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf, size_t maxSize) = 0;
virtual ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setList) = 0;
/**
* These function can be implemented by pool owner, if they are required
* and used by the housekeeping message interface.
* */
virtual ReturnValue_t addDataSet(dp::sid_t sid) { return returnvalue::FAILED; };
virtual ReturnValue_t removeDataSet(dp::sid_t sid) { return returnvalue::FAILED; };
virtual ReturnValue_t changeCollectionInterval(dp::sid_t sid, float newIntervalSeconds) {
return returnvalue::FAILED;
};
};
} // namespace hk

View File

@ -8,7 +8,7 @@
HousekeepingMessage::~HousekeepingMessage() {}
void HousekeepingMessage::setHkReportReply(CommandMessage *message, sid_t sid,
void HousekeepingMessage::setHkReportReply(CommandMessage *message, dp::structure_id_t sid,
store_address_t storeId) {
message->setCommand(HK_REPORT);
message->setMessageSize(HK_MESSAGE_SIZE);
@ -16,15 +16,15 @@ void HousekeepingMessage::setHkReportReply(CommandMessage *message, sid_t sid,
message->setParameter3(storeId.raw);
}
sid_t HousekeepingMessage::getHkDataReply(const CommandMessage *message,
store_address_t *storeIdToSet) {
dp::structure_id_t HousekeepingMessage::getHkDataReply(const CommandMessage *message,
store_address_t *storeIdToSet) {
if (storeIdToSet != nullptr) {
*storeIdToSet = message->getParameter3();
}
return getSid(message);
}
void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message, sid_t sid,
void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message, dp::structure_id_t sid,
bool enableReporting) {
if (enableReporting) {
message->setCommand(ENABLE_PERIODIC_HK_REPORT_GENERATION);
@ -35,20 +35,21 @@ void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message, sid
setSid(message, sid);
}
void HousekeepingMessage::setStructureReportingCommand(CommandMessage *command, sid_t sid) {
void HousekeepingMessage::setStructureReportingCommand(CommandMessage *command,
dp::structure_id_t sid) {
command->setCommand(REPORT_HK_REPORT_STRUCTURES);
setSid(command, sid);
}
void HousekeepingMessage::setOneShotReportCommand(CommandMessage *command, sid_t sid) {
void HousekeepingMessage::setOneShotReportCommand(CommandMessage *command, dp::structure_id_t sid) {
command->setCommand(GENERATE_ONE_PARAMETER_REPORT);
setSid(command, sid);
}
void HousekeepingMessage::setCollectionIntervalModificationCommand(CommandMessage *command,
sid_t sid,
dp::structure_id_t sid,
float collectionInterval) {
command->setCommand(MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL);
@ -60,7 +61,7 @@ void HousekeepingMessage::setCollectionIntervalModificationCommand(CommandMessag
setSid(command, sid);
}
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
dp::structure_id_t HousekeepingMessage::getCollectionIntervalModificationCommand(
const CommandMessage *command, dur_millis_t &newCollectionIntervalMs) {
std::memcpy(&newCollectionIntervalMs, command->getData() + 2 * sizeof(uint32_t),
sizeof(newCollectionIntervalMs));
@ -68,39 +69,39 @@ sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
return getSid(command);
}
void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply, sid_t sid) {
void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply, dp::structure_id_t sid) {
setSid(reply, sid);
reply->setCommand(HK_REQUEST_SUCCESS);
}
void HousekeepingMessage::setHkRequestFailureReply(CommandMessage *reply, sid_t sid,
void HousekeepingMessage::setHkRequestFailureReply(CommandMessage *reply, dp::structure_id_t sid,
ReturnValue_t error) {
setSid(reply, sid);
reply->setCommand(HK_REQUEST_FAILURE);
reply->setParameter3(error);
}
sid_t HousekeepingMessage::getHkRequestFailureReply(const CommandMessage *reply,
ReturnValue_t *error) {
dp::structure_id_t HousekeepingMessage::getHkRequestFailureReply(const CommandMessage *reply,
ReturnValue_t *error) {
if (error != nullptr) {
*error = reply->getParameter3();
}
return getSid(reply);
}
sid_t HousekeepingMessage::getSid(const CommandMessage *message) {
sid_t sid;
dp::structure_id_t HousekeepingMessage::getSid(const CommandMessage *message) {
dp::structure_id_t sid;
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));
return sid;
}
gp_id_t HousekeepingMessage::getGpid(const CommandMessage *message) {
gp_id_t globalPoolId;
dp::g_id_t HousekeepingMessage::getGpid(const CommandMessage *message) {
dp::g_id_t globalPoolId;
std::memcpy(&globalPoolId.raw, message->getData(), sizeof(globalPoolId.raw));
return globalPoolId;
}
void HousekeepingMessage::setHkStuctureReportReply(CommandMessage *reply, sid_t sid,
void HousekeepingMessage::setHkStuctureReportReply(CommandMessage *reply, dp::structure_id_t sid,
store_address_t storeId) {
reply->setCommand(HK_DEFINITIONS_REPORT);
setSid(reply, sid);
@ -123,34 +124,36 @@ void HousekeepingMessage::clear(CommandMessage *message) {
message->setCommand(CommandMessage::CMD_NONE);
}
sid_t HousekeepingMessage::getUpdateNotificationSetCommand(const CommandMessage *command) {
dp::structure_id_t HousekeepingMessage::getUpdateNotificationSetCommand(
const CommandMessage *command) {
return getSid(command);
}
gp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(const CommandMessage *command) {
dp::g_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(
const CommandMessage *command) {
return getGpid(command);
}
sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(const CommandMessage *command,
store_address_t *storeId) {
dp::structure_id_t HousekeepingMessage::getUpdateSnapshotSetCommand(const CommandMessage *command,
store_address_t *storeId) {
if (storeId != nullptr) {
*storeId = command->getParameter3();
}
return getSid(command);
}
gp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(const CommandMessage *command,
store_address_t *storeId) {
dp::g_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(const CommandMessage *command,
store_address_t *storeId) {
if (storeId != nullptr) {
*storeId = command->getParameter3();
}
return getGpid(command);
}
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
void HousekeepingMessage::setSid(CommandMessage *message, dp::structure_id_t sid) {
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
}
void HousekeepingMessage::setGpid(CommandMessage *message, gp_id_t globalPoolId) {
void HousekeepingMessage::setGpid(CommandMessage *message, dp::g_id_t globalPoolId) {
std::memcpy(message->getData(), &globalPoolId.raw, sizeof(globalPoolId.raw));
}

View File

@ -3,7 +3,7 @@
#include <fsfw/timemanager/clockDefinitions.h>
#include "fsfw/datapoollocal/localPoolDefinitions.h"
#include "fsfw/datapool/definitions.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/FwMessageTypes.h"
#include "fsfw/objectmanager/frameworkObjects.h"
@ -18,7 +18,7 @@
class HousekeepingMessage {
public:
static constexpr size_t HK_MESSAGE_SIZE =
CommandMessageIF::HEADER_SIZE + sizeof(sid_t) + sizeof(uint32_t);
CommandMessageIF::HEADER_SIZE + sizeof(dp::structure_id_t) + sizeof(uint32_t);
/**
* Concrete instance is not used, instead this class operates on
@ -54,25 +54,27 @@ class HousekeepingMessage {
// static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(134);
static sid_t getSid(const CommandMessage* message);
static gp_id_t getGpid(const CommandMessage* message);
static dp::sid_t getSid(const CommandMessage* message);
static dp::g_id_t getGpid(const CommandMessage* message);
/* Housekeeping Interface Messages */
static void setToggleReportingCommand(CommandMessage* command, sid_t sid, bool enableReporting);
static void setStructureReportingCommand(CommandMessage* command, sid_t sid);
static void setOneShotReportCommand(CommandMessage* command, sid_t sid);
static void setCollectionIntervalModificationCommand(CommandMessage* command, sid_t sid,
static void setToggleReportingCommand(CommandMessage* command, dp::sid_t sid,
bool enableReporting);
static void setStructureReportingCommand(CommandMessage* command, dp::sid_t sid);
static void setOneShotReportCommand(CommandMessage* command, dp::sid_t sid);
static void setCollectionIntervalModificationCommand(CommandMessage* command, dp::sid_t sid,
float collectionInterval);
static void setHkReportReply(CommandMessage* reply, sid_t sid, store_address_t storeId);
static void setHkReportReply(CommandMessage* reply, dp::sid_t sid, store_address_t storeId);
static void setHkRequestSuccessReply(CommandMessage* reply, sid_t sid);
static void setHkRequestFailureReply(CommandMessage* reply, sid_t sid, ReturnValue_t error);
static void setHkRequestSuccessReply(CommandMessage* reply, dp::sid_t sid);
static void setHkRequestFailureReply(CommandMessage* reply, dp::sid_t sid, ReturnValue_t error);
static void setHkStuctureReportReply(CommandMessage* reply, sid_t sid, store_address_t storeId);
static void setHkStuctureReportReply(CommandMessage* reply, dp::sid_t sid,
store_address_t storeId);
static sid_t getHkRequestFailureReply(const CommandMessage* reply, ReturnValue_t* error);
static dp::sid_t getHkRequestFailureReply(const CommandMessage* reply, ReturnValue_t* error);
/**
* @brief Generic getter function for housekeeping data replies
@ -81,33 +83,35 @@ class HousekeepingMessage {
* regular HK packets. This getter function should be used for the
* command IDs 10, 12, 25 and 26.
*/
static sid_t getHkDataReply(const CommandMessage* message, store_address_t* storeIdToSet);
static sid_t getCollectionIntervalModificationCommand(const CommandMessage* command,
dur_millis_t& newCollectionInterval);
static dp::sid_t getHkDataReply(const CommandMessage* message, store_address_t* storeIdToSet);
static dp::sid_t getCollectionIntervalModificationCommand(const CommandMessage* command,
dur_millis_t& newCollectionInterval);
/* Update Notification Messages */
static void setUpdateNotificationSetCommand(CommandMessage* command, sid_t sid);
static void setUpdateNotificationVariableCommand(CommandMessage* command, gp_id_t globalPoolId);
static void setUpdateNotificationSetCommand(CommandMessage* command, dp::sid_t sid);
static void setUpdateNotificationVariableCommand(CommandMessage* command,
dp::g_id_t globalPoolId);
static void setUpdateSnapshotSetCommand(CommandMessage* command, sid_t sid,
static void setUpdateSnapshotSetCommand(CommandMessage* command, dp::sid_t sid,
store_address_t storeId);
static void setUpdateSnapshotVariableCommand(CommandMessage* command, gp_id_t globalPoolId,
static void setUpdateSnapshotVariableCommand(CommandMessage* command, dp::g_id_t globalPoolId,
store_address_t storeId);
static sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
static gp_id_t getUpdateNotificationVariableCommand(const CommandMessage* command);
static dp::sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
static dp::g_id_t getUpdateNotificationVariableCommand(const CommandMessage* command);
static sid_t getUpdateSnapshotSetCommand(const CommandMessage* command, store_address_t* storeId);
static gp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
store_address_t* storeId);
static dp::sid_t getUpdateSnapshotSetCommand(const CommandMessage* command,
store_address_t* storeId);
static dp::g_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
store_address_t* storeId);
/** Utility */
static void clear(CommandMessage* message);
private:
static void setSid(CommandMessage* message, sid_t sid);
static void setGpid(CommandMessage* message, gp_id_t globalPoolId);
static void setSid(CommandMessage* message, dp::sid_t sid);
static void setGpid(CommandMessage* message, dp::g_id_t globalPoolId);
};
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ */

View File

@ -2,9 +2,8 @@
#include <fsfw/serialize/SerialBufferAdapter.h>
#include "../datapoollocal/SharedDatasetBase.h"
#include "../serialize/SerialLinkedListAdapter.h"
#include "../storagemanager/StorageManagerIF.h"
#include "fsfw/datapool/SharedSetBase.h"
#include "fsfw/serialize/SerialLinkedListAdapter.h"
/**
* @brief This class will be used to serialize general housekeeping packets
@ -19,7 +18,7 @@
*/
class HousekeepingPacketDownlink : public SerialLinkedListAdapter<SerializeIF> {
public:
HousekeepingPacketDownlink(sid_t sid, const uint8_t* hkData, size_t hkDataLen)
HousekeepingPacketDownlink(dp::sid_t sid, const uint8_t* hkData, size_t hkDataLen)
: sourceId(sid.objectId), setId(sid.ownerSetId), hkData(hkData, hkDataLen) {
setLinks();
}

View File

@ -4,7 +4,7 @@
class HousekeepingSetPacket : public SerialLinkedListAdapter<SerializeIF> {
public:
HousekeepingSetPacket(sid_t sid, bool reportingEnabled, dur_millis_t collectionIntervalMs)
HousekeepingSetPacket(dp::sid_t sid, bool reportingEnabled, dur_millis_t collectionIntervalMs)
: objectId(sid.objectId),
setId(sid.ownerSetId),
reportingEnabled(reportingEnabled),

View File

@ -1,11 +1,10 @@
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
#pragma once
#include "../datapoollocal/LocalPoolObjectBase.h"
#include "../serialize/SerialBufferAdapter.h"
#include "../serialize/SerialLinkedListAdapter.h"
#include "../timemanager/CCSDSTime.h"
#include "fsfw/datapoollocal/SharedDatasetBase.h"
#include "fsfw/datapool/LocalPoolObjectBase.h"
#include "fsfw/datapool/SharedSetBase.h"
#include "fsfw/serialize/SerialBufferAdapter.h"
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include "fsfw/timemanager/CCSDSTime.h"
/**
* @brief This helper class will be used to serialize and deserialize update housekeeping packets
@ -86,6 +85,4 @@ class HousekeepingSnapshot : public SerializeIF {
size_t timeStampSize = 0;
SerializeIF* updateData = nullptr;
};
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_ */
};

View File

@ -1,23 +1,19 @@
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "PeriodicHkHelper.h"
#include <cmath>
#include <set>
#include "fsfw/datapoollocal.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/housekeeping/HousekeepingSetPacket.h"
#include "fsfw/housekeeping/HousekeepingSnapshot.h"
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/timemanager/CCSDSTime.h"
#include "internal/HasLocalDpIFManagerAttorney.h"
#include "internal/LocalPoolDataSetAttorney.h"
PeriodicHkGenerationHelper::PeriodicHkGenerationHelper(PeriodicHkGenerationIF* owner,
MessageQueueIF* queueToUse,
MessageQueueId_t hkDestQueue)
using namespace hk;
PeriodicHelper::PeriodicHelper(GeneratesPeriodicHkIF* owner, MessageQueueIF* queueToUse,
MessageQueueId_t hkDestQueue)
: hkDestinationId(hkDestQueue) {
if (owner == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", returnvalue::FAILED,
@ -28,7 +24,7 @@ PeriodicHkGenerationHelper::PeriodicHkGenerationHelper(PeriodicHkGenerationIF* o
hkQueue = queueToUse;
}
ReturnValue_t PeriodicHkGenerationHelper::initialize(MessageQueueIF* queueToUse) {
ReturnValue_t PeriodicHelper::initialize(MessageQueueIF* queueToUse) {
if (queueToUse != nullptr) {
hkQueue = queueToUse;
}
@ -61,13 +57,13 @@ ReturnValue_t PeriodicHkGenerationHelper::initialize(MessageQueueIF* queueToUse)
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::performHkOperation() {
ReturnValue_t PeriodicHelper::performHkOperation() {
timeval now{};
Clock::getClockMonotonic(&now);
for (auto& setSpec : setList) {
switch (setSpec.reportingType) {
case (periodicHk::ReportingType::PERIODIC): {
if (setSpec.dataType == periodicHk::DataType::LOCAL_POOL_VARIABLE) {
case (ReportingType::PERIODIC): {
if (setSpec.dataType == DataType::LOCAL_POOL_VARIABLE) {
// Periodic packets shall only be generated from datasets
continue;
}
@ -82,9 +78,9 @@ ReturnValue_t PeriodicHkGenerationHelper::performHkOperation() {
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::handleHousekeepingMessage(CommandMessage* message) {
ReturnValue_t PeriodicHelper::handleHousekeepingMessage(CommandMessage* message) {
Command_t command = message->getCommand();
sid_t sid = HousekeepingMessage::getSid(message);
dp::sid_t sid = HousekeepingMessage::getSid(message);
ReturnValue_t result = returnvalue::OK;
switch (command) {
// Houskeeping interface handling.
@ -134,10 +130,10 @@ ReturnValue_t PeriodicHkGenerationHelper::handleHousekeepingMessage(CommandMessa
return result;
}
PeriodicHkGenerationIF* PeriodicHkGenerationHelper::getOwner() const { return owner; }
PeriodicHkGenerationIF* PeriodicHelper::getOwner() const { return owner; }
ReturnValue_t PeriodicHkGenerationHelper::generateHousekeepingPacket(const sid_t sid,
MessageQueueId_t destination) {
ReturnValue_t PeriodicHelper::generateHousekeepingPacket(const dp::sid_t sid,
MessageQueueId_t destination) {
store_address_t storeId;
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
@ -185,8 +181,7 @@ ReturnValue_t PeriodicHkGenerationHelper::generateHousekeepingPacket(const sid_t
return hkQueue->sendMessage(destination, &hkMessage);
}
void PeriodicHkGenerationHelper::performPeriodicHkGeneration(periodicHk::SetSpecification& setSpec,
timeval& now) {
void PeriodicHelper::performPeriodicHkGeneration(SetSpecification& setSpec, timeval& now) {
if (not setSpec.periodicCollectionEnabled) {
return;
}
@ -215,7 +210,7 @@ void PeriodicHkGenerationHelper::performPeriodicHkGeneration(periodicHk::SetSpec
}
}
ReturnValue_t PeriodicHkGenerationHelper::togglePeriodicGeneration(sid_t sid, bool enable) {
ReturnValue_t PeriodicHelper::togglePeriodicGeneration(dp::sid_t sid, bool enable) {
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
@ -226,8 +221,8 @@ ReturnValue_t PeriodicHkGenerationHelper::togglePeriodicGeneration(sid_t sid, bo
return returnvalue::OK;
}
std::optional<std::reference_wrapper<periodicHk::SetSpecification>>
PeriodicHkGenerationHelper::getSetSpecification(sid_t structureId) {
std::optional<std::reference_wrapper<SetSpecification>> PeriodicHelper::getSetSpecification(
sid_t structureId) {
for (auto& receiver : setList) {
if (receiver.dataId.sid == structureId) {
return receiver;
@ -236,8 +231,8 @@ PeriodicHkGenerationHelper::getSetSpecification(sid_t structureId) {
return std::nullopt;
}
ReturnValue_t PeriodicHkGenerationHelper::setCollectionInterval(
sid_t sid, dur_millis_t newCollectionIntervalMs) {
ReturnValue_t PeriodicHelper::setCollectionInterval(sid_t sid,
dur_millis_t newCollectionIntervalMs) {
bool wasUpdated = false;
for (auto& receiver : setList) {
if (receiver.dataId.sid == sid) {
@ -252,7 +247,7 @@ ReturnValue_t PeriodicHkGenerationHelper::setCollectionInterval(
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::generateSetStructurePacket(sid_t sid) {
ReturnValue_t PeriodicHelper::generateSetStructurePacket(sid_t sid) {
// Get and check dataset first.
auto optSetSpec = getSetSpecification(sid);
if (!optSetSpec.has_value()) {
@ -302,8 +297,8 @@ ReturnValue_t PeriodicHkGenerationHelper::generateSetStructurePacket(sid_t sid)
return result;
}
ReturnValue_t PeriodicHkGenerationHelper::enablePeriodicPacket(
const sid_t structureId, const std::optional<dur_millis_t> frequencyMs) {
ReturnValue_t PeriodicHelper::enablePeriodicPacket(const sid_t structureId,
const std::optional<dur_millis_t> frequencyMs) {
// Get and check dataset first.
const auto optSetSpec = getSetSpecification(structureId);
if (!optSetSpec.has_value()) {
@ -319,7 +314,7 @@ ReturnValue_t PeriodicHkGenerationHelper::enablePeriodicPacket(
return returnvalue::OK;
}
ReturnValue_t PeriodicHkGenerationHelper::disablePeriodicPacket(const sid_t structureId) {
ReturnValue_t PeriodicHelper::disablePeriodicPacket(const sid_t structureId) {
// Get and check dataset first.
const auto optSetSpec = getSetSpecification(structureId);
if (!optSetSpec.has_value()) {
@ -332,11 +327,10 @@ ReturnValue_t PeriodicHkGenerationHelper::disablePeriodicPacket(const sid_t stru
return returnvalue::OK;
}
object_id_t PeriodicHkGenerationHelper::getCreatorObjectId() const { return owner->getObjectId(); }
object_id_t PeriodicHelper::getCreatorObjectId() const { return owner->getObjectId(); }
void PeriodicHkGenerationHelper::printWarningOrError(sif::OutputTypes outputType,
const char* functionName, ReturnValue_t error,
const char* errorPrint) {
void PeriodicHelper::printWarningOrError(sif::OutputTypes outputType, const char* functionName,
ReturnValue_t error, const char* errorPrint) {
#if FSFW_VERBOSE_LEVEL >= 1
if (errorPrint == nullptr) {
if (error == DATASET_NOT_FOUND) {
@ -388,10 +382,10 @@ void PeriodicHkGenerationHelper::printWarningOrError(sif::OutputTypes outputType
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
}
void PeriodicHkGenerationHelper::setHkDestinationId(const MessageQueueId_t hkDestId) {
void PeriodicHelper::setHkDestinationId(const MessageQueueId_t hkDestId) {
hkDestinationId = hkDestId;
}
void PeriodicHkGenerationHelper::addSetSpecification(const periodicHk::SetSpecification& setSpec) {
void PeriodicHelper::addSetSpecification(const SetSpecification& setSpec) {
setList.push_back(setSpec);
}

View File

@ -1,86 +1,23 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_
#define FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_
#pragma once
#include <map>
#include <optional>
#include <vector>
#include "AccessLocalPoolF.h"
#include "ProvidesDataPoolSubscriptionIF.h"
#include "GeneratesPeriodicHkIF.h"
#include "PeriodicHkHelperIF.h"
#include "definitions.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/datapool/definitions.h"
#include "fsfw/housekeeping/HousekeepingMessage.h"
#include "fsfw/housekeeping/HousekeepingPacketDownlink.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/ipc/MutexIF.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
namespace periodicHk {
/**
* Different types of housekeeping reporting are possible.
* 1. PERIODIC:
* HK packets are generated in fixed intervals and sent to
* destination. Fromat will be raw.
* 2. UPDATE_NOTIFICATION:
* Notification will be sent out if HK data has changed.
* 3. UPDATE_SNAPSHOT:
* HK packets are only generated if explicitely requested.
* Propably not necessary, just use multiple local data sets or
* shared datasets.
*/
enum class ReportingType : uint8_t {
//! Periodic generation of HK packets.
PERIODIC,
};
union DataId {
DataId() : sid() {}
static DataId forSetId(sid_t sid) {
DataId d;
d.sid = sid;
return d;
}
sid_t sid;
lp_id_t localPoolId;
};
/** Different data types are possible in the HK receiver map. For example, updates can be
requested for full datasets or for single pool variables. Periodic reporting is only possible
for data sets. */
enum class DataType : uint8_t { LOCAL_POOL_VARIABLE, DATA_SET };
/** The data pool manager will keep an internal map of HK receivers. */
struct SetSpecification {
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_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;
private:
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
bool periodicCollectionEnabled = false;
timeval lastGenerated{};
};
} // namespace periodicHk
namespace hk {
/**
* @brief This class is the managing instance for the local data pool.
@ -106,10 +43,10 @@ struct SetSpecification {
* Each pool entry has a valid state too.
* @author R. Mueller
*/
class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
class PeriodicHelper : public PeriodicHelperIF {
//! 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;
friend class SharedPoolAttorney;
public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
@ -131,8 +68,8 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
* @param queueToUse
* validity state is generated when serializing or deserializing packets.
*/
PeriodicHkGenerationHelper(PeriodicHkGenerationIF* owner, MessageQueueIF* queueToUse,
MessageQueueId_t hkDestQueue = MessageQueueIF::NO_QUEUE);
PeriodicHelper(GeneratesPeriodicHkIF* owner, MessageQueueIF* queueToUse,
MessageQueueId_t hkDestQueue = MessageQueueIF::NO_QUEUE);
void setHkDestinationId(MessageQueueId_t hkDestId);
@ -173,17 +110,17 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
* @param sid
* @return
*/
ReturnValue_t generateHousekeepingPacket(sid_t sid,
ReturnValue_t generateHousekeepingPacket(dp::sid_t sid,
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
[[nodiscard]] PeriodicHkGenerationIF* getOwner() const;
void addSetSpecification(const periodicHk::SetSpecification& setSpec);
ReturnValue_t printPoolEntry(lp_id_t localPoolId);
void addSetSpecification(const SetSpecification& setSpec);
ReturnValue_t printPoolEntry(dp::lp_id_t localPoolId);
/* Copying forbidden */
PeriodicHkGenerationHelper(const PeriodicHkGenerationHelper&) = delete;
PeriodicHkGenerationHelper operator=(const PeriodicHkGenerationHelper&) = delete;
PeriodicHelper(const PeriodicHkGenerationHelper&) = delete;
PeriodicHelper operator=(const PeriodicHkGenerationHelper&) = delete;
/**
* This function can be used to clear the receivers list. This is
@ -206,32 +143,29 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
/**
* Set the periodic generation frequency without enabling the periodic generation of packets.
*/
ReturnValue_t enablePeriodicPacket(sid_t structureId,
ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
std::optional<dur_millis_t> frequencyMs) override;
ReturnValue_t disablePeriodicPacket(sid_t structureId) override;
ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) override;
ReturnValue_t setCollectionInterval(sid_t structureId,
ReturnValue_t setCollectionInterval(dp::sid_t structureId,
dur_millis_t newCollectionIntervalMs) override;
protected:
std::optional<std::reference_wrapper<periodicHk::SetSpecification>> getSetSpecification(
sid_t structureId);
std::optional<std::reference_wrapper<SetSpecification>> getSetSpecification(
dp::sid_t structureId);
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params);
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params);
std::optional<dur_millis_t> getCollectionFrequency(sid_t structureId);
std::optional<dur_millis_t> getCollectionFrequency(dp::sid_t structureId);
/** The class which actually owns the manager (and its datapool). */
PeriodicHkGenerationIF* owner = nullptr;
hk::GeneratesPeriodicHkIF* owner = nullptr;
/** Default receiver for periodic HK packets */
MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE;
/** This vector will contain the list of HK receivers. */
using SetList = std::vector<periodicHk::SetSpecification>;
using SetList = std::vector<SetSpecification>;
SetList setList;
SetList setList{};
/**
* @brief Queue used for communication, for example commands.
@ -246,9 +180,9 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
ReturnValue_t serializeHkPacketIntoStore(HousekeepingPacketDownlink& hkPacket,
store_address_t& storeId, size_t* serializedSize);
void performPeriodicHkGeneration(periodicHk::SetSpecification& hkReceiver, timeval& now);
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable);
ReturnValue_t generateSetStructurePacket(sid_t sid);
void performPeriodicHkGeneration(SetSpecification& hkReceiver, timeval& now);
ReturnValue_t togglePeriodicGeneration(dp::sid_t sid, bool enable);
ReturnValue_t generateSetStructurePacket(dp::sid_t sid);
// void handleChangeResetLogic(periodicHk::DataType type, periodicHk::DataId dataId,
// MarkChangedIF* toReset);
@ -261,4 +195,4 @@ class PeriodicHkGenerationHelper : public PeriodicHkGenerationProviderIF {
const char* errorPrint = nullptr);
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */
} // namespace hk

View File

@ -0,0 +1,23 @@
#pragma once
#include <fsfw/timemanager/clockDefinitions.h>
#include "fsfw/datapool/definitions.h"
#include "fsfw/retval.h"
namespace hk {
class PeriodicHelperIF {
public:
virtual ~PeriodicHelperIF() = default;
/**
* Set the periodic generation frequency without enabling the periodic generation of packets.
*/
virtual ReturnValue_t setCollectionInterval(dp::sid_t structureId,
dur_millis_t newCollectionIntervalMs) = 0;
virtual ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
std::optional<dur_millis_t> frequencyMs) = 0;
virtual ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) = 0;
};
} // namespace hk

View File

@ -0,0 +1,72 @@
#pragma once
#include <bits/types/struct_timeval.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/ipc/messageQueueDefinitions.h>
#include <fsfw/timemanager/clockDefinitions.h>
#include <cstdint>
#include "fsfw/datapool/definitions.h"
namespace hk {
/**
* Different types of housekeeping reporting are possible.
* 1. PERIODIC:
* HK packets are generated in fixed intervals and sent to
* destination. Fromat will be raw.
* 2. UPDATE_NOTIFICATION:
* Notification will be sent out if HK data has changed.
* 3. UPDATE_SNAPSHOT:
* HK packets are only generated if explicitely requested.
* Propably not necessary, just use multiple local data sets or
* shared datasets.
*/
enum class ReportingType : uint8_t {
//! Periodic generation of HK packets.
PERIODIC,
};
union DataId {
DataId() : sid() {}
static DataId forSetId(dp::structure_id_t sid) {
DataId d;
d.sid = sid;
return d;
}
dp::sid_t sid;
dp::lp_id_t localPoolId;
};
/** Different data types are possible in the HK receiver map. For example, updates can be
requested for full datasets or for single pool variables. Periodic reporting is only possible
for data sets. */
enum class DataType : uint8_t { LOCAL_POOL_VARIABLE, DATA_SET };
/** The data pool manager will keep an internal map of HK receivers. */
struct SetSpecification {
public:
SetSpecification(dp::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_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;
private:
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
bool periodicCollectionEnabled = false;
timeval lastGenerated{};
};
} // namespace hk

View File

@ -1,24 +1,24 @@
#ifndef FSFW_INTERNALERROR_INTERNALERRORDATASET_H_
#define FSFW_INTERNALERROR_INTERNALERRORDATASET_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticSharedDataset.h>
#include <fsfw/datapool/PoolVariable.h>
#include <fsfw/datapool/StaticSharedSet.h>
enum errorPoolIds { TM_HITS = 0, QUEUE_HITS = 1, STORE_HITS = 2, VALID = 3 };
class InternalErrorDataset : public StaticSharedDataset<4> {
class InternalErrorDataset : public dp::StaticSharedSet<4> {
public:
static constexpr uint8_t ERROR_SET_ID = 0;
InternalErrorDataset(localpool::SharedPool& sharedPool)
: StaticSharedDataset(sharedPool, ERROR_SET_ID) {}
InternalErrorDataset(dp::SharedPool& sharedPool) : StaticSharedSet(sharedPool, ERROR_SET_ID) {}
InternalErrorDataset(object_id_t objectId) : StaticSharedDataset(sid_t(objectId, ERROR_SET_ID)) {}
InternalErrorDataset(object_id_t objectId)
: StaticSharedSet(dp::structure_id_t(objectId, ERROR_SET_ID)) {}
lp_var_t<uint32_t> tmHits = lp_var_t<uint32_t>(sid.objectId, TM_HITS, this);
lp_var_t<uint32_t> queueHits = lp_var_t<uint32_t>(sid.objectId, QUEUE_HITS, this);
lp_var_t<uint32_t> storeHits = lp_var_t<uint32_t>(sid.objectId, STORE_HITS, this);
lp_var_t<uint8_t> valid = lp_var_t<uint8_t>(sid.objectId, VALID, this);
dp::var_t<uint32_t> tmHits = dp::var_t<uint32_t>(sid.objectId, TM_HITS, this);
dp::var_t<uint32_t> queueHits = dp::var_t<uint32_t>(sid.objectId, QUEUE_HITS, this);
dp::var_t<uint32_t> storeHits = dp::var_t<uint32_t>(sid.objectId, STORE_HITS, this);
dp::var_t<uint8_t> valid = dp::var_t<uint8_t>(sid.objectId, VALID, this);
};
#endif /* FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ */

View File

@ -152,8 +152,8 @@ void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType, ui
this->timeoutMs = timeoutMs;
}
ReturnValue_t InternalErrorReporter::serializeHkDataset(sid_t structureId, uint8_t *buf,
size_t maxSize) {
ReturnValue_t InternalErrorReporter::serializeHkDataset(dp::structure_id_t structureId,
uint8_t *buf, size_t maxSize) {
if (structureId == internalErrorDataset.getSid()) {
size_t serSize = 0;
return internalErrorDataset.serialize(buf, serSize, maxSize, SerializeIF::Endianness::NETWORK);
@ -162,10 +162,10 @@ ReturnValue_t InternalErrorReporter::serializeHkDataset(sid_t structureId, uint8
}
ReturnValue_t InternalErrorReporter::specifyHkDatasets(
std::vector<periodicHk::SetSpecification> &setSpecification) {
std::vector<hk::SetSpecification> &setSpecification) {
setSpecification.emplace_back(internalErrorDataset.getSid(),
internalErrorDataset.getSerializedSize(), generationFrequency);
return returnvalue::OK;
}
localpool::SharedPool *InternalErrorReporter::getOptionalSharedPool() { return &sharedPool; }
dp::SharedPool *InternalErrorReporter::getOptionalSharedPool() { return &sharedPool; }

View File

@ -1,8 +1,10 @@
#ifndef FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_
#define FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_
#include <fsfw/housekeeping/PeriodicHkHelper.h>
#include "InternalErrorReporterIF.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationHelper.h"
#include "fsfw/housekeeping/GeneratesPeriodicHkIF.h"
#include "fsfw/internalerror/InternalErrorDataset.h"
#include "fsfw/ipc/MutexIF.h"
#include "fsfw/objectmanager/SystemObject.h"
@ -19,7 +21,7 @@
class InternalErrorReporter : public SystemObject,
public ExecutableObjectIF,
public InternalErrorReporterIF,
public PeriodicHkGenerationIF {
public hk::GeneratesPeriodicHkIF {
public:
InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth,
bool enableSetByDefault, dur_millis_t generationFrequency);
@ -38,12 +40,11 @@ class InternalErrorReporter : public SystemObject,
[[nodiscard]] object_id_t getObjectId() const override;
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
localpool::SharedPool* getOptionalSharedPool() override;
dp::SharedPool* getOptionalSharedPool() override;
ReturnValue_t serializeHkDataset(sid_t structureId, uint8_t* buf, size_t maxSize) override;
ReturnValue_t serializeHkDataset(dp::sid_t structureId, uint8_t* buf, size_t maxSize) override;
ReturnValue_t specifyHkDatasets(
std::vector<periodicHk::SetSpecification>& setSpecification) override;
ReturnValue_t specifyHkDatasets(std::vector<hk::SetSpecification>& setSpecification) override;
ReturnValue_t initialize() override;
ReturnValue_t performOperation(uint8_t opCode) override;
@ -58,8 +59,8 @@ class InternalErrorReporter : public SystemObject,
protected:
MessageQueueIF* commandQueue;
localpool::SharedPool sharedPool;
PeriodicHkGenerationHelper hkHelper;
dp::SharedPool sharedPool;
hk::PeriodicHelper hkHelper;
PeriodicTaskIF* executingTask = nullptr;
@ -69,7 +70,7 @@ class InternalErrorReporter : public SystemObject,
bool enableSetByDefault;
dur_millis_t generationFrequency;
sid_t internalErrorSid;
dp::structure_id_t internalErrorSid;
InternalErrorDataset internalErrorDataset;
bool diagnosticPrintout = true;

View File

@ -9,7 +9,7 @@
template <typename T>
class AbsLimitMonitor : public MonitorBase<T> {
public:
AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId, gp_id_t globalPoolId,
AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId, dp::g_id_t globalPoolId,
uint16_t confirmationLimit, T limit,
Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE,
bool aboveIsViolation = true)

View File

@ -13,7 +13,7 @@
template <typename T>
class LimitMonitor : public MonitorBase<T> {
public:
LimitMonitor(object_id_t reporterId, uint8_t monitorId, gp_id_t globalPoolId,
LimitMonitor(object_id_t reporterId, uint8_t monitorId, dp::g_id_t globalPoolId,
uint16_t confirmationLimit, T lowerLimit, T upperLimit,
Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT,
Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT)

View File

@ -1,11 +1,11 @@
#ifndef FSFW_MONITORING_MONITORBASE_H_
#define FSFW_MONITORING_MONITORBASE_H_
#include "../datapoollocal/LocalPoolVariable.h"
#include "LimitViolationReporter.h"
#include "MonitorReporter.h"
#include "MonitoringIF.h"
#include "MonitoringMessageContent.h"
#include "fsfw/datapool/PoolVariable.h"
#include "monitoringConf.h"
/**
@ -22,7 +22,7 @@
template <typename T>
class MonitorBase : public MonitorReporter<T> {
public:
MonitorBase(object_id_t reporterId, uint8_t monitorId, gp_id_t globalPoolId,
MonitorBase(object_id_t reporterId, uint8_t monitorId, dp::g_id_t globalPoolId,
uint16_t confirmationLimit)
: MonitorReporter<T>(reporterId, monitorId, globalPoolId, confirmationLimit),
poolVariable(globalPoolId) {}
@ -63,7 +63,7 @@ class MonitorBase : public MonitorReporter<T> {
return returnvalue::OK;
}
LocalPoolVariable<T> poolVariable;
dp::PoolVariable<T> poolVariable;
};
#endif /* FSFW_MONITORING_MONITORBASE_H_ */

View File

@ -1,12 +1,11 @@
#ifndef FSFW_MONITORING_MONITORREPORTER_H_
#define FSFW_MONITORING_MONITORREPORTER_H_
#pragma once
#include "../datapoollocal/localPoolDefinitions.h"
#include "../events/EventManagerIF.h"
#include "../parameters/HasParametersIF.h"
#include "LimitViolationReporter.h"
#include "MonitoringIF.h"
#include "MonitoringMessageContent.h"
#include "fsfw/datapool/definitions.h"
#include "monitoringConf.h"
template <typename T>
@ -17,7 +16,7 @@ class MonitorReporter : public HasParametersIF {
// TODO: Adapt to use SID instead of parameter ID.
MonitorReporter(object_id_t reportingId, uint8_t monitorId, gp_id_t globalPoolId,
MonitorReporter(object_id_t reportingId, uint8_t monitorId, dp::g_id_t globalPoolId,
uint16_t confirmationLimit)
: monitorId(monitorId),
globalPoolId(globalPoolId),
@ -84,7 +83,7 @@ class MonitorReporter : public HasParametersIF {
protected:
const uint8_t monitorId;
const gp_id_t globalPoolId;
const dp::g_id_t globalPoolId;
object_id_t reportingId;
ReturnValue_t oldState;
@ -161,6 +160,4 @@ class MonitorReporter : public HasParametersIF {
}
return returnvalue::OK;
}
};
#endif /* FSFW_MONITORING_MONITORREPORTER_H_ */
};

View File

@ -1,7 +1,5 @@
#ifndef FSFW_MONITORING_MONITORINGMESSAGECONTENT_H_
#define FSFW_MONITORING_MONITORINGMESSAGECONTENT_H_
#pragma once
#include "../datapoollocal/localPoolDefinitions.h"
#include "../objectmanager/ObjectManager.h"
#include "../serialize/SerialBufferAdapter.h"
#include "../serialize/SerialFixedArrayListAdapter.h"
@ -11,6 +9,7 @@
#include "../timemanager/TimeWriterIF.h"
#include "HasMonitorsIF.h"
#include "MonitoringIF.h"
#include "fsfw/datapool/definitions.h"
#include "monitoringConf.h"
namespace Factory {
@ -29,7 +28,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
public:
SerializeElement<uint8_t> monitorId;
SerializeElement<uint32_t> parameterObjectId;
SerializeElement<lp_id_t> localPoolId;
SerializeElement<dp::lp_id_t> localPoolId;
SerializeElement<T> parameterValue;
SerializeElement<T> limitValue;
SerializeElement<ReturnValue_t> oldState;
@ -50,7 +49,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
timeStamper(nullptr) {
setAllNext();
}
MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue, ReturnValue_t oldState,
MonitoringReportContent(dp::g_id_t globalPoolId, T value, T limitValue, ReturnValue_t oldState,
ReturnValue_t newState)
: SerialLinkedListAdapter<SerializeIF>(&parameterObjectId),
monitorId(0),
@ -94,5 +93,3 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
};
template <typename T>
object_id_t MonitoringReportContent<T>::timeStamperId = 0;
#endif /* FSFW_MONITORING_MONITORINGMESSAGECONTENT_H_ */

View File

@ -8,8 +8,9 @@
object_id_t Fuse::powerSwitchId = 0;
Fuse::Fuse(object_id_t ownerId, object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet,
VariableIds ids, float maxCurrent, uint16_t confirmationCount)
Fuse::Fuse(object_id_t ownerId, object_id_t fuseObjectId, uint8_t fuseId,
dp::structure_id_t variableSet, VariableIds ids, float maxCurrent,
uint16_t confirmationCount)
: SystemObject(fuseObjectId),
oldFuseState(0),
fuseId(fuseId),

View File

@ -3,13 +3,13 @@
#include <list>
#include "../datapoollocal/StaticSharedDataset.h"
#include "../devicehandlers/HealthDevice.h"
#include "../monitoring/AbsLimitMonitor.h"
#include "../parameters/ParameterHelper.h"
#include "../returnvalues/returnvalue.h"
#include "PowerComponentIF.h"
#include "PowerSwitchIF.h"
#include "fsfw/datapool/StaticSharedSet.h"
#include "fsfw/devicehandlers/HealthDevice.h"
#include "fsfw/monitoring/AbsLimitMonitor.h"
#include "fsfw/parameters/ParameterHelper.h"
#include "fsfw/returnvalues/returnvalue.h"
namespace Factory {
void setStaticFrameworkObjectIds();
@ -25,20 +25,20 @@ enum FusePoolId {
};
class FuseSet : public StaticSharedDataset<6> {
class FuseSet : public datapool::StaticSharedSet<6> {
public:
static constexpr uint8_t FUSE_SET_ID = 0;
FuseSet(localpool::SharedPool &sharedPool) : StaticSharedDataset(sharedPool, FUSE_SET_ID) {}
FuseSet(dp::SharedPool &sharedPool) : StaticSharedSet(sharedPool, FUSE_SET_ID) {}
FuseSet(object_id_t objectId) : StaticSharedDataset(sid_t(objectId, FUSE_SET_ID)) {}
FuseSet(object_id_t objectId) : StaticSharedSet(dp::sid_t(objectId, FUSE_SET_ID)) {}
lp_var_t<float> voltage = lp_var_t<float>(sid.objectId, FusePoolId::VOLTAGE, this);
lp_var_t<float> current = lp_var_t<float>(sid.objectId, FusePoolId::CURRENT, this);
lp_var_t<uint8_t> state = lp_var_t<uint8_t>(sid.objectId, FusePoolId::STATE, this);
lp_var_t<float> power = lp_var_t<float>(sid.objectId, FusePoolId::POWER, this);
lp_var_t<uint8_t> powerValid = lp_var_t<uint8_t>(sid.objectId, FusePoolId::POWER_VALID, this);
lp_var_t<uint8_t> setValid = lp_var_t<uint8_t>(sid.objectId, FusePoolId::SET_VALID, this);
dp::f32_t voltage = dp::f32_t(sid.objectId, FusePoolId::VOLTAGE, this);
dp::f32_t current = dp::f32_t(sid.objectId, FusePoolId::CURRENT, this);
dp::u8_t state = dp::u8_t(sid.objectId, FusePoolId::STATE, this);
dp::f32_t power = dp::f32_t(sid.objectId, FusePoolId::POWER, this);
dp::u8_t powerValid = dp::u8_t(sid.objectId, FusePoolId::POWER_VALID, this);
dp::u8_t setValid = dp::u8_t(sid.objectId, FusePoolId::SET_VALID, this);
};
class Fuse : public SystemObject,
@ -53,10 +53,10 @@ class Fuse : public SystemObject,
//!< Worst case is Fuse and one of two switches on. See PCDU ICD 1.9 p29 bottom
public:
struct VariableIds {
gp_id_t pidVoltage;
gp_id_t pidCurrent;
gp_id_t pidState;
gp_id_t poolIdPower;
dp::g_id_t pidVoltage;
dp::g_id_t pidCurrent;
dp::g_id_t pidState;
dp::g_id_t poolIdPower;
};
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::POWER_SWITCH_IF;
@ -70,7 +70,7 @@ class Fuse : public SystemObject,
static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, severity::LOW);
typedef std::list<PowerComponentIF *> DeviceList;
Fuse(object_id_t ownerId, object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet,
Fuse(object_id_t ownerId, object_id_t fuseObjectId, uint8_t fuseId, dp::sid_t variableSet,
VariableIds ids, float maxCurrent, uint16_t confirmationCount = 2);
virtual ~Fuse();
void addDevice(PowerComponentIF *set);

View File

@ -3,8 +3,8 @@
#include "definitions.h"
#include "fsfw/ipc/QueueFactory.h"
PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, DefaultLimits limits,
SensorEvents events, uint16_t confirmationCount)
PowerSensor::PowerSensor(object_id_t objectId, dp::structure_id_t setId, VariableIds ids,
DefaultLimits limits, SensorEvents events, uint16_t confirmationCount)
: SystemObject(objectId),
parameterHelper(this),
healthHelper(this, objectId),

View File

@ -1,7 +1,7 @@
#ifndef FSFW_POWER_POWERSENSOR_H_
#define FSFW_POWER_POWERSENSOR_H_
#include "fsfw/datapoollocal/StaticSharedDataset.h"
#include "fsfw/datapool/StaticSharedSet.h"
#include "fsfw/devicehandlers/HealthDevice.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/monitoring/LimitMonitor.h"
@ -17,21 +17,19 @@ enum PowerSensorPoolId {
SET_VALID = 3
};
class PowerSensorSet : public StaticSharedDataset<6> {
class PowerSensorSet : public dp::StaticSharedSet<6> {
public:
static constexpr uint8_t POWER_SENSOR_SET_ID = 0;
PowerSensorSet(localpool::SharedPool &sharedPool)
: StaticSharedDataset(sharedPool, POWER_SENSOR_SET_ID) {}
PowerSensorSet(dp::SharedPool &sharedPool) : StaticSharedSet(sharedPool, POWER_SENSOR_SET_ID) {}
PowerSensorSet(object_id_t objectId)
: StaticSharedDataset(sid_t(objectId, POWER_SENSOR_SET_ID)) {}
: StaticSharedSet(dp::sid_t(objectId, POWER_SENSOR_SET_ID)) {}
lp_var_t<float> current = lp_var_t<float>(sid.objectId, PowerSensorPoolId::CURRENT, this);
lp_var_t<float> voltage = lp_var_t<float>(sid.objectId, PowerSensorPoolId::VOLTAGE, this);
lp_var_t<float> power = lp_var_t<float>(sid.objectId, PowerSensorPoolId::POWER, this);
lp_var_t<uint8_t> setIsValid =
lp_var_t<uint8_t>(sid.objectId, PowerSensorPoolId::SET_VALID, this);
dp::f32_t current{sid.objectId, PowerSensorPoolId::CURRENT, this};
dp::f32_t voltage{sid.objectId, PowerSensorPoolId::VOLTAGE, this};
dp::f32_t power = {sid.objectId, PowerSensorPoolId::POWER, this};
dp::u8_t setIsValid{sid.objectId, PowerSensorPoolId::SET_VALID, this};
};
/**
* @brief Does magic.
@ -41,10 +39,10 @@ class PowerSensor : public SystemObject, public ReceivesParameterMessagesIF, pub
public:
struct VariableIds {
gp_id_t pidCurrent;
gp_id_t pidVoltage;
gp_id_t poolIdPower;
gp_id_t valid;
dp::g_id_t pidCurrent;
dp::g_id_t pidVoltage;
dp::g_id_t poolIdPower;
dp::g_id_t valid;
};
struct DefaultLimits {
float currentMin;
@ -58,7 +56,7 @@ class PowerSensor : public SystemObject, public ReceivesParameterMessagesIF, pub
Event voltageLow;
Event voltageHigh;
};
PowerSensor(object_id_t objectId, sid_t sid, VariableIds setIds, DefaultLimits limits,
PowerSensor(object_id_t objectId, dp::sid_t sid, VariableIds setIds, DefaultLimits limits,
SensorEvents events, uint16_t confirmationCount = 0);
virtual ~PowerSensor();
ReturnValue_t calculatePower();

View File

@ -1,9 +1,11 @@
#include "fsfw/pus/Service3Housekeeping.h"
#include "fsfw/datapoollocal/PeriodicHkGenerationIF.h"
#include "fsfw/housekeeping/GeneratesPeriodicHkIF.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/pus/servicepackets/Service3Packets.h"
using namespace dp;
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId,
uint32_t queueDepth, uint8_t numParallelCommands)
: CommandingServiceBase(objectId, apid, "PUS 3 HK", serviceId, numParallelCommands,
@ -58,8 +60,7 @@ ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID(object_id_t* objectI
ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
// check HasLocalDataPoolIF property of target
PeriodicHkGenerationIF* possibleTarget =
ObjectManager::instance()->get<PeriodicHkGenerationIF>(*objectId);
auto* possibleTarget = ObjectManager::instance()->get<hk::GeneratesPeriodicHkIF>(*objectId);
if (possibleTarget == nullptr) {
return CommandingServiceBase::INVALID_OBJECT;
}
@ -99,12 +100,12 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand(CommandMessa
bool enableReporting,
const uint8_t* tcData,
size_t tcDataLen) {
if (tcDataLen < sizeof(sid_t)) {
if (tcDataLen < sizeof(structure_id_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
structure_id_t targetSid = buildStructureId(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setToggleReportingCommand(command, targetSid, enableReporting);
return returnvalue::OK;
}
@ -113,12 +114,12 @@ ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(CommandMess
object_id_t objectId,
const uint8_t* tcData,
size_t tcDataLen) {
if (tcDataLen < sizeof(sid_t)) {
if (tcDataLen < sizeof(structure_id_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
structure_id_t targetSid = buildStructureId(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setStructureReportingCommand(command, targetSid);
return returnvalue::OK;
}
@ -128,24 +129,24 @@ ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(CommandMessage*
const uint8_t* tcData,
size_t tcDataLen) {
if (tcDataLen < sizeof(sid_t)) {
if (tcDataLen < sizeof(structure_id_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
structure_id_t targetSid = buildStructureId(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setOneShotReportCommand(command, targetSid);
return returnvalue::OK;
}
ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand(
CommandMessage* command, object_id_t objectId, const uint8_t* tcData, size_t tcDataLen) {
if (tcDataLen < sizeof(sid_t) + sizeof(float)) {
if (tcDataLen < sizeof(structure_id_t) + sizeof(float)) {
/* SID plus the size of the new collection interval. */
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
structure_id_t targetSid = buildStructureId(objectId, &tcData, &tcDataLen);
float newCollectionInterval = 0;
SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG);
@ -276,7 +277,7 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess
uint8_t subserviceId) {
store_address_t storeId;
sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId);
structure_id_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId);
auto resultPair = ipcStore->getData(storeId);
if (resultPair.first != returnvalue::OK) {
return resultPair.first;
@ -286,9 +287,9 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess
return sendTmPacket(static_cast<uint8_t>(subserviceId), hkPacket.hkData, hkPacket.hkSize);
}
sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData,
size_t* tcDataLen) {
sid_t targetSid;
structure_id_t Service3Housekeeping::buildStructureId(object_id_t objectId, const uint8_t** tcData,
size_t* tcDataLen) {
structure_id_t targetSid;
targetSid.objectId = objectId;
// skip deserialization of object ID, was already done.
*tcData += sizeof(object_id_t);

View File

@ -97,7 +97,8 @@ class Service3Housekeeping : public CommandingServiceBase, public AcceptsHkPacke
size_t tcDataLen);
void handleUnrequestedReply(CommandMessage* reply) override;
sid_t buildSid(object_id_t objectId, const uint8_t** tcData, size_t* tcDataLen);
dp::structure_id_t buildStructureId(object_id_t objectId, const uint8_t** tcData,
size_t* tcDataLen);
};
#endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */

View File

@ -11,11 +11,12 @@
*/
class HkPacket { //!< [EXPORT] : [SUBSERVICE] 25, 26
public:
sid_t sid; //!< [EXPORT] : [COMMENT] Structure ID (SID) of housekeeping data.
dp::sid_t sid; //!< [EXPORT] : [COMMENT] Structure ID (SID) of housekeeping data.
const uint8_t* hkData; //!< [EXPORT] : [MAXSIZE] Deduced size
size_t hkSize; //!< [EXPORT] : [IGNORE]
HkPacket(sid_t sid, const uint8_t* data, size_t size) : sid(sid), hkData(data), hkSize(size) {}
HkPacket(dp::sid_t sid, const uint8_t* data, size_t size)
: sid(sid), hkData(data), hkSize(size) {}
};
#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_ */

View File

@ -1,9 +1,9 @@
#include "fsfw/thermal/ThermalComponent.h"
ThermalComponent::ThermalComponent(object_id_t reportingObjectId, uint8_t domainId,
gp_id_t temperaturePoolId, gp_id_t targetStatePoolId,
gp_id_t currentStatePoolId, gp_id_t requestPoolId,
SharedDatasetBase* dataSet, AbstractTemperatureSensor* sensor,
dp::g_id_t temperaturePoolId, dp::g_id_t targetStatePoolId,
dp::g_id_t currentStatePoolId, dp::g_id_t requestPoolId,
dp::SharedSetBase* dataSet, AbstractTemperatureSensor* sensor,
AbstractTemperatureSensor* firstRedundantSensor,
AbstractTemperatureSensor* secondRedundantSensor,
ThermalModuleIF* thermalModule, Parameters parameters,

View File

@ -44,9 +44,10 @@ class ThermalComponent : public ThermalComponentCore {
* @param parameters
* @param priority
*/
ThermalComponent(object_id_t reportingObjectId, uint8_t domainId, gp_id_t temperaturePoolId,
gp_id_t targetStatePoolId, gp_id_t currentStatePoolId, gp_id_t requestPoolId,
SharedDatasetBase *dataSet, AbstractTemperatureSensor *sensor,
ThermalComponent(object_id_t reportingObjectId, uint8_t domainId, dp::g_id_t temperaturePoolId,
dp::g_id_t targetStatePoolId, dp::g_id_t currentStatePoolId,
dp::g_id_t requestPoolId, dp::SharedSetBase *dataSet,
AbstractTemperatureSensor *sensor,
AbstractTemperatureSensor *firstRedundantSensor,
AbstractTemperatureSensor *secondRedundantSensor, ThermalModuleIF *thermalModule,
Parameters parameters, Priority priority);

View File

@ -3,9 +3,10 @@
#include "fsfw/thermal/tcsDefinitions.h"
ThermalComponentCore::ThermalComponentCore(object_id_t reportingObjectId, uint8_t domainId,
gp_id_t temperaturePoolId, gp_id_t targetStatePoolId,
gp_id_t currentStatePoolId, gp_id_t requestPoolId,
SharedDatasetBase* dataSet, Parameters parameters,
dp::g_id_t temperaturePoolId,
dp::g_id_t targetStatePoolId,
dp::g_id_t currentStatePoolId, dp::g_id_t requestPoolId,
dp::SharedSetBase* dataSet, Parameters parameters,
StateRequest initialTargetState)
: temperature(temperaturePoolId, dataSet, PoolVariableIF::VAR_WRITE),
targetState(targetStatePoolId, dataSet, PoolVariableIF::VAR_READ),

View File

@ -5,7 +5,7 @@
#include "ThermalComponentIF.h"
#include "ThermalModule.h"
#include "ThermalMonitorReporter.h"
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/datapool/PoolVariable.h"
/**
* @brief
@ -36,9 +36,9 @@ class ThermalComponentCore : public ThermalComponentIF {
* @param initialTargetState
*/
ThermalComponentCore(
object_id_t reportingObjectId, uint8_t domainId, gp_id_t temperaturePoolId,
gp_id_t targetStatePoolId, gp_id_t currentStatePoolId, gp_id_t requestPoolId,
SharedDatasetBase *dataSet, Parameters parameters,
object_id_t reportingObjectId, uint8_t domainId, dp::g_id_t temperaturePoolId,
dp::g_id_t targetStatePoolId, dp::g_id_t currentStatePoolId, dp::g_id_t requestPoolId,
dp::SharedSetBase *dataSet, Parameters parameters,
StateRequest initialTargetState = ThermalComponentIF::STATE_REQUEST_OPERATIONAL);
void addSensor(AbstractTemperatureSensor *firstRedundantSensor);
@ -74,10 +74,10 @@ class ThermalComponentCore : public ThermalComponentIF {
AbstractTemperatureSensor *secondRedundantSensor = nullptr;
ThermalModuleIF *thermalModule = nullptr;
lp_var_t<float> temperature;
lp_var_t<int8_t> targetState;
lp_var_t<int8_t> currentState;
lp_var_t<uint8_t> heaterRequest;
dp::f32_t temperature;
dp::i8_t targetState;
dp::i8_t currentState;
dp::i8_t heaterRequest;
bool isHeating = false;

View File

@ -4,8 +4,8 @@
#include "fsfw/monitoring/MonitoringMessageContent.h"
#include "fsfw/thermal/AbstractTemperatureSensor.h"
ThermalModule::ThermalModule(gp_id_t moduleTemperaturePoolId, gp_id_t currentStatePoolId,
gp_id_t targetStatePoolId, SharedDatasetBase* dataSet,
ThermalModule::ThermalModule(dp::g_id_t moduleTemperaturePoolId, dp::g_id_t currentStatePoolId,
dp::g_id_t targetStatePoolId, dp::SharedSetBase* dataSet,
Parameters parameters, RedundantHeater::Parameters heaterParameters)
: oldStrategy(ACTIVE_SINGLE),
parameters(parameters),
@ -15,12 +15,12 @@ ThermalModule::ThermalModule(gp_id_t moduleTemperaturePoolId, gp_id_t currentSta
heater = new RedundantHeater(heaterParameters);
}
ThermalModule::ThermalModule(gp_id_t moduleTemperaturePoolId, SharedDatasetBase* dataSet)
ThermalModule::ThermalModule(dp::g_id_t moduleTemperaturePoolId, dp::SharedSetBase* dataSet)
: oldStrategy(ACTIVE_SINGLE),
parameters({0, 0}),
moduleTemperature(moduleTemperaturePoolId, dataSet, PoolVariableIF::VAR_WRITE),
currentState(gp_id_t(), dataSet, PoolVariableIF::VAR_WRITE),
targetState(gp_id_t(), dataSet, PoolVariableIF::VAR_READ) {}
currentState(dp::g_id_t(), dataSet, PoolVariableIF::VAR_WRITE),
targetState(dp::g_id_t(), dataSet, PoolVariableIF::VAR_READ) {}
ThermalModule::~ThermalModule() { delete heater; }

View File

@ -3,12 +3,12 @@
#include <list>
#include "../datapoollocal/LocalPoolVariable.h"
#include "../devicehandlers/HealthDevice.h"
#include "../events/EventReportingProxyIF.h"
#include "RedundantHeater.h"
#include "ThermalModuleIF.h"
#include "fsfw/datapoollocal/SharedDatasetBase.h"
#include "fsfw/datapool/PoolVariable.h"
#include "fsfw/datapool/SharedSetBase.h"
#include "tcsDefinitions.h"
class PowerSwitchIF;
@ -25,11 +25,11 @@ class ThermalModule : public ThermalModuleIF {
float hysteresis;
};
ThermalModule(gp_id_t moduleTemperaturePoolId, gp_id_t currentStatePoolId,
gp_id_t targetStatePoolId, SharedDatasetBase *dataSet, Parameters parameters,
ThermalModule(dp::g_id_t moduleTemperaturePoolId, dp::g_id_t currentStatePoolId,
dp::g_id_t targetStatePoolId, dp::SharedSetBase *dataSet, Parameters parameters,
RedundantHeater::Parameters heaterParameters);
ThermalModule(gp_id_t moduleTemperaturePoolId, SharedDatasetBase *dataSet);
ThermalModule(dp::g_id_t moduleTemperaturePoolId, dp::SharedSetBase *dataSet);
virtual ~ThermalModule();
@ -70,12 +70,12 @@ class ThermalModule : public ThermalModuleIF {
Parameters parameters;
lp_var_t<float> moduleTemperature;
dp::f32_t moduleTemperature;
RedundantHeater *heater = nullptr;
lp_var_t<int8_t> currentState;
lp_var_t<int8_t> targetState;
dp::i8_t currentState;
dp::i8_t targetState;
std::list<AbstractTemperatureSensor *> sensors;
std::list<ComponentData> components;

View File

@ -109,7 +109,7 @@ ReturnValue_t DeviceHandlerMock::initialize() {
return result;
}
ReturnValue_t DeviceHandlerMock::serializeHkDataset(sid_t structureId, uint8_t *buf,
ReturnValue_t DeviceHandlerMock::serializeHkDataset(structure_id_t structureId, uint8_t *buf,
size_t maxSize) {
return returnvalue::OK;
}

View File

@ -28,7 +28,7 @@ ReturnValue_t LocalPoolOwnerBase::initialize() {
localpool::SharedPool *LocalPoolOwnerBase::getOptionalSharedPool() { return &sharedPool; }
ReturnValue_t LocalPoolOwnerBase::serializeHkDataset(sid_t structureId, uint8_t *buf,
ReturnValue_t LocalPoolOwnerBase::serializeHkDataset(structure_id_t structureId, uint8_t *buf,
size_t maxSize) {
return returnvalue::OK;
}

View File

@ -1,10 +1,10 @@
#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
#include <fsfw/datapoollocal/LocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/LocalPoolVector.h>
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
#include <fsfw/datapoollocal/PoolVariable.h>
#include <fsfw/datapoollocal/SharedDataset.h>
#include <fsfw/datapoollocal/StaticSharedDataset.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/SystemObject.h>
@ -25,9 +25,9 @@ static constexpr uint32_t testSetId1 = 1;
static constexpr uint32_t testSetId2 = 2;
static constexpr uint8_t dataSetMaxVariables = 10;
static const auto testSid0 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0);
static const auto testSid1 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1);
static const auto testSid2 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId2);
static const auto testSid0 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0);
static const auto testSid1 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1);
static const auto testSid2 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId2);
static const gp_id_t uint8VarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint8VarId);
static const gp_id_t floatVarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, floatVarId);
@ -73,7 +73,8 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
[[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); }
ReturnValue_t serializeHkDataset(sid_t structureId, uint8_t* buf, size_t maxSize) override;
ReturnValue_t serializeHkDataset(structure_id_t structureId, uint8_t* buf,
size_t maxSize) override;
ReturnValue_t specifyHkDatasets(std::vector<periodicHk::SetSpecification>& setList) override;