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

The DMX Patch object manages the communication between the DMX network and the Lumiverse devices. More...

#include <DMXPatch.h>

Inheritance diagram for Lumiverse::DMXPatch:
Inheritance graph
[legend]
Collaboration diagram for Lumiverse::DMXPatch:
Collaboration graph
[legend]

Public Member Functions

 DMXPatch ()
 Constructs a DMXPatch object.
 
 DMXPatch (const JSONNode data)
 Construct DMXPatch from JSON data. More...
 
virtual ~DMXPatch ()
 Destroys the object.
 
virtual void update (set< Device * > devices)
 Updates the values sent to the DMX network given the list of devices in the rig. More...
 
virtual void init ()
 Initializes connections and other network settings for the patch. More...
 
virtual void close ()
 Closes connections to the interfaces.
 
virtual JSONNode toJSON ()
 Exports a JSONNode with the data in this patch. More...
 
virtual string getType ()
 Gets the type of this object. More...
 
virtual void deleteDevice (string id)
 Called when a device is deleted from the Rig. More...
 
void assignInterface (DMXInterface *iface, unsigned int universe)
 Assigns an interface to a universe. More...
 
void assignInterface (string iface, unsigned int universe)
 Assigns an interface already in the Patch to a universe.
 
void removeInterface (unsigned int universe, string id="")
 Removes all interfaces from the selected universe Optionally specify a specific interface to remvoe from the universe.
 
bool addInterface (DMXInterface *iface)
 Adds an interface to the DMXPatch without assigning it to a universe. More...
 
void deleteInterface (string id)
 Deletes an interface with id "id" from the patch. More...
 
DMXInterfacegetInterface (string id)
 Returns a DMXInterface for editing.
 
void moveInterface (string id, unsigned int universeFrom, unsigned int universeTo)
 Moves an interface from a specified universe to a specified universe. More...
 
const multimap< string, unsigned int > getInterfaceInfo ()
 Returns the interface map. ID -> Universe. More...
 
void patchDevice (Device *device, DMXDevicePatch *patch)
 Patches a given device to the given DMXDevicePatch. More...
 
void patchDevice (string id, DMXDevicePatch *patch)
 Alternate patch function which just specifies an ID in a string. More...
 
DMXDevicePatchgetDevicePatch (string id)
 Gets a DMXDevicePatch for the specified Device. More...
 
void addDeviceMap (string id, map< string, patchData > deviceMap)
 Adds a device map to the Patch's database of mappings. More...
 
void addParameter (string mapId, string paramId, unsigned int address, conversionType type)
 Adds/modifies a parameter to/in a deviceMap. More...
 
void dumpUniverses ()
 Debug function that prints out all DMX values for all universes in the patch.
 
void dumpUniverse (unsigned int universe)
 Debug funtion that prints out all DMX values for a single universe. More...
 
bool setRawData (unsigned int universe, vector< unsigned char > univData)
 Directly modifies the DMX data in the specified universe. More...
 
size_t sizeOfDeviceMap (string id)
 Gets the size in DMX addresses of the specified device map. More...
 
vector< string > getInterfaceIDs ()
 Returns a list of the interface IDs used by this patch.
 
- Public Member Functions inherited from Lumiverse::Patch
virtual ~Patch ()
 Virtual destructor.
 

Private Member Functions

void loadJSON (const JSONNode data)
 Loads data from a parsed JSON object. More...
 
void loadDeviceMaps (const JSONNode data)
 Loads the device maps from a JSON node. More...
 
JSONNode deviceMapToJSON (string id, map< string, patchData > data)
 Converts a device map in the m_deviceMaps object into a JSON object. More...
 

Private Attributes

vector< vector< unsigned char > > m_universes
 Stores the state of the DMX universes. More...
 
multimap< string, unsigned int > m_ifacePatch
 Maps interface id to universe number (zero-indexed) More...
 
