From: hadaq Date: Tue, 27 Nov 2018 09:06:57 +0000 (+0100) Subject: HPlot, add option to add up values using "Fill" and scale y and cb axes X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=7ae28ce93282901b8541d272142bef9928b2c148;p=hadesdaq.git HPlot, add option to add up values using "Fill" and scale y and cb axes --- diff --git a/hmon/HPlot.pm b/hmon/HPlot.pm index 96e2c34..4f1087e 100755 --- a/hmon/HPlot.pm +++ b/hmon/HPlot.pm @@ -71,6 +71,8 @@ sub PlotInit { $p->{$name}->{file} = $p->{$name}->{file} || "dummy" ; $p->{$name}->{curves} = $p->{$name}->{curves} || 1 ; $p->{$name}->{xscale} = $p->{$name}->{xscale} || 1; + $p->{$name}->{yscale} = $p->{$name}->{yscale} || 1; + $p->{$name}->{cbscale} = $p->{$name}->{cbscale} || 1; $p->{$name}->{type} or die "No plot type specified"; $p->{$name}->{output} or die "No destination specified"; $p->{$name}->{colors} = $p->{$name}->{colors} || \@color; @@ -253,10 +255,10 @@ sub PlotDraw { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=$p->{$name}->{entries}-$realentries; $i< $p->{$name}->{entries}; $i++) { if ($p->{$name}->{countup}) { - plot_write($p->{$name}->{fh},(($i-($p->{$name}->{entries}-$realentries))/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]); + plot_write($p->{$name}->{fh},(($i-($p->{$name}->{entries}-$realentries))/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]/($p->{$name}->{yscale}||1)); } else { - plot_write($p->{$name}->{fh},(($i-$realentries)/($p->{$name}->{xscale}||1))." ".($p->{$name}->{value}->[$j]->[$i]||0)); + plot_write($p->{$name}->{fh},(($i-$realentries)/($p->{$name}->{xscale}||1))." ".($p->{$name}->{value}->[$j]->[$i]||0)/($p->{$name}->{yscale}||1)); } } plot_write($p->{$name}->{fh},"e"); @@ -267,7 +269,7 @@ sub PlotDraw { my $realentries = $p->{$name}{limitentries} || $p->{$name}->{entries}; for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=$p->{$name}->{entries}-$realentries; $i< $p->{$name}->{entries}; $i++) { - plot_write($p->{$name}->{fh},' '.$p->{$name}->{value}->[$j]->[$i]||0); #?? maybe without ||0 + plot_write($p->{$name}->{fh},' '.(($p->{$name}->{value}->[$j]->[$i]||0)/($p->{$name}->{yscale}||1))); #?? maybe without ||0 } plot_write($p->{$name}->{fh},"e"); } @@ -278,7 +280,7 @@ sub PlotDraw { # if($p->{$name}->{showvalues}) { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=0; $i< $p->{$name}->{entries}; $i++) { - plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]//'NaN')." ",1);#"NaN" + plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]//'NaN')/($p->{$name}->{cbscale}||1)." ",1);#"NaN" #plot_write($p->{$name}->{fh},((int((($p->{$name}->{value}->[$j]->[$i]||0)*100+0.5)/100))//'NaN')." ",1);#"NaN" } plot_write($p->{$name}->{fh}," ",0); @@ -290,7 +292,7 @@ sub PlotDraw { if ($p->{$name}{showvalues}) { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=0; $i< $p->{$name}->{entries}; $i++) { - plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1); + plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)/($p->{$name}->{cbscale}||1)." ",1); #plot_write($p->{$name}->{fh},(int((($p->{$name}->{value}->[$j]->[$i]||0)*100+0.5)/100))." ",1); } plot_write($p->{$name}->{fh}," ",0); @@ -320,9 +322,14 @@ sub PlotAdd { } sub PlotFill { - my($name,$value,$slot,$curve) = @_; + my($name,$value,$slot,$curve,$add) = @_; $curve = 0 unless $curve; - $p->{$name}->{value}->[$curve]->[$slot] = $value||0; + if($add) { + $p->{$name}->{value}->[$curve]->[$slot] += $value||0; + } + else { + $p->{$name}->{value}->[$curve]->[$slot] = $value||0; + } } sub PlotLimitEntries {