Added the maintenance 1-Wire display tab

Wed, 23 Jul 2014 21:14:20 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 23 Jul 2014 21:14:20 +0200
changeset 127
f2f45c44942f
parent 126
480bbe88ce0e
child 128
81b9167c1e93

Added the maintenance 1-Wire display tab

www-thermferm/index.php file | annotate | diff | comparison | revisions
www-thermferm/js/main.js file | annotate | diff | comparison | revisions
www-thermferm/js/maintenance_panel.js file | annotate | diff | comparison | revisions
www-thermferm/maintenance_panel.php file | annotate | diff | comparison | revisions
www-thermferm/utilities.php file | annotate | diff | comparison | revisions
--- a/www-thermferm/index.php	Wed Jul 23 17:12:18 2014 +0200
+++ b/www-thermferm/index.php	Wed Jul 23 21:14:20 2014 +0200
@@ -27,6 +27,7 @@
 $my_style = 'ui-redmond';
 
 require_once('liveview.php');
+require_once('maintenance_panel.php');
 
 
 $outstr  = '<!DOCTYPE html>'.PHP_EOL;
@@ -47,28 +48,12 @@
 $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>'.PHP_EOL;
 $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>'.PHP_EOL;
 $outstr .= '  <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>'.PHP_EOL;
-$outstr .= '  <script type="text/javascript">'.PHP_EOL;
-
-$outstr .= '   function addEventListeners() {'.PHP_EOL;
-$outstr .= '     $("#maintenance").mousedown(function () {'.PHP_EOL;
-$outstr .= '       $("#maintenance_window").jqxWindow(\'open\');'.PHP_EOL;
-$outstr .= '     });'.PHP_EOL;
-$outstr .= '   }'.PHP_EOL;
+$outstr .= '  <script type="text/javascript" src="jqwidgets/jqxscrollbar.js"></script>'.PHP_EOL;
+$outstr .= '  <script type="text/javascript" src="jqwidgets/jqxgrid.js"></script>'.PHP_EOL;
+$outstr .= '  <script type="text/javascript" src="jqwidgets/jqxgrid.selection.js"></script>'.PHP_EOL;
+$outstr .= '  <script type="text/javascript" src="jqwidgets/jqxgrid.columnsresize.js"></script>'.PHP_EOL;
+$outstr .= ' </head>'.PHP_EOL;
 
-$outstr .= '   function createMaintenance() {'.PHP_EOL;
-$outstr .= '       $("#maintenance_window").jqxWindow({'.PHP_EOL;
-$outstr .= '         height: 400, width: 800, autoOpen: false, theme: \''.$my_style.'\', '.PHP_EOL;
-$outstr .= '         position: { x:100, y:50 }, '.PHP_EOL;
-$outstr .= '         resizable: false, isModal: true, modalOpacity: 0.5, '.PHP_EOL;
-$outstr .= '         okButton: $("#maintenance_ok"), '.PHP_EOL;
-$outstr .= '         initContent: function () {'.PHP_EOL;
-$outstr .= '           $("#maintenance_ok").jqxButton({ width: 70, height: 25, theme: \''.$my_style.'\' });'.PHP_EOL;
-$outstr .= '         }'.PHP_EOL;
-$outstr .= '       });'.PHP_EOL;
-$outstr .= '       $("#maintenance").jqxButton({ width: 150, height: 25, theme: \''.$my_style.'\'});'.PHP_EOL;
-$outstr .= '   }'.PHP_EOL;
-$outstr .= '  </script>'.PHP_EOL;
-$outstr .= ' </head>'.PHP_EOL;
 $outstr .= ' <body class="default">'.PHP_EOL;
 $outstr .= '  <div id="jqxWidget">'.PHP_EOL;
 $outstr .= '   <div id="header">'.PHP_EOL;
@@ -76,52 +61,10 @@
 $outstr .= '    <input type="button" id="maintenance" value="Maintenance panel" />'.PHP_EOL;
 $outstr .= '   </div> <!-- header -->'.PHP_EOL;
 $outstr .= liveview();
