fsfw/datapoollocal/LocalDataPoolManager.cpp

84 lines
2.4 KiB
C++
Raw Normal View History

2020-06-07 02:22:18 +02:00
#include <framework/datapoollocal/LocalDataPoolManager.h>
2020-06-05 20:35:08 +02:00
#include <framework/datapoollocal/LocalDataSet.h>
2020-05-17 01:17:11 +02:00
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/ipc/MutexFactory.h>
#include <framework/ipc/MutexHelper.h>
2020-06-05 20:35:08 +02:00
#include <array>
2020-06-07 02:22:18 +02:00
LocalDataPoolManager::LocalDataPoolManager(OwnsLocalDataPoolIF* owner) {
2020-05-17 01:17:11 +02:00
if(owner == nullptr) {
sif::error << "HkManager: Invalid supplied owner!" << std::endl;
std::exit(0);
}
this->owner = owner;
mutex = MutexFactory::instance()->createMutex();
2020-06-05 20:35:08 +02:00
//owner->setMinimalHkSamplingFrequency();
2020-05-17 01:17:11 +02:00
}
2020-06-07 02:22:18 +02:00
LocalDataPoolManager::~LocalDataPoolManager() {}
2020-05-17 01:17:11 +02:00
2020-06-07 02:22:18 +02:00
ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
2020-05-17 01:17:11 +02:00
if(not mapInitialized) {
2020-06-07 02:22:18 +02:00
ReturnValue_t result =
owner->initializeHousekeepingPoolEntries(localDpMap);
2020-05-17 01:17:11 +02:00
if(result == HasReturnvaluesIF::RETURN_OK) {
mapInitialized = true;
}
return result;
}
2020-06-05 20:35:08 +02:00
sif::warning << "HousekeepingManager: The map" << std::endl;
2020-05-17 01:17:11 +02:00
return HasReturnvaluesIF::RETURN_OK;
}
2020-06-07 02:22:18 +02:00
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
2020-05-17 01:17:11 +02:00
CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
}
2020-06-07 02:22:18 +02:00
ReturnValue_t LocalDataPoolManager::printPoolEntry(
2020-06-05 20:35:08 +02:00
lp_id_t localPoolId) {
auto poolIter = localDpMap.find(localPoolId);
if (poolIter == localDpMap.end()) {
sif::debug << "HousekeepingManager::fechPoolEntry:"
" Pool entry not found." << std::endl;
2020-06-07 02:22:18 +02:00
return OwnsLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
2020-06-05 20:35:08 +02:00
}
poolIter->second->print();
return HasReturnvaluesIF::RETURN_OK;
}
2020-06-07 02:22:18 +02:00
MutexIF* LocalDataPoolManager::getMutexHandle() {
2020-05-17 01:17:11 +02:00
return mutex;
}
2020-06-05 20:35:08 +02:00
//void HousekeepingManager::setMinimalSamplingFrequency(float frequencySeconds) {
// this->samplingFrequency = frequencySeconds;
//
//}
2020-05-17 01:17:11 +02:00
2020-06-07 02:22:18 +02:00
void LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
2020-06-05 20:35:08 +02:00
LocalDataSet* dataSetToSerialize = dynamic_cast<LocalDataSet*>(
owner->getDataSetHandle(sid));
if(dataSetToSerialize == nullptr) {
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
" Set ID not found" << std::endl;
return;
}
std::array<uint8_t, 256> testBuffer = {};
uint8_t* dataPtr = testBuffer.data();
size_t size = 0;
dataSetToSerialize->serialize(&dataPtr, &size, testBuffer.size(),
false);
// and now we send it to the TM funnel or somewhere else
2020-05-17 01:17:11 +02:00
}
2020-06-07 02:22:18 +02:00
void LocalDataPoolManager::setHkPacketQueue(MessageQueueIF *msgQueue) {
2020-05-17 01:17:11 +02:00
this->hkPacketQueue = msgQueue;
}
2020-06-05 20:35:08 +02:00
2020-06-07 02:22:18 +02:00
const OwnsLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
2020-06-05 20:35:08 +02:00
return owner;
}