local data pool manager uses new packet now

This commit is contained in:
Robin Müller 2020-08-09 20:06:29 +02:00
parent 9e7d92b387
commit 87eb31b65a
4 changed files with 71 additions and 72 deletions

View File

@ -1,6 +1,7 @@
#include <framework/datapoollocal/LocalDataPoolManager.h> #include <framework/datapoollocal/LocalDataPoolManager.h>
#include <framework/datapoollocal/LocalPoolDataSetBase.h> #include <framework/datapoollocal/LocalPoolDataSetBase.h>
#include <framework/housekeeping/AcceptsHkPacketsIF.h> #include <framework/housekeeping/AcceptsHkPacketsIF.h>
#include <framework/housekeeping/HousekeepingPacketDownlink.h>
#include <framework/ipc/MutexFactory.h> #include <framework/ipc/MutexFactory.h>
#include <framework/ipc/MutexHelper.h> #include <framework/ipc/MutexHelper.h>
#include <framework/ipc/QueueFactory.h> #include <framework/ipc/QueueFactory.h>
@ -121,7 +122,7 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
} }
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
MessageQueueId_t sendTo) { float collectionInterval, MessageQueueId_t sendTo) {
LocalPoolDataSetBase* dataSetToSerialize = dynamic_cast<LocalPoolDataSetBase*>( LocalPoolDataSetBase* dataSetToSerialize = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid)); owner->getDataSetHandle(sid));
if(dataSetToSerialize == nullptr) { if(dataSetToSerialize == nullptr) {
@ -136,8 +137,9 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
// } // }
store_address_t storeId; store_address_t storeId;
ReturnValue_t result = serializeHkPacketIntoStore(&storeId, HousekeepingPacketDownlink hkPacket(sid, collectionInterval,
dataSetToSerialize); dataSetToSerialize->getFillCount(), dataSetToSerialize);
ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, &storeId);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -166,6 +168,22 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
return result; return result;
} }
ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(
HousekeepingPacketDownlink& hkPacket,
store_address_t *storeId) {
uint8_t* dataPtr = nullptr;
size_t serializedSize = hkPacket.getSerializedSize();
const size_t maxSize = serializedSize;
ReturnValue_t result = ipcStore->getFreeElement(storeId,
serializedSize, &dataPtr);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return hkPacket.serialize(&dataPtr, &serializedSize, maxSize,
SerializeIF::Endianness::MACHINE);
}
ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid) { ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid) {
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>( LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid)); owner->getDataSetHandle(sid));
@ -199,33 +217,6 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
this->nonDiagnosticIntervalFactor = nonDiagInvlFactor; this->nonDiagnosticIntervalFactor = nonDiagInvlFactor;
} }
ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(
store_address_t *storeId, LocalPoolDataSetBase* dataSet) {
size_t hkSize = dataSet->getSerializedSize();
uint8_t* storePtr = nullptr;
ReturnValue_t result = ipcStore->getFreeElement(storeId, hkSize,&storePtr);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "HousekeepingManager::generateHousekeepingPacket: "
"Could not get free element from IPC store." << std::endl;
return result;
}
size_t size = 0;
if(appendValidityBuffer) {
result = dataSet->serializeWithValidityBuffer(&storePtr,
&size, hkSize, SerializeIF::Endianness::MACHINE);
}
else {
result = dataSet->serialize(&storePtr, &size, hkSize,
SerializeIF::Endianness::MACHINE);
}
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "HousekeepingManager::serializeHkPacketIntoStore: "
"Serialization proccess failed!" << std::endl;
}
return result;
}
ReturnValue_t LocalDataPoolManager::performHkOperation() { ReturnValue_t LocalDataPoolManager::performHkOperation() {
for(auto& hkReceiversIter: hkReceiversMap) { for(auto& hkReceiversIter: hkReceiversMap) {

View File

@ -8,6 +8,7 @@
#include <framework/housekeeping/HousekeepingMessage.h> #include <framework/housekeeping/HousekeepingMessage.h>
#include <framework/datapool/PoolEntry.h> #include <framework/datapool/PoolEntry.h>
#include <framework/datapoollocal/HasLocalDataPoolIF.h> #include <framework/datapoollocal/HasLocalDataPoolIF.h>
#include <framework/housekeeping/HousekeepingPacketDownlink.h>
#include <framework/ipc/CommandMessage.h> #include <framework/ipc/CommandMessage.h>
#include <framework/ipc/MessageQueueIF.h> #include <framework/ipc/MessageQueueIF.h>
#include <framework/ipc/MutexHelper.h> #include <framework/ipc/MutexHelper.h>
@ -101,8 +102,8 @@ public:
* @param sid * @param sid
* @return * @return
*/ */
ReturnValue_t generateHousekeepingPacket(sid_t sid, MessageQueueId_t sendTo ReturnValue_t generateHousekeepingPacket(sid_t sid, float collectionInterval,
= MessageQueueIF::NO_QUEUE); MessageQueueId_t sendTo = MessageQueueIF::NO_QUEUE);
ReturnValue_t generateSetStructurePacket(sid_t sid); ReturnValue_t generateSetStructurePacket(sid_t sid);
ReturnValue_t handleHousekeepingMessage(CommandMessage* message); ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
@ -237,8 +238,9 @@ private:
PoolEntry<T> **poolEntry); PoolEntry<T> **poolEntry);
void setMinimalSamplingFrequency(float frequencySeconds); void setMinimalSamplingFrequency(float frequencySeconds);
ReturnValue_t serializeHkPacketIntoStore(store_address_t* storeId, ReturnValue_t serializeHkPacketIntoStore(
LocalPoolDataSetBase* dataSet); HousekeepingPacketDownlink& hkPacket,
store_address_t *storeId);
uint32_t intervalSecondsToInterval(bool isDiagnostics, uint32_t intervalSecondsToInterval(bool isDiagnostics,
float collectionIntervalSeconds); float collectionIntervalSeconds);

View File

@ -1,5 +1,6 @@
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ #ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ #define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
#include <framework/datapoollocal/LocalPoolDataSetBase.h> #include <framework/datapoollocal/LocalPoolDataSetBase.h>
#include <framework/housekeeping/HousekeepingMessage.h> #include <framework/housekeeping/HousekeepingMessage.h>
#include <framework/serialize/SerialLinkedListAdapter.h> #include <framework/serialize/SerialLinkedListAdapter.h>
@ -18,39 +19,31 @@ public:
numberOfParameters, LocalPoolDataSetBase* dataSetPtr): numberOfParameters, LocalPoolDataSetBase* dataSetPtr):
sourceId(sid.objectId), setId(sid.ownerSetId), sourceId(sid.objectId), setId(sid.ownerSetId),
collectionInterval(collectionInterval), collectionInterval(collectionInterval),
numberOfParameters(numberOfParameters), dataSetPtr(dataSetPtr), numberOfParameters(numberOfParameters), hkData(dataSetPtr) {
hkData(dataSetPtr) {
setLinks(); setLinks();
} }
// virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, /**
// size_t maxSize, Endianness streamEndianness) const override { * Helper functions which can be used to move HK data from the IPC store
// ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size, * to the telemetry store.
// maxSize, streamEndianness); * @param formerStore
// if(result != HasReturnvaluesIF::RETURN_OK) { * @param storeId
// return result; * @param newStore
// } * @param newStoreId [out]
// return dataSetPtr->serialize(buffer, size, maxSize, streamEndianness); * @return
// } */
//
// virtual size_t getSerializedSize() const override {
//
// }
virtual ReturnValue_t moveToOtherStore(StorageManagerIF* formerStore, virtual ReturnValue_t moveToOtherStore(StorageManagerIF* formerStore,
store_address_t storeId, StorageManagerIF* otherStore, store_address_t storeId, StorageManagerIF* newStore,
store_address_t* newStoreId, uint8_t** buffer, size_t size) { store_address_t* newStoreId) {
const uint8_t* dataPtr = nullptr; const uint8_t* dataPtr = nullptr;
size_t hkDataSize = 0; size_t hkDataSize = 0;
ReturnValue_t result = formerStore->getData(storeId, &dataPtr, &hkDataSize); ReturnValue_t result = formerStore->getData(storeId, &dataPtr,
&hkDataSize);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
otherStore->addData(newStoreId, dataPtrgetSerializedSize(), return newStore->addData(newStoreId, dataPtr, hkDataSize);
buffer);
std::memcpy
} }
private: private:
@ -67,9 +60,22 @@ private:
SerializeElement<float> collectionInterval; SerializeElement<float> collectionInterval;
SerializeElement<uint8_t> numberOfParameters; SerializeElement<uint8_t> numberOfParameters;
LinkedElement<SerializeIF> hkData; LinkedElement<SerializeIF> hkData;
LocalPoolDataSetBase* dataSetPtr;
}; };
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ */ #endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ */
// virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
// size_t maxSize, Endianness streamEndianness) const override {
// ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size,
// maxSize, streamEndianness);
// if(result != HasReturnvaluesIF::RETURN_OK) {
// return result;
// }
// return dataSetPtr->serialize(buffer, size, maxSize, streamEndianness);
// }
//
// virtual size_t getSerializedSize() const override {
//
// }

