From f319c94228c16a3a02166ac68c45eae0bd349057 Mon Sep 17 00:00:00 2001 From: "www@jspc55" Date: Wed, 18 Jun 2014 11:47:13 +0200 Subject: [PATCH] minor fixes to adcread, run.pl and testgui, added label with (F)HR of individual banks in the output plots of unpack_hld (testgui plots) --- tools/adcread.pl | 9 ++++++++- tools/preview/unpack_hld.pl | 36 ++++++++++++++++++++++++++++++++---- tools/run.pl | 2 +- tools/testgui.pl | 23 +++++++++-------------- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/tools/adcread.pl b/tools/adcread.pl index ecac69e..d8ad61c 100755 --- a/tools/adcread.pl +++ b/tools/adcread.pl @@ -19,6 +19,9 @@ use HADES::TrbNet; use AccessXmlDb; use CGI ':standard'; require Common; +use FindBin; +use lib "$FindBin::Bin/.."; +use Environment; use FindBin; @@ -73,7 +76,7 @@ trb_init_ports() or die trb_strerror(); my @vals; -minMax(); +minMax(); # throw away stale data, min and max are taken relative to last read $delay /= 1000; @@ -86,6 +89,10 @@ for (my $i = 0; $i < $n; $i++){ my( $min, $max) = minMax(); +if ($min > $max ) { + die "Error, not getting fresh values from converter board connected to FPGA $FPGA!\n"; +} + my $mean = average(\@vals); my $stdev = stdev(\@vals); print "unit = 1 ".$self->{unit}."\n" if $verbose; diff --git a/tools/preview/unpack_hld.pl b/tools/preview/unpack_hld.pl index 8af12d4..c37c48d 100755 --- a/tools/preview/unpack_hld.pl +++ b/tools/preview/unpack_hld.pl @@ -475,7 +475,7 @@ sub analyzeData() { $column = ($d >> 2) & 0x7FF; printf("\t$line, $column x %d\n",$pixels+1) if $opt_frameinfo; $hitcount->{$SensorId}++; - $pixelcount->{$SensorId}->[$column/288]+=$pixels; + $pixelcount->{$SensorId}->[int($column/288)]+=$pixels+1; $matrix->[$line]->[$column]++; if ($pixels > 0) { $matrix->[$line]->[$column+1]++; @@ -522,6 +522,7 @@ sub WriteResults { #No frames? No plot! if(!defined $Statistics->{$id}->{Valid}) {next;} + my @hitrates; if($opt_hitrates) { printf("%s\t%i\t%i\t%i\t%i\t%10i\t%10i\t%10i\t%10i\n", @@ -535,6 +536,18 @@ sub WriteResults { $pixelcount->{$id}->[2]||0, $pixelcount->{$id}->[3]||0 ); + printf ("HR Bank0\tHR Bank1\tHR Bank2\tHR Bank3\n"); + $hitrates[0] = ($pixelcount->{$id}->[0]||0) /(288*576*($Statistics->{$id}->{Valid}||0)); + $hitrates[1] = ($pixelcount->{$id}->[1]||0) /(288*576*($Statistics->{$id}->{Valid}||0)); + $hitrates[2] = ($pixelcount->{$id}->[2]||0) /(288*576*($Statistics->{$id}->{Valid}||0)); + $hitrates[3] = ($pixelcount->{$id}->[3]||0) /(288*576*($Statistics->{$id}->{Valid}||0)); + printf("%e\t%e\t%e\t%e\n", + $hitrates[0], + $hitrates[1], + $hitrates[2], + $hitrates[3] + ); + } if(!defined $fg) { @@ -549,14 +562,30 @@ sub WriteResults { my $s = sprintf("%04x",$id); print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime()); - print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ; + print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n" ; + print $fg "set label 102 \"hit rates: ". + sprintf("A: %.3e B: %.3e C: %.3e D:%.3e", + $hitrates[0], + $hitrates[1], + $hitrates[2], + $hitrates[3] + ) + ."\" at screen 0.4,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n" if($opt_hitrates); print $fg "set output '$opt_picpath/".$system."_$s$num.png';\n"; print $fg "plot '-' matrix with image\n"; } else { my $s = sprintf("%04x",$id); print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime()); - print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ; + print $fg "set label 101 \"".$hitcount->{$id}." States, ".($Statistics->{$id}->{Valid}||0)." good, ".($Statistics->{$id}->{Broken}||0)." broken, ".($Statistics->{$id}->{RealBroken}||0)." invalid\" at screen 0.02,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n" ; + print $fg "set label 102 \"hit rates: ". + sprintf("A: %.3e B: %.3e C: %.3e D:%.3e", + $hitrates[0], + $hitrates[1], + $hitrates[2], + $hitrates[3] + ) + ."\" at screen 0.4,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n" if($opt_hitrates); print $fg "set output '$opt_picpath/".$system."_$s$num.png';\n"; print $fg "replot\n"; @@ -583,4 +612,3 @@ sub WriteResults { #print DumpTree $Statistics; } - diff --git a/tools/run.pl b/tools/run.pl index a6f5dc3..0c9bde8 100755 --- a/tools/run.pl +++ b/tools/run.pl @@ -86,7 +86,7 @@ unless($q->param('startupOnly') eq 'true'){ $dummy.=qx"rm $dumpPath/temp.hld 2>&1"; $dummy.=qx"mv $dumpPath/te1* $dumpPath/temp.hld 2>&1"; $dummy.=qx"rm $picPath/$systemName*.png 2>&1"; # delete old pictures - $dummy.=qx"./preview/unpack_hld.pl -f $dumpPath/temp.hld -p $picPath -s $systemName 2>&1"; + $dummy.=qx"./preview/unpack_hld.pl -r -f $dumpPath/temp.hld -p $picPath -s $systemName 2>&1"; } my $escapedDummy = escapeHTML($dummy); $escapedDummy =~ s/\n/
/g; diff --git a/tools/testgui.pl b/tools/testgui.pl index 0113da9..843583c 100755 --- a/tools/testgui.pl +++ b/tools/testgui.pl @@ -255,17 +255,8 @@ sub print_setupStructure { unless(scalar(@sensors)>0) { die "no sensors attached to chain $chainName\n";} for my $sensor (@sensors) { -# my $sensorId = $systemName.'_'.$sensor->findvalue("./\@id"); -# my $sensorName = $sensor->findvalue("./\@name"); -# my $sensorConfig = $sensor->findvalue("./\@config"); -# my $sensorEnabled = $sensor->findvalue("./\@enabled"); -# my $sensorSerial = $sensor->findvalue("./\@serial"); -# my $sensorPosition = $sensor->findnodes("./position")->shift(); -# my $sensorDescription = $sensor->findvalue("./description"); - -# print h5("Sensor name:$sensorName id:$sensorId"); -# print "

description: $sensorDescription

"; - print_sensorArea($sensor); + + print_sensorArea($controller,$sensor); } } @@ -280,11 +271,15 @@ sub print_setupStructure { #### html output subs ########### sub print_sensorArea { - - my $sensor = $_[0]; + + my $controller = $_[0]; + my $sensor = $_[1]; # this is an xml object that contains the sensor node # from the setup file - my $sensorId = $systemName.'_'.$sensor->findvalue("./\@id"); + + my $controllerAddress = $controller->findvalue("./\@address"); + + my $sensorId = $systemName.'_0x'.$controllerAddress.'_'.$sensor->findvalue("./\@id"); my $sensorName = $sensor->findvalue("./\@name"); my $sensorConfig = $sensor->findvalue("./\@config"); my $sensorEnabled = $sensor->findvalue("./\@enabled"); -- 2.43.0