a lot of bugfixes and important api change

This commit is contained in:
Robin Müller 2021-01-06 21:14:23 +01:00
parent 91cf5f1764
commit dacdfc62d3
26 changed files with 314 additions and 93 deletions

View File

@ -38,11 +38,12 @@ ReturnValue_t PoolDataSetBase::registerVariable(
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t error = result; ReturnValue_t error = result;
if (state == States::STATE_SET_UNINITIALISED) { if (state == States::STATE_SET_UNINITIALISED) {
lockDataPool(lockTimeout); lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
result = readVariable(count); result = readVariable(count);
if(result != RETURN_OK) { if(result != RETURN_OK) {
@ -86,7 +87,8 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
!= PoolVariableIF::NO_PARAMETER) != PoolVariableIF::NO_PARAMETER)
{ {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
result = registeredVariables[count]->read(mutexTimeout); result = registeredVariables[count]->read(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
result = registeredVariables[count]->readWithoutLock(); result = registeredVariables[count]->readWithoutLock();
@ -99,25 +101,28 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
return result; return result;
} }
ReturnValue_t PoolDataSetBase::commit(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
if (state == States::STATE_SET_WAS_READ) { if (state == States::STATE_SET_WAS_READ) {
handleAlreadyReadDatasetCommit(lockTimeout); handleAlreadyReadDatasetCommit(timeoutType, lockTimeout);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else { else {
return handleUnreadDatasetCommit(lockTimeout); return handleUnreadDatasetCommit(timeoutType, lockTimeout);
} }
} }
void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) { void PoolDataSetBase::handleAlreadyReadDatasetCommit(
lockDataPool(lockTimeout); MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
if (registeredVariables[count]->getReadWriteMode() if (registeredVariables[count]->getReadWriteMode()
!= PoolVariableIF::VAR_READ != PoolVariableIF::VAR_READ
&& registeredVariables[count]->getDataPoolId() && registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) { != PoolVariableIF::NO_PARAMETER) {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
registeredVariables[count]->commit(mutexTimeout); registeredVariables[count]->commit(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
registeredVariables[count]->commitWithoutLock(); registeredVariables[count]->commitWithoutLock();
@ -128,16 +133,18 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) {
unlockDataPool(); unlockDataPool();
} }
ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(
MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
lockDataPool(lockTimeout); lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
if (registeredVariables[count]->getReadWriteMode() if (registeredVariables[count]->getReadWriteMode()
== PoolVariableIF::VAR_WRITE == PoolVariableIF::VAR_WRITE
&& registeredVariables[count]->getDataPoolId() && registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) { != PoolVariableIF::NO_PARAMETER) {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
result = registeredVariables[count]->commit(mutexTimeout); result = registeredVariables[count]->commit(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
result = registeredVariables[count]->commitWithoutLock(); result = registeredVariables[count]->commitWithoutLock();
@ -160,7 +167,8 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) {
} }
ReturnValue_t PoolDataSetBase::lockDataPool(uint32_t timeoutMs) { ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -62,8 +62,9 @@ public:
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling * - @c SET_WAS_ALREADY_READ if read() is called twice without calling
* commit() in between * commit() in between
*/ */
virtual ReturnValue_t read(uint32_t lockTimeout = virtual ReturnValue_t read(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/** /**
* @brief The commit call initializes writing back the registered variables. * @brief The commit call initializes writing back the registered variables.
* @details * @details
@ -82,8 +83,9 @@ public:
* - @c COMMITING_WITHOUT_READING if set was not read yet and * - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables * contains non write-only variables
*/ */
virtual ReturnValue_t commit(uint32_t lockTimeout = virtual ReturnValue_t commit(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/** /**
* Register the passed pool variable instance into the data set. * Register the passed pool variable instance into the data set.
@ -97,8 +99,9 @@ public:
* thread-safety. Default implementation is empty * thread-safety. Default implementation is empty
* @return Always returns -@c RETURN_OK * @return Always returns -@c RETURN_OK
*/ */
virtual ReturnValue_t lockDataPool(uint32_t timeoutMs = virtual ReturnValue_t lockDataPool(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/** /**
* Provides the means to unlock the underlying data structure to ensure * Provides the means to unlock the underlying data structure to ensure
* thread-safety. Default implementation is empty * thread-safety. Default implementation is empty
@ -160,8 +163,12 @@ private:
uint32_t mutexTimeout = 20; uint32_t mutexTimeout = 20;
ReturnValue_t readVariable(uint16_t count); ReturnValue_t readVariable(uint16_t count);
void handleAlreadyReadDatasetCommit(uint32_t lockTimeout); void handleAlreadyReadDatasetCommit(
ReturnValue_t handleUnreadDatasetCommit(uint32_t lockTimeout); 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_ */ #endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */

View File

@ -18,7 +18,10 @@ public:
* thread-safety * thread-safety
* @return Lock operation result * @return Lock operation result
*/ */
virtual ReturnValue_t lockDataPool(dur_millis_t timeoutMs) = 0; virtual ReturnValue_t lockDataPool(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) = 0;
/** /**
* @brief Unlock call corresponding to the lock call. * @brief Unlock call corresponding to the lock call.
* @return Unlock operation result * @return Unlock operation result

View File

@ -88,8 +88,10 @@ Type PoolEntry<T>::getType() {
template class PoolEntry<uint8_t>; template class PoolEntry<uint8_t>;
template class PoolEntry<uint16_t>; template class PoolEntry<uint16_t>;
template class PoolEntry<uint32_t>; template class PoolEntry<uint32_t>;
template class PoolEntry<uint64_t>;
template class PoolEntry<int8_t>; template class PoolEntry<int8_t>;
template class PoolEntry<int16_t>; template class PoolEntry<int16_t>;
template class PoolEntry<int32_t>; template class PoolEntry<int32_t>;
template class PoolEntry<int64_t>;
template class PoolEntry<float>; template class PoolEntry<float>;
template class PoolEntry<double>; template class PoolEntry<double>;

View File

@ -2,6 +2,7 @@
#define FSFW_DATAPOOL_READCOMMITIF_H_ #define FSFW_DATAPOOL_READCOMMITIF_H_
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/ipc/MutexIF.h>
/** /**
* @brief Common interface for all software objects which employ read-commit * @brief Common interface for all software objects which employ read-commit
@ -10,8 +11,10 @@
class ReadCommitIF { class ReadCommitIF {
public: public:
virtual ~ReadCommitIF() {} virtual ~ReadCommitIF() {}
virtual ReturnValue_t read(uint32_t mutexTimeout) = 0; virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
virtual ReturnValue_t commit(uint32_t mutexTimeout) = 0; uint32_t timeoutMs) = 0;
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) = 0;
protected: protected:
@ -19,11 +22,11 @@ protected:
//! members with commit and read semantics where the lock is only necessary //! members with commit and read semantics where the lock is only necessary
//! once. //! once.
virtual ReturnValue_t readWithoutLock() { virtual ReturnValue_t readWithoutLock() {
return read(20); return read(MutexIF::TimeoutType::WAITING, 20);
} }
virtual ReturnValue_t commitWithoutLock() { virtual ReturnValue_t commitWithoutLock() {
return commit(20); return commit(MutexIF::TimeoutType::WAITING, 20);
} }
}; };

View File

@ -1,4 +1,6 @@
#include "LocalPoolDataSetBase.h" #include "LocalPoolDataSetBase.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../datapoollocal/LocalDataPoolManager.h" #include "../datapoollocal/LocalDataPoolManager.h"
#include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../housekeeping/PeriodicHousekeepingHelper.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
@ -15,7 +17,10 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
<< "invalid!" << std::endl; << "invalid!" << std::endl;
#endif #else
fsfw::printError("LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
"invalid!\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();
@ -44,13 +49,26 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
mutex = MutexFactory::instance()->createMutex(); mutex = MutexFactory::instance()->createMutex();
} }
LocalPoolDataSetBase::LocalPoolDataSetBase(
PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables, bool protectFunctions):
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
if(protectFunctions) {
mutex = MutexFactory::instance()->createMutex();
}
}
LocalPoolDataSetBase::~LocalPoolDataSetBase() { LocalPoolDataSetBase::~LocalPoolDataSetBase() {
} }
ReturnValue_t LocalPoolDataSetBase::lockDataPool(uint32_t timeoutMs) { ReturnValue_t LocalPoolDataSetBase::lockDataPool(
MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if(hkManager != nullptr) { if(hkManager != nullptr) {
MutexIF* mutex = hkManager->getMutexHandle(); MutexIF* poolMutex = hkManager->getMutexHandle();
return mutex->lockMutex(MutexIF::TimeoutType::WAITING, timeoutMs); return poolMutex->lockMutex(timeoutType, timeoutMs);
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -150,9 +168,12 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
size, maxSize, streamEndianness); size, maxSize, streamEndianness);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
" error!" << std::endl; << "Serialization error!" << std::endl;
#endif #else
fsfw::printWarning("LocalPoolDataSetBase::serializeLocalPoolIds: "
"Serialization error!\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result; return result;
} }
} }
@ -211,8 +232,11 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size,
void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
if(position > 7) { if(position > 7) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Raw Access: Bit setting invalid position" sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!"
<< std::endl; << std::endl;
#else
fsfw::printWarning("LocalPoolDataSetBase::bitSetter: "
"Invalid position!\n\r");
#endif #endif
return; return;
} }
@ -244,14 +268,19 @@ void LocalPoolDataSetBase::initializePeriodicHelper(
} }
void LocalPoolDataSetBase::setChanged(bool changed) { void LocalPoolDataSetBase::setChanged(bool changed) {
// TODO: Make this configurable? if(mutex == nullptr) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); this->changed = changed;
return;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout);
this->changed = changed; this->changed = changed;
} }
bool LocalPoolDataSetBase::hasChanged() const { bool LocalPoolDataSetBase::hasChanged() const {
// TODO: Make this configurable? if(mutex == nullptr) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); return changed;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout);
return changed; return changed;
} }
@ -273,18 +302,22 @@ bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
} }
bool LocalPoolDataSetBase::isValid() const { bool LocalPoolDataSetBase::isValid() const {
if(mutex == nullptr) {
return this->valid;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5);
return this->valid; return this->valid;
} }
void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) { void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); mutex->lockMutex(timeoutType, mutexTimeout);
if(setEntriesRecursively) { if(setEntriesRecursively) {
for(size_t idx = 0; idx < this->getFillCount(); idx++) { for(size_t idx = 0; idx < this->getFillCount(); idx++) {
registeredVariables[idx] -> setValid(valid); registeredVariables[idx] -> setValid(valid);
} }
} }
this->valid = valid; this->valid = valid;
mutex->unlockMutex();
} }
void LocalPoolDataSetBase::setReadCommitProtectionBehaviour( void LocalPoolDataSetBase::setReadCommitProtectionBehaviour(
@ -292,3 +325,9 @@ void LocalPoolDataSetBase::setReadCommitProtectionBehaviour(
PoolDataSetBase::setReadCommitProtectionBehaviour(protectEveryReadCommit, PoolDataSetBase::setReadCommitProtectionBehaviour(protectEveryReadCommit,
mutexTimeout); mutexTimeout);
} }
void LocalPoolDataSetBase::setDataSetMutexTimeout(
MutexIF::TimeoutType timeoutType, uint32_t mutexTimeout) {
this->timeoutType = timeoutType;
this->mutexTimeout = mutexTimeout;
}

View File

@ -67,6 +67,15 @@ public:
LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables); const size_t maxNumberOfVariables);
/**
* Simple constructor, if the dataset is not owner permanently by
* a class with a HK manager.
* @param registeredVariablesArray
* @param maxNumberOfVariables
*/
LocalPoolDataSetBase(PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables, bool protectFunctions = true);
/** /**
* @brief The destructor automatically manages writing the valid * @brief The destructor automatically manages writing the valid
* information of variables. * information of variables.
@ -87,6 +96,9 @@ public:
void setReadCommitProtectionBehaviour(bool protectEveryReadCommit, void setReadCommitProtectionBehaviour(bool protectEveryReadCommit,
uint32_t mutexTimeout = 20); uint32_t mutexTimeout = 20);
void setDataSetMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t mutexTimeout);
void setValidityBufferGeneration(bool withValidityBuffer); void setValidityBufferGeneration(bool withValidityBuffer);
sid_t getSid() const; sid_t getSid() const;
@ -138,7 +150,12 @@ public:
protected: protected:
sid_t sid; sid_t sid;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t mutexTimeout = 20; uint32_t mutexTimeout = 20;
/**
* This mutex is required because the dataset can potentially be accessed
* by multiple threads for information like change status or validity.
*/
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
bool diagnostic = false; bool diagnostic = false;
@ -183,7 +200,9 @@ protected:
* @details * @details
* It makes use of the lockDataPool method offered by the DataPool class. * It makes use of the lockDataPool method offered by the DataPool class.
*/ */
ReturnValue_t lockDataPool(uint32_t timeoutMs) override; ReturnValue_t lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) override;
/** /**
* @brief This is a small helper function to facilitate * @brief This is a small helper function to facilitate
* unlocking the global data pool * unlocking the global data pool

View File

@ -106,7 +106,9 @@ public:
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
* *
*/ */
ReturnValue_t read(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; 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. * @brief The commit call copies the array values back to the data pool.
* @details * @details
@ -116,8 +118,21 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t commit(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief This commit function can be used to set the pool variable valid
* as well.
* @param setValid
* @param timeoutType
* @param timeoutMs
* @return
*/
ReturnValue_t commit(bool setValid, MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
LocalPoolVariable<T> &operator=(const T& newValue); LocalPoolVariable<T> &operator=(const T& newValue);
LocalPoolVariable<T> &operator=(const LocalPoolVariable<T>& newPoolVariable); LocalPoolVariable<T> &operator=(const LocalPoolVariable<T>& newPoolVariable);

View File

@ -24,9 +24,9 @@ inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::read(
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return readWithoutLock(); return readWithoutLock();
} }
@ -64,9 +64,16 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); this->setValid(setValid);
return commit(timeoutType, timeoutMs);
}
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return commitWithoutLock(); return commitWithoutLock();
} }

View File

@ -7,7 +7,7 @@
#include "../datapool/PoolVariableIF.h" #include "../datapool/PoolVariableIF.h"
#include "../datapoollocal/LocalDataPoolManager.h" #include "../datapoollocal/LocalDataPoolManager.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterface.h"
/** /**
@ -123,7 +123,9 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) override; 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. * @brief The commit call copies the array values back to the data pool.
* @details * @details
@ -133,7 +135,9 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t commit(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
protected: protected:
/** /**
@ -157,12 +161,12 @@ protected:
private: private:
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout // std::ostream is the type for object std::cout
template <typename U, uint16_t otherSize> template <typename U, uint16_t otherSize>
friend std::ostream& operator<< (std::ostream &out, friend std::ostream& operator<< (std::ostream &out,
const LocalPoolVector<U, otherSize> &var); const LocalPoolVector<U, otherSize> &var);
#endif
}; };

View File

@ -24,9 +24,9 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
dataSet, setReadWriteMode) {} dataSet, setReadWriteMode) {}
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(uint32_t lockTimeout) { inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return readWithoutLock(); return readWithoutLock();
} }
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
@ -59,9 +59,8 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit( inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
uint32_t lockTimeout) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
lockTimeout);
return commitWithoutLock(); return commitWithoutLock();
} }
@ -153,6 +152,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
return result; return result;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline std::ostream& operator<< (std::ostream &out, inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVector<T, vectorSize> &var) { const LocalPoolVector<T, vectorSize> &var) {
@ -166,5 +166,6 @@ inline std::ostream& operator<< (std::ostream &out,
out << "]"; out << "]";
return out; return out;
} }
#endif
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */ #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */

View File

@ -229,7 +229,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.value = thermalSet->heaterRequest.value =
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
thermalSet->commit(PoolVariableIF::VALID); thermalSet->heaterRequest.setValid(true);
thermalSet->commit();
} }
} }

View File

@ -162,9 +162,15 @@ void EventManager::printEvent(EventMessage* message) {
#endif #endif
void EventManager::lockMutex() { void EventManager::lockMutex() {
mutex->lockMutex(MutexIF::BLOCKING); mutex->lockMutex(timeoutType, timeoutMs);
} }
void EventManager::unlockMutex() { void EventManager::unlockMutex() {
mutex->unlockMutex(); mutex->unlockMutex();
} }
void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
this->timeoutType = timeoutType;
this->timeoutMs = timeoutMs;
}

View File

@ -29,6 +29,8 @@ public:
EventManager(object_id_t setObjectId); EventManager(object_id_t setObjectId);
virtual ~EventManager(); virtual ~EventManager();
void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
MessageQueueId_t getEventReportQueue(); MessageQueueId_t getEventReportQueue();
ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false); ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false);
@ -51,6 +53,8 @@ protected:
std::map<MessageQueueId_t, EventMatchTree> listenerList; std::map<MessageQueueId_t, EventMatchTree> listenerList;
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 20;
static const uint8_t N_POOLS = 3; static const uint8_t N_POOLS = 3;
LocalPool factoryBackend; LocalPool factoryBackend;

View File

@ -23,7 +23,7 @@ void InternalErrorReporter::setDiagnosticPrintout(bool enable) {
} }
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT); internalErrorDataset.read(timeoutType, timeoutMs);
uint32_t newQueueHits = getAndResetQueueHits(); uint32_t newQueueHits = getAndResetQueueHits();
uint32_t newTmHits = getAndResetTmHits(); uint32_t newTmHits = getAndResetTmHits();
@ -46,8 +46,8 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
internalErrorDataset.queueHits.value += newQueueHits; internalErrorDataset.queueHits.value += newQueueHits;
internalErrorDataset.storeHits.value += newStoreHits; internalErrorDataset.storeHits.value += newStoreHits;
internalErrorDataset.tmHits.value += newTmHits; internalErrorDataset.tmHits.value += newTmHits;
internalErrorDataset.setValidity(true, true);
internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); internalErrorDataset.commit(timeoutType, timeoutMs);
poolManager.performHkOperation(); poolManager.performHkOperation();
@ -69,7 +69,7 @@ void InternalErrorReporter::lostTm() {
uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = queueHits; value = queueHits;
queueHits = 0; queueHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -78,21 +78,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t InternalErrorReporter::getQueueHits() { uint32_t InternalErrorReporter::getQueueHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = queueHits; value = queueHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementQueueHits() { void InternalErrorReporter::incrementQueueHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
queueHits++; queueHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = tmHits; value = tmHits;
tmHits = 0; tmHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -101,14 +101,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t InternalErrorReporter::getTmHits() { uint32_t InternalErrorReporter::getTmHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = tmHits; value = tmHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementTmHits() { void InternalErrorReporter::incrementTmHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
tmHits++; tmHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
@ -119,7 +119,7 @@ void InternalErrorReporter::storeFull() {
uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = storeHits; value = storeHits;
storeHits = 0; storeHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -128,14 +128,14 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t InternalErrorReporter::getStoreHits() { uint32_t InternalErrorReporter::getStoreHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = storeHits; value = storeHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementStoreHits() { void InternalErrorReporter::incrementStoreHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
storeHits++; storeHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
@ -190,3 +190,8 @@ ReturnValue_t InternalErrorReporter::initializeAfterTaskCreation() {
return poolManager.initializeAfterTaskCreation(); return poolManager.initializeAfterTaskCreation();
} }
void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
this->timeoutType = timeoutType;
this->timeoutMs = timeoutMs;
}

View File

@ -22,7 +22,6 @@ class InternalErrorReporter: public SystemObject,
public InternalErrorReporterIF, public InternalErrorReporterIF,
public HasLocalDataPoolIF { public HasLocalDataPoolIF {
public: public:
static constexpr uint8_t INTERNAL_ERROR_MUTEX_TIMEOUT = 20;
InternalErrorReporter(object_id_t setObjectId, InternalErrorReporter(object_id_t setObjectId,
uint32_t messageQueueDepth = 5); uint32_t messageQueueDepth = 5);
@ -34,6 +33,9 @@ public:
*/ */
void setDiagnosticPrintout(bool enable); void setDiagnosticPrintout(bool enable);
void setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs);
virtual ~InternalErrorReporter(); virtual ~InternalErrorReporter();
virtual object_id_t getObjectId() const override; virtual object_id_t getObjectId() const override;
@ -61,7 +63,11 @@ protected:
LocalDataPoolManager poolManager; LocalDataPoolManager poolManager;
PeriodicTaskIF* executingTask = nullptr; PeriodicTaskIF* executingTask = nullptr;
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 20;
sid_t internalErrorSid; sid_t internalErrorSid;
InternalErrorDataset internalErrorDataset; InternalErrorDataset internalErrorDataset;

View File

@ -14,7 +14,7 @@ public:
/** /**
* Different types of timeout for the mutex lock. * Different types of timeout for the mutex lock.
*/ */
enum TimeoutType { enum class TimeoutType {
POLLING, //!< If mutex is not available, return immediately POLLING, //!< If mutex is not available, return immediately
WAITING, //!< Wait a specified time for the mutex to become available WAITING, //!< Wait a specified time for the mutex to become available
BLOCKING //!< Block indefinitely until the mutex becomes available. BLOCKING //!< Block indefinitely until the mutex becomes available.

View File

@ -202,7 +202,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){ if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -217,7 +217,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if(timeMutex == nullptr){ if(timeMutex == nullptr){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -4,16 +4,16 @@
Mutex::Mutex() {} Mutex::Mutex() {}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutType == MutexIF::BLOCKING) { if(timeoutType == TimeoutType::BLOCKING) {
mutex.lock(); mutex.lock();
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else if(timeoutType == MutexIF::POLLING) { else if(timeoutType == TimeoutType::POLLING) {
if(mutex.try_lock()) { if(mutex.try_lock()) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
} }
else if(timeoutMs > MutexIF::POLLING){ else if(timeoutType == TimeoutType::WAITING){
auto chronoMs = std::chrono::milliseconds(timeoutMs); auto chronoMs = std::chrono::milliseconds(timeoutMs);
if(mutex.try_lock_for(chronoMs)) { if(mutex.try_lock_for(chronoMs)) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;

View File

@ -65,8 +65,8 @@ ReturnValue_t Fuse::check() {
set.read(); set.read();
if (!healthHelper.healthTable->isHealthy(getObjectId())) { if (!healthHelper.healthTable->isHealthy(getObjectId())) {
setAllMonitorsToUnchecked(); setAllMonitorsToUnchecked();
set.commit(PoolVariableIF::INVALID); set.setValidity(false, true);
return RETURN_OK; return set.commit();
} }
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
checkFuseState(); checkFuseState();
@ -206,7 +206,8 @@ float Fuse::getPower() {
void Fuse::setDataPoolEntriesInvalid() { void Fuse::setDataPoolEntriesInvalid() {
set.read(); set.read();
set.commit(PoolVariableIF::INVALID); set.setValidity(false, true);
set.commit();
} }
ReturnValue_t Fuse::getParameter(uint8_t domainId, uint16_t parameterId, ReturnValue_t Fuse::getParameter(uint8_t domainId, uint16_t parameterId,

View File

@ -97,7 +97,8 @@ void PowerSensor::checkCommandQueue() {
void PowerSensor::setDataPoolEntriesInvalid() { void PowerSensor::setDataPoolEntriesInvalid() {
powerSensorSet.read(); powerSensorSet.read();
powerSensorSet.commit(PoolVariableIF::INVALID); powerSensorSet.setValidity(false, true);
powerSensorSet.commit();
} }
float PowerSensor::getPower() { float PowerSensor::getPower() {

View File

@ -13,7 +13,7 @@
void testmutex::testMutex() { void testmutex::testMutex() {
std::string id = "[testMutex]"; std::string id = "[testMutex]";
MutexIF* mutex = MutexFactory::instance()->createMutex(); MutexIF* mutex = MutexFactory::instance()->createMutex();
auto result = mutex->lockMutex(MutexIF::POLLING); auto result = mutex->lockMutex(MutexIF::TimeoutType::POLLING);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
unitt::put_error(id); unitt::put_error(id);
} }

View File

@ -0,0 +1,21 @@
#include "LocalPoolOwnerBase.h"
#include <catch2/catch_test_macros.hpp>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
LocalPoolOwnerBase* poolOwner = objectManager->
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner != nullptr);
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
== retval::CATCH_OK);
SECTION("BasicTest") {
//StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>()
}
}

View File

@ -4,6 +4,7 @@
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h> #include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h> #include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/LocalPoolVector.h>
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include <testcfg/objects/systemObjectList.h> #include <testcfg/objects/systemObjectList.h>
@ -11,9 +12,12 @@ namespace lpool {
static constexpr lp_id_t uint8VarId = 0; static constexpr lp_id_t uint8VarId = 0;
static constexpr lp_id_t floatVarId = 1; static constexpr lp_id_t floatVarId = 1;
static constexpr lp_id_t uint32VarId = 2; static constexpr lp_id_t uint32VarId = 2;
static constexpr lp_id_t uint16Vec3Id = 3;
static constexpr lp_id_t int64Vec2Id = 4;
} }
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF { class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
public: public:
LocalPoolOwnerBase( LocalPoolOwnerBase(
@ -31,25 +35,42 @@ public:
} }
ReturnValue_t initializeHkManager() { ReturnValue_t initializeHkManager() {
if(not initialized) {
initialized = true;
return hkManager.initialize(messageQueue); return hkManager.initialize(messageQueue);
}
return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t initializeHkManagerAfterTaskCreation() { ReturnValue_t initializeHkManagerAfterTaskCreation() {
if(not initializedAfterTaskCreation) {
initializedAfterTaskCreation = true;
return hkManager.initializeAfterTaskCreation(); return hkManager.initializeAfterTaskCreation();
} }
return HasReturnvaluesIF::RETURN_OK;
}
/** Command queue for housekeeping messages. */ /** Command queue for housekeeping messages. */
MessageQueueId_t getCommandQueue() const override { MessageQueueId_t getCommandQueue() const override {
return messageQueue->getId(); return messageQueue->getId();
} }
// This is called by initializeAfterTaskCreation of the HK manager.
virtual ReturnValue_t initializeLocalDataPool( virtual ReturnValue_t initializeLocalDataPool(
LocalDataPool& localDataPoolMap, LocalDataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
// Default initialization empty for now. // Default initialization empty for now.
localDataPoolMap.emplace(lpool::uint8VarId, new PoolEntry<uint8_t>({0})); localDataPoolMap.emplace(lpool::uint8VarId,
localDataPoolMap.emplace(lpool::floatVarId, new PoolEntry<float>({0})); new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(lpool::floatVarId,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(lpool::uint32VarId,
new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(lpool::uint16Vec3Id,
new PoolEntry<uint16_t>({0, 0, 0}));
localDataPoolMap.emplace(lpool::int64Vec2Id,
new PoolEntry<int64_t>({0, 0}));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -77,9 +98,17 @@ private:
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId); lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId);
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId); lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId);
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this,
lpool::uint16Vec3Id);
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this,
lpool::int64Vec2Id);
MessageQueueIF* messageQueue = nullptr; MessageQueueIF* messageQueue = nullptr;
LocalDataPoolManager hkManager; LocalDataPoolManager hkManager;
bool initialized = false;
bool initializedAfterTaskCreation = false;
}; };
#endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */ #endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */

View File

@ -6,9 +6,11 @@
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
LocalPoolOwnerBase poolOwner(objects::TEST_LOCAL_POOL_OWNER_BASE); LocalPoolOwnerBase* poolOwner = objectManager->
REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() REQUIRE(poolOwner != nullptr);
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
== retval::CATCH_OK); == retval::CATCH_OK);
SECTION("Basic Tests") { SECTION("Basic Tests") {
@ -26,6 +28,18 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
testVariable.setValid(true); testVariable.setValid(true);
CHECK(testVariable.isValid()); CHECK(testVariable.isValid());
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE);
testVariable.setDataPoolId(22);
CHECK(testVariable.getDataPoolId() == 22);
testVariable.setDataPoolId(lpool::uint8VarId);
testVariable.setChanged(true);
CHECK(testVariable.hasChanged());
testVariable.setChanged(false);
gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE,
lpool::uint8VarId); lpool::uint8VarId);
lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId); lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId);
@ -93,6 +107,15 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl; sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl;
#endif #endif
// for code coverage. If program does not crash -> OK
lp_var_t<uint8_t> invalidObjectVar = lp_var_t<uint8_t>(
0xffffffff, lpool::uint8VarId);
gp_id_t globPoolId(0xffffffff,
lpool::uint8VarId);
lp_var_t<uint8_t> invalidObjectVar2 = lp_var_t<uint8_t>(globPoolId);
lp_var_t<uint8_t> invalidObjectVar3 = lp_var_t<uint8_t>(nullptr,
lpool::uint8VarId);
} }
} }

View File

@ -0,0 +1,16 @@
#include "LocalPoolOwnerBase.h"
#include <catch2/catch_test_macros.hpp>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <unittest/core/CatchDefinitions.h>
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
LocalPoolOwnerBase* poolOwner = objectManager->
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner != nullptr);
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
== retval::CATCH_OK);
}