[dss-commits] digitalSTROM Server branch, 0.7.5, updated. 93fb74ed0b6f6253416f85edf1326791ddbc69a8

git version control dss-commits at forum.digitalstrom.org
Mon Jan 18 09:55:28 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, 0.7.5 has been updated
       via  93fb74ed0b6f6253416f85edf1326791ddbc69a8 (commit)
       via  bf890e58080c5ad92d80aed3f5ea89664fb82a56 (commit)
       via  3ce2d7bd737631cdc9d0f5b7c8c393dd18f6bf9b (commit)
       via  37d1aac38665b446f25fb33a4b61619b874a638f (commit)
      from  3d255237c78ed7174c9139dbdf73f0027316e331 (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 93fb74ed0b6f6253416f85edf1326791ddbc69a8
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Sat Jan 16 13:52:43 2010 +0100

    Remove devices from zones too if removed from apt
    (cherry picked from commit ebec34a0cd3521bedf0a4f82e7dd0a761baa09e6)

commit bf890e58080c5ad92d80aed3f5ea89664fb82a56
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Jan 15 08:20:47 2010 +0100

    Fixed sim handler
    (cherry picked from commit 088da73eedfec14a07561bdbfc02431988926cc5)

commit 3ce2d7bd737631cdc9d0f5b7c8c393dd18f6bf9b
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.
    (cherry picked from commit 44e1711076dc0680c5998c83b575e636e8d9966d)

commit 37d1aac38665b446f25fb33a4b61619b874a638f
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.
    (cherry picked from commit a2682735835db92e7f03657741376ec81acf2c5e)

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

Changes:
diff --git a/core/model/apartment.cpp b/core/model/apartment.cpp
index 36094d5..ccc8588 100644
--- a/core/model/apartment.cpp
+++ b/core/model/apartment.cpp
@@ -283,11 +283,17 @@ namespace dss {
     }
   } // removeZone
 
-  void Apartment::removeDevice(dsid_t _device) {
+  void Apartment::removeDevice(dsid_t _device) {    
     for(std::vector<Device*>::iterator ipDevice = m_Devices.begin(), e = m_Devices.end();
         ipDevice != e; ++ipDevice) {
       Device* pDevice = *ipDevice;
       if(pDevice->getDSID() == _device) {
+	int zoneID = pDevice->getZoneID();
+	DeviceReference devRef = DeviceReference(*pDevice, this);
+	if(zoneID != 0) {
+	  getZone(zoneID).removeDevice(devRef);
+	}
+	getZone(0).removeDevice(devRef);
         m_Devices.erase(ipDevice);
         delete pDevice;
         return;
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