1
0
forked from fsfw/fsfw

tc distribution improvements

This commit is contained in:
2020-10-01 13:23:06 +02:00
parent 7c3f99ed2d
commit 89c4370d91
10 changed files with 331 additions and 267 deletions

View File

@ -1,31 +1,39 @@
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "CCSDSDistributor.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../tmtcpacket/SpacePacketBase.h"
CCSDSDistributor::CCSDSDistributor( uint16_t setDefaultApid, object_id_t setObjectId ) :
TcDistributor( setObjectId ), default_apid( setDefaultApid ), tcStore(NULL) {
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
object_id_t setObjectId):
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
}
CCSDSDistributor::~CCSDSDistributor() {
CCSDSDistributor::~CCSDSDistributor() {}
}
iterator_t CCSDSDistributor::selectDestination() {
// debug << "CCSDSDistributor::selectDestination received: " << this->currentMessage.getStorageId().pool_index << ", " << this->currentMessage.getStorageId().packet_index << std::endl;
const uint8_t* p_packet = NULL;
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
// sif::debug << "CCSDSDistributor::selectDestination received: " <<
// this->currentMessage.getStorageId().pool_index << ", " <<
// this->currentMessage.getStorageId().packet_index << std::endl;
const uint8_t* packet = nullptr;
size_t size = 0;
//TODO check returncode?
this->tcStore->getData( this->currentMessage.getStorageId(), &p_packet, &size );
SpacePacketBase current_packet( p_packet );
// info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex << current_packet.getAPID() << std::dec << std::endl;
iterator_t position = this->queueMap.find( current_packet.getAPID() );
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;
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
if ( position != this->queueMap.end() ) {
return position;
} else {
//The APID was not found. Forward packet to main SW-APID anyway to create acceptance failure report.
return this->queueMap.find( this->default_apid );
//The APID was not found. Forward packet to main SW-APID anyway to
// create acceptance failure report.
return this->queueMap.find( this->defaultApid );
}
}
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
@ -35,9 +43,9 @@ MessageQueueId_t CCSDSDistributor::getRequestQueue() {
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 ) {
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
application->getRequestQueue());
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
@ -46,9 +54,8 @@ ReturnValue_t CCSDSDistributor::registerApplication(
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 ) {
auto insertPair = this->queueMap.emplace(apid, id);
if(not insertPair.second) {
returnValue = RETURN_FAILED;
}
return returnValue;
@ -62,7 +69,11 @@ uint16_t CCSDSDistributor::getIdentifier() {
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;
if (this->tcStore == nullptr) {
sif::error << "CCSDSDistributor::initialize: Could not initialize"
" TC store!" << std::endl;
status = RETURN_FAILED;
}
return status;
}