Lumiverse  2.5
A framework for creating lighting control applications
Playback.h
1 #ifndef _PLAYBACK_H_
2 #define _PLAYBACK_H_
3 
4 #pragma once
5 
6 #include <memory>
7 #include <chrono>
8 
9 #include <LumiverseCore.h>
10 #include "Timeline.h"
11 #include "Layer.h"
12 #include "Programmer.h"
13 
14 
15 namespace Lumiverse {
16 namespace ShowControl{
17  class Layer;
18  class CueList;
19 
32  class Playback
33  {
34  public:
39  Playback(Rig* rig, float gm = 1.0f);
40 
48  Playback(Rig* rig, string filename);
49 
50  // Changes to make to playback: Playback must now maintain a list of layers
51  // Layers are update in the playback update loop with layer->update()
52  // Each layer now takes over the cue playback controls
53  // Playback also maintains the master list of CueLists for reference by the layers.
54 
55  // Deletes a playback object.
56  ~Playback();
57 
61  void start();
62 
66  void stop();
67 
71  bool isRunning() { return m_running; }
72 
77  // void setRefreshRate(unsigned int rate);
78 
82  void update();
83 
91  bool addLayer(shared_ptr<Layer> layer);
92 
98  shared_ptr<Layer> getLayer(string name);
99 
103  void deleteLayer(string name);
104 
112  bool addTimeline(string id, shared_ptr<Timeline> tl);
113 
119  void deleteTimeline(string id);
120 
127  shared_ptr<Timeline> getTimeline(string id);
128 
132  map<string, shared_ptr<Timeline> >& getTimelines();
133 
139  bool attachToRig(int pid = 1);
140 
145  bool detachFromRig();
146 
148  const unique_ptr<Programmer>& getProgrammer() { return m_prog; }
149 
161  bool save(string filename, bool overwrite = false);
162 
170  JSONNode toJSON();
171 
173  Rig* getRig() { return m_rig; }
174 
176  vector<string> getLayerNames();
177 
183  vector<string> getTimelineNames();
184 
186  const map<string, shared_ptr<Layer> >& getLayers() { return m_layers; }
187 
189  bool loadJSON(JSONNode node);
190 
196  int getNumLayers();
197 
206  bool storeGroup(string name, DeviceSet group, bool overwrite = false);
207 
216  bool storeDynamicGroup(string name, DynamicDeviceSet group, bool overwrite = false);
217 
223  bool deleteGroup(string name);
224 
230  bool deleteDynamicGroup(string name);
231 
235  DeviceSet getGroup(string name);
236 
240  DynamicDeviceSet getDynamicGroup(string name);
241 
245  bool groupExists(string name);
246 
250  bool dynamicGroupExists(string name);
251 
255  const map<string, DeviceSet>& getGroups() { return m_groups; }
256 
260  const map<string, DynamicDeviceSet>& getDynamicGroups() { return m_dynGroups; }
261 
266  void setGrandmaster(float val);
267 
271  float getGrandmaster() { return m_grandmaster; }
272 
278  bool addCueList(shared_ptr<CueList> cueList);
279 
285  shared_ptr<CueList> getCueList(string id);
286 
290  void deleteCueList(string id);
291 
300  bool addCueListToLayer(string cueListId, string layerName, bool resetCurrentCue = true);
301 
306  void removeCueListFromLayer(string layerName);
307 
309  vector<string> getCueListNames();
310 
315  int getNumCueLists();
316 
317  private:
319  map<string, shared_ptr<Layer> > m_layers;
320 
322  map<string, Device*> m_state;
323 
325  map<string, DeviceSet> m_groups;
326 
328  map<string, DynamicDeviceSet> m_dynGroups;
329 
331  map<string, shared_ptr<Timeline> > m_timelines;
332 
334  map<string, shared_ptr<CueList> > m_cueLists;
335 
336  // Does the updating of the rig while running.
337  // unique_ptr<thread> m_updateLoop;
338 
340  bool m_running;
341 
343  int m_funcId;
344 
347 
348  // Refresh rate used by the update loop.
349  // unsigned int m_refreshRate;
350 
351  // Loop time in seconds
352  // float m_loopTime;
353 
356 
358  unique_ptr<Programmer> m_prog;
359 
361  bool load(string filename);
362  };
363 }
364 }
365 #endif
vector< string > getCueListNames()
Returns a list of the cue list names contained in the Playback.
Definition: Playback.cpp:567
void deleteTimeline(string id)
Deletes a Timeline from the Playback.
Definition: Playback.cpp:172
Include file for all of LumiverseCore in one conveninent location.
map< string, shared_ptr< Timeline > > & getTimelines()
Returns the map of all Timelines contained in the Playback.
Definition: Playback.cpp:184
bool attachToRig(int pid=1)
Binds the update function for this playback to the Rig's update function.
Definition: Playback.cpp:188
bool addLayer(shared_ptr< Layer > layer)
Adds a layer to the playback.
Definition: Playback.cpp:138
void setGrandmaster(float val)
Definition: Playback.cpp:521
bool addCueListToLayer(string cueListId, string layerName, bool resetCurrentCue=true)
Assigns a cue list to a layer If one of the specified items doesn't exist, nothing will happen and th...
Definition: Playback.cpp:552
bool dynamicGroupExists(string name)
Checks if a dynamic group with the given name exists.
Definition: Playback.cpp:517
const map< string, DynamicDeviceSet > & getDynamicGroups()
Get the map of dynamic groups in the Playback.
Definition: Playback.h:260
bool storeDynamicGroup(string name, DynamicDeviceSet group, bool overwrite=false)
Saves a user-specified DynamicDeviceSet as a group in the Playback.
Definition: Playback.cpp:477
bool isRunning()
Returns the status of the playback update loop.
Definition: Playback.h:71
map< string, DeviceSet > m_groups
Stores named groups (DeviceSets) created by the user.
Definition: Playback.h:325
int m_funcId
ID of the attached function in the rig update loop.
Definition: Playback.h:343
bool addTimeline(string id, shared_ptr< Timeline > tl)
Add a Timeline to the Playback.
Definition: Playback.cpp:163
Rig * getRig()
Returns a pointer to the rig.
Definition: Playback.h:173
int getNumCueLists()
Returns the number of cue lists contained in this Playback object.
Definition: Playback.cpp:577
map< string, Device * > m_state
Copy of all devices in the rig. Current state of the playback.
Definition: Playback.h:322
void deleteLayer(string name)
Deletes a layer from the playback.
Definition: Playback.cpp:157
A DeviceSet is a set of devices.
Definition: DeviceSet.h:41
A playback object manages layers, timelines, and coordinates their actions and updates.
Definition: Playback.h:32
bool m_running
True when the update loop is running.
Definition: Playback.h:340
map< string, DynamicDeviceSet > m_dynGroups
Stores named dynamic groups (DynamicDeviceSets) created by the user.
Definition: Playback.h:328
shared_ptr< Timeline > getTimeline(string id)
Gets a timeline from the Playback.
Definition: Playback.cpp:176
map< string, shared_ptr< Timeline > > m_timelines
Map of.
Definition: Playback.h:331
void deleteCueList(string id)
Deletes a cue list from the Playback.
Definition: Playback.cpp:546
bool groupExists(string name)
Checks if a group with the given name exists.
Definition: Playback.cpp:513
const map< string, shared_ptr< Layer > > & getLayers()
Returns a reference to the layers in the Playback.
Definition: Playback.h:186
bool detachFromRig()
Unbinds the update function for this playback from the Rig.
Definition: Playback.cpp:198
Playback(Rig *rig, float gm=1.0f)
Initializes a playback object.
Definition: Playback.cpp:7
JSONNode toJSON()
Returns the JSON representation of this playback object.
Definition: Playback.cpp:221
bool loadJSON(JSONNode node)
Loads data from a JSON object.
Definition: Playback.cpp:336
const map< string, DeviceSet > & getGroups()
Get the map of groups in the Playback.
Definition: Playback.h:255
void update()
Sets the playback update rate.
Definition: Playback.cpp:69
shared_ptr< CueList > getCueList(string id)
Retrieves a cue list from the Playback.
Definition: Playback.cpp:538
void removeCueListFromLayer(string layerName)
Removes a cue list assigned to a particular layer.
Definition: Playback.cpp:561
DeviceSet getGroup(string name)
Gets a saved group.
Definition: Playback.cpp:495
shared_ptr< Layer > getLayer(string name)
Retrieves a pointer to the layer with the specified name.
Definition: Playback.cpp:149
unique_ptr< Programmer > m_prog
Programmer object owned by the Playback.
Definition: Playback.h:358
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
vector< string > getTimelineNames()
Returns a list of Timeline ids contained in the Playback.
Definition: Playback.cpp:296
const unique_ptr< Programmer > & getProgrammer()
Gets a reference to the programmer object stored by the playback.
Definition: Playback.h:148
A DynamicDeviceSet is a set of devices specified by a query string.
Definition: DynamicDeviceSet.h:34
DynamicDeviceSet getDynamicGroup(string name)
Gets a saved Dynamic group.
Definition: Playback.cpp:504
map< string, shared_ptr< Layer > > m_layers
Map of layer names to layers.
Definition: Playback.h:319
bool save(string filename, bool overwrite=false)
Saves a JSON file containing all information stored by the playback, including the Rig...
Definition: Playback.cpp:206
bool deleteGroup(string name)
Deletes a group.
Definition: Playback.cpp:487
bool addCueList(shared_ptr< CueList > cueList)
Adds a cue list to the Playback If a list already exists with the same name, this function will retur...
Definition: Playback.cpp:525
Rig * m_rig
Pointer to the rig that this playback runs on.
Definition: Playback.h:355
bool storeGroup(string name, DeviceSet group, bool overwrite=false)
Saves a user-specified DeviceSet as a group in the Playback.
Definition: Playback.cpp:466
void start()
Starts the playback loop in a separate thread.
Definition: Playback.cpp:52
The Rig contains information about the state of the lighting system.
Definition: Rig.h:58
vector< string > getLayerNames()
Returns a list of the layer names contained in the Playback.
Definition: Playback.cpp:286
float m_grandmaster
Controls the overall level of parameters in the rig.
Definition: Playback.h:346
int getNumLayers()
Returns the number of layers contained in this Playback object.
Definition: Playback.cpp:462
void stop()
Stops the playback loop in a separate thread.
Definition: Playback.cpp:57
bool deleteDynamicGroup(string name)
Deletes a dynamic group.
Definition: Playback.cpp:491
bool load(string filename)
Load Playback data from a file.
Definition: Playback.cpp:306
map< string, shared_ptr< CueList > > m_cueLists
Map of CueList ids to CueList objects.
Definition: Playback.h:334
float getGrandmaster()
Gets the value of the grandmaster.
Definition: Playback.h:271