Lumiverse
2.5
A framework for creating lighting control applications
|
The DMX Patch object manages the communication between the DMX network and the Lumiverse devices. More...
#include <DMXPatch.h>
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... | |
DMXInterface * | getInterface (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... | |
DMXDevicePatch * | getDevicePatch (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. | |
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.
Lumiverse::DMXPatch::DMXPatch | ( | const JSONNode | data | ) |
void Lumiverse::DMXPatch::addDeviceMap | ( | string | id, |
map< string, patchData > | deviceMap | ||
) |
bool Lumiverse::DMXPatch::addInterface | ( | DMXInterface * | iface | ) |
Adds an interface to the DMXPatch without assigning it to a universe.
void Lumiverse::DMXPatch::addParameter | ( | string | mapId, |
string | paramId, | ||
unsigned int | address, | ||
conversionType | type | ||
) |
Adds/modifies a parameter to/in a deviceMap.
mapId | Device map ID |
paramId | Parameter to modify |
address | New address for the parameter |
type | Conversion 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.
iface | Pointer to the interface object to use. |
universe | Universe to assign to the interface |
|
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.
id | Interface ID to delete. |
|
private |
Converts a device map in the m_deviceMaps object into a JSON object.
id | Device Map id to convert |
data | Map 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.
universe | Universe to inspect |
DMXDevicePatch * Lumiverse::DMXPatch::getDevicePatch | ( | string | id | ) |
Gets a DMXDevicePatch for the specified Device.
|
inline |
Returns the interface map. ID -> Universe.
|
inlinevirtual |
|
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.
|
private |
Loads the device maps from a JSON node.
data | JSON node containing the Device Map data |
|
private |
Loads data from a parsed JSON object.
data | JSON 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"
id | Interface ID to move |
universeFrom | Universe to move from |
universeTo | Universe 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).
device | Device to patch |
patch | Information on how the device should be patched. |
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.
id | Device id to patch |
patch | Information on how the device should be patched. |
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.
universe | Universe number to set data for |
univData | Data to set the universe to |
size_t Lumiverse::DMXPatch::sizeOfDeviceMap | ( | string | id | ) |
Gets the size in DMX addresses of the specified device map.
|
virtual |
Exports a JSONNode with the data in this patch.
Implements Lumiverse::Patch.
|
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.
|
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.
|
private |
DMX Interfaces controlled by this patch.
Maps interface ids to interface. This is a unique mapping.
|
private |
Maps devices to DMX outputs.
This class will free DevicePatch objects given to it on destruction.
|
private |
Stores the state of the DMX universes.
Note that DMX Universe 1 is index 0 here due to one-indexing.