The message manager handles communications for a simple server. More...
#include <message_manager.h>
| 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::CommsFaultHandler * | getCommsFaultHandler () | 
| 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::SmplMsgConnection * | getConnection () | 
| Gets connection for manager. | |
| industrial::simple_comms_fault_handler::SimpleCommsFaultHandler & | getDefaultCommsFaultHandler () | 
| Gets default communications fault handler. | |
| industrial::message_handler::MessageHandler * | getHandler (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::PingHandler & | getPingHandler () | 
| 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::CommsFaultHandler * | comms_hndlr_ | 
| Reference to comms handler. | |
| industrial::smpl_msg_connection::SmplMsgConnection * | connection_ | 
| 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::MessageHandler * | handlers_ [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. | |
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 80 of file message_manager.h.
Constructor.
Definition at line 59 of file message_manager.cpp.
Destructor.
Definition at line 69 of file message_manager.cpp.
| bool industrial::message_manager::MessageManager::add | ( | industrial::message_handler::MessageHandler * | handler, | 
| bool | allow_replace = false | ||
| ) | 
Adds a message handler to the manager.
| handler | handler to add | 
| replace | existing handler (of same msg-type), if exists | 
Definition at line 199 of file message_manager.cpp.
| industrial::comms_fault_handler::CommsFaultHandler* industrial::message_manager::MessageManager::getCommsFaultHandler | ( | ) |  [inline] | 
Gets communications fault handler.
Definition at line 168 of file message_manager.h.
| industrial::smpl_msg_connection::SmplMsgConnection* industrial::message_manager::MessageManager::getConnection | ( | ) |  [inline, private] | 
Gets connection for manager.
Definition at line 279 of file message_manager.h.
| industrial::simple_comms_fault_handler::SimpleCommsFaultHandler& industrial::message_manager::MessageManager::getDefaultCommsFaultHandler | ( | ) |  [inline, private] | 
Gets default communications fault handler.
Definition at line 248 of file message_manager.h.
| MessageHandler * industrial::message_manager::MessageManager::getHandler | ( | int | msg_type | ) |  [private] | 
Gets message handler for specific message type.
| msg_type | message type to handle | 
Definition at line 242 of file message_manager.cpp.
| int industrial::message_manager::MessageManager::getHandlerIdx | ( | int | msg_type | ) |  [private] | 
Gets index of message handler for specific message type.
| message | type to handle | 
Definition at line 252 of file message_manager.cpp.
| unsigned int industrial::message_manager::MessageManager::getMaxNumHandlers | ( | ) |  [inline] | 
Gets maximumn number of handlers.
Definition at line 157 of file message_manager.h.
| unsigned int industrial::message_manager::MessageManager::getNumHandlers | ( | ) |  [inline] | 
Gets number of handlers.
Definition at line 147 of file message_manager.h.
| industrial::ping_handler::PingHandler& industrial::message_manager::MessageManager::getPingHandler | ( | ) |  [inline, private] | 
| bool industrial::message_manager::MessageManager::init | ( | industrial::smpl_msg_connection::SmplMsgConnection * | connection | ) | 
Class initializer.
| connection | simple message connection that will be managed. This connection must be properly initialized and connected before it is passed to the manager. | 
Definition at line 74 of file message_manager.cpp.
| bool industrial::message_manager::MessageManager::init | ( | industrial::smpl_msg_connection::SmplMsgConnection * | connection, | 
| industrial::comms_fault_handler::CommsFaultHandler * | fault_handler | ||
| ) | 
Class initializer.
| simple | message connection that will be managed. This connection must be properly initialized and connected before it is passed to the manager. | 
| connection | fault handler to be used in case of a connection fault. | 
Definition at line 96 of file message_manager.cpp.
| void industrial::message_manager::MessageManager::setCommsFaultHandler | ( | industrial::comms_fault_handler::CommsFaultHandler * | handler | ) |  [inline] | 
Gets communications fault handler.
| Pointer | to message handler | 
Definition at line 178 of file message_manager.h.
| void industrial::message_manager::MessageManager::setConnection | ( | industrial::smpl_msg_connection::SmplMsgConnection * | connection | ) |  [inline, private] | 
Sets connection manager.
| connection | connection reference | 
Definition at line 268 of file message_manager.h.
| void industrial::message_manager::MessageManager::setNumHandlers | ( | unsigned int | num_handlers | ) |  [inline, private] | 
Sets message type that callback expects.
| msg_type | message type | 
Definition at line 290 of file message_manager.h.
Perform a indefinite execution of the message manager.
Definition at line 182 of file message_manager.cpp.
Perform an single execution of the message manager (a single receive and send (if required)
Definition at line 130 of file message_manager.cpp.
| industrial::comms_fault_handler::CommsFaultHandler* industrial::message_manager::MessageManager::comms_hndlr_  [private] | 
Reference to comms handler.
Definition at line 218 of file message_manager.h.
| industrial::smpl_msg_connection::SmplMsgConnection* industrial::message_manager::MessageManager::connection_  [private] | 
Reference to reply connection (called if incoming message requires a reply)
Definition at line 202 of file message_manager.h.
| industrial::simple_comms_fault_handler::SimpleCommsFaultHandler industrial::message_manager::MessageManager::def_comms_hndlr_  [private] | 
Internal default comms handler (this is used if a communications fault handler is not specified as part of the class init.
Definition at line 213 of file message_manager.h.
| industrial::message_handler::MessageHandler* industrial::message_manager::MessageManager::handlers_[MAX_NUM_HANDLERS]  [private] | 
buffer of handlers
Definition at line 197 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 192 of file message_manager.h.
| unsigned int industrial::message_manager::MessageManager::num_handlers_  [private] | 
Number of handlers.
Definition at line 223 of file message_manager.h.
| industrial::ping_handler::PingHandler industrial::message_manager::MessageManager::ping_hndlr_  [private] | 
Internal ping handle (by default every message manager can handle pings)
Definition at line 207 of file message_manager.h.