Lumiverse
2.5
A framework for creating lighting control applications
|
A DeviceSet is a set of devices. More...
#include <DeviceSet.h>
Public Member Functions | |
DeviceSet () | |
Constructs a DeviceSet unassociated with a Rig. More... | |
DeviceSet (Rig *rig) | |
Constructs an empty set. More... | |
DeviceSet (Rig *rig, set< Device * > devices) | |
Constructs a set with the given devices. More... | |
DeviceSet (Rig *rig, JSONNode node) | |
Constructs a DeviceSet from a JSON node and a given Rig. | |
DeviceSet (const DeviceSet &dc) | |
Copy a DeviceSet. More... | |
~DeviceSet () | |
Destructor for the DeviceSet. | |
std::ostream & | operator<< (std::ostream &str) |
Override for steam output. More... | |
DeviceSet | select (string selector) |
Get devices matching a query from the Rig. More... | |
DeviceSet | add (Device *device) |
Adds a Device to the set. More... | |
DeviceSet | add (unsigned int channel) |
Adds Devices in the specified channel to the set. More... | |
DeviceSet | add (unsigned int lower, unsigned int upper) |
Adds Devices in the specified inclusive channel range to the set. More... | |
DeviceSet | add (string key, string val, bool isEqual) |
Adds Devices matching the specified metadata value to the set. More... | |
DeviceSet | add (string key, regex val, bool isEqual) |
Adds Devices matching the specified metadata value to the set. More... | |
DeviceSet | add (string key, LumiverseType *val, function< bool(LumiverseType *a, LumiverseType *b)> cmp, bool isEqual) |
Adds devices based on a parameter comparison function provided by the caller. More... | |
DeviceSet | add (string query) |
Adds devices based on a query string. More... | |
DeviceSet | add (DeviceSet set) |
Adds devices from another set. More... | |
DeviceSet | remove (Device *device) |
Removes a device from the set. More... | |
DeviceSet | remove (unsigned int channel) |
Removes Devices in the specified channel from the set. More... | |
DeviceSet | remove (unsigned int lower, unsigned int upper) |
Removes Devices in the specified inclusive channel range from the set. More... | |
DeviceSet | remove (string key, string val, bool isEqual) |
Removes Devices matching the specified metadata value to the set. More... | |
DeviceSet | remove (string key, regex val, bool isEqual) |
Removes Devices matching the specified metadata value from the set. More... | |
DeviceSet | remove (string key, LumiverseType *val, function< bool(LumiverseType *a, LumiverseType *b)> cmp, bool isEqual) |
Removes devices based on a parameter comparison function provided by the caller. More... | |
DeviceSet | remove (string query) |
Removes devices based on a query string. More... | |
DeviceSet | remove (DeviceSet set) |
Removes devices contained in another set from this set. More... | |
void | reset () |
Resets all the parameters in each Device in the device set. More... | |
void | setParam (string param, float val) |
Sets the value of a LumiverseFloat parameter on every device in the group. More... | |
void | setParam (string param, string val, float val2=-1.0f) |
Sets the value of a LumiverseEnum parameter on every device in the group. More... | |
void | setParam (string param, string channel, double val) |
Sets the value of a LumiverseColor parameter. More... | |
void | setParam (string param, string val, float val2, LumiverseEnum::Mode mode, LumiverseEnum::InterpolationMode interpMode) |
Sets the value of a LumiverseEnum parameter. More... | |
void | setParam (string param, double x, double y, double weight=1.0) |
Sets the value of a LumiverseColor parameter using LumiverseColor::setxy() More... | |
void | setColorRGBRaw (string param, double r, double g, double b, double weight=1.0) |
Sets the value of a LumiverseColor parameter. More... | |
void | setRGBRaw (double r, double g, double b, double weight=1.0) |
Sets the value of a LumiverseColor paramter. More... | |
void | setIntensity (float val) |
Proxy for setParam("intensity", val). Assumes the existence of an "intensity" parameter. | |
void | setColorRGB (string param, double r, double g, double b, double weight=1.0, RGBColorSpace cs=sRGB) |
Sets the value of a LumiverseColor parameter. More... | |
void | setColorHSV (string param, double H, double S, double V, double weight=1.0) |
Sets the value of a LumiverseColor parameter using HSV. | |
void | setColorWeight (string param, double weight) |
Sets the weight of a LumiverseColor parameter. | |
void | setMetadata (string key, string val) |
Sets the metadata for the given key-value pair for all devices in the DeviceSet. More... | |
const set< Device * > & | getDevices () |
Gets the devices managed by this set. More... | |
vector< string > | getIds () |
Gets a copy of the list of the IDs contained by this DeviceSet. | |
set< string > | getAllParams () |
Gets a copy of the set of all the parameters used by devices in this set. More... | |
set< string > | getAllMetadata () |
Gets a copy of the set of all the metadata keys used by devices in this set. | |
set< string > | getAllMetadataForKey (string key) |
Gets a copy of the set of all metadata values used by a particular key. | |
string | info () |
Returns a string containing info about the DeviceSet. More... | |
size_t | size () |
Returns the number of devices in the DeviceSet. More... | |
bool | hasSameIds (DeviceSet &devices) |
Returns true if the device sets have the same number of devices and contain the same set of IDs. More... | |
bool | hasSameDevices (DeviceSet &devices) |
Returns true if the device sets have the same number of devices and point to the same Devices. More... | |
void | clear () |
Removes all devices from the device set. | |
bool | contains (Device *d) |
Checks to see if a device is in the device set. More... | |
bool | contains (string id) |
Checks to see if a device is in the device set. More... | |
JSONNode | toJSON (string name) |
Saves the device set as a JSON object with the given name. More... | |
Private Member Functions | |
DeviceSet | parseSelector (string selector, bool filter) |
Parses a single selector. More... | |
DeviceSet | parseMetadataSelector (string selector, bool filter) |
Processes a metadata selector. More... | |
DeviceSet | parseChannelSelector (string selector, bool filter) |
Processes a channel selector. More... | |
DeviceSet | parseParameterSelector (string selector, bool filter) |
Processes a parameter selector. More... | |
DeviceSet | parseFloatParameter (string param, string op, float val, bool filter, bool eq) |
Processes a float parameter selector. More... | |
void | addDevice (Device *device) |
Adds to the set without returning a new copy. More... | |
void | removeDevice (Device *device) |
Removes from the set without returning a new copy. More... | |
void | addSet (DeviceSet otherSet) |
Adds a set to the current set. More... | |
void | removeSet (DeviceSet otherSet) |
Removes a set from the current set. More... | |
Private Attributes | |
set< Device * > | m_workingSet |
Set of devices currently contained in the Deviceset. | |
Rig * | m_rig |
Pointer to the rig for accessing indexes and devices. | |
A DeviceSet is a set of devices.
More specifically, a DeviceSet is the set resulting from a particular query or series of filtering operations. These devices can be manupulated by setting properties as a group, further filtering them, adding devices, etc. DeviceSets are returned by the Rig when asking for more than one device. Device sets can be filtered in chains, as each filtering operation will return a new DeviceSet: rig.getDevices("angle", "back", true).remove("area", "3", true) ...
etc. Returning a new set after each operation may use more memory, but it does allow for the construction of a query history and saving of that query during any point of its construction. This history is currently not saved, but may in the future be part of this class. Alternately, DeviceSets can be constructed from concise queries: https://github.com/ebshimizu/Lumiverse/wiki/Query-Syntax-Notes
|
inline |
Lumiverse::DeviceSet::DeviceSet | ( | Rig * | rig | ) |
Constructs an empty set.
rig | Pointer to a Rig to get devices from. |
Constructs a set with the given devices.
Similar to a copy constructor.
rig | Pointer to a Rig to get devices from. |
devices | List of Device pointers to initialize the set with. |
Lumiverse::DeviceSet::DeviceSet | ( | const DeviceSet & | dc | ) |
DeviceSet Lumiverse::DeviceSet::add | ( | unsigned int | channel | ) |
DeviceSet Lumiverse::DeviceSet::add | ( | unsigned int | lower, |
unsigned int | upper | ||
) |
Adds Devices in the specified inclusive channel range to the set.
lower | First channel in the range (inclusive) |
upper | Last channel in the range (inclusive) |
DeviceSet Lumiverse::DeviceSet::add | ( | string | key, |
string | val, | ||
bool | isEqual | ||
) |
Adds Devices matching the specified metadata value to the set.
If a Device does not have a value for the key specified, it will not be included in the set even if isEqual is set to false.
key | Metadata field to look at |
val | Target value of the metadata field |
isEqual | If true, the Devices matching the metadata value will be added. If false, devices that don't match the metadata value will be added. |
DeviceSet Lumiverse::DeviceSet::add | ( | string | key, |
regex | val, | ||
bool | isEqual | ||
) |
Adds Devices matching the specified metadata value to the set.
Regex version of the normal metadata add. If a Device does not have a value for the key specified, it will not be included in the set even if isEqual is set to false.
key | Metadata field to look at |
val | Target value of the metadata field. Since this is a std::regex , it is possible to search for metadata using all of the nice regex features you're used to. |
isEqual | If true, the Devices matching the metadata value will be added. If false, devices that don't match the metadata value will be added. |
DeviceSet Lumiverse::DeviceSet::add | ( | string | key, |
LumiverseType * | val, | ||
function< bool(LumiverseType *a, LumiverseType *b)> | cmp, | ||
bool | isEqual | ||
) |
Adds devices based on a parameter comparison function provided by the caller.
One of the more complicated add functions, this one adds devices based on a user-specified comparison function between two LumiverseType pointers. It is up to the user to make sure these types are the same to ensure a good comparison is made.
key | Parameter to look at |
val | Target parameter value |
cmp | Comparison function |
isEqual | If true, the Devices matching the metadata value will be added. If false, devices that don't match the metadata value will be added. |
DeviceSet Lumiverse::DeviceSet::add | ( | string | query | ) |
Adds devices from another set.
set | The other set of devices |
|
private |
Adds to the set without returning a new copy.
Internal use only.
device | Device to add to the set |
|
private |
Adds a set to the current set.
Internal set opration. Equivalent to a union.
otherSet | The set to add to the DeviceSet. |
bool Lumiverse::DeviceSet::contains | ( | Device * | d | ) |
Checks to see if a device is in the device set.
This version of the contains function takes a pointer and checks to see if the exact same device is in the set. This function is faster than contains(string).
bool Lumiverse::DeviceSet::contains | ( | string | id | ) |
Checks to see if a device is in the device set.
This version of the contains function takes a device ID and checks if a device with the same id is in the set.
set< string > Lumiverse::DeviceSet::getAllParams | ( | ) |
Gets a copy of the set of all the parameters used by devices in this set.
Set means no duplicates
|
inline |
Gets the devices managed by this set.
bool Lumiverse::DeviceSet::hasSameDevices | ( | DeviceSet & | devices | ) |
Returns true if the device sets have the same number of devices and point to the same Devices.
This actually just checks to see if the pointers in the set of devices managed by the device set are pointing to the same things.
bool Lumiverse::DeviceSet::hasSameIds | ( | DeviceSet & | devices | ) |
Returns true if the device sets have the same number of devices and contain the same set of IDs.
Note that even if this returns true, the device sets could refer to different objects, as they store pointers to the devices they contain. This function is currently very slow.
string Lumiverse::DeviceSet::info | ( | ) |
|
inline |
|
private |
Processes a channel selector.
Helper for parseSelector.
selector | Query string |
filter | If true, indicates that devices will be filtered out of the current device set based on the result of the selector. If false, devices will be added based on the selector result. |
|
private |
Processes a float parameter selector.
Helper for parseParameterSelector.
param | Parameter name |
op | Equality operation. One of "<", "<=", ">", ">=, "!=". Defaults to "==" if nothing specified or if invalid option is specified. |
val | The value we're testing against |
filter | If true, indicates that devices will be filtered out of the current device set based on the result of the selector. If false, devices will be added based on the selector result. |
eq | If set to false, this function will add everything that does not satisfy the selector. It essentially inverts the query. For example, if you have @intensity < .50 as the query with eq = false , the returned set will contain @intensity >= .5 . This parameter is intended for internal use only. |
|
private |
Processes a metadata selector.
Helper for parseSelector.
selector | Query string |
filter | If true, indicates that devices will be filtered out of the current device set based on the result of the selector. If false, devices will be added based on the selector result. |
|
private |
Processes a parameter selector.
Helper for parseSelector. This part of the query is a bit difficult to parse due to LumiverseType objects actually being different types (enum, float, etc.).
selector | Query string |
filter | If true, indicates that devices will be filtered out of the current device set based on the result of the selector. If false, devices will be added based on the selector result. |
|
private |
Parses a single selector.
Redirects to appropriate functions. See implementation for details. Boolean flag determines if selected Devices are added or subtracted from the current DeviceSet.
selector | Query string |
filter | If true, indicates that devices will be filtered out of the current device set based on the result of the selector. If false, devices will be added based on the selector result. |
DeviceSet Lumiverse::DeviceSet::remove | ( | unsigned int | channel | ) |
DeviceSet Lumiverse::DeviceSet::remove | ( | unsigned int | lower, |
unsigned int | upper | ||
) |
Removes Devices in the specified inclusive channel range from the set.
lower | First channel in the range (inclusive) |
upper | Last channel in the range (inclusive) |
DeviceSet Lumiverse::DeviceSet::remove | ( | string | key, |
string | val, | ||
bool | isEqual | ||
) |
Removes Devices matching the specified metadata value to the set.
If a Device does not have a value for the key specified, it will not be removed from the set even if isEqual is set to false.
key | Metadata field to look at |
val | Target value of the metadata field |
isEqual | If true, the Devices matching the metadata value will be removed. If false, devices that don't match the metadata value will be removed. |
DeviceSet Lumiverse::DeviceSet::remove | ( | string | key, |
regex | val, | ||
bool | isEqual | ||
) |
Removes Devices matching the specified metadata value from the set.
Regex version of the normal metadata remove. If a Device does not have a value for the key specified, it will not be removed from the set even if isEqual is set to false.
key | Metadata field to look at |
val | Target value of the metadata field. Since this is a std::regex , it is possible to search for metadata using all of the nice regex features you're used to. |
isEqual | If true, the Devices matching the metadata value will be removed. If false, devices that don't match the metadata value will be removed. |
DeviceSet Lumiverse::DeviceSet::remove | ( | string | key, |
LumiverseType * | val, | ||
function< bool(LumiverseType *a, LumiverseType *b)> | cmp, | ||
bool | isEqual | ||
) |
Removes devices based on a parameter comparison function provided by the caller.
One of the more complicated remove functions, this one removes devices based on a user-specified comparison function between two LumiverseType pointers. It is up to the user to make sure these types are the same to ensure a good comparison is made.
key | Parameter to look at |
val | Target parameter value |
cmp | Comparison function |
isEqual | If true, the Devices matching the metadata value will be removed. If false, devices that don't match the metadata value will be removed. |
DeviceSet Lumiverse::DeviceSet::remove | ( | string | query | ) |
Removes devices contained in another set from this set.
set | Set of devices to remove from this set. |
|
private |
Removes from the set without returning a new copy.
Internal use only.
device | Device to remove from the set. |
|
private |
Removes a set from the current set.
Internal set opration. Equivalent to a set difference.
otherSet | The set to remove fromthe DeviceSet. |
void Lumiverse::DeviceSet::reset | ( | ) |
Resets all the parameters in each Device in the device set.
DeviceSet Lumiverse::DeviceSet::select | ( | string | selector | ) |
Get devices matching a query from the Rig.
This is the primary function to select Devices from the Rig. Syntax details can be found here: https://github.com/ebshimizu/Lumiverse/wiki/Query-Syntax-Notes
selector | Query string. |
void Lumiverse::DeviceSet::setColorRGB | ( | string | param, |
double | r, | ||
double | g, | ||
double | b, | ||
double | weight = 1.0 , |
||
RGBColorSpace | cs = sRGB |
||
) |
Sets the value of a LumiverseColor parameter.
Proxy for LumiverseColor::setRGB().
void Lumiverse::DeviceSet::setColorRGBRaw | ( | string | param, |
double | r, | ||
double | g, | ||
double | b, | ||
double | weight = 1.0 |
||
) |
Sets the value of a LumiverseColor parameter.
Not gonna work terribly well if you're mixing fixtures that don't have RGB for some reason in your selection. Proxy for LumiverseColor::setRGBRaw().
void Lumiverse::DeviceSet::setMetadata | ( | string | key, |
string | val | ||
) |
Sets the metadata for the given key-value pair for all devices in the DeviceSet.
key | Metadata key |
val | Metadata value |
void Lumiverse::DeviceSet::setParam | ( | string | param, |
float | val | ||
) |
Sets the value of a LumiverseFloat parameter on every device in the group.
This function will only set the value of an existing parameter. If the parameter doesn't exist, it will not be created by this function.
param | Parameter to modify |
val | Value of the parameter |
void Lumiverse::DeviceSet::setParam | ( | string | param, |
string | val, | ||
float | val2 = -1.0f |
||
) |
Sets the value of a LumiverseEnum parameter on every device in the group.
This function will only set the value of an existing parameter. If the parameter doesn't exist, it will not be created by this function.
param | Parameter to modify |
val | Value of the enumeration |
val2 | The tweak value of the LumiverseEnum |
void Lumiverse::DeviceSet::setParam | ( | string | param, |
string | channel, | ||
double | val | ||
) |
Sets the value of a LumiverseColor parameter.
LumiverseColors present a bit of a challenge for group selections. Every light has differen color representations, so not every function will work for every group. This function will call the corresponding set param function for each device, but not every device may react to it.
param | Parameter name |
channel | Color channel name |
val | Value of the color channel |
void Lumiverse::DeviceSet::setParam | ( | string | param, |
string | val, | ||
float | val2, | ||
LumiverseEnum::Mode | mode, | ||
LumiverseEnum::InterpolationMode | interpMode | ||
) |
Sets the value of a LumiverseEnum parameter.
void Lumiverse::DeviceSet::setParam | ( | string | param, |
double | x, | ||
double | y, | ||
double | weight = 1.0 |
||
) |
Sets the value of a LumiverseColor parameter using LumiverseColor::setxy()
x and y are chromaticity coordinates in the xyY color space. Ideally this function would be the unifying function for all devices in a Rig. However, it only works if you know the XYZ values for each color of LED in a light, and it doesn't work with CMY fixtures at the moment.
param | Parameter name. |
x | x coordinate |
y | y coordinate |
void Lumiverse::DeviceSet::setRGBRaw | ( | double | r, |
double | g, | ||
double | b, | ||
double | weight = 1.0 |
||
) |
Sets the value of a LumiverseColor paramter.
Assumes the existence of a RGB "color" parameter.
|
inline |
Returns the number of devices in the DeviceSet.
JSONNode Lumiverse::DeviceSet::toJSON | ( | string | name | ) |