]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
update hmon scripts
authorhadaq <jan@lxhadeb07>
Sun, 4 Feb 2024 12:55:51 +0000 (13:55 +0100)
committerhadaq <jan@lxhadeb07>
Sun, 4 Feb 2024 12:55:51 +0000 (13:55 +0100)
32 files changed:
hmon/Hmon.pm
hmon/QA.pm
hmon/doc/endp-rich.htt
hmon/doc/server-ip.htt [new file with mode: 0644]
hmon/hmon_busynew.pl
hmon/hmon_cosmic_alarms.pl [new file with mode: 0644]
hmon/hmon_ecal_recover_dead_slow_channels.pl [changed mode: 0644->0755]
hmon/hmon_ecalresettdcchannels.pl [new file with mode: 0755]
hmon/hmon_endpoints.pl
hmon/hmon_lvl1mismatch_autorestart.pl [moved from hmon/hmon_lvl1mismatch.pl with 52% similarity]
hmon/hmon_mdc_ratecheck.pl
hmon/hmon_mdc_temp.pl
hmon/hmon_mdc_voltage.pl
hmon/hmon_onlineqa.pl
hmon/hmon_startrate.pl
hmon/hmon_tdc_totratio.pl [new file with mode: 0755]
hmon/hmon_trgerr.pl
hmon/hmon_trgsource.pl
hmon/hmon_waterfall.pl
hmon/index.cgi
hmon/openqawindow.cgi [new file with mode: 0755]
hmon/permanent/hmon_cpu.pl
hmon/permanent/hmon_ecalhv.pl
hmon/permanent/hmon_fwhv.pl
hmon/permanent/hmon_logbook.pl
hmon/permanent/hmon_magnet.pl
hmon/permanent/hmon_open_ssh_master_channels.pl
hmon/permanent/hmon_spillmon.pl
hmon/start.sh
hmon/styles.css
hmon/stylesmonitor.css [new file with mode: 0644]
spillmon/old/startup.sh [moved from spillmon/startup.sh with 100% similarity]

index 1e8dd95244bd3741784ca3b78727759e72bc39aa..23c953b03c3b3486c2b265646d58fcc7a58a1c4d 100644 (file)
@@ -189,6 +189,68 @@ sub findcolor {
   return $ret;
 }
 
+sub findcolorVoltages {
+  my ($v,$fmin,$fmax,$min,$max,$print) = @_;
+  my ($r,$g,$b);
+  $v = 0 unless defined $v;
+  my $step = (($fmax-$fmin)/655.);
+#   print ("$v,$fmin,$fmax,$min,$max,$step,".($v/$step)."\n") if $print;
+
+  my $minstep = 655-($min-$fmin)/$step;
+  my $maxstep = 655-($max-$fmin)/$step;
+  
+  if ($v == 0) {
+    $r = 0;
+    $g = 0;
+    $b = 0;
+    } 
+  else 
+    {
+    $v -= $fmin;
+    $v  = 655-$v/$step if $step;
+    my $realv = $v;
+#     if($v<$minstep && $v>$maxstep) {
+#       $r = 0xcc;
+#       $g = 0xcc;
+#       $b = 0xcc;
+#       }
+#     els
+    if ($v<156) {
+      $r = 0;
+      $g = $v+100;
+      $b = 0;
+    } elsif ($v<412) {
+      $v -= 156;
+      $r = $v;
+      $g = 255;
+      $b = 0;
+    } else {
+      $v -= 412;
+      $r = 255;
+      $g = 255-$v;
+      $b = 0;
+    }
+    
+    if($realv<$minstep && $realv>$maxstep) {
+     
+      my $f = 0.3;
+      my $L = 0.3*$r + 0.6*$g + 0.1*$b;
+      my $new_r = $r + $f * ($L - $r);
+      my $new_g = $g + $f * ($L - $g);
+      my $new_b = $b + $f * ($L - $b);
+      $r = $new_r;$g = $new_g;$b = $new_b;
+      $r = ($r-0xff)/5+0xf8;
+      $g = ($g-0xff)/4+0xf0;
+      $b = ($b-0xff)/5+0xf0;
+#       print("$r,$g,$b\n") if $print;
+      }
+  }
+
+  my $ret = sprintf("#%02x%02x%02x",$r%256,$g%256,$b%256);
+
+  return $ret;
+}
+
 ###############################################################################
 #  Make a nice colored drawing of MDC
 ###############################################################################
@@ -249,6 +311,24 @@ sub DrawScale {
   return $str;
 }
 
+sub DrawScaleVoltages {
+  my ($fmin,$fmax,$min,$max,$steps) = @_;
+  my $str;
+  #    print "$min $max $steps\n";
+  return "" if $max == $min;
+  $str .= "<table class=\"scale\"><tr>";
+  $str .= sprintf("<td style=\"background-color:#000\">");
+  $str .= sprintf("<td class=\"label\">%#2.3G",$fmin);
+  for (my $i = 1;$i<$steps;$i++) {
+    my $stp = $fmin + ($fmax-$fmin)/$steps*$i;
+    $str .= sprintf("<td style=\"background-color:%4s;\" title=\"%#2.3G\">",Hmon::findcolorVoltages($stp,$fmin,$fmax,$min,$max,1),$stp);
+  }
+  $str .= sprintf("<td class=\"label\">%#2.3G",$fmax);
+  $str .= "</table>\n";
+
+  return $str;
+}
+
 ###############################################################################
 # Makes Diffs to last stored value.
 # Loops over last plane/sector/board
index 9409b0687afc9014ed85279f4355d480d8a0895e..c2012ad2f40c693097de1c21f0ef5d59f76799bd 100644 (file)
@@ -40,7 +40,7 @@ our $entries->{'cats'} = ["main",
                           "hv",
                           "hv2",
                           "misc",
-                         "misc2",
+                          "misc2",
 
 ];
 
