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

git version control dss-commits at forum.digitalstrom.org
Fri Jan 15 08:51:18 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  088da73eedfec14a07561bdbfc02431988926cc5 (commit)
       via  44e1711076dc0680c5998c83b575e636e8d9966d (commit)
       via  a2682735835db92e7f03657741376ec81acf2c5e (commit)
      from  fe55c9789c580a7d3077c439ac8be2c562844274 (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 088da73eedfec14a07561bdbfc02431988926cc5
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Jan 15 08:20:47 2010 +0100

    Fixed sim handler

commit 44e1711076dc0680c5998c83b575e636e8d9966d
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Jan 14 17:32:51 2010 +0100

    Tread NULL contexts as empty sets not all devices
    
    Additional tests added while tracking down the issue.

commit a2682735835db92e7f03657741376ec81acf2c5e
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Thu Jan 14 17:23:18 2010 +0100

    Work with copies of DeviceReference
    
    Else we're running into big troubles as the next line deletes the object we're referencing.

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

Changes:
diff --git a/core/model/set.cpp b/core/model/set.cpp
index 0dff8bd..63d42ea 100644
--- a/core/model/set.cpp
+++ b/core/model/set.cpp
@@ -412,7 +412,7 @@ namespace dss {
         Set workingCopy = _set;
 
         while(!workingCopy.isEmpty()) {
-          DeviceReference& ref = workingCopy.get(0);
+          DeviceReference ref = workingCopy.get(0);
           workingCopy.removeDevice(ref);
 
           if(OptimizerDebug) {
diff --git a/core/setbuilder.cpp b/core/setbuilder.cpp
index 7f1e228..7998ab1 100644
--- a/core/setbuilder.cpp
+++ b/core/setbuilder.cpp
@@ -229,17 +229,19 @@ namespace dss {
   }
 
   Set SetBuilder::buildSet(const std::string& _setDescription, const Zone* _context) {
-	  Set result;
-	  m_SetDescription = _setDescription;
-	  const Zone* context = _context;
+    Set result;
+    m_SetDescription = _setDescription;
+    const Zone* context = _context;
     unsigned int index = 0;
-	  if((_context == NULL) || beginsWith(_setDescription, ".")) {
-		  context = &m_Apartment.getZone(0);
-		  result = context->getDevices();
-		  index = 0;
-	  } else {
-		  result = _context->getDevices();
-	  }
+    if(beginsWith(_setDescription, ".")) {
+      context = &m_Apartment.getZone(0);
+      result = context->getDevices();
+      index = 1;
+    } else if(_context != NULL) {
+      result = _context->getDevices();
+    } else {
+      context = &m_Apartment.getZone(0);
+    }
     result = parseSet(index, result, *context);
 
     return result;
diff --git a/core/web/handler/simrequesthandler.cpp b/core/web/handler/simrequesthandler.cpp
index 47fe093..d03af80 100644
--- a/core/web/handler/simrequesthandler.cpp
+++ b/core/web/handler/simrequesthandler.cpp
@@ -37,7 +37,7 @@ namespace dss {
   { }
 
   boost::shared_ptr<JSONObject> SimRequestHandler::jsonHandleRequest(const RestfulRequest& _request, Session* _session) {
-    if(_request.getMethod() == "switch") {
+    if(beginsWith(_request.getMethod(), "switch")) {
       if(_request.getMethod() == "switch/pressed") {
         int buttonNr = strToIntDef(_request.getParameter("buttonnr"), -1);
         if(buttonNr == -1) {
diff --git a/tests/modeltests.cpp b/tests/modeltests.cpp
index ec94f23..6c1a7ad 100644
--- a/tests/modeltests.cpp
+++ b/tests/modeltests.cpp
@@ -90,6 +90,31 @@ BOOST_AUTO_TEST_CASE(testSetGetByBusID) {
   BOOST_CHECK_THROW(apt.getDevices().getByBusID(2, mod2), ItemNotFoundException);
 } // testSetGetByBusID
 
+BOOST_AUTO_TEST_CASE(testSetRemoveDevice) {
+  Apartment apt(NULL);
+
+  Device& dev1 = apt.allocateDevice(dsid_t(0,1));
+  dev1.setShortAddress(1);
+  dev1.setName("dev1");
+
+  Device& dev2 = apt.allocateDevice(dsid_t(0,2));
+  dev2.setShortAddress(2);
+  dev2.setName("dev2");
+  
+  Set set;
+  set.addDevice(dev1);
+  set.addDevice(dev2);
+  
+  BOOST_CHECK_EQUAL(set.length(), 2);
+  BOOST_CHECK_EQUAL(set.get(0).getDevice(), dev1);
+  BOOST_CHECK_EQUAL(set.get(1).getDevice(), dev2);
+  
+  set.removeDevice(dev1);
+  
+  BOOST_CHECK_EQUAL(set.length(), 1);
+  BOOST_CHECK_EQUAL(set.get(0).getDevice(), dev2);
+} // testSetRemoveDevice
+
 BOOST_AUTO_TEST_CASE(testApartmentGetDeviceByShortAddress) {
   Apartment apt(NULL);
 
@@ -389,6 +414,21 @@ BOOST_AUTO_TEST_CASE(testSetBuilder) {
 
   builderTest = builder.buildSet("empty().addDevices(1,2,3)", &apt.getZone(0));
   BOOST_CHECK_EQUAL(3, builderTest.length());
+
+  builderTest = builder.buildSet("addDevices(1)", NULL);
+  BOOST_CHECK_EQUAL(1, builderTest.length());
+  BOOST_CHECK_EQUAL(dev1, builderTest.get(0).getDevice());
+
+  builderTest = builder.buildSet("addDevices(1,2)", NULL);
+  BOOST_CHECK_EQUAL(2, builderTest.length());
+  BOOST_CHECK_EQUAL(dev1, builderTest.get(0).getDevice());
+  BOOST_CHECK_EQUAL(dev2, builderTest.get(1).getDevice());
+
+  builderTest = builder.buildSet("addDevices(1,2,3)", NULL);
+  BOOST_CHECK_EQUAL(3, builderTest.length());
+  BOOST_CHECK_EQUAL(dev1, builderTest.get(0).getDevice());
+  BOOST_CHECK_EQUAL(dev2, builderTest.get(1).getDevice());
+  BOOST_CHECK_EQUAL(dev3, builderTest.get(2).getDevice());
 } // testSetBuilder
 
 BOOST_AUTO_TEST_CASE(testRemoval) {
@@ -472,6 +512,14 @@ BOOST_AUTO_TEST_CASE(testCallScenePropagation) {
   dev2.setName("dev2");
   dev2.setShortAddress(2);
   dev2.setDSMeterID(76);
+  DeviceReference devRef2(dev2, &apt);
+  mod.addDevice(devRef2);
+  Device& dev3 = apt.allocateDevice(dsid_t(0,3));
+  dev3.setName("dev3");
+  dev3.setShortAddress(3);
+  dev3.setDSMeterID(76);
+  DeviceReference devRef3(dev3, &apt);
+  mod.addDevice(devRef3);
 
   dev1.callScene(Scene1);
   sleepMS(500);
@@ -480,6 +528,15 @@ BOOST_AUTO_TEST_CASE(testCallScenePropagation) {
   sleepMS(500);
   BOOST_CHECK_EQUAL(Scene2, dev1.getLastCalledScene());
   BOOST_CHECK_EQUAL(Scene2, dev2.getLastCalledScene());
+  
+  Set set;
+  set.addDevice(dev3);
+  set.addDevice(dev2);
+  set.callScene(Scene3);
+  sleepMS(500);
+  BOOST_CHECK_EQUAL(Scene2, dev1.getLastCalledScene());
+  BOOST_CHECK_EQUAL(Scene3, dev2.getLastCalledScene());
+  BOOST_CHECK_EQUAL(Scene3, dev3.getLastCalledScene());  
   busHandler.terminate();
   maintenance.terminate();
   sleepMS(1500);


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list