From fed3c0a44b9f49c9eada2edbf1d03d0c3f43980b Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Tue, 10 Dec 2013 15:34:34 +0100 Subject: [PATCH] new scaler display version --- web/htdocs/layout/blue.css | 25 +++++++++++++------- web/htdocs/tools/scaler.pl | 47 ++++++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/web/htdocs/layout/blue.css b/web/htdocs/layout/blue.css index c88b907..14acdfa 100644 --- a/web/htdocs/layout/blue.css +++ b/web/htdocs/layout/blue.css @@ -349,18 +349,27 @@ table.queryresult th div, table.queryresult td div { position:relative; cursor:default; } - +/***************** + * Table for scaler view + *****************/ .scalers td:nth-child(2){ - min-width:160px; -/* font-family:monospace; */ - } - -.scalers td:nth-child(3),.scalers td:nth-child(1){ min-width:100px; - text-align:left; -/* font-family:monospace; */ + text-align:right; } +.scalers td:nth-child(3){ + min-width:100px; + text-align:right; + } +.scalers td:nth-child(4){ + min-width:100px; + text-align:right; + } +table.scalers td:first-child{ + width:85px; + text-align:center; + } + .scalers tr:first-child { border-bottom:1px solid #555; } \ No newline at end of file diff --git a/web/htdocs/tools/scaler.pl b/web/htdocs/tools/scaler.pl index 7614ead..13fcbef 100755 --- a/web/htdocs/tools/scaler.pl +++ b/web/htdocs/tools/scaler.pl @@ -35,31 +35,49 @@ if($ENV{'QUERY_STRING'} =~ /get/) { $rate->[$i] += 0x01000000 if ($rate->[$i] < 0); $rate->[$i] = $rate->[$i] / ($delay/1E6); } -# if(! ref($olddata->{rate}) eq "ARRAY") { -# # push(@{$olddata->{rate}},$rate); -# } + my @dat = $data->{0x3820}->{value}; + my $start = -9; + my $historyexists = exists($olddata->{rate}); + if ($historyexists && scalar @{$olddata->{rate}} < 9) { + $start = -(scalar @{$olddata->{rate}}); + } for(my $i = 0; $i < 4; $i++) { - my $sum = 0; + my $avgsum = 0; $sum = 0; for(my $j=0;$j<4;$j++) { $sum += $rate->[2*$j+8+$i*16]; + $avgsum += $rate->[2*$j+8+$i*16]; + if($historyexists) { + foreach my $k ($start .. -1) { + $avgsum += $olddata->{rate}->[$k]->[2*$j+8+$i*16]||0; + } + } } + $avgsum /= 1-$start; print "

"; - $t = sprintf("
Diamond $i"); - $t .= sprintf("%dSum",$sum); - $t .= sprintf("",$i,$q,time()/5); + $t = sprintf("
Diamond $iAverageCurrentRatio"); + $t .= sprintf("",$i,$q,time()/5); + $t .= sprintf("
Sum%d%d",$avgsum,$sum); for(my $j=0;$j<4;$j++) { - $t .= sprintf("
INP %d%d",$j+4+$i*8,$data->{0x3820}->{value}[2*$j+8+$i*16],$rate->[2*$j+8+$i*16]); - $t .= sprintf("(%.1f%%)",$rate->[2*$j+8+$i*16]/($sum||1E334)*100); + my $avgrate = $rate->[2*$j+8+$i*16]; + if($historyexists) { + foreach my $k ($start .. -1) { + $avgrate += $olddata->{rate}->[$k]->[2*$j+8+$i*16]||0; + } + } + $avgrate /= 1-$start; + $t .= sprintf("
INP %d%d", $j+4+$i*8, $avgrate); + $t .= sprintf("%d",$data->{0x3820}->{value}[2*$j+8+$i*16],$rate->[2*$j+8+$i*16]); + $t .= sprintf("%.1f%%",$rate->[2*$j+8+$i*16]/($sum||1E334)*100); } #$t =~ s/(?<=\d)(?=(?:\d\d\d)+\b)/ /g; print $t; - print "
 
\n"; + print "\n"; } - printf("

Time between last two readings (mod 1.6s) %d ms",$delay/1000.); + printf("


Time between last two readings (mod 1.6s) %d ms",$delay/1000.); printf(". %d entries",scalar @{$olddata->{rate}}); if((scalar @{$olddata->{rate}}) >= 100) { shift(@{$olddata->{rate}}); @@ -89,11 +107,11 @@ elsif($ENV{'QUERY_STRING'} =~ /plot/) { return; } my $cmd = ""; - $cmd .= "set terminal png xeeeeff font sans 6 size 500,180;\n"; + $cmd .= "set terminal png font sans 6 size 700,180;\n"; $cmd .= "set key off;\n"; $cmd .= "unset xtics;\n"; - $cmd .= "set lmargin 5;set rmargin 0.1;set tmargin 0.7; set bmargin 0.7;\n"; -# $cmd .= "set ytics font \"Times, 6\";\n"; + $cmd .= "set ylabel offset 1,0 \\\"kHz\\\";\n"; + $cmd .= "set lmargin 8;set rmargin 0.1;set tmargin 0.7; set bmargin 0.7;\n"; $cmd .= "plot '-' with lines,'-' with lines,'-' with lines, '-' with lines\n"; for(my $j=0; $j<4; $j++) { foreach my $r (@{$data->{rate}}) { @@ -106,7 +124,6 @@ elsif($ENV{'QUERY_STRING'} =~ /plot/) { print @o; return 1; } - ############################### -- 2.43.0