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/LocalPoolDataSetBase.h>
#include <framework/housekeeping/AcceptsHkPacketsIF.h>
#include <framework/housekeeping/HousekeepingPacketDownlink.h>
#include <framework/ipc/MutexFactory.h>
#include <framework/ipc/MutexHelper.h>
#include <framework/ipc/QueueFactory.h>
@ -121,7 +122,7 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
}
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
MessageQueueId_t sendTo) {
float collectionInterval, MessageQueueId_t sendTo) {
LocalPoolDataSetBase* dataSetToSerialize = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid));
if(dataSetToSerialize == nullptr) {
@ -136,8 +137,9 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
// }
store_address_t storeId;
ReturnValue_t result = serializeHkPacketIntoStore(&storeId,
dataSetToSerialize);
HousekeepingPacketDownlink hkPacket(sid, collectionInterval,
dataSetToSerialize->getFillCount(), dataSetToSerialize);
ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, &storeId);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -166,6 +168,22 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
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) {
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid));
@ -199,33 +217,6 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
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() {
for(auto& hkReceiversIter: hkReceiversMap) {

View File

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

View File

@ -1,5 +1,6 @@
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
#include <framework/datapoollocal/LocalPoolDataSetBase.h>
#include <framework/housekeeping/HousekeepingMessage.h>
#include <framework/serialize/SerialLinkedListAdapter.h>
@ -18,40 +19,32 @@ public:
numberOfParameters, LocalPoolDataSetBase* dataSetPtr):
sourceId(sid.objectId), setId(sid.ownerSetId),
collectionInterval(collectionInterval),
numberOfParameters(numberOfParameters), dataSetPtr(dataSetPtr),
hkData(dataSetPtr) {
numberOfParameters(numberOfParameters), hkData(dataSetPtr) {
setLinks();
}
// 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 {
//
// }
/**
* Helper functions which can be used to move HK data from the IPC store
* to the telemetry store.
* @param formerStore
* @param storeId
* @param newStore
* @param newStoreId [out]
* @return
*/
virtual ReturnValue_t moveToOtherStore(StorageManagerIF* formerStore,
store_address_t storeId, StorageManagerIF* newStore,
store_address_t* newStoreId) {
const uint8_t* dataPtr = nullptr;
size_t hkDataSize = 0;
ReturnValue_t result = formerStore->getData(storeId, &dataPtr,
&hkDataSize);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
virtual ReturnValue_t moveToOtherStore(StorageManagerIF* formerStore,
store_address_t storeId, StorageManagerIF* otherStore,
store_address_t* newStoreId, uint8_t** buffer, size_t size) {
const uint8_t* dataPtr = nullptr;
size_t hkDataSize = 0;
ReturnValue_t result = formerStore->getData(storeId, &dataPtr, &hkDataSize);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
otherStore->addData(newStoreId, dataPtrgetSerializedSize(),
buffer);
std::memcpy
}
return newStore->addData(newStoreId, dataPtr, hkDataSize);
}
private:
void setLinks() {
@ -67,9 +60,22 @@ private:
SerializeElement<float> collectionInterval;
SerializeElement<uint8_t> numberOfParameters;
LinkedElement<SerializeIF> hkData;
LocalPoolDataSetBase* dataSetPtr;
};
#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
* internal housekeeping packets into the store.
* update housekeeping packets into the store.
*/
class HousekeepingPacketUpdate: public SerializeIF {
public:
@ -25,8 +25,8 @@ public:
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
size_t maxSize, Endianness streamEndianness) const {
if(timeStamp != nullptr) {
// Endianness will always be MACHINE, so we can simply use memcpy
// here.
/* Endianness will always be MACHINE, so we can simply use memcpy
here. */
std::memcpy(*buffer, timeStamp, timeStampSize);
*size += timeStampSize;
*buffer += timeStampSize;
@ -48,8 +48,8 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override {
if(timeStamp != nullptr) {
// Endianness will always be MACHINE, so we can simply use memcpy
// here.
/* Endianness will always be MACHINE, so we can simply use memcpy
here. */
std::memcpy(timeStamp, *buffer, timeStampSize);
*size += timeStampSize;
*buffer += timeStampSize;