Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
industrial::message_manager::MessageManager Class Reference

The message manager handles communications for a simple server. More...

#include <message_manager.h>

List of all members.

Public Member Functions

bool add (industrial::message_handler::MessageHandler *handler, bool allow_replace=false)
 Adds a message handler to the manager.
industrial::comms_fault_handler::CommsFaultHandlergetCommsFaultHandler ()
 Gets communications fault handler.
unsigned int getMaxNumHandlers ()
 Gets maximumn number of handlers.
unsigned int getNumHandlers ()
 Gets number of handlers.
bool init (industrial::smpl_msg_connection::SmplMsgConnection *connection)
 Class initializer.
bool init (industrial::smpl_msg_connection::SmplMsgConnection *connection, industrial::comms_fault_handler::CommsFaultHandler *fault_handler)
 Class initializer.
 MessageManager ()
 Constructor.
void setCommsFaultHandler (industrial::comms_fault_handler::CommsFaultHandler *handler)
 Gets communications fault handler.
void spin ()
 Perform a indefinite execution of the message manager.
void spinOnce ()
 Perform an single execution of the message manager (a single receive and send (if required)
 ~MessageManager ()
 Destructor.

Private Member Functions

industrial::smpl_msg_connection::SmplMsgConnectiongetConnection ()
 Gets connection for manager.
industrial::simple_comms_fault_handler::SimpleCommsFaultHandlergetDefaultCommsFaultHandler ()
 Gets default communications fault handler.
industrial::message_handler::MessageHandlergetHandler (int msg_type)
 Gets message handler for specific message type.
int getHandlerIdx (int msg_type)
 Gets index of message handler for specific message type.
industrial::ping_handler::PingHandlergetPingHandler ()
 Gets ping handler.
void setConnection (industrial::smpl_msg_connection::SmplMsgConnection *connection)
 Sets connection manager.
void setNumHandlers (unsigned int num_handlers)
 Sets message type that callback expects.

Private Attributes

industrial::comms_fault_handler::CommsFaultHandlercomms_hndlr_
 Reference to comms handler.
industrial::smpl_msg_connection::SmplMsgConnectionconnection_
 Reference to reply connection (called if incoming message requires a reply)
industrial::simple_comms_fault_handler::SimpleCommsFaultHandler def_comms_hndlr_
 Internal default comms handler (this is used if a communications fault handler is not specified as part of the class init.
industrial::message_handler::MessageHandlerhandlers_ [MAX_NUM_HANDLERS]
 buffer of handlers
unsigned int num_handlers_
 Number of handlers.
industrial::ping_handler::PingHandler ping_hndlr_
 Internal ping handle (by default every message manager can handle pings)

Static Private Attributes

static const unsigned int MAX_NUM_HANDLERS = 64
 Maximum number of handlers.

Detailed Description

The message manager handles communications for a simple server.

The message manager receives simple messages via it's communications connection. It then performs function callbacks based on the message type. Callbacks perform the desired operation and send a reply, if required.

The message manager can be run in two ways. spin(), similar to ROS this executes a blocking execution indefinitely or spinOnce(), where a single execution of the manager is performed. In spinOnce mode, other server operations can be made, but the server application must make certain to execute the spinOnce() function at a minimum rate so as not to loose connection data.

THIS CLASS IS NOT THREAD-SAFE

Definition at line 74 of file message_manager.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 61 of file message_manager.cpp.

Destructor.

Definition at line 71 of file message_manager.cpp.


Member Function Documentation

Adds a message handler to the manager.

Parameters:
handlerhandler to add
replaceexisting handler (of same msg-type), if exists
Returns:
true if successful, otherwise false (max # of handlers reached)

Definition at line 201 of file message_manager.cpp.

Gets communications fault handler.

Returns:
reference to message handler or NULL if one doesn't exist

Definition at line 162 of file message_manager.h.

Gets connection for manager.

Returns:
connection reference

Definition at line 273 of file message_manager.h.

Gets default communications fault handler.

Returns:
reference to message handler or NULL if one doesn't exist

Definition at line 242 of file message_manager.h.

Gets message handler for specific message type.

Parameters:
msg_typemessage type to handle
Returns:
reference to message handler or NULL if one doesn't exist

Definition at line 244 of file message_manager.cpp.

Gets index of message handler for specific message type.

Parameters:
messagetype to handle
Returns:
index of matching handler or -1 if one doesn't exist

Definition at line 254 of file message_manager.cpp.

Gets maximumn number of handlers.

Returns:
connection reference

Definition at line 151 of file message_manager.h.

Gets number of handlers.

Returns:
connection reference

Definition at line 141 of file message_manager.h.

Gets ping handler.

Returns:
connection reference

Definition at line 251 of file message_manager.h.

Class initializer.

Parameters:
connectionsimple message connection that will be managed. This connection must be properly initialized and connected before it is passed to the manager.
Returns:
true on success, false otherwise

Definition at line 76 of file message_manager.cpp.

Class initializer.

Parameters:
simplemessage connection that will be managed. This connection must be properly initialized and connected before it is passed to the manager.
connectionfault handler to be used in case of a connection fault.
Returns:
true on success, false otherwise

Definition at line 98 of file message_manager.cpp.

Gets communications fault handler.

Parameters:
Pointerto message handler

Definition at line 172 of file message_manager.h.

Sets connection manager.

Parameters:
connectionconnection reference

Definition at line 262 of file message_manager.h.

void industrial::message_manager::MessageManager::setNumHandlers ( unsigned int  num_handlers) [inline, private]

Sets message type that callback expects.

Parameters:
msg_typemessage type

Definition at line 284 of file message_manager.h.

Perform a indefinite execution of the message manager.

Definition at line 184 of file message_manager.cpp.

Perform an single execution of the message manager (a single receive and send (if required)

Definition at line 132 of file message_manager.cpp.


Member Data Documentation

Reference to comms handler.

Definition at line 212 of file message_manager.h.

Reference to reply connection (called if incoming message requires a reply)

Definition at line 196 of file message_manager.h.

Internal default comms handler (this is used if a communications fault handler is not specified as part of the class init.

Definition at line 207 of file message_manager.h.

buffer of handlers

Definition at line 191 of file message_manager.h.

const unsigned int industrial::message_manager::MessageManager::MAX_NUM_HANDLERS = 64 [static, private]

Maximum number of handlers.

The number of handlers is limited in order to avoid dynamic memory allocation on robot controllers.

Definition at line 186 of file message_manager.h.

Number of handlers.

Definition at line 217 of file message_manager.h.

Internal ping handle (by default every message manager can handle pings)

Definition at line 201 of file message_manager.h.


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


simple_message
Author(s): Shaun Edwards
autogenerated on Sat Jun 8 2019 20:43:24