map< string, DMXInterface * > m_interfaces
 DMX Interfaces controlled by this patch. More...
 
map< string, DMXDevicePatch * > m_patch
 Maps devices to DMX outputs. More...
 
map< string, map< string, patchData > > m_deviceMaps
 Stores information about device maps, which can be reused across devices. Key is the device map name.
 

Detailed Description

The DMX Patch object manages the communication between the DMX network and the Lumiverse devices.

To add interfaces to this particular patch, you make a new interface object and assign it to a universe. You can assign multiple interfaces to the same universe, and you can assign a single device to multiple universes. However the latter option is probably only useful if your single device handles multiple universes.

Patching devices is done by providing the DMXPatch with a map telling it which device ID goes to which address. That map will also contain information indicating how the LumiverseType should be converted to DMX values. These maps are then stored in a map within the DMXPatch using the device type they control as the key. This allows simple reuse and automatic map usage based on device types.

Note that the DMXPatch does not do additional configuration of the DMXInterface beyond what is described in the abstract DMXInterface class. You can access other implementation specific settings directly as permitted by the implementation.

See also
DMXDevicePatch, DMXInterface

Constructor & Destructor Documentation

Lumiverse::DMXPatch::DMXPatch ( const JSONNode  data)

Construct DMXPatch from JSON data.

Parameters
dataJSONNode containing the DMXPatch object data.

Member Function Documentation

void Lumiverse::DMXPatch::addDeviceMap ( string  id,
map< string, patchData deviceMap 
)

Adds a device map to the Patch's database of mappings.

This function will REPLACE a map that already exists.

Parameters
idDevice type id
deviceMapMapping of parameters to DMX addresses.
bool Lumiverse::DMXPatch::addInterface ( DMXInterface iface)

Adds an interface to the DMXPatch without assigning it to a universe.

Returns
true on success, false if an interface with the same name already exists.
void Lumiverse::DMXPatch::addParameter ( string  mapId,
string  paramId,
unsigned int  address,
conversionType  type 
)

Adds/modifies a parameter to/in a deviceMap.

Parameters
mapIdDevice map ID
paramIdParameter to modify
addressNew address for the parameter
typeConversion function to use for the parameter
void Lumiverse::DMXPatch::assignInterface ( DMXInterface iface,
unsigned int  universe 
)

Assigns an interface to a universe.

Interfaces allocated by the user will be freed by the patch either on program end or on unpatch. If the interface is already assigned to a universe, it will not be moved.

Parameters
ifacePointer to the interface object to use.
universeUniverse to assign to the interface
See also
moveInterface
void Lumiverse::DMXPatch::deleteDevice ( string  id)
virtual

Called when a device is deleted from the Rig.

Patches should clean up information about the device in question.

Implements Lumiverse::Patch.

void Lumiverse::DMXPatch::deleteInterface ( string  id)

Deletes an interface with id "id" from the patch.

Note that this will unmap ALL universes mapped to this interface and deallocate it.

Parameters
idInterface ID to delete.
JSONNode Lumiverse::DMXPatch::deviceMapToJSON ( string  id,
map< string, patchData data 
)
private

Converts a device map in the m_deviceMaps object into a JSON object.

Parameters
idDevice Map id to convert
dataMap data to put in the JSONNode
void Lumiverse::DMXPatch::dumpUniverse ( unsigned int  universe)

Debug funtion that prints out all DMX values for a single universe.

Parameters
universeUniverse to inspect
DMXDevicePatch * Lumiverse::DMXPatch::getDevicePatch ( string  id)

Gets a DMXDevicePatch for the specified Device.

Returns
DMXDevicePatch for the device. Nullptr if the patch doesn't exist.
const multimap<string, unsigned int> Lumiverse::DMXPatch::getInterfaceInfo ( )
inline

Returns the interface map. ID -> Universe.