-
-/* The maintenance popup window */
-$outstr .= '   <div id="maintenance_window">'.PHP_EOL;
-$outstr .= '    <div id="maintenance_header">'.PHP_EOL;
-$outstr .= '     Maintenance panel'.PHP_EOL;
-$outstr .= '    </div>'.PHP_EOL;
-$outstr .= '    <div id="maintenance_content">'.PHP_EOL;
-$outstr .= '     <div id="jqxTabs_maint">'.PHP_EOL;
-$outstr .= '      <ul>'.PHP_EOL;
-$outstr .= '       <li style="margin-left: 20px;">General</li>'.PHP_EOL;
-$outstr .= '       <li style="margin-left: 20px;">1-Wire Bus</li>'.PHP_EOL;
-$outstr .= '       <li style="margin-left: 20px;">Profiles</li>'.PHP_EOL;
-$outstr .= '       <li style="margin-left: 20px;">Units</li>'.PHP_EOL;
-$outstr .= '      </ul>'.PHP_EOL;
-$outstr .= '      <div>'.PHP_EOL;
-$outstr .= '       General'.PHP_EOL;
-$outstr .= '      </div>'.PHP_EOL;
-$outstr .= '      <div>'.PHP_EOL;
-$outstr .= '       1-Wire Bus'.PHP_EOL;
-$outstr .= '      </div>'.PHP_EOL;
-$outstr .= '      <div>'.PHP_EOL;
-$outstr .= '       Profiles'.PHP_EOL;
-$outstr .= '      </div>'.PHP_EOL;
-$outstr .= '      <div>'.PHP_EOL;
-$outstr .= '       Units'.PHP_EOL;
-$outstr .= '      </div>'.PHP_EOL;
-$outstr .= '     </div>'.PHP_EOL;
-$outstr .= '     <input type="button" id="maintenance_ok" value="Dismiss" style="margin-top: 5px; margin-left: 365px" />'.PHP_EOL;
-$outstr .= '    </div>'.PHP_EOL;
-$outstr .= '    <script type="text/javascript">'.PHP_EOL;
-$outstr .= '     $(document).ready(function () {'.PHP_EOL;
-$outstr .= '       $("#jqxTabs_maint").jqxTabs({ width: 790, height: 330, position: \'top\', theme: \''.$my_style.'\'});'.PHP_EOL;
-$outstr .= '     });'.PHP_EOL;
-$outstr .= '    </script>'.PHP_EOL;
-$outstr .= '   </div> <!-- maintenance_window -->'.PHP_EOL;
+$outstr .= maintenance_panel();
 
 /* Create the tabs */
