Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
industrial::simple_message::SimpleMessage Class Reference

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) More...
 
industrial::byte_array::ByteArraygetData ()
 Returns a reference to the internal data member. More...
 
int getDataLength ()
 Gets length of message data portion. More...
 
int getMessageType ()
 Gets message type(see StandardMsgType) More...
 
int getMsgLength ()
 Gets message length (total size, HEADER + data) More...
 
int getReplyCode ()
 Gets reply code(see ReplyType) More...
 
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. More...
 
bool init (int msgType, int commType, int replyCode)
 Initializes a simple message with an emtpy data payload. More...
 
bool init (int msgType, int commType, int replyCode, industrial::byte_array::ByteArray &data)
 Initializes a fully populated simple message. More...
 
 SimpleMessage ()
 Constructs an empty message. More...
 
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. More...
 
bool validateMessage ()
 performs logical checks to ensure that the message is fully defined and adheres to the message conventions. More...
 
 ~SimpleMessage (void)
 Destructs a message. More...
 

Static Public Member Functions

static unsigned int getHeaderSize ()
 Gets size of message header in bytes(fixed) More...
 
static unsigned int getLengthSize ()
 Gets size of message length member in bytes (fixed) More...
 

Private Member Functions

void setCommType (int commType)
 Sets communications type. More...
 
void setData (industrial::byte_array::ByteArray &data)
 Sets data portion. More...
 
void setMessageType (int msgType)
 Sets message type. More...
 
void setReplyCode (int replyCode)
 Sets reply code. More...
 

Private Attributes

industrial::shared_types::shared_int comm_type_
 Communications type(see CommType) More...
 
industrial::byte_array::ByteArray data_
 Message data portion. More...
 
industrial::shared_types::shared_int message_type_
 Message type(see StandardMsgType) More...
 
industrial::shared_types::shared_int reply_code_
 Reply code(see ReplyType) More...
 

Static Private Attributes

static const unsigned int HEADER_SIZE
 Size(in bytes) of message header (fixed) More...
 
static const unsigned int LENGTH_SIZE = sizeof(industrial::shared_types::shared_int)
 Size (in bytes) of message length parameter (fixed) More...
 

Detailed Description

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 164 of file simple_message.h.

Constructor & Destructor Documentation

◆ SimpleMessage()

industrial::simple_message::SimpleMessage::SimpleMessage ( )

Constructs an empty message.

Definition at line 53 of file simple_message.cpp.

◆ ~SimpleMessage()

industrial::simple_message::SimpleMessage::~SimpleMessage ( void  )

Destructs a message.

Definition at line 57 of file simple_message.cpp.

Member Function Documentation

◆ getCommType()

int industrial::simple_message::SimpleMessage::getCommType ( )
inline

Gets message type(see CommType)

Returns
communications type

Definition at line 246 of file simple_message.h.

◆ getData()

industrial::byte_array::ByteArray& industrial::simple_message::SimpleMessage::getData ( )
inline

Returns a reference to the internal data member.

Returns
reference to message data portion.

Definition at line 274 of file simple_message.h.

◆ getDataLength()

int industrial::simple_message::SimpleMessage::getDataLength ( )
inline

Gets length of message data portion.

Returns
message data length

Definition at line 267 of file simple_message.h.

◆ getHeaderSize()

static unsigned int industrial::simple_message::SimpleMessage::getHeaderSize ( )
inlinestatic

Gets size of message header in bytes(fixed)

Returns
message header size

Definition at line 225 of file simple_message.h.

◆ getLengthSize()

static unsigned int industrial::simple_message::SimpleMessage::getLengthSize ( )
inlinestatic

Gets size of message length member in bytes (fixed)

Returns
message header size

Definition at line 232 of file simple_message.h.

◆ getMessageType()

int industrial::simple_message::SimpleMessage::getMessageType ( )
inline

Gets message type(see StandardMsgType)

Returns
message type

Definition at line 239 of file simple_message.h.

◆ getMsgLength()

