2020-12-27 01:52:48 +01:00
|
|
|
#ifndef FSFW_DATAPOOLLOCAL_POOLREADHELPER_H_
|
|
|
|
#define FSFW_DATAPOOLLOCAL_POOLREADHELPER_H_
|
|
|
|
|
2021-01-12 20:46:34 +01:00
|
|
|
#include "LocalPoolDataSetBase.h"
|
|
|
|
#include "../serviceinterface/ServiceInterface.h"
|
2020-12-27 01:52:48 +01:00
|
|
|
#include <FSFWConfig.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Helper class to read data sets or pool variables
|
|
|
|
*/
|
|
|
|
class PoolReadHelper {
|
|
|
|
public:
|
2021-01-06 21:33:54 +01:00
|
|
|
PoolReadHelper(ReadCommitIF* readObject,
|
|
|
|
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
|
|
|
uint32_t mutexTimeout = 20):
|
2020-12-27 01:52:48 +01:00
|
|
|
readObject(readObject), mutexTimeout(mutexTimeout) {
|
|
|
|
if(readObject != nullptr) {
|
2021-01-06 21:33:54 +01:00
|
|
|
readResult = readObject->read(timeoutType, mutexTimeout);
|
2021-01-12 20:56:53 +01:00
|
|
|
#if FSFW_VERBOSE_LEVEL == 1
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-12-27 01:52:48 +01:00
|
|
|
sif::error << "PoolReadHelper: Read failed!" << std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2021-01-12 20:46:34 +01:00
|
|
|
#else
|
|
|
|
sif::printError("PoolReadHelper: Read failed!\n");
|
2020-12-27 01:52:48 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t getReadResult() const {
|
|
|
|
return readResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
~PoolReadHelper() {
|
|
|
|
if(readObject != nullptr) {
|
2021-01-06 21:33:54 +01:00
|
|
|
readObject->commit(timeoutType, mutexTimeout);
|
2020-12-27 01:52:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ReadCommitIF* readObject = nullptr;
|
|
|
|
ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK;
|
2021-01-06 21:33:54 +01:00
|
|
|
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
2020-12-27 01:52:48 +01:00
|
|
|
uint32_t mutexTimeout = 20;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FSFW_DATAPOOLLOCAL_POOLREADHELPER_H_ */
|