-$outstr .= '   <script type="text/javascript">'.PHP_EOL;
-$outstr .= '    $(document).ready(function () {'.PHP_EOL;
-$outstr .= '      // Create jqxTabs.'.PHP_EOL;
-$outstr .= '      $("#jqxTabs").jqxTabs({ width: 978, height: 428, position: \'top\', theme: \''.$my_style.'\'});'.PHP_EOL;
-$outstr .= '      addEventListeners();'.PHP_EOL;
-$outstr .= '      createMaintenance();'.PHP_EOL;
-$outstr .= '    });'.PHP_EOL;
-$outstr .= '   </script>'.PHP_EOL;
-
+$outstr .= '   <script type="text/javascript" src="js/main.js"></script>'.PHP_EOL;
 $outstr .= '  </div> <!-- jqxWidget -->'.PHP_EOL;
 $outstr .= ' </body>'.PHP_EOL;
 $outstr .= '</html>'.PHP_EOL;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www-thermferm/js/main.js	Wed Jul 23 21:14:20 2014 +0200
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (C) 2014
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of ThermFerm
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * ThermFerm is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+
+function addEventListeners() {
+    $("#maintenance").mousedown(function () {
+	$("#maintenance_window").jqxWindow('open');
+    });
+}
+
+function createMaintenance() {
+    $("#maintenance_window").jqxWindow({
+	height: 400, width: 800, autoOpen: false, theme: 'ui-redmond', 
+	position: { x:100, y:50 }, 
+	resizable: false, isModal: true, modalOpacity: 0.5, 
+	okButton: $("#maintenance_ok"), 
+	initContent: function () {
+	    $("#maintenance_ok").jqxButton({ width: 70, height: 25, theme: 'ui-redmond' });
+	}
+    });
+    $("#maintenance").jqxButton({ width: 150, height: 25, theme: 'ui-redmond' });
+}
+
+$(document).ready(function () {
+    // Create jqxTabs.
+    $("#jqxTabs").jqxTabs({ width: 978, height: 428, position: 'top', theme: 'ui-redmond'});
+    addEventListeners();
+    createMaintenance();
+});
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www-thermferm/js/maintenance_panel.js	Wed Jul 23 21:14:20 2014 +0200
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (C) 2014
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of ThermFerm
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * ThermFerm is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+$(document).ready(function () {
+   var source_bus = {
+     	datatype: "json",
+     	datafields: [
+       	    { name: 'Address', type: 'string' },
+       	    { name: 'Refcnt', type: 'int' },
+       	    { name: 'Chip', type: 'string' },
+       	    { name: 'Description', type: 'string' }
+     	],
+     	url: 'getbus.php',
+     	sortcolumn: 'Address',
+     	sortdirection: 'asc'
+    };
+    var dataAdapter_bus = new $.jqx.dataAdapter(source_bus,{
+	downloadComplete: function (data, status, xhr) { },
+        loadComplete: function (data) { },
+        loadError: function (xhr, status, error) { }
+    });
+    $("#jqxgrid_bus").jqxGrid( {
+	width: 770, height: 280,
+	source: dataAdapter_bus,
+	theme: 'ui-redmond',
+	columnsresize: true,
+	columns: [
+	    { text: 'Address', datafield: 'Address', width: 150 },
+	    { text: 'References', datafield: 'Refcnt', width: 100 },
+	    { text: 'Chipset', datafield: 'Chip', width: 120 },
+	    { text: 'Description', datafield: 'Description', minwidth: 120 }
+	]
+    });
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www-thermferm/maintenance_panel.php	Wed Jul 23 21:14:20 2014 +0200
@@ -0,0 +1,74 @@
+<?php
+/*****************************************************************************
+ * Copyright (C) 2014
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of ThermFerm
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * ThermFerm is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+/*
+ * Look for the style names in the jqwidgets/styles directory.
+ */
+$my_style = 'ui-redmond';
+
+
+
+/* The maintenance popup window */
+function maintenance_panel()
+{
+    global $my_style;
+
+    $outstr  = PHP_EOL;
+    $outstr .= '   <div id="maintenance_window">'.PHP_EOL;
+    $outstr .= '    <script type="text/javascript" src="js/maintenance_panel.js"></script>'.PHP_EOL;
+    $outstr .= '    <div id="maintenance_header">'.PHP_EOL;
+    $outstr .= '     Maintenance panel'.PHP_EOL;
+    $outstr .= '    </div>'.PHP_EOL;
+    $outstr .= '    <div id="maintenance_content">'.PHP_EOL;
+    $outstr .= '     <div id="jqxTabs_maint">'.PHP_EOL;
+    $outstr .= '      <ul>'.PHP_EOL;
+    $outstr .= '       <li style="margin-left: 20px;">General</li>'.PHP_EOL;
+    $outstr .= '       <li style="margin-left: 20px;">1-Wire Bus</li>'.PHP_EOL;
+    $outstr .= '       <li style="margin-left: 20px;">Profiles</li>'.PHP_EOL;
+    $outstr .= '       <li style="margin-left: 20px;">Units</li>'.PHP_EOL;
+    $outstr .= '      </ul>'.PHP_EOL;
+    $outstr .= '      <div>'.PHP_EOL;
+    $outstr .= '       General'.PHP_EOL;
+    $outstr .= '      </div>'.PHP_EOL;
+    $outstr .= '      <div>'.PHP_EOL;
+    $outstr .= '       <div id="jqxgrid_bus" style="margin-left: 8px; margin-top: 6px;"></div>'.PHP_EOL;
+    $outstr .= '      </div>'.PHP_EOL;
+    $outstr .= '      <div>'.PHP_EOL;
+    $outstr .= '       Profiles'.PHP_EOL;
+    $outstr .= '      </div>'.PHP_EOL;
+    $outstr .= '      <div>'.PHP_EOL;
+    $outstr .= '       Units'.PHP_EOL;
+    $outstr .= '      </div>'.PHP_EOL;
+    $outstr .= '     </div>'.PHP_EOL;
+    $outstr .= '     <input type="button" id="maintenance_ok" value="Dismiss" style="margin-top: 5px; margin-left: 365px" />'.PHP_EOL;
+    $outstr .= '    </div>'.PHP_EOL;
+    $outstr .= '    <script type="text/javascript">'.PHP_EOL;
+    $outstr .= '     $(document).ready(function () {'.PHP_EOL;
+    $outstr .= '       $("#jqxTabs_maint").jqxTabs({ width: 790, height: 330, position: \'top\', theme: \''.$my_style.'\'});'.PHP_EOL;
+    $outstr .= '     });'.PHP_EOL;
+    $outstr .= '    </script>'.PHP_EOL;
+    $outstr .= '   </div> <!-- maintenance_window -->'.PHP_EOL;
+
+    return $outstr;
+}
+
--- a/www-thermferm/utilities.php	Wed Jul 23 17:12:18 2014 +0200
+++ b/www-thermferm/utilities.php	Wed Jul 23 21:14:20 2014 +0200
@@ -27,6 +27,7 @@
     $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 
     if (!($sock === false)) {
+//	if (socket_connect($sock, "rpi02", 6554)) {    
 	if (socket_connect($sock, "localhost", 6554)) {
 	    socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 15, 'usec' => 0));
 	} else {

mercurial