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

git version control dss-commits at forum.digitalstrom.org
Thu Dec 17 15:57:14 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  545036fce56f3145329a40d99f478d9831730f67 (commit)
       via  6ae0dcebed905e1ad2c2ab5caa47aaad819ae33f (commit)
       via  93410397954424d58f5e0233ab565da87595d752 (commit)
       via  09855b1d82abca26559878975a365ac34bccbd6c (commit)
       via  c734467b43609f7ac437cda1199d63218c994ac1 (commit)
       via  22aba0545f2ae555f5d1a244c3deb05a21ed55a2 (commit)
      from  210c56ff79850d93fabd1cc5e79a82145ef9bd14 (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 545036fce56f3145329a40d99f478d9831730f67
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 15:56:06 2009 +0100

    Fixed debug/pingDevice
    
    * Wait longer than 1 second for response
    * send the whole device address (oops)

commit 6ae0dcebed905e1ad2c2ab5caa47aaad819ae33f
Merge: 93410397954424d58f5e0233ab565da87595d752 210c56ff79850d93fabd1cc5e79a82145ef9bd14
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 15:45:03 2009 +0100

    Merge branch 'master' of ssh://developer.digitalstrom.org/home/git/sources/dss

commit 93410397954424d58f5e0233ab565da87595d752
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 15:44:41 2009 +0100

    Added some tests for js-class set

commit 09855b1d82abca26559878975a365ac34bccbd6c
Merge: c734467b43609f7ac437cda1199d63218c994ac1 bc15c4a25967ebfe5c4e8ff112c35eee5a5afd10
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 15:40:16 2009 +0100

    Merge branch 'master' of ssh://developer.digitalstrom.org/home/git/sources/dss

commit c734467b43609f7ac437cda1199d63218c994ac1
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 14:20:36 2009 +0100

    Don't abort a dSM scan on certain errors

commit 22aba0545f2ae555f5d1a244c3deb05a21ed55a2
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Dec 17 13:17:31 2009 +0100

    Compacted DS485Proxy::sendCommand(...Zone&..)

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

Changes:
diff --git a/core/model.cpp b/core/model.cpp
index 0bc3a00..796d97d 100644
--- a/core/model.cpp
+++ b/core/model.cpp
@@ -886,7 +886,6 @@ namespace dss {
           getZone(0).addGroup(pGroup);
           pGroup->setIsPresent(true);
           log("scanModulator:     Adding new group to zone 0");
-          return false;
         }
 
         // get last called scene for zone, group
@@ -902,7 +901,6 @@ namespace dss {
           }
         } catch(DS485ApiError& error) {
           log(std::string("scanModulator: Error getting last called scene '") + error.what() + "'", lsError);
-          return false;
         }
       }
     }
