pus TM funnel initialize not needed anymore

This commit is contained in:
Robin Müller 2022-10-17 16:37:35 +02:00
parent e0a383f0af
commit 88bbde520b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 12 additions and 27 deletions

View File

@ -63,7 +63,7 @@ void ObjectFactory::produceGenericObjects(PusTmFunnel **pusFunnel,
*ccsdsDistrib =
new CcsdsDistributor(common::COMMON_PUS_APID, objects::CCSDS_DISTRIBUTOR, &tcStore);
new PusDistributor(common::COMMON_PUS_APID, objects::PUS_DISTRIBUTOR, *ccsdsDistrib);
*pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, tmtcBridge, *stamperAndReader);
*pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, tmtcBridge, *stamperAndReader, tmStore);
auto *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, tmtcBridge, tmStore);
new TmFunnel(objects::TM_FUNNEL, **pusFunnel, *cfdpFunnel);
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */

View File

@ -5,8 +5,8 @@
#include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h"
PusTmFunnel::PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination,
TimeReaderIF &timeReader, uint32_t messageDepth)
: SystemObject(objectId), timeReader(timeReader) {
TimeReaderIF &timeReader, StorageManagerIF& tmStore, uint32_t messageDepth)
: SystemObject(objectId), timeReader(timeReader), tmStore(tmStore) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
tmQueue->setDefaultDestination(downlinkDestination.getReportReceptionQueue());
@ -22,7 +22,7 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) {
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while (status == returnvalue::OK) {
status = handlePacket(&currentMessage);
status = handlePacket(currentMessage);
if (status != returnvalue::OK) {
sif::warning << "TmFunnel packet handling failed" << std::endl;
break;
@ -36,10 +36,10 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) {
return status;
}
ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) {
ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage& message) {
uint8_t *packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size);
ReturnValue_t result = tmStore.modifyData(message.getStorageId(), &packetData, &size);
if (result != returnvalue::OK) {
return result;
}
@ -52,9 +52,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) {
sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT;
packet.updateErrorControl();
result = tmQueue->sendToDefault(message);
result = tmQueue->sendToDefault(&message);
if (result != returnvalue::OK) {
tmPool->deleteData(message->getStorageId());
tmStore.deleteData(message.getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl;
#endif
@ -64,18 +64,4 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) {
return result;
}
ReturnValue_t PusTmFunnel::initialize() {
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmPool == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly and implements "
"StorageManagerIF"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return SystemObject::initialize();
}
const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; }

View File

@ -20,21 +20,20 @@
class PusTmFunnel : public AcceptsTelemetryIF, public SystemObject {
public:
explicit PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination,
TimeReaderIF &timeReader, uint32_t messageDepth = 20);
TimeReaderIF &timeReader, StorageManagerIF& tmStore,
uint32_t messageDepth = 20);
[[nodiscard]] const char *getName() const override;
~PusTmFunnel() override;
[[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override;
ReturnValue_t performOperation(uint8_t operationCode);
ReturnValue_t initialize() override;
private:
uint16_t sourceSequenceCount = 0;
TimeReaderIF &timeReader;
StorageManagerIF& tmStore;
MessageQueueIF *tmQueue = nullptr;
StorageManagerIF *tmPool = nullptr;
ReturnValue_t handlePacket(TmTcMessage *message);
ReturnValue_t handlePacket(TmTcMessage& message);
};
#endif // FSFW_EXAMPLE_COMMON_PUSTMFUNNEL_H