3 var W = window.innerWidth;
4 var H = window.innerHeight;
6 document.getElementById(
"canvas").width = 1;
7 document.getElementById(
"canvas").height = 1;
9 var tw = document.getElementById(
'table').offsetWidth;
10 var th = document.getElementById(
'table').offsetHeight;
12 var margin = (W-tw)*2;
15 var ch = H - th - margin;
17 document.getElementById(
"canvas").width = cw;
18 document.getElementById(
"canvas").height = ch;
21 document.getElementById(
'debug').innerHTML =
"";
22 document.getElementById(
'debug').innerHTML +=
"|W="+W+
"/"+H;
23 document.getElementById(
'debug').innerHTML +=
"|T="+tw+
"/"+th;
24 document.getElementById(
'debug').innerHTML +=
"|C="+cw+
"/"+ch;
42 try { xmlHttp =
new XMLHttpRequest(); }
45 try { xmlHttp =
new ActiveXObject(
"Microsoft.XMLHTTP"); }
48 try { xmlHttp =
new ActiveXObject(
"Msxml2.XMLHTTP"); }
51 alert(
"Your browser doesn't support dynamic reload.");
57 xmlHttp.open(
'POST',
'status.txt',
true);
59 xmlHttp.onreadystatechange =
62 if (xmlHttp.readyState == 4)
64 if (xmlHttp.status==0)
66 setTimeout(
"refresh_text()", 3000);
69 if (xmlHttp.status!=200)
71 alert(
"HTTP request error: "+xmlHttp.statusText+
" ["+xmlHttp.status+
"]");
72 setTimeout(
"refresh_text()", 10000);
78 setTimeout(
"refresh_text()", 3000);
98 var e = document.getElementById(
id);
103 e.style.textDecoration=
"line-through";
105 e.style.textDecoration=
"";
110 var e = document.getElementById(
id);
116 e.style.color=
"#000";
117 e.style.textDecoration=
"";
121 e.style.color=
"#daa";
122 e.style.textDecoration=
"line-through";
141 var tokens = result.split(
'\n');
143 var date1 =
new Date();
145 if (tokens[0].length!=13)
148 strike(
"time",
date0.getTime()+60000>date1.getTime());
153 var date2 =
new Date();
154 date2.setTime(tokens[0]);
156 strike(
"time", date2.getTime()+60000>date1.getTime());
160 gray(
"drive", tokens[drive]);
161 gray(
"temp", tokens[temp]);
162 gray(
"volt", tokens[voltmed]);
163 gray(
"current", tokens[curmed]);
165 document.getElementById(
"time").innerHTML =
166 "· "+date0.toUTCString()+
" ·";
168 document.getElementById(
"system").innerHTML =
171 if (
valid(tokens[drive])) document.getElementById(
"drive").innerHTML =
172 tokens[drive]+
" ["+tokens[zd]+
" "+tokens[az]+
"]";
174 if (
valid(tokens[temp]))
176 document.getElementById(
"temp").innerHTML =
177 tokens[
temp]+
"°C ["+tokens[dew]+
"°C]";
178 document.getElementById(
"aux").innerHTML =
179 tokens[gusts]+
" km/h";
181 document.getElementById(
"temp_row").style.background=
"#fff8f0";
182 if (parseFloat(tokens[temp])-parseFloat(tokens[dew])>0.3)
183 document.getElementById(
"temp_row").style.background=
"#fffff0";
184 if (parseFloat(tokens[temp])-parseFloat(tokens[dew])>0.7)
185 document.getElementById(
"temp_row").style.background=
"#f0fff0";
187 document.getElementById(
"aux_row").style.background=
"#fff8f0";
188 if (parseFloat(tokens[gusts])<50)
189 document.getElementById(
"aux_row").style.background=
"#fffff0";
190 if (parseFloat(tokens[gusts])<35)
191 document.getElementById(
"aux_row").style.background=
"#f0fff0";
195 document.getElementById(
"temp_row").style.background=
"#ffffff";
196 document.getElementById(
"aux_row").style.background=
"#ffffff";
200 if (
valid(tokens[voltmed]))
202 document.getElementById(
"bias").innerHTML =
203 tokens[curmed]+
"µA / "+tokens[curmax]+
"µA"+
204 " ["+tokens[voltmed]+
"V]";
206 if (parseFloat(tokens[voltmed])>1)
207 document.getElementById(
"bias_row").style.background=
"#f0f0f0";
209 document.getElementById(
"bias_row").style.background=
"#fff0f0";
213 document.getElementById(
"bias_row").style.background=
"#ffffff";
216 document.getElementById(
"localtime").innerHTML =
"· "+date1.toLocaleString()+
" ·";
279 try { xmlHttp =
new XMLHttpRequest(); }
282 try { xmlHttp =
new ActiveXObject(
"Microsoft.XMLHTTP"); }
285 try { xmlHttp =
new ActiveXObject(
"Msxml2.XMLHTTP"); }
288 alert(
"Your browser doesn't support dynamic reload.");
294 xmlHttp.open(
'POST',
'fadcontrol-eventdata.bin',
true);
299 if (xmlHttp.readyState == 4)
301 if (xmlHttp.status!=200)
303 alert(
"HTTP request error: "+xmlHttp.statusText+
" ["+xmlHttp.status+
"]");
304 setTimeout(
"refresh_text()", 10000);
310 setTimeout(
"refresh_graphics()", 5000)
323 if (hue<1)
return parseInt(255*hue);
324 if (hue<3)
return parseInt(255);
325 if (hue<4)
return parseInt(255*(4-hue));
343 return s.length==2 ? s :
"0"+s;
369 var ch =
str[idx].toString(16);
370 return ch.length==2 ? ch :
"0"+ch;
375 var canv = document.getElementById(
"canvas");
378 var ch = canv.height;
380 var w = Math.min(cw/28, ch/28);
382 var ctx = canv.getContext(
"2d");
385 ctx.arc(x*w*2+cw/2, y*w*2+ch/2, w, 0, Math.PI*2,
true);
387 ctx.fillStyle =
"#"+
color(col);
394 if (result.length!=160)
397 var canv = document.getElementById(
"canvas");
400 var ch = canv.height;
402 var ctx = canv.getContext(
"2d");
404 ctx.clearRect(0, 0, cw, ch);
417 drawPix(0, 0, result.charCodeAt(0));
419 var gsSin60 = Math.sqrt(3)/2;
422 for (
var ring=1; ring<=30; ring++)
424 for (
var s=0; s<6; s++)
426 for (
var i=1;
i<=ring;
i++)
433 case 0: x = ring-
i*0.5; y =
i*gsSin60;
break;
434 case 1: x = ring*0.5-
i; y = ring*gsSin60;
break;
435 case 2: x = -(ring+
i)*0.5; y = (ring-
i)*gsSin60;
break;
436 case 3: x = 0.5*
i-ring; y = -
i*gsSin60;
break;
437 case 4: x =
i-ring*0.5; y = -ring*gsSin60;
break;
438 case 5: x = (ring+
i)*0.5; y = (-ring+
i)*gsSin60;
break;
441 if (Math.sqrt(x*x+y*y)>6.7)
443 if (ring==7 &&
i==6 && s==0)
445 if (ring==7 &&
i==1 && s==1)
447 if (ring==7 &&
i==6 && s==3)
449 if (ring==7 &&
i==1 && s==4)
453 var px = Math.sin(Math.PI/3)*x - Math.cos(Math.PI/3)*y;
454 var py = Math.cos(Math.PI/3)*x + Math.sin(Math.PI/3)*y;
456 drawPix(px, py, result.charCodeAt(cnt));
469 ctx.font =
"8pt Arial";
470 ctx.textAlign =
"right";
471 ctx.textBaseline =
"top";
473 ctx.strokeStyle =
"#"+
color(0);
474 ctx.strokeText(
"-2.0V", cw-5, 135);
476 ctx.strokeStyle =
"#"+
color(16);
477 ctx.strokeText(
"-1.5V", cw-5, 120);
479 ctx.strokeStyle =
"#"+
color(32);
480 ctx.strokeText(
"-1.0V", cw-5, 105);
482 ctx.strokeStyle =
"#"+
color(48);
483 ctx.strokeText(
"-0.5V", cw-5, 90);
485 ctx.strokeStyle =
"#"+
color(64);
486 ctx.strokeText(
"0V", cw-5, 70);
488 ctx.strokeStyle =
"#"+
color(80);
489 ctx.strokeText(
"0.5V", cw-5, 50);
491 ctx.strokeStyle =
"#"+
color(86);
492 ctx.strokeText(
"1.0V", cw-5, 35);
494 ctx.strokeStyle =
"#"+
color(102);
495 ctx.strokeText(
"1.5V", cw-5, 20);
497 ctx.strokeStyle =
"#"+
color(127);
498 ctx.strokeText(
"2.0V", cw-5, 5);
504 var canvas = document.getElementById(
"canvas");
505 var img = canvas.toDataURL(
"image/png");
507 img = img.replace(
"image/png",
"image/octet-stream");
509 document.location.href = img;
function strike(id, status)
po::typed_value< T > * var(T *ptr=0)
function process_eventdata(result)
function drawPix(x, y, col)
function process_status(result)
function refresh_graphics()