VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Mavlink_demuxer Class Reference

Mavlink message demultiplexer based on message, system and component identifiers. More...

#include <mavlink_demuxer.h>

Classes

struct  Duplicate_handler_dummy_struct
 Thrown when handler with a given filtering criteria is already registered. More...
 

Public Types

typedef signed Message_id
 Helper type for Mavlink message id which is able to hold special values.
 
typedef int64_t System_id
 Helper type for Mavlink system id which is able to hold special values.
 
typedef signed Component_id
 Helper type for Mavlink component id which is able to hold special values.
 
typedef ugcs::vsm::Param_exception< Duplicate_handler_dummy_struct,> Duplicate_handler
 
template<mavlink::MESSAGE_ID_TYPE message_id, class Extention_type = mavlink::Extension>
using Handler = Callback_proxy< void, typename mavlink::Message< message_id, Extention_type >::Ptr >
 Handler type for the specific demultiplexed Mavlink message. More...
 
typedef Callback_proxy< bool, mavlink::MESSAGE_ID_TYPE, System_id, uint8_t, uint32_t > Default_handler
 Default handler which is called for all Mavlink messages which does not have a handler. More...
 

Public Member Functions

 Mavlink_demuxer (const Mavlink_demuxer &)=delete
 Delete copy constructor. More...
 
void Disable ()
 Should be called prior to intention to delete the instance. More...
 
void Register_default_handler (Default_handler handler)
 Register default handler. More...
 
template<mavlink::MESSAGE_ID_TYPE message_id, class Extention_type >
Key Register_handler (Handler< message_id, Extention_type > handler, System_id system_id=SYSTEM_ID_ANY, Component_id component_id=COMPONENT_ID_ANY, Request_processor::Ptr processor=nullptr)
 Register handler for specific Mavlink message, system id and component id. More...
 
bool Demux (Io_buffer::Ptr buffer, mavlink::MESSAGE_ID_TYPE message_id, System_id system_id, uint8_t component_id, uint32_t request_id)
 Demultiplex Mavlink message. More...
 
void Unregister_handler (Key &)
 Unregister handler using registration key. More...
 

Static Public Attributes

static constexpr Message_id MESSAGE_ID_ANY = -1
 Special value representing any Mavlink message id. More...
 
static constexpr System_id SYSTEM_ID_ANY = -1
 Special value representing any Mavlink system id. More...
 
static constexpr Component_id COMPONENT_ID_ANY = -1
 Special value representing any Mavlink component id. More...
 

Detailed Description

Mavlink message demultiplexer based on message, system and component identifiers.

Supposed to be conveniently used with Mavlink_decoder. Messages from different mavlink extensions but with same identifiers can not be demultiplexed simultaneously.

Member Typedef Documentation

Default handler which is called for all Mavlink messages which does not have a handler.

Returns
true message will be resubmitted to demuxer for further processing, otherwise false.
template<mavlink::MESSAGE_ID_TYPE message_id, class Extention_type = mavlink::Extension>
using ugcs::vsm::Mavlink_demuxer::Handler = Callback_proxy< void, typename mavlink::Message<message_id, Extention_type>::Ptr>

Handler type for the specific demultiplexed Mavlink message.

Constructor & Destructor Documentation

ugcs::vsm::Mavlink_demuxer::Mavlink_demuxer ( const Mavlink_demuxer )
delete

Delete copy constructor.

Member Function Documentation

bool ugcs::vsm::Mavlink_demuxer::Demux ( Io_buffer::Ptr  buffer,
mavlink::MESSAGE_ID_TYPE  message_id,
System_id  system_id,
uint8_t  component_id,
uint32_t  request_id 
)

Demultiplex Mavlink message.

Returns
true if message was handled by some non-default handler, otherwise false.
void ugcs::vsm::Mavlink_demuxer::Disable ( )

Should be called prior to intention to delete the instance.

void ugcs::vsm::Mavlink_demuxer::Register_default_handler ( Default_handler  handler)

Register default handler.

Called when more specific handler does not exist. Always called from the thread, which calls Demux method.

template<mavlink::MESSAGE_ID_TYPE message_id, class Extention_type >
Key ugcs::vsm::Mavlink_demuxer::Register_handler ( Handler< message_id, Extention_type >  handler,
System_id  system_id = SYSTEM_ID_ANY,
Component_id  component_id = COMPONENT_ID_ANY,
Request_processor::Ptr  processor = nullptr 
)
inline

Register handler for specific Mavlink message, system id and component id.

Parameters
handlerHandler taking specific Mavlink message.
system_idSystem id to call the handler for, or SYSTEM_ID_ANY to call the handler for any system id.
component_idComponent id to call the handler for, or COMPONENT_ID_ANY to call the handler for any component id.
processorIf given, specifies request processor in which context the handler should be executed, otherwise handler is executed from the thread which calls Demux method.
Returns
Valid registration key which can be used to unregister the handler later.
void ugcs::vsm::Mavlink_demuxer::Unregister_handler ( Key &  )

Unregister handler using registration key.

Key is invalidated upon exit from the method.

Member Data Documentation

constexpr Component_id ugcs::vsm::Mavlink_demuxer::COMPONENT_ID_ANY = -1
static

Special value representing any Mavlink component id.

constexpr Message_id ugcs::vsm::Mavlink_demuxer::MESSAGE_ID_ANY = -1
static

Special value representing any Mavlink message id.

constexpr System_id ugcs::vsm::Mavlink_demuxer::SYSTEM_ID_ANY = -1
static

Special value representing any Mavlink system id.


The documentation for this class was generated from the following file: