From f86bcc2530d96d3911ce37d2f2a3b4e21f69571f Mon Sep 17 00:00:00 2001 From: Hades DAQ Date: Mon, 19 Jun 2017 17:17:01 +0200 Subject: [PATCH] changed hadplot to work with gnuplot 5+ --- tools/hadplot | 91 ++++++++++++++++++++++---------------- tools/loadregisterdb.pl | 2 +- web/htdocs/nxyter/index.pl | 3 +- 3 files changed, 56 insertions(+), 40 deletions(-) diff --git a/tools/hadplot b/tools/hadplot index ecc455a..d37a040 100755 --- a/tools/hadplot +++ b/tools/hadplot @@ -18,7 +18,7 @@ use constant NODELAY => 0; use constant NO => 0; use constant YES => 1; use constant NONEWLINE => 1; - +$| = 1; my $GPbuffer = ""; my $buffercount = 0; @@ -140,7 +140,7 @@ for(my $k = 0; $k < scalar @$address; $k++) { for(my $i=0;$i < scalar @{$address};$i++) { if(!defined($title->[$i])) { - $title->[$i] = "$address->[$i] $register->[$i] $regoffset->[$i]..".($regoffset->[$i]+$regwidth->[$i]-1); + $title->[$i] = hex($address->[$i])." $register->[$i] $regoffset->[$i]..".($regoffset->[$i]+$regwidth->[$i]-1); } } @@ -154,12 +154,12 @@ if($style == 5) {$curvestyle="histostacked"; $xticks=1;} #Open Gnuplot our $fh; -my $fn = "tee /dev/stderr | gnuplot -noraise -geometry $geom -bg 'ghost white'"; +my $fn = "gnuplot -noraise -geometry $geom -bg 'ghost white'"; $fh = new FileHandle ("|$fn") or die "error: no gnuplot"; $fh->autoflush(1); sub makeTimeString{ - return strftime("set label 100 \"%H:%M:%S\" at screen 0.92,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n", localtime()) + return strftime("set label 100 \"%H:%M:%S\" at screen 0.85,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n", localtime()) } ################################################# @@ -235,10 +235,14 @@ sub plot_end { my ($single) = @_; for(my $i = 0;$i{y}."\n"; + my $str = $PlotBufArr[$i]->{y}."\n"; + plot_write($str); + #print $str; } else { - print $fh $PlotBufArr[$i]->{x}." ".$PlotBufArr[$i]->{y}."\n"; + my $str = $PlotBufArr[$i]->{x}." ".$PlotBufArr[$i]->{y}."\n"; + plot_write($str); + #print $str; } } # foreach my $line (sort keys %{$PlotBuffer}) { @@ -254,7 +258,8 @@ sub plot_end { @PlotBufArr = (); $PlotBuffer = {}; $PlotBufferCnt = 0; - print $fh "e\n"; + plot_write("e"); + #print "e\n"; $plotendedbefore = 1 unless $plotendedbefore; } @@ -272,8 +277,8 @@ sub plot_reset { } if ($plotendedbefore != 0) { $plotendedbefore = 0; - print $fh makeTimeString(); - print $fh "replot \n"; + plot_write(makeTimeString()); +# print $fh "replot\n"; } } else { @@ -281,8 +286,8 @@ sub plot_reset { system("mv $write2file.tmp $write2file"); plot_write("set out \"$write2file.tmp\"\n"); $plotendedbefore = 0; - print $fh makeTimeString(); - print $fh "replot\n"; + plot_write(makeTimeString()); +# print $fh "replot\n"; # print "reset\n"; } } @@ -492,8 +497,8 @@ sub store_push { # Writes storage contents to stream ################################################# sub store_print { - my $str = ""; my ($storage) = @_; + my $str = ""; if($storage->{"initing"} != 2) { if($storage->{"iteration"} % $storage->{"downscale"} == 0) { my $xcnt = - $storage->{"totalx"} /1000000.0; @@ -508,8 +513,7 @@ sub store_print { #plot_write($xcnt/1000000.0." ".$yval); } plot_write($str,1); -# print $str; - plot_end(1); + plot_end(1);# print $str; } $storage->{"iteration"}++; } @@ -659,14 +663,20 @@ sub bitmap { plot_write("set boxwidth 1 absolute"); plot_write("unset key"); plot_write('set format x "%x"'); - plot_write("plot ",1); + my $plotstr = "plot "; for(my $i = 0; $i[$i]\" ",1); #using 2:xticlabels(1) - plot_write(", ",1) unless $i == scalar(@{$address})-1; + $plotstr .="'-' with points pt 5 ps 1 title \"$title->[$i]\" "; #using 2:xticlabels(1) + $plotstr .=", " unless $i == scalar(@{$address})-1; } plot_write(""); -# } + while(1) { + +# for(my $i = 0; $i[$i]\" ",1); #using 2:xticlabels(1) +# plot_write(", ",1) unless $i == scalar(@{$address})-1; +# } + plot_write($plotstr,0); for(my $i = 0; $i[$i] == 1) { @@ -726,29 +736,35 @@ sub genreg { plot_write("set autoscale xfix "); } - plot_write("plot ",1); + my $plotstr = "plot "; + for(my $i = 0; $i[$i]\" ",NONEWLINE); + $plotstr .= "with histograms lt rgb \"$color[$i]\" title \"$title->[$i]\" "; } - elsif ($curvestyle eq "steps") { - plot_write("with histeps title \"$title->[$i]\" ",NONEWLINE); + elsif ($curvestyle eq "steps") { + $plotstr .= "with histeps title \"$title->[$i]\" "; } else { - plot_write("with points pt 5 title \"$title->[$i]\" ",NONEWLINE); + $plotstr .= "with points pt 5 title \"$title->[$i]\" "; } - plot_write(" ".$curveoption->[$i],NONEWLINE); - plot_write(", ",NONEWLINE) unless $i == scalar(@{$address})-1; - } - plot_write(""); + $plotstr .= " ".$curveoption->[$i]; + $plotstr .= ", " unless $i == scalar(@{$address})-1; + } + +#my $cmd = q|plot '-' with points pt 5 title "+3V input" , '-' with points pt 5 title "-3V reg."|; +# plot_write($cmd,0); while(1) { + plot_write($plotstr,0); for(my $i = 0; $i[$i]) || $regamount->[$i] == 1) { $c = trb_register_read(($address->[$i]),($register->[$i])) or die trb_strerror(); foreach my $s (keys %$c) { @@ -758,7 +774,7 @@ sub genreg { else { $c = trb_register_read_mem(($address->[$i]),($register->[$i]),$fifomode->[$i],$regamount->[$i]) or die trb_strerror(); } - foreach my $s (sort keys $c) { + foreach my $s (sort keys %$c) { for(my $r = 0; $r < scalar @{$c->{$s}};$r++) { my $tmp = ($c->{$s}->[$r]>>$regoffset->[$i])&(2**$regwidth->[$i]-1); my $val = $tmp; @@ -805,24 +821,23 @@ sub genhist { # $xtitle = "Time [s]" unless $xtitle ne ""; plot_init(); plot_write("set autoscale fix"); - plot_write("plot",1); + my $plotstr ="plot "; $diff = 0 unless defined($diff); for(my $i = 0; $i[$i],$yoverflow->[$i]); - plot_write("'-' with lines title \"$title->[$i]\" ",1); - plot_write(", ",1) unless $i == scalar(@{$address})-1; - } - plot_write(""); - + $plotstr .= "'-' with lines title \"$title->[$i]\" "; + $plotstr .= ", " unless $i == scalar(@{$address})-1; + } while(1) { my $a, my $s, my $t; my $val = 0 , my $time; plot_storage_reset($storearr{0}); + plot_write($plotstr); for(my $i = 0; $i[$i], $register->[$i]) or sleep 1 and print "Error\n" and next; - foreach my $o (sort keys $c) { + foreach my $o (sort keys %$c) { $val += ((($c->{$o}->{'value'}->[0]||0)>>($regoffset->[$i]))&(2**($regwidth->[$i])-1)); $time = ($c->{$o}->{'time'}->[0]||0)*16; } diff --git a/tools/loadregisterdb.pl b/tools/loadregisterdb.pl index ba5657b..09f1d8e 100755 --- a/tools/loadregisterdb.pl +++ b/tools/loadregisterdb.pl @@ -37,6 +37,6 @@ while (my $a = ) { } } -# print $cmd; +print $cmd; system($cmd); # print "Done.\n\n"; diff --git a/web/htdocs/nxyter/index.pl b/web/htdocs/nxyter/index.pl index 65c90e2..6ce30a0 100755 --- a/web/htdocs/nxyter/index.pl +++ b/web/htdocs/nxyter/index.pl @@ -26,7 +26,8 @@ my @setup; $setup[0]->{name} = "Status"; -$setup[0]->{cmd} = "Nxyter-0xfe49-NXStatus&Nxyter-0xfe49-ADCStatus"; +#$setup[0]->{cmd} = "Nxyter-0xfe49-NXStatus&Nxyter-0xfe49-ADCStatus"; +$setup[0]->{cmd} = "Nxyter-0xfe49-NXStatus"; $setup[0]->{period} = -1; $setup[0]->{address} = 1; -- 2.43.0