changeset 13:47b0a143db39

...
author cannam
date Tue, 12 Dec 2006 10:38:55 +0000
parents faec23aecc74
children bd4589c609c7
files host/FDWriteAction.cpp host/ImageAction.cpp host/ImageAction.h host/Processor.cpp host/SimpleXMLRuleLoader.cpp
diffstat 5 files changed, 27 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/host/FDWriteAction.cpp	Fri Dec 08 18:18:28 2006 +0000
+++ b/host/FDWriteAction.cpp	Tue Dec 12 10:38:55 2006 +0000
@@ -64,12 +64,11 @@
 void
 FDWriteAction::fire()
 {
-    std::cerr << getName().toStdString() << ": fire" << std::endl;
-
     if (m_fd < 0) return;
     QMutexLocker locker(&m_mutex);
     if (m_togglePrevious) {
         if (m_previousData == m_data) return;
+        std::cerr << getName().toStdString() << ": fire" << std::endl;
         if (m_previousData != "") {
             // bug here
             write(m_fd, m_previousData.toLocal8Bit().data(), m_previousData.length());
--- a/host/ImageAction.cpp	Fri Dec 08 18:18:28 2006 +0000
+++ b/host/ImageAction.cpp	Tue Dec 12 10:38:55 2006 +0000
@@ -5,6 +5,9 @@
 
 #include <iostream>
 
+QString
+ImageAction::m_currentImage;
+
 ImageAction::ImageAction(QString imageName) :
     m_imageName(imageName)
 {
@@ -25,8 +28,10 @@
 void
 ImageAction::fire()
 {
+    if (m_currentImage == m_imageName) return;
     std::cerr << "ImageAction(\"" << getName().toStdString() << "\")::fire"
               << std::endl;
+    m_currentImage = m_imageName;
     emit showImage(m_imageName);
 }
 
--- a/host/ImageAction.h	Fri Dec 08 18:18:28 2006 +0000
+++ b/host/ImageAction.h	Tue Dec 12 10:38:55 2006 +0000
@@ -21,6 +21,7 @@
 
 protected:
     QString m_imageName;
+    static QString m_currentImage;
 };
 
 #endif
--- a/host/Processor.cpp	Fri Dec 08 18:18:28 2006 +0000
+++ b/host/Processor.cpp	Tue Dec 12 10:38:55 2006 +0000
@@ -212,7 +212,8 @@
                                 Vamp::RealTime rt =
                                     Vamp::RealTime::frame2RealTime(frame[reader], sr);
 
-                                bool changed = currentState.present;
+//                                bool changed = currentState.present;
+                                bool changed = false;
                                 Vamp::RealTime gap = rt - currentState.laststamp;
                                 m_pluginStates[pluginIndex][output] =
                                     OutputState(false, changed, currentState.value, currentState.laststamp, currentState.gap);
@@ -245,7 +246,8 @@
                                 m_pluginStates[pluginIndex][output];
                             
                             if (fl.empty()) {
-                                bool changed = currentState.present;
+//                                bool changed = currentState.present;
+                                bool changed = false;
                                 Vamp::RealTime gap = rt - currentState.laststamp;
                                 m_pluginStates[pluginIndex][output] =
                                     OutputState(false, changed, currentState.value, currentState.laststamp, currentState.gap);
@@ -259,9 +261,14 @@
                                     value = fl[0].values[0];
                                 }
                                 bool changed =
-                                    (!currentState.present ||
+//                                    (!currentState.present ||
                                      (fabsf(currentState.value - value) >
-                                      0.000001));
+                                      0.000001)
+//                                    )
+                                    ;
+                                if (changed) {
+                                    std::cerr << "changed: " <<currentState.value << " -> " << value << std::endl;
+                                }
                                 Vamp::RealTime gap = rt - currentState.laststamp;
 //                                std::cerr << "gap = " << gap << std::endl;
                                 m_pluginStates[pluginIndex][output] =
@@ -436,6 +443,7 @@
         Rule *rule(*i);
 
         bool passed = false;
+        bool oneChanged = false;
 
         for (Rule::ConditionList::const_iterator j = rule->getConditions().begin();
              j != rule->getConditions().end(); ++j) {
@@ -455,7 +463,10 @@
 
             passed = false;
 
-            if (!state.changed) break; //!!!???
+            if (state.changed) {
+//                std::cerr << "State changed with present = " << state.present << ", value = " << state.value << std::endl;
+                oneChanged = true;
+            }
 
             switch (type) {
 
@@ -477,10 +488,11 @@
                 
             case Condition::Present:
                 passed = state.present;
+                if (passed) oneChanged = true;
                 break;
                 
             case Condition::Changed:
-                passed = true;
+                passed = state.changed;
                 break;
                 
             case Condition::GapGreaterThan:
@@ -496,7 +508,7 @@
             if (!passed) break;
         }
 
-        if (passed) {
+        if (passed && oneChanged) {
             for (Rule::ActionList::const_iterator ai = rule->getActions().begin();
                  ai != rule->getActions().end(); ++ai) {
                 Action *action = *ai;
--- a/host/SimpleXMLRuleLoader.cpp	Fri Dec 08 18:18:28 2006 +0000
+++ b/host/SimpleXMLRuleLoader.cpp	Tue Dec 12 10:38:55 2006 +0000
@@ -162,7 +162,7 @@
         QString type = atts.value("type").toLower();
 
         if (type == "image") {
-            QString image = atts.value("image").toLower();
+            QString image = atts.value("image");
             Action *action = new ImageAction(image);
             m_rule->addAction(action);
             std::cerr << "INFO: SimpleXMLRuleLoader: Added image action" << std::endl;