Returns
Map of interface id to universe number.
virtual string Lumiverse::DMXPatch::getType ( )
inlinevirtual

Gets the type of this object.

Returns
String containing "DMXPatch"

Implements Lumiverse::Patch.

void Lumiverse::DMXPatch::init ( )
virtual

Initializes connections and other network settings for the patch.

Call this AFTER all interfaces have been assigned. May need to call again if interfaces change.

Implements Lumiverse::Patch.

void Lumiverse::DMXPatch::loadDeviceMaps ( const JSONNode  data)
private

Loads the device maps from a JSON node.

Parameters
dataJSON node containing the Device Map data
void Lumiverse::DMXPatch::loadJSON ( const JSONNode  data)
private

Loads data from a parsed JSON object.

Parameters
dataJSON data to load
void Lumiverse::DMXPatch::moveInterface ( string  id,
unsigned int  universeFrom,
unsigned int  universeTo 
)

Moves an interface from a specified universe to a specified universe.

If the interface isn't in "universeFrom" already it just gets assigned to "universeTo"

Parameters
idInterface ID to move
universeFromUniverse to move from
universeToUniverse to move to
void Lumiverse::DMXPatch::patchDevice ( Device device,
DMXDevicePatch patch 
)

Patches a given device to the given DMXDevicePatch.

At some point this should get nicer and do some stuff automatically for you (like looking up profiles on patch).

Parameters
deviceDevice to patch
patchInformation on how the device should be patched.
See also
DMXDevicePatch, Device
void Lumiverse::DMXPatch::patchDevice ( string  id,
DMXDevicePatch patch 
)

Alternate patch function which just specifies an ID in a string.

This class actually only needs the Device id property to handle mapping devices to DMX addresses.

Parameters
idDevice id to patch
patchInformation on how the device should be patched.
See also
DMXDevicePatch, Device
bool Lumiverse::DMXPatch::setRawData ( unsigned int  universe,
vector< unsigned char >  univData 
)

Directly modifies the DMX data in the specified universe.

Pushes the data to the proper interface after updating. Note that if the update loop is active, this probably won't do much of anything as the manual values will get overwritten by the update loop. To get around this, initialize the rig but don't call Rig::run(). Must give an entire universe to this function. If you don't provide the entire universe, the function returns false and doesn't do any updates.

Parameters
universeUniverse number to set data for
univDataData to set the universe to
Returns
True on success, false on failure
size_t Lumiverse::DMXPatch::sizeOfDeviceMap ( string  id)

Gets the size in DMX addresses of the specified device map.

Returns
Size of specified device map in terms of bytes (DMX addresses). Returns -1 if map does not exist.
JSONNode Lumiverse::DMXPatch::toJSON ( )
virtual

Exports a JSONNode with the data in this patch.

Returns
JSONNode containing the DMXPatch object

Implements Lumiverse::Patch.

void Lumiverse::DMXPatch::update ( set< Device * >  devices)
virtual

Updates the values sent to the DMX network given the list of devices in the rig.

The list of devices should be maintained outside of this class.

Implements Lumiverse::Patch.

Member Data Documentation

multimap<string, unsigned int> Lumiverse::DMXPatch::m_ifacePatch
private

Maps interface id to universe number (zero-indexed)

An interface can be mapped to multiple universes, since some devices have more than one output.

map<string, DMXInterface*> Lumiverse::DMXPatch::m_interfaces
private

DMX Interfaces controlled by this patch.

Maps interface ids to interface. This is a unique mapping.

See also
DMXInterface
map<string, DMXDevicePatch*> Lumiverse::DMXPatch::m_patch
private

Maps devices to DMX outputs.

This class will free DevicePatch objects given to it on destruction.

See also
DMXDevicePatch
vector<vector<unsigned char> > Lumiverse::DMXPatch::m_universes
private

Stores the state of the DMX universes.

Note that DMX Universe 1 is index 0 here due to one-indexing.


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