@@ -30,6 +30,7 @@ var dataIntervalMs = 1000;
30
30
var progIntervalMs = 500
31
31
var chartCS ;
32
32
var chartSC ;
33
+ var chartSE ;
33
34
var lastTime ;
34
35
var lastTimeBwDb = new Date ( ( new Date ( ) ) . getTime ( ) - ( xAxisSec * 1000 ) ) ;
35
36
@@ -58,6 +59,7 @@ var imageText = 'Execute camerapp to retrieve an image.';
58
59
var sensorText = 'Execute sensorapp to retrieve sensor data.' ;
59
60
var bwgraphsText = 'Click legend to hide/show data when continuous test is on.' ;
60
61
var cont_disable_msg = 'Continuous testing disabled.'
62
+ var echoText = 'Execute echo to measure response time.' ;
61
63
62
64
window . onbeforeunload = function ( event ) {
63
65
// detect window close to end continuous test if any
@@ -103,6 +105,7 @@ function initBwGraphs() {
103
105
csColAch ) ;
104
106
chartSC = drawBwtestSingleDir ( 'sc' , 'Download (mbps)' , true , scColReq ,
105
107
scColAch ) ;
108
+ chartSE = drawPingGraph ( 'echo-graph' , 'Echo Response (ms)' ) ;
106
109
// setup interval to manage smooth ticking
107
110
lastTime = ( new Date ( ) ) . getTime ( ) - ( ticks * tickMs ) + xLeftTrimMs ;
108
111
manageTickData ( ) ;
@@ -112,6 +115,9 @@ function initBwGraphs() {
112
115
function showOnlyConsoleGraphs ( activeApp ) {
113
116
$ ( '#bwtest-continuous' ) . css ( "display" ,
114
117
( activeApp == "bwtester" ) ? "block" : "none" ) ;
118
+ $ ( '#images' ) . css ( "display" , ( activeApp == "camerapp" ) ? "block" : "none" ) ;
119
+ $ ( '#echo-continuous' ) . css ( "display" ,
120
+ ( activeApp == "echo" ) ? "block" : "none" ) ;
115
121
var isConsole = ( activeApp == "bwtester" || activeApp == "camerapp"
116
122
|| activeApp == "sensorapp" || activeApp == "echo" ) ;
117
123
$ ( '.stdout' ) . css ( "display" , isConsole ? "block" : "none" ) ;
@@ -192,7 +198,7 @@ function drawBwtestSingleDir(dir, yAxisLabel, legend, reqCol, achCol) {
192
198
} ] ,
193
199
tooltip : {
194
200
enabled : true ,
195
- formatter : formatTooltip ,
201
+ formatter : formatBwTooltip ,
196
202
} ,
197
203
legend : {
198
204
y : - 15 ,
@@ -236,7 +242,56 @@ function drawBwtestSingleDir(dir, yAxisLabel, legend, reqCol, achCol) {
236
242
return chart ;
237
243
}
238
244
239
- function formatTooltip ( ) {
245
+ function drawPingGraph ( div_id , yAxisLabel ) {
246
+ var chart = Highcharts . chart ( div_id , {
247
+ chart : {
248
+ type : 'column'
249
+ } ,
250
+ title : {
251
+ text : null
252
+ } ,
253
+ xAxis : {
254
+ type : 'datetime' ,
255
+ } ,
256
+ yAxis : {
257
+ min : 0 ,
258
+ minTickInterval : 1 , // keep 0.1 errors visible
259
+ title : {
260
+ text : yAxisLabel
261
+ }
262
+ } ,
263
+ legend : {
264
+ enabled : false
265
+ } ,
266
+ tooltip : {
267
+ enabled : true ,
268
+ formatter : formatPingTooltip ,
269
+ } ,
270
+ credits : {
271
+ enabled : true ,
272
+ text : 'Download Data' ,
273
+ href : './data/' ,
274
+ } ,
275
+ exporting : {
276
+ enabled : false
277
+ } ,
278
+ plotOptions : {
279
+ column : {
280
+ pointWidth : 8
281
+ }
282
+ } ,
283
+ series : [ {
284
+ name : yAxisLabel ,
285
+ data : loadSetupData ( ) ,
286
+ dataLabels : {
287
+ enabled : false ,
288
+ }
289
+ } ]
290
+ } ) ;
291
+ return chart ;
292
+ }
293
+
294
+ function formatBwTooltip ( ) {
240
295
var tooltip = '<b>' + this . series . name + '</b><br/>'
241
296
+ Highcharts . dateFormat ( '%Y-%m-%d %H:%M:%S' , this . x ) + '<br/>'
242
297
+ Highcharts . numberFormat ( this . y , 2 ) + ' mbps<br/><i>'
@@ -247,6 +302,17 @@ function formatTooltip() {
247
302
return tooltip ;
248
303
}
249
304
305
+ function formatPingTooltip ( ) {
306
+ var tooltip = '<b>' + this . series . name + '</b><br/>'
307
+ + Highcharts . dateFormat ( '%Y-%m-%d %H:%M:%S' , this . x ) + '<br/>'
308
+ + Highcharts . numberFormat ( this . y , 3 ) + ' ms<br/>' + this . point . loss
309
+ + '% packet loss<br/><i>' + this . point . path + '</i>' ;
310
+ if ( this . point . error != null ) {
311
+ tooltip += '<br/><b>' + this . point . error + '</b>' ;
312
+ }
313
+ return tooltip ;
314
+ }
315
+
250
316
function loadSetupData ( ) {
251
317
// points are a function of timeline speed (width & seconds)
252
318
// no data points on setup
@@ -269,6 +335,7 @@ function manageTickData() {
269
335
var newTime = ( new Date ( ) ) . getTime ( ) ;
270
336
refreshTickData ( chartCS , newTime ) ;
271
337
refreshTickData ( chartSC , newTime ) ;
338
+ refreshTickData ( chartSE , newTime ) ;
272
339
} , tickMs ) ;
273
340
}
274
341
@@ -377,11 +444,23 @@ function requestEchoByTime(form_data) {
377
444
// result returned, display it and reset progress
378
445
handleEndCmdDisplay ( d . graph [ i ] . CmdOutput ) ;
379
446
}
380
-
381
- console . info ( 'continuous echo' , 'duration:' ,
447
+ var data = {
448
+ 'responseTime' : d . graph [ i ] . ResponseTime ,
449
+ 'runTime' : d . graph [ i ] . RunTime ,
450
+ 'loss' : d . graph [ i ] . PktLoss ,
451
+ 'path' : d . graph [ i ] . Path ,
452
+ 'error' : d . graph [ i ] . Error ,
453
+ } ;
454
+ if ( data . runTime == 0 ) {
455
+ // for other errors, use execution time
456
+ data . runTime = d . graph [ i ] . ActualDuration ;
457
+ }
458
+ console . info ( JSON . stringify ( data ) ) ;
459
+ console . info ( 'continous echo' , 'duration:' ,
382
460
d . graph [ i ] . ActualDuration , 'ms' ) ;
383
-
384
- // TODO (mwfarb): complete echo graph
461
+ // use the time the test began
462
+ var time = d . graph [ i ] . Inserted - d . graph [ i ] . ActualDuration ;
463
+ updatePingGraph ( chartSE , data , time )
385
464
}
386
465
}
387
466
}
@@ -398,19 +477,23 @@ function refreshTickData(chart, newTime) {
398
477
// manually remove all left side ticks < left side time
399
478
// wait for adding hidden ticks to draw
400
479
var draw = false ;
401
- removeOldPoints ( series0 , lastTime , draw ) ;
402
- removeOldPoints ( series1 , lastTime , draw ) ;
480
+ if ( series0 )
481
+ removeOldPoints ( series0 , lastTime , draw ) ;
482
+ if ( series1 )
483
+ removeOldPoints ( series1 , lastTime , draw ) ;
403
484
// manually add hidden right side ticks, time = now
404
485
// do all drawing here to avoid accordioning redraws
405
486
// do not shift points since we manually remove before this
406
487
draw = true ;
407
- series0 . addPoint ( [ x , y ] , draw , shift ) ;
408
- series1 . addPoint ( [ x , y ] , draw , shift ) ;
488
+ if ( series0 )
489
+ series0 . addPoint ( [ x , y ] , draw , shift ) ;
490
+ if ( series1 )
491
+ series1 . addPoint ( [ x , y ] , draw , shift ) ;
409
492
}
410
493
411
494
function removeOldPoints ( series , lastTime , draw ) {
412
495
for ( var i = 0 ; i < series . data . length ; i ++ ) {
413
- if ( series . data [ i ] . x < lastTime ) {
496
+ if ( series . data [ i ] && series . data [ i ] . x < lastTime ) {
414
497
series . removePoint ( i , draw ) ;
415
498
}
416
499
}
@@ -457,6 +540,36 @@ function updateBwChart(chart, dataDir, time) {
457
540
}
458
541
}
459
542
543
+ function updatePingGraph ( chart , data , time ) {
544
+ // manually add visible right side ticks, time = now
545
+ // wait for adding hidden ticks to draw, for consistancy
546
+ // do not shift points since we manually remove before this
547
+ var draw = false ;
548
+ var shift = false ;
549
+ if ( data . error || data . loss > 0 || data . responseTime <= 0 ) {
550
+ var error = 'An error occured.' ;
551
+ if ( data . loss > 0 ) {
552
+ error = 'Response timeout.' ;
553
+ }
554
+ chart . series [ 0 ] . addPoint ( {
555
+ x : time ,
556
+ y : data . runTime ,
557
+ loss : data . loss ,
558
+ path : data . path ,
559
+ error : data . error ? data . error : error ,
560
+ color : '#f00' ,
561
+ } , draw , shift ) ;
562
+ } else {
563
+ chart . series [ 0 ] . addPoint ( {
564
+ x : time ,
565
+ y : data . responseTime ,
566
+ loss : data . loss ,
567
+ path : data . path ,
568
+ color : '#0f0' ,
569
+ } , draw , shift ) ;
570
+ }
571
+ }
572
+
460
573
function endProgress ( ) {
461
574
clearInterval ( commandProg ) ;
462
575
commandProg = false ;
@@ -524,10 +637,8 @@ function command(continuous) {
524
637
// check for usable data for graphing
525
638
handleContResponse ( resp , continuous , startTime ) ;
526
639
} else if ( activeApp == "echo" ) {
640
+ // check for usable data for graphing
527
641
handleContResponse ( resp , continuous , startTime ) ;
528
-
529
- // TODO (mwfarb): implement continuous echo graph
530
-
531
642
} else {
532
643
handleGeneralResponse ( ) ;
533
644
}
@@ -741,6 +852,7 @@ function setDefaults() {
741
852
$ ( '#stats_text' ) . text ( sensorText ) ;
742
853
$ ( '#bwtest_text' ) . text ( bwText ) ;
743
854
$ ( '#bwgraphs_text' ) . text ( bwgraphsText ) ;
855
+ $ ( '#echo_text' ) . text ( echoText ) ;
744
856
745
857
onchange_radio ( 'cs' , 'size' ) ;
746
858
onchange_radio ( 'sc' , 'size' ) ;
0 commit comments