use old lpm api

This commit is contained in:
Robin Müller 2022-08-30 10:57:02 +02:00
parent 342a56410c
commit 92d65aa3a5
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
8 changed files with 57 additions and 154 deletions

View File

@ -326,32 +326,27 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() {
} }
} }
ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket( ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
subdp::RegularHkPeriodicParams params) { float collectionInterval, bool isDiagnostics,
return subscribeForPeriodicPacket(params); object_id_t packetDestination) {
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) {
return subscribeForPeriodicPacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver; struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = params.sid; hkReceiver.dataId.sid = sid;
hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.reportingType = ReportingType::PERIODIC;
hkReceiver.dataType = DataType::DATA_SET; hkReceiver.dataType = DataType::DATA_SET;
if (params.receiver == MessageQueueIF::NO_QUEUE) { if (packetDestination != objects::NO_OBJECT) {
hkReceiver.destinationQueue = hkDestinationId; auto* receivedHkIF = ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
} else { if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = params.receiver; hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = receivedHkIF->getHkQueue();
}
} }
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet != nullptr) { if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting); LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval, LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
owner->getPeriodicOperationFrequency()); owner->getPeriodicOperationFrequency());
} }
@ -359,30 +354,26 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket( ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
subdp::RegularHkUpdateParams params) { bool isDiagnostics,
return subscribeForUpdatePacket(params); object_id_t packetDestination) {
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket(
subdp::DiagnosticsHkUpdateParams params) {
return subscribeForUpdatePacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver; struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = params.sid; hkReceiver.dataId.sid = sid;
hkReceiver.reportingType = ReportingType::UPDATE_HK; hkReceiver.reportingType = ReportingType::UPDATE_HK;
hkReceiver.dataType = DataType::DATA_SET; hkReceiver.dataType = DataType::DATA_SET;
if (params.receiver == MessageQueueIF::NO_QUEUE) { if (packetDestination != objects::NO_OBJECT) {
hkReceiver.destinationQueue = hkDestinationId; auto* receivedHkIF = ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
} else { if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = params.receiver; hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = receivedHkIF->getHkQueue();
}
} }
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet != nullptr) { if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true); LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
} }
hkReceivers.push_back(hkReceiver); hkReceivers.push_back(hkReceiver);

View File

@ -241,13 +241,13 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
MutexIF* getMutexHandle(); MutexIF* getMutexHandle();
LocalDataPoolManager* getPoolManagerHandle() override; LocalDataPoolManager* getPoolManagerHandle() override;
ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override; ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override; float collectionInterval, bool isDiagnostics,
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); object_id_t packetDestination = objects::NO_OBJECT) override;
ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override; ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override; bool isDiagnostics,
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); object_id_t packetDestination = objects::NO_OBJECT) override;
protected: protected:
/** Core data structure for the actual pool data */ /** Core data structure for the actual pool data */

View File

@ -1,90 +1,24 @@
#ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "../ipc/messageQueueDefinitions.h"
#include "fsfw/ipc/MessageQueueIF.h" #include "../returnvalues/returnvalue.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "localPoolDefinitions.h" #include "localPoolDefinitions.h"
namespace subdp {
struct ParamsBase {
ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics)
: sid(sid),
enableReporting(enableReporting),
collectionInterval(collectionInterval),
diagnostics(diagnostics) {}
[[nodiscard]] bool isDiagnostics() const { return diagnostics; }
sid_t sid;
bool enableReporting;
float collectionInterval;
MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE;
protected:
bool diagnostics;
};
struct RegularHkPeriodicParams : public ParamsBase {
RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, false) {}
};
struct DiagnosticsHkPeriodicParams : public ParamsBase {
DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, true) {}
};
struct RegularHkUpdateParams : public ParamsBase {
RegularHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, false) {}
};
struct DiagnosticsHkUpdateParams : public ParamsBase {
DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, true) {}
};
} // namespace subdp
class ProvidesDataPoolSubscriptionIF { class ProvidesDataPoolSubscriptionIF {
public: public:
virtual ~ProvidesDataPoolSubscriptionIF() = default; virtual ~ProvidesDataPoolSubscriptionIF(){};
/** /**
* @brief Subscribe for the generation of periodic packets. Used for regular HK packets * @brief Subscribe for the generation of periodic packets.
* @details * @details
* This subscription mechanism will generally be used by the data creator * This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly. * to generate housekeeping packets which are downlinked directly.
* @return * @return
*/ */
virtual ReturnValue_t subscribeForRegularPeriodicPacket( virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
subdp::RegularHkPeriodicParams params) = 0; float collectionInterval, bool isDiagnostics,
/** object_id_t packetDestination) = 0;
* @brief Subscribe for the generation of periodic packets. Used for diagnostic packets
* @details
* This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly.
* @return
*/
virtual ReturnValue_t subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) = 0;
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval,
bool isDiagnostics,
object_id_t packetDestination = objects::NO_OBJECT) {
if (isDiagnostics) {
subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval);
return subscribeForDiagPeriodicPacket(params);
} else {
subdp::RegularHkPeriodicParams params(sid, enableReporting, collectionInterval);
return subscribeForRegularPeriodicPacket(params);
}
}
/** /**
* @brief Subscribe for the generation of packets if the dataset * @brief Subscribe for the generation of packets if the dataset
* is marked as changed. * is marked as changed.
@ -95,23 +29,9 @@ class ProvidesDataPoolSubscriptionIF {
* @param packetDestination * @param packetDestination
* @return * @return
*/ */
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; bool isDiagnostics,
object_id_t packetDestination) = 0;
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics,
object_id_t packetDestination = objects::NO_OBJECT) {
if (isDiagnostics) {
subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled);
return subscribeForDiagUpdatePacket(params);
} else {
subdp::RegularHkUpdateParams params(sid, reportingEnabled);
return subscribeForRegularUpdatePacket(params);
}
}
/** /**
* @brief Subscribe for a notification message which will be sent * @brief Subscribe for a notification message which will be sent
* if a dataset has changed. * if a dataset has changed.
@ -126,7 +46,8 @@ class ProvidesDataPoolSubscriptionIF {
* Otherwise, only an notification message is sent. * Otherwise, only an notification message is sent.
* @return * @return
*/ */
virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject, virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId, MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0; bool generateSnapshot) = 0;
/** /**
@ -143,7 +64,7 @@ class ProvidesDataPoolSubscriptionIF {
* only an notification message is sent. * only an notification message is sent.
* @return * @return
*/ */
virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId, virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
object_id_t destinationObject, object_id_t destinationObject,
MessageQueueId_t targetQueueId, MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0; bool generateSnapshot) = 0;

