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

git version control dss-commits at forum.digitalstrom.org
Fri Nov 13 14:58:40 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  6ceaff0933be8623f9754ae4a62680b212daf157 (commit)
       via  9ed89e52672bc484e56faab2ed4786bf228ce5a3 (commit)
       via  f317fa5093a79b683fa6732746ae3fb47d87bdbb (commit)
       via  0caa18d7599c81a1d7afdf9d51ca105014c9531d (commit)
      from  7d06b1a3f51528970ed43f6ca25ee83247a5691c (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 6ceaff0933be8623f9754ae4a62680b212daf157
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Nov 13 14:58:02 2009 +0100

    Log the exception message too

commit 9ed89e52672bc484e56faab2ed4786bf228ce5a3
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Nov 13 14:45:16 2009 +0100

    Fixed a race-condition in DS485Proxy::execute
    
    Fixes #197
    
    FrameBucketBase handled it's registration/de-registration in it's
    constructor/destructor. This was no problem until we've introduced
    a base-class that made FrameBucketBase::addFrame pure virtual.
    
    If a descendant of FrameBucketBase gets destoyed, it will remain
    in the bucket list of the proxy until FrameBucketBases destructor
    got called. During that short period the entry of addFrame in the
    vmt is of that object is null, as the descendant's destructor has
    already been called.
    
    I've taken out the automagic registration and replaced with manual
    registration/de-registration. To ensure that allocated buckets get
    removed from the bucket list I've added a static function that
    can be passed to a boost::shared_ptr.

commit f317fa5093a79b683fa6732746ae3fb47d87bdbb
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Nov 13 14:18:22 2009 +0100

    Updated eclipse project file

commit 0caa18d7599c81a1d7afdf9d51ca105014c9531d
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Nov 13 14:07:42 2009 +0100

    Translated temperature-sensor to javascript

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

Changes:
diff --git a/.cproject b/.cproject
index f3798db..12b784a 100644
--- a/.cproject
+++ b/.cproject
@@ -28,6 +28,7 @@
 <option id="gnu.cpp.compiler.option.preprocessor.preprocess.1231112907" name="Preprocess only (-E)" superClass="gnu.cpp.compiler.option.preprocessor.preprocess"/>
 <option id="gnu.cpp.compiler.option.preprocessor.def.701665023" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
 <listOptionValue builtIn="false" value="XP_UNIX"/>
+<listOptionValue builtIn="false" value="HAVE_STDINT"/>
 <listOptionValue builtIn="false" value="HAVE_LIBICAL_ICAL_H"/>
 <listOptionValue builtIn="false" value="USE_DNS_SD"/>
 <listOptionValue builtIn="false" value="WITH_TESTS"/>
@@ -60,7 +61,9 @@
 <option id="gnu.c.compiler.exe.debug.option.debugging.level.2066773453" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
 <option id="gnu.c.compiler.option.preprocessor.nostdinc.2028946356" name="Do not search system directories (-nostdinc)" superClass="gnu.c.compiler.option.preprocessor.nostdinc"/>
 <option id="gnu.c.compiler.option.preprocessor.preprocess.99927572" name="Preprocess only (-E)" superClass="gnu.c.compiler.option.preprocessor.preprocess"/>
-<option id="gnu.c.compiler.option.preprocessor.def.symbols.971916440" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/>
+<option id="gnu.c.compiler.option.preprocessor.def.symbols.971916440" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="HAVE_STDINT"/>
+</option>
 <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1011559478" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol"/>
 <option id="gnu.c.compiler.option.include.paths.272503253" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
 <option id="gnu.c.compiler.option.optimization.flags.1073155397" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags"/>
diff --git a/.gitignore b/.gitignore
index 093832c..170fc55 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 build/
 doc/json_api.xml
 data/webroot/js/lib/
+Debug/
diff --git a/core/ds485client.cpp b/core/ds485client.cpp
index 46da99e..13c1064 100644
--- a/core/ds485client.cpp
+++ b/core/ds485client.cpp
@@ -104,7 +104,8 @@ namespace dss {
     DS485Proxy* proxy = dynamic_cast<DS485Proxy*>(&DSS::getInstance()->getDS485Interface());
     assert(proxy != NULL);
 
-    boost::shared_ptr<FrameBucketBase> bucket(new FrameBucketCallback(proxy, _functionID, _source, _callback));
+    boost::shared_ptr<FrameBucketBase> bucket(new FrameBucketCallback(proxy, _functionID, _source, _callback), FrameBucketBase::removeFromProxyAndDelete);
+    bucket->addToProxy();
     m_pImpl->buckets.push_back(bucket);
   } // subscribeTo
 
diff --git a/core/sim/dsid_js.cpp b/core/sim/dsid_js.cpp
index 316edd1..309b8fa 100644
--- a/core/sim/dsid_js.cpp
+++ b/core/sim/dsid_js.cpp
@@ -56,7 +56,7 @@ namespace dss {
           }
         }
       } catch(ScriptException& e) {
-        Logger::getInstance()->log("DSIDJS: Could not get 'self' object");
+        Logger::getInstance()->log(std::string("DSIDJS: Could not get 'self' object: ") + e.what());
       }
     }
 
