|
From: <j-...@us...> - 2012-05-13 15:47:40
|
Revision: 818
http://openautomation.svn.sourceforge.net/openautomation/?rev=818&view=rev
Author: j-n-k
Date: 2012-05-13 15:47:33 +0000 (Sun, 13 May 2012)
Log Message:
-----------
Added cuelists
Modified Paths:
--------------
tools/knxdmxd/knxdmxd.conf
tools/knxdmxd/src/Makefile.am
tools/knxdmxd/src/cue.cc
tools/knxdmxd/src/cue.h
tools/knxdmxd/src/fixture.cc
tools/knxdmxd/src/fixture.h
tools/knxdmxd/src/knxdmxd.cc
Added Paths:
-----------
tools/knxdmxd/src/cuelist.cc
tools/knxdmxd/src/cuelist.h
Modified: tools/knxdmxd/knxdmxd.conf
===================================================================
--- tools/knxdmxd/knxdmxd.conf 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/knxdmxd.conf 2012-05-13 15:47:33 UTC (rev 818)
@@ -1,86 +1,96 @@
-{ "fixtures": [
- { "name" : "Treppe",
- "channels" : [
- { "name": "oben",
- "dmx" : "1.0",
- "knx" : "1/7/170"
- },
- { "name": "mitte",
- "knx" : "1/7/170",
- "dmx" : "1.1"
- },
- { "name": "unten",
- "knx" : "1/7/170",
- "dmx" : "1.2"
- }
+// CAUTION : never uses names starting with _ !!! These are used internally !
+{ "fixtures": [ // all fixture definitions
+ { "name" : "Treppe", // name is optional, default is _f_<number>
+ "channels" : [ // channel definition, dmx is mandatory, default name is _c_<number>
+ { "name": "oben", "dmx" : "1.0", "knx" : "1/7/170" },
+ { "name": "mitte", "knx" : "1/7/170", "dmx" : "1.1" },
+ { "name": "unten", "knx" : "1/7/170", "dmx" : "1.2" }
],
- "fading" : {
- "knx" : "1/6/170",
- "time": "10"
- }
+ "fading" : { "knx" : "1/6/170", "time": 10 } // knx-like dimming: fading is calculated for 0-100%
},
{ "name" : "Kueche",
"channels" : [
- { "name": "R",
- "knx" : "1/7/141",
- "dmx" : "1.10"
- },
- { "name": "G",
- "knx" : "1/7/142",
- "dmx" : "1.11"
- },
- { "name": "B",
- "knx" : "1/7/143",
- "dmx" : "1.12"
- }
+ { "name": "R", "knx" : "1/7/141", "dmx" : "1.10" },
+ { "name": "G", "knx" : "1/7/142", "dmx" : "1.11" },
+ { "name": "B", "knx" : "1/7/143", "dmx" : "1.12" }
],
+ "fading" : { "knx" : "1/6/141", "time": 3.0 }
+ }
+],
+"scenes": [ // all scene definitions
+ { "name" : "Treppe_Full_On", // name is optional, default is _s_<number>
+ "trigger" : { "knx" : "1/0/170", "call" : 1 }, // if call is omitted, scene is called on any value
+ "channels" : [ // definition of each channel in scene
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 255 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 255 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 255 }
+ ],
+ "fading" : { // all fading times used on scene call !
+ "in" : 5.0, // for increasing intensity
+ "out": 5.0, // for decreasing intensity
+ }
+ },
+ { "name" : "Treppe_Blackout",
+ "trigger" : { "knx" : "1/0/170", "call" : 0 },
+ "channels" : [
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 0 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 0 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 0 }
+ ],
"fading" : {
- "knx" : "1/6/141",
- "time": "3.0"
+ "time" : 2 // used for in and out
}
},
- { "name" : "Test"
- } ],
-"scenes": [
- { "name" : "Treppe_Full_On",
- "trigger" : {
- "knx" : "1/0/170",
- "call" : 1
- },
+ { "name" : "Treppe_Test",
+ "trigger" : { "knx" : "1/0/171", "call" : 0 },
"channels" : [
- { "fixture" : "Treppe",
- "channel" : "oben",
- "value" : 255
- },
- { "fixture" : "Treppe",
- "channel" : "mitte",
- "value" : 255
- },
- { "fixture" : "Treppe",
- "channel" : "unten",
- "value" : 255
- }
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 255 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 128 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 0 }
],
+ "fading" : {
+ "in" : 10,
+ "out" : 0
+ }
},
- {
- "name" : "Treppe_Blackout",
- "trigger" : {
- "knx" : "1/0/170",
- "call" : 0
- },
+ { "name" : "Treppe_Middle",
+ "trigger" : { "knx" : "1/0/171", "call" : 1 },
"channels" : [
- { "fixture" : "Treppe",
- "channel" : "oben",
- "value" : 0
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 128 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 128 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 128 }
+ ]
+ },
+],
+"cuelists": [ // all cuelists
+ { "name" : "Treppe Disco",
+ "trigger" : { "knx" : "1/0/172", "go" : 1, "halt" : 0 },
+ "cues" : [ // cues are like scenes, just without individual triggers
+ { "name" : "Cue_1",
+ "channels" : [
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 128 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 128 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 128 }
+ ],
+
},
- { "fixture" : "Treppe",
- "channel" : "mitte",
- "value" : 0
+ { "name" : "Cue_2",
+ "channels" : [
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 255 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 255 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 255 }
+ ],
+ "waittime" : 10 // waittime start after calling previous cue !
},
- { "fixture" : "Treppe",
- "channel" : "unten",
- "value" : 0
+ { "name" : "Cue_3",
+ "channels" : [
+ { "fixture" : "Treppe", "channel" : "oben", "value" : 0 },
+ { "fixture" : "Treppe", "channel" : "mitte", "value" : 0 },
+ { "fixture" : "Treppe", "channel" : "unten", "value" : 0 }
+ ],
+ "waittime" : 10
}
]
- } ]
-}
+ }
+]
+ }
Modified: tools/knxdmxd/src/Makefile.am
===================================================================
--- tools/knxdmxd/src/Makefile.am 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/Makefile.am 2012-05-13 15:47:33 UTC (rev 818)
@@ -8,4 +8,4 @@
# this lists the binaries to produce, the (non-PHONY, binary) targets in
# the previous manual Makefile
bin_PROGRAMS = knxdmxd
-knxdmxd_SOURCES = knxdmxd.cc log.cc fixture.cc cue.cc
+knxdmxd_SOURCES = knxdmxd.cc log.cc fixture.cc cue.cc cuelist.cc
Modified: tools/knxdmxd/src/cue.cc
===================================================================
--- tools/knxdmxd/src/cue.cc 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/cue.cc 2012-05-13 15:47:33 UTC (rev 818)
@@ -13,6 +13,8 @@
Cue::Cue(const std::string name) {
_name=name;
+ _fadeIn = 0.0;
+ _fadeOut = 0.0;
std::clog << "Creating Cue '" << name << "'" << std::endl;
}
@@ -20,7 +22,7 @@
_triggerKNX = KNX;
_trigger_val = val;
- std::clog << kLogDebug << "Cue '" << _name << "': Trigger by KNX:" << _triggerKNX << ", value " << _trigger_val << ((_trigger_val==-1) ? " (all)" : "") << std::endl;
+ std::clog << kLogDebug << "Cue '" << _name << "': added trigger by KNX:" << _triggerKNX << ", value " << _trigger_val << ((_trigger_val==-1) ? " (all)" : "") << std::endl;
std::pair<knxdmxd::knx_patch_map_t::iterator, knxdmxd::knx_patch_map_t::iterator> alreadypatched;
alreadypatched = patchMap.equal_range(KNX);
@@ -36,18 +38,45 @@
AddTrigger(patchMap, readgaddr(KNX), val);
}
-void Cue::AddChannel(cue_channel_t channel) {
+void Cue::AddChannel(const cue_channel_t& channel) {
_channel_data.push_back(channel);
- std::clog << "Added Channel definition " << channel.fixture << "/" << channel.name << "@" << channel.value << std::endl;
+ std::clog << "Cue '" << _name << "': added channel definition " << channel.fixture << "/" << channel.name << "@" << channel.value << std::endl;
}
+void Cue::SetFading(const float fadeIn, const float fadeOut) {
+ _fadeIn = fadeIn;
+ _fadeOut = (fadeOut < 0) ? fadeIn : fadeOut;
+ std::clog << kLogDebug << "Cue '" << _name << "': set fading " << _fadeIn << "/" << _fadeOut << std::endl;
+}
+
+void Cue::Update(std::map<std::string, knxdmxd::Fixture>& fixtureList) {
+ for(std::list<cue_channel_t>::iterator it = _channel_data.begin(); it != _channel_data.end(); ++it) {
+ knxdmxd::Fixture& f = fixtureList[it->fixture];
+ int currentValue = f.GetCurrentValue(it->name);
+ int deltaVal = currentValue - it->value;
+ float ft = (deltaVal>0) ? (deltaVal/(_fadeOut*1.e6/FADING_INTERVAL)) : (-deltaVal/(_fadeIn*1.e6/FADING_INTERVAL));
+ f.Update(it->name, it->value, (float)ft);
+ }
+ std::clog << "Called cue " << _name << std::endl;
+}
+
void Cue::Update(std::map<std::string, knxdmxd::Fixture>& fixtureList, const int KNX, const int val) {
if ((_trigger_val==-1) || (_trigger_val==val)) {
- for(std::list<cue_channel_t>::iterator it = _channel_data.begin(); it != _channel_data.end(); ++it) {
- fixtureList[it->fixture].Update(it->name, it->value, (float)255.);
- }
- std::clog << "Called cue " << _name << std::endl;
+ Update(fixtureList);
}
}
+std::string Cue::GetName() {
+ return _name;
}
+
+float Cue::GetWaitTime() {
+ return _waittime;
+}
+
+void Cue::SetWaittime(const float waittime) {
+ _waittime = waittime;
+ std::clog << kLogDebug << "Cue '" << _name << "': set waittime " << _waittime << std::endl;
+}
+
+}
Modified: tools/knxdmxd/src/cue.h
===================================================================
--- tools/knxdmxd/src/cue.h 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/cue.h 2012-05-13 15:47:33 UTC (rev 818)
@@ -27,17 +27,24 @@
Cue() {};
Cue(const std::string name);
- void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, int KNX, int val);
- void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, std::string KNX, int val);
- void AddChannel(cue_channel_t channel);
+ void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, const int KNX, const int val);
+ void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, const std::string KNX, const int val);
+ void AddChannel(const cue_channel_t& channel);
+ void SetFading(const float fadeIn, const float fadeOut=-1);
+ void SetWaittime(const float waittime);
+ void Update(std::map<std::string, knxdmxd::Fixture>& fixtureList);
+ void Update(std::map<std::string, knxdmxd::Fixture>& fixtureList, const int KNX, const int val);
+
+ std::string GetName();
+ float GetWaitTime();
- void Update(std::map<std::string, knxdmxd::Fixture>& fixtureList, const int KNX, const int val);
-
private:
std::string _name;
int _triggerKNX;
int _trigger_val;
std::list<cue_channel_t> _channel_data;
+ float _fadeIn, _fadeOut;
+ float _waittime;
};
Added: tools/knxdmxd/src/cuelist.cc
===================================================================
--- tools/knxdmxd/src/cuelist.cc (rev 0)
+++ tools/knxdmxd/src/cuelist.cc 2012-05-13 15:47:33 UTC (rev 818)
@@ -0,0 +1,80 @@
+/*
+ * cuelist.cc
+ *
+ * (c) by JNK 2012
+ *
+ *
+*/
+
+
+#include "cuelist.h"
+
+namespace knxdmxd {
+
+Cuelist::Cuelist(const std::string name) {
+ _name=name;
+ _current_cue=-1;
+ _next_cue_start=-1;
+ std::clog << "Creating Cuelist '" << name << "'" << std::endl;
+}
+
+void Cuelist::AddTrigger(knxdmxd::knx_patch_map_t& patchMap, int KNX, int val) {
+ _triggerKNX = KNX;
+ _trigger_val = val;
+
+ std::clog << kLogDebug << "Cuelist '" << _name << "': added trigger by KNX:" << _triggerKNX << ", value " << _trigger_val << ((_trigger_val==-1) ? " (all)" : "") << std::endl;
+
+ std::pair<knxdmxd::knx_patch_map_t::iterator, knxdmxd::knx_patch_map_t::iterator> alreadypatched;
+ alreadypatched = patchMap.equal_range(KNX);
+
+ for (knxdmxd::knx_patch_map_t::iterator it = alreadypatched.first; it != alreadypatched.second; ++it) {
+ if (it->second == _name) return; // already patched that one
+ }
+
+ patchMap.insert(knxdmxd::knx_patch_map_element_t(KNX,_name)); // no, add to patchMap
+}
+
+void Cuelist::AddTrigger(knxdmxd::knx_patch_map_t& patchMap, std::string KNX, int val) {
+ AddTrigger(patchMap, readgaddr(KNX), val);
+}
+
+
+void Cuelist::AddCue(knxdmxd::Cue& cue) {
+ _cue_data.push_back(cue);
+ std::clog << "Cuelist '" << _name << "': added cue " << cue.GetName() << " as #" << _cue_data.size()-1 << std::endl;
+}
+
+void Cuelist::NextCue(std::map<std::string, knxdmxd::Fixture>& fixtureList, const unsigned long long loopCounter) {
+ if (_cue_data.size()>(_current_cue+1)) {
+ _current_cue++;
+ _cue_data.at(_current_cue).Update(fixtureList);
+ float waittime;
+ if (_cue_data.size()>(_current_cue+1)) { // last cue stops automatically
+ waittime = _cue_data.at(_current_cue+1).GetWaitTime();
+ } else {
+ waittime = -1;
+ }
+ if (waittime>=0) { // if waittime < 0 : manual trigger
+ _next_cue_start = loopCounter + (int) (waittime*1.e6/FADING_INTERVAL);
+ } else {
+ _next_cue_start = -1;
+ }
+ } else {
+ _current_cue = -1;
+ _next_cue_start = -1;
+ }
+}
+
+void Cuelist::Update(std::map<std::string, knxdmxd::Fixture>& fixtureList, const int KNX, const int val, const unsigned long long loopCounter) {
+ if ((_trigger_val==-1) || (_trigger_val==val)) {
+ NextCue(fixtureList, loopCounter);
+ }
+}
+
+void Cuelist::Refresh(std::map<std::string, knxdmxd::Fixture>& fixtureList, const unsigned long long loopCounter) {
+ if ((loopCounter>_next_cue_start) && (_next_cue_start>0)) { // if next_cue_start < 0 : manual trigger
+ NextCue(fixtureList, loopCounter);
+ }
+}
+
+}
Added: tools/knxdmxd/src/cuelist.h
===================================================================
--- tools/knxdmxd/src/cuelist.h (rev 0)
+++ tools/knxdmxd/src/cuelist.h 2012-05-13 15:47:33 UTC (rev 818)
@@ -0,0 +1,47 @@
+/*
+ * cuelist.h
+ *
+ * (c) by JNK 2012
+ *
+ *
+*/
+
+#ifndef CUELIST_H
+#define CUELIST_H
+
+#include <string.h>
+#include <knxdmxd.h>
+#include <deque>
+#include <fixture.h>
+#include <cue.h>
+
+namespace knxdmxd {
+
+class Cuelist {
+ public:
+ Cuelist() {};
+ Cuelist(const std::string name);
+
+ void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, const int KNX, const int val);
+ void AddTrigger(knxdmxd::knx_patch_map_t& patchMap, const std::string KNX, const int val);
+ void AddCue(knxdmxd::Cue& cue);
+
+ void Update(std::map<std::string, knxdmxd::Fixture>& fixtureList, const int KNX, const int val, const unsigned long long loopCounter);
+ void Refresh(std::map<std::string, knxdmxd::Fixture>& fixtureList, const unsigned long long loopCounter);
+
+ private:
+ void NextCue(std::map<std::string, knxdmxd::Fixture>& fixtureList, const unsigned long long loopCounter);
+
+ std::string _name;
+ int _triggerKNX;
+ int _trigger_val;
+ int _current_cue;
+ unsigned long long _next_cue_start;
+ std::deque<knxdmxd::Cue> _cue_data;
+
+};
+
+
+}
+
+#endif
Modified: tools/knxdmxd/src/fixture.cc
===================================================================
--- tools/knxdmxd/src/fixture.cc 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/fixture.cc 2012-05-13 15:47:33 UTC (rev 818)
@@ -47,7 +47,7 @@
_fadeTimeKNX = KNX;
}
-void Fixture::Update(std::string channel, const int val, bool direct) {
+void Fixture::Update(const std::string& channel, const int val, bool direct) {
_channelValue[channel] = val;
_channelFadeStep[channel] = direct ? 256 : _fadeStep;
std::clog << "Fixture '" << _name << "': Channel '" << channel << "' @ " << val << ", direct: " << ((direct) ? "true" : "false") << std::endl;
@@ -59,16 +59,16 @@
}
}
-void Fixture::Update(std::string channel, const int val, float fadeStep) {
+void Fixture::Update(const std::string& channel, const int val, float fadeStep) {
_channelValue[channel] = val;
_channelFadeStep[channel] = fadeStep;
- std::clog << "Fixture '" << _name << "': Channel '" << channel << "' @ " << val << ", fading: " << fadeStep << std::endl;
+ std::clog << "Fixture '" << _name << "': Channel '" << channel << "' @ " << _channelValue[channel] << ", fading: " << fadeStep << " old: "<< _channelFloatValue[channel] << std::endl;
}
void Fixture::Refresh(std::map<int, ola::DmxBuffer>& output) {
for(std::map<std::string, int>::const_iterator i = _channelDMX.begin(); i != _channelDMX.end(); ++i) {
- int dmxuniverse = (int) (i->second / 512) , dmxchannel = i->second % 512;
+ int dmxuniverse = (int) (i->second / 512), dmxchannel = i->second % 512;
int oldValue = output[dmxuniverse].Get(dmxchannel);
int newValue = _channelValue[i->first];
if (oldValue<newValue) {
@@ -77,7 +77,7 @@
_channelFloatValue[i->first] = newValue;
}
output[dmxuniverse].SetChannel(dmxchannel, (int) _channelFloatValue[i->first]);
- std::clog << "Fade: " << dmxuniverse << "." << dmxchannel << " @ " << _channelFloatValue[i->first] << std::endl;
+ //std::clog << "Fade: " << dmxuniverse << "." << dmxchannel << " @ " << _channelFloatValue[i->first] << std::endl;
}
if (oldValue>newValue) {
_channelFloatValue[i->first] -= _channelFadeStep[i->first];
@@ -85,9 +85,12 @@
_channelFloatValue[i->first] = newValue;
}
output[dmxuniverse].SetChannel(dmxchannel, (int) _channelFloatValue[i->first]);
- std::clog << "Fade: " << dmxuniverse << "." << dmxchannel << " @ " << _channelFloatValue[i->first] << std::endl;
+ //std::clog << "Fade: " << dmxuniverse << "." << dmxchannel << " @ " << _channelFloatValue[i->first] << std::endl;
}
}
}
+int Fixture::GetCurrentValue(const std::string& channel) {
+ return (int) _channelFloatValue.find(channel)->second;
}
+}
Modified: tools/knxdmxd/src/fixture.h
===================================================================
--- tools/knxdmxd/src/fixture.h 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/fixture.h 2012-05-13 15:47:33 UTC (rev 818)
@@ -23,10 +23,11 @@
void Patch(knxdmxd::knx_patch_map_t& patchMap, const std::string channel, const std::string DMX, const std::string KNX);
void SetFadeTime(const float t);
void PatchFadeTime(const int KNX);
- void Update(std::string channel, const int val, const bool direct=false);
- void Update(std::string channel, const int val, const float fadeStep);
+ void Update(const std::string& channel, const int val, const bool direct=false);
+ void Update(const std::string& channel, const int val, const float fadeStep);
void Update(const int KNX, const int val, const bool direct=false);
void Refresh(std::map<int, ola::DmxBuffer>& output);
+ int GetCurrentValue(const std::string& channel);
private:
std::string _name;
std::map <std::string, int> _channelKNX;
Modified: tools/knxdmxd/src/knxdmxd.cc
===================================================================
--- tools/knxdmxd/src/knxdmxd.cc 2012-05-13 10:36:15 UTC (rev 817)
+++ tools/knxdmxd/src/knxdmxd.cc 2012-05-13 15:47:33 UTC (rev 818)
@@ -45,6 +45,7 @@
#include <fixture.h>
#include <cue.h>
+#include <cuelist.h>
#define DEBUG 1
#define DAEMON_NAME "knxdmxd"
@@ -101,13 +102,16 @@
std::string conf_file = "knxdmxd.conf";
int pidFilehandle;
std::string pidfilename = "/var/run/dmxknxd.pid";
+unsigned long long loopCounter = 0;
std::map<int, ola::DmxBuffer> dmxWriteBuffer;
std::map<std::string, knxdmxd::Fixture> fixtureList;
std::map<std::string, knxdmxd::Cue> sceneList;
+std::map<std::string, knxdmxd::Cuelist> cuelistList;
knxdmxd::knx_patch_map_t KNX_fixture_patchMap;
knxdmxd::knx_patch_map_t KNX_scene_patchMap;
+knxdmxd::knx_patch_map_t KNX_cuelist_patchMap;
//map<int, channel> DMXpatchMap;
@@ -141,9 +145,14 @@
void refresh_output(int signo)
{
+ loopCounter++;
for(std::map<std::string, knxdmxd::Fixture>::const_iterator i = fixtureList.begin(); i != fixtureList.end(); ++i) {
fixtureList[i->first].Refresh(dmxWriteBuffer);
}
+ for(std::map<std::string, knxdmxd::Cuelist>::const_iterator i = cuelistList.begin(); i != cuelistList.end(); ++i) {
+ cuelistList[i->first].Refresh(fixtureList, loopCounter);
+ }
+
signal(SIGALRM, refresh_output);
}
@@ -194,7 +203,7 @@
std::clog << "Received " << (int)val << " @ " << dest << ", updated " << unum << " fixtures" << std::endl;
}
if (KNX_scene_patchMap.count(dest)>0) {
- std::pair<knxdmxd::knx_patch_map_t::iterator, knxdmxd::knx_patch_map_t::iterator> uScenes; // fixtures that handle this
+ std::pair<knxdmxd::knx_patch_map_t::iterator, knxdmxd::knx_patch_map_t::iterator> uScenes; // scenes that handle this
uScenes = KNX_scene_patchMap.equal_range(dest);
int unum=0;
for (knxdmxd::knx_patch_map_t::iterator it = uScenes.first; it != uScenes.second; ++it)
@@ -204,9 +213,18 @@
}
std::clog << "Received " << (int) val << " @ " << dest << ", checked " << unum << " scenes" << std::endl;
}
-
-
- }
+ if (KNX_cuelist_patchMap.count(dest)>0) {
+ std::pair<knxdmxd::knx_patch_map_t::iterator, knxdmxd::knx_patch_map_t::iterator> uCuelists; // scenes that handle this
+ uCuelists = KNX_cuelist_patchMap.equal_range(dest);
+ int unum=0;
+ for (knxdmxd::knx_patch_map_t::iterator it = uCuelists.first; it != uCuelists.second; ++it)
+ {
+ cuelistList[it->second].Update(fixtureList, dest, val, loopCounter);
+ unum++;
+ }
+ std::clog << "Received " << (int) val << " @ " << dest << ", checked " << unum << " cuelists" << std::endl;
+ }
+ }
break;
}
return 0;
@@ -294,7 +312,7 @@
std::clog << kLogWarning << "eibd: Unknown APDU from "<< src << " to " << dest << std::endl;
break;
} else {
- if ( (KNX_fixture_patchMap.count(dest)+KNX_scene_patchMap.count(dest))<=0 ) //not for us
+ if ( (KNX_fixture_patchMap.count(dest)+KNX_scene_patchMap.count(dest)+KNX_cuelist_patchMap.count(dest))<=0 ) //not for us
continue;
handleKNXdgram(dest,buf,len);
}
@@ -312,11 +330,14 @@
config = json_object_from_file((char *)conf_file.c_str());
- // first all fixtures
+ /*
+ * fixtures
+ */
+
struct json_object *fixtures = json_object_object_get(config, "fixtures");
int fixturenum = json_object_array_length(fixtures);
- std::clog << "Trying to import " << fixturenum << " fixtures" << std::endl;
-
+ std::clog << "Trying to import " << fixturenum << " fixture(s)" << std::endl;
+
for (int i=0; i<fixturenum; i++) { // read all
// get fixture
struct json_object *fixture = json_object_array_get_idx(fixtures, i);
@@ -366,9 +387,13 @@
fixtureList[fname] = f;
}
+ /*
+ * scenes
+ */
+
struct json_object *scenes = json_object_object_get(config, "scenes");
int scenenum = json_object_array_length(scenes);
- std::clog << "Trying to import " << scenenum << " scenes" << std::endl;
+ std::clog << "Trying to import " << scenenum << " scene(s)" << std::endl;
for (int i=0; i<scenenum; i++) { // read all
struct json_object *scene = json_object_array_get_idx(scenes, i);
@@ -407,7 +432,7 @@
struct json_object *value = json_object_object_get(channel, "value");
if ((!fixt) || (!chan) || (!value)) {
- std::clog << kLogInfo << "Skipping errorneous channel def " << j << "' in scene '" << sname << "'" << std::endl;
+ std::clog << kLogInfo << "Skipping errorneous channel def " << j << " in scene '" << sname << "'" << std::endl;
continue;
}
@@ -420,10 +445,103 @@
s.AddChannel(channeldata);
}
-
+ struct json_object *fading = json_object_object_get(scene, "fading");
+ if (fading) {
+ struct json_object *fading_time = json_object_object_get(fading, "time");
+ if (!fading_time) {
+ struct json_object *fading_time_in = json_object_object_get(fading, "in");
+ struct json_object *fading_time_out = json_object_object_get(fading, "out");
+
+ if ((!fading_time_in) || (!fading_time_out)) {
+ std::clog << kLogInfo << "Skipping errorneous fading def in scene '" << sname << "'" << std::endl;
+ } else {
+ float in = json_object_get_double(fading_time_in);
+ s.SetFading(in, json_object_get_double(fading_time_out));
+ }
+ } else {
+ s.SetFading(json_object_get_double(fading_time));
+ }
+ }
+
sceneList[sname] = s;
}
+ /*
+ * cuelists
+ */
+
+ struct json_object *cuelists = json_object_object_get(config, "cuelists");
+ int cuelistnum = json_object_array_length(cuelists);
+ std::clog << "Trying to import " << cuelistnum << " cuelist(s)" << std::endl;
+
+ for (int i=0; i<cuelistnum; i++) { // read all
+ struct json_object *cuelist = json_object_array_get_idx(cuelists, i);
+
+ // get name & create
+ struct json_object *name = json_object_object_get(cuelist, "name");
+ std::string cname = (name) ? json_object_get_string(name) : "_c_"+t_to_string(i);
+ knxdmxd::Cuelist c(cname);
+
+ // trigger is required
+ struct json_object *trigger = json_object_object_get(cuelist, "trigger");
+ struct json_object *trigger_knx = json_object_object_get(trigger, "knx");
+
+ if ((!trigger) || (!trigger_knx)) {
+ std::clog << kLogInfo << "Skipping cuelist '" << cname << "' (error in trigger)" << std::endl;
+ continue;
+ }
+
+ struct json_object *trigger_go = json_object_object_get(trigger, "go");
+ c.AddTrigger(KNX_cuelist_patchMap, json_object_get_string(trigger_knx), (trigger_go) ? json_object_get_int(trigger_go) : -1);
+
+ struct json_object *cues = json_object_object_get(cuelist, "cues");
+ int cuenum = json_object_array_length(cues);
+ for (int i=0; i<cuenum; i++) { // read all
+ struct json_object *cue = json_object_array_get_idx(cues, i);
+
+ struct json_object *name = json_object_object_get(cue, "name");
+ std::string c_name = (name) ? json_object_get_string(name) : cname+"_c_"+t_to_string(i);
+ knxdmxd::Cue c_(c_name);
+
+ struct json_object *waittime = json_object_object_get(cue, "waittime");
+ c_.SetWaittime((waittime) ? (float) json_object_get_double(waittime) : -1);
+
+ // get channels
+ struct json_object *channels = json_object_object_get(cue, "channels");
+ if (!channels) {
+ std::clog << kLogInfo << "Skipping cue '" << c_name << "' (no channels defined)" << std::endl;
+ continue;
+ }
+
+ int channelnum = json_object_array_length(channels);
+ for (int j=0; j<channelnum; j++) { // read all
+ // get channel
+ struct json_object *channel = json_object_array_get_idx(channels, j);
+
+ struct json_object *fixt = json_object_object_get(channel, "fixture");
+ struct json_object *chan = json_object_object_get(channel, "channel");
+ struct json_object *value = json_object_object_get(channel, "value");
+
+ if ((!fixt) || (!chan) || (!value)) {
+ std::clog << kLogInfo << "Skipping errorneous channel def " << j << " in cue '" << c_name << "'" << std::endl;
+ continue;
+ }
+
+ knxdmxd::cue_channel_t channeldata;
+ channeldata.fixture = json_object_get_string(fixt);
+ channeldata.name = json_object_get_string(chan);
+ channeldata.value = json_object_get_int(value);
+
+ // add
+ c_.AddChannel(channeldata);
+ }
+
+ c.AddCue(c_);
+ }
+
+ cuelistList[cname] = c;
+ }
+
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|