@@ -48,8 +48,8 @@ our $entries->{'cats'} = ["main",
 $entries->{'main'}    = ['time', 'rate','beamabort','up','spillcount'];
 $entries->{'daq'}     = ['trbnet', 'timeouts', 'busy','readout','outofsync'];
 $entries->{'trg'}     = ['spill', 'accepted', 'source','pt1rate',  'start']; 
-$entries->{'rate'}    = ['pt1','pt2','pt3','here','pt8'];
-$entries->{'server'}  = ['fill', 'cpu', 'be', 'dragons', 'onlineqa']; #icinga, pwrsup
+$entries->{'rate'}    = ['pt1','pt2','pt3','hic sunt','pt8'];
+$entries->{'server'}  = ['fill', 'cpu', 'ip', 'dracones', 'onlineqa']; #icinga, pwrsup
 $entries->{'eb'}      = ['run', 'rate','bytes', 'lostevt', 'errbits'];
 $entries->{'mdc'}     = ['token', 'blocked', 'temp', 'linkqual', 'voltage'];
 $entries->{'endp'}    = ['mdc','rich', 'tof', 'rpc', 'other'];
@@ -92,7 +92,7 @@ our @MdcTempLimits    = (75, 80, 85);
 our @EcalTempLimits    = (55, 60, 65);
 our @StartTempLimits    = (55, 60, 65);
 our @ItofTempLimits    = (55, 60, 65);
-our @RichInnerTempLimits = (34.3,35.2,36);
+our @RichInnerTempLimits = (37.5,38.5,39);
 our @TrgErrLimits     = (100, 1000, 10000);
 our @CPULimits        = (95, 100, 100);
 our @TimeoutLimits    = (0, 0, 1);
@@ -114,7 +114,7 @@ our @MdcTokenMissLimits = (10,50,100);
 # Modification of 8.Feb2022 P2S3 supplied by different HV channels, so taken out here:
 our $MdcNominalHV = [[1750,1750,1750,1750,1750,1750],[1770,1790,0,1770,1770,1770],[1900,1900,1900,1900,1900,1900],[2150,2150,2150,2150,2150,2150]];
 our $MdcHVOffsetLimits = [[5,10,255],[5,30,255],[5,10,255],[10,110,325]];
-our @EcalHvLimits = (1000,990,950);
+our @EcalHvLimits = (978,960,950);
 our @RpcHvLimits = (12,12,12);
 our @TofHvLimits = (764,760,759);
 our @FwHvLimits = (280,250,200);
index 05b79c096f391fa8b1c96e88f167f65ef8939e48..e09d42cef8eb2151f38f96825905753247d5ab18 100644 (file)
@@ -9,7 +9,7 @@ modules are missing.
 <li>Try a Resync DiRich
 <li>Do a DAQ restart 
 <li>Do another DAQ restart 
-<li>If this doesn't help, use "Reboot DiRich", "Reboot Rich Combiner" and a DAQ restart
+<li>If this doesn't help, use "Reboot -&gt; Rich" and a DAQ restart
 <li>If many boards are missing (>100), check RICH power supplies
 <li>If a hub board (with 82xx address) is missing as well and a DAQ restart does not help, do a RICH power cycle
 </ul>
diff --git a/hmon/doc/server-ip.htt b/hmon/doc/server-ip.htt
new file mode 100644 (file)
index 0000000..dc951fb
--- /dev/null
@@ -0,0 +1,12 @@
+<h3>Network Connections of DAQ hubs</h3>
+Event data is sent from the DAQ to eventbuilders over normal Ethernet.
+This checks if all the DAQ boards do have a working link.
+
+If a link is not working, data from this subsystem will not reach the Eventbuilders
+preventing them from writing files.
+
+<h4>Error Handling</h4>
+Do a "fix missing IP" followed by a DAQ restart<br>
+If this doesn't help and some endpoints are missing (with an address in the 0x8000 range), a power cycle of that system might be needed.
+
+
index 2ee9274cc3f79e75a50e02d37065366950f99833..fe254adb216f628abcc52dcccb8da79151dc65ee 100755 (executable)
@@ -32,7 +32,7 @@ $plot->{titles}->[8] = "Start";
 $plot->{xlabel}  = "Time";
 $plot->{ylabel}  = "Deadtime (%)";
 $plot->{sizex}   = 690;
-$plot->{sizey}   = 320;
+$plot->{sizey}   = 280;
 $plot->{nokey}   = 0;
 $plot->{xscale}  = 8;
 $plot->{ymin}    = -1;
@@ -61,7 +61,7 @@ HPlot::PlotInit({
   bargap   => 5,
   });
 
-my  $str = Hmon::MakeTitle(9,7,"Busy Times",0);
+my  $str = Hmon::MakeTitle(9,6,"Busy Times",0);
   $str .= qq@<img src="%ADDPNG files/BusyTimes.png%" type="image/png">@;
   $str .= Hmon::MakeFooter();
   Hmon::WriteFile("busyhist",$str);
diff --git a/hmon/hmon_cosmic_alarms.pl b/hmon/hmon_cosmic_alarms.pl
new file mode 100644 (file)
index 0000000..57776cb
--- /dev/null
@@ -0,0 +1,208 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Data::Dumper;
+use HADES::TrbNet;
+use List::Util qw[min max];
+use Email::Sender::Simple qw(sendmail);
+use Email::Simple;
+use Email::Simple::Creator;
+
+use Log::Log4perl qw(get_logger);
+
+################################
+# To disable script: just uncomment
+# the following line with "exit"
+################################
+exit;
+################################
+
+
+my $HADESDAQ="/home/hadaq/trbsoft/hadesdaq/";
+
+Log::Log4perl::init($HADESDAQ . "hmon/automatic_restart_logger.conf");
+my $logger = get_logger("automatic_restart");
+
+$logger->info("startup");
+
+print STDERR "restarted. The log file is here: 
+/home/hadaq/trbsoft/hadesdaq/hmon/logs/automatic_restart.log
+";
+
+trb_init_ports() or die trb_strerror();
+
+my $mail_fn = $HADESDAQ . "main/alarm_mail_list.txt";
+
+my $number_of_reset_retries = 4;
+
+my $num_of_entries = 10; # loop 10 times and build average
+
+# number of MDC OEPs which are allowed to be misssing before alarm
+my $max_allowed_mdc_oeps_missing = 1;
+
+# minimal average DAQ rate allowed before an alarm
+my $lower_rate_limit = 150;
+my $upper_rate_limit = 450;
+
+
+my $beep_intervall = 10;
+my $mail_intervall = 600;
+
+my $rh_data = {};
+
+my $fh;
+
+open ($fh, "<", "/tmp/mdc_number_missing_boards") || die "could not open /tmp/mdc_number_missing_boards";
+$fh->autoflush(1);
+
+
+my $time_last_beep_alarm=0;
+my $time_last_mail_alarm=0;
+
+my $CURRENT_STATE = "idle";
+my $NEXT_STATE = "idle";
+my $reset_counter = 0;
+my $iterator = 0;
+while (1) {
+
+ STATE_SWITCH:
+  for ($CURRENT_STATE) {
+    if (/idle/) {
+      last STATE_SWITCH;
+    }
+    if (/error/) {
+      last STATE_SWITCH;
+    }
+    if (/reset/) {
+      if ($reset_counter < $number_of_reset_retries
+          && $iterator >= $num_of_entries) {
+        $reset_counter++;
+        $logger->debug("doing a reset now: number of resets: $reset_counter");
+        my $c = q|echo "<div style='position:absolute;top:5px;left:15px;color:red;font-weight:bold;z-index:100'>Doing an automatic TrbNet reset</div>" > ~/trbsoft/hadesdaq/hmon/files/note.htt; ssh lxhadesdaqp 'cd ~/trbsoft/daq/main; ./startup_briccolage.sh dont_restart_monitoring'; rm ~/trbsoft/hadesdaq/hmon/files/note.htt|;
+        #print STDERR localtime() . ": command: $c\n";
+        qx($c);
+        $c=q|ssh lxhadesdaqp '/usr/bin/wget  -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt "http://lxhadeb12:8099/Master/BNET/StartRun/execute?prefix=co&oninit=10"'|;
+        #print STDERR localtime() . ": command: $c\n";
+        qx($c);
+        $iterator = 0;
+        @{$rh_data->{'rates'}} =();
+        last STATE_SWITCH;
+      }
+    }
+  }
+
+  my $daq_rate;
+
+  my $rh_rate = trb_register_read(0x0003, 0xa001) or sleep 5 and next;
+
+  if ( !defined $rh_rate) {
+    $daq_rate = 0;
+  }
+  else {
+    $daq_rate = $rh_rate->{0x0003} & 0xfffff; # only 20bits
+  }
+
+  #print STDERR "daq_rate: $daq_rate\n";
+  push(@{$rh_data->{'rates'}}, $daq_rate);
+  $iterator++;
+  my $num_datapoints = scalar @{$rh_data->{'rates'}};
+  #print STDERR "iterator: $iterator: num_data_points: $num_datapoints\n";
+  if ($iterator >= $num_of_entries) {
+    shift @{$rh_data->{'rates'}};
+  }
+
+  my $sum = 0;
+  foreach (@{$rh_data->{'rates'}}) {
+    $sum += $_;
+  }
+  my $average_rate = $sum / $num_of_entries;
+  #print STDERR "average_rate: $average_rate\n";
+  seek($fh, 0, 0);
+  my $num_mdc_missing = <$fh>;
+  chomp $num_mdc_missing;
+
+  my $state_string = "num missing: $num_mdc_missing , average_rate: $average_rate";
+  #print "state_string: $state\n";
+
+  if($iterator >= $num_of_entries ) {
+    # ($average_rate > $upper_rate_limit) ||
+    if ( ($average_rate < $lower_rate_limit) ||
+          ($num_mdc_missing > $max_allowed_mdc_oeps_missing) ) {
+      my $time = time();
+      $logger->debug("going to state in_error: average_rate: $average_rate, mdc_missing: $num_mdc_missing, iterator: $iterator\n");
+      $NEXT_STATE = "reset";
+      if ($time - $time_last_beep_alarm > $beep_intervall) {
+        $time_last_beep_alarm=$time;
+        $logger->debug("beep: state: $state_string");
+        my $c;
+        $c = q|ssh -X hadesp30 'DISPLAY=:1 xterm -iconic  -e bash -c "~/bin/bell;"' &|;
+        print "command: $c\n";
+        qx($c);
+
+        $c = "mpv --audio-device=auto ~/Documents/foghorn-daniel_simon.mp3 >/dev/null 2>/dev/null </dev/null &";
+        qx($c);
+      }
+
+
+      if ( ($time - $time_last_mail_alarm) > $mail_intervall && $reset_counter >= $number_of_reset_retries) {
+
+        $time_last_mail_alarm = $time;
+
+        my $mail_fh;
+        open ($mail_fh, "<", "$mail_fn") || print "could not open file: $mail_fn\n";
+
+        my @mails = <$mail_fh>;
+        $mail_fh->close;
+        chomp @mails;
+        foreach my $cur_mail (@mails) {
+
+          next if($cur_mail=~/^#/ || $cur_mail=~/^\s+/ || $cur_mail=~/^\n/);
+          next unless $cur_mail=~/\w+@\w+/;
+          $logger->debug("current mail sent to: $cur_mail" );
+          my $reset_counter_str = $reset_counter;
+          my $email = Email::Simple->create(
+                                            header => [
+                                                       To      => "$cur_mail",
+                                                       From    => '"HADES DAQ" <hades33@gsi.de>',
+                                                       Subject => 'Alarm during cosmic data-taking',
+                                                      ],
+                                            body => "Error Condition:
+- MDC-missing-OEPs: $num_mdc_missing
+- average DAQ-rate: $average_rate
+  - lower_limit: $lower_rate_limit: upper_limit: $upper_rate_limit
+  - if it is outside the limits it might be due to some issue in the RPC.
+- number of resets already tried: $reset_counter_str
+",
+                                           );
+
+          sendmail($email)  or $logger->error("error sending mail to $cur_mail");
+
+        } # loop over mail addresses
+
+      }                         # if mail intervall
+
+    }  # error condition
+    else {
+      if($CURRENT_STATE eq "reset") {
+        $NEXT_STATE = "idle";
+        $reset_counter=0;
+        $iterator = 0;
+        @{$rh_data->{'rates'}} =();
+        $logger->info("leaving error state after $reset_counter number of resets: state: $state_string");
+      }
+    }
+
+
+    if($iterator%60==0) {
+      $logger->debug("still alive signal: $state_string, state: $CURRENT_STATE, iterator: $iterator");
+    }
+
+  }                # only if iterator is large enough make error meesages.
+
+  sleep 1;
+  $CURRENT_STATE = $NEXT_STATE;
+} #endless loop
+
+
+
old mode 100644 (file)
new mode 100755 (executable)
index 5cbd086..39a8866
@@ -45,18 +45,32 @@ my $rh_tdc_skip_list = {}; # {6011=>1, 6012=>1, 6013=>1, 6014=>1, 6015=>1, 6050=
 
 while (1) {
 
+  my $first_spill_break_message = 1;
+  while ( ! in_spill() ) {
+    if ($first_spill_break_message == 1) {
+      print STDERR "we are in the spill break, waiting to be in spill again.\n";
+        $first_spill_break_message = 0;
+    }
+    else {
+      print STDERR ". "
+    }
+
+    sleep 1;
+  }
+  print STDERR "\n";
+
   $res = trb_register_read_mem($dirich, $hit_counters_reg + 1 , 0, 48);
+  #print Dumper $res;
   unshift(@res, $res);
   pop @res if ($#res >1);
-  print "res: $#res\n";
-
-  my $final_counter = 0;
+  #print "res: $#res\n";
 
   if($#res==0) {
     sleep 1;
     next;
   }
 
+  my $final_counter = 0;
   my $rh_thresh = {};
   my $rh_affected = {};
   my $rh_final_list = {};
@@ -65,13 +79,17 @@ while (1) {
     foreach my $cur_ep (keys %{$res[0]}) {
       my $rate = $res[0]->{$cur_ep}->[$channel] - $res[1]->{$cur_ep}->[$channel];
       $rh_diffs->{$cur_ep}->[$channel] = $rate;
+      if ($rate > 1E6 and $rate < 2E9) {
+        printf STDERR "rate > 1MHz. Endpoint: %04x, channel: %d => rate: %d\n", $cur_ep, $channel, $rate;
+      }
     }
   }
 
+  #print Dumper $rh_diffs;
   for my $channel (0 .. $last_channel) {
     foreach my $cur_ep (keys %{$rh_diffs}) {
       my $rate = $rh_diffs->{$cur_ep}->[$channel];
-      if ($rate == 0) {
+      if ($rate == 0 or ($rate > 1E6 and $rate < 2E9) ) {
         $rh_affected->{$cur_ep}->[$channel] = 1;
       }
     }
@@ -121,33 +139,59 @@ while (1) {
     }
   }
 
-  print Dumper $rh_final_list;
-  print "thresholds to bw written: $final_counter\n";
-
-  foreach my $cur_ep (keys %$rh_final_list) {
-    foreach my $channel (keys %{$rh_final_list->{$cur_ep}}) {
-      $chain = int($channel/16);
-      $command = ($channel&0xf)<<$REGNR | $WRITE | 0x1ff;
-      #print "write: chain: $chain, Channel: $channel, value: $cur_value\n";
-      Dmon::PadiwaSendCmd($command,$cur_ep, $chain);
+  my $now_string = localtime;
+  print STDERR "\n$now_string\n";
+  if ($final_counter>0) {
+    print STDERR "final list of channels to set high slow threshold and then back to original thereshold stored in padiwa\n";
+    foreach my $cur_ep (keys %$rh_final_list) {
+      printf STDERR "Endpoint: 0x%04x => channels: ", $cur_ep;
+      foreach my $channel (keys %{$rh_final_list->{$cur_ep}}) {
+        print STDERR "$channel, ";
+      }
+      print STDERR "\n";
     }
+
+    #print STDERR Dumper $rh_final_list;
+    print STDERR "number of thresholds to be written: $final_counter\n";
+  }
+  else {
+    print STDERR "no affected channels found.\n";
   }
 
 
-  usleep(30E3);
 
-  foreach my $cur_ep (keys %$rh_final_list) {
-    foreach my $channel (keys %{$rh_final_list->{$cur_ep}}) {
-      my $value = $rh_thresh->{$cur_ep}->[$channel];
-      $chain = int($channel/16);
-      printf "want to write: $value to ecal: 0x%x, chain %d channel: $channel\n",$cur_ep,$chain;
-      $command = ($channel&0xf)<<$REGNR | $WRITE | $value;
-      Dmon::PadiwaSendCmd($command,$cur_ep, $chain);
+  if (1) { # really recover channels
+    foreach my $cur_ep (keys %$rh_final_list) {
+      foreach my $channel (keys %{$rh_final_list->{$cur_ep}}) {
+        $chain = int($channel/16);
+        $command = ($channel&0xf)<<$REGNR | $WRITE | 0x1ff; # high threshold
+        #print "write: chain: $chain, Channel: $channel, value: $cur_value\n";
+        Dmon::PadiwaSendCmd($command,$cur_ep, $chain);
+      }
+    }
+
+    usleep(30E3);
+
+    foreach my $cur_ep (keys %$rh_final_list) {
+      foreach my $channel (keys %{$rh_final_list->{$cur_ep}}) {
+        my $value = $rh_thresh->{$cur_ep}->[$channel];
+        $chain = int($channel/16);
+        printf STDERR "want to write: $value to ecal: 0x%x, chain %d channel: $channel\n",$cur_ep,$chain;
+        $command = ($channel&0xf)<<$REGNR | $WRITE | $value;
+        Dmon::PadiwaSendCmd($command,$cur_ep, $chain);
+      }
     }
   }
 
-  sleep 4;
+  sleep 1;
+}
+
+
+sub in_spill {
+  my $o = trb_register_read(0x10,0x905d);
+  my $inspill = $o->{0x10} >> 31;
+  return $inspill;
 }
 
-exit;
+exit 1
 
diff --git a/hmon/hmon_ecalresettdcchannels.pl b/hmon/hmon_ecalresettdcchannels.pl
new file mode 100755 (executable)
index 0000000..4e7ed1c
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Data::Dumper;
+use Hmon;
+use QA;
+use HADES::TrbNet;
+use POSIX qw(strftime);
+my $fh;
+
+#toggle TDC channel enable after every other spill to reset internal edge flag
+trb_init_ports() or die trb_strerror();
+my $inspill;
+while (1) {
+  do {
+    sleep(1);
+    my $o = trb_register_read(0x10,0x905d);
+    $inspill = $o->{0x10} >> 31;
+  } while($inspill);
+
+  trb_register_write(0xfe61,0xc802,0);
+  trb_register_write(0xfe61,0xc803,0);
+  trb_register_write(0xfe61,0xc802,0xffffffff);
+  trb_register_write(0xfe61,0xc803,0x0000ffff);
+
+  sleep(5);
+  }
index 8035f331bb3b10fb639e8dde2d89398b51a063bd..42dd07814b232a2d12b8d428e3c8d8fbaf41e3cc 100755 (executable)
@@ -293,7 +293,7 @@ while(1) {
     my $qastate = QA::GetQAState('below',$num_mdc_missing,@QA::MdcEndpMissingLimits);
        $qastate = max($qastate,QA::ERROR)  if $samechamberboards;
        $qastate = min(QA::WARN,$qastate)   if !$samesectorboards;
-       $qastate = QA::NOTE  if $mdcmissingtime > 360;
+       $qastate = max($qastate,QA::NOTE)  if $mdcmissingtime > 600;
        
        $longtext .= "<br>Few boards missing, but for a long time. Better do a restart." if $mdcmissingtime > 360;
        
@@ -406,8 +406,8 @@ while(1) {
     foreach my $element (@tof_boards) { $tof_mask{$element} |= 2 }
     foreach my $element (@QA::tof_boards_removed) { $tof_mask{$element} |= 4 }
     foreach my $element (keys %tof_mask) {
-       push @{$tof_results[0]}, sprintf("0x%x",$element);
-       push @{$tof_results[$tof_mask{$element}]}, sprintf("0x%x",$element);
+       push @{$tof_results[0]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
+       push @{$tof_results[$tof_mask{$element}]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
     }
 
     my $num_tof_missing = (scalar @{$tof_results[2]});
@@ -440,8 +440,8 @@ while(1) {
     foreach my $element (@rpc_boards) { $rpc_mask{$element} |= 2 }
     foreach my $element (@QA::rpc_boards_removed) { $rpc_mask{$element} |= 4 }
     foreach my $element (keys %rpc_mask) {
-       push @{$rpc_results[0]}, sprintf("0x%x",$element);
-       push @{$rpc_results[$rpc_mask{$element}]}, sprintf("0x%x",$element);
+       push @{$rpc_results[0]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
+       push @{$rpc_results[$rpc_mask{$element}]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
     }
 
     my $num_rpc_missing = (scalar @{$rpc_results[2]});
@@ -471,8 +471,8 @@ while(1) {
     foreach my $element (@other_boards) { $other_mask{$element} |= 2 }
     foreach my $element (@QA::other_boards_removed) { $other_mask{$element} |= 4 }
     foreach my $element (keys %other_mask) {
-       push @{$other_results[0]}, sprintf("0x%x",$element);
-       push @{$other_results[$other_mask{$element}]}, sprintf("0x%x",$element);
+       push @{$other_results[0]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
+       push @{$other_results[$other_mask{$element}]}, sprintf("0x%04x (%s), ",$element,Hmon::getsystem($element));
     }
 
     my $num_other_missing = (scalar @{$other_results[2]});
similarity index 52%
rename from hmon/hmon_lvl1mismatch.pl
rename to hmon/hmon_lvl1mismatch_autorestart.pl
index 7563ebf42447e1a4f7575e6a8ebb4784276ac2f6..af7c919eb5fdd1d74a2926ffc47c2fedd8a2b94a 100755 (executable)
@@ -27,33 +27,34 @@ while(1){
     if ($temp->{$b} & 0x10) {
       $cnt++;
       $msg .= sprintf("%04x (%s)",$b,Hmon::getsystem($b));
+      if(Hmon::getsystem($b) == "DiRICH" && $cnt+$cnt2 < 2) {
+        #Stopping trigger
+        system("trbcmd setbit 0x0003 0xa0c0 0x400");
+        #send local reset
+        my @port = `trbcmd nettrace $b | tail -n1`;
+        my ($c,$p) = $port[0] =~ /0x(\w{4})\s+0x(\w{8})/;
+        printf("Sending local reset signal %04x %08x\n",hex($c),1 << hex($p));
+        trb_register_write(hex($c),0xc6,1 << hex($p));
+        system("ssh -X lxhadesdaqp 'cd /home/hadaq/trbsoft/daq/main/;./startup.pl -f ../rich/startup.script -c 0 -eb off'");
+        #Starting trigger
+        system("trbcmd clearbit 0x0003 0xa0c0 0x400");
+        $cnt--;
+        $msg .= "->AR";
+        $cnt2++;
       }
     }
+  }
 
   my $txt = "OK";
      $txt = "$msg" if $cnt && $cnt < 2;
+     $txt = "$msg" if $cnt == 0 && $cnt2 == 1;
      $txt = "Error" if $cnt >= 2;
   $msg = "None" if $cnt == 0;  
   $msg = "Out of sync: ".$msg;
   my $status = QA::OK;
+     $status = QA::WARN if $cnt2;
      $status = QA::ERROR if $cnt;
 
-     
-#   foreach my $b (keys %{$temp}) {
-#     if ($temp->{$b} & 0x200) {
-#       $cnt2++;
-#       $msg2 .= sprintf("%04x ",$b);
-#       }
-#     }
-# 
-#   $txt .= " ".$msg2 if $cnt2 && $cnt2 < 2;
-#   $msg2 = "None" if $cnt == 0;  
-#   $msg2 = "<br>Buffer problems: ".$msg2;
-#   $status = QA::ERROR if $cnt2;
-# 
-  $txt = "Error" if $cnt2+$cnt >= 2 ;
-#      
-     
   QA::WriteQALog($fqa,"daq","outofsync",20,$status,'Sync',$txt,$msg);
   sleep 2;  
-  }
+}
index 8145b6bbf5eb0c84971e6adfc81bc72cd1b6701c..905b7c71b9767f859dadcaec5e6c4de07591b07f 100755 (executable)
@@ -60,11 +60,13 @@ while (1) {
     chop $boardlist; chop $boardlist;
     my $qastate = QA::OK;
     my $status = "";
-    $qastate = QA::ERROR if($error);
+    $qastate = QA::WARN if($error);
+    $qastate = QA::ERROR if($error > 2);
     $status = $error." errors" if $error;
     my $longmsg = sprintf("All MDC motherboard deliver data -  Avg. number of words per second: %i - Avg number of words per event: %i",$avg,$avg/($rate || 1));
     $longmsg = "MDC motherboards not delivering data: $boardlist" if $error;
     QA::WriteQALog($fqa, "mdc", "blocked", 20, $qastate,"MBO w/o data", $status,$longmsg);
+    Hmon::Speak('mdcnodata',"$error M-B-O collect no data") if($error > 2 && $iteration%3==0);
     }
   else {
     $iteration = 1;
index 1140e31f1758afd8ca02526e9fa0b7fd6b4c3627..03fdeed37dfea10c40b349649466ba99bd3856b1 100755 (executable)
@@ -84,7 +84,7 @@ while (1) {
 
   if($qastate >= QA::ERROR || ( $data->{'TempAlarmEPICS'}->{'val'}//0 > 0 )  ) {
     if($mailerrstatecnt++ >= 60) {
-      Hmon::SendEmail('j.michel@gsi.de,c.wendisch@gsi.de',"Error: MDC Temperature too high","MDC temperatures are too high:  
+      Hmon::SendEmail('c.wendisch@gsi.de',"Error: MDC Temperature too high","MDC temperatures are too high:  
 \n$str\n".$data->{'TempAlarmEPICS'}->{'val'});
       $mailerrstatecnt = 0;
       }
index 8cc6929a5c324e8b4f0acba9b841ba76b6a55dff..64d01650fd7788fc0e9e2bda0cd64ff1d8a7b033 100755 (executable)
@@ -12,14 +12,21 @@ use QA;
 use HADES::TrbNet;
 
 my $store = {};
+
 my $msg = "";
 my $low = 0;
 my $high = 0;
 my $status = "";
 
-my @names = qw(5.8V 5V 3.8V 3.3V 1.8V 1.2V 3V -3V);
-my @minimum = (5.5, 4.75, 3.5, 3.15, 1.4, 1.15, 2.90, -3.05);
-my @maximum = (6.3, 5.1, 4.0, 3.4, 2.1, 1.25, 3.10, -2.95);
+#for Hmon box
+my @names = qw(5.8V 5V 3.8V 3.3V 1.8V 1.2V +3V -3V);
+my @minimum = (5.5, 4.75, 3.6, 3.15, 1.4, 1.15, 2.85, -3.05);
+my @maximum = (6.3, 5.1,  4.3, 3.4,  2.1, 1.25, 3.15, -2.95);
+
+#for drawings
+my @fname = qw(5V8 5V 3V8 3V3 1V8 1V2 p3V m3V);
+my @fminimum = (4.900, 4.750, 3.000, 3.150, 1.000, 1.150, 2.500, -3.166);
+my @fmaximum = (6.500, 5.100, 4.500, 3.400, 2.400, 1.250, 3.500, -2.833);
 
 
 my $fqa = QA::OpenQAFile();
@@ -28,6 +35,7 @@ my $qastate;
 trb_init_ports() or die trb_strerror();
 
 while (1) {
+  my $store2;
   my $rh_volt = trb_register_read_mem(0xfffd, 0x8010, 0, 8) or sleep 5 and next;
 
   foreach my $board (sort {$a <=> $b} keys %$rh_volt) {
@@ -40,6 +48,9 @@ while (1) {
       } else {
         $store->{$reg_address}->{$board} = $val;
       }
+      
+      $store2->[$reg_address] {($board >> 8) & 0x0f} {($board >> 4) & 0x0f} {($board >> 0) & 0x0f} = $store->{$reg_address}->{$board} / 1000. ;
+      
       if ($store->{$reg_address}->{$board} > $maximum[$reg_address] * 1000) {
                                my $boardstr = sprintf("%04x",$board);
         $msg .= " $boardstr $names[$reg_address] high (".sprintf("%.2fV),",$store->{$reg_address}->{$board}/1000.); 
@@ -53,7 +64,7 @@ while (1) {
       $reg_address++;
     }
   }
-
+  
   $status = $high + $low . " warnings";
   my $qastate = QA::GetQAState('below', $high + $low, @QA::MdcVoltageLimits);
   QA::WriteQALog($fqa, "mdc", "voltage", 30, $qastate,"Voltages", $status,$msg);
@@ -64,5 +75,31 @@ while (1) {
   $high = 0;
   $status = "";
 
+  my $cnt = 0;
+  foreach my $regs (@$store2) {
+    my $page = Hmon::MakeTitle(9, 10, "MDC Voltages $names[$cnt]");
+#     my ($min,$max) = ($fminimum[$cnt],$fmaximum[$cnt]);
+#     my ($min,$max) = Hmon::MakeMinMax3( $regs, 4, 6, 16);
+#     print "$min $max\n";
+    my ($color,$raw);
+    for (my $l = 0; $l < 4;$l++) {
+      $page .= "<p>";
+      for (my $s = 0; $s < 6;$s++) {
+        for (my $b = 0; $b < 16; $b++) {    
+          $color->{$b} = sprintf("style=\"background:%4s;\"",Hmon::findcolorVoltages($regs->{$l}->{$s}->{$b}//0,$fminimum[$cnt],$fmaximum[$cnt],$minimum[$cnt],$maximum[$cnt],0));
+#           $color->{$b} = "style=\"background:#000;\"" unless defined $regs->{$l}->{$s}->{$b};
+          
+          $raw->{$b} = sprintf("%1.2f",$regs->{$l}->{$s}->{$b}//"NaN");
+          }
+        $page .= Hmon::DrawMDC($l,$s,$color,$raw);  
+        }
+      }
+    $page .= Hmon::DrawScaleVoltages($fminimum[$cnt],$fmaximum[$cnt],$minimum[$cnt],$maximum[$cnt],42);
+    $page .= Hmon::MakeFooter();
+    Hmon::WriteFile("MDCVoltage$fname[$cnt]",$page);
+    $cnt++;
+    }
+  
+  
   sleep 15;
 }
index 6267f88e2295ec687d5549e9c606e17175ccb956..fe2e342f3bd55ec5944c9417433090fd14908cc1 100755 (executable)
@@ -13,11 +13,11 @@ my $qastate = QA::OK;
 
 while (1) { 
   my $title = "Online QA";
-  my $longmsg = "The QA server process is running.";
+  my $longmsg = "Both QA server processes are running.";
   my $msg = "";
 
   # JAM2020- the pgrep command defaults on lxhadeb06 have changed for debian9. use -fal instead -fl:  
-  my $cmd = "ssh hadesp66 'pgrep -fal \"hadesonlineserver.exe .* 5678\"' </dev/null";
+  my $cmd = "ssh hadesp67 'pgrep -fal \"hadesonlineserver.exe .* 567\" | sort -n -k5 | grep -v zsh' </dev/null";
   my @out = qx($cmd);
 
 
@@ -27,12 +27,12 @@ while (1) {
   $timecnt++ if $timecnt < 0;
   $timecnt = 0 if $qastate <= 30;
 
-  $longmsg = "QA server was restarted recently - check if client is still connected." if $qastate == QA::WARN_2;
+  $longmsg = "QA server was restarted recently - check if all windows are still updated." if $qastate == QA::WARN_2;
 
-  unless(scalar @out > 0 && $out[0] =~ /hadesonlineserver.exe .* 5678/) {
+  unless(scalar @out > 1 && $out[0] =~ /hadesonlineserver.exe .* 5678/  && $out[1] =~ /hadesonlineserver.exe .* 5679/) {
     $qastate = QA::ERROR;
     $msg = "Not found";
-    $longmsg = "The online QA server process could not be found.";
+    $longmsg = "At least one online QA server process could not be found.";
     }
 
   if($QA::QAServerOff) {
index e8d488387845dc72756aeed5058020cd004d92eb..3b02f2113da04712bc50ab4b68ae7e43fbd5e3cc 100755 (executable)
@@ -26,14 +26,14 @@ my $plot3 = {
     entries => 200,
     type    => HPlot::TYPE_HISTORY,
     output  => HPlot::OUT_PNG,
-    titles  => ["X lower half position","X upper half position","Y left half position","Y right half position"],#,"Xrms_0","Xrms_1","Yrms_0","Yrms_1"],
+    titles  => ["Position Start-X","Position Start-Y"],#,"Xrms_0","Xrms_1","Yrms_0","Yrms_1"],
     xlabel  => "Seconds",
     ylabel  => "Strips",
     sizex   => 950,
-    sizey   => 360,
-    ymin    => "-0.5",
-    ymax    => "49.5",
-    curves  => 4,
+    sizey   => 320,
+    ymin    => "0.5",
+    ymax    => "16.5",
+    curves  => 2,
     xscale  => 10,
     buffer  => 1,
             };
@@ -50,7 +50,7 @@ my $plot4 = {
     xlabel  => "Seconds",
     ylabel  => "Strips",
     sizex   => 950,
-    sizey   => 360,
+    sizey   => 320,
     ymin    => "-0.5",
     ymax    => "19.5",
     curves  => 4,
@@ -272,21 +272,80 @@ my $plot2 = {
              type    => HPlot::TYPE_HEATMAP,
              output  => HPlot::OUT_PNG,
              zlabel  => "Hitrate",
-             sizex   => 450,
-             sizey   => 500,
+             sizex   => 300,
+             sizey   => 300,
              nokey   => 1,
              buffer  => 1,
              xmin    => -0.5,
              xmax    => 3.5,
              ymin    => -0.5,
-             ymax    => 49.5,
+             ymax    => 19.5,
              cbmax   => "100<*<1E7",
              cbmin   => "1",
              showvalues => 0,
            #  additional => "set logscale cb; set xtics ('Left' 0.5, 'Bottom' 2.5); set x2tics ('Right' 0.5, 'Top' 2.5);"
-            additional => " set xtics ('Left' 0.5, 'Bottom' 2.5); set x2tics ('Right' 0.5, 'Top' 2.5);"
+            additional => " set xtics ('0x5000' 0, '0x5002' 1,'0x5001' 2, '0x5003' 3); set x2tics ('StartX' 0.5, 'StartY' 2.5);"
             };
 HPlot::PlotInit($plot2);
+my $plot2bx = {
+    name    => "StartRateNumbers_1DX",
+    file    => "files/StartRateNumbers_1DX",
+    entries => 17,
+    type    => HPlot::TYPE_BARGRAPH,
+    output  => HPlot::OUT_PNG,
+    titles  => ["TDC5000","TDC5001","TDC5002","TDC5003"],
+    xlabel  => "Start Channel START X",
+    ylabel  => "Hitrate [Hz]",
+    nokey   => 1,
+    sizex   => 350,
+    sizey   => 330,
+    xmin    => 0,
+    xmax    => 17,
+    ymin    => "0",
+    ymax    => "100<*",
+    curves  => 4,
+    xscale  => 10, # xscale does not work with TYPE_BARGRAPH
+    buffer  => 1,
+    bargap => 0.1,
+    stacked => 1,
+    curvewidth  => .9,
+#     additional => "
+#   set obj 1 rect from   -1, 7E7 to  2000, 10E7 fc rgb '#ffffbb' behind \n
+#   set obj 2 rect from   -1, 10E7 to  2000, 100E7 fc rgb '#ffdddd' behind
+#     "
+    };
+HPlot::PlotInit($plot2bx);
+
+my $plot2by = {
+    name    => "StartRateNumbers_1DY",
+    file    => "files/StartRateNumbers_1DY",
+    entries => 17,
+    type    => HPlot::TYPE_BARGRAPH,
+    output  => HPlot::OUT_PNG,
+    titles  => ["TDC5000","TDC5001","TDC5002","TDC5003"],
+    xlabel  => "Start Channel START Y",
+    ylabel  => "Hitrate [Hz]",
+    
+    sizex   => 350,
+    sizey   => 330,
+    xmin    => 0,
+    xmax    => 17,
+    ymin    => "0",
+    ymax    => "100<*",
+    curves  => 4,
+    xscale  => 10, # xscale does not work with TYPE_BARGRAPH
+    buffer  => 1,
+    bargap => 0.1,
+    stacked => 1,
+    curvewidth  => .9,
+#     additional => "
+#   set obj 1 rect from   -1, 7E7 to  2000, 10E7 fc rgb '#ffffbb' behind \n
+#   set obj 2 rect from   -1, 10E7 to  2000, 100E7 fc rgb '#ffdddd' behind
+#     "
+    };
+HPlot::PlotInit($plot2by);
+
+
 
 # START spill plots
 HPlot::PlotInit({
@@ -398,18 +457,24 @@ HPlot::PlotInit({
 # $str .= Hmon::MakeFooter();
 # Hmon::WriteFile("StartRateSimple_VW",$str);
 
-my $str  = Hmon::MakeTitle(6, 12, "Start Hit Numbers");
+my $str  = Hmon::MakeTitle(4, 7, "Start Hit Numbers");
 $str .= qq@<img src="%ADDPNG files/StartRateNumbers.png%" type="image/png"><br>\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("StartRateNumbers",$str);
 
-$str  = Hmon::MakeTitle(12, 8, "Start Position",0);
+$str  = Hmon::MakeTitle(9, 7, "Start Hit Numbers 1D");
+$str .= qq@<img src="%ADDPNG files/StartRateNumbers_1DX.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/StartRateNumbers_1DY.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateNumbers_1D",$str);
+
+$str  = Hmon::MakeTitle(12, 7, "Start Position",0);
 $str .= qq@<img src="%ADDPNG files/StartPosition.png%" type="image/png">\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("StartPosition",$str);
 
 
-$str  = Hmon::MakeTitle(12, 8, "Start Position RMS",0);
+$str  = Hmon::MakeTitle(12, 7, "Start Position RMS",0);
 $str .= qq@<img src="%ADDPNG files/StartPositionRMS.png%" type="image/png">\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("StartPositionRMS",$str);
@@ -511,207 +576,49 @@ HPlot::PlotDrawFork('StartDutyFactorY_0');
 
 
 my $channels_x_1 = [
-                  { pch =>  2,  tdc => 6, ch => int(1 /2)},                  # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
-                  { pch =>  1,  tdc => 6, ch => int(3 /2)},                  # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>  4,  tdc => 6, ch => int(5 /2)},
-                  { pch =>  3,  tdc => 6, ch => int(7 /2)},
-                  { pch =>  6,  tdc => 6, ch => int(9 /2)},
-                  { pch =>  5,  tdc => 6, ch => int(11/2)},
-                  { pch =>  8,  tdc => 6, ch => int(13/2)},
-                  { pch =>  7,  tdc => 6, ch => int(15/2)},
-                  { pch => 10,  tdc => 6, ch => int(17/2)},
-                  { pch =>  9,  tdc => 6, ch => int(19/2)},
-                  { pch => 12,  tdc => 6, ch => int(21/2)},
-                  { pch => 11,  tdc => 6, ch => int(23/2)},
-                  { pch => 14,  tdc => 6, ch => int(25/2)},
-                  { pch => 13,  tdc => 6, ch => int(27/2)},
-                  { pch => 16,  tdc => 6, ch => int(29/2)},
-                  { pch => 15,  tdc => 6, ch => int(31/2)},
-                  { pch => 18,  tdc => 6, ch => int(33/2)},
-                  { pch => 17,  tdc => 6, ch => int(35/2)},
-                  { pch => 20,  tdc => 6, ch => int(37/2)},
-                  { pch => 19,  tdc => 6, ch => int(39/2)},
-                  { pch => 22,  tdc => 6, ch => int(41/2)},
-                  { pch => 21,  tdc => 6, ch => int(43/2)},
-                  { pch => 24,  tdc => 6, ch => int(45/2)},
-                  { pch => 23,  tdc => 6, ch => int(47/2)},
-                  { pch => 34,  tdc => 7, ch => int(1 /2)},
-                  { pch => 33,  tdc => 7, ch => int(3 /2)},
-                  { pch => 36,  tdc => 7, ch => int(5 /2)},
-                  { pch => 35,  tdc => 7, ch => int(7 /2)},
-                  { pch => 38,  tdc => 7, ch => int(9 /2)},
-                  { pch => 37,  tdc => 7, ch => int(11/2)},
-                  { pch => 40,  tdc => 7, ch => int(13/2)},
-                  { pch => 39,  tdc => 7, ch => int(15/2)},
-                  { pch => 42,  tdc => 7, ch => int(17/2)},
-                  { pch => 41,  tdc => 7, ch => int(19/2)},
-                  { pch => 44,  tdc => 7, ch => int(21/2)},
-                  { pch => 43,  tdc => 7, ch => int(23/2)},
-                  { pch => 46,  tdc => 7, ch => int(25/2)},
-                  { pch => 45,  tdc => 7, ch => int(27/2)},
-                  { pch => 48,  tdc => 7, ch => int(29/2)},
-                  { pch => 47,  tdc => 7, ch => int(31/2)},
-                  { pch => 26,  tdc => 7, ch => int(33/2)},
-                  { pch => 25,  tdc => 7, ch => int(35/2)},
-                  { pch => 28,  tdc => 7, ch => int(37/2)},
-                  { pch => 27,  tdc => 7, ch => int(39/2)},
-                  { pch => 30,  tdc => 7, ch => int(41/2)},
-                  { pch => 29,  tdc => 7, ch => int(43/2)},
-                  { pch => 32,  tdc => 7, ch => int(45/2)},
-                  { pch => 31,  tdc => 7, ch => int(47/2)}
+                  { pch =>   1,  tdc => 2, ch => 0},                  # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>   3,  tdc => 2, ch => 1},                  # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>   5,  tdc => 2, ch => 1},                  # pch: physical channel. The thing which will be plotted
+                  { pch =>   7,  tdc => 2, ch => 3},                  # tdc: tdc number
+                  { pch =>   9,  tdc => 2, ch => 4},                  # ch: channel in the TDC
+                  { pch =>  11,  tdc => 2, ch => 6},
+                  { pch =>  13,  tdc => 2, ch => 6},
+                  { pch =>  15,  tdc => 2, ch => 7}
+
                  ];                              
                                                  
 my $channels_x_0 = [
-                  { pch =>  15 ,  tdc => 4, ch => int(1 /2)},               # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
-                  { pch =>  16 ,  tdc => 4, ch => int(3 /2)},               # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>  13 ,  tdc => 4, ch => int(5 /2)},
-                  { pch =>  14 ,  tdc => 4, ch => int(7 /2)},
-                  { pch =>  11 ,  tdc => 4, ch => int(9 /2)},
-                  { pch =>  12 ,  tdc => 4, ch => int(11/2)},
-                  { pch =>   9 ,  tdc => 4, ch => int(13/2)},
-                  { pch =>  10 ,  tdc => 4, ch => int(15/2)},
-                  { pch =>   7 ,  tdc => 4, ch => int(17/2)},
-                  { pch =>   8 ,  tdc => 4, ch => int(19/2)},
-                  { pch =>   5 ,  tdc => 4, ch => int(21/2)},
-                  { pch =>   6 ,  tdc => 4, ch => int(23/2)},
-                  { pch =>   3 ,  tdc => 4, ch => int(25/2)},
-                  { pch =>   4 ,  tdc => 4, ch => int(27/2)},
-                  { pch =>   1 ,  tdc => 4, ch => int(29/2)},
-                  { pch =>   2 ,  tdc => 4, ch => int(31/2)},
-                  { pch =>  31 ,  tdc => 4, ch => int(33/2)},
-                  { pch =>  32 ,  tdc => 4, ch => int(35/2)},
-                  { pch =>  29 ,  tdc => 4, ch => int(37/2)},
-                  { pch =>  30 ,  tdc => 4, ch => int(39/2)},
-                  { pch =>  27 ,  tdc => 4, ch => int(41/2)},
-                  { pch =>  28 ,  tdc => 4, ch => int(43/2)},
-                  { pch =>  25 ,  tdc => 4, ch => int(45/2)},
-                  { pch =>  26 ,  tdc => 4, ch => int(47/2)},
-                  { pch =>  47 ,  tdc => 5, ch => int(1 /2)},
-                  { pch =>  48 ,  tdc => 5, ch => int(3 /2)},
-                  { pch =>  45 ,  tdc => 5, ch => int(5 /2)},
-                  { pch =>  46 ,  tdc => 5, ch => int(7 /2)},
-                  { pch =>  43 ,  tdc => 5, ch => int(9 /2)},
-                  { pch =>  44 ,  tdc => 5, ch => int(11/2)},
-                  { pch =>  41 ,  tdc => 5, ch => int(13/2)},
-                  { pch =>  42 ,  tdc => 5, ch => int(15/2)},
-                  { pch =>  39 ,  tdc => 5, ch => int(17/2)},
-                  { pch =>  40 ,  tdc => 5, ch => int(19/2)},
-                  { pch =>  37 ,  tdc => 5, ch => int(21/2)},
-                  { pch =>  38 ,  tdc => 5, ch => int(23/2)},
-                  { pch =>  35 ,  tdc => 5, ch => int(25/2)},
-                  { pch =>  36 ,  tdc => 5, ch => int(27/2)},
-                  { pch =>  33 ,  tdc => 5, ch => int(29/2)},
-                  { pch =>  34 ,  tdc => 5, ch => int(31/2)},
-                  { pch =>  23 ,  tdc => 5, ch => int(33/2)},
-                  { pch =>  24 ,  tdc => 5, ch => int(35/2)},
-                  { pch =>  21 ,  tdc => 5, ch => int(37/2)},
-                  { pch =>  22 ,  tdc => 5, ch => int(39/2)},
-                  { pch =>  19 ,  tdc => 5, ch => int(41/2)},
-                  { pch =>  20 ,  tdc => 5, ch => int(43/2)},
-                  { pch =>  17 ,  tdc => 5, ch => int(45/2)},
-                  { pch =>  18 ,  tdc => 5, ch => int(47/2)}
+                  { pch =>  2 ,  tdc => 0, ch => 7 },               # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>  4 ,  tdc => 0, ch => 6 },               # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>  6 ,  tdc => 0, ch => 6 },
+                  { pch =>  8 ,  tdc => 0, ch => 4 },
+                  { pch =>  10,  tdc => 0, ch => 3 },
+                  { pch =>  12,  tdc => 0, ch => 1 },
+                  { pch =>  14,  tdc => 0, ch => 1 },
+                  { pch =>  16,  tdc => 0, ch => 0 }
+
                  ];
 my $channels_y_1 = [
-                  { pch =>  2,   tdc => 2, ch => int(1 /2)},                   # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
-                  { pch =>  1,   tdc => 2, ch => int(3 /2)},                   # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>  4,   tdc => 2, ch => int(5 /2)},
-                  { pch =>  3,   tdc => 2, ch => int(7 /2)},
-                  { pch =>  6,   tdc => 2, ch => int(9 /2)},
-                  { pch =>  5,   tdc => 2, ch => int(11/2)},
-                  { pch =>  8,   tdc => 2, ch => int(13/2)},
-                  { pch =>  7,   tdc => 2, ch => int(15/2)},
-                  { pch => 10,   tdc => 2, ch => int(17/2)},
-                  { pch =>  9,   tdc => 2, ch => int(19/2)},
-                  { pch => 12,   tdc => 2, ch => int(21/2)},
-                  { pch => 11,   tdc => 2, ch => int(23/2)},
-                  { pch => 14,   tdc => 2, ch => int(25/2)},
-                  { pch => 13,   tdc => 2, ch => int(27/2)},
-                  { pch => 16,   tdc => 2, ch => int(29/2)},
-                  { pch => 15,   tdc => 2, ch => int(31/2)},
-                  { pch => 18,   tdc => 2, ch => int(33/2)},
-                  { pch => 17,   tdc => 2, ch => int(35/2)},
-                  { pch => 20,   tdc => 2, ch => int(37/2)},
-                  { pch => 19,   tdc => 2, ch => int(39/2)},
-                  { pch => 22,   tdc => 2, ch => int(41/2)},
-                  { pch => 21,   tdc => 2, ch => int(43/2)},
-                  { pch => 24,   tdc => 2, ch => int(45/2)},
-                  { pch => 23,   tdc => 2, ch => int(47/2)},
-                  { pch => 34,   tdc => 3, ch => int(1 /2)},
-                  { pch => 33,   tdc => 3, ch => int(3 /2)},
-                  { pch => 36,   tdc => 3, ch => int(5 /2)},
-                  { pch => 35,   tdc => 3, ch => int(7 /2)},
-                  { pch => 38,   tdc => 3, ch => int(9 /2)},
-                  { pch => 37,   tdc => 3, ch => int(11/2)},
-                  { pch => 40,   tdc => 3, ch => int(13/2)},
-                  { pch => 39,   tdc => 3, ch => int(15/2)},
-                  { pch => 42,   tdc => 3, ch => int(17/2)},
-                  { pch => 41,   tdc => 3, ch => int(19/2)},
-                  { pch => 44,   tdc => 3, ch => int(21/2)},
-                  { pch => 43,   tdc => 3, ch => int(23/2)},
-                  { pch => 46,   tdc => 3, ch => int(25/2)},
-                  { pch => 45,   tdc => 3, ch => int(27/2)},
-                  { pch => 48,   tdc => 3, ch => int(29/2)},
-                  { pch => 47,   tdc => 3, ch => int(31/2)},
-                  { pch => 26,   tdc => 3, ch => int(33/2)},
-                  { pch => 25,   tdc => 3, ch => int(35/2)},
-                  { pch => 28,   tdc => 3, ch => int(37/2)},
-                  { pch => 27,   tdc => 3, ch => int(39/2)},
-                  { pch => 30,   tdc => 3, ch => int(41/2)},
-                  { pch => 29,   tdc => 3, ch => int(43/2)},
-                  { pch => 32,   tdc => 3, ch => int(45/2)},
-                  { pch => 31,   tdc => 3, ch => int(47/2)}
+                  { pch =>  2 ,  tdc => 3, ch => 7 },                 # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>  4 ,  tdc => 3, ch => 6 },                 # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>  6 ,  tdc => 3, ch => 6 },
+                  { pch =>  8 ,  tdc => 3, ch => 4 },
+                  { pch =>  10,  tdc => 3, ch => 3 },
+                  { pch =>  12,  tdc => 3, ch => 1 },
+                  { pch =>  14,  tdc => 3, ch => 1 },
+                  { pch =>  16,  tdc => 3, ch => 0 }
                  ];
                  
                  
 my $channels_y_0 = [
-                  { pch =>   15 ,  tdc => 0 , ch => int(1 /2)},              # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. 
-                  { pch =>   16 ,  tdc => 0 , ch => int(3 /2)},              # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>   13 ,  tdc => 0 , ch => int(5 /2)},
-                  { pch =>   14 ,  tdc => 0 , ch => int(7 /2)},
-                  { pch =>   11 ,  tdc => 0 , ch => int(9 /2)},
-                  { pch =>   12 ,  tdc => 0 , ch => int(11/2)},
-                  { pch =>    9 ,  tdc => 0 , ch => int(13/2)},
-                  { pch =>   10 ,  tdc => 0 , ch => int(15/2)},
-                  { pch =>    7 ,  tdc => 0 , ch => int(17/2)},
-                  { pch =>    8 ,  tdc => 0 , ch => int(19/2)},
-                  { pch =>    5 ,  tdc => 0 , ch => int(21/2)},
-                  { pch =>    6 ,  tdc => 0 , ch => int(23/2)},
-                  { pch =>    3 ,  tdc => 0 , ch => int(25/2)},
-                  { pch =>    4 ,  tdc => 0 , ch => int(27/2)},
-                  { pch =>    1 ,  tdc => 0 , ch => int(29/2)},
-                  { pch =>    2 ,  tdc => 0 , ch => int(31/2)},
-                  { pch =>   31 ,  tdc => 0 , ch => int(33/2)},
-                  { pch =>   32 ,  tdc => 0 , ch => int(35/2)},
-                  { pch =>   29 ,  tdc => 0 , ch => int(37/2)},
-                  { pch =>   30 ,  tdc => 0 , ch => int(39/2)},
-                  { pch =>   27 ,  tdc => 0 , ch => int(41/2)},
-                  { pch =>   28 ,  tdc => 0 , ch => int(43/2)},
-                  { pch =>   25 ,  tdc => 0 , ch => int(45/2)},
-                  { pch =>   26 ,  tdc => 0 , ch => int(47/2)},
-                  { pch =>   47 ,  tdc => 1 , ch => int(1 /2)},
-                  { pch =>   48 ,  tdc => 1 , ch => int(3 /2)},
-                  { pch =>   45 ,  tdc => 1 , ch => int(5 /2)},
-                  { pch =>   46 ,  tdc => 1 , ch => int(7 /2)},
-                  { pch =>   43 ,  tdc => 1 , ch => int(9 /2)},
-                  { pch =>   44 ,  tdc => 1 , ch => int(11/2)},
-                  { pch =>   41 ,  tdc => 1 , ch => int(13/2)},
-                  { pch =>   42 ,  tdc => 1 , ch => int(15/2)},
-                  { pch =>   39 ,  tdc => 1 , ch => int(17/2)},
-                  { pch =>   40 ,  tdc => 1 , ch => int(19/2)},
-                  { pch =>   37 ,  tdc => 1 , ch => int(21/2)},
-                  { pch =>   38 ,  tdc => 1 , ch => int(23/2)},
-                  { pch =>   35 ,  tdc => 1 , ch => int(25/2)},
-                  { pch =>   36 ,  tdc => 1 , ch => int(27/2)},
-                  { pch =>   33 ,  tdc => 1 , ch => int(29/2)},
-                  { pch =>   34 ,  tdc => 1 , ch => int(31/2)},
-                  { pch =>   23 ,  tdc => 1 , ch => int(33/2)},
-                  { pch =>   24 ,  tdc => 1 , ch => int(35/2)},
-                  { pch =>   21 ,  tdc => 1 , ch => int(37/2)},
-                  { pch =>   22 ,  tdc => 1 , ch => int(39/2)},
-                  { pch =>   19 ,  tdc => 1 , ch => int(41/2)},
-                  { pch =>   20 ,  tdc => 1 , ch => int(43/2)},
-                  { pch =>   17 ,  tdc => 1 , ch => int(45/2)},
-                  { pch =>   18 ,  tdc => 1 , ch => int(47/2)}
+                  { pch =>   1,  tdc => 1, ch => 0},             # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>   3,  tdc => 1, ch => 1},             # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>   5,  tdc => 1, ch => 1},
+                  { pch =>   7,  tdc => 1, ch => 3},
+                  { pch =>   9,  tdc => 1, ch => 4},
+                  { pch =>  11,  tdc => 1, ch => 6},
+                  { pch =>  13,  tdc => 1, ch => 6},
+                  { pch =>  15,  tdc => 1, ch => 7}
                  ];
 
 
@@ -801,7 +708,7 @@ while(1) {
 
 
   
-    my $current_readout = trb_registertime_read_mem(0xfe76,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
+    my $current_readout = trb_registertime_read_mem(0xfe58,0xc001,0,8); # or die trb_strerror() or sleep 5 and next;
         if (defined $old) {
     
     
@@ -810,14 +717,44 @@ while(1) {
             my @hitRatesStartX_1 = calculate_rates($channels_x_1, $old, $current_readout);
             my @hitRatesStartY_0 = calculate_rates($channels_y_0, $old, $current_readout);
             my @hitRatesStartY_1 = calculate_rates($channels_y_1, $old, $current_readout);
+
+            # The next lines are special for feb24 carbon beam. Two physical channels were bonded to the same readout channel
+            # Therefore the rate of the readout channel will be divided by 2 and and the same rate will be applied to the other channel
+            # This happens twice per TDC
+            #TDC 0x5000
+#             $hitRatesStartX_0[6] = $hitRatesStartX_0[6]/2; # willy changed look-up table
+#             $hitRatesStartX_0[4] = $hitRatesStartX_0[4]/2;
+#             $hitRatesStartX_0[12] =$hitRatesStartX_0[12]/2;
+#             $hitRatesStartX_0[14] =$hitRatesStartX_0[14]/2;
+#             #TDC 0x5002
+#             $hitRatesStartX_1[5] = $hitRatesStartX_1[5]/2;
+#             $hitRatesStartX_1[3] = $hitRatesStartX_1[3]/2;
+#             $hitRatesStartX_1[11] =$hitRatesStartX_1[11]/2;
+#             $hitRatesStartX_1[13] =$hitRatesStartX_1[13]/2;
+#             #TDC 0x5001
+#             $hitRatesStartY_0[5] = $hitRatesStartY_0[5]/2;
+#             $hitRatesStartY_0[3] = $hitRatesStartY_0[3]/2;
+#             $hitRatesStartY_0[11] =$hitRatesStartY_0[11]/2;
+#             $hitRatesStartY_0[13] =$hitRatesStartY_0[13]/2;
+#             #TDC 0x5003
+#             $hitRatesStartY_1[6] = $hitRatesStartY_1[6]/2;
+#             $hitRatesStartY_1[4] = $hitRatesStartY_1[4]/2;
+#             $hitRatesStartY_1[12] =$hitRatesStartY_1[12]/2;
+#             $hitRatesStartY_1[14] =$hitRatesStartY_1[14]/2;
             
-            for my $i(1..48 ){
+            for my $i(1..16 ){
                 HPlot::PlotFill('StartRateNumbers',$hitRatesStartX_0[$i],0, $i);  #*$inspill       
                 HPlot::PlotFill('StartRateNumbers',$hitRatesStartX_1[$i],1, $i);  #*$inspill
                 HPlot::PlotFill('StartRateNumbers',$hitRatesStartY_0[$i],2, $i);  #*$inspill
                 HPlot::PlotFill('StartRateNumbers',$hitRatesStartY_1[$i],3, $i);  #*$inspill
-                
-            
+                HPlot::PlotFill('StartRateNumbers_1DX', $hitRatesStartX_0[$i], $i, 0);
+                HPlot::PlotFill('StartRateNumbers_1DX', $hitRatesStartX_1[$i], $i, 2);
+
+                HPlot::PlotFill('StartRateNumbers_1DY', $hitRatesStartY_0[$i], $i, 1);
+                HPlot::PlotFill('StartRateNumbers_1DY', $hitRatesStartY_1[$i], $i, 3);
+
+
+
             }
             
             
@@ -830,11 +767,11 @@ while(1) {
                 $summedRatesFor4Channels_Y0[$i]=0;
             }
             
-            for my $i(1..48){
-                 $summedRatesFor4Channels_X0[int(($i-1) / 4)]+= $hitRatesStartX_0[$i];    # TODO Bugcheck
-                 $summedRatesFor4Channels_X0[int(($i-1) / 4)]+= $hitRatesStartX_1[$i]; 
-                 $summedRatesFor4Channels_Y0[int(($i-1) / 4)]+= $hitRatesStartY_0[$i]; 
-                 $summedRatesFor4Channels_Y0[int(($i-1) / 4)]+= $hitRatesStartY_1[$i]; 
+            for my $i(1..8){
+                 $summedRatesFor4Channels_X0[int(($i-1)]+= $hitRatesStartX_0[$i];    # TODO Bugcheck
+                 $summedRatesFor4Channels_X0[int(($i-1)) ]+= $hitRatesStartX_1[$i];
+                 $summedRatesFor4Channels_Y0[int(($i-1)) ]+= $hitRatesStartY_0[$i];
+                 $summedRatesFor4Channels_Y0[int(($i-1)) ]+= $hitRatesStartY_1[$i];
             }
             
             
@@ -1039,10 +976,21 @@ while(1) {
             }
             
             if($inspill) {
-              HPlot::PlotAdd("StartPosition",$avg_x_0,0);
-              HPlot::PlotAdd("StartPosition",$avg_x_1,1);
-              HPlot::PlotAdd("StartPosition",$avg_y_0,2);
-              HPlot::PlotAdd("StartPosition",$avg_y_1,3);
+              my $avg_all_x=0;
+              my $avg_all_y=0;
+
+              $avg_all_x = ($wsum_x_0+$wsum_x_1) / ($sum_x_0+$sum_x_1) if (($sum_x_0+$sum_x_1)!=0);
+              $avg_all_y = ($wsum_y_0+$wsum_y_1) / ($sum_y_0+$sum_y_1) if (($sum_y_0+$sum_y_1)!=0);
+
+#               HPlot::PlotAdd("StartPosition",$avg_x_0,0);
+#               HPlot::PlotAdd("StartPosition",$avg_x_1,1);
+#               HPlot::PlotAdd("StartPosition",$avg_y_0,2);
+#               HPlot::PlotAdd("StartPosition",$avg_y_1,3);
+
+              HPlot::PlotAdd("StartPosition",$avg_all_x,0);
+              HPlot::PlotAdd("StartPosition",$avg_all_y,1);
+
+
               
               HPlot::PlotAdd("StartPositionRMS",$rms_x_0,0);
               HPlot::PlotAdd("StartPositionRMS",$rms_x_1,1);
@@ -1052,8 +1000,8 @@ while(1) {
             else {
               HPlot::PlotAdd("StartPosition","NaN",0);
               HPlot::PlotAdd("StartPosition","NaN",1);
-              HPlot::PlotAdd("StartPosition","NaN",2);
-              HPlot::PlotAdd("StartPosition","NaN",3);
+              HPlot::PlotAdd("StartPosition","NaN",2);
+              HPlot::PlotAdd("StartPosition","NaN",3);
               
               HPlot::PlotAdd("StartPositionRMS","NaN",0);
               HPlot::PlotAdd("StartPositionRMS","NaN",1);
@@ -1063,6 +1011,9 @@ while(1) {
     
             HPlot::PlotDrawFork('StartPosition')      if ($iter == 1);
             HPlot::PlotDrawFork('StartRateNumbers')    if ($iter == 2);
+            HPlot::PlotDrawFork('StartRateNumbers_1DX')    if ($iter == 5);
+            HPlot::PlotDrawFork('StartRateNumbers_1DY')    if ($iter == 9);
+
             HPlot::PlotDrawFork('StartPositionRMS')      if ($iter == 3);
             HPlot::PlotDrawFork('StartRateX_histbar') if ($iter == 4);
 #             HPlot::PlotDrawFork('StartRateX_1histbar_VW') if ($iter == 5);
@@ -1089,7 +1040,7 @@ sub calculate_rates{
     my ($ra_channels, $old,$current_readout) = @_ ;
     
     my @result;
-    for my $i (0..48){
+    for my $i (0..16){
         $result[$i] = 0;
     }
     
@@ -1105,10 +1056,12 @@ sub calculate_rates{
         $tdiff *= 16;
         my $rate = $hitdiff / ($tdiff || 1E6) * 1E6 ;
         
-        $result[$phy_channel] = $rate;
+        if ($channel==1 || $channel==6) {$result[$phy_channel] = $rate/2;} # added 16.1.24 by Willy to accound for double bonded readout channels
+        else{$result[$phy_channel] = $rate;}# added 16.1.24 by Willy to accound for double bonded readout channels
+        #$result[$phy_channel] = $rate; # commented 16.1.24 by Willy to accound for double bonded readout channels
     }
     
-     for my $i(1..48){
+     for my $i(1..16){
          $result[$i] +=2**24 if $result[$i] < 0;
      }
     
@@ -1139,7 +1092,9 @@ sub calculate_diff_time_and_sum {
       $vdiff += 2**24 if $vdiff < 0;
       my $diff = $vdiff/($tdiff||1E6)*1E6;
       #print "vdiff: $vdiff, diff: $diff, tdiff: $tdiff\n";
-      
+      if ($channel==1 || $channel==6){ $diff = $diff/2;} # added 16.1.24 by Willy to accound for double bonded readout channels
+
+
       $sum += $diff;
       $wsum += $diff * $phy_channel;
 
@@ -1166,6 +1121,7 @@ sub calculate_weighted_sum_difference_from_mean{
     $tdiff *= 16;
     my $rate = $hitdiff / ($tdiff || 1E6) * 1E6 ;
 #     $weighted_sum_difference_from_mean += $hitdiff * ( ($phy_channel-$avg)**2); # this was a bug. One has to weight with the rate, not with the recorded hits, as weighted sum is also a rate
+    if ($channel==1 || $channel==6){ $rate = $rate/2;} # added 16.1.24 by Willy to accound for double bonded readout channels
     $weighted_sum_difference_from_mean += $rate * ( ($phy_channel-$avg)**2);
   }
   return $weighted_sum_difference_from_mean;
diff --git a/hmon/hmon_tdc_totratio.pl b/hmon/hmon_tdc_totratio.pl
new file mode 100755 (executable)
index 0000000..e5bcfaf
--- /dev/null
@@ -0,0 +1,145 @@
+#!/usr/bin/perl
+
+use warnings;
+use POSIX qw(strftime floor ceil);
+use FileHandle;
+use lib "./code";
+use lib "../daqtools/tools";
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use Dmon;
+use Hmon;
+use HPlot;
+use QA;
+use getebjson;
+use getrootjson;
+use JSON::XS;
+use Data::Dumper;
+use List::Util qw(min max sum);
+use LWP::Simple qw(get);
+use Try::Tiny;
+trb_init_ports() or die trb_strerror();
+
+my $data;
+my $NUMPLOTS = 1;
+my $SERVER = 'rawmon';   #calib or calibtest
+my $fqa = QA::OpenQAFile();
+  
+
+  my $labels = 'set xtics (';
+  
+  my $entry = 0;
+  my $regs = trb_register_read_mem(0xffff,0xc802,0,2) or die trb_strerror() or sleep 5 and next;
+  my $boards;
+  foreach my $b (sort {$a <=> $b} keys %$regs) {
+    next unless (defined $regs->{$b}[1]);
+    $boards->{$b}{enable} = $regs->{$b}[0] + ($regs->{$b}[1] << 32);
+    $labels .= sprintf("'%04x' %i,",$b,$entry++);
+    }
+  chomp $labels;  
+  my $numboards = $entry;
+  $labels .= ') rotate by 90 offset 0,-1.4 font ",6";';
+  
+  my @names = qw(RatioToThits);
+  
+HPlot::PlotInit({
+  name    => "TdcTotHitRatio",
+  file    => "files/TdcTotHitRatio",
+  cblabel   => $names[0],
+  entries => $numboards,
+  curves  => 49,
+  type    => HPlot::TYPE_HEATMAP,
+  output  => HPlot::OUT_PNG,
+  sizex   => 10000,
+  sizey   => 500,
+  nokey   => 1,
+  buffer  => 0,
+  xmin    => -0.5,
+  xmax    => $numboards-0.5,
+  ymin    => -0.5,
+  ymax    => 48.5,
+  cbmin   => 0,
+  cbmax   => 0.6,
+  noinit  => 1,
+  palette => 'defined (0 "red", 0.5 "green", 0.6 "yellow")',
+  additional => $labels,
+  showvalues => 0,  });
+
+  
+  my $str  = Hmon::MakeTitle(200, 12, "TDC ToT Ratio",1);
+  $str .= qq@<img src="%ADDPNG files/TdcTotHitRatio.png%" type="image/png"><br>\n@;
+  $str .= Hmon::MakeFooter();
+  Hmon::WriteFile("TdcTotHitRatio",$str);  
+
+  my $oldtots; my $oldhits;
+  my $iteration = 0;
+  
+while(1) {
+#   my $datahistlist = getjsonhash($SERVER,'h.json');
+  #print Dumper $datahistlist->{'_allnames'};
+
+  $entry = -1;
+  my $longstatus = "TDC channels with likely problems:<br>";
+  my $qastate = QA::OK;
+  
+  my $ToTCount = getroothist($SERVER,"/HADES/Run/HLD/HLD_ToTCountPerChannel");
+  my $HitCount = getroothist($SERVER,"/HADES/Run/HLD/HLD_HitsPerChannel");
+
+  my $tots; my $hits;
+  for(my $i=0; $i < scalar @{$ToTCount->{'xlabels'}}; $i++) {
+    $tots->{hex($ToTCount->{'xlabels'}[$i])} = $ToTCount->{'bins'}[$i];
+    }
+  for(my $i=0; $i < scalar @{$HitCount->{'xlabels'}}; $i++) {
+    $hits->{hex($HitCount->{'xlabels'}[$i])} = $HitCount->{'bins'}[$i];
+    }
+    
+    
+  if($oldtots) {
+    my $brokenchannels = 0;  
+      
+    foreach my $b (sort {$a <=> $b} keys %$boards) {
+      $entry++;
+      my $localbroken = 0;
+      for(my $i=1;$i<=48;$i++) {
+
+        my $currenthits = ($hits->{$b}[$i]||0)-($oldhits->{$b}[$i]||0);
+        my $currenttots = ($tots->{$b}[$i]||0)-($oldtots->{$b}[$i]||0);
+        
+        my $ratio = $currenthits;
+        next unless $ratio;
+        $ratio = $currenttots / ($ratio||1);
+        HPlot::PlotFill("TdcTotHitRatio",$ratio,$entry,$i)  if $currenthits > 10;    
+        
+        next if $hits->{$b}[$i] < $oldhits->{$b}[$i];
+        $brokenchannels++ if $ratio < 0.05 and $currenthits > 10;
+        $localbroken++    if $ratio < 0.05 and $currenthits > 10;
+#         $longstatus .= $i." ".$currenttots." ".$currenthits."." if $ratio < 0.05 and $currenthits > 10;
+        }
+      
+      #one always noisy channel
+      $localbroken-- if $localbroken > 0 && $b == 0x5815;  
+        
+      $qastate = max($qastate,QA::WARN) if $localbroken >=3;
+      $qastate = max($qastate,QA::WARN_2) if $localbroken >=8;
+      $longstatus .= sprintf("%04x: %i (%s)<br>",$b,$localbroken,Hmon::getsystem($b)) if $localbroken;
+      }
+
+    
+    HPlot::PlotDraw("TdcTotHitRatio");  
+    
+
+    QA::WriteQALog($fqa, "misc2", "tdctot", 120, $qastate, "TDC",
+      $brokenchannels, $longstatus);
+    }  
+  $oldtots = $tots;
+  $oldhits = $hits;
+
+  if($iteration++ == 10) {
+    get ("http://lxhadeb12:8090/HADES/Run/HLD/HLD_ToTCountPerChannel/cmd.json?command=ClearHistos");    
+    get ("http://lxhadeb12:8090/HADES/Run/HLD/HLD_HitsPerChannel/cmd.json?command=ClearHistos");    
+    $iteration = 0;
+    }
+  sleep 30;
+  }
index d43f9f05bda4f5728e6baf29485328521585e7b0..2d6c2606a8364186667b7eaa47abd3254abbd77e 100755 (executable)
@@ -136,7 +136,7 @@ while (1) {
     my $qalg = sprintf("%u errors in last second - %u errors in total",
                        $sum, $totalsum);
 
-    $qastate = min($qastate,QA::NOTE) if $boardstring eq "0x70a7 (DiRICH)";  #Misbehaving board....
+   # $qastate = min($qastate,QA::NOTE) if $boardstring eq "0x70a7 (DiRICH)";  #Misbehaving board....
                        
     QA::WriteQALog($fqa, "feeerr", "trgqual", 20, $qastate,
                    "Trigger", $qash, $qalg." - Boards (in last 10 seconds): ".$boardstring);
index 24405d5b2445bfe22c16eb68c3d86e059eaaa2a1..a95f897526bfe5579ec37747fc6ef21937ff02bd 100755 (executable)
@@ -172,7 +172,7 @@ while (1) {
 my $longmsgcheck = $longmsg;    
 
 #Input polarity wrong?    
-  if($QA::TrgCheckPolarity && (($polarity->{3}->[1] & 0xffff0000))) { # || $polarity->{3}->[0] & 0x1e0)
+  if($QA::TrgCheckPolarity && (($polarity->{3}->[1] & 0x7fff0000))) { # || $polarity->{3}->[0] & 0x1e0)
     $qastate = QA::WARN;
     $longmsg .= " - Signal polarity wrong on inputs ";
     foreach my $i(16..31) {
@@ -181,7 +181,7 @@ my $longmsgcheck = $longmsg;
 #         $longmsg .= "Veto ".($i-7) if $i<16 && $i>=8;
         $longmsg .= "TOF ".($i-15) if $i<22 && $i>=16;
         $longmsg .= "RPC ".($i-21) if $i<28 && $i>=22;
-        $longmsg .= "PT ".($i-27) if $i<32 && $i>=28;
+        $longmsg .= "PT ".($i-27) if $i<31 && $i>=28;
         $longmsg .= ", ";
         }
       }
index 67be1666b5b5d652b1e8be69cef32e0fae936f9d..f262eb0353edf183fcd718126452af8f3172b4b7 100755 (executable)
@@ -20,7 +20,7 @@ HPlot::PlotInit({
     name    => "StartFalls",
     file    => "files/StartFalls",
     entries => 200,
-    curves  => 97,
+    curves  => 32,
     type    => HPlot::TYPE_HEATMAP,
     output  => HPlot::OUT_PNG,
     xlabel  => "Time [100ms]",
@@ -32,7 +32,7 @@ HPlot::PlotInit({
     buffer  => 1,
     xmin    => -0.5,
     xmax    => 199.5,
-    ymin    => 96.5,
+    ymin    => 31.5,
     ymax    => -0.5,
     cbmin   => "0",
 #     cbmax   => "1000<*",
@@ -49,105 +49,105 @@ my $str  = Hmon::MakeTitle(12, 10, "Start Falls");
 trb_init_ports() or die trb_strerror();
 
 my $channels_x_1 = [
-                  { pch =>  2,  tdc => 6, ch => int(1 /2)},                  # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
-                  { pch =>  1,  tdc => 6, ch => int(3 /2)},                  # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>  4,  tdc => 6, ch => int(5 /2)},
-                  { pch =>  3,  tdc => 6, ch => int(7 /2)},
-                  { pch =>  6,  tdc => 6, ch => int(9 /2)},
-                  { pch =>  5,  tdc => 6, ch => int(11/2)},
-                  { pch =>  8,  tdc => 6, ch => int(13/2)},
-                  { pch =>  7,  tdc => 6, ch => int(15/2)},
-                  { pch => 10,  tdc => 6, ch => int(17/2)},
-                  { pch =>  9,  tdc => 6, ch => int(19/2)},
-                  { pch => 12,  tdc => 6, ch => int(21/2)},
-                  { pch => 11,  tdc => 6, ch => int(23/2)},
-                  { pch => 14,  tdc => 6, ch => int(25/2)},
-                  { pch => 13,  tdc => 6, ch => int(27/2)},
-                  { pch => 16,  tdc => 6, ch => int(29/2)},
-                  { pch => 15,  tdc => 6, ch => int(31/2)},
-                  { pch => 18,  tdc => 6, ch => int(33/2)},
-                  { pch => 17,  tdc => 6, ch => int(35/2)},
-                  { pch => 20,  tdc => 6, ch => int(37/2)},
-                  { pch => 19,  tdc => 6, ch => int(39/2)},
-                  { pch => 22,  tdc => 6, ch => int(41/2)},
-                  { pch => 21,  tdc => 6, ch => int(43/2)},
-                  { pch => 24,  tdc => 6, ch => int(45/2)},
-                  { pch => 23,  tdc => 6, ch => int(47/2)},
-                  { pch => 34,  tdc => 7, ch => int(1 /2)},
-                  { pch => 33,  tdc => 7, ch => int(3 /2)},
-                  { pch => 36,  tdc => 7, ch => int(5 /2)},
-                  { pch => 35,  tdc => 7, ch => int(7 /2)},
-                  { pch => 38,  tdc => 7, ch => int(9 /2)},
-                  { pch => 37,  tdc => 7, ch => int(11/2)},
-                  { pch => 40,  tdc => 7, ch => int(13/2)},
-                  { pch => 39,  tdc => 7, ch => int(15/2)},
-                  { pch => 42,  tdc => 7, ch => int(17/2)},
-                  { pch => 41,  tdc => 7, ch => int(19/2)},
-                  { pch => 44,  tdc => 7, ch => int(21/2)},
-                  { pch => 43,  tdc => 7, ch => int(23/2)},
-                  { pch => 46,  tdc => 7, ch => int(25/2)},
-                  { pch => 45,  tdc => 7, ch => int(27/2)},
-                  { pch => 48,  tdc => 7, ch => int(29/2)},
-                  { pch => 47,  tdc => 7, ch => int(31/2)},
-                  { pch => 26,  tdc => 7, ch => int(33/2)},
-                  { pch => 25,  tdc => 7, ch => int(35/2)},
-                  { pch => 28,  tdc => 7, ch => int(37/2)},
-                  { pch => 27,  tdc => 7, ch => int(39/2)},
-                  { pch => 30,  tdc => 7, ch => int(41/2)},
-                  { pch => 29,  tdc => 7, ch => int(43/2)},
-                  { pch => 32,  tdc => 7, ch => int(45/2)},
-                  { pch => 31,  tdc => 7, ch => int(47/2)}
+                  { pch =>  2,  tdc => 2, ch => int(1 /2)},                  # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>  1,  tdc => 2, ch => int(3 /2)},                  # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>  4,  tdc => 2, ch => int(5 /2)},
+                  { pch =>  3,  tdc => 2, ch => int(7 /2)},
+                  { pch =>  6,  tdc => 2, ch => int(9 /2)},
+                  { pch =>  5,  tdc => 2, ch => int(11/2)},
+                  { pch =>  8,  tdc => 2, ch => int(13/2)},
+                  { pch =>  7,  tdc => 2, ch => int(15/2)},
+                  { pch => 10,  tdc => 2, ch => int(17/2)},
+                  { pch =>  9,  tdc => 2, ch => int(19/2)},
+                  { pch => 12,  tdc => 2, ch => int(21/2)},
+                  { pch => 11,  tdc => 2, ch => int(23/2)},
+                  { pch => 14,  tdc => 2, ch => int(25/2)},
+                  { pch => 13,  tdc => 2, ch => int(27/2)},
+                  { pch => 16,  tdc => 2, ch => int(29/2)},
+                  { pch => 15,  tdc => 2, ch => int(31/2)},
+                  { pch => 18,  tdc => 2, ch => int(33/2)},
+                  { pch => 17,  tdc => 2, ch => int(35/2)},
+                  { pch => 20,  tdc => 2, ch => int(37/2)},
+                  { pch => 19,  tdc => 2, ch => int(39/2)},
+                  { pch => 22,  tdc => 2, ch => int(41/2)},
+                  { pch => 21,  tdc => 2, ch => int(43/2)},
+                  { pch => 24,  tdc => 2, ch => int(45/2)},
+                  { pch => 23,  tdc => 2, ch => int(47/2)},
+                  { pch => 34,  tdc => 3, ch => int(1 /2)},
+                  { pch => 33,  tdc => 3, ch => int(3 /2)},
+                  { pch => 36,  tdc => 3, ch => int(5 /2)},
+                  { pch => 35,  tdc => 3, ch => int(7 /2)},
+                  { pch => 38,  tdc => 3, ch => int(9 /2)},
+                  { pch => 37,  tdc => 3, ch => int(11/2)},
+                  { pch => 40,  tdc => 3, ch => int(13/2)},
+                  { pch => 39,  tdc => 3, ch => int(15/2)},
+                  { pch => 42,  tdc => 3, ch => int(17/2)},
+                  { pch => 41,  tdc => 3, ch => int(19/2)},
+                  { pch => 44,  tdc => 3, ch => int(21/2)},
+                  { pch => 43,  tdc => 3, ch => int(23/2)},
+                  { pch => 46,  tdc => 3, ch => int(25/2)},
+                  { pch => 45,  tdc => 3, ch => int(27/2)},
+                  { pch => 48,  tdc => 3, ch => int(29/2)},
+                  { pch => 47,  tdc => 3, ch => int(31/2)},
+                  { pch => 26,  tdc => 3, ch => int(33/2)},
+                  { pch => 25,  tdc => 3, ch => int(35/2)},
+                  { pch => 28,  tdc => 3, ch => int(37/2)},
+                  { pch => 27,  tdc => 3, ch => int(39/2)},
+                  { pch => 30,  tdc => 3, ch => int(41/2)},
+                  { pch => 29,  tdc => 3, ch => int(43/2)},
+                  { pch => 32,  tdc => 3, ch => int(45/2)},
+                  { pch => 31,  tdc => 3, ch => int(47/2)}
                  ];                              
                                                  
 my $channels_x_0 = [
-                  { pch =>  15 ,  tdc => 4, ch => int(1 /2)},               # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
-                  { pch =>  16 ,  tdc => 4, ch => int(3 /2)},               # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
-                  { pch =>  13 ,  tdc => 4, ch => int(5 /2)},
-                  { pch =>  14 ,  tdc => 4, ch => int(7 /2)},
-                  { pch =>  11 ,  tdc => 4, ch => int(9 /2)},
-                  { pch =>  12 ,  tdc => 4, ch => int(11/2)},
-                  { pch =>   9 ,  tdc => 4, ch => int(13/2)},
-                  { pch =>  10 ,  tdc => 4, ch => int(15/2)},
-                  { pch =>   7 ,  tdc => 4, ch => int(17/2)},
-                  { pch =>   8 ,  tdc => 4, ch => int(19/2)},
-                  { pch =>   5 ,  tdc => 4, ch => int(21/2)},
-                  { pch =>   6 ,  tdc => 4, ch => int(23/2)},
-                  { pch =>   3 ,  tdc => 4, ch => int(25/2)},
-                  { pch =>   4 ,  tdc => 4, ch => int(27/2)},
-                  { pch =>   1 ,  tdc => 4, ch => int(29/2)},
-                  { pch =>   2 ,  tdc => 4, ch => int(31/2)},
-                  { pch =>  31 ,  tdc => 4, ch => int(33/2)},
-                  { pch =>  32 ,  tdc => 4, ch => int(35/2)},
-                  { pch =>  29 ,  tdc => 4, ch => int(37/2)},
-                  { pch =>  30 ,  tdc => 4, ch => int(39/2)},
-                  { pch =>  27 ,  tdc => 4, ch => int(41/2)},
-                  { pch =>  28 ,  tdc => 4, ch => int(43/2)},
-                  { pch =>  25 ,  tdc => 4, ch => int(45/2)},
-                  { pch =>  26 ,  tdc => 4, ch => int(47/2)},
-                  { pch =>  47 ,  tdc => 5, ch => int(1 /2)},
-                  { pch =>  48 ,  tdc => 5, ch => int(3 /2)},
-                  { pch =>  45 ,  tdc => 5, ch => int(5 /2)},
-                  { pch =>  46 ,  tdc => 5, ch => int(7 /2)},
-                  { pch =>  43 ,  tdc => 5, ch => int(9 /2)},
-                  { pch =>  44 ,  tdc => 5, ch => int(11/2)},
-                  { pch =>  41 ,  tdc => 5, ch => int(13/2)},
-                  { pch =>  42 ,  tdc => 5, ch => int(15/2)},
-                  { pch =>  39 ,  tdc => 5, ch => int(17/2)},
-                  { pch =>  40 ,  tdc => 5, ch => int(19/2)},
-                  { pch =>  37 ,  tdc => 5, ch => int(21/2)},
-                  { pch =>  38 ,  tdc => 5, ch => int(23/2)},
-                  { pch =>  35 ,  tdc => 5, ch => int(25/2)},
-                  { pch =>  36 ,  tdc => 5, ch => int(27/2)},
-                  { pch =>  33 ,  tdc => 5, ch => int(29/2)},
-                  { pch =>  34 ,  tdc => 5, ch => int(31/2)},
-                  { pch =>  23 ,  tdc => 5, ch => int(33/2)},
-                  { pch =>  24 ,  tdc => 5, ch => int(35/2)},
-                  { pch =>  21 ,  tdc => 5, ch => int(37/2)},
-                  { pch =>  22 ,  tdc => 5, ch => int(39/2)},
-                  { pch =>  19 ,  tdc => 5, ch => int(41/2)},
-                  { pch =>  20 ,  tdc => 5, ch => int(43/2)},
-                  { pch =>  17 ,  tdc => 5, ch => int(45/2)},
-                  { pch =>  18 ,  tdc => 5, ch => int(47/2)}
+                  { pch =>  15 ,  tdc => 0, ch => int(1 /2)},               # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+                  { pch =>  16 ,  tdc => 0, ch => int(3 /2)},               # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+                  { pch =>  13 ,  tdc => 0, ch => int(5 /2)},
+                  { pch =>  14 ,  tdc => 0, ch => int(7 /2)},
+                  { pch =>  11 ,  tdc => 0, ch => int(9 /2)},
+                  { pch =>  12 ,  tdc => 0, ch => int(11/2)},
+                  { pch =>   9 ,  tdc => 0, ch => int(13/2)},
+                  { pch =>  10 ,  tdc => 0, ch => int(15/2)},
+                  { pch =>   7 ,  tdc => 0, ch => int(17/2)},
+                  { pch =>   8 ,  tdc => 0, ch => int(19/2)},
+                  { pch =>   5 ,  tdc => 0, ch => int(21/2)},
+                  { pch =>   6 ,  tdc => 0, ch => int(23/2)},
+                  { pch =>   3 ,  tdc => 0, ch => int(25/2)},
+                  { pch =>   4 ,  tdc => 0, ch => int(27/2)},
+                  { pch =>   1 ,  tdc => 0, ch => int(29/2)},
+                  { pch =>   2 ,  tdc => 0, ch => int(31/2)},
+                  { pch =>  31 ,  tdc => 0, ch => int(33/2)},
+                  { pch =>  32 ,  tdc => 0, ch => int(35/2)},
+                  { pch =>  29 ,  tdc => 0, ch => int(37/2)},
+                  { pch =>  30 ,  tdc => 0, ch => int(39/2)},
+                  { pch =>  27 ,  tdc => 0, ch => int(41/2)},
+                  { pch =>  28 ,  tdc => 0, ch => int(43/2)},
+                  { pch =>  25 ,  tdc => 0, ch => int(45/2)},
+                  { pch =>  26 ,  tdc => 0, ch => int(47/2)},
+                  { pch =>  47 ,  tdc => 1, ch => int(1 /2)},
+                  { pch =>  48 ,  tdc => 1, ch => int(3 /2)},
+                  { pch =>  45 ,  tdc => 1, ch => int(5 /2)},
+                  { pch =>  46 ,  tdc => 1, ch => int(7 /2)},
+                  { pch =>  43 ,  tdc => 1, ch => int(9 /2)},
+                  { pch =>  44 ,  tdc => 1, ch => int(11/2)},
+                  { pch =>  41 ,  tdc => 1, ch => int(13/2)},
+                  { pch =>  42 ,  tdc => 1, ch => int(15/2)},
+                  { pch =>  39 ,  tdc => 1, ch => int(17/2)},
+                  { pch =>  40 ,  tdc => 1, ch => int(19/2)},
+                  { pch =>  37 ,  tdc => 1, ch => int(21/2)},
+                  { pch =>  38 ,  tdc => 1, ch => int(23/2)},
+                  { pch =>  35 ,  tdc => 1, ch => int(25/2)},
+                  { pch =>  36 ,  tdc => 1, ch => int(27/2)},
+                  { pch =>  33 ,  tdc => 1, ch => int(29/2)},
+                  { pch =>  34 ,  tdc => 1, ch => int(31/2)},
+                  { pch =>  23 ,  tdc => 1, ch => int(33/2)},
+                  { pch =>  24 ,  tdc => 1, ch => int(35/2)},
+                  { pch =>  21 ,  tdc => 1, ch => int(37/2)},
+                  { pch =>  22 ,  tdc => 1, ch => int(39/2)},
+                  { pch =>  19 ,  tdc => 1, ch => int(41/2)},
+                  { pch =>  20 ,  tdc => 1, ch => int(43/2)},
+                  { pch =>  17 ,  tdc => 1, ch => int(45/2)},
+                  { pch =>  18 ,  tdc => 1, ch => int(47/2)}
                  ];
 my $channels_y_1 = [
                   { pch =>  2,   tdc => 2, ch => int(1 /2)},                   # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
@@ -255,14 +255,14 @@ my $channels_y_0 = [
 
 
 while (1) {
- my $st = trb_registertime_read_mem(0xfe76,0xdfc0,0,24);
+ my $st = trb_registertime_read_mem(0xfe58,0xc001,0,8);
   
 
 
   if (defined $oldst) {
 
     foreach my $b (keys %$st) {
-      next if ($b < 0x5000 || $b > 0x5008);
+      next if ($b < 0x5000 || $b > 0x5003);
       my $s = ($b & 0xF)*24;
       my $tdiff = $st->{$b}{time}[0] - ($oldst->{$b}{time}[0]||0);
       $tdiff += 2**16 if ($tdiff <= 0);
@@ -276,10 +276,10 @@ while (1) {
 
         }
       }
-    my $startdirectx = sum(@{$diff->{0x5004}},@{$diff->{0x5005}},@{$diff->{0x5006}},@{$diff->{0x5007}});
-    my $startdirecty = sum(@{$diff->{0x5000}},@{$diff->{0x5001}},@{$diff->{0x5002}},@{$diff->{0x5003}});
+    my $startdirecty = sum(@{$diff->{0x5001}},@{$diff->{0x5003}});
+    my $startdirectx = sum(@{$diff->{0x5000}},@{$diff->{0x5002}});
     my @y; my @x;
-      for my $e (0..47) {
+      for my $e (0..7) {
 
         my $b = 0x5000 + $channels_y_0->[$e]->{tdc};
         my $v =          $channels_y_0->[$e]->{ch};
@@ -308,11 +308,11 @@ while (1) {
 # #         $v =          $channels_x_1->[$e]->{ch};
 # #         HPlot::PlotAdd("StartFalls",$diff->{$b}->[$v]/$startdirect,$channels_x_1->[$e]->{pch}+144);
         }
-      for my $e (0..47) {
+      for my $e (0..7) {
 #         print $e."\n";
         HPlot::PlotAdd("StartFalls",$y[$e+1]/$startdirecty,$e);
-        HPlot::PlotAdd("StartFalls",$x[$e+1]/$startdirectx,$e+49);
-        HPlot::PlotAdd("StartFalls","NaN",48);
+        HPlot::PlotAdd("StartFalls",$x[$e+1]/$startdirectx,$e+16);
+        HPlot::PlotAdd("StartFalls","NaN",48);
         }
     }
   $oldst = $st;
index b9ce9d6b65335d897ab57202959c43460e4e82c4..fc390582ab3efb7fd3c54220ab4569713047a141 100755 (executable)
@@ -49,19 +49,22 @@ function openwin(url) {
 </div>
 
 <div class="linkbox" style="width:730px;"><h4>Operator Monitor - the "must-have" windows</h4><ul>
+<p style="width:600px">Use these links if you want to open them on your own screen. In the counting house, use the icons provided on the desktop!
 <li style="width:600px;"><a href="monitor.cgi?1-window-QA">Main Screen 0</a> Tactical Overview
 <li style="width:600px;"><a href="monitor.cgi?1-window9x21-busyhist-eventratelong-eventrateshort-StartBars">Main Screen 1</a> Eventrate & Busy
 <li style="width:600px;"><a href="monitor.cgi?1-window8x26-busy-DutyFactor-Pt3AcceptRatio-EvtsPerSpill-StartCountSpill">Main Screen 2</a> Spill Info
 <li style="width:600px;"><a href="monitor.cgi?1-window14x8-EBSummary-hldlast">Main Screen 3</a> EBs</li>
 <!--<li style="width:600px;"><a href="monitor.cgi?2-window19x16-EcalSimpleRate-RpcRate-StsRate-TofRate-ItofRate-StartRateSimple-FrpcRate">Main Screen 4</a> Tof Rpc STS Ecal iTOF fRPC Start rates</li>-->
 <li style="width:600px;"><a href="monitor.cgi?2-window12x16-EcalSimpleRate-RpcRate-TofRate-StartRateSimple-FwRateSimple">Main Screen 4</a> Tof Rpc FW Ecal Start rates</li>
-<li style="width:600px;"><a href="monitor.cgi?2-window12x21-StartFalls-ItofRateNumbers-TriggerRatesPerSector-CTSRates">Main Screen 5</a> Positional map for Start and iTOF, Trigger Rates</li>
-<li class="outdated" style="width:600px;"><a href="monitor.cgi?2-window12x21-RpcTofSectorRate_highres-StartRateX_histbar-StartRateY_histbar">Main Screen 6</a> Beam Intensities</li>
+<li style="width:600px;"><a href="monitor.cgi?2-window14x14-StartMap-StartRateNumbers_1D-StartPosition">Main Screen 5</a> Beam Position</li>
+<li style="width:600px;"><a href="monitor.cgi?2-window12x21-StartFalls-CTSRates</a>Main Screen 5a</a>Beam and CTS rates</li>
+<li style="width:600px;"><a href="monitor.cgi?2-window12x21-RpcTofSectorRate_highres-StartRateX_histbar-StartRateX_histbar_short">Main Screen 6</a> Beam Intensities</li>
 </ul></div>
 
-<div class="linkbox" style="clear:both;width:730px;"><h4>Other Ressources</h4><ul>
-<li><a href="/qaweb/?layout=tabs&monitoring=2000" target="_blank">QA Plots (web-based)</a>
-<li><a href="files/qa.htm">QA Plots (updated every 5 minutes)</a></li>
+<div class="linkbox" style="clear:both;width:730px;"><h4>Other Resources</h4><ul>
+<li><a href="/mon/qawindows" target="_blank">QA Windows as on main screen (web-based)</a>
+<li><a href="/qaweb/?layout=tabs&monitoring=2000" target="_blank">All QA Plots (web-based)</a>
+<li><a href="/mon/qa?C=M;O=D">QA Plot Archive (updated every 15 minutes)</a></li>
 <li><a href="files/vertex.htm">Vertex Plots (updated after each file)</a></li>
 <!--<li class="outdated"><a href="../spillmon/?browser=no&monitoring=1000&layout=grid4x4&items=[%22EventBuilder/Run/HLD/HLD_HitsFast%22,%22EventBuilder/Run/HLD/HLD_HitsSlow%22,%22EventBuilder/Run/HLD/HLD_TrendX%22,%22EventBuilder/Run/HLD/HLD_TrendY%22,%22EventBuilder/Run/HLD/HLD_BeamX%22,%22EventBuilder/Run/HLD/HLD_BeamY%22,%22EventBuilder/Run/HLD/HLD_VETO_Patt%22,%22EventBuilder/Run/HLD/HLD_QSlow%22,%22EventBuilder/Run/HLD/HLD_HALO_Patt%22,%22EventBuilder/Run/HLD/HLD_XHALOSlow%22,%22EventBuilder/Run/HLD/HLD_YHALOSlow%22,%22EventBuilder/Run/HLD/HLD_LastSpill_Q_factor%22]">Beam Properties</a></li>-->
 <!-- <li class="outdated"><a href="http://lxhadeb06/icinga">Icinga Server Monitoring (local access only)</a> -->
@@ -123,10 +126,10 @@ function openwin(url) {
 <li class="outdated"><a href="monitor.cgi?1-window-StartBars">Rates for all Start / Veto (bargraph) </a></li>
 <li class="outdated"><a href="monitor.cgi?1-window-VetoHalo">Rates for Veto &amp; HALO</a></li>
 <li><a href="monitor.cgi?1-window12x8-StartRateSimple-HodoRate">Beam Position</a></li>
-<li class="outdated"><a href="monitor.cgi?1-window-SpillStructure">Spill Structure from Start</a></li>  -->
-<li class="outdated"><a href="monitor.cgi?6-StartRateNumbers-StartPosition-StartPositionRMS">Start position</a></li>
-<li class="outdated"><a href="monitor.cgi?6-StartSpillShapeAnalysisX_0-StartSpillShapeAnalysisY_0">Spill Structure from Start</a></li>
-<li class="outdated"><a href="monitor.cgi?6-StartRateX_histbar-StartRateY_histbar">Start rate (histbar)</a></li>
+<li><a href="monitor.cgi?1-window-SpillStructure">Spill Structure from Start</a></li>  -->
+<li><a href="monitor.cgi?6-window12x21-StartRateNumbers-StartMap-StartPosition-StartPositionRMS">Start position</a></li>
+<li><a href="monitor.cgi?6-StartSpillShapeAnalysisX_0-StartSpillShapeAnalysisY_0">Spill Structure from Start</a></li>
+<!--<li><a href="monitor.cgi?6-StartRateX_histbar-StartRateY_histbar">Start rate (histbar)</a></li>-->
 <!-- <li class="outdated"><a href="monitor.cgi?1-StartRateBars-StartBars-StartPosition-VetoHalo-ForwardQuartz">Beam Summary</a></li> -->
 </ul></div>
 
@@ -165,6 +168,7 @@ function openwin(url) {
 <li><a href="monitor.cgi?2-window-MDCTriggerError">Trigger Errors</a></li>
 <li><a href="monitor.cgi?10-window-MDCPressure">Gas System Pressures</a></li>
 <li><a href="monitor.cgi?10-window-MDCReflow">Gas System Reflow &amp; Scales</a></li>
+<li><a href="monitor.cgi?15-window18x30-MDCVoltage5V8-MDCVoltage3V8-MDCVoltage1V8-MDCVoltagep3V-MDCVoltagem3V">Raw Voltages</a></li>
 <li><a href="monitor.cgi?2-window-MDCLV">LV switch status</a></li>
 </ul></div>
 
diff --git a/hmon/openqawindow.cgi b/hmon/openqawindow.cgi
new file mode 100755 (executable)
index 0000000..f1e0b8f
--- /dev/null
@@ -0,0 +1,221 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use CGI::Carp qw(fatalsToBrowser);
+print "Content-type: text/html\r\n\r\n";
+
+my $out;
+
+my $delay;
+my @args = split('-',$ENV{'QUERY_STRING'});
+
+
+if( $ENV{'QUERY_STRING'} ) {
+
+  my $width; my $height;
+  #print $geom;
+  my $newurl;
+  if($ENV{'QUERY_STRING'} =~ /^(\d+)x(\d+)(.*)/ ) {
+    $width = $1;
+    $height = $2;
+    $newurl = $3;
+print $newurl;
+    $newurl = "qawindows/".$newurl unless $newurl =~ /^http/;
+    }
+  else {
+    $newurl = $ENV{'QUERY_STRING'};
+    $width = 1200;
+    $height = 800;
+    }
+  $newurl .= '.htm' unless $newurl =~ /^http/;
+      
+  
+
+#              $out = qq$<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+$out = qq$<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
+<title>Hmon</title>
+<link href="files/styles.css" rel="stylesheet" type="text/css"/>
+
+</head>
+<body>
+<script type="text/javascript">
+  document.write("Opening Window...<br>");
+       win = window.open("$.$newurl.qq$","Hmon$.$newurl.qq$","name=HmonQA,innerWidth=$.$width.qq$,innerHeight=$.$height.qq$,scrollbars=no,status=no,location=no,menubar=no,resizable=no,titlebar=no,dialog=no");
+       if(win) {
+    win.focus();
+    win.document.title="HmonQA $.$newurl.qq#";
+    history.back();
+    }
+  else {
+    document.write("Can't open pop-up window. Please disable pop-up blocker. Starting monitor inline...");
+    setTimeout('window.location.href = "$newurl"',2000);
+    }
+</script>
+#;
+
+             } else {
+
+#              $out = qq$<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+$out = qq$<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class="monitor">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<!--<meta http-equiv="refresh" content="$.$delay.qq$"/> -->
+<link href="files/styles.css" rel="stylesheet" type="text/css"/>
+<link rel="alternate stylesheet"  href="files/styles-lcars.css" type="text/css" title="LCARS"/>
+<title>HmonQA 
+$.$ENV{'QUERY_STRING'}.qq$</title>
+</head>
+<body ><!--onmousedown="stoprefresh(0);" onmouseup="stoprefresh(0);" ondblclick="stoprefresh(0);"-->
+<div class="button" style="width:45px;right:-8px;" onclick="askclose();">&nbsp;close&nbsp;</div>
+<div class="button" id = "stop" style="right:35px;width:45px;" onclick="stoprefresh(1)">stop</div>
+<!--<div class="button" id = "big" style="right:75px;width:45px;" onclick="zoom();">&nbsp;bigger&nbsp;</div>-->
+
+<div id="contentback" class="blinkon"></div>
+<div id="content" class="blinkon"></div>
+$;
+
+
+
+$out .= qq$<script  language='javascript'>
+  var reloadevery = setTimeout('reload()',10);
+  var saveScrollTop = 0;
+  var forcereloadbecauseofmemoryleak = setTimeout("location.reload()",7200000);
+  blinkcnt = 0;
+  //blinking = setInterval("blink()",490);
+  currentzoom = 1;
+
+/*function zoom() {
+       var zoomstep = 1.5;
+       if (currentzoom == 1) {
+               currentzoom = 1.5;
+               document.getElementById('content').style.MozTransform="scale("+currentzoom+")"; 
+    document.getElementById('contentback').style.MozTransform="scale("+currentzoom+")"; 
+               window.innerWidth *= zoomstep;
+               window.innerHeight*= zoomstep;
+               document.getElementById("big").innerHTML = "small";
+               }
+       else {
+               currentzoom = 1;
+               document.getElementById('content').style.MozTransform="scale("+currentzoom+")"; 
+    document.getElementById('contentback').style.MozTransform="scale("+currentzoom+")"; 
+               window.innerWidth /= zoomstep;
+               window.innerHeight/= zoomstep;
+               document.getElementById("big").innerHTML = "bigger";
+               }
+       }*/
+
+function reload() {
+  xmlhttp=new XMLHttpRequest();
+  xmlhttp.onreadystatechange = function() {
+    if(xmlhttp.readyState == 4) {
+      if(!document.getElementById("footer") && !document.getElementById('logbox')) {
+        document.getElementById("content").style.opacity="0";
+        document.getElementById("content").innerHTML=xmlhttp.responseText;
+        //document.getElementById('content').style.transform="scale("+myscale+","+myscale+")";
+        setTimeout('document.getElementById("content").style.opacity="1"',100);
+        setTimeout('document.getElementById("contentback").innerHTML=document.getElementById("content").innerHTML',200);
+        }
+      else {  
+        document.getElementById("content").innerHTML=xmlhttp.responseText;
+        }
+        
+        
+      if(document.getElementById('logbox')) {
+        if(saveScrollTop) {
+          document.getElementById('logbox').scrollTop = saveScrollTop;
+          }
+        }
+
+      document.getElementById("stop").style.background="#444";
+      reloadevery = setTimeout('reload()',$.($delay*1000).qq$);
+      delete xmlhttp;
+      delete saveScrollTop;
+      }
+    };
+  if(document.getElementById('logbox')) {
+    saveScrollTop = document.getElementById('logbox').scrollTop;
+    if (saveScrollTop == 0) {saveScrollTop = 0.1;}
+    }
+  xmlhttp.open("GET","get.cgi?$.$ENV{'QUERY_STRING'}.qq$",true);
+  xmlhttp.send(null);
+  document.getElementById("stop").style.background="#111";
+  }
+
+function stoprefresh(button) {
+       if(reloadevery) {
+               clearTimeout(reloadevery);
+               reloadevery = false;
+               document.getElementById("stop").style.background="red";
+               document.getElementById("stop").style.color="white";
+               document.getElementById("stop").innerHTML="cont.";
+               }
+       else {
+               document.getElementById("stop").style.background="#444";
+               document.getElementById("stop").style.color="#aaa";
+               document.getElementById("stop").innerHTML="stop";
+               reload();
+               }
+       return false;
+       }
+
+function askclose() {
+       if(confirm("Close Window?")==true){window.close();}
+       }
+
+function clk(e) {
+  document.getElementById("content").getElementsByClassName("footer")[0].innerHTML= e.getAttribute("alt");
+  }
+/*
+function openhelp(w) {
+  x = "doc.cgi?"+w;
+  y = window.open(x,"TacticalOverviewDocumentation","innerwidth=930,innerheight=900,scrollbars=yes,location=yes,menubar=yes,toolbar=yes");
+  y.focus();
+  }
+
+
+
+function blink() {
+  if(blinkcnt&1) {
+    document.getElementById('content').setAttribute("class","blinkoff");
+    document.getElementById('contentback').setAttribute("class","blinkoff");
+    }
+  else {
+    document.getElementById('content').setAttribute("class","blinkon");
+    document.getElementById('contentback').setAttribute("class","blinkon");
+    }
+  blinkcnt++;
+  }*/
+
+/*var myscale =1 ;  
+function resize() {
+  if (document.getElementById('content').scrollWidth*myscale > window.innerWidth ||
+      document.getElementById('content').scrollHeight*myscale > window.innerHeight) {
+    myscale = myscale*0.9;
+    document.getElementById('content').style.transform="scale("+myscale+","+myscale+")";
+    //document.getElementById('contentback').style.transform="scale("+myscale+","+myscale+")";
+    }
+  if (document.getElementById('content').scrollWidth*myscale < window.innerWidth*0.9 ||
+      document.getElementById('content').scrollHeight*myscale < window.innerHeight*0.9) {
+          myscale = myscale/0.9;
+    document.getElementById('content').style.transform="scale("+myscale+","+myscale+")";
+    //document.getElementById('contentback').style.transform="scale("+myscale+","+myscale+")";
+    }
+  console.log(myscale);  
+  console.log(document.getElementById('content').scrollWidth, document.getElementById('content').scrollHeight );
+  }
+  
+setInterval("resize()",1000);*/
+
+</script>$;
+             }
+$out .= qq$
+</body>
+</html>
+$;
+
+print $out;
+
index 8fdff7ce1b25ab421726198f00c8712989a04273..cc3cb570022f37e7b3e8e9089085b42dc4b3e1d2 100755 (executable)
@@ -32,7 +32,7 @@ my $fqa = QA::OpenQAFile();
 
 # JAM 6.1.2020 - for the moment exlude hosts depcp418 and lxhaddcs03 not available
 # MT 2022.02.09 - all to internal HADES-VLAN CPU-names
-my @srv = qw( lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb14p lxhadeb15p lxhadeb16p lxhadeb17p lxhadeb18p lxhadesdaqp  lxhadeb13p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p hadesdaqp03 hadesdaqp04 hadesp57 hadesp31 hadesp33 hadesp63 hadesp66 hadesp67 hadesp69 hadesp70);
+my @srv = qw( lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb14p lxhadeb15p lxhadeb16p lxhadeb17p lxhadeb18p lxhadesdaqp  lxhadeb13p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p hadesdaqp03 hadesdaqp04 hadesp57 hadesp31 hadesp33 hadesp63 hadesp66 hadesp67 hadesp69 hadesp70 hadesp79);
 
 my $template .= "\n<table class=\"colorfields cpu\">\n<tr><th>";
 for(my $d=1;$d<=32;$d++) {
@@ -44,7 +44,7 @@ while(1) {
   $laststore = clone($store);
   $store = {};
   for(my $n=0;$n< scalar @srv;$n++) {
-    #print "$srv[$n]\n";
+    print "$srv[$n]\n";
     my @out;
     if($srv[$n] eq 'lxhadeb13p') {
       @out = Hmon::qxtimeout("ssh hades-qa\@$srv[$n] \"cat /proc/stat \" </dev/null",10);
index 298caf101571b815baab799128c03035fc1d7fec..42a1393ce6ecc404982299fa95d1c7e3cb9da389 100755 (executable)
@@ -16,11 +16,11 @@ use HPlot;
 my $flog = QA::OpenQAFile();
 my @colors = ("#333333","#00ff00","#ff0000","#0000ff","#dddd00","#dd00dd");
 
-my $TOTALCHANS = 1008;
+my $TOTALCHANS = 978;
 
 for my $i (0..5) {
   HPlot::PlotInit( {
-    name    => "EcalCurr$i",
+    name    => "EcalCurr".($i+1),
     file    => "files/EcalCurr$i",
     entries => 168,
     type    => HPlot::TYPE_BARGRAPH,
@@ -45,7 +45,7 @@ for my $i (0..5) {
     
 for my $i (0..5) {
   HPlot::PlotInit( {
-    name    => "EcalVolt$i",
+    name    => "EcalVolt".($i+1),
     file    => "files/EcalVolt$i",
     entries => 168,
     type    => HPlot::TYPE_BARGRAPH,
@@ -71,7 +71,7 @@ for my $i (0..5) {
 
 for my $i (0..5) {
   HPlot::PlotInit( {
-  name    => "EcalVMap$i",
+  name    => "EcalVMap".($i+1),
   file    => "files/EcalVMap$i",
   title   => "",
   entries => 17,
@@ -96,7 +96,7 @@ for my $i (0..5) {
 
 for my $i (0..5) {
   HPlot::PlotInit( {
-  name    => "EcalCMap$i",
+  name    => "EcalCMap".($i+1),
   file    => "files/EcalCMap$i",
   title   => "",
   entries => 17,
@@ -128,7 +128,7 @@ my $s="";
 for(my $i = 1; $i <=6; $i++) {
 #  if ($i>=2){
   for(my $j = 1; $j<=168; $j++) {
-    my $cnt = (($i-1)*168)+$j-1;
+    my $cnt = (($i)*168)+$j-1;
     if($j<10) {$s = sprintf("HAD:ECAL:HV:S%i:M00%i:imon",$i,$j);}
     if($j>=10 and $j<100) {$s = sprintf("HAD:ECAL:HV:S%i:M0%i:imon",$i,$j);}
     if($j>=100) {$s = sprintf("HAD:ECAL:HV:S%i:M%i:imon",$i,$j);}
@@ -173,12 +173,10 @@ while(1) {
   my $ChnlsOn = 0;
   my $data = Perl2Epics::GetAll(3);
 
-  for(my $i = 0; $i <=5; $i++) {
+  for(my $i = 1; $i <=6; $i++) {
         for(my $j = 0; $j<=167; $j++) {
         my $cnt = ($i*168)+$j;
-        if ($i>=1){
-            if (abs($data->{"U$cnt"}->{val}//0)>1000 and ($data->{"I$cnt"}->{val}//0)>50) {$ChnlsOn++;}
-            }
+        if (abs($data->{"U$cnt"}->{val}//0)>1000 and ($data->{"I$cnt"}->{val}//0)>50) {$ChnlsOn++;}
         }
     }
   
@@ -375,7 +373,7 @@ while(1) {
    }
   
 
-    for (my $i = 0; $i <= 5;$i++){
+    for (my $i = 1; $i <= 6;$i++){
 #      if($i>=1){
         for (my $j = 0; $j<=167; $j++) {
         my $cnt = ($i*168)+$j;
@@ -403,7 +401,7 @@ while(1) {
     
     #print Dumper $data;
     if($timer%8 == 0) {
-        for (my $i = 0; $i <= 5;$i++){
+        for (my $i = 1; $i <= 6;$i++){
             HPlot::PlotDraw("EcalCurr$i");
             HPlot::PlotDraw("EcalVolt$i");
             HPlot::PlotDraw("EcalVMap$i");
index 19078689ac1e1dca569cd9837bcf07ba541fde8f..2b3ef2b6c11d4862aa51557e2f2266e1cd1cd036 100755 (executable)
@@ -103,18 +103,18 @@ Hmon::WriteFile("FwHVCurrent",$str);
 
 for(my $i = 1; $i <= 144; $i++) {
   next if ($i == 66 || $i == 67 || $i == 78 || $i == 79);
-  $s = "HAD:FWHV:S$i:vmon";
+  $s = "HAD:FWALL:HV:S$i:vmon";
   Perl2Epics::Connect("$i",$s);
-  $s = "HAD:FWHV:S$i:imon";
+  $s = "HAD:FWALL:HV:S$i:imon";
   Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 990;
   }
 
 for(my $i = 145; $i <= 208; $i++) {
-  $s = "HAD:FWHV:M$i:vmon";
+  $s = "HAD:FWALL:HV:M$i:vmon";
   Perl2Epics::Connect("$i",$s);
-  $s = "HAD:FWHV:M$i:imon";
+  $s = "HAD:FWALL:HV:M$i:imon";
   Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 1300;
@@ -123,9 +123,9 @@ for(my $i = 145; $i <= 208; $i++) {
 for(my $i = 211; $i <= 302; $i++) {
   next if ($i == 218 || $i == 219 || $i == 220 || $i == 230);
   next if ($i == 283 || $i == 293 || $i == 294 || $i == 295);
-  $s = "HAD:FWHV:L$i:vmon";
+  $s = "HAD:FWALL:HV:L$i:vmon";
   Perl2Epics::Connect("$i",$s);
-  $s = "HAD:FWHV:L$i:imon";
+  $s = "HAD:FWALL:HV:L$i:imon";
   Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 1400;
@@ -166,7 +166,7 @@ while(1) {
       $ChnlsOn++;
       }
     else {
-      $str .= "$c off. ";
+      $str .= "#$c off. ";
       }
     if ($time > ($data->{$c}{tme}//0)+600)  {
       $ChnlsOld++;
@@ -184,7 +184,7 @@ while(1) {
      $longtext .= "<br>".$str;
 
   $qastate = QA::GetQAState('above', $ChnlsOn, @QA::FwHvLimits);   
-  if ($ChnlsOld >0) { $qastate = QA::WARN_2;}
+  if ($ChnlsOld > 10) { $qastate = QA::WARN_2;}
   if ($ChnlsOn <= 2){ $qastate = QA::ERROR;  $value = "OFF";}
   if ($QA::FwHvOff == 1) { $qastate = QA::OK;}
 
index fe5d70a9ba43cb7134957567d4c764034cf74792..9913a442433f81b355d8a311d79a710c6feee6b0 100755 (executable)
@@ -10,6 +10,8 @@ use IPC::Run3;
 use Data::Dumper;
 use Encode qw(decode encode from_to);
 use JSON;
+use Hmon;
+use QA;
 
 
 my $firstrun =1; 
@@ -22,7 +24,6 @@ $hash->{username}='daqi';
 while(1) {
 
   my @res = qx($command); 
-# print Dumper @res;
   my ($date,$topic,$user,$text);
 
   my $cnt = 0;
@@ -61,6 +62,7 @@ while(1) {
             );
         $ua->request($req);
 #         exit;
+        Hmon::Speak("logbook","There is a new lockbook entry to read.");
         }
       }
     $found = 0 if $found == 6;
@@ -68,6 +70,15 @@ while(1) {
     }
   $firstrun=0;
 #   exit;
+
+  my $str = Hmon::MakeTitle(12, 16, "HADES Logbook", 1, "");
+  shift @res for (0..8);
+  $str .= '<div id="logbox" class="textbox" >';
+  $str .= join("\n",@res);
+  $str .= "</div>";
+  $str .= Hmon::MakeFooter();
+  Hmon::WriteFile("Logbook", $str);  
+
   sleep 60;
   }
   
index a4878560872d7e349bfbda48ef3fc381acc7f130..c6a555c86fc7eedf056dfae906beee33679e4133 100755 (executable)
@@ -14,59 +14,59 @@ my $magnet_on = 1 - $QA::MagnetOff;
 
 my %range_list = (
                   'Time'             => {},
-                  'TC1200'           => {'min' => 5.2    , 'max' =>5.6  },
-                  'TC1266'           => {'min' => 4.9    , 'max' =>5.1  },
-                  'TC1202'           => {'min' => 4.4    , 'max' =>4.6  },
-                  'TC1208'           => {'min' => 4.5    , 'max' =>4.8  },
-                  'TC1214'           => {'min' => 4.4    , 'max' =>4.6  },
-                  'TC1220'           => {'min' => 4.4    , 'max' =>4.6  },
-                  'TC1226'           => {'min' => 4.5    , 'max' =>4.8  },
-                  'TC1232'           => {'min' => 4.4    , 'max' =>4.6  },
-                  'TC1206'           => {'min' => 4.0    , 'max' =>6.0  },
-                  'TC1212'           => {'min' => 3.7    , 'max' =>6.0  },
-                  'TC1218'           => {'min' => 6.0    , 'max' =>7.0  },
-                  'TC1224'           => {'min' => 6.0    , 'max' =>8.0  },
-                  'TC1230'           => {'min' => 4.6    , 'max' =>8.0  },
-                  'TC1236'           => {'min' => 4.4    , 'max' =>6.0  },
-                  'TC1238'           => {'min' => 4.6    , 'max' =>4.9  },
-                  'TC1248'           => {'min' => 4.5    , 'max' =>4.7  },
-                  'FI1400'           => {'min' => 0.36   , 'max' =>0.62 },
-                  'PSUI_rbk'         => {'min' => 2990   , 'max' =>3210 },
-                  'PSUV_rbk'         => {'min' => 0      , 'max' =>1    },
-                  'BBI'              => {'min' => 419    , 'max' =>620  },
-                  'LL1708'           => {'min' => 54     , 'max' =>65.0, 'minerror' => 53 },
-                  'TP1240'           => {'min' => 75.5   , 'max' =>89.0 , 'cal_max' => 2},
-                  'PI2610'           => {'min' => 1.7    , 'max' =>3.1  },
-                  'TP2200'           => {'min' => 83.0   , 'max' =>85.5 , 'cal_max' => 2},
-                  'TP2202'           => {'min' => 81.0   , 'max' =>87.0 , 'cal_max' => 2},
-                  'TP2204'           => {'min' => 81.0   , 'max' =>85.5 , 'cal_max' => 2},
-                  'TP2206'           => {'min' => 81.0   , 'max' =>85.0 , 'cal_max' => 2},
-                  'TP2208'           => {'min' => 87.0   , 'max' =>95.0 , 'cal_max' => 2},
-                  'TP2210'           => {'min' => 80.0   , 'max' =>85.0 , 'cal_max' => 2},
-                  'TP2212'           => {'min' => 82.0   , 'max' =>92.0 , 'cal_max' => 2},
-                  'TP2214'           => {'min' => 80.0   , 'max' =>85.0 , 'cal_max' => 2},
-                  'TP2216'           => {'min' => 80.0   , 'max' =>84.0 , 'cal_max' => 2},
-                  'TP2218'           => {'min' => 84.0   , 'max' =>90.5 , 'cal_max' => 2},
-                  'TP2220'           => {'min' => 80.0   , 'max' =>84.0 , 'cal_max' => 2},
-                  'TP2222'           => {'min' => 80.0   , 'max' =>86.0 , 'cal_max' => 2},
-                  'TP2224'           => {'min' => 81.0   , 'max' =>85.0 , 'cal_max' => 2},
-                  'TP2226'           => {'min' => 80.0   , 'max' =>100  , 'cal_max' => 2},
-                  'TP2228'           => {'min' => 85     , 'max' =>94.0 , 'cal_max' => 2},
-                  'TP2230'           => {'min' => 80.0   , 'max' =>85.5 , 'cal_max' => 2},
-                  'PI2600'           => {'min' => 1.65   , 'max' =>2.0  },
-                  'VG3000'           => {'min' => -6.5   , 'max' =>-5.5 },
-                  'PI1600'           => {'min' => 2.94   , 'max' =>3.03 },
-                  'PI1602'           => {'min' => 1.30   , 'max' =>1.37 },
-                  'PI1604'           => {'min' => 2.7    , 'max' =>2.99 },
-                  'PI1612'           => {'min' =>0       , 'max' =>12.0}, 
-                  'EV1100R'          => {'min' => 27     , 'max' =>45   },
-                  'EV1122R'          => {'min' => 55     , 'max' =>61   },
-                  'EV1128R'          => {'min' => 73     , 'max' =>88   },
-                  'TC1200M'          => {'min' => 6.5    , 'max' =>8.5  },
-                  'PI1600I'          => {'min' => 1.28   , 'max' =>1.37 },
+                  'TC1200'           => {'min' => 5.2    , 'max' => 5.6  },
+                  'TC1266'           => {'min' => 4.9    , 'max' => 5.1  },
+                  'TC1202'           => {'min' => 4.4    , 'max' => 4.6  },
+                  'TC1208'           => {'min' => 4.5    , 'max' => 4.8  },
+                  'TC1214'           => {'min' => 4.4    , 'max' => 4.6  },
+                  'TC1220'           => {'min' => 4.4    , 'max' => 4.6  },
+                  'TC1226'           => {'min' => 4.5    , 'max' => 4.8  },
+                  'TC1232'           => {'min' => 4.4    , 'max' => 4.6  },
+                  'TC1206'           => {'min' => 4.0    , 'max' => 6.0  },
+                  'TC1212'           => {'min' => 3.7    , 'max' => 6.0  },
+                  'TC1218'           => {'min' => 6.0    , 'max' => 7.0  },
+                  'TC1224'           => {'min' => 6.0    , 'max' => 8.0  },
+                  'TC1230'           => {'min' => 4.6    , 'max' => 8.0  },
+                  'TC1236'           => {'min' => 4.4    , 'max' => 6.0  },
+                  'TC1238'           => {'min' => 4.6    , 'max' => 4.9  },
+                  'TC1248'           => {'min' => 4.5    , 'max' => 4.7  },
+                  'FI1400'           => {'min' => 0.36   , 'max' => 0.62 },
+                  'PSUI_rbk'         => {'min' => 2990   , 'max' => 3210 },
+                  'PSUV_rbk'         => {'min' => 0      , 'max' => 1    },
+                  'BBI'              => {'min' => 419    , 'max' => 620  },
+                  'LL1708'           => {'min' => 54     , 'max' => 65.0 , 'minerror' => 53 },
+                  'TP1240'           => {'min' => 75.5   , 'max' => 89.0 , 'cal_max' => 2},
+                  'PI2610'           => {'min' => 1.7    , 'max' => 3.1  },
+                  'TP2200'           => {'min' => 83.0   , 'max' => 85.5 , 'cal_max' => 2},
+                  'TP2202'           => {'min' => 81.0   , 'max' => 87.0 , 'cal_max' => 2},
+                  'TP2204'           => {'min' => 81.0   , 'max' => 85.5 , 'cal_max' => 2},
+                  'TP2206'           => {'min' => 81.0   , 'max' => 85.0 , 'cal_max' => 2},
+                  'TP2208'           => {'min' => 87.0   , 'max' => 95.0 , 'cal_max' => 2},
+                  'TP2210'           => {'min' => 80.0   , 'max' => 85.0 , 'cal_max' => 2},
+                  'TP2212'           => {'min' => 82.0   , 'max' => 92.0 , 'cal_max' => 2},
+                  'TP2214'           => {'min' => 80.0   , 'max' => 85.0 , 'cal_max' => 2},
+                  'TP2216'           => {'min' => 80.0   , 'max' => 84.0 , 'cal_max' => 2},
+                  'TP2218'           => {'min' => 84.0   , 'max' => 90.5 , 'cal_max' => 2},
+                  'TP2220'           => {'min' => 80.0   , 'max' => 84.0 , 'cal_max' => 2},
+                  'TP2222'           => {'min' => 80.0   , 'max' => 86.0 , 'cal_max' => 2},
+                  'TP2224'           => {'min' => 81.0   , 'max' => 85.0 , 'cal_max' => 2},
+                  'TP2226'           => {'min' => 80.0   , 'max' => 100  , 'cal_max' => 2},
+                  'TP2228'           => {'min' => 85     , 'max' => 94.0 , 'cal_max' => 2},
+                  'TP2230'           => {'min' => 80.0   , 'max' => 85.5 , 'cal_max' => 2},
+                  'PI2600'           => {'min' => 1.65   , 'max' => 2.0  },
+                  'VG3000'           => {'min' => -6.5   , 'max' => -5.5 },
+                  'PI1600'           => {'min' => 2.94   , 'max' => 3.03 },
+                  'PI1602'           => {'min' => 1.30   , 'max' => 1.37 },
+                  'PI1604'           => {'min' => 2.7    , 'max' => 2.99 },
+                  'PI1612'           => {'min' => 0      , 'max' => 12.0 }, 
+                  'EV1100R'          => {'min' => 27     , 'max' => 45   },
+                  'EV1122R'          => {'min' => 55     , 'max' => 61   },
+                  'EV1128R'          => {'min' => 73     , 'max' => 88   },
+                  'TC1200M'          => {'min' => 6.5    , 'max' => 8.5  },
+                  'PI1600I'          => {'min' => 1.28   , 'max' => 1.37 },
                   'MV2102X'          => {},
                   'MV2102L'          => {},
-                  'MV2102LUX(a)'     => {'min' => .8     , 'max' =>8.0},
+                  'MV2102LUX(a)'     => {'min' => .8     , 'max' => 8.0  },
                   'MV2102U'          => {},
                   'EV2128E'          => {},
                   'EV2128F'          => {},
@@ -100,12 +100,15 @@ my $temperature_factor = 0;
 my $ssh_fh;
 
 foreach my $rh_val (keys %$range_list_href) {
+  Perl2Epics::Connect("$rh_val", "HAD:MAGNET:$rh_val");
+  #print("$rh_val HAD:MAGNET:$rh_val\n");
   if (defined $range_list_href->{$rh_val}->{'cal_max'}) {
     $range_list_href->{$rh_val}->{'max'} += $temperature_factor * $range_list_href->{$rh_val}->{'cal_max'};
   }
 }
 
 Perl2Epics::Connect("TS105", "HAD:CRYO:TS105");
+#print("TS105 HAD:CRYO:TS105\n");
 
 my $callEmergency = 0;
 
@@ -114,128 +117,50 @@ while (1) {
 
   my $fatal_error_string = "";
   my $current = "OFF";
-  my $get_filename_command = "ssh -o BatchMode=yes magnet\@hadesp28  \"ls -rtl /home/magnet/Hades_Magnet_Labview/Log/log1 | tail -n 1\"";
-  my @get_filename_result = qx($get_filename_command);
-  #printf("$get_filename_result[0]");
 
   my $title = "Magnet";
   my $value = "";
   my $longtext = "";
-  my $time = "--";
+  my $time = 0;
 
-  
-#ssh Log Loop
-  if ((scalar @get_filename_result) != 1) {
-    #if (!defined $ssh_fh || eof($ssh_fh)) {
-    $red_error_counter++;
-    $fatal_error_string = "No ssh connection to magnet PC";
-  } else {
-    my ($Sekunden, $Minuten, $Stunden, $Tag, $Monat,
-        $Jahr, $Wochentag, $Jahrestag, $Sommerzeit) = localtime(time);
-    $Monat += 1;
-    $Jahr  += 1900;
-    my $log_localtime = sprintf('%02d%02d%04d', $Tag, $Monat, $Jahr);
-      
-    my @get_filename_array = split(/\s+/,$get_filename_result[0]);
-    #printf("@get_filename_array\n");
-    $get_filename_array[8] =~ s/\n//g;
-      
-    #printf("$log_localtime $get_filename_array[8]\n");
-    if (!($log_localtime eq $get_filename_array[8])) {
-      $fatal_error_string = "Log file is not up-to-date";
-      $red_error_counter++;
-    } else {
-      my $log_file = "/home/magnet/Hades_Magnet_Labview/Log/log1/" . $log_localtime;
-      #check if file is increasing
-      if ($started == 1) {
-        $started = 0;
-        $last_mod_time = $Sekunden + 60*$Minuten + 60*60*$Stunden;
-        $last_size = $get_filename_array[4];
-      }
-      if ($last_size != $get_filename_array[4]) {
-        $last_mod_time = $Sekunden + 60*$Minuten + 60*60*$Stunden;
-        $last_size = $get_filename_array[4];
+  $red_error_counter   = 0;
+  $fatal_error_counter = 0;
+  $yellow_error_counter = 0;
+
+  my $epics = Perl2Epics::GetAll();
+  foreach my $name (keys %$range_list_href) {
+    my $val  = $epics->{$name}->{val};
+    $time = $epics->{$name}->{tme} if ($epics->{$name}->{tme} < $time) or ($time == 0);
+    if ($name eq 'PSUI_rbk') {
+      $current = $val;
+    }
+    $range_list_href->{$name}->{'value'} = $val;
+    if (defined $range_list_href->{$name}->{'max'} && $val > $range_list_href->{$name}->{'max'}) {
+      if ($yellow_error_counter>0) {
+        $fatal_error_string .= sprintf("<br> Value '$name' has %.2f, maximum is $range_list_href->{$name}->{'max'}",$val);
+      } else {
+        $fatal_error_string .= sprintf("Value '$name' has %.2f, maximum is $range_list_href->{$name}->{'max'}",$val);
       }
-      my $time_diff = ($Sekunden + 60*$Minuten + 60*60*$Stunden) - $last_mod_time;
-      if ($time_diff > 3*60+20) {
-        $fatal_error_string = "Log file not increased since $time_diff sec.";
-        $red_error_counter++;
+      $yellow_error_counter++;
+      $red_error_counter++ if (defined $range_list_href->{$name}->{'maxerror'} && $val > $range_list_href->{$name}->{'maxerror'});
+      $callEmergency++     if (defined $range_list_href->{$name}->{'maxerror'} && $val > $range_list_href->{$name}->{'maxerror'});;
+    }
+    if (defined $range_list_href->{$name}->{'min'} && $val < $range_list_href->{$name}->{'min'}) {
+      if ($yellow_error_counter>0) {
+        $fatal_error_string .= sprintf("<br> Value '$name' has %.2f, minimum is $range_list_href->{$name}->{'min'}",$val);
       } else {
-        my $get_filename_command = "ssh -o BatchMode=yes magnet\@hadesp28 \"tail -n 1 /home/magnet/Hades_Magnet_Labview/Log/log1/$get_filename_array[8]  \"";
-        my @get_value_array = qx($get_filename_command);
-        #printf("$get_filename_command");
-        #printf("@get_value_array");
-        $get_filename_command = "ssh -o BatchMode=yes magnet\@hadesp28 \"head -n 1 /home/magnet/Hades_Magnet_Labview/Log/log1/$get_filename_array[8] \"";
-        my @get_header_array = qx($get_filename_command);
-        #printf("@get_header_array");
-        if (scalar @get_header_array != 1 || scalar @get_value_array != 1) {
-          $fatal_error_string = "Log file has no header line";
-          $red_error_counter++;
-        } else {
-          my @get_header_array_split = split(/\s+/,$get_header_array[0]);
-          my @get_value_array_split = split(/\t+/,$get_value_array[0]);
-          if ((scalar @get_header_array_split) != (scalar @get_value_array_split) + 1) {
-            $fatal_error_string = "Log file entries not consistent";
-            print scalar @get_header_array_split . ":" . scalar @get_value_array_split . "\n";
-            $red_error_counter++;
-            #print $fatal_error_string . "\n";
-          } else {
-            my $old_error_counter  = $red_error_counter;
-            my $old_red_error_counter  = $red_error_counter;
-            my $old_fatal_error_counter  = $fatal_error_counter;
-            $time = $get_value_array_split[0];
-            $red_error_counter   = 0;
-            $fatal_error_counter = 0;
-            $yellow_error_counter = 0;
-            #print scalar @get_header_array_split . ":" . scalar @get_value_array_split . ":" . $nrOfValues . "\n";
-            for (my $i = 1; $i < scalar @get_header_array_split; $i++) {
-              #print $name . "\n";
-
-              my $name = $get_header_array_split[$i];
-              my $val  = $get_value_array_split[$i-1];
-              if (!defined $range_list_href->{$name}) {
-                $fatal_error_string = "Found entry '$name' which is not existing";
-                $red_error_counter = $old_red_error_counter + 1;
-              } else {
-                if ($name eq 'PSUI_rbk') {
-                  $current = $val;
-                }
-    
-    
-                $range_list_href->{$name}->{'value'} = $val;
-                if (defined $range_list_href->{$name}->{'max'} && $val > $range_list_href->{$name}->{'max'}) {
-                  if ($yellow_error_counter>0) {
-                    $fatal_error_string .= ", Value '$name' has $val, maximum is $range_list_href->{$name}->{'max'}";
-                  } else {
-                    $fatal_error_string .= "Value '$name' has $val, maximum is $range_list_href->{$name}->{'max'}";
-                  }
-                  $yellow_error_counter++;
-                  $red_error_counter++ if (defined $range_list_href->{$name}->{'maxerror'} && $val > $range_list_href->{$name}->{'maxerror'});
-                  $callEmergency++     if (defined $range_list_href->{$name}->{'maxerror'} && $val > $range_list_href->{$name}->{'maxerror'});;
-                }
-                if (defined $range_list_href->{$name}->{'min'} && $val < $range_list_href->{$name}->{'min'}) {
-                  if ($yellow_error_counter>0) {
-                    $fatal_error_string .= ", Value '$name' has $val, minimum is $range_list_href->{$name}->{'min'}";
-                  } else {
-                    $fatal_error_string .= "Value '$name' has $val, minimum is $range_list_href->{$name}->{'min'}";
-                  }
-                  $yellow_error_counter++;
-                  $red_error_counter++ if (defined $range_list_href->{$name}->{'minerror'} && $val < $range_list_href->{$name}->{'minerror'});
-                  $callEmergency++     if (defined $range_list_href->{$name}->{'minerror'} && $val < $range_list_href->{$name}->{'minerror'});
-                }
-              }
-            }                   #for
-            if ($yellow_error_counter>2) {
-              #print $yellow_error_counter . "\n";
-              $fatal_error_counter = $old_fatal_error_counter + $yellow_error_counter;
-            }
-          }
-        }
+        $fatal_error_string .= sprintf("Value '$name' has %.2f, minimum is $range_list_href->{$name}->{'min'}",$val);
       }
+      $yellow_error_counter++;
+      $red_error_counter++ if (defined $range_list_href->{$name}->{'minerror'} && $val < $range_list_href->{$name}->{'minerror'});
+      $callEmergency++     if (defined $range_list_href->{$name}->{'minerror'} && $val < $range_list_href->{$name}->{'minerror'});
     }
   }
+  if ($yellow_error_counter>2) {
+    #print $yellow_error_counter . "\n";
+    $fatal_error_counter = $yellow_error_counter;
+  }
 #EPICS Loop
-  my $epics = Perl2Epics::GetAll();
   my $val = $epics->{"TS105"}->{val} if $epics->{"TS105"}->{tme} != -1;
 #   print Dumper $epics;
   if(defined $val && ($val < 116 || $val > 121)) {
@@ -248,14 +173,14 @@ while (1) {
     $callEmergency=0;
   }
 
-  #Make Calls
-  printf "call Emergency: $callEmergency : not off: %d\n", !$QA::MagnetOff;
-  if(($callEmergency==3 || $callEmergency==6 ) && !$QA::MagnetOff) {
-    Hmon::CallScript("./magnet_emergency_call.sh","Magnet/Cryo","Fehler am Magnet");
-    }
-  if($callEmergency >= 60) {
-    $callEmergency = 0;
-    }
+  #Make Calls
+  printf "call Emergency: $callEmergency : not off: %d\n", !$QA::MagnetOff;
+  if(($callEmergency==3 || $callEmergency==6 ) && !$QA::MagnetOff) {
+    Hmon::CallScript("./magnet_emergency_call.sh","Magnet/Cryo","Fehler am Magnet");
+    }
+  if($callEmergency >= 60) {
+    $callEmergency = 0;
+    }
     
 #Output  
   if (!$magnet_on) {
@@ -279,6 +204,6 @@ while (1) {
     QA::WriteQALog($flog,"misc","magnet",$interval+20,QA::OK,$title,$value,$longtext);
     $last_good_time = $time;
   } 
-  print $fatal_error_string."\n";
+  #print $fatal_error_string."\n";
   sleep($interval);
 }
index fac078970c3feed9a767a29738fd7cee4a6fb8bc..7456deb820c454f4001b2975c0c28d711783aed5 100755 (executable)
@@ -6,18 +6,18 @@ use v5.10.0;
 
 
 my @cpus = qw |
-hades30 hades33 hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp28 hadesp30 hadesp31 hadesp33 hadesp57 hadesp63 hadesp66 hadesp70 lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhadesdaqp lxhadeb18p lxhadeb17p
+hades30 hades33 hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp28 hadesp30 hadesp31 hadesp33 hadesp57 hadesp63 hadesp66 hadesp70 lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhadesdaqp lxhadeb18p lxhadeb17p
 |;
 
 #lxhadeb07 lxhadeb08 lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 lxhadeb13 lxhadeb14 lxhadeb15 lxhadeb16  lxhaddcs05 lxhaddcs06 lxhaddcs11 lxhadesdaq hadesdaq01 hades30 ha#desp31 hades33 lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhaddcs05p lxhaddcs06p lxhaddcs11p lxhad#esdaqp hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp30 hadesp33 hadesp57 hadesp70
 
 for my $cpu (@cpus) {
-  my $c = "~/trbsoft/hadesdaq/hmon/hmon_ssh $cpu -N -f </dev/null >/dev/null&";
+  my $c = "~/trbsoft/hadesdaq/hmon/hmon_ssh hadaq\@$cpu -N -f </dev/null >/dev/null&";
 
   if ($cpu =~ /hadesp28/) {
     $c=~s/hadaq\@/magnet\@/;
   }
-  if ($cpu =~ /hades13p/) {
+  if ($cpu =~ /lxhadeb13p/) {
     $c=~s/hadaq\@/hades-qa\@/;
   }
   #my $c = "~/trbsoft/hadesdaq/hmon/hmon_ssh hadaq\@$cpu -N -f";
index 78e5c8be947a5e6a70bfeaeb496079d004680481..767403dfe3a4e6c463857b21c502c71b6bbe631f 100755 (executable)
@@ -14,6 +14,7 @@ use List::Util qw[min max];
 use Encode qw(encode from_to);
 use JSON::XS;
 
+#5000/20/2100 are hardcoded defaults in FPGA design
 my $MINRATE = 5000; #minimum counts in 42ms
 my $BINWIDTH = 20; # µs bin width
 my $BINPERMEAN = 2100; #bins per read number set
@@ -32,8 +33,8 @@ HPlot::PlotInit({
     titles  => [],
     xlabel  => "Time [s] (".($BINWIDTH*$BINPERMEAN/1000)." ms binning)",
     ylabel  => "QFactor",
-    sizex   => 950,
-    sizey   => 280,
+    sizex   => 650,
+    sizey   => 330,
     ymin    => "0.95",
     ymax    => "10.05",
 #    ymax    => "1.05<*",
@@ -94,22 +95,45 @@ HPlot::PlotInit({
     output  => HPlot::OUT_PNG,
     zlabel  => "Hitrate",
     sizex   => 310,
-    sizey   => 310,
+    sizey   => 250,
     nokey   => 1,
     buffer  => 1,
-    ymin    => 15.5,
-    ymax    => -0.5,
+    ymin    => -0.5,
+    ymax    => 15.5,
     xmin    => -0.5,
     xmax    => 15.5,
     cbmax   => "100<*<1E5",
     cbmin   => 1,
     noinit  => 1,
-    additional => "set logscale cb;unset ytics;set format cb \"_{10}{\%L}\"",
+    additional => "set logscale cb;set format cb \"_{10}{\%L}\"",
     showvalues => 0, 
     });
 
-
-my $str  = Hmon::MakeTitle(12, 6, "Beam QFactor",0);
+HPlot::PlotInit({
+    name    => "StartClusterSize",
+    file    => "files/StartClusterSize",
+    entries => 8,
+    type    => HPlot::TYPE_BARGRAPH,
+    output  => HPlot::OUT_PNG,
+    titles  => ["X","Y"],
+    xlabel  => "Multiplicity",
+    ylabel  => "Hitrate [Hz]",
+    nokey   => 0,
+    sizex   => 350,
+    sizey   => 330,
+    xmin    => -0.5,
+    xmax    => 7.5,
+    ymin    => "0",
+    ymax    => "100<*",
+    curves  => 2,
+    buffer  => 1,
+    bargap  => 0.1,
+    stacked => 0,
+    curvewidth  => .9,
+    });
+    
+    
+my $str  = Hmon::MakeTitle(8, 7, "Beam QFactor",0);
 $str .= qq@<img src="%ADDPNG files/QFactor.png%" type="image/png">\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("QFactor",$str);
@@ -120,12 +144,25 @@ $str .= qq@<img src="%ADDPNG files/MicroRate10ms.png%" type="image/png"><br>\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("MicroSpillStructure",$str);
 
-$str  = Hmon::MakeTitle(4, 7, "StartMap",0);
-$str .= qq@<img src="%ADDPNG files/StartMap.png%" type="image/png"><br>\n@;
+$str  = Hmon::MakeTitle(12, 7, "Spill micro-structure",0);
+$str .= qq@<img src="%ADDPNG files/MicroRate.png%" type="image/png">\n@;
 $str .= Hmon::MakeFooter();
-Hmon::WriteFile("StartMap",$str);
+Hmon::WriteFile("MicroSpillStructureShort",$str);
 
+$str  = Hmon::MakeTitle(12, 7, "Spill micro-structure",0);
+$str .= qq@<img src="%ADDPNG files/MicroRate10ms.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("MicroSpillStructureLong",$str);
 
+$str  = Hmon::MakeTitle(5, 7, "StartMap",0);
+$str .= qq@<div style="padding-top:35px;padding-left:15px;overflow:hidden;height:500px;width:90%;text-align:center;"><img src="%ADDPNG files/StartMap.png%" type="image/png" style="transform:rotate(45deg);"></div>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartMap",$str);
+
+$str  = Hmon::MakeTitle(5, 7, "Start Cluster Size",0);
+$str .= qq@<img src="%ADDPNG files/StartClusterSize.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartClusterSize",$str);
 
 trb_init_ports() or die trb_strerror();
 
@@ -134,6 +171,9 @@ my $oldtime = time();
 my $time = time();
 my $diff;
 my $round = 0;
+my @xpos = (15,13,11,9,7,5,3,1,0,2,4,6,8,10,12,14);
+my @ypos = (0,2,4,6,8,10,12,14,15,13,11,9,7,5,3,1);
+
 while(1) {
 
   
@@ -192,25 +232,82 @@ while(1) {
     HPlot::PlotDraw('MicroRate10ms');
     }
 
-  $o = trb_register_read_mem(0xffff,0xba00,0,256) or print trb_strerror() or sleep 5 and next;
+  $o = trb_register_read_mem(0xffff,0xba00,0,272) or print trb_strerror() or sleep 5 and next;
 
   if (defined $old) {
     my $tdiff = (time() - $oldtime)|1;
     foreach my $b (keys %$o) {
 
-      for my $v (0..255) {
-        my $vdiff = ($o->{$b}->[$v]&0xfffff) - ($old->{$b}->[$v]&0xfffff);
+#       for my $v (0..255) {
+      for my $x (0..15) {
+        for my $y (0..15) {
+          my $v = $x + $y * 16;
+          my $vdiff = ($o->{$b}->[$v]&0xfffff) - ($old->{$b}->[$v]&0xfffff);
+          if ($vdiff < 0) { $vdiff += 2**20;}
+          $diff->[$xpos[$x]][$ypos[$y]] = $vdiff/$tdiff;
+          }
+        }
+      
+
+      for my $x (0..15) {
+        for my $y (0..15) {
+          if($x == 2) {
+            $diff->[2][$y] /= 2;
+            $diff->[4][$y] = $diff->[2][$y]; 
+            }
+          if($x == 3) {
+            $diff->[3][$y] /= 2;
+            $diff->[5][$y] = $diff->[3][$y]; 
+            }
+          if($x == 13) {
+            $diff->[13][$y] /= 2;
+            $diff->[11][$y] = $diff->[13][$y]; 
+            }
+          if($x == 12) {
+            $diff->[12][$y] /= 2;
+            $diff->[10][$y] = $diff->[12][$y]; 
+            }
+          }
+        }
+      for my $x (0..15) {
+        for my $y (0..15) {
+          if($y == 2) {
+            $diff->[$x][2] /= 2;
+            $diff->[$x][4] = $diff->[$x][2]; 
+            }
+          if($y == 3) {
+            $diff->[$x][3] /= 2;
+            $diff->[$x][5] = $diff->[$x][3]; 
+            }
+          if($y == 13) {
+            $diff->[$x][13] /= 2;
+            $diff->[$x][11] = $diff->[$x][13]; 
+            }
+          if($y == 12) {
+            $diff->[$x][12] /= 2;
+            $diff->[$x][10] = $diff->[$x][12]; 
+            }
+          }
+        }
         
+      for my $x (0..15) {
+        for my $y (0..15) {
+          HPlot::PlotFill('StartMap',$diff->[$x][$y],$x,$y);
+          }
+        }  
+#Multiplicities
+      for my $i (0..15) {
+        my $v = $i + 256;
+        my $vdiff = ($o->{$b}->[$v]&0xfffff) - ($old->{$b}->[$v]&0xfffff);
         if ($vdiff < 0) { $vdiff += 2**20;}
-        $diff->{$b}->[$v] = $vdiff/$tdiff;
-        #$ratesum += $diff->{$b}->[$v+1];
-#         print "$v $diff->{$b}->[$v]\n";
-        HPlot::PlotFill('StartMap',$diff->{$b}->[$v],$v%16,$v/16);
+        my $d = $vdiff/$tdiff;      
+        HPlot::PlotFill('StartClusterSize',$d,$i%8,$i/8);
         }
-
       }
-    HPlot::PlotDrawFork('StartMap');    
+      
+
+    HPlot::PlotDrawFork('StartMap');
+    HPlot::PlotDrawFork('StartClusterSize');
     
     
 
index f43806c477ae71ceab43234352a9b49ea56ba83d..c15823b8567cc3962046470f4f22187cd78c610e 100755 (executable)
@@ -60,6 +60,7 @@ echo "  <Hmon>     Linking files to server..."
 ln -fs `pwd`/archive /srv/www/htdocs/mon/
 #ln -fs `pwd`/qa /srv/www/htdocs/mon/
 #ln -fs `pwd`/vertex /srv/www/htdocs/mon/
+ln -fs `pwd`/qawindows /srv/www/htdocs/mon/
 ln -fs `pwd`/files /srv/www/htdocs/mon/
 ln -fs `pwd`/doc /srv/www/htdocs/mon/
 ln -fs `pwd`/doc.cgi /srv/www/htdocs/mon/
index c32303b98cf514f2283c0fb11cc6e13d511f2a11..410de6cadc0b40cd339ce8aaccb5d5ce899d18f3 100644 (file)
@@ -175,12 +175,13 @@ table {
   }
     
 
-.textbox, #logbox {  
+.textbox, #logbox, table.data {  
   margin:auto;
   background:white;
   font-family: monospace;
   text-align:left;
   overflow-y:scroll;
+  overflow-x:hidden;
   }
   
 .height9 .textbox {  height:420px;  }  
@@ -542,3 +543,30 @@ div.flex table {
 .bwh {background:#eee !important;}
 .bmg {background:#f0a !important;}
   
+
+table.data {
+    border-collapse:collapse;
+    font-size : 120%;
+  }  
+  
+table.data td{
+  border:2px solid black;
+}
+
+table.data>tbody>tr>td:nth-child(6) {
+  font-size:14pt;
+}
+table.data>tbody>tr>td:nth-child(2) {
+  width:100px;
+}
+
+
+table.data>tbody>tr> td:nth-child(3), table.data>tbody>tr> th:nth-child(3),
+table.data>tbody>tr> td:nth-child(1), table.data>tbody>tr> th:nth-child(1){
+  max-width:0px;
+  width:0px;
+  margin:0;
+border:0;
+padding:0;
+  overflow:hidden;
+}
diff --git a/hmon/stylesmonitor.css b/hmon/stylesmonitor.css
new file mode 100644 (file)
index 0000000..7b429b4
--- /dev/null
@@ -0,0 +1,3 @@
+html{  
+  scrollbar-width:none;
+}
similarity index 100%
rename from spillmon/startup.sh
rename to spillmon/old/startup.sh