View File

@ -7,7 +7,7 @@
/** /**
* @brief This helper class will be used to serialize and deserialize * @brief This helper class will be used to serialize and deserialize
* internal housekeeping packets into the store. * update housekeeping packets into the store.
*/ */
class HousekeepingPacketUpdate: public SerializeIF { class HousekeepingPacketUpdate: public SerializeIF {
public: public:
@ -25,8 +25,8 @@ public:
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
size_t maxSize, Endianness streamEndianness) const { size_t maxSize, Endianness streamEndianness) const {
if(timeStamp != nullptr) { if(timeStamp != nullptr) {
// Endianness will always be MACHINE, so we can simply use memcpy /* Endianness will always be MACHINE, so we can simply use memcpy
// here. here. */
std::memcpy(*buffer, timeStamp, timeStampSize); std::memcpy(*buffer, timeStamp, timeStampSize);
*size += timeStampSize; *size += timeStampSize;
*buffer += timeStampSize; *buffer += timeStampSize;
@ -48,8 +48,8 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override { SerializeIF::Endianness streamEndianness) override {
if(timeStamp != nullptr) { if(timeStamp != nullptr) {
// Endianness will always be MACHINE, so we can simply use memcpy /* Endianness will always be MACHINE, so we can simply use memcpy
// here. here. */
std::memcpy(timeStamp, *buffer, timeStampSize); std::memcpy(timeStamp, *buffer, timeStampSize);
*size += timeStampSize; *size += timeStampSize;
*buffer += timeStampSize; *buffer += timeStampSize;