Lumiverse  2.5
A framework for creating lighting control applications
Programmer.h
1 #ifndef _PROGRAMMER_H_
2 #define _PROGRAMMER_H_
3 
4 #pragma once
5 
6 #include "Rig.h"
7 #include "Timeline.h"
8 #include "Cue.h"
9 
10 namespace Lumiverse {
11 namespace ShowControl {
12 
25 {
26 public:
32  Programmer(Rig* rig);
33 
37  Programmer(Rig* rig, JSONNode data);
38 
42  ~Programmer();
43 
53  void setParam(DeviceSet selection, string param, LumiverseType* val);
54 
65  void setParam(string selection, string param, LumiverseType* val);
66 
67  // --------------------------------------------------------------------------
68  // Convenience set functions
69  // The following functions are pretty much identical to the setParam
70  // functions in DeviceSet.
71 
72  void setParam(DeviceSet selection, string param, float val);
73  void setParam(DeviceSet selection, string param, string val, float val2 = -1.0f);
74  void setParam(DeviceSet selection, string param, string channel, double val);
75  void setParam(DeviceSet selection, string param, double x, double y, double weight = 1.0);
76  void setParam(DeviceSet selection, string param, string val, float val2, LumiverseEnum::Mode mode, LumiverseEnum::InterpolationMode interpMode);
77  void setColorRGB(DeviceSet selection, string param, double r, double g, double b, double weight = 1.0, RGBColorSpace cs = sRGB);
78  void setColorRGBRaw(DeviceSet selection, string param, double r, double g, double b, double weight = 1.0);
79 
80  void setParam(string selection, string param, float val);
81  void setParam(string selection, string param, string val, float val2 = -1.0f);
82  void setParam(string selection, string param, string channel, double val);
83  void setParam(string selection, string param, double x, double y, double weight = 1.0);
84  void setParam(string selection, string param, string val, float val2, LumiverseEnum::Mode mode, LumiverseEnum::InterpolationMode interpMode);
85  void setColorRGB(string selection, string param, double r, double g, double b, double weight = 1.0, RGBColorSpace cs = sRGB);
86  void setColorRGBRaw(string selection, string param, double r, double g, double b, double weight = 1.0);
87 
96  Device* operator[](string id);
97 
104  Device* getDevice(string id);
105 
113  const Device* readDevice(string id);
114 
120  void captureDevices(DeviceSet d);
121 
125  void clearCaptured();
126 
130  void reset();
131 
135  void clearAndReset();
136 
140  map<string, Device*> getCapturedDevices();
141 
147  bool isCaptured(string id);
148 
155  void blend(map<string, Device*> state);
156 
161  inline const map<string, Device *>& getDevices() { return m_devices; }
162 
170  //Cue getCue(float upfade = 3, float downfade = 3, float delay = 0);
171 
175  void writeToTimeline(shared_ptr<Timeline> tl, size_t time, bool ucs = false);
176 
177  void writeToTimeline(DeviceSet d, shared_ptr<Timeline> tl, size_t time, bool ucs = false);
178 
185  void captureFromRig(DeviceSet devices);
186 
193  void captureFromRig(string id);
194 
198  JSONNode toJSON();
199 
206  bool loadJSON(JSONNode data);
207 
211  Cue* getCue(float up, float down, float delay);
212 
213 private:
219  map<string, Device*> m_devices;
220 
225 
230 
232  mutex m_progMutex;
233 
235  void addCaptured(DeviceSet set);
236 
238  void addCaptured(string id);
239 };
240 
241 }
242 }
243 
244 #endif
const Device * readDevice(string id)
Returns a device from the programmer without capturing it.
Definition: Programmer.cpp:162
void blend(map< string, Device * > state)
Writes the programmer's captured channels on top of the given device state.
Definition: Programmer.cpp:203
void clearCaptured()
Clears the list of captured devices but does not reset the state of the devices.
Definition: Programmer.cpp:170
The Rig contains information about the state of the lighting system.
This class is a wapper around a variety of different possible data types that might be needed by a De...
Definition: LumiverseType.h:33
Programmer(Rig *rig)
Programmers must be initialized from Rigs to ensure that they contain the same Devices.
Definition: Programmer.cpp:7
bool loadJSON(JSONNode data)
Loads JSON data into the Programmer.
Definition: Programmer.cpp:276
DeviceSet captured
Set of captured devices in the Programmer.
Definition: Programmer.h:224
void setParam(DeviceSet selection, string param, LumiverseType *val)
Sets the selected device's parameter to the given value.
Definition: Programmer.cpp:28
void captureDevices(DeviceSet d)
Adds the selected devices to the captured list.
Definition: Programmer.cpp:166
Definition: LumiverseColorLib.h:30
RGBColorSpace
Selects a RGB color space to use in color conversion functions.
Definition: LumiverseColorLib.h:29
A DeviceSet is a set of devices.
Definition: DeviceSet.h:41
mutex m_progMutex
Mutex for interacting with the programmer.
Definition: Programmer.h:232
~Programmer()
Destroys a programmer object.
Definition: Programmer.cpp:21
InterpolationMode
Sets the interpolation mode when transitioning between two LumiverseEnums.
Definition: LumiverseEnum.h:71
Device * getDevice(string id)
Returns a device from the Programmer and captures it.
Definition: Programmer.cpp:157
void clearAndReset()
Clears the list of captured devices and resets the state of the devices.
Definition: Programmer.cpp:182
Device * operator[](string id)
Shorthand to access a device by ID.
Definition: Programmer.cpp:153
void reset()
Resets the state of the layer. Does not clear the captured devices.
Definition: Programmer.cpp:176
Mode
When you select an enumeration, mode determines where in the range the calculated value will fall...
Definition: LumiverseEnum.h:56
bool isCaptured(string id)
Returns that capture status of a single device.
Definition: Programmer.cpp:199
A Programmer is a special Layer-like object used to manipulate specific devices for cues...
Definition: Programmer.h:24
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
const map< string, Device * > & getDevices()
Gets the set of the Devices the Programmer has.
Definition: Programmer.h:161
Rig * m_rig
The Rig this programmer is storing a state for.
Definition: Programmer.h:229
map< string, Device * > m_devices
Set of devices managed by this Programmer.
Definition: Programmer.h:219
The Rig contains information about the state of the lighting system.
Definition: Rig.h:58
JSONNode toJSON()
Converts this object to a JSON object.
Definition: Programmer.cpp:258
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
void writeToTimeline(shared_ptr< Timeline > tl, size_t time, bool ucs=false)
Creates a cue from the programmer's state.
Definition: Programmer.cpp:221
void addCaptured(DeviceSet set)
Safely adds a set to the set of captured devices.
Definition: Programmer.cpp:313
A cue stores data for a particular look (called a cue)
Definition: Cue.h:31
void captureFromRig(DeviceSet devices)
Captures the selected devices and copies their current values from the rig.
Definition: Programmer.cpp:235
Cue * getCue(float up, float down, float delay)
Returns a cue constructed from the current state of the programmer.
Definition: Programmer.cpp:308
map< string, Device * > getCapturedDevices()
Returns the set of captured devices.
Definition: Programmer.cpp:187