eive-obsw/mission/tmtc/PersistentTmStoreWithTmQueue.cpp

34 lines
1.1 KiB
C++
Raw Normal View History

2023-03-09 17:44:05 +01:00
#include "PersistentTmStoreWithTmQueue.h"
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/tmtcservices/TmTcMessage.h>
2023-03-09 19:42:20 +01:00
PersistentTmStoreWithTmQueue::PersistentTmStoreWithTmQueue(PersistentTmStoreArgs args,
const char* storeName,
2023-03-09 17:44:05 +01:00
uint32_t tmQueueDepth)
2023-03-09 19:42:20 +01:00
: PersistentTmStore(args), storeName(storeName) {
2023-03-09 17:44:05 +01:00
tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth);
}
ReturnValue_t PersistentTmStoreWithTmQueue::handleNextTm() {
TmTcMessage msg;
ReturnValue_t result = tmQueue->receiveMessage(&msg);
if (result == MessageQueueIF::EMPTY) {
return result;
}
auto accessor = tmStore.getData(msg.getStorageId());
if (accessor.first != returnvalue::OK) {
return result;
}
PusTmReader reader(accessor.second.data(), accessor.second.size());
2023-03-09 19:42:20 +01:00
storePacket(reader);
2023-03-09 17:44:05 +01:00
return returnvalue::OK;
}
2023-03-09 19:42:20 +01:00
const char* PersistentTmStoreWithTmQueue::getName() const { return storeName; }
MessageQueueId_t PersistentTmStoreWithTmQueue::getReportReceptionQueue(
uint8_t virtualChannel) const {
return tmQueue->getId();
}