View File

@ -129,9 +129,8 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( poolManager.subscribeForPeriodicPacket(internalErrorSid, false,
internalErrorSid, false, static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0), true);
static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0)));
internalErrorDataset.setValidity(true, true); internalErrorDataset.setValidity(true, true);
return returnvalue::OK; return returnvalue::OK;
} }

View File

@ -466,7 +466,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo
LocalDataPoolManager &poolManager) { LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ);
localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature);
poolManager.subscribeForRegularPeriodicPacket({dataset.getSid(), false, 10.0}); poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false);
return returnvalue::OK; return returnvalue::OK;
} }

View File

@ -310,7 +310,7 @@ void MgmRM3100Handler::modeChanged() { internalState = InternalState::NONE; }
ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) { LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ);
poolManager.subscribeForRegularPeriodicPacket({primaryDataset.getSid(), false, 10.0}); poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false);
return returnvalue::OK; return returnvalue::OK;
} }

View File

@ -2,5 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
testLocalPoolVariable.cpp testLocalPoolVariable.cpp
testLocalPoolVector.cpp testLocalPoolVector.cpp
testDataSet.cpp testDataSet.cpp
testLocalPoolManager.cpp testLocalPoolManager.cpp
) )

View File

@ -11,6 +11,7 @@
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
#include "fsfw/datapool/PoolEntry.h" #include "fsfw/datapool/PoolEntry.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "mocks/MessageQueueMock.h" #include "mocks/MessageQueueMock.h"
#include "tests/TestsConfig.h" #include "tests/TestsConfig.h"
@ -104,8 +105,7 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF {
} }
ReturnValue_t subscribePeriodicHk(bool enableReporting) { ReturnValue_t subscribePeriodicHk(bool enableReporting) {
return poolManager.subscribeForRegularPeriodicPacket( return poolManager.subscribeForPeriodicPacket(lpool::testSid, enableReporting, 0.2, false);
subdp::RegularHkPeriodicParams(lpool::testSid, enableReporting, 0.2));
} }
ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) { ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) {
@ -121,17 +121,9 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF {
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false, ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false,
AcceptsHkPacketsIF* receiver = nullptr) { AcceptsHkPacketsIF* receiver = nullptr) {
if (diagnostics) { if (diagnostics) {
auto params = subdp::DiagnosticsHkUpdateParams(lpool::testSid, true); return poolManager.subscribeForUpdatePacket(lpool::testSid, true, true);
if (receiver != nullptr) {
params.receiver = receiver->getHkQueue();
}
return poolManager.subscribeForDiagUpdatePacket(params);
} else { } else {
auto params = subdp::RegularHkUpdateParams(lpool::testSid, true); return poolManager.subscribeForUpdatePacket(lpool::testSid, true, false);
if (receiver != nullptr) {
params.receiver = receiver->getHkQueue();
}
return poolManager.subscribeForRegularUpdatePacket(params);
} }
} }