consistency changes
This commit is contained in:
parent
fdef8bc22b
commit
a4e0f15dac
@ -9,16 +9,16 @@ class MutexIF;
|
||||
*/
|
||||
class AccessPoolManagerIF {
|
||||
public:
|
||||
virtual ~AccessPoolManagerIF() {};
|
||||
virtual ~AccessPoolManagerIF() {};
|
||||
|
||||
virtual MutexIF* getLocalPoolMutex() = 0;
|
||||
virtual MutexIF* getLocalPoolMutex() = 0;
|
||||
|
||||
/**
|
||||
* Can be used to get a handle to the local data pool manager.
|
||||
* This function is protected because it should only be used by the
|
||||
* class imlementing the interface.
|
||||
*/
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
|
||||
/**
|
||||
* Can be used to get a handle to the local data pool manager.
|
||||
* This function is protected because it should only be used by the
|
||||
* class imlementing the interface.
|
||||
*/
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -30,32 +30,32 @@ class LocalDataPoolManager;
|
||||
*
|
||||
*/
|
||||
class HasLocalDataPoolIF {
|
||||
friend class HasLocalDpIFManagerAttorney;
|
||||
friend class HasLocalDpIFUserAttorney;
|
||||
friend class HasLocalDpIFManagerAttorney;
|
||||
friend class HasLocalDpIFUserAttorney;
|
||||
public:
|
||||
virtual~ HasLocalDataPoolIF() {};
|
||||
virtual~ HasLocalDataPoolIF() {};
|
||||
|
||||
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;
|
||||
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;
|
||||
|
||||
virtual object_id_t getObjectId() const = 0;
|
||||
virtual object_id_t getObjectId() const = 0;
|
||||
|
||||
/** Command queue for housekeeping messages. */
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
/** Command queue for housekeeping messages. */
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
|
||||
/**
|
||||
* Is used by pool owner to initialize the pool map once
|
||||
* The manager instance shall also be passed to this function.
|
||||
* It can be used to subscribe for periodic packets for for updates.
|
||||
*/
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) = 0;
|
||||
/**
|
||||
* Is used by pool owner to initialize the pool map once
|
||||
* The manager instance shall also be passed to this function.
|
||||
* It can be used to subscribe for periodic packets for for updates.
|
||||
*/
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) = 0;
|
||||
|
||||
/**
|
||||
* Returns the minimum sampling frequency in milliseconds, which will
|
||||
* usually be the period the pool owner performs its periodic operation.
|
||||
* @return
|
||||
*/
|
||||
virtual uint32_t getPeriodicOperationFrequency() const = 0;
|
||||
/**
|
||||
* Returns the minimum sampling frequency in milliseconds, which will
|
||||
* usually be the period the pool owner performs its periodic operation.
|
||||
* @return
|
||||
*/
|
||||
virtual uint32_t getPeriodicOperationFrequency() const = 0;
|
||||
|
||||
/**
|
||||
* @brief This function will be called by the manager if an update
|
||||
@ -67,7 +67,7 @@ public:
|
||||
* the IPC store with this store ID.
|
||||
*/
|
||||
virtual void handleChangedDataset(sid_t sid,
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
|
||||
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -85,68 +85,68 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* These function can be implemented by pool owner, if they are required
|
||||
* and used by the housekeeping message interface.
|
||||
* */
|
||||
virtual ReturnValue_t addDataSet(sid_t sid) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
virtual ReturnValue_t removeDataSet(sid_t sid) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
/**
|
||||
* These function can be implemented by pool owner, if they are required
|
||||
* and used by the housekeeping message interface.
|
||||
* */
|
||||
virtual ReturnValue_t addDataSet(sid_t sid) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
virtual ReturnValue_t removeDataSet(sid_t sid) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function can be used by data pool consumers to retrieve a handle
|
||||
* which allows subscriptions to dataset and variable updates in form of messages.
|
||||
* The consumers can then read the most recent variable value by calling read with
|
||||
* an own pool variable or set instance or using the deserialized snapshot data.
|
||||
* @return
|
||||
*/
|
||||
virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() = 0;
|
||||
/**
|
||||
* This function can be used by data pool consumers to retrieve a handle
|
||||
* which allows subscriptions to dataset and variable updates in form of messages.
|
||||
* The consumers can then read the most recent variable value by calling read with
|
||||
* an own pool variable or set instance or using the deserialized snapshot data.
|
||||
* @return
|
||||
*/
|
||||
virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Accessor handle required for internal handling. Not intended for users and therefore
|
||||
* declared protected. Users should instead use pool variables, sets or the subscription
|
||||
* interface to access pool entries.
|
||||
* @return
|
||||
*/
|
||||
virtual AccessPoolManagerIF* getAccessorHandle() = 0;
|
||||
/**
|
||||
* Accessor handle required for internal handling. Not intended for users and therefore
|
||||
* declared protected. Users should instead use pool variables, sets or the subscription
|
||||
* interface to access pool entries.
|
||||
* @return
|
||||
*/
|
||||
virtual AccessPoolManagerIF* getAccessorHandle() = 0;
|
||||
|
||||
/**
|
||||
* This function is used by the pool manager to get a valid dataset
|
||||
/**
|
||||
* This function is used by the pool manager to get a valid dataset
|
||||
* from a SID. This function is protected to prevent users from
|
||||
* using raw data set pointers which could not be thread-safe. Users
|
||||
* should use the #ProvidesDataPoolSubscriptionIF.
|
||||
* @param sid Corresponding structure ID
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) = 0;
|
||||
* @param sid Corresponding structure ID
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) = 0;
|
||||
|
||||
/**
|
||||
* Similar to the function above, but used to get a local pool variable
|
||||
* handle. This is only needed for update notifications, so it is not
|
||||
* defined as abstract. This function is protected to prevent users from
|
||||
/**
|
||||
* Similar to the function above, but used to get a local pool variable
|
||||
* handle. This is only needed for update notifications, so it is not
|
||||
* defined as abstract. This function is protected to prevent users from
|
||||
* using raw pool variable pointers which could not be thread-safe.
|
||||
* Users should use the #ProvidesDataPoolSubscriptionIF.
|
||||
* @param localPoolId
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
|
||||
* @param localPoolId
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
|
||||
<< ". Returning nullptr!" << std::endl;
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
|
||||
<< ". Returning nullptr!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("HasLocalDataPoolIF::getPoolObjectHandle: "
|
||||
"Not overriden. Returning nullptr!\n");
|
||||
sif::printWarning("HasLocalDataPoolIF::getPoolObjectHandle: "
|
||||
"Not overriden. Returning nullptr!\n");
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ */
|
||||
|
@ -9,13 +9,13 @@ LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, uint32_t setId,
|
||||
const size_t maxNumberOfVariables):
|
||||
LocalPoolDataSetBase(hkOwner, setId, nullptr, maxNumberOfVariables),
|
||||
poolVarList(maxNumberOfVariables) {
|
||||
this->setContainer(poolVarList.data());
|
||||
this->setContainer(poolVarList.data());
|
||||
}
|
||||
|
||||
LocalDataSet::LocalDataSet(sid_t sid, const size_t maxNumberOfVariables):
|
||||
LocalPoolDataSetBase(sid, nullptr, maxNumberOfVariables),
|
||||
poolVarList(maxNumberOfVariables) {
|
||||
this->setContainer(poolVarList.data());
|
||||
poolVarList(maxNumberOfVariables) {
|
||||
this->setContainer(poolVarList.data());
|
||||
}
|
||||
|
||||
LocalDataSet::~LocalDataSet() {}
|
||||
|
@ -7,7 +7,7 @@
|
||||
class LocalDataSet: public LocalPoolDataSetBase {
|
||||
public:
|
||||
LocalDataSet(HasLocalDataPoolIF* hkOwner, uint32_t setId,
|
||||
const size_t maxSize);
|
||||
const size_t maxSize);
|
||||
LocalDataSet(sid_t sid, const size_t maxSize);
|
||||
virtual~ LocalDataSet();
|
||||
|
||||
|
@ -11,309 +11,309 @@
|
||||
#include <cstring>
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool periodicHandling):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
if(hkOwner == nullptr) {
|
||||
// Configuration error.
|
||||
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool periodicHandling):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
if(hkOwner == nullptr) {
|
||||
// Configuration error.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
<< "invalid!" << std::endl;
|
||||
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
<< "invalid!" << std::endl;
|
||||
#else
|
||||
sif::printError("LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
"invalid!\n\r");
|
||||
sif::printError("LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
"invalid!\n\r");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
|
||||
if(accessor != nullptr) {
|
||||
poolManager = accessor->getHkManagerHandle();
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
}
|
||||
if(accessor != nullptr) {
|
||||
poolManager = accessor->getHkManagerHandle();
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
}
|
||||
|
||||
this->sid.objectId = hkOwner->getObjectId();
|
||||
this->sid.ownerSetId = setId;
|
||||
this->sid.objectId = hkOwner->getObjectId();
|
||||
this->sid.ownerSetId = setId;
|
||||
|
||||
// Data creators get a periodic helper for periodic HK data generation.
|
||||
if(periodicHandling) {
|
||||
periodicHelper = new PeriodicHousekeepingHelper(this);
|
||||
}
|
||||
// Data creators get a periodic helper for periodic HK data generation.
|
||||
if(periodicHandling) {
|
||||
periodicHelper = new PeriodicHousekeepingHelper(this);
|
||||
}
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
|
||||
PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||
sid.objectId);
|
||||
if(hkOwner != nullptr) {
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
if(accessor != nullptr) {
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
}
|
||||
}
|
||||
PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||
sid.objectId);
|
||||
if(hkOwner != nullptr) {
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
if(accessor != nullptr) {
|
||||
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
|
||||
}
|
||||
}
|
||||
|
||||
this->sid = sid;
|
||||
this->sid = sid;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(
|
||||
PoolVariableIF **registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool protectEveryReadCommitCall):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
this->setReadCommitProtectionBehaviour(protectEveryReadCommitCall);
|
||||
PoolVariableIF **registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool protectEveryReadCommitCall):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
this->setReadCommitProtectionBehaviour(protectEveryReadCommitCall);
|
||||
}
|
||||
|
||||
|
||||
LocalPoolDataSetBase::~LocalPoolDataSetBase() {
|
||||
if(periodicHelper != nullptr) {
|
||||
delete periodicHelper;
|
||||
}
|
||||
if(periodicHelper != nullptr) {
|
||||
delete periodicHelper;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::lockDataPool(
|
||||
MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
if(mutexIfSingleDataCreator != nullptr) {
|
||||
return mutexIfSingleDataCreator->lockMutex(timeoutType, timeoutMs);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
if(mutexIfSingleDataCreator != nullptr) {
|
||||
return mutexIfSingleDataCreator->lockMutex(timeoutType, timeoutMs);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::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<float>(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;
|
||||
}
|
||||
}
|
||||
size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
uint8_t validityMaskSize = std::ceil(static_cast<float>(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;
|
||||
}
|
||||
}
|
||||
|
||||
if(*size + validityMaskSize > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
// copy validity buffer to end
|
||||
std::memcpy(*buffer, validityMask, validityMaskSize);
|
||||
*size += validityMaskSize;
|
||||
return result;
|
||||
if(*size + validityMaskSize > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
// copy validity buffer to end
|
||||
std::memcpy(*buffer, validityMask, validityMaskSize);
|
||||
*size += validityMaskSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer(
|
||||
const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
result = registeredVariables[count]->deSerialize(buffer, size,
|
||||
streamEndianness);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
result = registeredVariables[count]->deSerialize(buffer, size,
|
||||
streamEndianness);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if(*size < std::ceil(static_cast<float>(fillCount) / 8.0)) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
if(*size < std::ceil(static_cast<float>(fillCount) / 8.0)) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
||||
uint8_t validBufferIndex = 0;
|
||||
uint8_t validBufferIndexBit = 0;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
// set validity buffer here.
|
||||
bool nextVarValid = this->bitGetter(*buffer +
|
||||
validBufferIndex, validBufferIndexBit);
|
||||
registeredVariables[count]->setValid(nextVarValid);
|
||||
uint8_t validBufferIndex = 0;
|
||||
uint8_t validBufferIndexBit = 0;
|
||||
for (uint16_t count = 0; count < fillCount; count++) {
|
||||
// set validity buffer here.
|
||||
bool nextVarValid = this->bitGetter(*buffer +
|
||||
validBufferIndex, validBufferIndexBit);
|
||||
registeredVariables[count]->setValid(nextVarValid);
|
||||
|
||||
if(validBufferIndexBit == 7) {
|
||||
validBufferIndex ++;
|
||||
validBufferIndexBit = 0;
|
||||
}
|
||||
else {
|
||||
validBufferIndexBit ++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if(validBufferIndexBit == 7) {
|
||||
validBufferIndex ++;
|
||||
validBufferIndexBit = 0;
|
||||
}
|
||||
else {
|
||||
validBufferIndexBit ++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::unlockDataPool() {
|
||||
if(mutexIfSingleDataCreator != nullptr) {
|
||||
return mutexIfSingleDataCreator->unlockMutex();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
if(mutexIfSingleDataCreator != nullptr) {
|
||||
return mutexIfSingleDataCreator->unlockMutex();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness,
|
||||
bool serializeFillCount) const {
|
||||
// Serialize as uint8_t
|
||||
uint8_t fillCount = this->fillCount;
|
||||
if(serializeFillCount) {
|
||||
SerializeAdapter::serialize(&fillCount, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
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) {
|
||||
size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness,
|
||||
bool serializeFillCount) const {
|
||||
// Serialize as uint8_t
|
||||
uint8_t fillCount = this->fillCount;
|
||||
if(serializeFillCount) {
|
||||
SerializeAdapter::serialize(&fillCount, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
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) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
<< "Serialization error!" << std::endl;
|
||||
sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
<< "Serialization error!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
"Serialization error!\n\r");
|
||||
sif::printWarning("LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
"Serialization error!\n\r");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
uint8_t LocalPoolDataSetBase::getLocalPoolIdsSerializedSize(
|
||||
bool serializeFillCount) const {
|
||||
if(serializeFillCount) {
|
||||
return fillCount * sizeof(lp_id_t) + sizeof(uint8_t);
|
||||
}
|
||||
else {
|
||||
return fillCount * sizeof(lp_id_t);
|
||||
}
|
||||
bool serializeFillCount) const {
|
||||
if(serializeFillCount) {
|
||||
return fillCount * sizeof(lp_id_t) + sizeof(uint8_t);
|
||||
}
|
||||
else {
|
||||
return fillCount * sizeof(lp_id_t);
|
||||
}
|
||||
}
|
||||
|
||||
size_t LocalPoolDataSetBase::getSerializedSize() const {
|
||||
if(withValidityBuffer) {
|
||||
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||
return validityMaskSize + PoolDataSetBase::getSerializedSize();
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::getSerializedSize();
|
||||
}
|
||||
if(withValidityBuffer) {
|
||||
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||
return validityMaskSize + PoolDataSetBase::getSerializedSize();
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::getSerializedSize();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setValidityBufferGeneration(
|
||||
bool withValidityBuffer) {
|
||||
this->withValidityBuffer = withValidityBuffer;
|
||||
bool withValidityBuffer) {
|
||||
this->withValidityBuffer = withValidityBuffer;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::deSerialize(const uint8_t **buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||
if(withValidityBuffer) {
|
||||
return this->deSerializeWithValidityBuffer(buffer, size,
|
||||
streamEndianness);
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::deSerialize(buffer, size, streamEndianness);
|
||||
}
|
||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||
if(withValidityBuffer) {
|
||||
return this->deSerializeWithValidityBuffer(buffer, size,
|
||||
streamEndianness);
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::deSerialize(buffer, size, streamEndianness);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, SerializeIF::Endianness streamEndianness) const {
|
||||
if(withValidityBuffer) {
|
||||
return this->serializeWithValidityBuffer(buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
size_t maxSize, SerializeIF::Endianness streamEndianness) const {
|
||||
if(withValidityBuffer) {
|
||||
return this->serializeWithValidityBuffer(buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
}
|
||||
else {
|
||||
return PoolDataSetBase::serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
|
||||
if(position > 7) {
|
||||
if(position > 7) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!"
|
||||
<< std::endl;
|
||||
sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolDataSetBase::bitSetter: "
|
||||
"Invalid position!\n\r");
|
||||
sif::printWarning("LocalPoolDataSetBase::bitSetter: "
|
||||
"Invalid position!\n\r");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte |= 1 << shiftNumber;
|
||||
return;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
*byte |= 1 << shiftNumber;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setDiagnostic(bool isDiagnostics) {
|
||||
this->diagnostic = isDiagnostics;
|
||||
this->diagnostic = isDiagnostics;
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::isDiagnostics() const {
|
||||
return diagnostic;
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) {
|
||||
this->reportingEnabled = reportingEnabled;
|
||||
this->reportingEnabled = reportingEnabled;
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::getReportingEnabled() const {
|
||||
return reportingEnabled;
|
||||
return reportingEnabled;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::initializePeriodicHelper(
|
||||
float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor) {
|
||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval,
|
||||
isDiagnostics, nonDiagIntervalFactor);
|
||||
float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor) {
|
||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval,
|
||||
isDiagnostics, nonDiagIntervalFactor);
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setChanged(bool changed) {
|
||||
this->changed = changed;
|
||||
this->changed = changed;
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::hasChanged() const {
|
||||
return changed;
|
||||
return changed;
|
||||
}
|
||||
|
||||
sid_t LocalPoolDataSetBase::getSid() const {
|
||||
return sid;
|
||||
return sid;
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
|
||||
uint8_t position) const {
|
||||
if(position > 7) {
|
||||
uint8_t position) const {
|
||||
if(position > 7) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Pool Raw Access: Bit setting invalid position"
|
||||
<< std::endl;
|
||||
sif::debug << "Pool Raw Access: Bit setting invalid position"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
return *byte & (1 << shiftNumber);
|
||||
return false;
|
||||
}
|
||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||
return *byte & (1 << shiftNumber);
|
||||
}
|
||||
|
||||
bool LocalPoolDataSetBase::isValid() const {
|
||||
return this->valid;
|
||||
return this->valid;
|
||||
}
|
||||
|
||||
void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) {
|
||||
if(setEntriesRecursively) {
|
||||
for(size_t idx = 0; idx < this->getFillCount(); idx++) {
|
||||
registeredVariables[idx] -> setValid(valid);
|
||||
}
|
||||
}
|
||||
this->valid = valid;
|
||||
if(setEntriesRecursively) {
|
||||
for(size_t idx = 0; idx < this->getFillCount(); idx++) {
|
||||
registeredVariables[idx] -> setValid(valid);
|
||||
}
|
||||
}
|
||||
this->valid = valid;
|
||||
}
|
||||
|
||||
object_id_t LocalPoolDataSetBase::getCreatorObjectId() {
|
||||
if(poolManager != nullptr) {
|
||||
return poolManager->getCreatorObjectId();
|
||||
}
|
||||
return objects::NO_OBJECT;
|
||||
if(poolManager != nullptr) {
|
||||
return poolManager->getCreatorObjectId();
|
||||
}
|
||||
return objects::NO_OBJECT;
|
||||
}
|
||||
|
@ -41,184 +41,185 @@ class PeriodicHousekeepingHelper;
|
||||
*
|
||||
* @ingroup data_pool
|
||||
*/
|
||||
class LocalPoolDataSetBase: public PoolDataSetBase,
|
||||
class LocalPoolDataSetBase:
|
||||
public PoolDataSetBase,
|
||||
public MarkChangedIF {
|
||||
friend class LocalPoolDataSetAttorney;
|
||||
friend class PeriodicHousekeepingHelper;
|
||||
friend class LocalPoolDataSetAttorney;
|
||||
friend class PeriodicHousekeepingHelper;
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for the creator of local pool data.
|
||||
* @details
|
||||
* This constructor also initializes the components required for
|
||||
* periodic handling.
|
||||
*/
|
||||
LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool periodicHandling = true);
|
||||
/**
|
||||
* @brief Constructor for the creator of local pool data.
|
||||
* @details
|
||||
* This constructor also initializes the components required for
|
||||
* periodic handling.
|
||||
*/
|
||||
LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables, bool periodicHandling = true);
|
||||
|
||||
/**
|
||||
* @brief Constructor for users of the local pool data, which need
|
||||
* to access data created by one (!) HK manager.
|
||||
* @details
|
||||
* Unlike the first constructor, no component for periodic handling
|
||||
* will be initiated.
|
||||
* @param sid Unique identifier of dataset consisting of object ID and
|
||||
* set ID.
|
||||
* @param registeredVariablesArray
|
||||
* @param maxNumberOfVariables
|
||||
*/
|
||||
LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables);
|
||||
/**
|
||||
* @brief Constructor for users of the local pool data, which need
|
||||
* to access data created by one (!) HK manager.
|
||||
* @details
|
||||
* Unlike the first constructor, no component for periodic handling
|
||||
* will be initiated.
|
||||
* @param sid Unique identifier of dataset consisting of object ID and
|
||||
* set ID.
|
||||
* @param registeredVariablesArray
|
||||
* @param maxNumberOfVariables
|
||||
*/
|
||||
LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables);
|
||||
|
||||
/**
|
||||
* @brief Simple constructor, if the dataset is not the owner by
|
||||
* a class with a HK manager.
|
||||
* @details
|
||||
* This constructor won't create components required for periodic handling
|
||||
* and it also won't try to deduce the HK manager because no SID is
|
||||
* supplied. This function should therefore be called by classes which need
|
||||
* to access pool variables from different creators.
|
||||
*
|
||||
* If the class is intended to access pool variables from different
|
||||
* creators, the third argument should be set to true. The mutex
|
||||
* properties can be set with #setReadCommitProtectionBehaviour .
|
||||
* @param registeredVariablesArray
|
||||
* @param maxNumberOfVariables
|
||||
* @param protectEveryReadCommitCall If the pool variables are created by
|
||||
* multiple creators, this flag can be set to protect all read and
|
||||
* commit calls separately.
|
||||
*/
|
||||
LocalPoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables,
|
||||
bool protectEveryReadCommitCall = true);
|
||||
/**
|
||||
* @brief Simple constructor, if the dataset is not the owner by
|
||||
* a class with a HK manager.
|
||||
* @details
|
||||
* This constructor won't create components required for periodic handling
|
||||
* and it also won't try to deduce the HK manager because no SID is
|
||||
* supplied. This function should therefore be called by classes which need
|
||||
* to access pool variables from different creators.
|
||||
*
|
||||
* If the class is intended to access pool variables from different
|
||||
* creators, the third argument should be set to true. The mutex
|
||||
* properties can be set with #setReadCommitProtectionBehaviour .
|
||||
* @param registeredVariablesArray
|
||||
* @param maxNumberOfVariables
|
||||
* @param protectEveryReadCommitCall If the pool variables are created by
|
||||
* multiple creators, this flag can be set to protect all read and
|
||||
* commit calls separately.
|
||||
*/
|
||||
LocalPoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables,
|
||||
bool protectEveryReadCommitCall = true);
|
||||
|
||||
/**
|
||||
* @brief The destructor automatically manages writing the valid
|
||||
* information of variables.
|
||||
* @details
|
||||
* In case the data set was read out, but not committed(indicated by state),
|
||||
* the destructor parses all variables that are still registered to the set.
|
||||
* For each, the valid flag in the data pool is set to "invalid".
|
||||
*/
|
||||
~LocalPoolDataSetBase();
|
||||
/**
|
||||
* @brief The destructor automatically manages writing the valid
|
||||
* information of variables.
|
||||
* @details
|
||||
* In case the data set was read out, but not committed(indicated by state),
|
||||
* the destructor parses all variables that are still registered to the set.
|
||||
* For each, the valid flag in the data pool is set to "invalid".
|
||||
*/
|
||||
~LocalPoolDataSetBase();
|
||||
|
||||
void setValidityBufferGeneration(bool withValidityBuffer);
|
||||
void setValidityBufferGeneration(bool withValidityBuffer);
|
||||
|
||||
sid_t getSid() const;
|
||||
sid_t getSid() const;
|
||||
|
||||
/** SerializeIF overrides */
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const override;
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) override;
|
||||
size_t getSerializedSize() const override;
|
||||
/** SerializeIF overrides */
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const override;
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) override;
|
||||
size_t getSerializedSize() const override;
|
||||
|
||||
/**
|
||||
* Special version of the serilization function which appends a
|
||||
* validity buffer at the end. Each bit of this validity buffer
|
||||
* denotes whether the container data set entries are valid from left
|
||||
* to right, MSB first. (length = ceil(N/8), N = number of pool variables)
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param maxSize
|
||||
* @param bigEndian
|
||||
* @param withValidityBuffer
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t serializeWithValidityBuffer(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const;
|
||||
ReturnValue_t deSerializeWithValidityBuffer(const uint8_t** buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness);
|
||||
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness,
|
||||
bool serializeFillCount = true) const;
|
||||
uint8_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const;
|
||||
/**
|
||||
* Special version of the serilization function which appends a
|
||||
* validity buffer at the end. Each bit of this validity buffer
|
||||
* denotes whether the container data set entries are valid from left
|
||||
* to right, MSB first. (length = ceil(N/8), N = number of pool variables)
|
||||
* @param buffer
|
||||
* @param size
|
||||
* @param maxSize
|
||||
* @param bigEndian
|
||||
* @param withValidityBuffer
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t serializeWithValidityBuffer(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const;
|
||||
ReturnValue_t deSerializeWithValidityBuffer(const uint8_t** buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness);
|
||||
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer,
|
||||
size_t* size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness,
|
||||
bool serializeFillCount = true) const;
|
||||
uint8_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const;
|
||||
|
||||
/**
|
||||
* Set the dataset valid or invalid. These calls are mutex protected.
|
||||
* @param setEntriesRecursively
|
||||
* If this is true, all contained datasets will also be set recursively.
|
||||
*/
|
||||
void setValidity(bool valid, bool setEntriesRecursively);
|
||||
bool isValid() const override;
|
||||
/**
|
||||
* Set the dataset valid or invalid. These calls are mutex protected.
|
||||
* @param setEntriesRecursively
|
||||
* If this is true, all contained datasets will also be set recursively.
|
||||
*/
|
||||
void setValidity(bool valid, bool setEntriesRecursively);
|
||||
bool isValid() const override;
|
||||
|
||||
/**
|
||||
* These calls are mutex protected.
|
||||
* @param changed
|
||||
*/
|
||||
void setChanged(bool changed) override;
|
||||
bool hasChanged() const override;
|
||||
/**
|
||||
* These calls are mutex protected.
|
||||
* @param changed
|
||||
*/
|
||||
void setChanged(bool changed) override;
|
||||
bool hasChanged() const override;
|
||||
|
||||
object_id_t getCreatorObjectId();
|
||||
object_id_t getCreatorObjectId();
|
||||
protected:
|
||||
sid_t sid;
|
||||
//! This mutex is used if the data is created by one object only.
|
||||
MutexIF* mutexIfSingleDataCreator = nullptr;
|
||||
sid_t sid;
|
||||
//! This mutex is used if the data is created by one object only.
|
||||
MutexIF* mutexIfSingleDataCreator = nullptr;
|
||||
|
||||
bool diagnostic = false;
|
||||
void setDiagnostic(bool diagnostics);
|
||||
bool isDiagnostics() const;
|
||||
bool diagnostic = false;
|
||||
void setDiagnostic(bool diagnostics);
|
||||
bool isDiagnostics() const;
|
||||
|
||||
/**
|
||||
* Used for periodic generation.
|
||||
*/
|
||||
bool reportingEnabled = false;
|
||||
void setReportingEnabled(bool enabled);
|
||||
bool getReportingEnabled() const;
|
||||
/**
|
||||
* Used for periodic generation.
|
||||
*/
|
||||
bool reportingEnabled = false;
|
||||
void setReportingEnabled(bool enabled);
|
||||
bool getReportingEnabled() const;
|
||||
|
||||
void initializePeriodicHelper(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5);
|
||||
void initializePeriodicHelper(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval,
|
||||
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5);
|
||||
|
||||
/**
|
||||
* If the valid state of a dataset is always relevant to the whole
|
||||
* data set we can use this flag.
|
||||
*/
|
||||
bool valid = false;
|
||||
/**
|
||||
* If the valid state of a dataset is always relevant to the whole
|
||||
* data set we can use this flag.
|
||||
*/
|
||||
bool valid = false;
|
||||
|
||||
/**
|
||||
* Can be used to mark the dataset as changed, which is used
|
||||
* by the LocalDataPoolManager to send out update messages.
|
||||
*/
|
||||
bool changed = false;
|
||||
/**
|
||||
* Can be used to mark the dataset as changed, which is used
|
||||
* by the LocalDataPoolManager to send out update messages.
|
||||
*/
|
||||
bool changed = false;
|
||||
|
||||
/**
|
||||
* Specify whether the validity buffer is serialized too when serializing
|
||||
* or deserializing the packet. Each bit of the validity buffer will
|
||||
* contain the validity state of the pool variables from left to right.
|
||||
* The size of validity buffer thus will be ceil(N / 8) with N = number of
|
||||
* pool variables.
|
||||
*/
|
||||
bool withValidityBuffer = true;
|
||||
/**
|
||||
* Specify whether the validity buffer is serialized too when serializing
|
||||
* or deserializing the packet. Each bit of the validity buffer will
|
||||
* contain the validity state of the pool variables from left to right.
|
||||
* The size of validity buffer thus will be ceil(N / 8) with N = number of
|
||||
* pool variables.
|
||||
*/
|
||||
bool withValidityBuffer = true;
|
||||
|
||||
/**
|
||||
* @brief This is a small helper function to facilitate locking
|
||||
* the global data pool.
|
||||
* @details
|
||||
* It makes use of the lockDataPool method offered by the DataPool class.
|
||||
*/
|
||||
ReturnValue_t lockDataPool(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) override;
|
||||
/**
|
||||
* @brief This is a small helper function to facilitate locking
|
||||
* the global data pool.
|
||||
* @details
|
||||
* It makes use of the lockDataPool method offered by the DataPool class.
|
||||
*/
|
||||
ReturnValue_t lockDataPool(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) override;
|
||||
|
||||
/**
|
||||
* @brief This is a small helper function to facilitate
|
||||
* unlocking the global data pool
|
||||
* @details
|
||||
* It makes use of the freeDataPoolLock method offered by the DataPool class.
|
||||
*/
|
||||
ReturnValue_t unlockDataPool() override;
|
||||
/**
|
||||
* @brief This is a small helper function to facilitate
|
||||
* unlocking the global data pool
|
||||
* @details
|
||||
* It makes use of the freeDataPoolLock method offered by the DataPool class.
|
||||
*/
|
||||
ReturnValue_t unlockDataPool() override;
|
||||
|
||||
/**
|
||||
* Set n-th bit of a byte, with n being the position from 0
|
||||
* (most significant bit) to 7 (least significant bit)
|
||||
*/
|
||||
void bitSetter(uint8_t* byte, uint8_t position) const;
|
||||
bool bitGetter(const uint8_t* byte, uint8_t position) const;
|
||||
/**
|
||||
* Set n-th bit of a byte, with n being the position from 0
|
||||
* (most significant bit) to 7 (least significant bit)
|
||||
*/
|
||||
void bitSetter(uint8_t* byte, uint8_t position) const;
|
||||
bool bitGetter(const uint8_t* byte, uint8_t position) const;
|
||||
|
||||
PeriodicHousekeepingHelper* periodicHelper = nullptr;
|
||||
LocalDataPoolManager* poolManager = nullptr;
|
||||
PeriodicHousekeepingHelper* periodicHelper = nullptr;
|
||||
LocalDataPoolManager* poolManager = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,128 +1,130 @@
|
||||
#include "LocalDataPoolManager.h"
|
||||
#include "LocalPoolObjectBase.h"
|
||||
#include "LocalDataPoolManager.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
#include "HasLocalDataPoolIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||
DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
|
||||
localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
|
||||
localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
if(hkOwner == nullptr) {
|
||||
}
|
||||
if(hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
|
||||
<< "owner is a invalid!" << std::endl;
|
||||
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
|
||||
<< "owner is a invalid!" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
hkManager = poolManAccessor->getHkManagerHandle();
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
hkManager = poolManAccessor->getHkManagerHandle();
|
||||
|
||||
if (dataSet != nullptr) {
|
||||
dataSet->registerVariable(this);
|
||||
}
|
||||
if (dataSet != nullptr) {
|
||||
dataSet->registerVariable(this);
|
||||
}
|
||||
}
|
||||
|
||||
LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF *dataSet,
|
||||
pool_rwm_t setReadWriteMode):
|
||||
localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
pool_rwm_t setReadWriteMode):
|
||||
localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
||||
if(hkOwner == nullptr) {
|
||||
}
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
||||
if(hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner did not "
|
||||
<< "implement the correct interface"
|
||||
<< " HasLocalDataPoolIF!" << std::endl;
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner did not "
|
||||
<< "implement the correct interface"
|
||||
<< " HasLocalDataPoolIF!" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
//hkManager = hkOwner->getHkManagerHandle();
|
||||
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
//hkManager = HasLocalDpIFUserAttorney::getHkManagerHandle(hkOwner);
|
||||
hkManager = poolManAccessor->getHkManagerHandle();
|
||||
if(dataSet != nullptr) {
|
||||
dataSet->registerVariable(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
if(accessor != nullptr) {
|
||||
hkManager = accessor->getHkManagerHandle();
|
||||
}
|
||||
|
||||
if(dataSet != nullptr) {
|
||||
dataSet->registerVariable(this);
|
||||
}
|
||||
}
|
||||
|
||||
pool_rwm_t LocalPoolObjectBase::getReadWriteMode() const {
|
||||
return readWriteMode;
|
||||
return readWriteMode;
|
||||
}
|
||||
|
||||
bool LocalPoolObjectBase::isValid() const {
|
||||
return valid;
|
||||
return valid;
|
||||
}
|
||||
|
||||
void LocalPoolObjectBase::setValid(bool valid) {
|
||||
this->valid = valid;
|
||||
this->valid = valid;
|
||||
}
|
||||
|
||||
lp_id_t LocalPoolObjectBase::getDataPoolId() const {
|
||||
return localPoolId;
|
||||
return localPoolId;
|
||||
}
|
||||
|
||||
void LocalPoolObjectBase::setDataPoolId(lp_id_t poolId) {
|
||||
this->localPoolId = poolId;
|
||||
this->localPoolId = poolId;
|
||||
}
|
||||
|
||||
void LocalPoolObjectBase::setChanged(bool changed) {
|
||||
this->changed = changed;
|
||||
this->changed = changed;
|
||||
}
|
||||
|
||||
bool LocalPoolObjectBase::hasChanged() const {
|
||||
return changed;
|
||||
return changed;
|
||||
}
|
||||
|
||||
void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
|
||||
this->readWriteMode = newReadWriteMode;
|
||||
this->readWriteMode = newReadWriteMode;
|
||||
}
|
||||
|
||||
void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
|
||||
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) {
|
||||
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
const char* type = nullptr;
|
||||
if(read) {
|
||||
type = "read";
|
||||
}
|
||||
else {
|
||||
type = "commit";
|
||||
}
|
||||
const char* type = nullptr;
|
||||
if(read) {
|
||||
type = "read";
|
||||
}
|
||||
else {
|
||||
type = "commit";
|
||||
}
|
||||
|
||||
const char* errMsg = nullptr;
|
||||
if(error == localpool::POOL_ENTRY_NOT_FOUND) {
|
||||
errMsg = "Pool entry not found";
|
||||
}
|
||||
else if(error == localpool::POOL_ENTRY_TYPE_CONFLICT) {
|
||||
errMsg = "Pool entry type conflict";
|
||||
}
|
||||
else if(error == PoolVariableIF::INVALID_READ_WRITE_MODE) {
|
||||
errMsg = "Pool variable wrong read-write mode";
|
||||
}
|
||||
else if(error == PoolVariableIF::INVALID_POOL_ENTRY) {
|
||||
errMsg = "Pool entry invalid";
|
||||
}
|
||||
else {
|
||||
errMsg = "Unknown error code";
|
||||
}
|
||||
const char* errMsg = nullptr;
|
||||
if(error == localpool::POOL_ENTRY_NOT_FOUND) {
|
||||
errMsg = "Pool entry not found";
|
||||
}
|
||||
else if(error == localpool::POOL_ENTRY_TYPE_CONFLICT) {
|
||||
errMsg = "Pool entry type conflict";
|
||||
}
|
||||
else if(error == PoolVariableIF::INVALID_READ_WRITE_MODE) {
|
||||
errMsg = "Pool variable wrong read-write mode";
|
||||
}
|
||||
else if(error == PoolVariableIF::INVALID_POOL_ENTRY) {
|
||||
errMsg = "Pool entry invalid";
|
||||
}
|
||||
else {
|
||||
errMsg = "Unknown error code";
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << variableType << ": " << type << " call | " << errMsg << " | Owner: 0x"
|
||||
<< std::hex << std::setw(8) << std::setfill('0') << objectId << std::dec
|
||||
<< " LPID: " << lpId << std::endl;
|
||||
sif::warning << variableType << ": " << type << " call | " << errMsg << " | Owner: 0x"
|
||||
<< std::hex << std::setw(8) << std::setfill('0') << objectId << std::dec
|
||||
<< " LPID: " << lpId << std::endl;
|
||||
#else
|
||||
sif::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n",
|
||||
variableType, type, errMsg, objectId, lpId);
|
||||
sif::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n",
|
||||
variableType, type, errMsg, objectId, lpId);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_
|
||||
#define FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_
|
||||
|
||||
#include <fsfw/datapoollocal/localPoolDefinitions.h>
|
||||
#include "MarkChangedIF.h"
|
||||
#include "localPoolDefinitions.h"
|
||||
|
||||
#include "../objectmanager/SystemObjectIF.h"
|
||||
#include "../datapool/PoolVariableIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
@ -11,9 +12,13 @@ class LocalDataPoolManager;
|
||||
class DataSetIF;
|
||||
class HasLocalDataPoolIF;
|
||||
|
||||
/**
|
||||
* @brief This class serves as a non-template base for pool objects like pool variables
|
||||
* or pool vectors.
|
||||
*/
|
||||
class LocalPoolObjectBase: public PoolVariableIF,
|
||||
public HasReturnvaluesIF,
|
||||
public MarkChangedIF {
|
||||
public HasReturnvaluesIF,
|
||||
public MarkChangedIF {
|
||||
public:
|
||||
LocalPoolObjectBase(lp_id_t poolId,
|
||||
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||
@ -61,10 +66,8 @@ protected:
|
||||
//! @brief Pointer to the class which manages the HK pool.
|
||||
LocalDataPoolManager* hkManager = nullptr;
|
||||
|
||||
void reportReadCommitError(const char* variableType,
|
||||
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId);
|
||||
void reportReadCommitError(const char* variableType,
|
||||
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLOBJECTBASE_H_ */
|
||||
|
@ -27,159 +27,159 @@
|
||||
template<typename T>
|
||||
class LocalPoolVariable: public LocalPoolObjectBase {
|
||||
public:
|
||||
//! Default ctor is forbidden.
|
||||
LocalPoolVariable() = delete;
|
||||
//! Default ctor is forbidden.
|
||||
LocalPoolVariable() = delete;
|
||||
|
||||
/**
|
||||
* This constructor is used by the data creators to have pool variable
|
||||
* instances which can also be stored in datasets.< |