Skip to content

Commit

Permalink
started with device configuration web interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed May 17, 2013
1 parent eefb0ea commit 7bdd335
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 6 deletions.
28 changes: 26 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ button#refresh-beer-chart span.ui-icon{
clear:left;
font-size: 16px;
font-weight: normal;
font-style: normal;
font-style: normal;
font-family: '5x8LCDHD44780UA02Regular';
color: #FFFF00;
white-space: pre;
Expand All @@ -226,6 +226,30 @@ button#refresh-beer-chart span.ui-icon{
padding-right: 1px;
}

#maintenance-panel ul.ui-tabs-nav li{
margin: 2px;
width: 180px;
text-align: center;
}

#maintenance-panel ul.ui-tabs-nav li a{
width: inherit;
padding-left: 0;
}

#maintenance-panel ul.ui-tabs-nav li:nth-child(6n) {
clear: left;
}

.console-box{
width: inherit;
height: 200px;
margin: 10px 40px;
border: solid 1px;
padding: 10px;
}


#maintenance-panel #beer-selector{
margin-bottom: 20px;
}
Expand Down Expand Up @@ -469,4 +493,4 @@ button#refresh-beer-chart span.ui-icon{
margin-top: 20px;
margin-bottom: 20px;
width: inherit;
}
}
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,4 @@ $(document).ready(function(){
receiveControlVariables();
checkScriptStatus(); //will call refreshLcd and alternate between the two
});

64 changes: 63 additions & 1 deletion js/maintenance-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,66 @@ $(document).ready(function(){

$(".cv.update-from-arduino").button({ icons: {primary: "ui-icon-refresh" } })
.click(reloadControlVariablesFromArduino);
});

initDeviceConfiguration();
});

function initDeviceConfiguration(){
"use strict";
$(".refresh-device-list").button({icons: {primary: "ui-icon-refresh" } })
.click(refreshDeviceList);
$(".get-device-list").button({icons: {primary: "ui-icon-arrowthickstop-1-s" } })
.click(getDeviceList);
}

function getDeviceList(){
"use strict";
$.post('socketmessage.php', {messageType: "getDeviceList", message: ""}, function(response){
try
{
response = response.replace(/\s/g, ''); //strip all whitespace, including newline.
var deviceList = JSON.parse(response);
$("#device-console span").html(parseDeviceList(deviceList));
}
catch(e)
{
$("#device-console span").html("Cannot parse JSON:" + e);
}
});
}

function refreshDeviceList(){
"use strict";
var parameters = "";
if ($('#read-values').is(":checked")){
parameters += "v:1";
}
if ($('#only-unassigned').is(":checked")){
parameters += "u:1";
}

$.post('socketmessage.php', {messageType: "refreshDeviceList", message: parameters});
}


function parseDeviceList(deviceList){
// temporary test function, just print devices to a string
// "use strict";

var output = "";
//output += JSON.stringify(deviceList);

for (var i = 0; i < deviceList.length; i++) {
var device = deviceList[i];

output += "Device " + i.toString() + ", ";
output += "function " + device.f.toString() + ", ";
output += "type " + device.h.toString() + ", ";
if((typeof device.v !== "undefined") ){
output += "value " + device.v.toString();
}

output += '<br>';
}
return output;
}
18 changes: 17 additions & 1 deletion maintenance-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
?>

<ul>
<button class="script-status"></button>
<li><a href="#settings"><span class="setting-name">Settings</span></a></li>
<li><a href="logs.php"><span>Log files</span></a></li>
<li><a href="previous_beers.php"><span>Previous Beers</span></a></li>
<li><a href="#control-algorithm"><span>Control Algorithm</span></a></li>
<li><a href="#advanced-settings"><span>Advanced Settings</span></a></li>
<li><a href="#reprogram-arduino"><span>Reprogram Arduino</span></a></li>
<li><a href="#device-config"><span>Device Configuration</span></a></li>
<!--kinda dirty to have buttons in the ul, but the ul is styled as a nice header by jQuery UI -->
<button class="script-status"></button>

</ul>
<div id="reprogram-arduino">
<div class="script-warning ui-widget-content ui-corner-all" style="padding:5px;">
Expand Down Expand Up @@ -327,6 +329,20 @@
</div>
</div>

<div id="device-config">
<div class="settings-container ui-widget-content ui-corner-all">
<div class="console-box" id="device-console">
<span>Script output will appear here</span>
</div>

<label for="read-values">Read values</label><input type="checkbox" name="read-values" id="read-values"/>
<label for="only-unassigned">Only unassigned devices</label><input type="checkbox" name="only-unassigned" id="only-unassigned"/>
<button class="refresh-device-list">Refresh device list</button>
<button class="get-device-list">Get device list</button>
</div>
</div>


<?php
function echoFilterSelect($filterName){
echo "<select name=" . $filterName . " class=\"cc " . $filterName . "\">";
Expand Down
2 changes: 0 additions & 2 deletions socketmessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
else {
die('ERROR: Unable to open required file (config.php)');
}
?>
<?php

function startsWith($haystack, $needle)
{
Expand Down

0 comments on commit 7bdd335

Please sign in to comment.