Lumiverse  2.5
A framework for creating lighting control applications
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Lumiverse::DMXDevicePatch Class Reference

This class includes information on how to translate the device properties for a given device to DMX values. More...

#include <DMXDevicePatch.h>

Public Member Functions

 DMXDevicePatch (string mapKey, unsigned int baseAddress, unsigned int universe)
 Constructs an empty patch. More...
 
 ~DMXDevicePatch ()
 Destroys the patch object.
 
void updateDMX (unsigned char *data, Device *device, map< string, patchData > &dmxMap)
 Given a universe of DMX, update the device. More...
 
unsigned int getUniverse ()
 Gets the universe the device is patched to. More...
 
void setUniverse (unsigned char newUniverse)
 Sets the universe the device is patched to. More...
 
unsigned int getBaseAddress ()
 Gets the base address for the device. More...
 
void setBaseAddress (unsigned int newAddress)
 Sets the base address for the device. More...
 
string getDMXMapKey ()
 Gets the key for the DMX map this device should use to translate its Lumiverse values to DMX values. More...
 

Private Member Functions

void floatToSingle (unsigned char *data, unsigned int address, LumiverseFloat *val)
 Converts a float value to a single DMX channel of data. min-max -> 0-255. More...
 
void floatToFine (unsigned char *data, unsigned int address, float val)
 Converts a float value to two DMX channels of data. min-max -> 0 - 65535. More...
 
void toEnum (unsigned char *data, unsigned int address, LumiverseEnum *val)
 Converts an enum to a single DMX channel of data. More...
 
void RGBRepeat (unsigned char *data, unsigned int address, LumiverseFloat *val, int repeats)
 Converts a float value to a single DMX channel of data. min-max -> 0-255 and repeats it a number of times, offset by 3 each time. More...
 
void ColorToRGB (unsigned char *data, unsigned int address, LumiverseColor *val)
 Converts a LumiverseColor to 3 channels of DMX data. More...
 
void ColorToRGBW (unsigned char *data, unsigned int address, LumiverseColor *val)
 Converts a LumiverseColor to 4 channels of DMX data. More...
 
void ColorToLustrPlus (unsigned char *data, unsigned int address, LumiverseColor *val)
 Converts a LumiverseColor to 7 channels of DMX data. More...
 
void setDMXVal (unsigned char *data, unsigned int address, unsigned char val)
 Helper for setting DMX values. More...
 

Private Attributes

unsigned int m_baseAddress
 Base address for the device (zero-indexed)
 
unsigned int m_universe
 Universe number for the device (zero-indexed)
 
unsigned int m_numAddresses
 Number of addresses this device uses on a DMX network.
 
string m_dmxMapKey
 Key to get the map that maps device parameters to a start DMX address. More...
 

Detailed Description

This class includes information on how to translate the device properties for a given device to DMX values.

This information can be loaded from a JSON document while the base address is always set dynamically. Note that the map of parameter to relative DMX address is stored not in this object, but in the DMX Patch. This allows reuse of the patch data for similar instruments.

See also
DMXPatch, DMXDevicePatch, patchData

Constructor & Destructor Documentation

Lumiverse::DMXDevicePatch::DMXDevicePatch ( string  mapKey,
unsigned int  baseAddress,
unsigned int  universe 
)

Constructs an empty patch.

Parameters
mapKeyKey to lookup the DMX Map
baseAddressBase address for the device as a whole
universeUniverse the device lives in

Member Function Documentation

void Lumiverse::DMXDevicePatch::ColorToLustrPlus ( unsigned char *  data,
unsigned int  address,
LumiverseColor val 
)
private

Converts a LumiverseColor to 7 channels of DMX data.

Conversion assumes an ETC Source 4 LED Lustr+ in direct control mode. See https://www.etcconnect.com/WorkArea/DownloadAsset.aspx?id=10737461413

Parameters
dataDMX Universe buffer
addressAddress to write the value to
valLumiverseColor value to convert
void Lumiverse::DMXDevicePatch::ColorToRGB ( unsigned char *  data,
unsigned int  address,
LumiverseColor val 
)
private

Converts a LumiverseColor to 3 channels of DMX data.

This function assumes colors are laid out in standard RGB order.

