[dss-commits] digitalSTROM Server branch, master, updated. 22db5eed7c26b7956ed4708cccbc2942df46e2d0

git version control dss-commits at forum.digitalstrom.org
Thu Jan 7 10:56:09 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".

The branch, master has been updated
       via  22db5eed7c26b7956ed4708cccbc2942df46e2d0 (commit)
       via  cc8bc19ee351d85c919b7896e0f1096b7456b296 (commit)
      from  aadf9ade9ed5dfedbd674f1c3ff0a8fe630b488d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 22db5eed7c26b7956ed4708cccbc2942df46e2d0
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Jan 7 10:55:26 2010 +0100

    DS485-event-plugin works again

commit cc8bc19ee351d85c919b7896e0f1096b7456b296
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Jan 7 10:54:58 2010 +0100

    Initialize pointers

-----------------------------------------------------------------------

Changes:
diff --git a/core/ds485/ds485proxy.cpp b/core/ds485/ds485proxy.cpp
index 6742ae6..352b911 100644
--- a/core/ds485/ds485proxy.cpp
+++ b/core/ds485/ds485proxy.cpp
@@ -51,6 +51,7 @@ namespace dss {
 
   DS485Proxy::DS485Proxy(DSS* _pDSS, ModelMaintenance* _pModelMaintenance)
   : Subsystem(_pDSS, "DS485Proxy"),
+    m_pBusInterfaceHandler(NULL),
     m_pModelMaintenance(_pModelMaintenance),
     m_InitializeDS485Controller(true)
   {
diff --git a/core/eventinterpreterplugins.cpp b/core/eventinterpreterplugins.cpp
index 462003f..5265303 100644
--- a/core/eventinterpreterplugins.cpp
+++ b/core/eventinterpreterplugins.cpp
@@ -38,6 +38,8 @@
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
 
 #include <Poco/DOM/Element.h>
 #include <Poco/DOM/Node.h>
@@ -165,26 +167,17 @@ namespace dss {
 
   class SubscriptionOptionsDS485 : public SubscriptionOptions {
   private:
-    int m_ParameterIndex;
-    int m_SceneIndex;
-    std::string m_To;
-    std::string m_Context;
+    typedef boost::function<void(Set&)> Command;
+    Command m_Command;
   public:
-    SubscriptionOptionsDS485()
-    : m_ParameterIndex(-1), m_SceneIndex(-1)
-    { }
-
-    void setParameterIndex(const int _value) { m_ParameterIndex = _value; }
-    int getParameterIndex() const { return m_ParameterIndex; }
-
-    void setTo(const std::string& _value) { m_To = _value; }
-    const std::string& GetTo() const { return m_To; }
-
-    void setContext(const std::string& _value) { m_Context = _value; }
-    const std::string& getContext() const { return m_Context; }
+    void execute(Set& _set) const {
+      assert(m_Command);
+      m_Command(_set);
+    }
 
-    void setSceneIndex(const int _value) { m_SceneIndex = _value; }
-    int getSceneIndex() const { return m_SceneIndex; }
+    void setCommand(Command _command) {
+      m_Command = _command;
+    }
   };
 
   std::string EventInterpreterPluginDS485::getParameter(Node* _node, const std::string& _parameterName) {
@@ -200,6 +193,7 @@ namespace dss {
       }
       curNode = curNode->nextSibling();
     }
+    Logger::getInstance()->log(std::string("bus_handler: Needed parameter '") + _parameterName + "' not found", lsError);
     return "";
   } // getParameter
 
@@ -212,22 +206,34 @@ namespace dss {
         Element* elem = dynamic_cast<Element*>(curNode);
         if(elem != NULL) {
           std::string typeName = elem->getAttribute("type");
-          std::string paramName = "";
-          bool needParam = false;
-          // TODO: add functionality back
-
-          if(!paramName.empty()) {
-            std::string paramValue = getParameter(curNode, paramName);
-            if(paramValue.size() == 0 && needParam) {
-              Logger::getInstance()->log(std::string("bus_handler: Needed parameter '") + paramName + "' not found in subscription for type '" + typeName + "'", lsError);
-            }
-
-            if(paramName == "parameter") {
-              result->setParameterIndex(strToIntDef(paramValue, -1));
-            } else if(paramName == "scene") {
-              result->setSceneIndex(strToIntDef(paramValue, -1));
-            }
+
+          if(typeName == "turnOn") {
+            result->setCommand(boost::bind(&Set::turnOn, _1));
+          } else if(typeName == "turnOff") {
+            result->setCommand(boost::bind(&Set::turnOff, _1));
+          } else if(typeName == "dimUp") {
+            result->setCommand(boost::bind(&Set::startDim, _1, true));
+          } else if(typeName == "stopDim") {
+            result->setCommand(boost::bind(&Set::endDim, _1));
+          } else if(typeName == "increaseValue") {
+            result->setCommand(boost::bind(&Set::increaseValue, _1));
+          } else if(typeName == "decreaseValue") {
+            result->setCommand(boost::bind(&Set::decreaseValue, _1));
+          } else if(typeName == "callScene") {
+            int sceneNr = strToInt(getParameter(curNode, "scene"));
+            result->setCommand(boost::bind(&Set::callScene, _1, sceneNr));
+          } else if(typeName == "saveScene") {
+            int sceneNr = strToInt(getParameter(curNode, "scene"));
+            result->setCommand(boost::bind(&Set::callScene, _1, sceneNr));
+          } else if(typeName == "undoScene") {
+            int sceneNr = strToInt(getParameter(curNode, "scene"));
+            result->setCommand(boost::bind(&Set::callScene, _1, sceneNr));
+          } else {
+            Logger::getInstance()->log(std::string("unknown command: ") + typeName);
+            delete result;
+            return NULL;
           }
+
         }
       }
       curNode = curNode->nextSibling();
@@ -239,15 +245,6 @@ namespace dss {
   void EventInterpreterPluginDS485::handleEvent(Event& _event, const EventSubscription& _subscription) {
     const SubscriptionOptionsDS485* options = dynamic_cast<const SubscriptionOptionsDS485*>(&_subscription.getOptions());
     if(options != NULL) {
-//      DS485Command cmd = options->getCommand();
-
-
-      // determine location
-      // if a location is given
-      //   evaluate relative to context
-      // else
-      //   send to context's parent-entity (zone)
-
       SetBuilder builder(m_Apartment);
       Set to;
       if(_event.hasPropertySet(EventPropertyLocation)) {
@@ -259,7 +256,7 @@ namespace dss {
           to = _event.getRaisedAtZone().getDevices();
         }
       }
-      // TODO: add functionality
+      options->execute(to);
     } else {
       Logger::getInstance()->log("EventInterpreterPluginDS485::handleEvent: Options are not of type SubscriptionOptionsDS485, ignoring", lsError);
     }
diff --git a/tests/eventtests.cpp b/tests/eventtests.cpp
index bb5a63f..24901b2 100644
--- a/tests/eventtests.cpp
+++ b/tests/eventtests.cpp
@@ -36,6 +36,7 @@
 #include "core/model/group.h"
 #include "core/model/set.h"
 #include "core/ds485/ds485proxy.h"
+#include "core/ds485/ds485busrequestdispatcher.h"
 
 using namespace dss;
 
@@ -220,11 +221,16 @@ BOOST_AUTO_TEST_CASE(testDS485Events) {
   queue.setEventRunner(&runner);
   runner.setEventQueue(&queue);
 
-  Apartment apt(NULL);
   ModelMaintenance maintenance(NULL);
+  Apartment apt(NULL);
+  maintenance.setApartment(&apt);
   DSDSMeterSim modSim(NULL);
   DS485Proxy proxy(NULL, &maintenance);
   apt.setDS485Interface(&proxy);
+  DS485BusRequestDispatcher dispatcher;
+  dispatcher.setFrameSender(&proxy);
+  apt.setBusRequestDispatcher(&dispatcher);
+
 
   proxy.initialize();
 


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list