From c81127f2a4356d07849dc56fbcd304bc3ca004ba Mon Sep 17 00:00:00 2001 From: Darryl Quinn Date: Wed, 9 Dec 2015 15:36:09 -0600 Subject: [PATCH] feature: select a device to view archived data against, enabled chart zooming/panning --- files/www/cgi-bin/signal2 | 45 +++++++++++++++++++++++++++++----- files/www/cgi-bin/signal2.json | 16 +++++++++--- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/files/www/cgi-bin/signal2 b/files/www/cgi-bin/signal2 index 5bca7e2b..580545b8 100755 --- a/files/www/cgi-bin/signal2 +++ b/files/www/cgi-bin/signal2 @@ -79,6 +79,7 @@ $header = < MAXPOINTS) { - // dps[0].shift(); - // dps[1].shift(); - //} + \$.getJSON("/cgi-bin/signal2.json?realtime=1&device=$parms{device}", function (result) { dps[0].push(result[0][0]); dps[1].push(result[1][0]); chart.render(); @@ -156,6 +153,42 @@ $page = <

$node


+
+
+ Selected Device: "; +$page = $page . "" if($parms{realtime} eq "1"); + +$page = $page . < +
diff --git a/files/www/cgi-bin/signal2.json b/files/www/cgi-bin/signal2.json index efe1de57..147003ff 100755 --- a/files/www/cgi-bin/signal2.json +++ b/files/www/cgi-bin/signal2.json @@ -42,24 +42,32 @@ use perlfunc; read_query_string(); my $debug = 0; -my $filename="/tmp/snrlog"; +my $dirname="/tmp/snrlog"; my @values; my $counter=0; my $sjson; my $njson; -system("touch $filename") unless (-f $filename); +system("mkdir $dirname") unless (-d $dirname); if($parms{"realtime"}) { # ==== REALTIME DATA ===== ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); - $d = sprintf ("%02d:%02d:%02d", $hour, $min, $sec); - ($s, $n) = get_wifi_signal(get_interface("wifi")); + $d = sprintf ("%02d:%02d:%02d", $hour, $min, $sec); + + #if($parms{device} eq '') { + ($s, $n) = get_wifi_signal(get_interface("wifi")); + #} + $sjson= sprintf("{\"label\":\"%s\",\"y\":%s}",$d,$s); $njson= sprintf("{\"label\":\"%s\",\"y\":%s}",$d,$n); } else { # ==== ARCHIVE DATA ===== # --- Load the snr data into an array + if($parms{device} == '') { $parms{device}="strongest"; } + + $filename=$dirname . "/" . $parms{device}; + open my $fh, '<', $filename or die "Could not open file '$filename' $!"; chomp(my @lines = <$fh>); close $fh;