Parameters
dataDMX universe buffer
addressAddress to write the value to.
valLumiverseColor value to convert.
void Lumiverse::DMXDevicePatch::ColorToRGBW ( unsigned char *  data,
unsigned int  address,
LumiverseColor val 
)
private

Converts a LumiverseColor to 4 channels of DMX data.

Conversion assumes that colors are laid out in standard RGBW order.

Parameters
dataDMX Universe buffer
addressAddress to write the value to
valLumiverseColor value to convert
void Lumiverse::DMXDevicePatch::floatToFine ( unsigned char *  data,
unsigned int  address,
float  val 
)
private

Converts a float value to two DMX channels of data. min-max -> 0 - 65535.

Corresponds to the FLOAT_TO_FINE and ORI_TO_FINE values of conversionType The first channel is the upper bits (coarse) and the second channel is the lower (fine) The given float must be between 0 and 1 otherwise overflow will occur.

Parameters
dataDMX Universe buffer
addressFirst address to write the value to (the coarse bits)
valThe float value to convert. Must be in the range [0, 1].
void Lumiverse::DMXDevicePatch::floatToSingle ( unsigned char *  data,
unsigned int  address,
LumiverseFloat val 
)
private

Converts a float value to a single DMX channel of data. min-max -> 0-255.

Corresponds to the FLOAT_TO_SINGLE value of conversionType

Parameters
dataDMX Universe buffer
addressAddress to write the value to
LumiverseFloatvalue to convert
unsigned int Lumiverse::DMXDevicePatch::getBaseAddress ( )
inline

Gets the base address for the device.

Returns
The Device's base address
string Lumiverse::DMXDevicePatch::getDMXMapKey ( )
inline

Gets the key for the DMX map this device should use to translate its Lumiverse values to DMX values.

Returns
The DMX map key for this patch object.
unsigned int Lumiverse::DMXDevicePatch::getUniverse ( )
inline

Gets the universe the device is patched to.

Returns
The Device's universe
void Lumiverse::DMXDevicePatch::RGBRepeat ( unsigned char *  data,
unsigned int  address,
LumiverseFloat val,
int  repeats 
)
private

Converts a float value to a single DMX channel of data. min-max -> 0-255 and repeats it a number of times, offset by 3 each time.

This function is meant to assist the programming of fixtures where less precision is required, but still have a large number of channels to deal with.

Parameters
dataDMX Universe buffer
addressAddress to write the value to
valLumiverseFloat value to convert
repeatsNumber of times to repeat the writing of the data.
void Lumiverse::DMXDevicePatch::setBaseAddress ( unsigned int  newAddress)
inline

Sets the base address for the device.

Parameters
newAddressThe new base address for the device
void Lumiverse::DMXDevicePatch::setDMXVal ( unsigned char *  data,
unsigned int  address,
unsigned char  val 
)
inlineprivate

Helper for setting DMX values.

Not as helpful for small functions but better to just write it once.

Parameters
dataDMX Universe buffer
addressAddress to write the value to
DMXvalue to write, single byte.
void Lumiverse::DMXDevicePatch::setUniverse ( unsigned char  newUniverse)
inline

Sets the universe the device is patched to.

Parameters
newUniverseThe new universe to patch the device to.
void Lumiverse::DMXDevicePatch::toEnum ( unsigned char *  data,
unsigned int  address,
LumiverseEnum val 
)
private

Converts an enum to a single DMX channel of data.

Corresponds to the ENUM value of conversionType

Parameters
dataDMX Universe buffer
addressFirst address to write the value to
valthe LumiverseEnum value to convert.
void Lumiverse::DMXDevicePatch::updateDMX ( unsigned char *  data,
Device device,
map< string, patchData > &  dmxMap 
)

Given a universe of DMX, update the device.

This function will throw logic errors if the device and the patch don't match up.

Parameters
dataBuffer of 512 bytes representing the universe to update
deviceThe Device to pull data from
dmxMapTable to DMX Maps to tell this function how to interpret the Device's data.

Member Data Documentation

string Lumiverse::DMXDevicePatch::m_dmxMapKey
private

Key to get the map that maps device parameters to a start DMX address.

The actual translation is handled by a function specified by the conversionType enum in the patchData struct. This value can be shared by multiple devices.


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