continued with local datapool manager

This commit is contained in:
Robin Müller 2020-08-08 19:56:42 +02:00
parent e7d28d630c
commit b828d7c6d7
2 changed files with 42 additions and 33 deletions

View File

@ -129,6 +129,12 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
" Set ID not found" << std::endl; " Set ID not found" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
// do we generate hk packets for invalid datasets?
// if(not dataSetToSerialize->isValid()) {
// return HasReturnvaluesIF::RETURN_OK;
// }
store_address_t storeId; store_address_t storeId;
ReturnValue_t result = serializeHkPacketIntoStore(&storeId, ReturnValue_t result = serializeHkPacketIntoStore(&storeId,
dataSetToSerialize); dataSetToSerialize);
@ -224,8 +230,16 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(
ReturnValue_t LocalDataPoolManager::performHkOperation() { ReturnValue_t LocalDataPoolManager::performHkOperation() {
for(auto& hkReceiversIter: hkReceiversMap) { for(auto& hkReceiversIter: hkReceiversMap) {
HkReceiver* receiver = &hkReceiversIter.second; HkReceiver* receiver = &hkReceiversIter.second;
if(not receiver->reportingEnabled) {
return HasReturnvaluesIF::RETURN_OK;
}
switch(receiver->reportingType) { switch(receiver->reportingType) {
case(ReportingType::PERIODIC): { case(ReportingType::PERIODIC): {
if(receiver->dataId.dataSetSid == sid_t::INVALID_ADDRESS) {
// Periodic packets shall only be generated from datasets.
continue;
}
performPeriodicHkGeneration(receiver); performPeriodicHkGeneration(receiver);
break; break;
} }
@ -242,24 +256,22 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() {
} }
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) {
if(receiver->reportingEnabled) { if(receiver->intervalCounter >= intervalSecondsToInterval(
if(receiver->intervalCounter >= intervalSecondsToInterval( receiver->isDiagnostics,
receiver->isDiagnostics, receiver->hkParameter.collectionInterval)) {
receiver->hkParameter.collectionInterval)) { ReturnValue_t result = generateHousekeepingPacket(
ReturnValue_t result = generateHousekeepingPacket( receiver->dataId.dataSetSid, receiver->destinationQueue);
receiver->dataSetSid, receiver->destinationQueue); if(result != HasReturnvaluesIF::RETURN_OK) {
if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error
// configuration error sif::debug << "LocalDataPoolManager::performHkOperation:"
sif::debug << "LocalDataPoolManager::performHkOperation:" << "0x" << std::setfill('0') << std::setw(8)
<< "0x" << std::setfill('0') << std::setw(8) << owner->getObjectId() << " Error generating "
<< owner->getObjectId() << " Error generating " << "HK packet" << std::setfill(' ') << std::endl;
<< "HK packet" << std::setfill(' ') << std::endl;
}
receiver->intervalCounter = 1;
}
else if(receiver->reportingEnabled){
receiver->intervalCounter++;
} }
receiver->intervalCounter = 1;
}
else {
receiver->intervalCounter++;
} }
} }

View File

@ -31,7 +31,7 @@ class LocalPoolDataSetBase;
* value is stored. The helper classes offer a read() and commit() interface * value is stored. The helper classes offer a read() and commit() interface
* through the PoolVariableIF which is used to read and update values. * through the PoolVariableIF which is used to read and update values.
* Each pool entry has a valid state too. * Each pool entry has a valid state too.
* * @author R. Mueller
*/ */
class LocalDataPoolManager { class LocalDataPoolManager {
template<typename T> template<typename T>
@ -129,12 +129,6 @@ public:
* Propably not necessary, just use multiple local data sets or * Propably not necessary, just use multiple local data sets or
* shared datasets. * shared datasets.
* *
* TODO: This is a big architecture question. Use raw data or shared
* datasets? dumb thing about shared datasets: It propably would be better
* if each task who uses the data has their own copy of the pool
* variables. Then the LPIDs should be hardcoded in the dataset implementations
* so the users don't have to worry about it anymore.
*
* Notifications should also be possible for single variables instead of * Notifications should also be possible for single variables instead of
* full dataset updates. * full dataset updates.
*/ */
@ -144,10 +138,6 @@ public:
// Notification will be sent out as message. // Notification will be sent out as message.
// Data is accessed via shared data set or multiple local data sets. // Data is accessed via shared data set or multiple local data sets.
ON_UPDATE, ON_UPDATE,
// actually, requested is propably unnecessary. If another component
// needs data on request, they can just use the new SharedDataSet
// which is thread-safe to also have full access to the interface..
REQUESTED
}; };
/* Copying forbidden */ /* Copying forbidden */
@ -168,14 +158,21 @@ private:
/** The data pool manager will keep an internal map of HK receivers. */ /** The data pool manager will keep an internal map of HK receivers. */
struct HkReceiver { struct HkReceiver {
sid_t dataSetSid; /** Different member of this union will be used depending on the
//LocalPoolDataSetBase* dataSet = nullptr; type of data the receiver is interested in (full datasets or
lp_id_t localPoolId = HasLocalDataPoolIF::NO_POOL_ID; single data variables. */
union DataId {
/** Will be initialized to INVALID_ADDRESS */
sid_t dataSetSid;
lp_id_t localPoolId = HasLocalDataPoolIF::NO_POOL_ID;
};
DataId dataId;
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE; MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
ReportingType reportingType = ReportingType::PERIODIC; ReportingType reportingType = ReportingType::PERIODIC;
bool reportingEnabled = true; bool reportingEnabled = true;
/** Different members of this union will be used depending on reporting /** Different members of this union will be used depending on reporting
* type */ type */
union HkParameter { union HkParameter {
/** This parameter will be used for the PERIODIC type */ /** This parameter will be used for the PERIODIC type */
dur_seconds_t collectionInterval = 0; dur_seconds_t collectionInterval = 0;
@ -184,7 +181,7 @@ private:
}; };
HkParameter hkParameter; HkParameter hkParameter;
bool isDiagnostics; bool isDiagnostics;
//! General purpose counter which is used for periodic generation. /** General purpose counter which is used for periodic generation. */
uint32_t intervalCounter; uint32_t intervalCounter;
}; };