Lumiverse  2.5
A framework for creating lighting control applications
DMXPatch.h
Go to the documentation of this file.
1 
4 #ifndef _DMXPATCH_H_
5 #define _DMXPATCH_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 
11 #include "../Patch.h"
12 #include "DMXDevicePatch.h"
13 #include "DMXInterface.h"
14 #include "../lib/libjson/libjson.h"
15 
16 #include <iostream>
17 
18 namespace Lumiverse {
19 
42  class DMXPatch : public Patch
43  {
44  public:
48  DMXPatch();
49 
55  DMXPatch(const JSONNode data);
56 
60  virtual ~DMXPatch();
61 
68  virtual void update(set<Device *> devices);
69 
76  virtual void init();
77 
81  virtual void close();
82 
88  virtual JSONNode toJSON();
89 
95  virtual string getType() { return "DMXPatch"; }
96 
97  virtual void deleteDevice(string id);
98 
99  // Gets a mapping of device parameters to addresses for the patch type.
100  // This is the full patch map.
101  // Entries should look something like "deviceId.paramName -> 1 / 25" (DMX example)
102  // virtual map<string, string> getPatchParams();
103 
104  // Maps Device IDs to starting addresses.
105  // This is a more concise view of the patch map compared to getPatchParams()
106  // virtual map<string, string> getPatchIDs();
107 
108  // Gets a map of patch data with implementation-defined options.
109  // Allows flexible querying of patches with implementation-specific details.
110  // virtual map<string, string> getPatchInfo(string opts);
111 
122  void assignInterface(DMXInterface* iface, unsigned int universe);
123 
127  void assignInterface(string iface, unsigned int universe);
128 
133  void removeInterface(unsigned int universe, string id = "");
134 
140  bool addInterface(DMXInterface* iface);
141 
148  void deleteInterface(string id);
149 
153  DMXInterface* getInterface(string id);
154 
164  void moveInterface(string id, unsigned int universeFrom, unsigned int universeTo);
165 
171  const multimap<string, unsigned int> getInterfaceInfo() { return m_ifacePatch; }
172 
182  void patchDevice(Device* device, DMXDevicePatch* patch);
183 
193  void patchDevice(string id, DMXDevicePatch* patch);
194 
199  DMXDevicePatch* getDevicePatch(string id);
200 
208  void addDeviceMap(string id, map<string, patchData> deviceMap);
209 
218  void addParameter(string mapId, string paramId, unsigned int address, conversionType type);
219 
223  void dumpUniverses();
224 
229  void dumpUniverse(unsigned int universe);
230 
243  bool setRawData(unsigned int universe, vector<unsigned char> univData);
244 
249  size_t sizeOfDeviceMap(string id);
250 
254  vector<string> getInterfaceIDs();
255 
256  private:
261  void loadJSON(const JSONNode data);
262 
267  void loadDeviceMaps(const JSONNode data);
268 
274  JSONNode deviceMapToJSON(string id, map<string, patchData> data);
275 
281  vector<vector<unsigned char> > m_universes;
282 
289  multimap<string, unsigned int> m_ifacePatch;
290 
297  map<string, DMXInterface*> m_interfaces;
298 
305  map<string, DMXDevicePatch*> m_patch;
306 
311  map<string, map<string, patchData> > m_deviceMaps;
312  };
313 }
314 
315 #endif
void moveInterface(string id, unsigned int universeFrom, unsigned int universeTo)
Moves an interface from a specified universe to a specified universe.
Definition: DMXPatch.cpp:402
size_t sizeOfDeviceMap(string id)
Gets the size in DMX addresses of the specified device map.
Definition: DMXPatch.cpp:469
void removeInterface(unsigned int universe, string id="")
Removes all interfaces from the selected universe Optionally specify a specific interface to remvoe f...
Definition: DMXPatch.cpp:364
void dumpUniverse(unsigned int universe)
Debug funtion that prints out all DMX values for a single universe.
Definition: DMXPatch.cpp:443
DMXPatch()
Constructs a DMXPatch object.
Definition: DMXPatch.cpp:26
Provides a common interface to various DMX devices.
Definition: DMXInterface.h:24
const multimap< string, unsigned int > getInterfaceInfo()
Returns the interface map. ID -> Universe.
Definition: DMXPatch.h:171
virtual void init()
Initializes connections and other network settings for the patch.
Definition: DMXPatch.cpp:247
conversionType
Enumeration maps to a function that performs the appropriate conversion from Lumiverse value to DMX v...
Definition: DMXDevicePatch.h:17
map< string, map< string, patchData > > m_deviceMaps
Stores information about device maps, which can be reused across devices. Key is the device map name...
Definition: DMXPatch.h:311
A Patch maps devices to output channels and handles the output of data to the network.
Definition: Patch.h:24
virtual JSONNode toJSON()
Exports a JSONNode with the data in this patch.
Definition: DMXPatch.cpp:264
void loadJSON(const JSONNode data)
Loads data from a parsed JSON object.
Definition: DMXPatch.cpp:34
This class includes information on how to translate the device properties for a given device to DMX v...
Definition: DMXDevicePatch.h:137
DMXInterface * getInterface(string id)
Returns a DMXInterface for editing.
Definition: DMXPatch.cpp:395
bool addInterface(DMXInterface *iface)
Adds an interface to the DMXPatch without assigning it to a universe.
Definition: DMXPatch.cpp:377
virtual ~DMXPatch()
Destroys the object.
Definition: DMXPatch.cpp:207
map< string, DMXInterface * > m_interfaces
DMX Interfaces controlled by this patch.
Definition: DMXPatch.h:297
vector< vector< unsigned char > > m_universes
Stores the state of the DMX universes.
Definition: DMXPatch.h:281
void dumpUniverses()
Debug function that prints out all DMX values for all universes in the patch.
Definition: DMXPatch.cpp:437
virtual void deleteDevice(string id)
Called when a device is deleted from the Rig.
Definition: DMXPatch.cpp:324
void deleteInterface(string id)
Deletes an interface with id "id" from the patch.
Definition: DMXPatch.cpp:385
vector< string > getInterfaceIDs()
Returns a list of the interface IDs used by this patch.
Definition: DMXPatch.cpp:510
bool setRawData(unsigned int universe, vector< unsigned char > univData)
Directly modifies the DMX data in the specified universe.
Definition: DMXPatch.cpp:453
void loadDeviceMaps(const JSONNode data)
Loads the device maps from a JSON node.
Definition: DMXPatch.cpp:177
Tells a DMXPatch how to interpret the Device data.
multimap< string, unsigned int > m_ifacePatch
Maps interface id to universe number (zero-indexed)
Definition: DMXPatch.h:289
JSONNode deviceMapToJSON(string id, map< string, patchData > data)
Converts a device map in the m_deviceMaps object into a JSON object.
Definition: DMXPatch.cpp:305
Base class describing how DMX Interfaces should act.
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
virtual void update(set< Device * > devices)
Updates the values sent to the DMX network given the list of devices in the rig.
Definition: DMXPatch.cpp:220
map< string, DMXDevicePatch * > m_patch
Maps devices to DMX outputs.
Definition: DMXPatch.h:305
void addParameter(string mapId, string paramId, unsigned int address, conversionType type)
Adds/modifies a parameter to/in a deviceMap.
Definition: DMXPatch.cpp:433
The DMX Patch object manages the communication between the DMX network and the Lumiverse devices...
Definition: DMXPatch.h:42
DMXDevicePatch * getDevicePatch(string id)
Gets a DMXDevicePatch for the specified Device.
Definition: DMXPatch.cpp:425
void addDeviceMap(string id, map< string, patchData > deviceMap)
Adds a device map to the Patch's database of mappings.
Definition: DMXPatch.cpp:429
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
void assignInterface(DMXInterface *iface, unsigned int universe)
Assigns an interface to a universe.
Definition: DMXPatch.cpp:329
virtual void close()
Closes connections to the interfaces.
Definition: DMXPatch.cpp:258
virtual string getType()
Gets the type of this object.
Definition: DMXPatch.h:95
void patchDevice(Device *device, DMXDevicePatch *patch)
Patches a given device to the given DMXDevicePatch.
Definition: DMXPatch.cpp:417