WIP: somethings wrong.. #19
@ -44,18 +44,18 @@ PoolEntryIF* GlobalDataPool::getRawData( uint32_t data_pool_id ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GlobalDataPool::freeDataPoolLock() {
|
ReturnValue_t GlobalDataPool::unlockDataPool() {
|
||||||
ReturnValue_t status = mutex->unlockMutex();
|
ReturnValue_t status = mutex->unlockMutex();
|
||||||
if ( status != RETURN_OK ) {
|
if(status != RETURN_OK) {
|
||||||
sif::error << "DataPool::DataPool: unlock of mutex failed with"
|
sif::error << "DataPool::DataPool: unlock of mutex failed with"
|
||||||
" error code: " << status << std::endl;
|
" error code: " << status << std::endl;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GlobalDataPool::lockDataPool() {
|
ReturnValue_t GlobalDataPool::lockDataPool(uint32_t timeoutMs) {
|
||||||
ReturnValue_t status = mutex->lockMutex(MutexIF::BLOCKING);
|
ReturnValue_t status = mutex->lockMutex(timeoutMs);
|
||||||
if ( status != RETURN_OK ) {
|
if(status != RETURN_OK) {
|
||||||
sif::error << "DataPool::DataPool: lock of mutex failed "
|
sif::error << "DataPool::DataPool: lock of mutex failed "
|
||||||
"with error code: " << status << std::endl;
|
"with error code: " << status << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -95,12 +95,12 @@ public:
|
|||||||
* @brief This is a small helper function to facilitate locking the global data pool.
|
* @brief This is a small helper function to facilitate locking the global data pool.
|
||||||
* @details It fetches the pool's mutex id and tries to acquire the mutex.
|
* @details It fetches the pool's mutex id and tries to acquire the mutex.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t lockDataPool();
|
ReturnValue_t lockDataPool(uint32_t timeoutMs = MutexIF::BLOCKING);
|
||||||
/**
|
/**
|
||||||
* @brief This is a small helper function to facilitate unlocking the global data pool.
|
* @brief This is a small helper function to facilitate unlocking the global data pool.
|
||||||
* @details It fetches the pool's mutex id and tries to free the mutex.
|
* @details It fetches the pool's mutex id and tries to free the mutex.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t freeDataPoolLock();
|
ReturnValue_t unlockDataPool();
|
||||||
/**
|
/**
|
||||||
* @brief The print call is a simple debug method.
|
* @brief The print call is a simple debug method.
|
||||||
* @details It prints the current content of the data pool.
|
* @details It prints the current content of the data pool.
|
||||||
|
@ -8,22 +8,22 @@ GlobDataSet::GlobDataSet(): DataSetBase() {}
|
|||||||
// (Destructor is already called)
|
// (Destructor is already called)
|
||||||
GlobDataSet::~GlobDataSet() {}
|
GlobDataSet::~GlobDataSet() {}
|
||||||
|
|
||||||
ReturnValue_t GlobDataSet::commit(bool valid) {
|
ReturnValue_t GlobDataSet::commit(bool valid, uint32_t lockTimeout) {
|
||||||
setEntriesValid(valid);
|
setEntriesValid(valid);
|
||||||
setSetValid(valid);
|
setSetValid(valid);
|
||||||
return commit();
|
return commit(lockTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GlobDataSet::commit() {
|
ReturnValue_t GlobDataSet::commit(uint32_t lockTimeout) {
|
||||||
return DataSetBase::commit();
|
return DataSetBase::commit(lockTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GlobDataSet::unlockDataPool() {
|
ReturnValue_t GlobDataSet::unlockDataPool() {
|
||||||
return glob::dataPool.freeDataPoolLock();
|
return glob::dataPool.unlockDataPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t GlobDataSet::lockDataPool() {
|
ReturnValue_t GlobDataSet::lockDataPool(uint32_t timeoutMs) {
|
||||||
return glob::dataPool.lockDataPool();
|
return glob::dataPool.lockDataPool(timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobDataSet::setEntriesValid(bool valid) {
|
void GlobDataSet::setEntriesValid(bool valid) {
|
||||||
|
@ -44,8 +44,8 @@ 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
|
||||||
*/
|
*/
|
||||||
ReturnValue_t commit(bool valid);
|
ReturnValue_t commit(bool valid, uint32_t lockTimeout = MutexIF::BLOCKING);
|
||||||
ReturnValue_t commit() override;
|
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all entries
|
* Set all entries
|
||||||
@ -74,8 +74,7 @@ private:
|
|||||||
* @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() override;
|
ReturnValue_t lockDataPool(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
|
||||||
|
@ -72,7 +72,49 @@ public:
|
|||||||
*/
|
*/
|
||||||
~GlobPoolVar() {}
|
~GlobPoolVar() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is a call to read the value from the global data pool.
|
||||||
|
* @details
|
||||||
|
* When executed, this operation tries to fetch the pool entry with matching
|
||||||
|
* data pool id from the global data pool and copies the value and the valid
|
||||||
|
* information to its local attributes. In case of a failure (wrong type 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(uint32_t lockTimeout) override;
|
||||||
|
/**
|
||||||
|
* @brief The commit call writes back the variable's value 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 valid flag is automatically set to "valid".
|
||||||
|
* The operation does NOT provide any mutual exclusive protection by itself.
|
||||||
|
* The commit 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(uint32_t lockTimeout) override;
|
||||||
|
|
||||||
protected:
|
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;
|
||||||
/**
|
/**
|
||||||
* @brief To access the correct data pool entry on read and commit calls,
|
* @brief To access the correct data pool entry on read and commit calls,
|
||||||
* the data pool is stored.
|
* the data pool is stored.
|
||||||
@ -91,26 +133,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
pool_rwm_t readWriteMode;
|
pool_rwm_t readWriteMode;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is a call to read the value from the global data pool.
|
|
||||||
* @details
|
|
||||||
* When executed, this operation tries to fetch the pool entry with matching
|
|
||||||
* data pool id from the global data pool and copies the value and the valid
|
|
||||||
* information to its local attributes. In case of a failure (wrong type or
|
|
||||||
* pool id not found), the variable is set to zero and invalid.
|
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
|
||||||
*/
|
|
||||||
ReturnValue_t read() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The commit call writes back the variable's value 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 valid flag is automatically set to "valid".
|
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ReturnValue_t commit() override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty ctor for List initialization
|
* Empty ctor for List initialization
|
||||||
*/
|
*/
|
||||||
@ -138,7 +160,7 @@ public:
|
|||||||
|
|
||||||
uint8_t getValid();
|
uint8_t getValid();
|
||||||
|
|
||||||
void setValid(uint8_t valid);
|
void setValid(bool valid) override;
|
||||||
|
|
||||||
operator T() {
|
operator T() {
|
||||||
return value;
|
return value;
|
||||||
|
@ -12,8 +12,38 @@ inline GlobPoolVar<T>::GlobPoolVar(uint32_t set_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline ReturnValue_t GlobPoolVar<T>::read(uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = readWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline ReturnValue_t GlobPoolVar<T>::commit(uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = commitWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline ReturnValue_t GlobPoolVar<T>::read() {
|
inline ReturnValue_t GlobPoolVar<T>::readWithoutLock() {
|
||||||
PoolEntry<T>* read_out = glob::dataPool.getData<T>(dataPoolId, 1);
|
PoolEntry<T>* read_out = glob::dataPool.getData<T>(dataPoolId, 1);
|
||||||
if (read_out != NULL) {
|
if (read_out != NULL) {
|
||||||
valid = read_out->valid;
|
valid = read_out->valid;
|
||||||
@ -29,7 +59,7 @@ inline ReturnValue_t GlobPoolVar<T>::read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline ReturnValue_t GlobPoolVar<T>::commit() {
|
inline ReturnValue_t GlobPoolVar<T>::commitWithoutLock() {
|
||||||
PoolEntry<T>* write_back = glob::dataPool.getData<T>(dataPoolId, 1);
|
PoolEntry<T>* write_back = glob::dataPool.getData<T>(dataPoolId, 1);
|
||||||
if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
|
if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
|
||||||
write_back->valid = valid;
|
write_back->valid = valid;
|
||||||
@ -80,7 +110,7 @@ inline uint8_t GlobPoolVar<T>::getValid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void GlobPoolVar<T>::setValid(uint8_t valid) {
|
inline void GlobPoolVar<T>::setValid(bool valid) {
|
||||||
this->valid = valid;
|
this->valid = valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void setValid(uint8_t valid) {this->valid = valid;}
|
void setValid(bool valid) {this->valid = valid;}
|
||||||
uint8_t getValid() {return valid;}
|
uint8_t getValid() {return valid;}
|
||||||
|
|
||||||
T &operator [](int i) {return value[i];}
|
T &operator [](int i) {return value[i];}
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
virtual size_t getSerializedSize() const override;
|
virtual size_t getSerializedSize() const override;
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
bool bigEndian) override;
|
bool bigEndian) override;
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* @brief This is a call to read the array's values
|
* @brief This is a call to read the array's values
|
||||||
* from the global data pool.
|
* from the global data pool.
|
||||||
@ -122,19 +122,43 @@ protected:
|
|||||||
* data pool id from the global data pool and copies all array values
|
* data pool id from the global data pool and copies all array values
|
||||||
* and the valid information to its local attributes.
|
* and the valid information to its local attributes.
|
||||||
* In case of a failure (wrong type, size or pool id not found), the
|
* In case of a failure (wrong type, size or pool id not found), the
|
||||||
* variable is set to zero and invalid. The operation does NOT provide
|
* variable is set to zero and invalid.
|
||||||
* any mutual exclusive protection by itself.
|
* The read call is protected by a lock of the global data pool.
|
||||||
|
* 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();
|
ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) 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
|
||||||
* It checks type and size, as well as if the variable is writable. If so,
|
* It checks type and size, as well as if the variable is writable. If so,
|
||||||
* the value is copied and the valid flag is automatically set to "valid".
|
* the value is copied and the valid flag is automatically set to "valid".
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
* The commit call is protected by a lock of the global data pool.
|
||||||
|
* 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();
|
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief To access the correct data pool entry on read and commit calls,
|
* @brief To access the correct data pool entry on read and commit calls,
|
||||||
|
@ -12,8 +12,40 @@ inline GlobPoolVector<T, vectorSize>::GlobPoolVector(uint32_t set_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t GlobPoolVector<T, vectorSize>::read() {
|
inline ReturnValue_t GlobPoolVector<T, vectorSize>::read(uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = readWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline ReturnValue_t GlobPoolVector<T, vectorSize>::commit(
|
||||||
|
uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = commitWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline ReturnValue_t GlobPoolVector<T, vectorSize>::readWithoutLock() {
|
||||||
PoolEntry<T>* read_out = glob::dataPool.getData<T>(this->dataPoolId,
|
PoolEntry<T>* read_out = glob::dataPool.getData<T>(this->dataPoolId,
|
||||||
vectorSize);
|
vectorSize);
|
||||||
if (read_out != nullptr) {
|
if (read_out != nullptr) {
|
||||||
@ -33,7 +65,7 @@ inline ReturnValue_t GlobPoolVector<T, vectorSize>::read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t GlobPoolVector<T, vectorSize>::commit() {
|
inline ReturnValue_t GlobPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||||
PoolEntry<T>* writeBack = glob::dataPool.getData<T>(this->dataPoolId,
|
PoolEntry<T>* writeBack = glob::dataPool.getData<T>(this->dataPoolId,
|
||||||
vectorSize);
|
vectorSize);
|
||||||
if ((writeBack != nullptr) && (this->readWriteMode != VAR_READ)) {
|
if ((writeBack != nullptr) && (this->readWriteMode != VAR_READ)) {
|
||||||
|
@ -15,7 +15,8 @@ class PIDReader: public PoolVariableIF {
|
|||||||
protected:
|
protected:
|
||||||
uint32_t parameterId;
|
uint32_t parameterId;
|
||||||
uint8_t valid;
|
uint8_t valid;
|
||||||
ReturnValue_t read() {
|
|
||||||
|
ReturnValue_t readWithoutLock() {
|
||||||
uint8_t arrayIndex = GlobalDataPool::PIDToArrayIndex(parameterId);
|
uint8_t arrayIndex = GlobalDataPool::PIDToArrayIndex(parameterId);
|
||||||
PoolEntry<T>* read_out = glob::dataPool.getData<T>(
|
PoolEntry<T>* read_out = glob::dataPool.getData<T>(
|
||||||
GlobalDataPool::PIDToDataPoolId(parameterId), arrayIndex);
|
GlobalDataPool::PIDToDataPoolId(parameterId), arrayIndex);
|
||||||
@ -36,9 +37,13 @@ protected:
|
|||||||
* Reason is the possibility to access a single DP vector element, but if we commit,
|
* Reason is the possibility to access a single DP vector element, but if we commit,
|
||||||
* we set validity of the whole vector.
|
* we set validity of the whole vector.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t commit() {
|
ReturnValue_t commit(uint32_t lockTimeout) override {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
ReturnValue_t commitWithoutLock() override {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty ctor for List initialization
|
* Empty ctor for List initialization
|
||||||
*/
|
*/
|
||||||
@ -71,6 +76,19 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t read(uint32_t lockTimeout) override {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool();
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = readWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "PIDReader::read: Could not unlock data pool!"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Copy ctor to copy classes containing Pool Variables.
|
* Copy ctor to copy classes containing Pool Variables.
|
||||||
*/
|
*/
|
||||||
@ -113,7 +131,7 @@ public:
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValid(uint8_t valid) {
|
void setValid(bool valid) {
|
||||||
this->valid = valid;
|
this->valid = valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,21 @@ PoolRawAccess::PoolRawAccess(uint32_t set_id, uint8_t setArrayEntry,
|
|||||||
|
|
||||||
PoolRawAccess::~PoolRawAccess() {}
|
PoolRawAccess::~PoolRawAccess() {}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccess::read() {
|
ReturnValue_t PoolRawAccess::read(uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = readWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PoolRawAccess::readWithoutLock() {
|
||||||
ReturnValue_t result = RETURN_FAILED;
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
PoolEntryIF* readOut = glob::dataPool.getRawData(dataPoolId);
|
PoolEntryIF* readOut = glob::dataPool.getRawData(dataPoolId);
|
||||||
if (readOut != nullptr) {
|
if (readOut != nullptr) {
|
||||||
@ -75,7 +89,21 @@ void PoolRawAccess::handleReadError(ReturnValue_t result) {
|
|||||||
memset(value, 0, sizeof(value));
|
memset(value, 0, sizeof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PoolRawAccess::commit() {
|
ReturnValue_t PoolRawAccess::commit(uint32_t lockTimeout) {
|
||||||
|
ReturnValue_t result = glob::dataPool.lockDataPool(lockTimeout);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = commitWithoutLock();
|
||||||
|
ReturnValue_t unlockResult = glob::dataPool.unlockDataPool();
|
||||||
|
if(unlockResult != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "GlobPoolVar::read: Could not unlock global data pool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PoolRawAccess::commitWithoutLock() {
|
||||||
PoolEntryIF* write_back = glob::dataPool.getRawData(dataPoolId);
|
PoolEntryIF* write_back = glob::dataPool.getRawData(dataPoolId);
|
||||||
if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
|
if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
|
||||||
write_back->setValid(valid);
|
write_back->setValid(valid);
|
||||||
@ -189,7 +217,7 @@ bool PoolRawAccess::isValid() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoolRawAccess::setValid(uint8_t valid) {
|
void PoolRawAccess::setValid(bool valid) {
|
||||||
this->valid = valid;
|
this->valid = valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
void setValid(uint8_t valid);
|
void setValid(bool valid);
|
||||||
/**
|
/**
|
||||||
* Getter for the remaining size.
|
* Getter for the remaining size.
|
||||||
*/
|
*/
|
||||||
@ -135,31 +135,49 @@ public:
|
|||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
bool bigEndian);
|
bool bigEndian);
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* @brief This is a call to read the value from the global data pool.
|
* @brief This is a call to read the value from the global data pool.
|
||||||
* @details When executed, this operation tries to fetch the pool entry with matching
|
* @details
|
||||||
* data pool id from the global data pool and copies the value and the valid
|
* When executed, this operation tries to fetch the pool entry with matching
|
||||||
* information to its local attributes. In case of a failure (wrong type or
|
* data pool id from the global data pool and copies the value and the valid
|
||||||
* pool id not found), the variable is set to zero and invalid.
|
* information to its local attributes. In case of a failure (wrong type or
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself !
|
* pool id not found), the variable is set to zero and invalid.
|
||||||
* If reading from the data pool without information about the type is desired,
|
* The call is protected by a lock of the global data pool.
|
||||||
* initialize the raw pool access by supplying a data set and using the data set
|
|
||||||
* read function, which calls this read function.
|
|
||||||
* @return -@c RETURN_OK Read successfull
|
* @return -@c RETURN_OK Read successfull
|
||||||
* -@c READ_TYPE_TOO_LARGE
|
* -@c READ_TYPE_TOO_LARGE
|
||||||
* -@c READ_INDEX_TOO_LARGE
|
* -@c READ_INDEX_TOO_LARGE
|
||||||
* -@c READ_ENTRY_NON_EXISTENT
|
* -@c READ_ENTRY_NON_EXISTENT
|
||||||
*/
|
*/
|
||||||
ReturnValue_t read();
|
ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
/**
|
/**
|
||||||
* @brief The commit call writes back the variable's value to the data pool.
|
* @brief The commit call writes back the variable's value to the data pool.
|
||||||
* @details It checks type and size, as well as if the variable is writable. If so,
|
* @details
|
||||||
* the value is copied and the valid flag is automatically set to "valid".
|
* It checks type and size, as well as if the variable is writable. If so,
|
||||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
* the value is copied and the valid flag is automatically set to "valid".
|
||||||
|
* The call is protected by a lock of the global data pool.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ReturnValue_t commit();
|
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
ReturnValue_t handleReadOut(PoolEntryIF* read_out);
|
ReturnValue_t handleReadOut(PoolEntryIF* read_out);
|
||||||
void handleReadError(ReturnValue_t result);
|
void handleReadError(ReturnValue_t result);
|
||||||
|
Loading…
Reference in New Issue
Block a user