updates for PusDistributor

This commit is contained in:
Robin Müller 2022-07-27 14:40:51 +02:00
parent 059fb10558
commit 740644f2c8
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 15 additions and 25 deletions

View File

@ -9,12 +9,12 @@
#define PUS_DISTRIBUTOR_DEBUGGING 0
PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource, StorageManagerIF* store_)
CCSDSDistributorIF* distributor, StorageManagerIF* store_)
: TcDistributor(setObjectId),
store(store_),
checker(setApid, ccsds::PacketType::TC),
tcStatus(RETURN_FAILED),
packetSource(setPacketSource) {}
ccsdsDistributor(distributor),
tcStatus(RETURN_FAILED) {}
PusDistributor::~PusDistributor() = default;
@ -25,7 +25,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() {
<< storeId.packetIndex << std::endl;
#endif
auto queueMapIt = this->queueMap.end();
if (this->currentPacket == nullptr) {
if (reader.isNull()) {
return queueMapIt;
}
// TODO: Need to set the data
@ -135,12 +135,12 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
uint16_t PusDistributor::getIdentifier() { return checker.getApid(); }
ReturnValue_t PusDistributor::initialize() {
if (currentPacket == nullptr) {
// Should not happen, memory allocation failed!
if (store == nullptr) {
store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (store == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
auto* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
}
if(ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;
@ -149,13 +149,7 @@ ReturnValue_t PusDistributor::initialize() {
sif::printError("PusDistributor::initialize: Packet source invalid\n");
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
#endif
return RETURN_FAILED;
}
if (store == nullptr) {
store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (store == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
return ccsdsDistributor->registerApplication(this);
}

View File

@ -9,7 +9,7 @@
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
class PacketStorageHelper;
class CCSDSDistributorIF;
/**
* This class accepts PUS Telecommands and forwards them to Application
@ -27,7 +27,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource,
PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource,
StorageManagerIF* store = nullptr);
/**
* The destructor is empty.
@ -49,10 +49,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* TC Verification service.
*/
VerificationReporterIF* verifyChannel = nullptr;
/**
* The currently handled packet is stored here.
*/
PacketStorageHelper* currentPacket = nullptr;
//! Cached for initialization
CCSDSDistributorIF* ccsdsDistributor = nullptr;
PusTcReader reader;
/**
@ -61,8 +59,6 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
*/
ReturnValue_t tcStatus;
const object_id_t packetSource;
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.