[dss-commits] r8819 - dss/trunk/core

dss-commits at forum.digitalstrom.org dss-commits at forum.digitalstrom.org
Mon Oct 5 17:03:28 CEST 2009


Author: pstaehlin
Date: 2009-10-05 17:03:28 +0200 (Mon, 05 Oct 2009)
New Revision: 8819

Modified:
   dss/trunk/core/model.h
   dss/trunk/core/webserver.cpp
Log:
Allow rescanning the apartment/single circuit from JSON
The corresponding calls are:
* apartment/rescan
* circuit/rescan?id=dsid

References #73

Modified: dss/trunk/core/model.h
===================================================================
--- dss/trunk/core/model.h	2009-10-05 14:49:44 UTC (rev 8818)
+++ dss/trunk/core/model.h	2009-10-05 15:03:28 UTC (rev 8819)
@@ -780,8 +780,6 @@
     void addDefaultGroupsToZone(Zone& _zone);
     /** Starts the event-processing */
     virtual void execute();
-    void initializeFromBus();
-    bool scanModulator(Modulator& _modulator);
     void handleModelEvents();
     void newModulator(int _modulatorBusID);
     void lostModulator(int _modulatorBusID);
@@ -849,6 +847,9 @@
 
     /** Returns wheter the apartment is still initializing or already running. */
     bool isInitializing() const { return m_IsInitializing; }
+
+    void initializeFromBus();
+    bool scanModulator(Modulator& _modulator);
   public:
 
     /** Returns the root-node for the apartment tree */

Modified: dss/trunk/core/webserver.cpp
===================================================================
--- dss/trunk/core/webserver.cpp	2009-10-05 14:49:44 UTC (rev 8818)
+++ dss/trunk/core/webserver.cpp	2009-10-05 15:03:28 UTC (rev 8819)
@@ -178,6 +178,8 @@
       .withDocumentation("Returns a session token");
     clsApartment.addMethod("getCircuits")
       .withDocumentation("Returns a list of the circuits present in the apartment");
+    clsApartment.addMethod("rescan")
+      .withDocumentation("Rescans all circuits of the apartment");
 
     RestfulClass& clsZone = api.addClass("zone")
         .withInstanceParameter("id", "integer", false)
@@ -322,6 +324,8 @@
        .withDocumentation("Returns the consumption of all connected devices in mW");
     clsCircuit.addMethod("getEnergyMeterValue")
        .withDocumentation("Returns the meter-value in Wh");
+    clsCircuit.addMethod("rescan")
+       .withDocumentation("Rescans the circuit");
 
     RestfulClass& clsProp = api.addClass("property")
         .withInstanceParameter("path", "string", true);
@@ -827,6 +831,9 @@
       } else if(endsWith(_method, "/setName")) {
         getDSS().getApartment().setName(_parameter["newName"]);
         result = ResultToJSON(true);
+      } else if(endsWith(_method, "/rescan")) {
+        getDSS().getApartment().initializeFromBus();
+        result = ResultToJSON(true);
       } else {
         _handled = false;
       }
@@ -1096,6 +1103,13 @@
         return JSONOk("{ " + ToJSONValue("consumption") + ": " +  uintToString(modulator.getPowerConsumption()) +"}");
       } else if(endsWith(_method, "/getEnergyMeterValue")) {
         return JSONOk("{ " + ToJSONValue("metervalue") + ": " +  uintToString(modulator.getEnergyMeterValue()) +"}");
+      } else if(endsWith(_method, "/rescan")) {
+        try {
+          getDSS().getApartment().scanModulator(modulator);
+          return ResultToJSON(true);
+        } catch(std::runtime_error& err) {
+          return ResultToJSON(false, err.what());
+        }
       } else {
         _handled = false;
       }



More information about the dss-commits mailing list