int industrial::simple_message::SimpleMessage::getMsgLength ( )
inline

Gets message length (total size, HEADER + data)

Returns
message length

Definition at line 260 of file simple_message.h.

◆ getReplyCode()

int industrial::simple_message::SimpleMessage::getReplyCode ( )
inline

Gets reply code(see ReplyType)

Returns
reply code

Definition at line 253 of file simple_message.h.

◆ init() [1/3]

bool industrial::simple_message::SimpleMessage::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.

Parameters
validmessage (as bytes)
Returns
true if valid message created

Definition at line 82 of file simple_message.cpp.

◆ init() [2/3]

bool industrial::simple_message::SimpleMessage::init ( int  msgType,
int  commType,
int  replyCode 
)

Initializes a simple message with an emtpy data payload.

Parameters
messagetype. Globally unique message ID (see StandardMsgType)
communicationstypes (see CommType)
replycode(see ReplyType), only valide if comms type is a reply
Returns
true if valid message created

Definition at line 63 of file simple_message.cpp.

◆ init() [3/3]

bool industrial::simple_message::SimpleMessage::init ( int  msgType,
int  commType,
int  replyCode,
industrial::byte_array::ByteArray data 
)

Initializes a fully populated simple message.

Parameters
messagetype. Globally unique message ID (see StandardMsgType)
communicationstypes (see CommType)
replycode(see ReplyType), only valide if comms type is a reply
datapayload for the message
Returns
true if valid message created

Definition at line 70 of file simple_message.cpp.

◆ setCommType()

void industrial::simple_message::SimpleMessage::setCommType ( int  commType)
inlineprivate

Sets communications type.

Parameters
communicationstype

Definition at line 332 of file simple_message.h.

◆ setData()

void industrial::simple_message::SimpleMessage::setData ( industrial::byte_array::ByteArray data)
private

Sets data portion.

Parameters
dataportion

Definition at line 128 of file simple_message.cpp.

◆ setMessageType()

void industrial::simple_message::SimpleMessage::setMessageType ( int  msgType)
inlineprivate

Sets message type.

Parameters
messagetype

Definition at line 325 of file simple_message.h.

◆ setReplyCode()

void industrial::simple_message::SimpleMessage::setReplyCode ( int  replyCode)
inlineprivate

Sets reply code.

Parameters
replycode

Definition at line 339 of file simple_message.h.

◆ toByteArray()

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.

Parameters
bytearray to be populated

Definition at line 113 of file simple_message.cpp.

◆ validateMessage()

bool industrial::simple_message::SimpleMessage::validateMessage ( )

performs logical checks to ensure that the message is fully defined and adheres to the message conventions.

Returns
true if message valid, false otherwise

Definition at line 134 of file simple_message.cpp.

Member Data Documentation

◆ comm_type_

industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::comm_type_
private

Communications type(see CommType)

Definition at line 296 of file simple_message.h.

◆ data_

industrial::byte_array::ByteArray industrial::simple_message::SimpleMessage::data_
private

Message data portion.

Definition at line 306 of file simple_message.h.

◆ HEADER_SIZE

const unsigned int industrial::simple_message::SimpleMessage::HEADER_SIZE
staticprivate
Initial value:

Size(in bytes) of message header (fixed)

Definition at line 311 of file simple_message.h.

◆ LENGTH_SIZE

const unsigned int industrial::simple_message::SimpleMessage::LENGTH_SIZE = sizeof(industrial::shared_types::shared_int)
staticprivate

Size (in bytes) of message length parameter (fixed)

Definition at line 318 of file simple_message.h.

◆ message_type_

industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::message_type_
private

Message type(see StandardMsgType)

Definition at line 291 of file simple_message.h.

◆ reply_code_

industrial::shared_types::shared_int industrial::simple_message::SimpleMessage::reply_code_
private

Reply code(see ReplyType)

Definition at line 301 of file simple_message.h.


The documentation for this class was generated from the following files:
industrial::shared_types::shared_int
int shared_int
Definition: shared_types.h:62


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53