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

git version control dss-commits at forum.digitalstrom.org
Tue Dec 15 16:27:25 CET 2009


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  dd649f1d4972da3d49d7add8b3ab3147bb8c74eb (commit)
       via  f10dcf08aea7db7f6047676304b63b1d15b53888 (commit)
      from  933257e1afe3035f9744499c7127b77a56febcd2 (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 dd649f1d4972da3d49d7add8b3ab3147bb8c74eb
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Tue Dec 15 16:24:12 2009 +0100

    Allow finer grained control over events props
    
    The @raise_event@ plugin will now override all properties of an event
    that have a suffix of @_override at . And it will predefine properties that
    end with @_default@ (which means that they may be overriden by the event
    being processed.
    
    Closes #239, #240

commit f10dcf08aea7db7f6047676304b63b1d15b53888
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Tue Dec 15 15:38:56 2009 +0100

    Generate events on button press
    
    Note that this code is untestet as I don't know how to generate such
    packages.
    
    Closes #183

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

Changes:
diff --git a/core/ds485const.h b/core/ds485const.h
index c7f2ae6..2733fd4 100644
--- a/core/ds485const.h
+++ b/core/ds485const.h
@@ -122,6 +122,8 @@ namespace dss {
   const uint8_t EventNewDS485Device = 0x80;
   const uint8_t EventLostDS485Device = 0x81;
   const uint8_t EventDeviceReady = 0x82;
+  const uint8_t EventDeviceReceivedTelegramShort = 0x83;
+  const uint8_t EventDeviceReceivedTelegramLong = 0x84;
   const uint8_t EventDSLinkInterrupt = 0x85;
 
   // Scene constants for devices
diff --git a/core/event.h b/core/event.h
index 7085549..b34308b 100644
--- a/core/event.h
+++ b/core/event.h
@@ -113,6 +113,8 @@ namespace dss {
     bool hasParameter(const string& _name) const;
 
     void loadParameterFromXML(XMLNode& _node);
+
+    const Properties& getParameters() const { return m_Parameters; }
   }; // SubscriptionOptions
 
 
diff --git a/core/eventinterpreterplugins.cpp b/core/eventinterpreterplugins.cpp
index 7f49e96..53801d5 100644
--- a/core/eventinterpreterplugins.cpp
+++ b/core/eventinterpreterplugins.cpp
@@ -27,6 +27,7 @@
 #include "setbuilder.h"
 #include "dss.h"
 #include "scripting/modeljs.h"
+#include "core/foreach.h"
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/filesystem.hpp>
@@ -52,6 +53,7 @@ namespace dss {
         newEvent->setTime(timeParam);
       }
     }
+    applyOptionsWithSuffix(_subscription.getOptions(), "_default", newEvent);
     if(_subscription.getOptions().hasParameter(EventPropertyLocation)) {
       string location = _subscription.getOptions().getParameter(EventPropertyLocation);
       if(!location.empty()) {
@@ -59,10 +61,22 @@ namespace dss {
         newEvent->setLocation(location);
       }
     }
+    applyOptionsWithSuffix(_subscription.getOptions(), "_override", newEvent);
     newEvent->setProperties(_event.getProperties());
     getEventInterpreter().getQueue().pushEvent(newEvent);
   } // handleEvent
 
+  void EventInterpreterPluginRaiseEvent::applyOptionsWithSuffix(const SubscriptionOptions& _options, const std::string& _suffix, boost::shared_ptr<Event> _event) {
+    const HashMapConstStringString sourceMap = _options.getParameters().getContainer();
+    typedef const std::pair<const std::string, string> tItem;
+    foreach(tItem kv, sourceMap) {
+      if(endsWith(kv.first, _suffix)) {
+        std::string propName = kv.first.substr(0, kv.first.length() - _suffix.length());
+        _event->setProperty(propName, kv.second);
+      }
+    }
+  } // applyOptionsWithSuffix
+
 
   //================================================== EventInterpreterPluginJavascript
 
diff --git a/core/eventinterpreterplugins.h b/core/eventinterpreterplugins.h
index 5014956..381d39c 100644
--- a/core/eventinterpreterplugins.h
+++ b/core/eventinterpreterplugins.h
@@ -30,6 +30,8 @@
 
 namespace dss {
   class EventInterpreterPluginRaiseEvent : public EventInterpreterPlugin {
+  private:
+    void applyOptionsWithSuffix(const SubscriptionOptions& _options, const std::string& _suffix, boost::shared_ptr<Event> _event);
   public:
     EventInterpreterPluginRaiseEvent(EventInterpreter* _pInterpreter);
     virtual ~EventInterpreterPluginRaiseEvent();
diff --git a/tests/eventtests.cpp b/tests/eventtests.cpp
index 007ca01..1e3ad8b 100644
--- a/tests/eventtests.cpp
+++ b/tests/eventtests.cpp
@@ -77,6 +77,8 @@ BOOST_AUTO_TEST_CASE(testSubscription) {
 
   boost::shared_ptr<SubscriptionOptions> opts(new SubscriptionOptions());
   opts->setParameter("event_name", "event1");
+  opts->setParameter("test_override", "always testing");
+  opts->setParameter("test2_default", "defaults to that");
   boost::shared_ptr<EventSubscription> subscription(new EventSubscription("my_event", "raise_event", interpreter, opts));
   interpreter.subscribe(subscription);
 
diff --git a/unix/ds485proxy.cpp b/unix/ds485proxy.cpp
index 3eccae2..cdbf73e 100644
--- a/unix/ds485proxy.cpp
+++ b/unix/ds485proxy.cpp
@@ -1286,6 +1286,10 @@ namespace dss {
       return "Event New DS485 Device";
     case EventLostDS485Device:
       return "Event Lost DS485 Device";
+    case EventDeviceReceivedTelegramShort:
+      return "Event Telegram Short";
+    case EventDeviceReceivedTelegramLong:
+      return "Event Telegram Long";
     case EventDeviceReady:
       return "Event Device Ready";    
     }
@@ -1403,6 +1407,38 @@ namespace dss {
               pEvent->addParameter(devID);
               pEvent->addParameter(priority);
               getDSS().getApartment().addModelEvent(pEvent);
+            } else if(functionID == EventDeviceReceivedTelegramShort) {
+              pd.get<uint8_t>(); // function id
+              uint16_t p1 = pd.get<uint16_t>();
+              uint16_t p2 = pd.get<uint16_t>();
+              uint16_t p3 = pd.get<uint16_t>();
+              uint16_t address = p1 & 0x007F;
+              uint16_t buttonNumber = p2 & 0x000F;
+              uint16_t kind = p3 & 0x000F;
+              boost::shared_ptr<Event> buttonEvt(new Event("buttonPressed"));
+              buttonEvt->setProperty("address", intToString(address));
+              buttonEvt->setProperty("buttonNumber", intToString(buttonNumber));
+              buttonEvt->setProperty("kind", intToString(kind));
+              getDSS().getEventQueue().pushEvent(buttonEvt);
+            } else if(functionID == EventDeviceReceivedTelegramLong) {
+              pd.get<uint8_t>(); // function id
+              pd.get<uint16_t>();
+              uint16_t p2 = pd.get<uint16_t>();
+              uint16_t p3 = pd.get<uint16_t>();
+              uint16_t p4 = pd.get<uint16_t>();
+              uint16_t address = ((p3&0x0f00) | (p4&0x00f0) | (p4&0x000f))>>2;
+              uint16_t subqualifier = ((p4 & 0xf000)>>12);
+              uint8_t mainqualifier = (p4&0x0f00)>>8;
+              uint16_t data = ((p2 &0x0f00)<< 4)&0xf000;
+              data |= ((p3&0x00f0) << 4) &0x0f00;
+              data |= ((p3 &0x000f)<<4)&0x00f0;
+              data |= ((p3&0xf000)>> 12) &0x000f;
+              boost::shared_ptr<Event> telEvt(new Event("deviceReceivedTelegram"));
+              telEvt->setProperty("data", intToString(data));
+              telEvt->setProperty("address", intToString(address));
+              telEvt->setProperty("subqualifier", intToString(subqualifier));
+              telEvt->setProperty("mainqualifier", intToString(mainqualifier));
+              getDSS().getEventQueue().pushEvent(telEvt);
             } else if(functionID == EventNewDS485Device) {
               pd.get<uint8_t>(); // functionID
               int modID = pd.get<uint16_t>();


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list