refactored TM funnels to allow multiple TM recipients
This commit is contained in:
@ -5,29 +5,21 @@
|
||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
||||
|
||||
CfdpTmFunnel::CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid,
|
||||
const AcceptsTelemetryIF& downlinkDestination, StorageManagerIF& tmStore,
|
||||
uint8_t vc)
|
||||
: SystemObject(objectId), cfdpInCcsdsApid(cfdpInCcsdsApid), tmStore(tmStore) {
|
||||
msgQueue = QueueFactory::instance()->createMessageQueue(5);
|
||||
msgQueue->setDefaultDestination(downlinkDestination.getReportReceptionQueue(vc));
|
||||
}
|
||||
StorageManagerIF& tmStore)
|
||||
: TmFunnelBase(objectId, tmStore, 10), cfdpInCcsdsApid(cfdpInCcsdsApid) {}
|
||||
|
||||
const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; }
|
||||
|
||||
MessageQueueId_t CfdpTmFunnel::getReportReceptionQueue(uint8_t virtualChannel) const {
|
||||
return msgQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) {
|
||||
TmTcMessage currentMessage;
|
||||
ReturnValue_t status = msgQueue->receiveMessage(¤tMessage);
|
||||
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
||||
while (status == returnvalue::OK) {
|
||||
status = handlePacket(currentMessage);
|
||||
if (status != returnvalue::OK) {
|
||||
sif::warning << "CfdpTmFunnel packet handling failed" << std::endl;
|
||||
break;
|
||||
}
|
||||
status = msgQueue->receiveMessage(¤tMessage);
|
||||
status = tmQueue->receiveMessage(¤tMessage);
|
||||
}
|
||||
|
||||
if (status == MessageQueueIF::EMPTY) {
|
||||
@ -74,12 +66,25 @@ ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) {
|
||||
// Delete old packet
|
||||
tmStore.deleteData(msg.getStorageId());
|
||||
msg.setStorageId(newStoreId);
|
||||
result = msgQueue->sendToDefault(&msg);
|
||||
if (result != returnvalue::OK) {
|
||||
tmStore.deleteData(msg.getStorageId());
|
||||
store_address_t origStoreId = newStoreId;
|
||||
for (unsigned int idx = 0; idx < destinations.size(); idx++) {
|
||||
const auto& destVcidPair = destinations[idx];
|
||||
if (idx <= destinations.size() - 1) {
|
||||
// Create copy of data to ensure each TM recipient has its own copy. That way, we don't need
|
||||
// to bother with send order and where the data is deleted.
|
||||
store_address_t storeId;
|
||||
result = tmStore.addData(&storeId, newPacketData, serSize);
|
||||
msg.setStorageId(storeId);
|
||||
} else {
|
||||
msg.setStorageId(origStoreId);
|
||||
}
|
||||
result = tmQueue->sendMessage(destVcidPair.first, &msg);
|
||||
if (result != returnvalue::OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CfdpTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl;
|
||||
sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl;
|
||||
#endif
|
||||
tmStore.deleteData(msg.getStorageId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user