Condense js file and hopefully convert to unix line endings. Move r.abort to stop button so IE9 can stop ajax streaming.

This commit is contained in:
David Kopf 2011-11-05 14:34:04 -04:00
parent 404895ec04
commit 91cf1cc92e
3 changed files with 29 additions and 42 deletions

View file

@ -981,10 +981,10 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c
#endif
#if 1
uint16_t cpp,txp,rxp;
energest_flush();
cpp=((10000UL*energest_type_time(ENERGEST_TYPE_CPU))/RTIMER_ARCH_SECOND)/clock_seconds();
txp=((10000UL*energest_type_time(ENERGEST_TYPE_TRANSMIT))/RTIMER_ARCH_SECOND)/clock_seconds();
rxp=((10000UL*energest_type_time(ENERGEST_TYPE_LISTEN))/RTIMER_ARCH_SECOND)/clock_seconds();
// energest_flush();
cpp=((10000UL*energest_total_time(ENERGEST_TYPE_CPU.current))/RTIMER_ARCH_SECOND)/clock_seconds();
txp=((10000UL*energest_total_time(ENERGEST_TYPE_TRANSMIT.current))/RTIMER_ARCH_SECOND)/clock_seconds();
rxp=((10000UL*energest_total_time(ENERGEST_TYPE_LISTEN.current))/RTIMER_ARCH_SECOND)/clock_seconds();
numprinted += snprintf(buf+numprinted, sizeof(buf)-numprinted,"ener(%u,%u,%u);",cpp,txp,rxp);
#endif
}

View file

@ -1,18 +1,9 @@
<script>function lo(){li();}window.onload=lo;</script>
<script type="text/javascript">
var sts;
function li(){ls();}
function ls() {
var r;try{r=new XMLHttpRequest();}catch(e) {alert("Your browser does not support AJAX!");return false;}
r.open("GET", "/ajaxdata.shtml", true);//r.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
var lx=0;sts=new Date();r.onreadystatechange=function() {
if(r.readyState>0) {var img=document.getElementById("date");img.innerHTML=(new Date()).toTimeString();var lr=r.responseText.substr(lx);lx+=lr.length;eval(lr);}
if (ls.stop) r.abort();
}
r.send(null);
}
function e(el){d=document;if(d.getElementById){return d.getElementById(el);}else if (d.all){return d.all[el];}}
function s(el,n,max,text){e(el).innerHTML = '<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray">&nbsp;</td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray">&nbsp;</td>'+'</table>';}
<script>function lo(){ls();}window.onload=lo;</script>
<script type="text/javascript">var sts=new Date(),r,x,b,j;
function e(el){return document.getElementById(el);}
function ls(){try{r=new XMLHttpRequest();}catch(e){alert("Browswer does not support Ajax");return false;}r.open("GET","/ajaxdata.shtml",true);
x=0;r.onreadystatechange=function(){e('date').innerHTML=(new Date()).toTimeString();if(r.readyState>0){j=r.responseText.substr(x);x+=j.length;eval(j);}};r.send(null);}
function s(el,n,max,text){e(el).innerHTML='<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray">&nbsp;</td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray">&nbsp;</td>'+'</table>';}
function dc(n,d){return n.toFixed(d);}
function t(m){n=dc(m/10,1);s('temp',n,50,'Temperature '+n+' &deg;C');}
function b(m){s('batt',m,5000,'Battery '+dc(m/1000,3)+' volts');}
@ -20,18 +11,14 @@ function ax(m){s('ax',m+2000,4000,'Acceleration (X-axis) '+m+'mg');}
function ay(m){s('ay',m+2000,4000,'Acceleration (Y-axis) '+m+'mg');}
function az(m){s('az',m+2000,4000,'Acceleration (Z-axis) '+m+'mg');}
function rs(m){s('rs',n,100,'RSSI '+n);}
function p(c,l,t,r){
tm=c+1;cp=c*18/tm;lt=t*50.4/tm;lr=r*45.6/tm;n=cp+lt+lr;
function p(c,l,t,r){tm=c+1;cp=c*18/tm;lt=t*50.4/tm;lr=r*45.6/tm;n=cp+lt+lr;
s('p',n,100,'Power consumption '+dc(n,2)+' mW');
s('pc',cp,100,'CPU power '+dc(cp,2)+' mW');
s('pr',lr,100,'Radio RX power '+dc(lr,2)+' mW');
s('pt',lt,100,'Radio TX power '+dc(lt,2)+' mW');
}
function adc(a0,a1,a2,a3,a4,a5,a6,a7){
var el=e('csv'),sv=el.scrollTop;
el.innerHTML+=dc(((new Date()).getTime()-sts.getTime())/1000,1)+','+a0+','+a1+','+a2+','+a3+','+a4+','+a5+','+a6+','+a7+'\r';
if((sv+el.clientHeight+30)<el.scrollHeight)el.scrollTop=sv;else el.scrollTop=sv+42;
}
s('pt',lt,100,'Radio TX power '+dc(lt,2)+' mW');}
function adc(a0,a1,a2,a3,a4,a5,a6,a7){var t=e('csv'),s=t.scrollTop;
t.value+=dc(((new Date()).getTime()-sts.getTime())/1000,1)+','+a0+','+a1+','+a2+','+a3+','+a4+','+a5+','+a6+','+a7+'\r';
if((s+t.clientHeight+30)<t.scrollHeight)t.scrollTop=s;else t.scrollTop=s+42;}
function rime(tx,rx,tl,rl){e('rims').innerHTML='<em>RIMESTATS:</em> Tx= '+tx+' Rx= '+rx+' TxL= '+tl+' RxL= '+rl;}
function ener(cp,tx,rx) {e('ener').innerHTML='<em>ENERGEST :</em> CPU= '+dc(cp/100,2)+'% Tx= '+dc(tx/100,2)+'% Rx= '+dc(rx/100,2)+'%';}
function v(n){e('v').innerHTML='Iterations = '+n;}

View file

@ -1,6 +1,6 @@
%! header
%!: /ajax.js
<input type="button" value="RUN" onclick="ls.stop=false; ls();"><input type="button" value="STOP" onclick="ls.stop=true;"><br><span id="date"></span>
<input type="button" value="RUN" onclick="ls()"><input type="button" value="STOP" onclick="r.abort()"><br><span id="date"></span>
<div id="v"></div>
<pre><span id="rims"></span><div id="ener"></div></pre>
<h2>Sensors</h2>