2016-06-15 23:48:41 +02:00
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <framework/tcdistribution/CCSDSDistributor.h>
|
|
|
|
#include <framework/tmtcpacket/SpacePacketBase.h>
|
|
|
|
|
2020-07-08 02:20:38 +02:00
|
|
|
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
|
|
|
object_id_t setObjectId):
|
|
|
|
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2020-07-08 02:20:38 +02:00
|
|
|
CCSDSDistributor::~CCSDSDistributor() {}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-07-08 03:18:09 +02:00
|
|
|
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
2020-07-08 02:20:38 +02:00
|
|
|
// sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
|
|
|
// this->currentMessage.getStorageId().pool_index << ", " <<
|
|
|
|
// this->currentMessage.getStorageId().packet_index << std::endl;
|
|
|
|
const uint8_t* packet = nullptr;
|
2020-03-23 17:58:23 +01:00
|
|
|
size_t size = 0;
|
2020-07-08 02:20:38 +02:00
|
|
|
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
|
|
|
&packet, &size );
|
|
|
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
|
|
|
"store failed!" << std::endl;
|
|
|
|
}
|
|
|
|
SpacePacketBase currentPacket(packet);
|
|
|
|
|
|
|
|
// sif:: info << "CCSDSDistributor::selectDestination has packet with APID "
|
|
|
|
// << std::hex << currentPacket.getAPID() << std::dec << std::endl;
|
2020-07-08 03:18:09 +02:00
|
|
|
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
2016-06-15 23:48:41 +02:00
|
|
|
if ( position != this->queueMap.end() ) {
|
|
|
|
return position;
|
|
|
|
} else {
|
2020-07-08 02:20:38 +02:00
|
|
|
//The APID was not found. Forward packet to main SW-APID anyway to
|
|
|
|
// create acceptance failure report.
|
|
|
|
return this->queueMap.find( this->defaultApid );
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
|
2018-07-12 16:29:32 +02:00
|
|
|
return tcQueue->getId();
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t CCSDSDistributor::registerApplication(
|
|
|
|
AcceptsTelecommandsIF* application) {
|
|
|
|
ReturnValue_t returnValue = RETURN_OK;
|
|
|
|
bool errorCode = true;
|
|
|
|
errorCode = this->queueMap.insert( std::pair<uint32_t, MessageQueueId_t>( application->getIdentifier(), application->getRequestQueue() ) ).second;
|
|
|
|
if( errorCode == false ) {
|
|
|
|
returnValue = RETURN_FAILED;
|
|
|
|
}
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid,
|
|
|
|
MessageQueueId_t id) {
|
|
|
|
ReturnValue_t returnValue = RETURN_OK;
|
|
|
|
bool errorCode = true;
|
|
|
|
errorCode = this->queueMap.insert( std::pair<uint32_t, MessageQueueId_t>( apid, id ) ).second;
|
|
|
|
if( errorCode == false ) {
|
|
|
|
returnValue = RETURN_FAILED;
|
|
|
|
}
|
|
|
|
return returnValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t CCSDSDistributor::getIdentifier() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t CCSDSDistributor::initialize() {
|
|
|
|
ReturnValue_t status = this->TcDistributor::initialize();
|
|
|
|
this->tcStore = objectManager->get<StorageManagerIF>( objects::TC_STORE );
|
|
|
|
if (this->tcStore == NULL) status = RETURN_FAILED;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t CCSDSDistributor::callbackAfterSending(
|
|
|
|
ReturnValue_t queueStatus) {
|
|
|
|
if (queueStatus != RETURN_OK) {
|
|
|
|
tcStore->deleteData(currentMessage.getStorageId());
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|