mergCanBus
 All Classes Functions Typedefs
Message Class Reference

#include <Message.h>

Public Member Functions

 Message ()
 
 Message (unsigned int canId, unsigned int opc, unsigned int nodeNumber, unsigned int eventNumber, byte data[CANDATA_SIZE], unsigned int priority)
 
virtual ~Message ()
 
byte getByte (byte pos)
 
byte * getDataBuffer ()
 
void setDataBuffer (byte val[CANDATA_SIZE])
 
byte * getHeaderBuffer ()
 
void setHeaderBuffer (byte val[HEADER_SIZE])
 
byte getCanId ()
 
void setCanId (byte val)
 
byte getOpc ()
 
void setOpc (byte val)
 
message_type getType ()
 
void setType (message_type val)
 
unsigned int getEventNumber ()
 
void setEventNumber (unsigned int val)
 
unsigned int getNodeNumber ()
 
void setNodeNumber (unsigned int val)
 
unsigned int getDeviceNumber ()
 
void setDeviceNumber (unsigned int val)
 
byte getPriority ()
 
void setPriority (byte val)
 
byte getMessageSize ()
 
unsigned int getNumBytes ()
 
void setNumBytes (unsigned int val)
 
void setRTR ()
 
void unsetRTR ()
 
bool getRTR ()
 
void setSession (byte val)
 
byte getSession ()
 
unsigned int getDecoder ()
 
void setDecoder (unsigned int val)
 
unsigned int getCV ()
 
void setCV (unsigned int val)
 
unsigned int getCVMode ()
 
unsigned int getCVValue ()
 
byte getConsist ()
 
byte getSpeedDir ()
 
byte getEngineFlag ()
 
byte getAvailableEventsLeft ()
 
byte getStoredEvents ()
 
byte getFunctionNumber ()
 
byte functionValue ()
 
byte getStatus ()
 
byte getParaIndex ()
 
byte getParameter ()
 
byte getNodeVariableIndex ()
 
byte getNodeVariable ()
 
byte getEventIndex ()
 
byte getEventVarIndex ()
 
byte getEventVar ()
 
void clear ()
 
void setDebug (bool val)
 
byte getCanMessageSize ()
 
void setCanMessageSize (byte val)
 
bool isAccOn ()
 
bool isAccOff ()
 
bool isLongEvent ()
 
bool isShortEvent ()
 
byte accExtraData ()
 
byte getAccExtraData (byte idx)
 
void createOnEvent (unsigned int nodeNumber, bool longEvent, unsigned int eventNumber, byte numDataBytes, byte *data)
 
void createOffEvent (unsigned int nodeNumber, bool longEvent, unsigned int eventNumber, byte numDataBytes, byte *data)
 

Detailed Description

The Message class holds the detailed information about a can message. If works as a wrapper class over the can bus message. It extracts the information from the message based on the semantics of the message OPC. Still in fase of modification and cleanning.

Constructor & Destructor Documentation

Message::Message ( )

Constructor Clear the internal buffers and load the basic configuration.

Message::Message ( unsigned int  canId,
unsigned int  opc,
unsigned int  nodeNumber,
unsigned int  eventNumber,
byte  data[CANDATA_SIZE],
unsigned int  priority 
)

Creates a message to be sent. Not being used.

Message::~Message ( )
virtual

Destructor

Member Function Documentation

byte Message::accExtraData ( )

Return how many bytes of extra data has the ON event.

Returns
The number of extra bytes depending on the message type. ACON,ACOF=0 ; ACON1,ACOF1=1; ACON2,ACOF2=2; ACON3,ACOF1=3
void Message::clear ( )

Clear the internal structure.

byte Message::functionValue ( )

Get the function value for DCC messages

Returns
a 1 byte integer.
byte Message::getAccExtraData ( byte  idx)

Get the extra data byte on an ON or OFF event.

Returns
Return the extra byte. The index is between 1 and 3
byte Message::getAvailableEventsLeft ( )

Get the space left to store events

Returns
a 1 byte integer.
byte Message::getByte ( byte  pos)

Used to get the data fields directly

Parameters
posByte position.
byte Message::getCanId ( )

Get the Can id from the header.

Returns
message size.
byte Message::getCanMessageSize ( )

Get the message size. Extract it from the can frame.

Returns
message size.
byte Message::getConsist ( )

Get the consist value for DCC messages

Returns
a 1 byte integer.
unsigned int Message::getCV ( )

Get the decoder id for DCC messages

Returns
a 2 byte integer.
unsigned int Message::getCVMode ( )

Get the cv mode value for DCC messages

Returns
a 1 byte integer.
unsigned int Message::getCVValue ( )

Get the cv value for DCC messages

Returns
a 1 byte integer.
unsigned int Message::getDecoder ( )

Get the decoder id for DCC messages

Returns
a 2 byte integer.
unsigned int Message::getDeviceNumber ( )

Get the device number

Returns
a 16 bit integer.
byte Message::getEngineFlag ( )

Get the engine flags for DCC messages

Returns
a 1 byte integer.
byte Message::getEventIndex ( )

Get the event index EN# field

Returns
a 1 byte integer.
unsigned int Message::getEventNumber ( )

Get the event number

Returns
a 16 bit integer.
byte Message::getEventVar ( )

Get the event variable EV field

Returns
a 1 byte integer.
byte Message::getEventVarIndex ( )

Get the event variable index EV# field

Returns
a 1 byte integer.
byte Message::getFunctionNumber ( )

Get the function number Fn for DCC messages

Returns
a 1 byte integer.
byte Message::getMessageSize ( )

Get the CBUS message size. Extract it from the opc.

Returns
message size.
unsigned int Message::getNodeNumber ( )

Get the node number

Returns
a 16 bit integer.
byte Message::getNodeVariable ( )

Get the node variable NV field

Returns
a 1 byte integer.
byte Message::getNodeVariableIndex ( )

Get the node variable index NV# field

Returns
a 1 byte integer.
byte Message::getOpc ( )

first byte contains the opc and the number of bytes in the message the first 3 bits are the number of bytes the 5 last bits are the OPC

byte Message::getParaIndex ( )

Get the parameter index Para# field

Returns
a 1 byte integer.
byte Message::getParameter ( )

Get the parameter Para field

Returns
a 1 byte integer.
byte Message::getSession ( )

Get the loc session for DCC messages

Returns
a byte.
byte Message::getSpeedDir ( )

Get the speed direction for DCC messages

Returns
a 1 byte integer.
byte Message::getStatus ( )

Get the status field

Returns
a 1 byte integer.
byte Message::getStoredEvents ( )

Get the amount of stored events

Returns
a 1 byte integer.
bool Message::isAccOff ( )

Check the if it is an OFF message. Major event in CBUS.

Returns
True if is and OFF event, false if not
bool Message::isAccOn ( )

Check the if it is an ON message. Major event in CBUS.

Returns
True if is and On event, false if not
bool Message::isLongEvent ( )

Check the if it is an OFF message. Major event in CBUS.

Returns
True if is and OFF event, false if not
bool Message::isShortEvent ( )

Check the if it is an ON message. Major event in CBUS.

Returns
True if is and On event, false if not
void Message::setDataBuffer ( byte  val[CANDATA_SIZE])

Set the can buffer.

Parameters
valA 8 bytes array.
void Message::setHeaderBuffer ( byte  val[HEADER_SIZE])

Set the header buffer.

Parameters
valA 8 bytes array.

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