Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ola::rdm::UID Class Reference

Detailed Description

Represents a RDM UID.

UIDs are 6 bytes, the first two bytes are the manufacturer code and the last 4 bytes are the device id. UIDs are written as:

XXXX:YYYYYYYY

Classes

struct  rdm_uid

Public Types

enum  { LENGTH = 6 }
enum  { UID_SIZE = 6 }

Public Member Functions

 UID (uint16_t esta_id, uint32_t device_id)
 Constructs a new UID.
 UID (const UID &uid)
 Copy constructor.
 UID (const uint8_t *data)
 Construct a new UID from binary data.
UIDoperator= (const UID &other)
 Assignment operator.
bool operator== (const UID &other) const
 Equality operator.
bool operator!= (const UID &other) const
 Inequality operator.
bool operator> (const UID &other) const
 Greater than.
bool operator< (const UID &other) const
 Less than.
uint16_t ManufacturerId () const
 The manufacturer ID for this UID.
uint32_t DeviceId () const
 The device ID for this UID.
bool IsBroadcast () const
 Check if this UID is a broadcast or vendorcast UID.
bool DirectedToUID (const UID &uid) const
 Check if this UID matches against another.
std::string ToString () const
 Convert a UID to a human readable string.
bool Pack (uint8_t *buffer, unsigned int length) const
 Write the binary representation of the UID to memory.

Static Public Member Functions

static UID AllDevices ()
 Returns a UID that matches all devices (ffff:ffffffff).
static UID VendorcastAddress (uint16_t esta_id)
 Returns a UID that matches all devices for a particular manufacturer.
static UID VendorcastAddress (UID uid)
 Returns a UID that matches all devices for a particular manufacturer.
static UIDFromString (const std::string &uid)
 Return a new UID from a string.

Static Public Attributes

static const uint16_t ALL_MANUFACTURERS = 0xffff
 The value for the 'all manufacturers' id.
static const uint32_t ALL_DEVICES = 0xffffffff
 The value for the 'all devices' id.

Friends

std::ostream & operator<< (std::ostream &out, const UID &uid)
 A helper function to write a UID to an ostream.

Member Enumeration Documentation

anonymous enum

The size of a UID.

Enumerator:
UID_SIZE 

The size of a UID in binary form

Constructor & Destructor Documentation

ola::rdm::UID::UID ( uint16_t  esta_id,
uint32_t  device_id 
)
inline

Constructs a new UID.

Parameters
esta_idthe ESTA (manufacturer ID).
device_idthe device ID.
ola::rdm::UID::UID ( const UID uid)
inline

Copy constructor.

Parameters
uidthe UID to copy.
ola::rdm::UID::UID ( const uint8_t *  data)
inlineexplicit

Construct a new UID from binary data.

Parameters
dataa pointer to the memory containing the UID data. The data should be most significant byte first.

Member Function Documentation

static UID ola::rdm::UID::AllDevices ( )
inlinestatic

Returns a UID that matches all devices (ffff:ffffffff).

Returns
a UID(0xffff, 0xffffffff).
uint32_t ola::rdm::UID::DeviceId ( ) const
inline

The device ID for this UID.

Returns
the device id for this UID.
bool ola::rdm::UID::DirectedToUID ( const UID uid) const
inline

Check if this UID matches against another.

Parameters
uidthe UID to check against
Returns
true if the UIDs are equal or if this UID is a broadcast UID and the uid argument falls within the broadcast range.

This is useful to determine if a responder should reply to a message.

Example
UID uid(0x7a70, 1);
uid.DirectedToUID(uid); // always true.
UID broadcast_uid(UID::AllDevices());
broadcast_uid.DirectedToUID(uid); // true
UID vendorcast_uid(UID::VendorcastAddress(0x7a70));
vendorcast_uid.DirectedToUID(uid); // true
UID other_vendorcast_uid(UID::VendorcastAddress(0x0808));
other_vendorcast_uid.DirectedToUID(uid); // false
UID * ola::rdm::UID::FromString ( const std::string &  uid)
static

Return a new UID from a string.

Parameters
uidthe UID as a string i.e. XXXX:YYYYYYYY.
Returns
a new UID object, or NULL if the string is not a valid UID. Ownership of the new UID object is transferred to the caller.
bool ola::rdm::UID::IsBroadcast ( ) const
inline

Check if this UID is a broadcast or vendorcast UID.

Returns
true if the device id is 0xffffffff.
uint16_t ola::rdm::UID::ManufacturerId ( ) const
inline

The manufacturer ID for this UID.

Returns
the manufacturer id for this UID.
bool ola::rdm::UID::operator!= ( const UID other) const
inline

Inequality operator.

Parameters
otherthe UID to compare to.
bool ola::rdm::UID::operator< ( const UID other) const
inline

Less than.

Parameters
otherthe UID to compare to.
bool ola::rdm::UID::operator== ( const UID other) const
inline

Equality operator.

Parameters
otherthe UID to compare to.
bool ola::rdm::UID::operator> ( const UID other) const
inline

Greater than.

Parameters
otherthe UID to compare to.
bool ola::rdm::UID::Pack ( uint8_t *  buffer,
unsigned int  length 
) const
inline

Write the binary representation of the UID to memory.

Parameters
buffera pointer to memory to write the UID to
lengththe size of the memory block, should be at least UID_SIZE.
Returns
true if length was >= UID_SIZE, false otherwise.
std::string ola::rdm::UID::ToString ( ) const
inline

Convert a UID to a human readable string.

Returns
a string in the form XXXX:YYYYYYYY.
static UID ola::rdm::UID::VendorcastAddress ( uint16_t  esta_id)
inlinestatic

Returns a UID that matches all devices for a particular manufacturer.

Parameters
esta_idthe manufacturer id of the devices to match.
Returns
a UID(X, 0xffffffff).
static UID ola::rdm::UID::VendorcastAddress ( UID  uid)
inlinestatic

Returns a UID that matches all devices for a particular manufacturer.

Parameters
uida UID whose manufacturer id you want to match.
Returns
a UID(X, 0xffffffff).

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const UID uid 
)
friend

A helper function to write a UID to an ostream.

Parameters
outthe ostream
uidthe UID to write.

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