diff --git a/core/scripting/modeljs.cpp b/core/scripting/modeljs.cpp
index fc85d6c..0707d13 100644
--- a/core/scripting/modeljs.cpp
+++ b/core/scripting/modeljs.cpp
@@ -248,30 +248,23 @@ namespace dss {
 
     ModelScriptContextExtension* ext = dynamic_cast<ModelScriptContextExtension*>(ctx->getEnvironment().getExtension(ModelScriptcontextExtensionName));
     if((ext != NULL) && (set != NULL) && (argc >= 1)) {
-      bool ok = false;
       Set result;
       try {
         if(JSVAL_IS_INT(argv[0])) {
           result = set->getByZone(JSVAL_TO_INT(argv[0]));
-          ok = true;
         } else {
           JSString* str = JS_ValueToString(cx, argv[0]);
           if(str != NULL) {
             std::string zonename = JS_GetStringBytes(str);
             result = set->getByZone(zonename);
-            ok = true;
           }
         }
       } catch(ItemNotFoundException&) {
-        ok = true; // return an empty set if the zone hasn't been found
+        // return an empty set if the zone hasn't been found
         Logger::getInstance()->log("JS: set_by_zone: Zone not found", lsWarning);
       }
-      if(ok) {
-        JSObject* resultObj = ext->createJSSet(*ctx, result);
-        *rval = OBJECT_TO_JSVAL(resultObj);
-      } else {
-        *rval = JSVAL_NULL;
-      }
+      JSObject* resultObj = ext->createJSSet(*ctx, result);
+      *rval = OBJECT_TO_JSVAL(resultObj);
       return JS_TRUE;
     }
     return JS_FALSE;
diff --git a/core/webserver.cpp b/core/webserver.cpp
index d60a973..870c42c 100644
--- a/core/webserver.cpp
+++ b/core/webserver.cpp
@@ -1630,12 +1630,12 @@ namespace dss {
         frame->getHeader().setDestination(device.getModulatorID());
         frame->setCommand(CommandRequest);
         frame->getPayload().add<uint8_t>(FunctionDeviceGetTransmissionQuality);
-        frame->getPayload().add<uint8_t>(device.getShortAddress());
+        frame->getPayload().add<uint16_t>(device.getShortAddress());
         DS485Interface* intf = &DSS::getInstance()->getDS485Interface();
         DS485Proxy* proxy = dynamic_cast<DS485Proxy*>(intf);
         if(proxy != NULL) {
           boost::shared_ptr<FrameBucketCollector> bucket = proxy->sendFrameAndInstallBucket(*frame, FunctionDeviceGetTransmissionQuality);
-          bucket->waitForFrame(1000);
+          bucket->waitForFrame(2000);
 
           boost::shared_ptr<ReceivedFrame> recFrame = bucket->popFrame();
           if(recFrame == NULL) {
diff --git a/tests/modeljstests.cpp b/tests/modeljstests.cpp
index 1e48cb1..cbd31a3 100644
--- a/tests/modeljstests.cpp
+++ b/tests/modeljstests.cpp
@@ -67,12 +67,16 @@ BOOST_AUTO_TEST_CASE(testSets) {
   dev1.addToGroup(1);
   dev1.setIsPresent(true);
   dev1.setZoneID(1);
+  dev1.setName("dev1");
+  dev1.setFunctionID(1);
   Device& dev2 = apt.allocateDevice(dsid_t(0,2));
   dev2.setShortAddress(2);
   dev2.setModulatorID(1);
   dev2.addToGroup(1);
   dev2.setIsPresent(false);
   dev2.setZoneID(2);
+  dev2.setName("dev2");
+  dev2.setFunctionID(1);
 
   boost::scoped_ptr<ScriptEnvironment> env(new ScriptEnvironment());
   env->initialize();
@@ -110,6 +114,21 @@ BOOST_AUTO_TEST_CASE(testSets) {
   length = ctx->evaluate<int>("getDevices().byPresence(true).length()");
   BOOST_CHECK_EQUAL(1, length);
 
+  length = ctx->evaluate<int>("getDevices().remove(getDevices().byZone(1)).byZone(1).length()");
+  BOOST_CHECK_EQUAL(0, length);
+
+  length = ctx->evaluate<int>("getDevices().remove(getDevices().byZone(1)).byZone(1).length()");
+  BOOST_CHECK_EQUAL(0, length);
+
+  std::string name = ctx->evaluate<std::string>("getDevices().byName('dev1').name");
+  BOOST_CHECK_EQUAL("dev1", name);
+
+  name = ctx->evaluate<std::string>("getDevices().byDSID('2').name");
+  BOOST_CHECK_EQUAL("dev2", name);
+
+  length = ctx->evaluate<int>("getDevices().byFunctionID(1).length()");
+  BOOST_CHECK_EQUAL(2, length);
+
   // invalid types
   length = ctx->evaluate<int>("getDevices().byZone(1.1).length()");
   BOOST_CHECK_EQUAL(0, length);
diff --git a/unix/ds485proxy.cpp b/unix/ds485proxy.cpp
index 4499532..95af480 100644
--- a/unix/ds485proxy.cpp
+++ b/unix/ds485proxy.cpp
@@ -310,71 +310,46 @@ namespace dss {
     frame.getHeader().setType(1);
     frame.setCommand(CommandRequest);
     int toZone = _zone.getID();
+    int param = _param;
+    const int kNoParam = -1;
     if(_cmd == cmdTurnOn) {
       frame.getPayload().add<uint8_t>(FunctionGroupCallScene);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      frame.getPayload().add<uint16_t>(SceneMax);
-      sendFrame(frame);
+      param = SceneMax;
       log("turn on: zone " + intToString(_zone.getID()) + " group: " + intToString(_groupID));
     } else if(_cmd == cmdTurnOff) {
       frame.getPayload().add<uint8_t>(FunctionGroupCallScene);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      frame.getPayload().add<uint16_t>(SceneMin);
-      sendFrame(frame);
+      param = SceneMin;
       log("turn off: zone " + intToString(_zone.getID()) + " group: " + intToString(_groupID));
     } else if(_cmd == cmdCallScene) {
       frame.getPayload().add<uint8_t>(FunctionGroupCallScene);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      frame.getPayload().add<uint16_t>(_param);
-      sendFrame(frame);
       log("call scene: zone " + intToString(_zone.getID()) + " group: " + intToString(_groupID));
     } else if(_cmd == cmdSaveScene) {
       frame.getPayload().add<uint8_t>(FunctionGroupSaveScene);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      frame.getPayload().add<uint16_t>(_param);
-      sendFrame(frame);
     } else if(_cmd == cmdUndoScene) {
       frame.getPayload().add<uint8_t>(FunctionGroupUndoScene);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      frame.getPayload().add<uint16_t>(_param);
-      sendFrame(frame);
     } else if(_cmd == cmdStartDimUp) {
       frame.getPayload().add<uint8_t>(FunctionGroupStartDimInc);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      sendFrame(frame);
     } else if(_cmd == cmdStartDimDown) {
       frame.getPayload().add<uint8_t>(FunctionGroupStartDimDec);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      sendFrame(frame);
     } else if(_cmd == cmdStopDim) {
       frame.getPayload().add<uint8_t>(FunctionGroupEndDim);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      sendFrame(frame);
     } else if(_cmd == cmdIncreaseValue) {
       frame.getPayload().add<uint8_t>(FunctionGroupIncreaseValue);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      sendFrame(frame);
+      param = kNoParam;
     } else if(_cmd == cmdDecreaseValue) {
       frame.getPayload().add<uint8_t>(FunctionGroupDecreaseValue);
-      frame.getPayload().add<uint16_t>(toZone);
-      frame.getPayload().add<uint16_t>(_groupID);
-      sendFrame(frame);
+      param = kNoParam;
     } else if(_cmd == cmdSetValue) {
       frame.getPayload().add<uint8_t>(FunctionGroupSetValue);
-      frame.getPayload().add<devid_t>(toZone);
-      frame.getPayload().add<devid_t>(_groupID);
-      frame.getPayload().add<devid_t>(_param);
-      sendFrame(frame);
+    } else {
+      throw std::invalid_argument("DS485Proxy::sendCommand: Unknown command " + intToString(_cmd));
     }
+    frame.getPayload().add<uint16_t>(toZone);
+    frame.getPayload().add<uint16_t>(_groupID);
+    if(param != kNoParam) {
+      frame.getPayload().add<uint16_t>(param);
+    }
+    sendFrame(frame);
     return result;
   } // sendCommand(zone, group)
 


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list