]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
patched to gnuplot5 and perl 5.24 and many others just commited, mt
authorhadaq@countinghouse <hadaq@CountingHouse>
Thu, 22 Dec 2016 13:27:44 +0000 (14:27 +0100)
committerhadaq@countinghouse <hadaq@CountingHouse>
Thu, 22 Dec 2016 13:27:44 +0000 (14:27 +0100)
25 files changed:
hmon/HPlot.pm
hmon/QA.pm
hmon/hmon_endpoints.pl
hmon/hmon_goofy.pl [new file with mode: 0755]
hmon/hmon_hadplotnew.sh
hmon/hmon_hodo.pl [changed mode: 0755->0644]
hmon/hmon_hodo_hist.pl
hmon/hmon_mdc_ratecheck.pl
hmon/hmon_micro.pl
hmon/hmon_pionovfl.pl
hmon/hmon_pionpileup.pl
hmon/hmon_pionrate.pl
hmon/hmon_readoutstuck.pl
hmon/hmon_shower.pl
hmon/hmon_spill.pl
hmon/hmon_trgsource.pl
hmon/permanent/hmon_archiver.pl [changed mode: 0755->0644]
hmon/permanent/hmon_eb_run.pl
hmon/permanent/hmon_magnet.pl
hmon/permanent/hmon_mdchv.pl
hmon/permanent/hmon_mdcpressure.pl
hmon/permanent/hmon_pionsupply.pl
hmon/permanent/hmon_richhv.pl
hmon/permanent/hmon_sequencer.pl
hmon/start.sh

index 826e34ad8bb1db59e11419775044edc145ce6184..b570357e1be9bd74446f3b80ff15722c1c52f5b3 100755 (executable)
@@ -45,9 +45,11 @@ sub setranges {
     }
   elsif(defined $min) {
     plot_write($fh,"set $name [$min:]");
-    }  
+    }
   }
 
