|
From: <j-...@us...> - 2012-10-28 16:06:12
|
Revision: 1079
http://openautomation.svn.sourceforge.net/openautomation/?rev=1079&view=rev
Author: j-n-k
Date: 2012-10-28 16:06:00 +0000 (Sun, 28 Oct 2012)
Log Message:
-----------
Fixed lots of bugs, including
- spamming of logfile in daemon-mode (should be INFO+up, was ALL)
- wrong DMX-channel numbering (started 0, but should be 1)
- cuelists should be halted after last cue (and released if
configured)
- waittime in cuelists should be treated as float, not integer
Modified Paths:
--------------
tools/knxdmxd/knxdmxd
tools/knxdmxd/src/cue.cc
tools/knxdmxd/src/cue.h
tools/knxdmxd/src/dmxsender.cc
tools/knxdmxd/src/dmxsender.h
tools/knxdmxd/src/knxdmxd.cc
tools/knxdmxd/src/trigger.cc
Modified: tools/knxdmxd/knxdmxd
===================================================================
(Binary files differ)
Modified: tools/knxdmxd/src/cue.cc
===================================================================
--- tools/knxdmxd/src/cue.cc 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/cue.cc 2012-10-28 16:06:00 UTC (rev 1079)
@@ -4,131 +4,173 @@
* (c) by JNK 2012
*
*
-*/
+ */
-
#include "cue.h"
-namespace knxdmxd {
+namespace knxdmxd
+{
- Cue::Cue(const std::string name, const bool isLink) {
- _name=name;
+ Cue::Cue(const std::string name, const bool isLink)
+ {
+ _name = name;
fadeIn_ = 0.0;
fadeOut_ = 0.0;
waittime_ = -1; // never step automatically
delay_ = 0.0; // call immediately
delay_on_ = false;
is_link_ = isLink;
- if (!is_link_) {
- std::clog << "Creating Cue " << name << std::endl;
- } else {
- std::clog << "Creating link to cue " << name << std::endl;
- }
+ if (!is_link_)
+ {
+ std::clog << kLogDebug << "Creating Cue " << name << std::endl;
+ }
+ else
+ {
+ std::clog << kLogDebug << "Creating link to cue " << name << std::endl;
+ }
}
- void Cue::AddChannel(const cue_channel_t& channel) {
+ void
+ Cue::AddChannel(const cue_channel_t& channel)
+ {
_channel_data.push_back(channel);
- std::clog << "Cue " << _name << ": added channel definition " << channel.dmx << "@" << channel.value << std::endl;
+ std::clog << kLogDebug << "Cue " << _name << ": added channel definition "
+ << channel.dmx << "@" << channel.value << std::endl;
}
- void Cue::SetFading(const float fadeIn, const float fadeOut) {
- fadeIn_ = (fadeIn<1.e-3) ? (DMX_INTERVAL/1.e3) : fadeIn;
- fadeOut_ = (fadeOut<1.e-3) ? (DMX_INTERVAL/1.e3) : fadeOut;
-
- std::clog << kLogDebug << "Cue " << _name << ": set fading " << fadeIn_ << "/" << fadeOut_ << std::endl;
+ void
+ Cue::SetFading(const float fadeIn, const float fadeOut)
+ {
+ fadeIn_ = (fadeIn < 1.e-3) ? (DMX_INTERVAL / 1.e3) : fadeIn;
+ fadeOut_ = (fadeOut < 1.e-3) ? (DMX_INTERVAL / 1.e3) : fadeOut;
+
+ std::clog << kLogDebug << "Cue " << _name << ": set fading " << fadeIn_
+ << "/" << fadeOut_ << std::endl;
}
- void Cue::Go() {
- if ((delay_>0) && (!delay_on_)) {
- DMX::GetOLAClient().GetSelectServer()->RegisterSingleTimeout(
- (int) delay_*1000, ola::NewSingleCallback(this, &Cue::Go));
- delay_on_ = true;
- std::clog << "Called cue " << _name << " (delaying)" << std::endl;
- } else {
- for(std::list<cue_channel_t>::iterator it = _channel_data.begin(); it != _channel_data.end(); ++it) {
- DMX::SetDMXChannel(it->dmx , it->value, fadeIn_, fadeOut_ );
+ void
+ Cue::Go()
+ {
+ if ((delay_ > 0) && (!delay_on_))
+ {
+ DMX::GetOLAClient().GetSelectServer()->RegisterSingleTimeout(
+ (int) delay_ * 1000, ola::NewSingleCallback(this, &Cue::Go));
+ delay_on_ = true;
+ std::clog << kLogDebug << "Called cue " << _name << " (delaying)"
+ << std::endl;
}
- delay_on_ = false;
- std::clog << "Called cue " << _name << std::endl;
- }
+ else
+ {
+ for (std::list<cue_channel_t>::iterator it = _channel_data.begin();
+ it != _channel_data.end(); ++it)
+ {
+ DMX::SetDMXChannel(it->dmx, it->value, fadeIn_, fadeOut_);
+ }
+ delay_on_ = false;
+ std::clog << kLogDebug << "Called cue " << _name << std::endl;
+ }
}
- Cuelist::Cuelist(const std::string name) {
- _name=name;
- current_cue_=-1;
-
+ Cuelist::Cuelist(const std::string name)
+ {
+ _name = name;
+ current_cue_ = -1;
+
was_direct_ = false;
cue_halted_ = true;
release_on_halt_ = true;
-
+
max_cue_ = 0;
-
- std::clog << "Creating Cuelist '" << name << "'" << std::endl;
- }
- void Cuelist::AddCue(knxdmxd::Cue& cue) {
+ std::clog << kLogDebug << "Creating Cuelist '" << name << "'" << std::endl;
+ }
+
+ void
+ Cuelist::AddCue(knxdmxd::Cue& cue)
+ {
cue_data_.push_back(cue);
int cue_num = max_cue_;
- if (!cue.isLink()) {
- cue_names_.insert(std::pair<std::string, int>(cue.GetName(), cue_num));
- std::clog << "Cuelist " << _name << ": added cue " << cue.GetName() << " as #" << cue_num << std::endl;
- } else {
- std::clog << "Cuelist " << _name << ": added link to cue '" << cue.GetName() << "' as #" << cue_num << std::endl;
- }
+ if (!cue.isLink())
+ {
+ cue_names_.insert(std::pair<std::string, int>(cue.GetName(), cue_num));
+ std::clog << kLogDebug << "Cuelist " << _name << ": added cue "
+ << cue.GetName() << " as #" << cue_num << std::endl;
+ }
+ else
+ {
+ std::clog << kLogDebug << "Cuelist " << _name << ": added link to cue '"
+ << cue.GetName() << "' as #" << cue_num << std::endl;
+ }
max_cue_++;
}
- void Cuelist::NextCue(const int direct) {
- if (was_direct_) {
- was_direct_ = false;
- return;
- }
+ void
+ Cuelist::NextCue(const int direct)
+ {
+ if (was_direct_)
+ {
+ was_direct_ = false;
+ return;
+ }
- switch (direct) {
- default: // direct call
- if (direct>=max_cue_) { // called cue too large
- std::clog << kLogInfo << "Tried direct call to cue " << direct << " in cuelist " << _name << ": too large" << std::endl;
+ switch (direct)
+ {
+ default: // direct call
+ if (direct >= max_cue_)
+ { // called cue too large
+ std::clog << kLogInfo << "Tried direct call to cue " << direct
+ << " in cuelist " << _name << ": too large" << std::endl;
return;
}
- current_cue_ = direct - 1;
- if (!cue_halted_) // only if cuelist was running
- was_direct_ = true;
- break;
- case -1: // normal call
- break;
- case -2: // next on running cuelist
+ current_cue_ = direct - 1;
+ if (!cue_halted_) // only if cuelist was running
was_direct_ = true;
- break;
- }
+ break;
+ case -1: // normal call
+ break;
+ case -2: // next on running cuelist
+ was_direct_ = true;
+ break;
+ }
- if (max_cue_>(current_cue_+1)) {
- try {
- if (current_cue_>=0)
- cue_data_.at(current_cue_).Release();
+ if (max_cue_ > (current_cue_ + 1))
+ {
+ try
+ {
+ if (current_cue_ >= 0)
+ cue_data_.at(current_cue_).Release();
- current_cue_++;
- knxdmxd::Cue cue = cue_data_.at(current_cue_);
- if (cue.isLink()) {
- current_cue_ = cue_names_.find(cue.GetName())->second;
- }
-
- cue_data_.at(current_cue_).Go();
-
- float waittime;
- int nextCuenum = current_cue_+1;
- if (max_cue_>nextCuenum) { // last cue stops automatically
- knxdmxd::Cue nextCue = cue_data_.at(nextCuenum);
- if (nextCue.isLink()) {
- nextCuenum = cue_names_.find(nextCue.GetName())->second;
- nextCue = cue_data_.at(nextCuenum);
- }
- waittime = nextCue.GetWaitTime();
- if ((waittime>=0) && (!cue_halted_)) {
- DMX::GetOLAClient().GetSelectServer()->RegisterSingleTimeout(
- (int) waittime*1000, ola::NewSingleCallback(this, &Cuelist::NextCue, -1));
- }
+ current_cue_++;
+ knxdmxd::Cue cue = cue_data_.at(current_cue_);
+ if (cue.isLink())
+ {
+ current_cue_ = cue_names_.find(cue.GetName())->second;
}
+
+ cue_data_.at(current_cue_).Go();
+
+ float waittime;
+ int nextCuenum = current_cue_ + 1;
+ if (max_cue_ > nextCuenum)
+ {
+ knxdmxd::Cue nextCue = cue_data_.at(nextCuenum);
+ if (nextCue.isLink())
+ {
+ nextCuenum = cue_names_.find(nextCue.GetName())->second;
+ nextCue = cue_data_.at(nextCuenum);
+ }
+ waittime = nextCue.GetWaitTime();
+ if ((waittime >= 0) && (!cue_halted_))
+ {
+ DMX::GetOLAClient().GetSelectServer()->RegisterSingleTimeout(
+ (int) (waittime * 1000.),
+ ola::NewSingleCallback(this, &Cuelist::NextCue, -1));
+ }
+ } else {
+ // last cue halts automatically
+ Halt();
+ }
}
catch (char *str)
{
@@ -136,7 +178,7 @@
<< " in calling cue, current_cue_ = " << current_cue_
<< std::endl;
}
- }
+ }
}
}
Modified: tools/knxdmxd/src/cue.h
===================================================================
--- tools/knxdmxd/src/cue.h 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/cue.h 2012-10-28 16:06:00 UTC (rev 1079)
@@ -150,7 +150,8 @@
void
Release()
{
- cue_data_.at(current_cue_).Release();
+ cue_halted_ = true;
+ current_cue_ = -1;
}
;
};
Modified: tools/knxdmxd/src/dmxsender.cc
===================================================================
--- tools/knxdmxd/src/dmxsender.cc 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/dmxsender.cc 2012-10-28 16:06:00 UTC (rev 1079)
@@ -64,13 +64,13 @@
if (currenttime > fadeend_[i])
{
current_[i] = old_[i] = new_[i];
- std::clog << "DMXSender: Finished crossfading universe "
+ std::clog << kLogDebug << "DMXSender: Finished crossfading universe "
<< (int) universe_ << " channel " << i << " to "
<< (int) current_[i] << std::endl;
dmx_addr_t dmx = (universe_ << 9) + i; // calculate dmx-addr
if (knxdmxd::statusmap.count(dmx))
{
- std::clog << "DMXSender: writing status update to KNX "
+ std::clog << kLogDebug << "DMXSender: writing status update to KNX "
<< std::endl;
knxdmxd::eib_message_t message;
message.value = (long) new_[i];
Modified: tools/knxdmxd/src/dmxsender.h
===================================================================
--- tools/knxdmxd/src/dmxsender.h 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/dmxsender.h 2012-10-28 16:06:00 UTC (rev 1079)
@@ -45,17 +45,18 @@
1.e-4, const float fade_out = 1.e-4)
{
ola::thread::MutexLocker locker(&data_mutex);
- new_[channel] = value;
- old_[channel] = current_[channel];
- float fadeTime = (new_[channel] > current_[channel]) ? fade_in : fade_out;
- fadestart_[channel] = Timer::Get();
- fadeend_[channel] = fadestart_[channel]
+ const unsigned ch = channel - 1;
+ new_[ch] = value;
+ old_[ch] = current_[ch];
+ float fadeTime = (new_[ch] > current_[ch]) ? fade_in : fade_out;
+ fadestart_[ch] = Timer::Get();
+ fadeend_[ch] = fadestart_[ch]
+ (unsigned long) (fadeTime * 1000.0);
}
unsigned char
Get(const unsigned channel)
{
- return current_[channel];
+ return current_[channel-1];
}
ola::DmxBuffer &
GetBuffer()
@@ -138,7 +139,7 @@
{ // only create if not already existing;
pUniverse new_universe = new Universe(universe);
output.insert(std::pair<char, pUniverse>(universe, new_universe));
- std::clog << "DMXSender created universe " << (int) universe
+ std::clog << kLogInfo << "DMXSender created universe " << (int) universe
<< std::endl;
}
}
@@ -163,7 +164,7 @@
dmx_ = dmx;
ga_ = ga;
fade_time_ = 1.e-4;
- std::clog << "Created dimmer '" << name << "' for " << dmx << std::endl;
+ std::clog << kLogDebug << "Created dimmer '" << name << "' for " << dmx << std::endl;
}
void
SetFadeTime(float fade_time)
@@ -179,17 +180,17 @@
Process(const Trigger& trigger)
{
eibaddr_t ga = trigger.GetKNX();
- std::clog << "Checking trigger " << trigger << " for " << name_
+ std::clog << kLogDebug << "Checking trigger " << trigger << " for " << name_
<< " (GA: " << ga_ << ")" << std::endl;
if (ga == ga_)
{
DMX::SetDMXChannel(dmx_, trigger.GetValue(), fade_time_, fade_time_);
- std::clog << "Dimmer/Process: Updating value for " << name_ << " to "
+ std::clog << kLogDebug << "Dimmer/Process: Updating value for " << name_ << " to "
<< trigger.GetValue() << std::endl;
}
if (ga == ga_fading_)
{
- std::clog << "Dimmer/Process: Updating (tba) fading for " << name_
+ std::clog << kLogDebug << "Dimmer/Process: Updating (tba) fading for " << name_
<< " to " << trigger.GetValue() << std::endl;
}
}
Modified: tools/knxdmxd/src/knxdmxd.cc
===================================================================
--- tools/knxdmxd/src/knxdmxd.cc 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/knxdmxd.cc 2012-10-28 16:06:00 UTC (rev 1079)
@@ -179,14 +179,14 @@
len = EIBSendAPDU(con, len, buf);
if (len == -1)
{
- std::clog << "KNXSender: failed to sent " << (int) message.value
+ std::clog << kLogDebug << "KNXSender: failed to sent " << (int) message.value
<< " to " << message.ga << " (DPT: " << (int) message.dpt
<< ")" << std::endl;
}
else
{
- std::clog << "KNXSender: sent " << (int) message.value << " to "
+ std::clog << kLogDebug << "KNXSender: sent " << (int) message.value << " to "
<< message.ga << " (DPT: " << (int) message.dpt << ")"
<< std::endl;
}
@@ -194,9 +194,9 @@
EIBClose(con);
} else {
- std::clog << "KNX sender waiting for message" << std::endl;
+ std::clog << kLogDebug << "KNX sender waiting for message" << std::endl;
KNXSender::condition_toKNX.Wait(&KNXSender::mutex_toKNX);
- std::clog << "KNX sender resumed" << std::endl;
+ std::clog << kLogDebug << "KNX sender resumed" << std::endl;
}
}
@@ -271,7 +271,7 @@
val = (len == 2) ? buf[1] & 0x3F : buf[2];
if (KNXHandler::listenGA.count(dest))
{ // keep queue clean from unwanted messages
- std::clog << "KNXHandler: " << dest << " "
+ std::clog << kLogDebug << "KNXHandler: " << dest << " "
<< (int) val << std::endl;
knxdmxd::Trigger trigger(knxdmxd::kTriggerAll, dest,
val);
@@ -562,7 +562,7 @@
sender.AddUniverse((char) (dmx_addr / 512));
knxdmxd::channel_names.insert(
std::pair<std::string, knxdmxd::dmx_addr_t>(name_str, dmx_addr));
- std::clog << "Named DMX " << dmx_addr << " as " << name_str;
+ std::clog << kLogDebug << "Named DMX " << dmx_addr << " as " << name_str;
struct json_object *ga = json_object_object_get(element, "statusga");
if (!ga)
{
@@ -584,7 +584,7 @@
in_data = json_object_object_get(config, "dimmers");
in_length = json_object_array_length(in_data);
- std::clog << "Trying to import " << in_length << " dimmer(s)" << std::endl;
+ std::clog << kLogDebug << "Trying to import " << in_length << " dimmer(s)" << std::endl;
for (int i = 0; i < in_length; i++)
{ // read all
@@ -665,7 +665,7 @@
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;
+ std::clog << kLogDebug << "Trying to import " << cuelistnum << " cuelist(s)" << std::endl;
for (int i = 0; i < cuelistnum; i++)
{ // read all
@@ -777,15 +777,15 @@
std::clog.rdbuf(
new Log(DAEMON_NAME, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID,
LOG_USER));
- std::clog << "startup with debug; pidfile: " << pidfilename << ", eibd: "
+ std::clog << kLogDebug << "startup with debug; pidfile: " << pidfilename << ", eibd: "
<< knxhandler.GetEIBDURL() << std::endl;
}
else
{
- setlogmask(LOG_UPTO(LOG_DEBUG));
+ setlogmask(LOG_UPTO(LOG_INFO));
std::clog.rdbuf(new Log(DAEMON_NAME, LOG_CONS, LOG_USER));
}
- std::clog << kLogDebug << DAEMON_NAME << " compiled on " << __DATE__ << " "
+ std::clog << kLogInfo << DAEMON_NAME << " compiled on " << __DATE__ << " "
<< __TIME__ << " with GCC " << __VERSION__ << std::endl;
std::clog << kLogInfo << "using config-file " << conf_file << std::endl;
Modified: tools/knxdmxd/src/trigger.cc
===================================================================
--- tools/knxdmxd/src/trigger.cc 2012-10-28 08:54:08 UTC (rev 1078)
+++ tools/knxdmxd/src/trigger.cc 2012-10-28 16:06:00 UTC (rev 1079)
@@ -46,7 +46,7 @@
{
_triggers.push_back(trigger);
_handlers.push_back(handler);
- std::clog << "Added Trigger " << trigger << " for handler " << (*handler)
+ std::clog << kLogDebug << "Added Trigger " << trigger << " for handler " << (*handler)
<< std::endl;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|