updated pool data set base
This commit is contained in:
parent
7b3616c41f
commit
8dec4c9311
@ -44,7 +44,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
|||||||
|
|
||||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||||
const size_t maxNumberOfVariables):
|
const size_t maxNumberOfVariables):
|
||||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||||
sid.objectId);
|
sid.objectId);
|
||||||
if(hkOwner != nullptr) {
|
if(hkOwner != nullptr) {
|
||||||
@ -96,15 +96,22 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
|||||||
SerializeIF::Endianness streamEndianness) const {
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
const uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
const uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||||
|
uint8_t* validityPtr = nullptr;
|
||||||
|
#ifdef _MSC_VER
|
||||||
/* Use a std::vector here because MSVC will (rightly) not create a fixed size array
|
/* Use a std::vector here because MSVC will (rightly) not create a fixed size array
|
||||||
with a non constant size specifier */
|
with a non constant size specifier */
|
||||||
std::vector<uint8_t> validityMask(validityMaskSize);
|
std::vector<uint8_t> validityMask(validityMaskSize);
|
||||||
|
validityPtr = validityMask.data();
|
||||||
|
#else
|
||||||
|
uint8_t validityMask[validityMaskSize];
|
||||||
|
validityPtr = validityMask;
|
||||||
|
#endif
|
||||||
uint8_t validBufferIndex = 0;
|
uint8_t validBufferIndex = 0;
|
||||||
uint8_t validBufferIndexBit = 0;
|
uint8_t validBufferIndexBit = 0;
|
||||||
for (uint16_t count = 0; count < fillCount; count++) {
|
for (uint16_t count = 0; count < fillCount; count++) {
|
||||||
if(registeredVariables[count]->isValid()) {
|
if(registeredVariables[count]->isValid()) {
|
||||||
/* Set bit at correct position */
|
/* Set bit at correct position */
|
||||||
bitutil::bitSet(validityMask.data() + validBufferIndex, validBufferIndexBit);
|
bitutil::bitSet(validityMask + validBufferIndex, validBufferIndexBit);
|
||||||
}
|
}
|
||||||
if(validBufferIndexBit == 7) {
|
if(validBufferIndexBit == 7) {
|
||||||
validBufferIndex ++;
|
validBufferIndex ++;
|
||||||
@ -125,7 +132,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
|||||||
return SerializeIF::BUFFER_TOO_SHORT;
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
// copy validity buffer to end
|
// copy validity buffer to end
|
||||||
std::memcpy(*buffer, validityMask.data(), validityMaskSize);
|
std::memcpy(*buffer, validityPtr, validityMaskSize);
|
||||||
*size += validityMaskSize;
|
*size += validityMaskSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -264,11 +271,9 @@ bool LocalPoolDataSetBase::getReportingEnabled() const {
|
|||||||
return reportingEnabled;
|
return reportingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPoolDataSetBase::initializePeriodicHelper(
|
void LocalPoolDataSetBase::initializePeriodicHelper(float collectionInterval,
|
||||||
float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
dur_millis_t minimumPeriodicInterval, uint8_t nonDiagIntervalFactor) {
|
||||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor) {
|
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval, nonDiagIntervalFactor);
|
||||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval,
|
|
||||||
isDiagnostics, nonDiagIntervalFactor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPoolDataSetBase::setChanged(bool changed) {
|
void LocalPoolDataSetBase::setChanged(bool changed) {
|
||||||
@ -308,3 +313,12 @@ void LocalPoolDataSetBase::setAllVariablesReadOnly() {
|
|||||||
registeredVariables[idx]->setReadWriteMode(pool_rwm_t::VAR_READ);
|
registeredVariables[idx]->setReadWriteMode(pool_rwm_t::VAR_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float LocalPoolDataSetBase::getCollectionInterval() const {
|
||||||
|
if(periodicHelper != nullptr) {
|
||||||
|
return periodicHelper->getCollectionIntervalInSeconds();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -166,6 +166,16 @@ public:
|
|||||||
|
|
||||||
object_id_t getCreatorObjectId();
|
object_id_t getCreatorObjectId();
|
||||||
|
|
||||||
|
bool getReportingEnabled() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current periodic HK generation interval this set
|
||||||
|
* belongs to a HK manager and the interval is not 0. Otherwise,
|
||||||
|
* returns 0.0
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
float getCollectionInterval() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sid_t sid;
|
sid_t sid;
|
||||||
//! This mutex is used if the data is created by one object only.
|
//! This mutex is used if the data is created by one object only.
|
||||||
@ -180,11 +190,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
bool reportingEnabled = false;
|
bool reportingEnabled = false;
|
||||||
void setReportingEnabled(bool enabled);
|
void setReportingEnabled(bool enabled);
|
||||||
bool getReportingEnabled() const;
|
|
||||||
|
|
||||||
void initializePeriodicHelper(float collectionInterval,
|
void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||||
dur_millis_t minimumPeriodicInterval,
|
uint8_t nonDiagIntervalFactor = 5);
|
||||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the valid state of a dataset is always relevant to the whole
|
* If the valid state of a dataset is always relevant to the whole
|
||||||
|
Loading…
Reference in New Issue
Block a user