From f766398b20a1c148f63d10eaea70aad46bf2f3a2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 8 Aug 2020 12:49:20 +0200 Subject: [PATCH] some bugfixes --- datapoollocal/LocalDataSet.cpp | 70 +------------------ datapoollocal/LocalDataSet.h | 2 +- ...taSetBase.cpp => LocalPoolDataSetBase.cpp} | 2 +- datapoollocal/SharedLocalDataSet.cpp | 2 +- datapoollocal/StaticLocalDataSet.h | 4 +- 5 files changed, 6 insertions(+), 74 deletions(-) rename datapoollocal/{LocalDataSetBase.cpp => LocalPoolDataSetBase.cpp} (98%) diff --git a/datapoollocal/LocalDataSet.cpp b/datapoollocal/LocalDataSet.cpp index d91c93e9..84ed2ae2 100644 --- a/datapoollocal/LocalDataSet.cpp +++ b/datapoollocal/LocalDataSet.cpp @@ -33,73 +33,5 @@ LocalDataSet::LocalDataSet(object_id_t ownerId, hkManager = hkOwner->getHkManagerHandle(); } -LocalDataSet::~LocalDataSet() { -} +LocalDataSet::~LocalDataSet() {} -ReturnValue_t LocalDataSet::lockDataPool(uint32_t timeoutMs) { - MutexIF* mutex = hkManager->getMutexHandle(); - return mutex->lockMutex(MutexIF::TimeoutType::WAITING, timeoutMs); -} - -ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer, - size_t *size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - uint8_t validityMaskSize = std::ceil(static_cast(fillCount)/8.0); - uint8_t validityMask[validityMaskSize]; - uint8_t validBufferIndex = 0; - uint8_t validBufferIndexBit = 0; - for (uint16_t count = 0; count < fillCount; count++) { - if(registeredVariables[count]->isValid()) { - // set validity buffer here. - this->bitSetter(validityMask + validBufferIndex, - validBufferIndexBit); - if(validBufferIndexBit == 7) { - validBufferIndex ++; - validBufferIndexBit = 0; - } - else { - validBufferIndexBit ++; - } - } - result = registeredVariables[count]->serialize(buffer, size, maxSize, - streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - // copy validity buffer to end - std::memcpy(*buffer, validityMask, validityMaskSize); - *size += validityMaskSize; - return result; -} - -ReturnValue_t LocalDataSet::unlockDataPool() { - MutexIF* mutex = hkManager->getMutexHandle(); - return mutex->unlockMutex(); -} - -ReturnValue_t LocalDataSet::serializeLocalPoolIds(uint8_t** buffer, - size_t* size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const { - for (uint16_t count = 0; count < fillCount; count++) { - lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); - auto result = SerializeAdapter::serialize(¤tPoolId, buffer, - size, maxSize, streamEndianness); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" - " error!" << std::endl; - return result; - } - } - return HasReturnvaluesIF::RETURN_OK; -} - -void LocalDataSet::bitSetter(uint8_t* byte, uint8_t position) const { - if(position > 7) { - sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; - return; - } - uint8_t shiftNumber = position + (7 - 2 * position); - *byte |= 1 << shiftNumber; -} diff --git a/datapoollocal/LocalDataSet.h b/datapoollocal/LocalDataSet.h index e6bd2012..820818d7 100644 --- a/datapoollocal/LocalDataSet.h +++ b/datapoollocal/LocalDataSet.h @@ -7,7 +7,7 @@ class LocalDataSet: public LocalDataSetBase { public: LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize); LocalDataSet(object_id_t owner, const size_t maxSize); - virtual~ LocalDataSet() {}; + virtual~ LocalDataSet(); //! Copying forbidden for now. LocalDataSet(const LocalDataSet&) = delete; diff --git a/datapoollocal/LocalDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp similarity index 98% rename from datapoollocal/LocalDataSetBase.cpp rename to datapoollocal/LocalPoolDataSetBase.cpp index f490ff67..7c2c0632 100644 --- a/datapoollocal/LocalDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -36,7 +36,7 @@ LocalDataSetBase::~LocalDataSetBase() { ReturnValue_t LocalDataSetBase::lockDataPool(uint32_t timeoutMs) { MutexIF* mutex = hkManager->getMutexHandle(); - return mutex->lockMutex(timeoutMs); + return mutex->lockMutex(MutexIF::TimeoutType::WAITING, timeoutMs); } ReturnValue_t LocalDataSetBase::serializeWithValidityBuffer(uint8_t **buffer, diff --git a/datapoollocal/SharedLocalDataSet.cpp b/datapoollocal/SharedLocalDataSet.cpp index 6f355a8a..c2b1d21b 100644 --- a/datapoollocal/SharedLocalDataSet.cpp +++ b/datapoollocal/SharedLocalDataSet.cpp @@ -8,7 +8,7 @@ SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, object_id_t owner, } ReturnValue_t SharedLocalDataSet::lockDataset(dur_millis_t mutexTimeout) { - return datasetLock->lockMutex(mutexTimeout); + return datasetLock->lockMutex(MutexIF::TimeoutType::WAITING, mutexTimeout); } ReturnValue_t SharedLocalDataSet::unlockDataset() { diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index fbe1545f..b381ed41 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -1,6 +1,6 @@ #ifndef FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #define FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ -#include +#include #include #include @@ -20,7 +20,7 @@ public: LocalDataSetBase(owner, poolVarList.data(), NUM_VARIABLES) { } - virtual~ StaticLocalDataSet(); + virtual~ StaticLocalDataSet() {}; private: std::array poolVarList; };