some fixes, indentation with spaces now

This commit is contained in:
Robin Müller 2021-01-25 13:44:21 +01:00
parent 0bb19c5ee5
commit 52c177479f
2 changed files with 160 additions and 160 deletions

View File

@ -53,16 +53,15 @@ class LocalDataPool;
* @author R. Mueller * @author R. Mueller
*/ */
class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF, class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF,
public AccessPoolManagerIF { public AccessPoolManagerIF {
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();
//! Some classes using the pool manager directly need to access class internals of the //! Some classes using the pool manager directly need to access class internals of the
//! manager. The attorney provides granular control of access to these internals. //! manager. The attorney provides granular control of access to these internals.
friend class LocalDpManagerAttorney; friend class LocalDpManagerAttorney;
public: public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER; static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_INVALID = MAKE_RETURN_CODE(0); static constexpr ReturnValue_t QUEUE_OR_DESTINATION_INVALID = MAKE_RETURN_CODE(0);
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(1);
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(3); static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(3);
@ -81,29 +80,29 @@ public:
* @param appendValidityBuffer Specify whether a buffer containing the * @param appendValidityBuffer Specify whether a buffer containing the
* validity state is generated when serializing or deserializing packets. * validity state is generated when serializing or deserializing packets.
*/ */
LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
bool appendValidityBuffer = true); bool appendValidityBuffer = true);
virtual~ LocalDataPoolManager(); virtual~ LocalDataPoolManager();
/** /**
* Assigns the queue to use. Make sure to call this in the #initialize * Assigns the queue to use. Make sure to call this in the #initialize
* function of the owner. * function of the owner.
* @param queueToUse * @param queueToUse
* @param nonDiagInvlFactor See #setNonDiagnosticIntervalFactor doc * @param nonDiagInvlFactor See #setNonDiagnosticIntervalFactor doc
* @return * @return
*/ */
ReturnValue_t initialize(MessageQueueIF* queueToUse); ReturnValue_t initialize(MessageQueueIF* queueToUse);
/** /**
* Initializes the map by calling the map initialization function and * Initializes the map by calling the map initialization function and
* setting the periodic factor for non-diagnostic packets. * setting the periodic factor for non-diagnostic packets.
* Don't forget to call this in the #initializeAfterTaskCreation call of * Don't forget to call this in the #initializeAfterTaskCreation call of
* the owner, otherwise the map will be invalid! * the owner, otherwise the map will be invalid!
* @param nonDiagInvlFactor * @param nonDiagInvlFactor
* @return * @return
*/ */
ReturnValue_t initializeAfterTaskCreation( ReturnValue_t initializeAfterTaskCreation(
uint8_t nonDiagInvlFactor = 5); uint8_t nonDiagInvlFactor = 5);
/** /**
* @brief This should be called in the periodic handler of the owner. * @brief This should be called in the periodic handler of the owner.
@ -116,49 +115,49 @@ public:
*/ */
virtual ReturnValue_t performHkOperation(); virtual ReturnValue_t performHkOperation();
/** /**
* @brief Subscribe for the generation of periodic 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
*/ */
ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
float collectionInterval, bool isDiagnostics, float collectionInterval, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override; object_id_t packetDestination = defaultHkDestination) override;
/** /**
* @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.
* @details * @details
* This subscription mechanism will generally be used by the data creator. * This subscription mechanism will generally be used by the data creator.
* @param sid * @param sid
* @param isDiagnostics * @param isDiagnostics
* @param packetDestination * @param packetDestination
* @return * @return
*/ */
ReturnValue_t subscribeForUpdatePackets(sid_t sid, bool reportingEnabled, ReturnValue_t subscribeForUpdatePackets(sid_t sid, bool reportingEnabled,
bool isDiagnostics, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override; object_id_t packetDestination = defaultHkDestination) override;
/** /**
* @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.
* @details * @details
* This subscription mechanism will generally be used internally by * This subscription mechanism will generally be used internally by
* other software components. * other software components.
* @param setId Set ID of the set to receive update messages from. * @param setId Set ID of the set to receive update messages from.
* @param destinationObject * @param destinationObject
* @param targetQueueId * @param targetQueueId
* @param generateSnapshot If this is set to true, a copy of the current * @param generateSnapshot If this is set to true, a copy of the current
* data with a timestamp will be generated and sent via message. * data with a timestamp will be generated and sent via message.
* Otherwise, only an notification message is sent. * Otherwise, only an notification message is sent.
* @return * @return
*/ */
ReturnValue_t subscribeForSetUpdateMessages(const uint32_t setId, ReturnValue_t subscribeForSetUpdateMessages(const uint32_t setId,
object_id_t destinationObject, object_id_t destinationObject,
MessageQueueId_t targetQueueId, MessageQueueId_t targetQueueId,
bool generateSnapshot) override; bool generateSnapshot) override;
/** /**
* @brief Subscribe for an notification message which will be sent if a * @brief Subscribe for an notification message which will be sent if a
@ -179,16 +178,16 @@ public:
MessageQueueId_t targetQueueId, MessageQueueId_t targetQueueId,
bool generateSnapshot) override; bool generateSnapshot) override;
/** /**
* Non-Diagnostics packets usually have a lower minimum sampling frequency * Non-Diagnostics packets usually have a lower minimum sampling frequency
* than diagnostic packets. * than diagnostic packets.
* A factor can be specified to determine the minimum sampling frequency * A factor can be specified to determine the minimum sampling frequency
* for non-diagnostic packets. The minimum sampling frequency of the * for non-diagnostic packets. The minimum sampling frequency of the
* diagnostics packets,which is usually jusst the period of the * diagnostics packets,which is usually jusst the period of the
* performOperation calls, is multiplied with that factor. * performOperation calls, is multiplied with that factor.
* @param factor * @param factor
*/ */
void setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor); void setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor);
/** /**
* @brief The manager is also able to handle housekeeping messages. * @brief The manager is also able to handle housekeeping messages.
@ -204,18 +203,18 @@ public:
*/ */
virtual ReturnValue_t handleHousekeepingMessage(CommandMessage* message); virtual ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
/** /**
* Generate a housekeeping packet with a given SID. * Generate a housekeeping packet with a given SID.
* @param sid * @param sid
* @return * @return
*/ */
ReturnValue_t generateHousekeepingPacket(sid_t sid, ReturnValue_t generateHousekeepingPacket(sid_t sid,
LocalPoolDataSetBase* dataSet, bool forDownlink, LocalPoolDataSetBase* dataSet, bool forDownlink,
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
HasLocalDataPoolIF* getOwner(); HasLocalDataPoolIF* getOwner();
ReturnValue_t printPoolEntry(lp_id_t localPoolId); ReturnValue_t printPoolEntry(lp_id_t localPoolId);
/** /**
* Different types of housekeeping reporting are possible. * Different types of housekeeping reporting are possible.
@ -234,8 +233,8 @@ public:
PERIODIC, PERIODIC,
//! Housekeeping packet will be generated if values have changed. //! Housekeeping packet will be generated if values have changed.
UPDATE_HK, UPDATE_HK,
//! Update notification will be sent out as message. //! Update notification will be sent out as message.
UPDATE_NOTIFICATION, UPDATE_NOTIFICATION,
//! Notification will be sent out as message and a snapshot of the //! Notification will be sent out as message and a snapshot of the
//! current data will be generated. //! current data will be generated.
UPDATE_SNAPSHOT, UPDATE_SNAPSHOT,
@ -245,8 +244,8 @@ public:
requested for full datasets or for single pool variables. Periodic reporting is only possible requested for full datasets or for single pool variables. Periodic reporting is only possible
for data sets. */ for data sets. */
enum class DataType: uint8_t { enum class DataType: uint8_t {
LOCAL_POOL_VARIABLE, LOCAL_POOL_VARIABLE,
DATA_SET DATA_SET
}; };
/* Copying forbidden */ /* Copying forbidden */
@ -262,6 +261,14 @@ public:
object_id_t getCreatorObjectId() const; object_id_t getCreatorObjectId() const;
/**
* Get the pointer to the mutex. Can be used to lock the data pool
* externally. Use with care and don't forget to unlock locked mutexes!
* For now, only friend classes can accss this function.
* @return
*/
MutexIF* getMutexHandle();
virtual LocalDataPoolManager* getPoolManagerHandle() override; virtual LocalDataPoolManager* getPoolManagerHandle() override;
private: private:
localpool::DataPool localPoolMap; localpool::DataPool localPoolMap;
@ -274,9 +281,9 @@ private:
uint8_t nonDiagnosticIntervalFactor = 0; uint8_t nonDiagnosticIntervalFactor = 0;
/** Default receiver for periodic HK packets */ /** Default receiver for periodic HK packets */
static object_id_t defaultHkDestination; static object_id_t defaultHkDestination;
MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE; MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE;
union DataId { union DataId {
DataId(): sid() {}; DataId(): sid() {};
@ -286,10 +293,10 @@ 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 {
/** Object ID of receiver */ /** Object ID of receiver */
object_id_t objectId = objects::NO_OBJECT; object_id_t objectId = objects::NO_OBJECT;
DataType dataType = DataType::DATA_SET; DataType dataType = DataType::DATA_SET;
DataId dataId; DataId dataId;
ReportingType reportingType = ReportingType::PERIODIC; ReportingType reportingType = ReportingType::PERIODIC;
@ -319,37 +326,30 @@ private:
* of generated housekeeping packets. */ * of generated housekeeping packets. */
bool appendValidityBuffer = true; bool appendValidityBuffer = true;
/** /**
* @brief Queue used for communication, for example commands. * @brief Queue used for communication, for example commands.
* Is also used to send messages. Can be set either in the constructor * Is also used to send messages. Can be set either in the constructor
* or in the initialize() function. * or in the initialize() function.
*/ */
MessageQueueIF* hkQueue = nullptr; MessageQueueIF* hkQueue = nullptr;
/** Global IPC store is used to store all packets. */ /** Global IPC store is used to store all packets. */
StorageManagerIF* ipcStore = nullptr; StorageManagerIF* ipcStore = nullptr;
/**
* Get the pointer to the mutex. Can be used to lock the data pool
* externally. Use with care and don't forget to unlock locked mutexes!
* For now, only friend classes can accss this function.
* @return
*/
MutexIF* getMutexHandle();
/** /**
* Read a variable by supplying its local pool ID and assign the pool * Read a variable by supplying its local pool ID and assign the pool
* entry to the supplied PoolEntry pointer. The type of the pool entry * entry to the supplied PoolEntry pointer. The type of the pool entry
* is deduced automatically. This call is not thread-safe! * is deduced automatically. This call is not thread-safe!
* For now, only friend classes like LocalPoolVar may access this * For now, only friend classes like LocalPoolVar may access this
* function. * function.
* @tparam T Type of the pool entry * @tparam T Type of the pool entry
* @param localPoolId Pool ID of the variable to read * @param localPoolId Pool ID of the variable to read
* @param poolVar [out] Corresponding pool entry will be assigned to the * @param poolVar [out] Corresponding pool entry will be assigned to the
* supplied pointer. * supplied pointer.
* @return * @return
*/ */
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T> **poolEntry); PoolEntry<T> **poolEntry);
/** /**
* This function is used to fill the local data pool map with pool * This function is used to fill the local data pool map with pool
@ -361,55 +361,55 @@ private:
MutexIF* getLocalPoolMutex() override; MutexIF* getLocalPoolMutex() override;
ReturnValue_t serializeHkPacketIntoStore( ReturnValue_t serializeHkPacketIntoStore(
HousekeepingPacketDownlink& hkPacket, HousekeepingPacketDownlink& hkPacket,
store_address_t& storeId, bool forDownlink, size_t* serializedSize); store_address_t& storeId, bool forDownlink, size_t* serializedSize);
void performPeriodicHkGeneration(HkReceiver& hkReceiver); void performPeriodicHkGeneration(HkReceiver& hkReceiver);
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable,
bool isDiagnostics); bool isDiagnostics);
ReturnValue_t changeCollectionInterval(sid_t sid, ReturnValue_t changeCollectionInterval(sid_t sid,
float newCollectionInterval, bool isDiagnostics); float newCollectionInterval, bool isDiagnostics);
ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics); ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics);
void handleHkUpdateResetListInsertion(DataType dataType, DataId dataId); void handleHkUpdateResetListInsertion(DataType dataType, DataId dataId);
void handleChangeResetLogic(DataType type, void handleChangeResetLogic(DataType type,
DataId dataId, MarkChangedIF* toReset); DataId dataId, MarkChangedIF* toReset);
void resetHkUpdateResetHelper(); void resetHkUpdateResetHelper();
ReturnValue_t handleHkUpdate(HkReceiver& hkReceiver, ReturnValue_t handleHkUpdate(HkReceiver& hkReceiver,
ReturnValue_t& status); ReturnValue_t& status);
ReturnValue_t handleNotificationUpdate(HkReceiver& hkReceiver, ReturnValue_t handleNotificationUpdate(HkReceiver& hkReceiver,
ReturnValue_t& status);
ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver,
ReturnValue_t& status); ReturnValue_t& status);
ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver,
store_address_t& storeId); ReturnValue_t& status);
ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket,
store_address_t& storeId);
void printWarningOrError(sif::OutputTypes outputType, void printWarningOrError(sif::OutputTypes outputType,
const char* functionName, const char* functionName,
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
const char* errorPrint = nullptr); const char* errorPrint = nullptr);
}; };
template<class T> inline template<class T> inline
ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T> **poolEntry) { PoolEntry<T> **poolEntry) {
auto poolIter = localPoolMap.find(localPoolId); auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) { if (poolIter == localPoolMap.end()) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry", printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry",
localpool::POOL_ENTRY_NOT_FOUND); localpool::POOL_ENTRY_NOT_FOUND);
return localpool::POOL_ENTRY_NOT_FOUND; return localpool::POOL_ENTRY_NOT_FOUND;
} }
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second); *poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
if(*poolEntry == nullptr) { if(*poolEntry == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry", printWarningOrError(sif::OutputTypes::OUT_ERROR, "fetchPoolEntry",
localpool::POOL_ENTRY_TYPE_CONFLICT); localpool::POOL_ENTRY_TYPE_CONFLICT);
return localpool::POOL_ENTRY_TYPE_CONFLICT; return localpool::POOL_ENTRY_TYPE_CONFLICT;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -276,7 +276,7 @@ TEST_CASE( "Local Pool Extended Tests [3 Pools]" , "[TestPool2]") {
CHECK(receptionArray[3] == 66); CHECK(receptionArray[3] == 66);
// now clear first page // now clear first page
simplePool.clearPage(0); simplePool.clearSubPool(0);
bytesWritten = 0; bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten); simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// Second page full, median fill count is 33 % // Second page full, median fill count is 33 %