+
+
 sub PlotInit {
   my ($c) = @_;
 
@@ -56,6 +58,7 @@ sub PlotInit {
   my $fn = "gnuplot";
   #my $fh = new FileHandle ("|$fn") or  die "error: no gnuplot";
   open my $fh, "|$fn" or  die "error: no gnuplot";
+  #open my $fh, ">delme_$name" or  die "error: no gnuplot";
   $fh->autoflush(1);
 
 
@@ -73,18 +76,19 @@ sub PlotInit {
   $p->{$name}->{colors} = $p->{$name}->{colors} || \@color;
   $p->{$name}->{showvalues} = $p->{$name}->{showvalues} || 0;
   $p->{$name}->{storable} = $p->{$name}->{storable} || 0;
+  $p->{$name}->{plot_string} = ""; # to store the plot command
 
   my $filename = $p->{$name}->{file};
   $filename =~ s%/%%;
   $storefile->{$name} = "/dev/shm/".$name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
 
-    
+
   foreach my $i (0..($c->{entries}-1)) {
     for my $j (0..($c->{curves}-1)) {
       push(@{$p->{$name}->{value}->[$j]},0) ;
       }
     }
-  
+
   if($p->{$name}->{storable}) {
     if (-e $storefile->{$name}) {
       $p->{$name}->{value} = lock_retrieve($storefile->{$name});
@@ -120,73 +124,87 @@ sub PlotInit {
   setranges($fh,'zrange',$p->{$name}->{zmin},$p->{$name}->{zmax});
   setranges($fh,'cbrange',$p->{$name}->{cbmin},$p->{$name}->{cbmax});
 
-    
-  if($p->{$name}->{type} == TYPE_HISTORY) {
-    if($p->{$name}->{fill}) {
+  if ($p->{$name}->{type} == TYPE_HISTORY) {
+    if ($p->{$name}->{fill}) {
       plot_write($fh,"set style fill solid 1.00");
-      }
+    }
     else {
       plot_write($fh,"set style fill solid 0");
-      }
+    }
     plot_write($fh,"set boxwidth 2 absolute");
     plot_write($fh,"set autoscale fix");
     plot_write($fh,"set xtics autofreq"); #$p->{$name}->{entries}
     plot_write($fh,"set grid");
-#     plot_write($fh,"set style fill solid 1.0");
-    plot_write($fh,"plot ",1);
-    for(my $j=0; $j<$p->{$name}->{curves};$j++) {
-      if($p->{$name}->{fill}) {
-        plot_write($fh,"'-' using 1:2 with filledcurves x1 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
-        }
-      elsif($p->{$name}->{dots}) {
-        plot_write($fh,"'-' using 1:2 with points pointsize 0.6 pointtype 2 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
-        }
+    #     plot_write($fh,"set style fill solid 1.0");
+    #plot_write($fh,"plot ",1);
+    $p->{$name}->{plot_string} .= "plot ";
+    for (my $j=0; $j<$p->{$name}->{curves};$j++) {
+      if ($p->{$name}->{fill}) {
+        #plot_write($fh,"'-' using 1:2 with filledcurves x1 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
+        $p->{$name}->{plot_string} .= "'-' using 1:2 with filledcurves x1 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
+      }
+      elsif ($p->{$name}->{dots}) {
+        #plot_write($fh,"'-' using 1:2 with points pointsize 0.6 pointtype 2 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
+        $p->{$name}->{plot_string} .= "'-' using 1:2 with points pointsize 0.6 pointtype 2 lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
+      }
       else {
-        plot_write($fh,"'-' using 1:2 with lines  lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
-        }
-      plot_write($fh,', ',1) unless ($j+1==$p->{$name}->{curves});
+        #plot_write($fh,"'-' using 1:2 with lines  lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
+        $p->{$name}->{plot_string} .= "'-' using 1:2 with lines  lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
       }
-    plot_write($fh," ");
+      #plot_write($fh,', ',1) unless ($j+1==$p->{$name}->{curves});
+      $p->{$name}->{plot_string} .= ', ' unless ($j+1==$p->{$name}->{curves});
     }
-  elsif($p->{$name}->{type} == TYPE_BARGRAPH) {
+    #plot_write($fh," ");
+    $p->{$name}->{plot_string} .= " \n";
+    plot_write($fh, $p->{$name}->{plot_string});
+  }
+  elsif ($p->{$name}->{type} == TYPE_BARGRAPH) {
     plot_write($fh,"set style fill   solid 1.00 border -1");
     plot_write($fh,"set grid noxtics ytics");
     plot_write($fh,"set boxwidth ".($p->{$name}->{curvewidth}||4)." absolute");
     plot_write($fh,"set style histogram gap ".($p->{$name}->{bargap}||1));
-    if(defined $p->{$name}->{bartitle} && scalar @{$p->{$name}->{bartitle}}) {
+    if (defined $p->{$name}->{bartitle} && scalar @{$p->{$name}->{bartitle}}) {
       plot_write($fh,"set xtics (",1);
-      for(my $j=0; $j<scalar @{$p->{$name}->{bartitle}};$j++) {
+      for (my $j=0; $j<scalar @{$p->{$name}->{bartitle}};$j++) {
         plot_write($fh,', ',1) if $j;
         plot_write($fh,"'".$p->{$name}->{bartitle}->[$j]."' $j ",1);
-        }
-      plot_write($fh,") offset 2.5,0 scale 0");
       }
+      plot_write($fh,") offset 2.5,0 scale 0");
+    }
     plot_write($fh,"set style histogram title offset character 0, 0, 0");
     plot_write($fh,"set style data histograms");
-    plot_write($fh,"plot ",1);
-    for(my $j=0; $j<$p->{$name}->{curves};$j++) {
-      plot_write($fh,', ',1) if $j;
-      plot_write($fh,"'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
-      }
-    plot_write($fh," ");
+    #plot_write($fh,"plot ",1);
+    $p->{$name}->{plot_string} .= "plot ";
+    for (my $j=0; $j<$p->{$name}->{curves};$j++) {
+      #plot_write($fh,', ',1) if $j;
+      $p->{$name}->{plot_string} .= ', ' if $j;
+      #plot_write($fh,"'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
+      $p->{$name}->{plot_string} .= "'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
     }
-  elsif($p->{$name}->{type} == TYPE_HEATMAP) {
+    #plot_write($fh," ");
+    $p->{$name}->{plot_string} .= " \n";
+    plot_write($fh, $p->{$name}->{plot_string});
+  }
+  elsif ($p->{$name}->{type} == TYPE_HEATMAP) {
     plot_write($fh,"set view map");
     plot_write($fh,"set palette rgbformulae 22,13,-31");
     if ($p->{$name}->{showvalues} == 0) {
-      plot_write($fh,"splot '-' matrix with image");
-      }
+      #plot_write($fh,"splot '-' matrix with image");
+      $p->{$name}->{plot_string} .= "splot '-' matrix with image \n"
+    }
     else {
-      plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)) with labels tc rgb \"#ffffff\" font ',10'");
-#      plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)):3 with labels tc palette  font ',10'");
-      }
+      #plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)) with labels tc rgb \"#ffffff\" font ',10'");
+      $p->{$name}->{plot_string} .= "plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)) with labels tc rgb \"#ffffff\" font ',10'";
+      ####      plot_write($fh,"plot '-' matrix with image, '-' matrix using 1:2:(sprintf('%i', \$3)):3 with labels tc palette  font ',10'");
     }
+    plot_write($fh, $p->{$name}->{plot_string});
+  }
   else {
     die "Plot type not supported";
-    }
-
   }
 
+}
+
 
 sub PlotDraw {
   my($name) = @_;
@@ -196,9 +214,10 @@ sub PlotDraw {
   if($p->{$name}->{run}>=1) {
     plot_write($p->{$name}->{fh},"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
     plot_write($p->{$name}->{fh},makeTimeString());
-    plot_write($p->{$name}->{fh},"replot");
+    #plot_write($p->{$name}->{fh},"replot");
+    plot_write($p->{$name}->{fh}, $p->{$name}->{plot_string});
     }
-    
+
   if($p->{$name}->{type} == TYPE_HISTORY) {  
     for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
       for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
@@ -210,11 +229,11 @@ sub PlotDraw {
           }
         }
       plot_write($p->{$name}->{fh},"e");
-      }  
+      }
     }
-    
-    
-  if($p->{$name}->{type} == TYPE_BARGRAPH) { 
+
+  if($p->{$name}->{type} == TYPE_BARGRAPH) {
+    #plot_write($p->{$name}->{fh}, $p->{$name}->{plot_string});
     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]);
@@ -222,17 +241,16 @@ sub PlotDraw {
       plot_write($p->{$name}->{fh},"e");
       }
     }
-      
-      
-  if($p->{$name}->{type} == TYPE_HEATMAP) {    
+
+  if($p->{$name}->{type} == TYPE_HEATMAP) {
       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}," ",0);
         }
-      plot_write($p->{$name}->{fh},"e");      
-      plot_write($p->{$name}->{fh},"e");     
+      plot_write($p->{$name}->{fh},"e");
+      plot_write($p->{$name}->{fh},"e");
 
       for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
         for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
@@ -240,15 +258,15 @@ sub PlotDraw {
           }
         plot_write($p->{$name}->{fh}," ",0);
         }
-      plot_write($p->{$name}->{fh},"e");      
-      plot_write($p->{$name}->{fh},"e");     
+      plot_write($p->{$name}->{fh},"e");
+      plot_write($p->{$name}->{fh},"e");
 
     }
-    
-    
+
+
   $p->{$name}->{run}++;
-  
-  
+
+
   if($p->{$name}->{storable}) {
     lock_store($p->{$name}->{value},$storefile->{$name});
     }
@@ -268,6 +286,6 @@ sub PlotFill {
   $curve = 0 unless $curve;
   $p->{$name}->{value}->[$curve]->[$slot] = $value||0;
   }
-  
+
 
 1;
index 608bff07ead166e8897eaef5791aa1b837460ec0..0c1ab3faadd5c0bff1038873c639c46fc818202f 100644 (file)
@@ -15,7 +15,8 @@ our $cats = {'main'=>"Main",
              'endp'=>"Endp",
              'feeerr'=>"Fee",
              'other'=>"Other",
-             'pion'=>"Pion"};
+             'pion'=>"Pion",
+             'qa'=>'QA'};
 
 # Order of categories
 our $entries->{'cats'} = ["main",
@@ -27,8 +28,9 @@ our $entries->{'cats'} = ["main",
                           "mdc",
                           "endp",
                           "feeerr",
-                          "pion",
+#                          "pion",
                           "other",
+                          "qa",
 ];
 
 # Order of entries in each cat
@@ -43,6 +45,7 @@ $entries->{'endp'}    = ['mdc','rich', 'tof', 'rpc', 'other'];
 $entries->{'feeerr'}  = ['rich', 'trb', 'feeerr','trginp','trgqual'];
 $entries->{'pion'}    = ['nxstatus', 'HV', 'HVcurr', 'cooling','seu'];
 $entries->{'other'}   = ['magnet','rich','shower','mdcinvalid','sequencer'];
+$entries->{'qa'}      = ['goofy','','','',''];
 
 
 our $QAServer = "hades33";
@@ -74,10 +77,10 @@ our @CPULimits        = (95, 100, 100);
 our @TimeoutLimits    = (0, 0, 1);
 our @LinkErrLimits     = (50, 500, 1000);
 our @MdcEndpMissingLimits   =  (0, 0, 1);
-our @RichEndpMissingLimits   = (0, 0, 0);
+our @RichEndpMissingLimits   = (0, 30, 30); #!!!!
 our @TofEndpMissingLimits   = (0, 0, 0);
 our @RpcEndpMissingLimits   = (0, 0, 0);
-our @OtherEndpMissingLimits   = (0, 0, 0);
+our @OtherEndpMissingLimits   = (0, 30, 30);#!!!
 our @EBDeltaRateLimits = (10, 15, 25);
 our $TrgCheckPolarity = 1;
 our @Eventsbroken     = (.5,5,10);
@@ -87,6 +90,9 @@ our @MdcHVOffsetLimits = (5,10,20);
 
 our @PionLvCurrLimits = (4,5,6);
 
+our $MdcHvOff = 1;
+our $RichHvOff = 1;
+our $MagnetOff = 1;
 
 our @LimitTriggerPerSpill = (1000, 0, 0);
 our $AcceleratorCycle = 7;
@@ -96,7 +102,7 @@ use constant {CTSAddress => 0x0003};
 #  Missing Boards
 ###############################################################################
 
-our @mdc_boards_removed =(0x2257); # 2233 added 2014-08-28
+our @mdc_boards_removed =(0x2257, 0x2029); # 2233 added 2014-08-28 , 2203 at 2014/09/03, 2029 2014/09/23
 our @mdc_chambers_removed =();
 our @rich_boards_removed =();
 our @tof_boards_removed =();
index 6c72b585e38c7944f1430c265bed037a01dbb86c..42761c878ae2ac1642bd3afca576aef099cdec45 100755 (executable)
@@ -93,8 +93,8 @@ while(1) {
 
     my @other_boards =(
        #shower
-#      0x3200,0x3201,0x3202,0x3210,0x3211,0x3212,0x3220,0x3221,0x3222,0x3230,0x3231,0x3232,0x3240,0x3241,0x3242,
-#      0x3250,0x3251,0x3252,
+       0x3200,0x3201,0x3202,0x3210,0x3211,0x3212,0x3220,0x3221,0x3222,0x3230,0x3231,0x3232,0x3240,0x3241,0x3242,
+       0x3250,0x3251,0x3252,
        #shower-hub
 #      0x8500,0x8501,
        #cts
diff --git a/hmon/hmon_goofy.pl b/hmon/hmon_goofy.pl
new file mode 100755 (executable)
index 0000000..42dbc7b
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+use strict;
+use IO::Handle;
+use Hmon;
+use QA;
+
+sub makeTimeString{
+  return strftime("set label 100 \"%H:%M:%S\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n", localtime())
+  }
+
+
+open my $GP,'|gnuplot -background white';
+
+my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile";
+
+my  $str = Hmon::MakeTitle(24,20,"Goofy",0);
+  $str .= qq@<img src="%ADDPNG files/goofyplot1.png%" type="image/png">@;
+  $str .= Hmon::MakeFooter();
+  Hmon::WriteFile("goofy1",$str);
+
+
+while(1)
+{
+my $tmp_lines = qx{ssh hadesdaq01 tail -n 500 /home/hadaq/Documents/bitscope/EPICS/goofy/goofyApp/gas_quality.txt};
+open(TMP_FILE,">/tmp/last_gas_data.txt");
+print TMP_FILE $tmp_lines;
+close(TMP_FILE);
+
+print {$GP} << '__GNUPLOT__';
+set term png size 1320,700 font "monospace,8"
+set out "files/goofyplot1.png"
+set multiplot
+set size 0.5,0.5
+set origin 0,0.5
+set title "drift velocity"
+set grid
+set xdata time
+set timefmt "%d/%m/%Y:%H:%M:%S"
+set format x "%d/%m\n%H:%M"
+set xlabel "time (dd/mm)"
+set ylabel "drift velocity (cm/us)"
+plot "/tmp/last_gas_data.txt" u 1:5 notitle
+set size 0.5,0.25
+set origin 0.5,0.5
+set title "drift time top"
+set grid
+set xdata time
+set timefmt "%d/%m/%Y:%H:%M:%S"
+set format x "%d/%m\n%H:%M"
+set xlabel "time (dd/mm)"
+set ylabel "drift time top (us)"
+plot "/tmp/last_gas_data.txt" u 1:6 notitle
+set origin 0.5,0.75
+set title "drift time bottom"
+set grid
+set xdata time
+set timefmt "%d/%m/%Y:%H:%M:%S"
+set format x "%d/%m\n%H:%M"
+set xlabel "time (dd/mm)"
+set ylabel "drift time bottom (us)"
+plot "/tmp/last_gas_data.txt" u 1:7 notitle
+set size 0.5,0.5
+set origin 0,0
+set title "pickup bottom on pickup top amplitude ratio"
+set grid
+set xdata time
+set timefmt "%d/%m/%Y:%H:%M:%S"
+set format x "%d/%m\n%H:%M"
+set xlabel "time (dd/mm)"
+set ylabel "pickup bottom on pickup top amplitude ratio"
+plot "/tmp/last_gas_data.txt" u 1:8 notitle
+set origin 0.5,0
+set title "pickup bottom on pickup top area ratio"
+set grid
+set xdata time
+set timefmt "%d/%m/%Y:%H:%M:%S"
+set format x "%d/%m\n%H:%M"
+set xlabel "time (dd/mm)"
+set ylabel "pickup bottom on pickup top area ratio"
+plot "/tmp/last_gas_data.txt" u 1:9 notitle
+unset multiplot
+reset
+__GNUPLOT__
+$GP->autoflush;
+
+my $qastate = QA::OK;
+#Replace 0 by the condition for ERROR on hmon Panel
+
+my $tmp_line = qx{ssh hadesdaq01 tail -n 1 /home/hadaq/Documents/bitscope/EPICS/goofy/goofyApp/gas_quality.txt};
+my @data = split(/ /,$tmp_line);
+my ($dateS,$dateE,$countsT,$countsB,$dv,$dtT,$dtB,$ramp,$rar)=@data;
+
+$qastate = QA::ERROR if (0);
+QA::WriteQALogvaleurs($fqa,"qa","goofy",120,$qastate,"Goofy","Running","Doing whatever needs to be done.");  
+
+sleep(60);
+}
+
+#<>;
+close $GP;
index 37da618b7db36537ca0915881dd92ac965a98810..059a84248fd9387be521529b2104475410c25b3d 100755 (executable)
@@ -746,7 +746,7 @@ sub genreg {
       if (!(defined $regamount->[$i]) || $regamount->[$i] == 1) {
 #         $c = "trbcmd r $address->[$i] $register->[$i] | sort";  
         $c = trb_register_read(($address->[$i]),($register->[$i]));
-        foreach my $s (keys $c) {
+        foreach my $s (keys %$c) {
           $c->{$s}=[$c->{$s}];
           }
         }
@@ -756,7 +756,7 @@ sub genreg {
 #         print Dumper $c;
         }
 #       my @out = qx($c);
-      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;
@@ -818,7 +818,7 @@ sub genhist {
     for(my $i = 0; $i<scalar(@{$address});$i++) {
       $val = 0;
       my $c = trb_registertime_read($address->[$i], $register->[$i]) or sleep 1 and print "Error\n" and next;
-      foreach my $o (sort keys $c) {
+      foreach my $o (sort keys %$c) {
 #         if (($a,$s,$t) = $o =~ /^0x(\w{4})\s*0x(\w{8})\s*0x(\w{4})/) {
           
           $val  += (($c->{$o}->{'value'}->[0]>>($regoffset->[$i]))&(2**($regwidth->[$i])-1));
old mode 100755 (executable)
new mode 100644 (file)
index 8eaa656217ce75911dcdbe76dae56e55c5450784..2d0bb77c58188bd8d632ef3b21c0fdd6e92bb9fb 100755 (executable)
@@ -240,7 +240,7 @@ while (1) {
     }
   $t = trb_registertime_read(0xfe49,0x8132);
   if (defined $t) {
-    foreach my $b (keys $t) {
+    foreach my $b (keys %$t) {
       $o2->{$b}->{0x8132} = $t->{$b};
       }
     }
@@ -273,7 +273,7 @@ while (1) {
       }
       
     foreach my $b (keys %$o2) { 
-      foreach my $a (keys $o2->{$b}) {
+      foreach my $a (keys %{$o2->{$b}}) {
         my $tdiff = $o2->{$b}->{$a}->{time}->[0] - ($oldtime->{$b}||0);
         my $vdiff = ($o2->{$b}->{$a}->{value}->[0]) - ($old2->{$b}->{$a}->{value}->[0]);
         if ($vdiff < 0) { $vdiff += 2**32;}
index 409b80fe0daffa8404cf43cfeef17625a4fd6879..9cfe8c127caa03aa2c8d035b799aa27d7fe4189d 100755 (executable)
@@ -30,7 +30,7 @@ while (1) {
   my $rh_mdc_rates = trb_register_read(0xfffd, 0x910b) or sleep 5 and next;
   my $rh_evts      = trb_register_read(0x0002, 0x0001) or sleep 5 and next;
 
-  foreach my $v (sort keys $rh_mdc_rates) {
+  foreach my $v (sort keys %$rh_mdc_rates) {
     $values->{$v} = ($rh_mdc_rates->{$v} || 0) - ($laststore->{$v} || $rh_mdc_rates->{$v} || 0);
     $laststore->{$v} = $rh_mdc_rates->{$v};
     $sum += $values->{$v};
@@ -49,7 +49,7 @@ while (1) {
 
 
     if($rate > 1000 && $avg > 1000) {
-      foreach my $v (sort keys $values) {
+      foreach my $v (sort keys %$values) {
 #         print($v." ".$values->{$v}."\n");
         if($values->{$v} == 0) {
           $error++;
@@ -70,4 +70,4 @@ while (1) {
     $iteration = 1;
     }
   sleep 10;
-  }
\ No newline at end of file
+  }
index 203e3b825cbf44f13f6aea9b30e6615bede5a754..631aa9679df968d14f09804bf489a60db953f2b6 100755 (executable)
@@ -36,6 +36,7 @@ while (1) {
     trb_register_setbit(0x8880,0xcf8f,1);
     my $a = trb_register_read(0x8880,0xcf82);
     my $length = $a->{0x8880};
+    $length = 0 if(!defined $length);
     if($length > 0 && $length < 1E6) {
       $length = $length/100*1024;
       if($length < 500000) {$length = 500000;}
index bf71752839679ec9be005b14d3d389c6074400d8..50276992ea5ceb32025c768ffeff6366c42ba0fc 100755 (executable)
@@ -27,9 +27,8 @@ if($plots) {
        $filter = trb_register_read($address, 0x8400);
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
-
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -37,7 +36,6 @@ if($plots) {
        } else {
            $str .= "${histname}";
        }
-
        $str .= "</strong>";
        $str .= "<img width=\"700\" height=\"265\" src=\"%ADDPNG files/Pion1XOvfl.png%\" type=\"image/png\">\n";
        
@@ -47,8 +45,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
        
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -75,8 +73,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
 
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -98,8 +96,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
        
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -112,7 +110,7 @@ if($plots) {
        $str .= "<img width=\"700\" height=\"265\" src=\"%ADDPNG files/Pion2YOvfl.png%\" type=\"image/png\">\n";
 
        $str .= Hmon::MakeFooter();
-       Hmon::WriteFile("pion2ovfl",$str);
+       Hmon::WriteFile("pion2ovfl", $str);
        sleep(5);
     }
 } else { 
index 385584bc42b4599e1af83889c7096b646a02c07f..8e46f20d5a2a25c1fabfc6ead729eb7a2e66ed6c 100755 (executable)
@@ -28,8 +28,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
 
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -47,8 +47,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
        
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -75,8 +75,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
 
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
@@ -98,8 +98,8 @@ if($plots) {
        $addonfilter = trb_register_read($address, 0x8420);
        $str .= "<strong>";
        
-       if (($filter->{$address} & 0x80000000) == 0) {
-           if (($addonfilter->{$address} & 0x80000000) > 0) {   
+       if (($addonfilter->{$address} & 0x80000000) != 0) {
+           if (($addonfilter->{$address} & 0x40000000) != 0) {   
                $str .= "${histname} (TS Cut Level2)";  
            } else { 
                $str .= "${histname} (TS Cut)";
index b54d0907ce7b03cdc9a1a46558af6530b17150c5..862fffac2858b1e41f670bb57585e15511ee9b3e 100755 (executable)
@@ -97,7 +97,7 @@ if($plots) {
        $str .= "<img width=\"700\" height=\"265\" src=\"%ADDPNG files/Pion2Y.png%\" type=\"image/png\">\n";
 
        $str .= Hmon::MakeFooter();
-       Hmon::WriteFile("pion2rate",$str);
+       Hmon::WriteFile("pion2rate", $str);
        sleep(5);
     }
 } else { 
index 01bf99dfdf29202c8e4f9061178093ac9c4b3434..9a2678e95acb0858861d7cb9484256f5b7986328 100755 (executable)
@@ -46,7 +46,7 @@ while (1) {
 
   if($rate == 0 && ($rh_status->{3} & (1 << 31)) && ($rh_status->{3} & 0x3ff00000)) {
     my $rh_hubs = trb_register_read(0xfffe,0x81) or sleep 5 and next;
-    foreach my $h (sort keys $rh_hubs) {
+    foreach my $h (sort keys %$rh_hubs) {
       if($rh_hubs->{$h} != 0) {
 #         $boardlist .= sprintf("%04x, ",$h);
         if (isFeeHub($h)) {
@@ -68,4 +68,4 @@ while (1) {
   QA::WriteQALog($fqa, "daq", "readout", 30, $qastate,"Read-out", $status,$longmsg);    
 #   print $qastate." ".$status." ".$longmsg."\n";
   sleep(5);
-  }
\ No newline at end of file
+  }
index 54483e92221ca2c2bd14ea2eafc1d353bd6865fe..b8e89487e842c2528770cfe9a8bea0e882d100e3 100755 (executable)
@@ -45,8 +45,8 @@ while (1) {
     my $hexval = sprintf("%x", $board);
     my @a = split("", $hexval);
       if($a[0] == "3" && $a[1] == "2") {
-        $values{$board}->{"bytes"} = %$bytes_sent->{$board} - ($values{$board}->{"prev_bytes"}||0) if defined %$bytes_sent->{$board};
-        $values{$board}->{"prev_bytes"}  = %$bytes_sent->{$board};
+        $values{$board}->{"bytes"} = $bytes_sent->{$board} - ($values{$board}->{"prev_bytes"}||0) if defined $bytes_sent->{$board};
+        $values{$board}->{"prev_bytes"}  = $bytes_sent->{$board};
 
         $sum += $values{$board}->{"bytes"};
       }
@@ -66,8 +66,8 @@ while (1) {
    my $patternSum = 0;
    my $thresholdSum = 0;
    foreach my $board (keys %$configuration) {
-       $pattern = sprintf("%x", ((%$configuration->{$board} & 0xf0) >> 4));
-       $threshold = sprintf("%x", (%$configuration->{$board} & 0xf));
+       $pattern = sprintf("%x", (($configuration->{$board} & 0xf0) >> 4));
+       $threshold = sprintf("%x", ($configuration->{$board} & 0xf));
        $patternSum += $pattern;
        $thresholdSum += $threshold;
    }
@@ -81,14 +81,14 @@ while (1) {
    #analyze data from EPICS
        my $iSum = 0;
        foreach my $n (%$data) {
-               if (defined %$data->{$n}->{"val"}) {
-                       $iSum += %$data->{$n}->{"val"};
+               if (defined $data->{$n}->{"val"}) {
+                       $iSum += $data->{$n}->{"val"};
                }
        }
 
    foreach my $n (%$data) {
-       if (defined %$data->{$n}->{"val"}) {
-               if (%$data->{$n}->{"val"} > ($iSum / 18) + 0.5) {
+       if (defined $data->{$n}->{"val"}) {
+               if ($data->{$n}->{"val"} > ($iSum / 18) + 0.5) {
                        $setAlert = 3;
                }
        }
index 5a81dc0942a9d650e2aa9a012b06a7f8a1454f9e..cc318feb890558b3bd839f74c7f8a0725afe5d6c 100755 (executable)
@@ -2,6 +2,7 @@
 
 use warnings;
 use Time::HiRes qw(usleep);
+use List::Util qw(min max);
 use strict;
 use Data::Dumper;
 use Hmon;
@@ -44,6 +45,7 @@ my  $str = Hmon::MakeTitle(8,5,"Recorded Events per Spill (1000)",0);
   Hmon::WriteFile("EvtsPerSpill",$str);
 
 my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile";
+my $lastqa = 0;
 
 trb_init_ports() or die trb_strerror();
 
@@ -54,18 +56,20 @@ while (1) {
     my $rh_result = trb_register_read(QA::CTSAddress, 0xa002) or $trbneterr = 1; #sleep 5 and next;
     my $stopped  = trb_register_read(0x3,0xa0c0) or sleep 5 and next;  
     $stopped = ($stopped->{3} || 0) & 0x400;
-    
+
     my $sc = trb_register_read(0x3830,0xc00d);
+    if(!defined $sc) {
+      sleep 10;
+      next;
+    }
     my $spillcount = $sc->{0x3830} & 0x00ffffff;
     my $inspill    = ($sc->{0x3830} & 0x80000000) >> 31;
-    my $data = Perl2Epics::GetAll();
-    
+
     $lastspill = $outofspill;
     $outofspill = ($rh_result->{QA::CTSAddress} || 0) & 0x10;
     $spilllength++ ; #if($outofspill);
     $rh_result = trb_register_read(0x0002, 0x01) or $trbneterr = 1; #sleep 5 and next;
-    # 0x3000 => a reliable guy to ask about rates
-    
+
     if($trbneterr == 0) {
        my $res = $rh_result->{0x0002} & 0xffff;
        $evtrate = $res >= $lastres ? $res - $lastres : ($res + 2**16) - $lastres;
@@ -100,7 +104,8 @@ while (1) {
            $spillavgshort /= (scalar @spills < 10)?(scalar @spills):10;
 
            $qashort = QA::SciNotation($events)." (".$spilllength."s)";
-           $qastate = QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill);
+           $qastate = min($lastqa,QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill));
+           $lastqa  =             QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill);
            $qalong = sprintf("current spill: %s - 10-spill avg. %s - 50-spill avg. %s - Spill length %is", 
                              QA::SciNotation($events),
                              QA::SciNotation($spillavgshort),
@@ -115,9 +120,11 @@ while (1) {
        } elsif ($spilllength > 20) {
               QA::WriteQALog($fqa, "trg", "spill", 30, QA::NOTE, "Spill Sum",
                           "No Spills", "No Spills detected at the moment");  
-            
-            if($spilllength >= 25 && !($spilllength%25)) {
-              if($data->{'prefix'}->{val} eq 'be') {
+            #print $spilllength."\n" unless $spilllength%10;
+            if($spilllength >= 25 && ($spilllength%25 == 0)) {
+              my $data = Perl2Epics::GetAll();
+              print STDERR $data->{'prefix'}->{val}."\n";
+              if(($data->{'prefix'}->{val} eq '-1') || ($data->{'prefix'}->{val} eq 'be')) {
                 Hmon::Speak('nobeam', "No beam");
                 }
               }
index 5a213a40912c35600a90c9d13d4d84d3cf9d244a..46d0f78e3fd1bcb0bdcfe6d9ade905d67bc376b8 100755 (executable)
@@ -47,12 +47,14 @@ $plot->{type}    = HPlot::TYPE_HISTORY;
 $plot->{output}  = HPlot::OUT_PNG;
 $plot->{titles}->[0] = "";
 $plot->{xlabel}  = "Spill Number";
-$plot->{ylabel}  = "Start Counts / Mcnt";
+$plot->{ylabel}  = "Hodoscope Counts / Mcnt";
 $plot->{sizex}   = 630;
 $plot->{sizey}   = 220;
 $plot->{nokey} = 1;
+$plot->{buffer} = 1;
+$plot->{storable} = 1;
 HPlot::PlotInit($plot);
-my  $str = Hmon::MakeTitle(8,5,"Start Counts per Spill (millions)",0);
+my  $str = Hmon::MakeTitle(8,5,"Hodoscope Counts per Spill (millions)",0);
   $str .= qq@<img src="%ADDPNG files/StartCountSpills.png%" type="image/png">@;
   $str .= Hmon::MakeFooter();
   Hmon::WriteFile("StartCountSpill",$str);
@@ -258,7 +260,7 @@ my $longmsgcheck = $longmsg;
     $spillsum = 0;
     }
   $startmsg = sprintf("%s / %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum));
-  $startlongmsg = sprintf("Hodo counts per second %s/s  - Hodo counts per spill %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum));
+  $startlongmsg = sprintf("Start counts per second %s/s  - Start counts per spill %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum));
   QA::WriteQALog($fqa, "trg", "start", 10, $qastatstart, "Hodo Count", $startmsg, $startlongmsg);
    
   
old mode 100755 (executable)
new mode 100644 (file)
index 304f4fb02fde1751d17c1c99a4a6c2d54f4d49e4..96f5998a80dcfe3549c5cfccbe63df868cd0f558 100755 (executable)
@@ -80,8 +80,8 @@ while(1) {
 
  
   # 0x3000 => ??
-  $rh_result = trb_register_read(0x3000, 0x1) or $trbneterr = 1;
-  my $res = ($rh_result->{0x3000} || 0) & 0xFFFF;
+  $rh_result = trb_register_read(0x3001, 0x1) or $trbneterr = 1;
+  my $res = ($rh_result->{0x3001} || 0) & 0xFFFF;
 
   $evtrate = $res - ($events || $res);
   $evtrate += 2**16 if $evtrate < 0;
index 4f316f2a579b1257c47168d40e99429ed62e69da..25162d0bc37867540c2954ffb8e97a627f50cf63 100755 (executable)
@@ -9,7 +9,7 @@ use QA;
 use Getopt::Long;
 use Data::Dumper;
 
-my $magnet_on = 1;
+my $magnet_on = 1 - $QA::MagnetOff;
 
 my %range_list = (
                  'Time'             => {},
index d0442e7e0beb87e3e14723e9fa1bcb9ee3c3ce41..caf43550b2ffeeb4b3be5341bd4551991eaa0ba5 100755 (executable)
@@ -13,6 +13,7 @@ use Perl2Epics;
 use HADES::TrbNet;
 use HPlot;
 
+
 my $timer = 0;
 my @colors = ("#000000", "#ff0000","#00ff00","#0000ff","#cccc00","#009955");
 my @names = qw( S1 S2 S3 S4 S5 S6);
@@ -22,6 +23,9 @@ if(!$connect_status) {
   die("could not connect to trbnetd");
 }
 
+my $currenterr = 0;
+my $currenterrtimer = 0;
+my $spikeString = "";
 
 ###########
 #Change 3 for-loops to include all four planes again!
@@ -35,10 +39,10 @@ foreach my $s (0..1) {
     $plot[$p*2+$s]->{name}    = "P".$p.($s?'F':'C')."I";
     $plot[$p*2+$s]->{file}    = "files/MDCHV".$plot[$p*2+$s]->{name};
     $plot[$p*2+$s]->{entries} = 360;
-    $plot[$p*2+$s]->{xscale}  = 12;
+    $plot[$p*2+$s]->{xscale}  = 1;
     $plot[$p*2+$s]->{type}    = HPlot::TYPE_HISTORY;
     $plot[$p*2+$s]->{output}  = HPlot::OUT_PNG;
-    $plot[$p*2+$s]->{xlabel}  = "Minutes";
+    $plot[$p*2+$s]->{xlabel}  = "Seconds";
     $plot[$p*2+$s]->{ylabel}  = ($s?'F':'C')." Current";
     $plot[$p*2+$s]->{sizex}   = 700;
     $plot[$p*2+$s]->{sizey}   = 240;
@@ -56,10 +60,10 @@ foreach my $s (0..1) {
     $plot[$p*2+$s+8]->{name}    = "P".$p.($s?'F':'C')."V";
     $plot[$p*2+$s+8]->{file}    = "files/MDCHV".$plot[$p*2+$s+8]->{name};
     $plot[$p*2+$s+8]->{entries} = 360;
-    $plot[$p*2+$s+8]->{xscale}  = 12;
+    $plot[$p*2+$s+8]->{xscale}  = 1;
     $plot[$p*2+$s+8]->{type}    = HPlot::TYPE_HISTORY;
     $plot[$p*2+$s+8]->{output}  = HPlot::OUT_PNG;
-    $plot[$p*2+$s+8]->{xlabel}  = "Minutes";
+    $plot[$p*2+$s+8]->{xlabel}  = "Seconds";
     $plot[$p*2+$s+8]->{ylabel}  = ($s?'F':'C')." Voltage";
     $plot[$p*2+$s+8]->{sizex}   = 700;
     $plot[$p*2+$s+8]->{sizey}   = 240;
@@ -75,8 +79,8 @@ foreach my $s (0..1) {
     }
   }
 
-
-for(my $i = 1; $i<=4; $i++) {
+### default HV channels:
+ for(my $i = 1; $i<=4; $i++) {
   for(my $j = 1; $j<=6; $j++) {
     my $s = sprintf("HAD:MDC:HV:P%i:S%i:F:vmon",$i,$j);
     Perl2Epics::Connect("$i-$j-0-V",$s);
@@ -84,15 +88,33 @@ for(my $i = 1; $i<=4; $i++) {
     Perl2Epics::Connect("$i-$j-1-V",$s);
     $s = sprintf("HAD:MDC:HV:P%i:S%i:F:imon",$i,$j);
     Perl2Epics::Connect("$i-$j-0-I",$s);
-    $s = sprintf("HAD:MDC:HV:P%i:S%i:C:imon",$i,$j);
+   $s = sprintf("HAD:MDC:HV:P%i:S%i:C:imon",$i,$j);
     Perl2Epics::Connect("$i-$j-1-I",$s);
     }
   }
+####################################################################
+## CW 2.Oct 2014 individual layer HV:
+for(my $i = 1; $i<=4; $i++) {
+  for(my $j = 1; $j<=6; $j++) {
+    my $s = sprintf("HAD:MDC:HV:Ind%i:F%i:vmon",$i,$j);
+    Perl2Epics::Connect("Ind-$i-$j-0-V",$s);
+    if($j == 6) { $s = sprintf("HAD:MDC:HV:Ind%i:C0%i:vmon",$i,$j);}
+    else { $s = sprintf("HAD:MDC:HV:Ind%i:C%i:vmon",$i,$j);}
+    Perl2Epics::Connect("Ind-$i-$j-1-V",$s);
+    $s = sprintf("HAD:MDC:HV:Ind%i:F%i:imon",$i,$j);
+    Perl2Epics::Connect("Ind-$i-$j-0-I",$s);
+    if($j == 6) { $s = sprintf("HAD:MDC:HV:Ind%i:C0%i:imon",$i,$j);}
+    else { $s = sprintf("HAD:MDC:HV:Ind%i:C%i:imon",$i,$j);}
+    Perl2Epics::Connect("Ind-$i-$j-1-I",$s);
+    }
+  }
+#####################################################################
+
 print "Connected.\n";
 
 while(1) {
   my $data = Perl2Epics::GetAll();
-  my $str = Hmon::MakeTitle(13, 6, "MDC HV", 1, "");
+  my $str = Hmon::MakeTitle(18, 12, "MDC HV", 1, "");
     $str .= "<table class=\"rates textbox\">"; #<div id=\"logbox\" class=\"textbox\" >
     $str .= "<tr><th><th colspan=1>Sector 1<th colspan=1>Sector 2<th colspan=1>Sector 3<th colspan=1>Sector 4<th colspan=1>Sector 5<th colspan=1>Sector 6"; 
   for(my $i = 1; $i<=4; $i++) {
@@ -108,16 +130,44 @@ while(1) {
         $curr = -1 unless defined $curr;
         HPlot::PlotAdd("P".($i-1).(($v)?'C':'F')."I",$curr,$s-1);
         HPlot::PlotAdd("P".($i-1).(($v)?'C':'F')."V",$volt,$s-1);
-        my $tmp .= sprintf(" %4i V | %2.2f uA",$volt,$curr);
+        my $tmp .= sprintf(" %4i V | %3.2f uA",$volt,$curr);
         $tmp =~ s/\s/&nbsp;/gi;
         $str .= "<td title=\"$tv / $tc\">".$tmp;
+       
         }
       }
 
     #$str .= "<tr><th colspan=7>&nbsp;\n";      
     }  
+  $str .= "</table>\n ";#</div
+  #~ $str .= Hmon::MakeFooter();
+
+####################################################################
+## CW 20. June 2016 individual layer HV:
+ my $data = Perl2Epics::GetAll();
+  #~ my $str = Hmon::MakeTitle(13, 6, "MDC indv. HV", 1, "");
+    $str .= "<br><table class=\"rates textbox\">"; #<div id=\"logbox\" class=\"textbox\" >
+    $str .= "<tr><th><th colspan=1>Layer 1<th colspan=1>Layer 2<th colspan=1>Layer 3<th colspan=1>Layer 4<th colspan=1>Layer 5<th colspan=1>Layer 6/0"; 
+   for(my $i = 1; $i<=4; $i++) {
+      $str .= "<tr><tr><th colspan=7>Chamber $i\n";      
+    for(my $v = 0; $v<=1; $v++) {
+      $str .= "<tr><td>".$layerlabel[$v]."&nbsp;";
+      for(my $s = 1; $s<=6; $s++) {
+        my $voltI = $data->{"Ind-$i-$s-$v-V"}->{val};
+        my $currI = $data->{"Ind-$i-$s-$v-I"}->{val};
+        my $tvI   = strftime("%H:%M:%S",localtime($data->{"Ind-$i-$s-$v-V"}->{tme} || 0));
+        my $tcI   = strftime("%H:%M:%S",localtime($data->{"Ind-$i-$s-$v-I"}->{tme} || 0));
+        $voltI = -1 unless defined $voltI;
+        $currI = -1 unless defined $currI;
+        my $tmpI .= sprintf(" %4i V | %3.2f uA",$voltI,$currI);
+        $str .= "<td title=\"$tvI / $tcI\">".$tmpI;
+        }
+      }
+    }  
   $str .= "</table>\n";#</div
-  $str .= Hmon::MakeFooter();
+ $str .= Hmon::MakeFooter(); 
+####################################################################
+
 
   if(!($timer%1)) {
     Hmon::WriteFile("MDCHV", $str);  
@@ -131,6 +181,7 @@ while(1) {
       }
     }
     
+#  my $logString = strftime("%Y.%m.%d %H:%M:%S",localtime())."\t";
   my @mdcHvMin;
   my @mdcHvMax;
   my $qastate = QA::OK;
@@ -138,12 +189,21 @@ while(1) {
     for my $s (1..6) {
       for my $i (0..1) {
         my $volt = $data->{"$p-$s-$i-V"}->{val};
+        my $current = $data->{"$p-$s-$i-I"}->{val};
         if(! defined $mdcHvMin[$p] || $mdcHvMin[$p] > $volt) {
           $mdcHvMin[$p] = $volt;
           }
         if(! defined $mdcHvMax[$p] || $mdcHvMax[$p] < $volt) {
           $mdcHvMax[$p] = $volt;
           }
+#       if($p>2) {
+#      $logString .= " ".$volt." ".$current."  ";
+#      }
+       if($current > 160) {
+                $spikeString .= "P$p S$s F/C $i: HV = ".$volt." , I = ".$current."  -  ".localtime()."\n"; 
+         $currenterr++;
+         }
         }
       }
     if($mdcHvMax[$p] > $QA::MdcNominalHV[$p-1] + $QA::MdcHVOffsetLimits[0]) {$qastate = max($qastate,QA::WARN);}
@@ -153,13 +213,38 @@ while(1) {
     if($mdcHvMin[$p] < $QA::MdcNominalHV[$p-1] - $QA::MdcHVOffsetLimits[1]) {$qastate = max($qastate,QA::WARN_2);}
     if($mdcHvMin[$p] < $QA::MdcNominalHV[$p-1] - $QA::MdcHVOffsetLimits[2]) {$qastate = max($qastate,QA::ERROR);}
     }
-    
+  $qastate = min($qastate,$QA::MdcHvOff?QA::NOTE:200);    
   my $value    = sprintf("%.1f/%.1f/%.1f/%.1f",$mdcHvMin[1]/1000.,$mdcHvMin[2]/1000.,$mdcHvMin[3]/1000.,$mdcHvMin[4]/1000.);
   my $longtext = "MDC high voltage in all four planes".
                  "<br>Minimum [V]: ".$mdcHvMin[1]." / ".$mdcHvMin[2]." / ".$mdcHvMin[3]." / ".$mdcHvMin[4].
                  "<br>Maximum [V]: ".$mdcHvMax[1]." / ".$mdcHvMax[2]." / ".$mdcHvMax[3]." / ".$mdcHvMax[4].
                  "<br>Nominal [V]: ".$QA::MdcNominalHV[0]." / ".$QA::MdcNominalHV[1]." / ".$QA::MdcNominalHV[2]." / ".$QA::MdcNominalHV[3];
   QA::WriteQALog($flog,"other","mdcinvalid",10,$qastate,"MDC HV",$value,$longtext);  
+
+
+
+  if($currenterr > 0 ) {
+      $currenterrtimer++;
+       if( $currenterrtimer == 10  && $currenterr < 6){ 
+                Hmon::SendEmail('c.wendisch@gsi.de',"MDC Current Spike","Currents in MDC was spiking in\n$spikeString");
+               $currenterrtimer = 0;
+       }
+       if ($currenterrtimer == 20  && $currenterr >= 6  ){
+                 Hmon::SendEmail('c.wendisch@gsi.de',"MDC OVC","Current in MDC was too high in\n$spikeString");
+                $currenterrtimer = 0;
+        }    
+       if($currenterrtimer==0) {
+                               $currenterr = 0;
+                               $spikeString = "";  
+                               }
+    }
+  my $fh;
+  
+ # $logString .= "\n";  
+ # open($fh, ">>",Hmon::HMONDIR."/archive/mdcCurrentslog.csv");
+ # print $fh $logString;
+ # close $fh;
+
   $timer++;
   sleep(1);
   }
index 1203bedc3e977cbc8b14f2fcb15fbf0bd02c7743..44892666495398d280198bc5b53be31f3a07ced5 100755 (executable)
@@ -262,33 +262,31 @@ while(1) {
 #      $presserr++;
 #      }
     
-  for my $i (1..3) {
+  for my $i (1..3) { # CW 1.4.2016 : only for Plane 1 to 3, as pressure values in plane 4 S5&6 are wrong - readout failure  
+planes
    for my $j (1..6) { 
-    if($data->{"p$i$j"}->{val} > 50 ) {
-       $presserr++;
+          my $pressure_now = $data->{"p$i$j"}->{val}; 
+    if(  $pressure_now < 1.0 || $pressure_now > 55) {
+         # $presserr++;
        }
     }
    }
-  if($presserr >= 3) {
-    if($presserrtimer == 0) { 
+  if($presserr > 0) {
+       $presserrtimer++;
+    if($presserrtimer >  3 && $presserr > 3) { 
       $presserr = 0;
       my $valstr = "";
-        $valstr.="CO2 concentration Plane1: ".$data->{"p1CO2"}->{val}." %  \n";
-        $valstr.="CO2 concentration Plane2: ".$data->{"p2CO2"}->{val}." %  \n";
-      for my $i (1..3) {
-       for my $j (1..6) {
-        $valstr.="P$i S$j: ".$data->{"p$i$j"}->{val}."\n";
+         $valstr.="CO2 concentration Plane1: ".$data->{"p1CO2"}->{val}." %  \n";
+         $valstr.="CO2 concentration Plane2: ".$data->{"p2CO2"}->{val}." %  \n";
+      for my $i (1..4) {
+           for my $j (1..6) {
+          $valstr.="P$i S$j: ".$data->{"p$i$j"}->{val}."\n";
         }
        }
-      $presserrtimer = 90;
-      Hmon::SendEmail('c.wendisch@gsi.de',"Warning: MDC Over-Pressure","Pressures in MDC are too high:  \n$valstr");
-      }
-    else {
-      $presserrtimer--;
-      }
+      $presserrtimer = 0;
+  #    Hmon::SendEmail('c.wendisch@gsi.de',"Warning: MDC Over-Pressure","Pressures in MDC are too high:  \n$valstr");
+<      }
     }
-
-    
   $timer++;
   sleep(10);
   }
index 6d9ef1fba7389192a4f5e81bc92cd4664c94417e..02c21b6bb43203fe6a73e23f3422cdb8b5573865 100755 (executable)
@@ -44,66 +44,69 @@ HPlot::PlotInit($plot2);
 
 while(1) {
 
-             
-  open(PIONLOG, Hmon::HMONDIR."hmon_permanent_tail -F ".Hmon::HMONDIR."pion/scmon.log|");
+    
+    open(PIONLOG, Hmon::HMONDIR."hmon_permanent_tail -F ".Hmon::HMONDIR."pion/scmon.log|");
 
-  my $readlines = 0;
-  my $str = "";
-  my $oldtime = time();
-  my $a;
+    my $readlines = 0;
+    my $str = "";
+    my $oldtime = time();
+    my $a;
 
-  while($a = <PIONLOG>) {
-    $str  = Hmon::MakeTitle(9,11,"PionSupplies",1);
-    my @val = split(/\s+/,$a);
+    while($a = <PIONLOG>) {
+       $str  = Hmon::MakeTitle(9,11,"PionSupplies",1);
+       my @val = split(/\s+/,$a);
 
-    #$str .= strftime("%H:%M:%S",localtime($val[0]));
-    $str .= "<br><table style='margin:auto' class=\"rates \"><tr><th><th>HV (V)<th>HV (&mu;A)<th>Temp. (&degC)";
-    $str .= sprintf("<tr><th>Pion1:<td>%.1fV<td>%.3fuA<td>%.1f&degC",$val[3],$val[4],$val[47]);
-    $str .= sprintf("<tr><th>Pion2:<td>%.1fV<td>%.3fuA<td>%.1f&degC",$val[25],$val[26],$val[53]);
-    $str .= "</table>";
-    $str .= qq@<img src="%ADDPNG files/PionHV.png%" type="image/png"><br>\n@;
-    $str .= qq@<img src="%ADDPNG files/PionHVCurrent.png%" type="image/png">\n@;
-    $str .= Hmon::MakeFooter();
-    Hmon::WriteFile("PionSupplies",$str);   
-    
-    HPlot::PlotAdd('HighVoltage',$val[3],0);
-    HPlot::PlotAdd('HighVoltage',$val[25],1);
-    HPlot::PlotDraw("HighVoltage");  
-    
-    HPlot::PlotAdd('HVCurrent',$val[4],0);
-    HPlot::PlotAdd('HVCurrent',$val[26],1);
-    HPlot::PlotDraw("HVCurrent");  
-    
-    
-    my $shorttext = sprintf("%.1f/%.3f",$val[3],$val[4]);
-    my $longtext = sprintf("Pion 1: %.1f V / %.4fuA",$val[3],$val[4]);
-    my $state = QA::OK;
-       $state = QA::WARN if($val[3]<140);    
-       $state = QA::WARN if($val[4] > 1.0);
-       $state = QA::FATAL if($val[4] > 5);
-       
-    QA::WriteQALog($flog, "pion", "HV", 30,
-       $state, 'Pion 0 HV', $shorttext, $longtext);
+       #$str .= strftime("%H:%M:%S",localtime($val[0]));
+       $str .= "<br><table style='margin:auto' class=\"rates \"><tr><th><th>HV (V)<th>HV (&mu;A)<th>Temp. (&degC)";
+       $str .= sprintf("<tr><th>Pion1:<td>%.1fV<td>%.3fuA<td>%.1f&degC",$val[3],$val[4],$val[47]);
+       $str .= sprintf("<tr><th>Pion2:<td>%.1fV<td>%.3fuA<td>%.1f&degC",$val[25],$val[26],$val[53]);
+       $str .= "</table>";
+       $str .= qq@<img src="%ADDPNG files/PionHV.png%" type="image/png"><br>\n@;
+       $str .= qq@<img src="%ADDPNG files/PionHVCurrent.png%" type="image/png">\n@;
+       $str .= Hmon::MakeFooter();
+       Hmon::WriteFile("PionSupplies",$str);   
+       
+       HPlot::PlotAdd('HighVoltage',$val[3],0);
+       HPlot::PlotAdd('HighVoltage',$val[25],1);
+       HPlot::PlotDraw("HighVoltage");  
+       
+       HPlot::PlotAdd('HVCurrent',$val[4],0);
+       HPlot::PlotAdd('HVCurrent',$val[26],1);
+       HPlot::PlotDraw("HVCurrent");  
+       
+       
+       my $shorttext = sprintf("%.1f/%.3f",$val[3],$val[4]);
+       my $longtext = sprintf("Pion 1: %.1f V / %.4fuA",$val[3],$val[4]);
+       my $state = QA::OK;
+       $state = QA::WARN if($val[3]<140);    
+       $state = QA::WARN if($val[4] > 1.0);
+       $state = QA::FATAL if($val[4] > 5);
+       
+       QA::WriteQALog($flog, "pion", "HV", 30,
+                      $state, 'Pion 0 HV', $shorttext, $longtext);
 
-    $shorttext = sprintf("%.1f/%.3f",$val[25],$val[26]);
-    $longtext = sprintf("Pion 2: %.2f V / %.3fuA",$val[25],$val[26]);
-    $state = QA::OK;
-    $state = QA::WARN if($val[25]<140);    
-    $state = QA::WARN if($val[26] > 1.5);
-    $state = QA::FATAL if($val[26] > 5);
-       
-    QA::WriteQALog($flog, "pion", "HVcurr", 30,
-       $state, 'Pion 1 HV', $shorttext, $longtext);
+       $shorttext = sprintf("%.1f/%.3f",$val[25],$val[26]);
+       $longtext = sprintf("Pion 2: %.2f V / %.3fuA",$val[25],$val[26]);
+       $state = QA::OK;
+       $state = QA::WARN if($val[25]<140);    
+       $state = QA::WARN if($val[26] > 1.5);
+       $state = QA::FATAL if($val[26] > 5);
+       
+       QA::WriteQALog($flog, "pion", "HVcurr", 30,
+                      $state, 'Pion 1 HV', $shorttext, $longtext);
 
-    $shorttext = sprintf("%.1f&deg; / %.1f&deg;",$val[47],$val[53]);
-    $longtext = sprintf("Pion 1: is %.1f&deg;, soll %.1f&deg;<br>Pion 2: is %.1f&deg;, soll %.1f&deg;",$val[47],$val[49],$val[53],$val[55]);
-    $state = QA::OK;
-    $state = QA::WARN if($val[47]>-15 || $val[53]>-15);
-    
-    
-    QA::WriteQALog($flog, "pion", "cooling", 120,
-       $state, 'Pion Cool', $shorttext, $longtext);       
-       
+       $shorttext = sprintf("%.1f&deg; / %.1f&deg;", $val[47], $val[53]);
+       $longtext = sprintf("Pion 1: is %.1f&deg;, soll %.1f&deg;<br>Pion 2: is %.1f&deg;, soll %.1f&deg;", $val[47], $val[49], $val[53], $val[55]);
+       $state = QA::OK;
+       $state = QA::WARN if ($val[47] >-15 || $val[53] >- 15);
+       if ($val[50] != 1 || $val[56] != 1) {
+           $longtext = $longtext . sprintf("<br>--------- CHILLER OFFLINE ERROR ---------<br> Pion1: %s<br>Pion2: %s", \
+                                           $val[50] != 1 ? "OFF" : "ON", $val[56] != 1 ? "OFF" : "ON");
+           $state = QA::ERROR;
+       }
+       
+       QA::WriteQALog($flog, "pion", "cooling", 120,
+                      $state, 'Pion Cool', $shorttext, $longtext);       
     }
 }
 
index 71f7ab93931e7c40278774e036c854f5f8682192..941e198a15655df33050359592ca7c3b1376ef31 100755 (executable)
@@ -95,8 +95,8 @@ while(1) {
   $str .= "<tr><th>Volt.";
   for(my $v = 1; $v<=6; $v++) {
     $str .= sprintf("<td> %i V\n",$data->{"U$v"}->{val} || -1);
-    $min = min($min,$data->{"U$v"}->{val}||1E6);
-    $max = max($max,$data->{"U$v"}->{val}||0);
+    $min = min($min,$data->{"U$v"}->{val}||-1);
+    $max = max($max,$data->{"U$v"}->{val}||-1);
     }
   $str .= "</table>\n";
   $str .= qq@<img src="%ADDPNG files/RichCurr.png%" type="image/png">\n@;
@@ -124,33 +124,35 @@ while(1) {
   else {
     $errortimer = 0;
     }
-  if($errortimer >= 800) {
+  if($errortimer >= 800 && !$QA::RichHvOff) {
     $qastate = QA::ERROR;
     if (!($errortimer%200)) {
       Hmon::Speak('richhv', "Rich high voltage error");
       }
     }
   
+$qastate = QA::NOTE if ($QA::RichHvOff == 1);
+
   if( $timer % (4*$OVERCURRENT_period) == 0) {
       $value    = sprintf("%.2f / %.2f kV",$min/1000,$max/1000);
       $longtext = sprintf("Averaged current in RICH HV: %i uA",$current_average);
-      $longtext.= sprintf("<br>HV settings: %i, %i, %i, %i, %i, %i V", $data->{"U1"}->{val}, $data->{"U2"}->{val},
-                                                                       $data->{"U3"}->{val}, $data->{"U4"}->{val},
-                                                                       $data->{"U5"}->{val}, $data->{"U6"}->{val});
+      $longtext.= sprintf("<br>HV settings: %i, %i, %i, %i, %i, %i V", $data->{"U1"}->{val}||-1, $data->{"U2"}->{val}||-1,
+                                                                       $data->{"U3"}->{val}||-1, $data->{"U4"}->{val}||-1,
+                                                                       $data->{"U5"}->{val}||-1, $data->{"U6"}->{val}||-1);
       #print "current_average: $current_average, sum: $current_sum\n";
-
+  
       $current_sum = 0;
       QA::WriteQALog($flog,"other","rich",30,$qastate,"RICH HV",$value,$longtext);
   }
 
   for(my $i = 1; $i<=6;$i++) {
-    HPlot::PlotAdd("RichCurr",$data->{"I$i"}->{val},$i-1);
+    HPlot::PlotAdd("RichCurr",$data->{"I$i"}->{val}||-1,$i-1);
 
     }
   if($timer%8 == 0) {
     HPlot::PlotDraw("RichCurr");
     for(my $i = 1; $i<=6;$i++) {
-      HPlot::PlotAdd("RichCurrLong",$data->{"I$i"}->{val},$i-1);
+      HPlot::PlotAdd("RichCurrLong",$data->{"I$i"}->{val}||-1,$i-1);
       }
     HPlot::PlotDraw("RichCurrLong");
     }
index d85bca4c36876cce431017a754936d5ddb6cf5ff..2b5da0f2a2ba2dd61aed1a2c7db32498ee1c35b3 100755 (executable)
@@ -11,6 +11,10 @@ use Perl2Epics;
 
 my @names;
 my $errorcounter;
+
+
+#HAD:FWHV:G7:status:alive:roc:average
+
 my @variables = qw(
 
 HAD:TOFHV:G1:status:alive:roc:average
@@ -19,7 +23,6 @@ HAD:TOFHV:G3:status:alive:roc:average
 HAD:TOFHV:G4:status:alive:roc:average
 HAD:TOFHV:G5:status:alive:roc:average
 HAD:TOFHV:G6:status:alive:roc:average
-HAD:FWHV:G7:status:alive:roc:average
 HAD:RPCHV:G8:status:alive:roc:average
 HAD:RPCHV:G9:status:alive:roc:average
 HAD:RICH:HV:G25:status:alive:roc:average
@@ -99,7 +102,9 @@ for my $v (@variables) {
   Perl2Epics::Connect($name,$v);
   }
 
-sleep(10);  
+sleep(10);
+Perl2Epics::GetAll();
+sleep(20);  
   
 while(1) {
   my $qastate = QA::OK;
index c1e0f042557af0f92295e4edce76f79073a294b8..cc311fce3e5911bf8b23c29a8b6179c5f91671f3 100755 (executable)
@@ -13,7 +13,7 @@ echo "  <Hmon>     No tunnel found, digging new one";
 ssh -f -R 8888:hades33.gsi.de:80 -R 3060:hades33.gsi.de:80 -R 8889:hades33.gsi.de:1234 -R 9999:lxhadeb06.gsi.de:80  cerberus.x-matter.uni-frankfurt.de -N &
 fi
 
-killall speakdaemon.pl
+killall -f speakdaemon.pl
 cd /home/hadaq/trbsoft/hadesdaq/hmon/
 
  # cd permanent