1
0
forked from fsfw/fsfw

message arriving.

big clean up in tcdistribution folder
This commit is contained in:
2020-07-08 02:20:38 +02:00
parent 399fc0e287
commit 2efcda735f
12 changed files with 253 additions and 174 deletions

View File

@ -1,5 +1,6 @@
#ifndef TCDISTRIBUTOR_H_
#define TCDISTRIBUTOR_H_
#ifndef FRAMEWORK_TMTCSERVICES_TCDISTRIBUTOR_H_
#define FRAMEWORK_TMTCSERVICES_TCDISTRIBUTOR_H_
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
@ -9,16 +10,12 @@
#include <framework/ipc/MessageQueueIF.h>
#include <map>
/**
* \defgroup tc_distribution Telecommand Distribution
* All classes associated with Routing and Distribution of Telecommands belong to this group.
* @defgroup tc_distribution Telecommand Distribution
* All classes associated with Routing and Distribution of Telecommands
* belong to this group.
*/
/**
* This typedef simplifies writing down the \c map iterator.
*/
typedef std::map<uint32_t, MessageQueueId_t>::iterator iterator_t;
/**
* This is the base class to implement distributors for Space Packets.
@ -28,59 +25,15 @@ typedef std::map<uint32_t, MessageQueueId_t>::iterator iterator_t;
* message queue ids to some identifier. The process of unpacking the
* destination information from the packet is handled by the child class
* implementations.
* \ingroup tc_distribution
* @ingroup tc_distribution
*/
class TcDistributor : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
private:
/**
* This constant sets the maximum number of packets distributed per call.
*/
static const uint8_t DISTRIBUTER_MAX_PACKETS = 128;
protected:
/**
* This is the receiving queue for incoming Telecommands.
* The child classes must make its queue id public.
*/
MessageQueueIF* tcQueue;
/**
* The last received incoming packet information is stored in this
* member.
* As different child classes unpack the incoming packet differently
* (i.e. as a CCSDS Space Packet or as a PUS Telecommand Packet), it
* is not tried to unpack the packet information within this class.
*/
TmTcMessage currentMessage;
/**
* The map that links certain packet information to a destination.
* The packet information may be the APID of the packet or the service
* identifier. Filling of the map is under control of the different child
* classes.
*/
std::map<uint32_t, MessageQueueId_t> queueMap;
/**
* This method shall unpack the routing information from the incoming
* packet and select the map entry which represents the packet's target.
* @return An iterator to the map element to forward to or queuMap.end().
*/
virtual iterator_t selectDestination() = 0;
/**
* The handlePacket method calls the child class's selectDestination method
* and forwards the packet to its destination, if found.
* @return The message queue return value or \c RETURN_FAILED, in case no
* destination was found.
*/
ReturnValue_t handlePacket();
/**
* This method gives the child class a chance to perform some kind of operation
* after the parent tried to forward the message.
* A typically application would be sending success/failure messages.
* The default implementation just returns \c RETURN_OK.
* @param queueStatus The status of the message queue after an attempt to send the TC.
* @return - \c RETURN_OK on success
* - \c RETURN_FAILED on failure
*/
virtual ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus );
class TcDistributor : public SystemObject,
public ExecutableObjectIF,
public HasReturnvaluesIF {
public:
using TcMessageQueueMap = std::map<uint32_t, MessageQueueId_t>;
using TcMessageQueueMapIter = std::map<uint32_t, MessageQueueId_t>::iterator;
static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_DISTRIBUTION;
static const ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE( 1 );
static const ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE( 2 );
@ -110,6 +63,57 @@ public:
* queueMap.
*/
void print();
protected:
/**
* This is the receiving queue for incoming Telecommands.
* The child classes must make its queue id public.
*/
MessageQueueIF* tcQueue;
/**
* The last received incoming packet information is stored in this
* member.
* As different child classes unpack the incoming packet differently
* (i.e. as a CCSDS Space Packet or as a PUS Telecommand Packet), it
* is not tried to unpack the packet information within this class.
*/
TmTcMessage currentMessage;
/**
* The map that links certain packet information to a destination.
* The packet information may be the APID of the packet or the service
* identifier. Filling of the map is under control of the different child
* classes.
*/
TcMessageQueueMap queueMap;
/**
* This method shall unpack the routing information from the incoming
* packet and select the map entry which represents the packet's target.
* @return An iterator to the map element to forward to or queuMap.end().
*/
virtual TcMessageQueueMapIter selectDestination() = 0;
/**
* The handlePacket method calls the child class's selectDestination method
* and forwards the packet to its destination, if found.
* @return The message queue return value or \c RETURN_FAILED, in case no
* destination was found.
*/
ReturnValue_t handlePacket();
/**
* This method gives the child class a chance to perform some kind of operation
* after the parent tried to forward the message.
* A typically application would be sending success/failure messages.
* The default implementation just returns \c RETURN_OK.
* @param queueStatus The status of the message queue after an attempt to send the TC.
* @return - \c RETURN_OK on success
* - \c RETURN_FAILED on failure
*/
virtual ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus );
private:
/**
* This constant sets the maximum number of packets distributed per call.
*/
static const uint8_t DISTRIBUTER_MAX_PACKETS = 128;
};