Layout Control System (LCS)
Public Member Functions | List of all members
UDPMessage Class Reference

A class for handling UDP messages sent between controllers and the application server. More...

#include <UDPMessage.h>

Public Member Functions

 UDPMessage (void)
 
 UDPMessage (const UDPMessage &other)
 
 UDPMessage (const UDPMessageStruct &other)
 
UDPMessageoperator= (const UDPMessage &other)
 
bool isValid (void) const
 Returns true if the message is considered valid. At minimum, a valid message has its message ID set to a value greater than zero.
 
void setMessageID (unsigned char value)
 
void setID (long value)
 
void setField (unsigned char fieldIndex, unsigned char value)
 
int getDeviceID (unsigned char index) const
 returns the device ID from the device entry at the given index.
 
void setDeviceID (unsigned char index, int value)
 
int getDeviceStatus (unsigned char index) const
 returns the status from the device entry at the given index.
 
void setDeviceStatus (unsigned char index, int value)
 
char * getRef (void) const
 returns a reference to the internal UDPMessageStruct
 
unsigned char getMessageID (void) const
 returns the messageID.
 
long getID (void) const
 returns the ID
 
unsigned char getTransactionNumber (void) const
 returns the transaction number
 
void setTransactionNumber (unsigned char value)
 
unsigned char getField (unsigned char fieldIndex) const
 
void copyFrom (const UDPMessage &other)
 

Detailed Description

A class for handling UDP messages sent between controllers and the application server.

UDPMessage This class along with the Message Structure contains the data layout of a UDP message. Messages are sent from controller-to-controller in a peer-to-peer fasion using UDP uni-cast. Each controller contains a list of "controllers to notify" in its configuration data. Each time a device needs to send a command or status message, the controller's Network Manager sends the message to all controllers contained in the notification list. Each controller listens for the SYS_CONTROLLER_ONLINE broadcast message which is sent by each controller upon startup. Upon resceiving this message, the controller checks to see if the controller's ID is contained in its notification list and, if so, stores the address of the sending controller which is stored in field[0] - field[3] and then responds by sending device status messages. If the controller misses this message, the controller sends a SYS_FIND_CONTROLLER broadcast message every 3 seconds for each controller in its notification list until it recieves a corresponding SYS_CONTROLLER_ONLINE message from each controller.

Constructor & Destructor Documentation

◆ UDPMessage() [1/3]

UDPMessage::UDPMessage ( void  )

Contstructor Creates a blank, invalid contsturctor auto-generating the transaction number by incrementing the static

◆ UDPMessage() [2/3]

UDPMessage::UDPMessage ( const UDPMessage other)
inline

Copy constructor Creates a new UDPMessage copying the information from other creating an exact copy (including the transaction number)

Parameters
otherA UDPMessage to use as the soruce

◆ UDPMessage() [3/3]

UDPMessage::UDPMessage ( const UDPMessageStruct other)
inline

Convenience constructor Creates a new UDPMessage using the data supplied in the supplied UDPMessageStruct

Parameters
otherA UDPMessageStruct to use as the soruce

Member Function Documentation

◆ copyFrom()

void UDPMessage::copyFrom ( const UDPMessage other)
inline

replaces the data of the message creating a copy Replaces the message data; copying the information from other. This function does NOT copy the transaction number, rather, a new transaction number is created.

Parameters
otherA UDPMessage to use as the soruce

◆ getField()

unsigned char UDPMessage::getField ( unsigned char  fieldIndex) const
inline

Returns one of the bytes in the 32 byte payload.

Parameters
fieldIndexindex of the field to retrieve.

◆ operator=()

UDPMessage& UDPMessage::operator= ( const UDPMessage other)
inline

Assignment Replaces the message data; copying the information from other creating an exact copy (including the transaction number)

Parameters
otherA UDPMessage to use as the soruce

◆ setDeviceID()

void UDPMessage::setDeviceID ( unsigned char  index,
int  value 
)
inline

Setter function. Sets the device ID of one of the device entries.

Parameters
indexindex of the field to set
valuean int containing the device ID.

◆ setDeviceStatus()

void UDPMessage::setDeviceStatus ( unsigned char  index,
int  value 
)
inline

Setter function. Sets the status of one of the device entries.

Parameters
indexindex of the field to set
valuean int containing the status of the device.

◆ setField()

void UDPMessage::setField ( unsigned char  fieldIndex,
unsigned char  value 
)
inline

Setter function. Sets one of the bytes in the 32 byte payload.

Parameters
fieldIndexindex of the field to set
valuea byte containing the new value.

◆ setID()

void UDPMessage::setID ( long  value)
inline

Setter function. Sets the ID.

Parameters
valuean long integer value that represents the controller's ID, serial number or a route ID depending on the message.

◆ setMessageID()

void UDPMessage::setMessageID ( unsigned char  value)
inline

Setter function. Sets the message ID.

Parameters
valueMessage ID

◆ setTransactionNumber()

void UDPMessage::setTransactionNumber ( unsigned char  value)
inline

Setter function. Sets the transaction number overwriting the auto-generated number;

Parameters
valuethe new trasaction number.

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