-
Notifications
You must be signed in to change notification settings - Fork 1
/
vm7000.js
38 lines (30 loc) · 1.13 KB
/
vm7000.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var xmlhttp;
xmlhttp = new XMLHttpRequest();
var getvalue = function getvalue(){
xmlhttp.open("GET","/getvalue",true);
// xmlhttp.timeout = 500;
// xmlhttp.ontimeour = function(){xmlhttp.abort();};
xmlhttp.responseType = "arraybuffer";
xmlhttp.send();
};
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status==200){
var v = new DataView(xmlhttp.response);
var t = document.getElementById("VM1");
for (var i =0;i<6;i++){
var b = v.getUint16(i*2+9);
if(b<32767){
t.rows[i].cells[1].innerHTML = (b/100).toFixed(2);
}else{
t.rows[i].cells[1].innerHTML = ((b-65536)/100).toFixed(2);
}
/*
t.rows[0].cells[1].innerHTML = (v.getUint16(9,false)/100).toFixed(2);
t.rows[1].cells[1].innerHTML = (v.getUint16(11,false)/100).toFixed(2);
t.rows[2].cells[1].innerHTML = (v.getUint16(13,false)/100).toFixed(2);
t.rows[3].cells[1].innerHTML = (v.getUint16(15,false)/100).toFixed(2);
t.rows[4].cells[1].innerHTML = (v.getUint16(17,false)/100).toFixed(2);
t.rows[5].cells[1].innerHTML = (v.getUint16(19,false)/100).toFixed(2);
*/
}}}
setInterval(getvalue,1000);