[dss-commits] r8853 - in dss/trunk: core data/webroot data/webroot/debug
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Tue Oct 20 10:20:48 CEST 2009
Author: pstaehlin
Date: 2009-10-20 10:20:48 +0200 (Tue, 20 Oct 2009)
New Revision: 8853
Added:
dss/trunk/data/webroot/debug/
dss/trunk/data/webroot/debug/resetZone.html
Modified:
dss/trunk/core/ds485const.h
dss/trunk/core/webserver.cpp
Log:
Added debug page to reset zones on the dSM
Modified: dss/trunk/core/ds485const.h
===================================================================
--- dss/trunk/core/ds485const.h 2009-10-19 11:39:23 UTC (rev 8852)
+++ dss/trunk/core/ds485const.h 2009-10-20 08:20:48 UTC (rev 8853)
@@ -74,6 +74,7 @@
const uint8_t FunctionZoneAddDevice = 0x30;
const uint8_t FunctionZoneRemoveDevice = 0x31;
const uint8_t FunctionDeviceAddToGroup = 0x34;
+ const uint8_t FunctionZoneRemoveAllDevicesFromZone = 0x35;
const uint8_t FunctionDeviceCallScene = 0x42;
const uint8_t FunctionDeviceSaveScene = 0x43;
Modified: dss/trunk/core/webserver.cpp
===================================================================
--- dss/trunk/core/webserver.cpp 2009-10-19 11:39:23 UTC (rev 8852)
+++ dss/trunk/core/webserver.cpp 2009-10-20 08:20:48 UTC (rev 8853)
@@ -1588,6 +1588,29 @@
sstream << "{" << ToJSONValue("value") << ":" << ToJSONValue(result) << "}";
return JSONOk(sstream.str());
}
+ } else if(endsWith(_method, "debug/resetZone")) {
+ std::string zoneIDStr = _parameter["zoneID"];
+ int zoneID;
+ try {
+ zoneID = strToInt(zoneIDStr);
+ } catch(std::runtime_error&) {
+ return ResultToJSON(false, "Could not parse Zone ID");
+ }
+ DS485CommandFrame* frame = new DS485CommandFrame();
+ frame->getHeader().setBroadcast(true);
+ frame->getHeader().setDestination(0);
+ frame->setCommand(CommandRequest);
+ frame->getPayload().add<uint8_t>(FunctionZoneRemoveAllDevicesFromZone);
+ frame->getPayload().add<uint8_t>(zoneID);
+ DS485Interface* intf = &DSS::getInstance()->getDS485Interface();
+ DS485Proxy* proxy = dynamic_cast<DS485Proxy*>(intf);
+ if(proxy != NULL) {
+ proxy->sendFrame(*frame);
+ return ResultToJSON(true, "Please restart your dSMs");
+ } else {
+ delete frame;
+ return ResultToJSON(false, "Proxy has a wrong type or is null");
+ }
} else {
_handled = false;
return "";
Added: dss/trunk/data/webroot/debug/resetZone.html
===================================================================
--- dss/trunk/data/webroot/debug/resetZone.html (rev 0)
+++ dss/trunk/data/webroot/debug/resetZone.html 2009-10-20 08:20:48 UTC (rev 8853)
@@ -0,0 +1,71 @@
+<html>
+ <head>
+ <title>digitalStrom - Server</title>
+<script type="text/javascript" language="JavaScript">
+function onModelLoaded() {
+}
+</script>
+ <script src="../js/lib/prototype/prototype.js" language="JavaScript" type="text/javascript"></script>
+ <script src="../js/model.js" language="JavaScript" type="text/javascript"></script>
+ <link rel="stylesheet" type="text/css" href="../main.css"/>
+ <script type="text/javascript" language="JavaScript">
+
+function ApartmentRenderer(into) {
+ var self = this;
+ self.apartment = new Apartment();
+ self.apartment.fetch();
+
+ this.render = function() {
+ var zonelist = "<ul>"
+ self.apartment.zones.each(
+ function(zone) {
+ if(zone.id == 0) {
+ devTotal = zone.devices.length;
+ return;
+ }
+ zonelist += "<li>" + zone.name + ' [<a href="#" onclick="clearZone(\'' + zone.id + '\')">Clear Zone</a>]';
+ }
+ );
+ zonelist += "</ul>";
+ $(into).innerHTML = zonelist;
+ }
+}
+
+function SystemRenderer(into) {
+ var self = this;
+ self.system = new System();
+
+ this.render = function() {
+ $(into).innerHTML = self.system.version();
+ }
+}
+
+var apt = null;
+var sysinfo = null;
+
+
+ function clearZone(_zoneID) {
+ DSS.sendSyncRequest("debug/resetZone", {zoneID: _zoneID});
+ }
+
+ function doOnload() {
+ apt = new ApartmentRenderer("bla");
+ apt.render();
+
+ sysinfo = new SystemRenderer("sysinfo");
+ sysinfo.render();
+ }
+</script>
+ </head>
+ <body onload="doOnload()">
+ <h1>Welcome to the dSS!</h1>
+ <div class="container">
+ <div class="item"><a href="browse/">Browse properties</a></div>
+ <div class="item">Connected devices: <span id="numDevs">(...loading...)</span></div>
+ </div>
+ <div class="container">
+ <div id="bla">(loading...)</div>
+ </div>
+ <div class="container" id="sysinfo">dss</div>
+ </body>
+</html>
More information about the dss-commits
mailing list