diff --git a/data/config.xml b/data/config.xml
index 9aa0323..005c99f 100644
--- a/data/config.xml
+++ b/data/config.xml
@@ -13,6 +13,14 @@
           <value>example.js-device</value>
         </property>
       </property>
+      <property name="temperature_sensor">
+        <property name="script-file" type="string">
+          <value>data/temperature_sensor.js</value>
+        </property>
+        <property name="id" type="string">
+          <value>example.temperature_sensor</value>
+        </property>
+     </property>
     </property>
 
 <!--
diff --git a/data/temperature_sensor.js b/data/temperature_sensor.js
new file mode 100644
index 0000000..60e96d6
--- /dev/null
+++ b/data/temperature_sensor.js
@@ -0,0 +1,122 @@
+var dev = {
+  initialize: function(dsid, shortaddress, zoneid) {
+    print('initializing js device (temperature_sensor.js) ', dsid, ' ', shortaddress, ' ', zoneid);
+    var self = this;
+    self.dsid = dsid;
+    self.temperature = 20;
+    self.linkState = 'none';
+    var tempPropName = '/sim/'+dsid+'/temperature';
+    setProperty(tempPropName, self.temperature);
+    setListener(tempPropName, function() {
+                        var oldTemp= self.temperature;
+                        self.temperature = getProperty(tempPropName);
+                        if(oldTemp != self.temperature) {
+                            dSLinkInterrupt(self.dsid);
+                          }
+                        }
+    );
+  },
+
+  log: function(str) {
+    print('temp_sensor: ', str);
+  },
+
+  dSLinkSend: function(value, flags) {
+    this.log('in dSLinkSend with value ' + value + ' flags ' + flags);
+    if(this.linkState == 'none') {
+      if((value & 0x40) == 0x40) {
+        var eventID = (value & 0x3F);
+//        this.processEvent(eventID);
+        return 0;
+      } else {
+        this.registerAddress = (value & 0x7F);
+        if((value & 0x80) == 0x80) {
+          this.linkState = 'write';
+          this.log('new state: write');
+          return 0;
+        } else {
+          this.linkState = 'read';
+          this.log('new state: read');
+          return 0;
+        }
+      }
+    } else if(this.linkState == 'write') {
+      var result = 0;
+//      this.writeRegister(this.registerAddress, value);
+      this.linkState = 'none';
+      this.log('new state: none');
+      return result;
+    } else if(this.linkState == 'read') {
+//      var result = this.readRegister(this.registerAddress);
+      var result = this.temperature;
+      this.linkState = 'none';
+      this.log('new state: none');
+      return result;
+    }
+  },
+
+  getFunctionID: function() {
+    return 0xbeef;
+  },
+
+  callScene: function(nr) {
+    print('called scene ', nr);
+  },
+
+  saveScene: function(nr) {
+    print('save scene ', nr);
+  },
+
+  undoScene: function(nr) {
+    print('undo scene');
+  },
+
+  increaseValue: function() {
+    print('increase value');
+  },
+
+  decreaseValue: function() {
+    print('decrease value');
+  },
+
+  enable: function() {
+    print('enable');
+  },
+
+  disable: function() {
+    print('disable');
+  },
+
+  getConsumption: function() {
+    print('getConsumption');
+    return 0;
+  },
+
+  startDim: function(direction) {
+    print('startDim ', direction);
+  },
+
+  endDim: function() {
+    print('endDim');
+  },
+
+  setValue: function(value) {
+    print('setValue ', value);
+  },
+
+  getValue: function() {
+    print('getValue');
+    return 0;
+  },
+
+  setConfigParameter: function(name, value) {
+    print('setConfigParameter ', name, '=', value);
+  },
+
+  getConfigParameter: function(name) {
+    print('getConfigParameter ', name);
+  }
+
+  
+};
+dev;
diff --git a/examples/plugins/temperature_sensor/Makefile b/examples/plugins/temperature_sensor/Makefile
deleted file mode 100644
index 277855b..0000000
--- a/examples/plugins/temperature_sensor/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-all:	temperature_sensor.so install
-
-temperature_sensor.so2:	temperature_sensor.o
-	#g++ -lPocoNet -lpthread -shared -Wl,-soname,temperature_sensor.so -o temperature_sensor.so *.o
-	g++ -shared -o temperature_sensor.so *.o
-	
-
-temperature_sensor.so:	temperature_sensor.cpp ../../../core/sim/plugin/pluginbase.cpp ../../../core/sim/plugin/pluginmedia.cpp ../../../core/sim/include/dsid_plugin.h
-	g++ -g3 -O0 -Wall -fPIC -shared temperature_sensor.cpp ../../../core/sim/plugin/pluginbase.cpp ../../../core/sim/plugin/pluginmedia.cpp -o temperature_sensor.so
-
-install:	temperature_sensor.so
-	cp temperature_sensor.so ../../../data/plugins/
diff --git a/examples/plugins/temperature_sensor/Makefile.OSX b/examples/plugins/temperature_sensor/Makefile.OSX
deleted file mode 100644
index e72809f..0000000
--- a/examples/plugins/temperature_sensor/Makefile.OSX
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-all:	temperature_sensor.so install
-
-temperature_sensor.so:	temperature_sensor.o
-	g++ -lPocoNet -dynamiclib -undefined dynamic_lookup -single_module -o temperature_sensor.so *.o
-temperature_sensor.o:	temperature_sensor.cpp ../../../core/sim/plugin/pluginbase.cpp ../../../core/sim/plugin/pluginmedia.cpp
-	g++ -g3 -O0 -Wall -fPIC -c temperature_sensor.cpp ../../../core/sim/plugin/pluginbase.cpp ../../../core/sim/plugin/pluginmedia.cpp
-
-install:	temperature_sensor.so
-	cp temperature_sensor.so ../../../data/plugins/
diff --git a/examples/plugins/temperature_sensor/Makefile.arm9 b/examples/plugins/temperature_sensor/Makefile.arm9
deleted file mode 100644
index 09aea5e..0000000
--- a/examples/plugins/temperature_sensor/Makefile.arm9
+++ /dev/null
@@ -1,14 +0,0 @@
-CXX=/opt/emlix/picocom1/bin/arm-linux-gnueabi-g++
-
-all:	vlc_remote.so 
-
-vlc_remote.so2:	vlc_remote.o
-	#g++ -lPocoNet -lpthread -shared -Wl,-soname,vlc_remote.so -o vlc_remote.so *.o
-	$(CXX) -shared -o vlc_remote.so *.o
-	
-
-vlc_remote.so:	vlc_remote.cpp
-	$(CXX) -g3 -O0 -Wall -fPIC -shared vlc_remote.cpp -I /home/patrick/test/sysroot/include -o vlc_remote.so
-
-install:	vlc_remote.so
-#	cp vlc_remote.so ../../../data/plugins/
diff --git a/examples/plugins/temperature_sensor/temperature_sensor.cpp b/examples/plugins/temperature_sensor/temperature_sensor.cpp
deleted file mode 100644
index f040931..0000000
--- a/examples/plugins/temperature_sensor/temperature_sensor.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <stdlib.h>
-
-#include <iostream>
-#include <map>
-
-#include <pthread.h>
-
-#include <Poco/Net/StreamSocket.h>
-#include <Poco/Net/SocketStream.h>
-#include <Poco/Net/SocketAddress.h>
-#include <Poco/StreamCopier.h>
-#include <Poco/Exception.h>
-
-#include "../../../core/sim/include/dsid_plugin.h"
-#include "../../../core/ds485const.h"
-#include "../../../core/base.h"
-#include "../../../core/sim/plugin/pluginbase.h"
-
-
-class DSIDTemperatureSensor : public DSID {
-private:
-  int m_RemotePort;
-  std::string m_RemoteHost;
-public:
-    DSIDTemperatureSensor() {
-    }
-
-    virtual ~DSIDTemperatureSensor() {}
-
-    virtual void callScene(const int _sceneNr) {}
-    virtual void saveScene(const int _sceneNr) {}
-    virtual void undoScene(const int _sceneNr) {}
-
-    virtual void increaseValue(const int _parameterNr = -1) {}
-    virtual void decreaseValue(const int _parameterNr = -1) {}
-
-    virtual void enable() {}
-    virtual void disable() {}
-
-    virtual void startDim(bool _directionUp, const int _parameterNr = -1) {}
-    virtual void endDim(const int _parameterNr = -1) {}
-    virtual void setValue(const double _value, int _parameterNr = -1) {}
-
-    virtual double getValue(int _parameterNr = -1) const { return 0.0; }
-
-    virtual void setConfigurationParameter(const std::string& _name, const std::string& _value) {
-    }
-
-    virtual unsigned char udiSend(unsigned char _value, bool _lastByte) {
-      return _value;
-    }
-
-    virtual int getFunctionID() {
-      return 0xbeef;
-    }
-};
-
-class TemperatureSensorDSIDFactory : public DSIDFactory {
-protected:
-  TemperatureSensorDSIDFactory()
-  : DSIDFactory("example.temperature_sensor")
-  { }
-
-  virtual ~TemperatureSensorDSIDFactory() {}
-
-  virtual DSID* doCreateDSID() {
-    return new DSIDTemperatureSensor();
-  }
-
-public:
-  static void create() {
-    if(m_Instance == NULL) {
-      m_Instance = new TemperatureSensorDSIDFactory();
-    }
-  }
-
-}; // VLCRemoteDSIDFactory
-
-static void _init(void) __attribute__ ((constructor));
-static void _init(void) {
-  TemperatureSensorDSIDFactory::create();
-} // init
-
diff --git a/unix/ds485proxy.cpp b/unix/ds485proxy.cpp
index b7a06d0..79e6990 100644
--- a/unix/ds485proxy.cpp
+++ b/unix/ds485proxy.cpp
@@ -500,7 +500,8 @@ namespace dss {
 
   boost::shared_ptr<FrameBucketCollector> DS485Proxy::sendFrameAndInstallBucket(DS485CommandFrame& _frame, const int _functionID) {
     int sourceID = _frame.getHeader().isBroadcast() ? -1 :  _frame.getHeader().getDestination();
-    boost::shared_ptr<FrameBucketCollector> result(new FrameBucketCollector(this, _functionID, sourceID));
+    boost::shared_ptr<FrameBucketCollector> result(new FrameBucketCollector(this, _functionID, sourceID), FrameBucketBase::removeFromProxyAndDelete);
+    result->addToProxy();
     sendFrame(_frame);
     return result;
   } // sendFrameAndInstallBucket
@@ -1493,14 +1494,23 @@ namespace dss {
     m_FunctionID(_functionID),
     m_SourceID(_sourceID)
   {
-    Logger::getInstance()->log("Bucket: Registering for fid: " + intToString(_functionID) + " sid: " + intToString(_sourceID));
-    m_pProxy->addFrameBucket(this);
+    assert(m_pProxy != NULL);
   } // ctor
 
-  FrameBucketBase::~FrameBucketBase() {
+  void FrameBucketBase::addToProxy() {
+    Logger::getInstance()->log("Bucket: Registering for fid: " + intToString(m_FunctionID) + " sid: " + intToString(m_SourceID));
+    m_pProxy->addFrameBucket(this);
+  } // addToProxy
+
+  void FrameBucketBase::removeFromProxyAndDelete(FrameBucketBase* _obj) {
+    _obj->removeFromProxy();
+    delete _obj;
+  } // remove_from_proxy_and_delete
+
+  void FrameBucketBase::removeFromProxy() {
     Logger::getInstance()->log("Bucket: Removing for fid: " + intToString(m_FunctionID) + " sid: " + intToString(m_SourceID));
     m_pProxy->removeFrameBucket(this);
-  } // dtor
+  } // removeFromProxy
 
 
   //================================================== FrameBucket
diff --git a/unix/ds485proxy.h b/unix/ds485proxy.h
index 6d15b0d..b7066bd 100644
--- a/unix/ds485proxy.h
+++ b/unix/ds485proxy.h
@@ -84,12 +84,19 @@ namespace dss {
   class FrameBucketBase {
   public:
     FrameBucketBase(DS485Proxy* _proxy, int _functionID, int _sourceID);
-    virtual ~FrameBucketBase();
+    virtual ~FrameBucketBase() {}
 
     int getFunctionID() const { return m_FunctionID; }
     int getSourceID() const { return m_SourceID; }
 
     virtual bool addFrame(boost::shared_ptr<ReceivedFrame> _frame) = 0;
+
+    /** Registers the bucket at m_pProxy */
+    void addToProxy();
+    /** Removes the bucket from m_pProxy */
+    void removeFromProxy();
+    /** Static function to be used from a boost::shared_ptr as a deleter. */
+    static void removeFromProxyAndDelete(FrameBucketBase* _obj);
   private:
     DS485Proxy* m_pProxy;
     int m_FunctionID;


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list