Commit 53913a6e authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

Temperatures monitor page

parent 95466801
...@@ -14,6 +14,9 @@ PR = "r0" ...@@ -14,6 +14,9 @@ PR = "r0"
SRC_URI = "file://controls.html \ SRC_URI = "file://controls.html \
file://controls.js \ file://controls.js \
file://hwmon.html \
file://hwmon.js \
file://hwmon.php \
" "
S = "${WORKDIR}/" S = "${WORKDIR}/"
...@@ -26,6 +29,9 @@ do_install_append() { ...@@ -26,6 +29,9 @@ do_install_append() {
install -d ${D}/www/pages install -d ${D}/www/pages
install -m 0644 ${WORKDIR}/controls.html ${D}/www/pages install -m 0644 ${WORKDIR}/controls.html ${D}/www/pages
install -m 0644 ${WORKDIR}/controls.js ${D}/www/pages install -m 0644 ${WORKDIR}/controls.js ${D}/www/pages
install -m 0644 ${WORKDIR}/hwmon.html ${D}/www/pages
install -m 0644 ${WORKDIR}/hwmon.js ${D}/www/pages
install -m 0644 ${WORKDIR}/hwmon.php ${D}/www/pages
} }
PACKAGES = " apps-web" PACKAGES = " apps-web"
......
<html>
<head>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/flot/jquery.flot.min.js"></script>
<script src="hwmon.js"></script>
<style>
input{
width:50px;
text-align:right;
}
</style>
</head>
<body onload='init()'>
<table>
<tr>
<td valign='top'>
<table>
<tr>
<td>T<sub>shutdown</sub> </td>
<td><input type='text' id='t_shutdown' value='0' class='pars'/></td>
<td> &deg;C</td>
</tr>
<tr>
<td>T<sub>fan</sub> </td>
<td><input type='text' id='t_fan_on' value='0' class='pars'/></td>
<td> &deg;C</td>
</tr>
<tr>
<td>&Delta;T<sub>fan hyst</sub> </td>
<td><input type='text' id='t_fan_hyst' value='0' class='pars'/></td>
<td> &deg;C</td>
</tr>
<tr>
<td>t<sub>scan period</sub> </td>
<td><input type='text' id='scan_period' value='1' class='pars'/></td>
<td> s</td>
</tr>
</table>
</td>
<td><div id="t_chart"></div></td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
$(function(){
//init();
});
var interval_read_temperature;
var d0 = Array();
var d1 = Array();
var d2 = Array();
var d3 = Array();
var t = Array();
var level_shutdown;
var level_fan_on;
var level_fan_hyst;
var options = {
lines: { show: true },
points: { show: false },
xaxis: {
tickDecimals: 0,
tickSize: 1
},
yaxis: {
min: 0,
max: 100
},
colors: ['rgba(255,100,100,0.5)','rgba(255,150,20,0.5)','rgba(100,255,100,0.5)','black']
};
function init(){
console.log("hwmon init()");
var tc = $("#t_chart");
tc.css({
width: "800px",
height: "600px",
background:"rgba(100,100,100,0.0)"
});
read_params(init_fields);
}
function init_fields(){
$("#t_shutdown").val(level_shutdown);
$("#t_fan_on").val(level_fan_on);
$("#t_fan_hyst").val(level_fan_hyst);
$("#scan_period").val(scan_period);
$(".pars").change(function(){
update_params();
});
interval_read_temperature = setInterval(read_core_temp,scan_period*1000);
}
function update_params(){
level_shutdown = parseFloat($("#t_shutdown").val());
level_fan_on = parseFloat($("#t_fan_on").val());
level_fan_hyst = parseFloat($("#t_fan_hyst").val());
scan_period = parseFloat($("#scan_period").val());
$.ajax({
url: "hwmon.php?cmd=write&temp_sampling_time="+scan_period+"&temp_major="+level_shutdown+"&temp_minor="+level_fan_on+"&temp_hyst="+level_fan_hyst,
complete: function(){
console.log("parameters updated");
clearInterval(interval_read_temperature);
interval_read_temperature = setInterval(read_core_temp,scan_period*1000);
}
});
}
function read_params(callback){
$.ajax({
url: "hwmon.php?cmd=read",
complete: function(data){
var tmp_str = data.responseText;
tmp_str = tmp_str.trim();
var tmp_arr = tmp_str.split(/\n|: /);
for (var i=0;i<tmp_arr.length;i++){
switch(tmp_arr[i]){
case "temp_sampling_time":
scan_period = parseFloat(tmp_arr[i+1]);
break;
case "temp_major":
level_shutdown = parseFloat(tmp_arr[i+1]);
break;
case "temp_minor":
level_fan_on = parseFloat(tmp_arr[i+1]);
break;
case "temp_hyst":
level_fan_hyst = parseFloat(tmp_arr[i+1]);
break;
default:
break;
}
}
callback();
}
});
}
function read_core_temp(){
$.ajax({
url: "hwmon.php?cmd=t",
complete: function(data){
console.log(data.responseText);
t.push(d1.length);
d0.push(level_shutdown);
d1.push(level_fan_on);
d2.push(level_fan_on-level_fan_hyst);
d3.push(data.responseText);
options.xaxis.tickSize = Math.max(1,Math.round(d1.length)/10);
$.plot($("#t_chart"), [
{label: "Shutdown level", data: get_data(t,d0)},
{label: "Fan-On level", data: get_data(t,d1)},
{label: "Fan-Off level", data: get_data(t,d2)},
{label: "CPU", data: get_data(t,d3)},
], options);
}
});
}
function get_data(x,y){
var d = Array();
for (var i=0;i<x.length; i++){
d.push([x[i], y[i]]);
}
return d;
}
\ No newline at end of file
<?php
if (isset($_GET['cmd']))
$cmd = $_GET['cmd'];
else
$cmd = "t";
if ($cmd=="t"){
echo file_get_contents("/tmp/core_temp");
}
if ($cmd=="read"){
echo file_get_contents("/tmp/core_temp_params");
}
if ($cmd=="write"){
$cstr = "";
foreach($_GET as $key => $val){
if(strpos($key,"temp")===0){
$cstr .= "$key:$val\n";
}
}
file_put_contents("/tmp/core_temp_params",$cstr);
echo "$cstr";
}
?>
...@@ -11,6 +11,7 @@ PR = "r0" ...@@ -11,6 +11,7 @@ PR = "r0"
SRC_URI = "http://mirror.elphel.com/elphel393_mirror/jquery-2.2.3.min.js;md5sum=33cabfa15c1060aaa3d207c653afb1ee \ SRC_URI = "http://mirror.elphel.com/elphel393_mirror/jquery-2.2.3.min.js;md5sum=33cabfa15c1060aaa3d207c653afb1ee \
http://mirror.elphel.com/elphel393_mirror/jquery-ui-1.11.4.custom.zip;md5sum=ee19e783272a4fc4a04ff78e92694df2 \ http://mirror.elphel.com/elphel393_mirror/jquery-ui-1.11.4.custom.zip;md5sum=ee19e783272a4fc4a04ff78e92694df2 \
http://mirror.elphel.com/elphel393_mirror/bootstrap-3.3.6-dist.zip;md5sum=229936b042baadfc9f167244575ffe12 \ http://mirror.elphel.com/elphel393_mirror/bootstrap-3.3.6-dist.zip;md5sum=229936b042baadfc9f167244575ffe12 \
http://mirror.elphel.com/elphel393_mirror/flot-0.8.3.zip;md5sum=229936b042baadfc9f167244575ffe12 \
" "
#SRC_URI[md5sum] = "33cabfa15c1060aaa3d207c653afb1ee" #SRC_URI[md5sum] = "33cabfa15c1060aaa3d207c653afb1ee"
...@@ -25,5 +26,6 @@ do_install() { ...@@ -25,5 +26,6 @@ do_install() {
install -m 644 ${WORKDIR}/jquery-2.2.3.min.js ${D}/www/pages/js/ install -m 644 ${WORKDIR}/jquery-2.2.3.min.js ${D}/www/pages/js/
cp -r ${WORKDIR}/jquery-ui-1.11.4.custom ${D}/www/pages/js/jquery-ui/ cp -r ${WORKDIR}/jquery-ui-1.11.4.custom ${D}/www/pages/js/jquery-ui/
cp -r ${WORKDIR}/bootstrap-3.3.6-dist ${D}/www/pages/js/bootstrap/ cp -r ${WORKDIR}/bootstrap-3.3.6-dist ${D}/www/pages/js/bootstrap/
cp -r ${WORKDIR}/flot-0.8.3 ${D}/www/pages/js/flot/
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment