This class defines a simple messaging protocol for communicating with an industrial robot controller. More...
#include <simple_message.h>
Public Member Functions | |
int | getCommType () |
Gets message type(see CommType) | |
industrial::byte_array::ByteArray & | getData () |
Returns a reference to the internal data member. | |
int | getDataLength () |
Gets length of message data portion. | |
int | getMessageType () |
Gets message type(see StandardMsgType) | |
int | getMsgLength () |
Gets message length (total size, HEADER + data) | |
int | getReplyCode () |
Gets reply code(see ReplyType) | |
bool | init (int msgType, int commType, int replyCode, industrial::byte_array::ByteArray &data) |
Initializes a fully populated simple message. | |
bool | init (int msgType, int commType, int replyCode) |
Initializes a simple message with an emtpy data payload. | |
bool | init (industrial::byte_array::ByteArray &msg) |
Initializes a simple message from a generic byte array. The byte array is assumed to hold a valid message with a HEADER and data payload. | |
SimpleMessage () | |
Constructs an empty message. | |
void | toByteArray (industrial::byte_array::ByteArray &msg) |
Populates a raw byte array with the message. Any data stored in the passed in byte array is deleted. | |
bool | validateMessage () |
performs logical checks to ensure that the message is fully defined and adheres to the message conventions. | |
~SimpleMessage (void) | |
Destructs a message. | |
Static Public Member Functions | |
static unsigned int | getHeaderSize () |
Gets size of message header in bytes(fixed) | |
static unsigned int | getLengthSize () |
Gets size of message length member in bytes (fixed) | |
Private Member Functions | |
void | setCommType (int commType) |
Sets communications type. | |
void | setData (industrial::byte_array::ByteArray &data) |
Sets data portion. | |
void | setMessageType (int msgType) |
Sets message type. | |
void | setReplyCode (int replyCode) |
Sets reply code. | |
Private Attributes | |
industrial::shared_types::shared_int | comm_type_ |
Communications type(see CommType) | |
industrial::byte_array::ByteArray | data_ |
Message data portion. | |
industrial::shared_types::shared_int | message_type_ |
Message type(see StandardMsgType) | |
industrial::shared_types::shared_int | reply_code_ |
Reply code(see ReplyType) | |
Static Private Attributes | |
static const unsigned int | HEADER_SIZE |
Size(in bytes) of message header (fixed) | |
static const unsigned int | LENGTH_SIZE = sizeof(industrial::shared_types::shared_int) |
Size (in bytes) of message length parameter (fixed) |
This class defines a simple messaging protocol for communicating with an industrial robot controller.
The protocol meets the following requirements:
1. Format should be simple enough that code can be shared between ROS and the controller (for those controllers that support C/C++). For those controllers that do not support C/C++, the protocol must be simple enough to be decoded with the limited capabilities of the typical robot programming language. A corollary to this requirement is that the protocol should not be so onerous as to overwhelm the limited resources of the robot controller
2. Format should allow for data streaming (ROS topic like)
3. Format should allow for data reply (ROS service like)
4. The protocol is not intended to encapsulate version information It is up to individual developers to ensure that code developed for communicating platforms does not have any version conflicts (this includes message type identifiers).
Message Structure
THIS CLASS IS NOT THREAD-SAFE
Definition at line 160 of file simple_message.h.
Constructs an empty message.
Definition at line 53 of file simple_message.cpp.
Destructs a message.
Definition at line 57 of file simple_message.cpp.
int industrial::simple_message::SimpleMessage::getCommType | ( | ) | [inline] |
Gets message type(see CommType)
Definition at line 242 of file simple_message.h.
Returns a reference to the internal data member.
Definition at line 270 of file simple_message.h.
int industrial::simple_message::SimpleMessage::getDataLength | ( | ) | [inline] |
Gets length of message data portion.
Definition at line 263 of file simple_message.h.
static unsigned int industrial::simple_message::SimpleMessage::getHeaderSize | ( | ) | [inline, static] |
Gets size of message header in bytes(fixed)
Definition at line 221 of file simple_message.h.
static unsigned int industrial::simple_message::SimpleMessage::getLengthSize | ( | ) | [inline, static] |
Gets size of message length member in bytes (fixed)
Definition at line 228 of file simple_message.h.
int industrial::simple_message::SimpleMessage::getMessageType | ( | ) | [inline] |
Gets message type(see StandardMsgType)
Definition at line 235 of file simple_message.h.
int industrial::simple_message::SimpleMessage::getMsgLength | ( | ) | [inline] |
Gets message length (total size, HEADER + data)
Definition at line 256 of file simple_message.h.
int industrial::simple_message::SimpleMessage::getReplyCode | ( | ) | [inline] |
bool industrial::simple_message::SimpleMessage::init | ( | int | msgType, |
int | commType, | ||
int | replyCode, | ||
industrial::byte_array::ByteArray & | data | ||
) |
Initializes a fully populated simple message.
message | type. Globally unique message ID (see StandardMsgType) |
communications | types (see CommType) |
reply | code(see ReplyType), only valide if comms type is a reply |
data | payload for the message |
Definition at line 70 of file simple_message.cpp.
bool industrial::simple_message::SimpleMessage::init | ( | int | msgType, |
int | commType, | ||
int | replyCode | ||
) |
Initializes a simple message with an emtpy data payload.
message | type. Globally unique message ID (see StandardMsgType) |
communications | types (see CommType) |
reply | code(see ReplyType), only valide if comms type is a reply |
Definition at line 63 of file simple_message.cpp.
Initializes a simple message from a generic byte array. The byte array is assumed to hold a valid message with a HEADER and data payload.
valid | message (as bytes) |
Definition at line 82 of file simple_message.cpp.
void industrial::simple_message::SimpleMessage::setCommType | ( | int | commType | ) | [inline, private] |
Sets communications type.
communications | type |
Definition at line 328 of file simple_message.h.
void industrial::simple_message::SimpleMessage::setData | ( | industrial::byte_array::ByteArray & | data | ) | [private] |
void industrial::simple_message::SimpleMessage::setMessageType | ( | int | msgType | ) | [inline, private] |
void industrial::simple_message::SimpleMessage::setReplyCode | ( | int | replyCode | ) | [inline, private] |
void industrial::simple_message::SimpleMessage::toByteArray | ( | industrial::byte_array::ByteArray & | msg | ) |
Populates a raw byte array with the message. Any data stored in the passed in byte array is deleted.
byte | array to be populated |
Definition at line 113 of file simple_message.cpp.
performs logical checks to ensure that the message is fully defined and adheres to the message conventions.
Definition at line 134 of file simple_message.cpp.
industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::comm_type_ [private] |
Communications type(see CommType)
Definition at line 292 of file simple_message.h.
Message data portion.
Definition at line 302 of file simple_message.h.
const unsigned int industrial::simple_message::SimpleMessage::HEADER_SIZE [static, private] |
sizeof(industrial::shared_types::shared_int) + sizeof(industrial::shared_types::shared_int) + sizeof(industrial::shared_types::shared_int)
Size(in bytes) of message header (fixed)
Definition at line 307 of file simple_message.h.
const unsigned int industrial::simple_message::SimpleMessage::LENGTH_SIZE = sizeof(industrial::shared_types::shared_int) [static, private] |
Size (in bytes) of message length parameter (fixed)
Definition at line 314 of file simple_message.h.
industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::message_type_ [private] |
Message type(see StandardMsgType)
Definition at line 287 of file simple_message.h.
industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::reply_code_ [private] |
Reply code(see ReplyType)
Definition at line 297 of file simple_message.h.