]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
HPlot, add option to add up values using "Fill" and scale y and cb axes
authorhadaq <jan@lxhadeb07>
Tue, 27 Nov 2018 09:06:57 +0000 (10:06 +0100)
committerhadaq <jan@lxhadeb07>
Tue, 27 Nov 2018 09:06:57 +0000 (10:06 +0100)
hmon/HPlot.pm

index 96e2c34b015ea8542af3ab1eef9595b2f7b5645f..4f1087e4d7d6041559bb339856e2a681b7ebbe76 100755 (executable)
@@ -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 {