]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
latest updates to hmon scripts
authorhadaq <jan@lxhadeb07>
Wed, 15 Nov 2023 16:40:35 +0000 (17:40 +0100)
committerhadaq <jan@lxhadeb07>
Wed, 15 Nov 2023 16:40:35 +0000 (17:40 +0100)
44 files changed:
control/gui/daq/50_Cosmics_Files [moved from control/gui/daq/50_COSMICS_Files with 100% similarity]
control/gui/daq/52_Test_Files [moved from control/gui/daq/52_TEST_File with 100% similarity]
control/gui/expert/30_TDC_Caltest [moved from control/gui/expert/30_Start_TDC_Caltest with 100% similarity]
control/gui/expert/old/31_Stop_TDC_Caltest [moved from control/gui/expert/31_Stop_TDC_Caltest with 100% similarity]
control/gui/monitor/10_CTS_Monitor [moved from control/gui/monitor/10_CTS_Mon with 100% similarity]
control/gui/monitor/30_EPICS [moved from control/gui/monitor/30_EPICS_Power with 100% similarity]
control/gui/monitor/80_Daq_Expert_VNC [moved from control/gui/monitor/80_Daq_VNC with 100% similarity]
control/gui/monitor/old/10_CTS_Mon.png [moved from control/gui/monitor/10_CTS_Mon.png with 100% similarity]
control/gui/monitor/old/20_Hmon.png [moved from control/gui/monitor/20_Hmon.png with 100% similarity]
control/gui/monitor/old/40_Eventbuilder.png [moved from control/gui/monitor/40_Eventbuilder.png with 100% similarity]
control/gui/monitor/old/45_DAQ_RawMon.png [moved from control/gui/monitor/45_DAQ_RawMon.png with 100% similarity]
control/gui/power/Ecal_Padiwa [moved from control/gui/power/ECAL_Padiwa_Powercycle with 100% similarity]
control/gui/power/Ecal_RPC [moved from control/gui/power/ECAL_RPC_Powercycle with 100% similarity]
control/gui/power/Hubs [moved from control/gui/power/HUBS_Powercycle with 100% similarity]
control/gui/power/MDC_LV [moved from control/gui/power/MDC_LV_Powercycle with 100% similarity]
control/gui/power/MDC_Relais_On [moved from control/gui/power/MDC_LV_Turn_On_ALL_Relais with 100% similarity]
control/gui/power/RICH [moved from control/gui/power/RICH_Powercycle with 100% similarity]
control/gui/power/Start [moved from control/gui/power/Start_Powercycle with 100% similarity]
control/gui/power/TOF_MdcHub [moved from control/gui/power/TOF_MdcHub_Powercycle with 100% similarity]
control/gui/power/Triggerbox_Beam [moved from control/gui/power/Triggerbox_Beam_Powercycle with 100% similarity]
control/gui/power/Wall [moved from control/gui/power/Wall_Powercycle with 100% similarity]
control/gui/power/old/Hodo [moved from control/gui/power/Hodo_Powercycle with 100% similarity]
control/gui/settings/20_Beam_Abort_OnOff [moved from control/gui/settings/Beam_Abort_Toggle with 100% similarity]
control/gui/settings/21_Beam_Abort_Reset [moved from control/gui/expert/Reset_Beamabort_Error with 100% similarity]
control/gui/settings/Ecal_Thrs [moved from control/gui/settings/Thresholds_ECAL with 100% similarity]
control/gui/settings/RICH_Thrs [moved from control/gui/settings/Thresholds_RICH with 100% similarity]
control/gui/settings/RPC_Thrs [moved from control/gui/settings/Thresholds_RPC with 100% similarity]
control/gui/settings/Start_Thrs [moved from control/gui/settings/Thresholds_Start with 100% similarity]
control/gui/settings/TOF_FW_Thrs [moved from control/gui/settings/Thresholds_TOF_FW with 100% similarity]
hmon/QA.pm
hmon/doc/endp-mdc.htt
hmon/hmon_adcvolt.pl
hmon/hmon_calibration.pl
hmon/hmon_endpoints.pl
hmon/hmon_padiwatemp_ecal.pl
hmon/hmon_richMagnet.pl
hmon/hmon_tdcchanerrors_testmonitor.pl [new file with mode: 0755]
hmon/hmon_tofrate.pl
hmon/index.cgi
hmon/monitor.cgi
hmon/permanent/hmon_caveTemp.pl [new file with mode: 0755]
hmon/permanent/hmon_ecalhv.pl
hmon/permanent/hmon_fwhv.pl
hmon/permanent/hmon_hvcrates.pl [new file with mode: 0755]

index d7ca6624aa10f6bf510d95d20f721b49c7df86f4..9e006070f54beb58ed3c046fa6909872598f5fbe 100644 (file)
@@ -14,13 +14,15 @@ our $cats = {'main'=>"Main",
              'mdc'=>"MDC",
              'endp'=>"Endp",
              'feeerr'=>"Fee",
-             'other'=>"Other",
+#             'other'=>"Othe",
              'pion'=>"Pion",
              'rich'=>'RICH',
              'padiwa'=>'Padiwa',
              'hv'=>'HV',
              'hv2'=>'HV',
-             'misc'=>'misc'};
+             'misc'=>'misc',
+             'misc2'=>'misc',
+};
 
 # Order of categories
 our $entries->{'cats'} = ["main",
@@ -34,10 +36,11 @@ our $entries->{'cats'} = ["main",
                           "feeerr",
 #                          "pion",
                           "rich",
-                         "padiwa",
+#                        "padiwa",
                           "hv",
                           "hv2",
                           "misc",
+                         "misc2",
 
 ];
 
@@ -45,17 +48,19 @@ 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','nothing','pt8'];
-$entries->{'server'}  = ['fill', 'cpu', 'to see', 'here', 'onlineqa']; #icinga, pwrsup
+$entries->{'rate'}    = ['pt1','pt2','pt3','here','pt8'];
+$entries->{'server'}  = ['fill', 'cpu', 'be', 'dragons', 'onlineqa']; #icinga, pwrsup
 $entries->{'eb'}      = ['run', 'rate','bytes', 'lostevt', 'errbits'];
 $entries->{'mdc'}     = ['token', 'blocked', 'temp', 'linkqual', 'voltage'];
 $entries->{'endp'}    = ['mdc','rich', 'tof', 'rpc', 'other'];
 $entries->{'feeerr'}  = ['feeerr','trginp','trgqual','rpc','tof'];
 $entries->{'rich'}    = ['temp','LV','bkpl','isob','richthr'];
-$entries->{'padiwa'}  = ['ecal','start','','',''];#'sts','itof','hodo'
+#$entries->{'padiwa'}  = ['ecal','start','sts','itof','hodo'];
 $entries->{'hv'}      = ['richhv','ecalhv','rpchv','fwhv','tofhv'];
-$entries->{'hv2'}     = ['mdchv','','','','valve'];#stshv,frpchv,itofhv
+#$entries->{'hv2'}     = ['mdchv','stshv','frpchv','itofhv','valve'];
+$entries->{'hv2'}     = ['mdchv','','','','valve'];
 $entries->{'misc'}    = ['seu','calib','magnet','env','sequencer'];
+$entries->{'misc2'}   = ['ecal','m1','m2','m3','m4'];
 
 
 $entries->{'pion'}    = ['nxstatus', 'HV', 'HVcurr', 'cooling','seu'];
@@ -160,9 +165,9 @@ our $QAServerOff = 1;
 #  Missing Boards
 ###############################################################################
 
-our @mdc_boards_removed =(0x2203, 0x2027, 0x2057); #(0x2257, 0x2029); # 2233 added 2014-08-28 , 2203 at 2014/09/03, 2029 2014/09/23
+our @mdc_boards_removed =();#(0x2203, 0x2027, 0x2057); #(0x2257, 0x2029); # 2233 added 2014-08-28 , 2203 at 2014/09/03, 2029 2014/09/23
 our @mdc_chambers_removed =();
-our @rich_boards_removed =(0x71a4,0x71a5,0x71b4,0x71b5,0x72a4,0x72a5,0x72b4,0x72b5,0x73a4,0x73a5,0x73b4,0x73b5,0x826a);
+our @rich_boards_removed =();#(0x71a4,0x71a5,0x71b4,0x71b5,0x72a4,0x72a5,0x72b4,0x72b5,0x73a4,0x73a5,0x73b4,0x73b5,0x826a);
 our @tof_boards_removed =();
 our @rpc_boards_removed =();
 our @other_boards_removed =();
index da4e0d4bd209b096d7e0f63097e7eeee1350faa1..d9cd0ef0d1459bc39f2caaa5806dd7ad4d25d2fa 100644 (file)
@@ -1,6 +1,6 @@
 <h3>MDC Endpoints</h3>
 
-This button shows if all MDC front-end modules are active. The button is red if too many modules are 
+This button shows if all MDC boards (OEP, MDC-Hub) are active. The button is red if too many modules are 
 missing or two boards in the same chamber are missing or few boards are missing for a long time.<br>
 
 
@@ -11,7 +11,7 @@ missing or two boards in the same chamber are missing or few boards are missing
 <li>If this doesn't help, use "Reboot MdcHub" plus 2 DAQ restarts.
 <li>If the missing boards include a hub (0x1___) and a restart doesn't help, a power cycle of MDC Hubs might be needed.
 <li>If 14/16 boards show an error after a power-cycle, click "MDC LV Turn On ALL Relais". You can 
-check the status of relais <a href="/mon/monitor.cgi?1-window-MDCLV">here</a>.
+check the status of relais <a href="/mon/monitor.cgi?5-window-MDCLV">here</a>.
 </ul>
 <br>
 
index 79cad3251bf2c5be149113df590f419f3f1726a3..db0d70663ce8659871977be5d0b4fa4a37bc74fd 100755 (executable)
@@ -196,7 +196,8 @@ sub measure {
 while(1) {
 
   my $ret;
-  my $EPICS_data = Perl2Epics::GetAll();
+#  my $EPICS_data = Perl2Epics::GetAll();
+  my $EPICS_data;
 
 #   foreach my $a (@{$config{AdcTrb3sc}}) {
 #     $ret->[0] = measure($a,0);
index 26764e28c8180758a1174646b91febd01dc05fed..44e0fdf53e1ba569734324ce24e26b6eaaf80fd6 100755 (executable)
@@ -25,7 +25,7 @@ trb_init_ports() or die trb_strerror();
 while(1){
   my $data = getjsonhash('eb', 'Master/BNET/get.json');
   unless($data->{Inputs}{value}) {sleep 5; next;}
-  
+#print Dumper $data;  
   
   my $export;
   my $store;
index 704f1f1e7dbf94bc014426ff64e4643e1271f0dd..833778171d419cc2e90c991ea92d7c1927e987d0 100755 (executable)
@@ -448,7 +448,7 @@ while(1) {
     my $num_rpc_mistake = (scalar @{$rpc_results[4]});
     my @sorted_rpc_results = sort @{$rpc_results[2]};
 
-    my $rpc_title    = "ECal/STT/fRPC";
+    my $rpc_title    = "ECal";
     my $rpc_value    = "OK ".(scalar @rpc_boards);
     if ($num_rpc_missing > 0) {$rpc_value = "$num_rpc_missing / ".(scalar @rpc_boards)." miss";} 
     if ($num_rpc_mistake > 0) {$rpc_value = "Check Script";} 
index bd7ed0568d20ecc6eb4026cfac9bdb25459b165b..a4c6c82df32be0d2d7d61b83e8db0f4578b15e15 100755 (executable)
@@ -87,7 +87,7 @@ while(1) {
     $worstQaState = QA::OK;
     }
 
-  QA::WriteQALog($fqa,"padiwa","ecal", 45, $worstQaState, "ECAL", $nofStr . " | " . $tempStr, 
+  QA::WriteQALog($fqa,"misc2","ecal", 45, $worstQaState, "ECAL", $nofStr . " | " . $tempStr, 
     $tempStr2. "Temperature in ECAL " . $tempStr . "°C.<br>" . $nofStr2 . $nofStr . " PADIWAs<br>" . " Missing are: " . $missing_str);
 
   sleep(10);
index 3afb0824078a564154f7c645bd8991d4ac976941..ea7dc8324b3f3d3fc9428962f98991267aec0db6 100755 (executable)
@@ -340,7 +340,8 @@ sub Val2Hist {
   my ($Hist,$val,$board,$sens) = @_;
 #  print "$val  $board   $sens \n";
   if ($board == 0) {
-    $board=7-$sens; $sens=8-$sens;
+    #$board=7-$sens; $sens=8-$sens;
+    return; # JOF: Since Arm 0 is not working '23-11-15
   } elsif ($board == 1) {
     $board = 7-$sens; $sens = 4;
   } elsif ($board == 2) {
diff --git a/hmon/hmon_tdcchanerrors_testmonitor.pl b/hmon/hmon_tdcchanerrors_testmonitor.pl
new file mode 100755 (executable)
index 0000000..b4e9bfc
--- /dev/null
@@ -0,0 +1,411 @@
+#!/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 = 9;
+my $SERVER = 'calib';   #calib or calibtest
+  
+
+  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(LeadingAverage[ns] LeadingSigma[ps] IgnoredOutliers IgnoredHits ToTAverage[ns] ToTSigma[ps] IgnoredToTOutliers IgnoredToT CorrectedHits);
+  
+HPlot::PlotInit({
+  name    => "TdcCalMon0",
+  file    => "files/TdcCalMon0",
+  cblabel   => "TdcCalMon ".$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   => -10,
+  cbmax   => 10,
+  noinit  => 1,
+  palette => 'defined (-10 "red", -9 "yellow", 9 "blue", 10 "red")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon1",
+  file    => "files/TdcCalMon1",
+  cblabel   => "TdcCalMon ".$names[1],
+  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   => 200,
+  noinit  => 1,
+  palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "#ffff00", 35 "#ffaaaa", 50 "#ff00ff", 50.1 "#aa0000", 200 "#000000")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon2",
+  file    => "files/TdcCalMon2",
+  cblabel   => "TdcCalMon ".$names[2],
+  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,
+  noinit  => 1,
+#   palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon3",
+  file    => "files/TdcCalMon3",
+  cblabel   => "TdcCalMon ".$names[3],
+  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,
+  noinit  => 1,
+#   palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")',
+  additional => $labels,
+  showvalues => 0,  });  
+  
+###################################################################################################  
+  
+HPlot::PlotInit({
+  name    => "TdcCalMon4",
+  file    => "files/TdcCalMon4",
+  cblabel   => "TdcCalMon ".$names[4],
+  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   => 19,
+  cbmax   => 31,
+  noinit  => 1,
+  palette => 'defined (19 "red", 19.8 "red", 20 "green", 20.2 "red", 29.8 "red", 30 "blue", 30.2 "red", 31 "red")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon5",
+  file    => "files/TdcCalMon5",
+  cblabel   => "TdcCalMon ".$names[5],
+  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   => 400,
+  noinit  => 1,
+  palette => 'defined (0 "red", 0.1 "#008800", 40 "#00ff00", 50 "#ffff00", 51 "orange", 100 "#ffaaaa", 120 "#ff00ff", 120.1 "#aa0000", 400 "#000000")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon6",
+  file    => "files/TdcCalMon6",
+  cblabel   => "TdcCalMon ".$names[6],
+  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,
+  noinit  => 1,
+#   palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")',
+  additional => $labels,
+  showvalues => 0,  });
+
+HPlot::PlotInit({
+  name    => "TdcCalMon7",
+  file    => "files/TdcCalMon7",
+  cblabel   => "TdcCalMon ".$names[7],
+  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,
+  noinit  => 1,
+#   palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")',
+  additional => $labels."set logscale cb;",
+  showvalues => 0,  });  
+
+HPlot::PlotInit({
+  name    => "TdcCalMon8",
+  file    => "files/TdcCalMon8",
+  cblabel   => "TdcCalMon ".$names[8],
+  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,
+  noinit  => 1,
+  cbmin   => 0,
+  cbmax   => 0.1,
+  palette => 'defined (0 "#004400", 0.000001 "#00ff00", 0.0009 "#33ff00", 0.001 "yellow", 0.1 "red")',
+  additional => $labels,#."set logscale cb;",
+  showvalues => 0,  });    
+
+while(1){  
+###################################################################################################  
+  #loop until run is finished
+  print "Wait for end of analysis run\n";
+  my $eventhist;
+  my $oldevnum; my $evnum=0;
+  do{
+    $oldevnum = $evnum;
+    $eventhist = getroothist($SERVER,"/HADES/Run/HLD/HLD_EvType");
+    $evnum =  $eventhist->{bins}[13];
+    print "run".$evnum."\n";
+    sleep 10;
+    }while($evnum == 0 || $evnum != $oldevnum);
+
+###################################################################################################  
+  print "End detected. Start to work\n";
+
+  my $str  = Hmon::MakeTitle(200, 110, "TDC Cal Mon",1);
+  $str .= '<p>'.QA::getTimeString().'</p>';
+  $str .= '<p> Working</p>';
+  $str .= Hmon::MakeFooter();
+  Hmon::WriteFile("TdcCalMon",$str);  
+
+
+  my $datahistlist = getjsonhash($SERVER,'h.json');
+  #print Dumper $datahistlist->{'_allnames'};
+
+  $entry = -1;
+  
+  foreach my $b (sort {$a <=> $b} keys %$boards) {
+    $entry++;
+    my $activechannels = $boards->{$b}{enable};
+    
+    my $p = sprintf("TDC_%04X_Edges",$b);
+       $p = $datahistlist->{'_allnames'}{$p};
+    my $hits = getroothist($SERVER,$p)     if($p)   ;
+    next unless $hits;
+    
+       $p = sprintf("TDC_%04X_CorrectedHits",$b);
+       $p = $datahistlist->{'_allnames'}{$p};
+    my $corr = getroothist($SERVER,$p)    if($p)   ;
+    next unless $corr;
+    
+    for(my $i=1;$i<=48;$i++) {
+      next unless $activechannels & (1<<($i-1));
+      next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); 
+      
+      my $avg = ($corr->{bins}[$i]//0) / ($hits->{bins}[$i*2]||1);
+      HPlot::PlotFill("TdcCalMon8",$avg,$entry,$i);
+      }
+    }
+  
+  $entry = -1;
+  foreach my $b (sort {$a <=> $b} keys %$boards) {
+    $entry++;
+    my $activechannels = $boards->{$b}{enable};
+    
+    my $p = sprintf("TDC_%04X_RisingChanneslDiff",$b);
+    $p = $datahistlist->{'_allnames'}{$p};
+    if($p) { 
+      my $d = getroothist($SERVER,$p);
+      next unless $d;
+      
+      for(my $i=1;$i<=48;$i++) {
+        next unless $activechannels & (1<<($i-1));
+        next if($b < 0x5008 && $b >= 0x5000 && !($i&1)); 
+        
+        my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i]);
+        
+        $avg = ($avg/100.-10);
+        $sigma = ($sigma*10);
+        #printf("%04x\t%i\n",$b,$sigma);
+        HPlot::PlotFill("TdcCalMon0",$avg,$entry,$i);
+        HPlot::PlotFill("TdcCalMon1",$sigma,$entry,$i);
+        HPlot::PlotFill("TdcCalMon2",$outlier,$entry,$i);
+        HPlot::PlotFill("TdcCalMon3",$ignored,$entry,$i);
+        }
+      }
+
+    $p = sprintf("TDC_%04X_TotVsChannel",$b);
+    $p = $datahistlist->{'_allnames'}{$p};
+    if($p) { 
+      my $d = getroothist($SERVER,$p);
+      next unless $d;
+      
+      for(my $i=1;$i<=48;$i++) {
+        next unless $activechannels & (1<<($i-1));
+        next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); 
+        
+        my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],1460,1540) if ($b < 0x7000);
+           ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],960,1040) if ($b >= 0x7000);
+        
+        $avg = ($avg/50);
+        $sigma = ($sigma*20);
+        #printf("%04x\t%i\n",$b,$sigma);
+        HPlot::PlotFill("TdcCalMon4",$avg,$entry,$i);
+        HPlot::PlotFill("TdcCalMon5",$sigma,$entry,$i);
+        HPlot::PlotFill("TdcCalMon6",$outlier,$entry,$i);
+        HPlot::PlotFill("TdcCalMon7",$ignored,$entry,$i);
+        }
+      }      
+      
+#     last if $entry == 150;
+    }
+  
+  
+  for(my $e = 0; $e < $NUMPLOTS; $e++) {
+    HPlot::PlotDraw("TdcCalMon$e");  
+    }  
+
+  $str  = Hmon::MakeTitle(200, 110, "TDC Cal Mon",1);
+  $str .= '<p>'.QA::getTimeString().'</p>';
+  for(my $e = 0; $e < $NUMPLOTS; $e++) {
+    $str .= qq@<img src="%ADDPNG files/TdcCalMon@.$e.qq@.png%" type="image/png"><br>\n@;
+    }
+  $str .= Hmon::MakeFooter();
+  Hmon::WriteFile("TdcCalMon",$str);  
+
+
+  do{
+    $oldevnum = $evnum;
+    $eventhist = getroothist($SERVER,"/HADES/Run/HLD/HLD_EvType");
+    $evnum =  $eventhist->{bins}[13];
+    print "wait".$evnum."\n";
+    sleep 5;
+    }while($evnum == $oldevnum);
+}
+
+
+    
+sub stats {
+  my @arr = @{$_[0]};
+  my $minwindow = $_[1] // 0;
+  my $maxwindow = $_[2] // (scalar @arr-1);
+  
+  my $weightedsum = 0;
+  my $sigma = 0;
+  my $outlier = 0;
+  my $ignored = 0;
+  my $sum = 0;
+  my $sigmasum = 0;
+  
+  for my $i ($minwindow..$maxwindow){
+    $weightedsum += $arr[$i]*$i;
+    $sum += $arr[$i];
+    }
+  return (0,0,0,0,0) unless $sum;
+
+  my $avg = $weightedsum/$sum;
+  
+  for my $i (0..(scalar @arr-1)){
+    if ($i > $maxwindow || $i < $minwindow) {
+      $ignored += $arr[$i];
+      }
+    elsif($arr[$i] > 0 && $arr[$i] <= 2) {
+      $outlier+= $arr[$i];
+      }
+    else {  
+      $sigma += ($i-$avg)**2 * $arr[$i];
+      $sigmasum += $arr[$i];
+      }
+    }
+  $sigma = sqrt($sigma/($sigmasum||1));
+  
+  return ($sum,$avg,$sigma,$outlier,$ignored);
+  }
+    
index 6e11afbfabf92f0d8801b63a4dacde23e187f2a4..980493faff9002dffa24d84d0557f753216967e2 100755 (executable)
@@ -26,7 +26,7 @@ curves  => 30,
 type    => HPlot::TYPE_HEATMAP,
 output  => HPlot::OUT_PNG,
 zlabel  => "Hitrate",
-sizex   => 470,
+sizex   => 310,
 sizey   => 310,
 nokey   => 1,
 buffer  => 1,
@@ -42,7 +42,7 @@ showvalues => 0,  };
 HPlot::PlotInit($plot1);
 
 
-my $str  = Hmon::MakeTitle(6, 7, "TOF Hit Rate",0);
+my $str  = Hmon::MakeTitle(4, 7, "TOF Hit Rate",0);
 $str .= qq@<img src="%ADDPNG files/TofRate.png%" type="image/png"><br>\n@;
 
 $str .= Hmon::MakeFooter();
index cadc0fe94a047950f7417fbd898192cf01ce08f5..4464178f596c0019a439aef21f35206d9e04d641 100755 (executable)
@@ -38,10 +38,9 @@ function openwin(url) {
 </ul></div>
 
 <div class="linkbox" style="float:right"><h4>Documents</h4><ul>
-<li class="outdated"><a href="https://jspc29.x-matter.uni-frankfurt.de/docu/hadesoperator.pdf" style="color:#d33">Operator manual</a>
+<li><a href="https://hessenbox-a10.rz.uni-frankfurt.de/getlink/fiFyuhGJXrwV1dPs5RebuW/HadesOperatorManual.pdf" style="color:#d33">Operator manual</a>
+<li><a href="https://hessenbox-a10.rz.uni-frankfurt.de/getlink/fiRhk3zAKorCqtPgXk7hpa/">Document Repository</a>
 <li><a href="https://jspc29.x-matter.uni-frankfurt.de/docu/networkaddresses.pdf">DAQ FEE Addresses</a>
-<li><a href="https://jspc29.x-matter.uni-frankfurt.de/docu/HadesNotes.pdf">Drawings and Notes from the Logbook</a>
-<li><a href="https://hessenbox-a10.rz.uni-frankfurt.de/getlink/fiRhk3zAKorCqtPgXk7hpa/">Further Documents</a>
 <li><a href="phonenumbers.jpg">Phone Numbers</a>
 <li><a href="https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hlogbook2.form_selection">Beamtime Logbook</a></li>
 <li><a href="https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hshiftcrews2.form_select">Shift Crew</a></li>
@@ -54,7 +53,7 @@ function openwin(url) {
 <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-window26x9-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-window13x16-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-window13x23-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>
 </ul></div>
@@ -65,8 +64,7 @@ function openwin(url) {
 <li class="outdated"><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> -->
-<li class="outdated"><a href="http://hades63/icingaweb2/dashboard">Icinga Server Monitoring (local access only)</a>
-<li><a href="/calib">Calibration Monitor</a>
+<!--<li class="outdated"><a href="http://hades63/icingaweb2/dashboard">Icinga Server Monitoring (local access only)</a>-->
 <li><a href="/munin">Munin Server Monitoring</a></li>
 <li style="width:600px;"><a href="archive/?C=M;O=D">Archive of Hmon Windows (updated every 10 minutes)</a></li>
 </ul></div>
@@ -126,8 +124,8 @@ function openwin(url) {
 <div class="linkbox" style="float:right"><h4>ECal</h4><ul>
 <li><a href="monitor.cgi?1-window-ECalRate">Rate Summary for ECal</a></li>
 <li><a href="ecal_drawing.htm#ecalrate_slow">Rate for ECal</a></li>
-<li><a href="monitor.cgi?2-EcalHVVMap">ECAL HV Voltage Map</a></li>
-<li><a href="monitor.cgi?2-EcalHVCMap">ECAL HV Current Map</a></li>
+<li><a href="monitor.cgi?2-window-EcalHVVMap">ECAL HV Voltage Map</a></li>
+<li><a href="monitor.cgi?2-window-EcalHVCMap">ECAL HV Current Map</a></li>
 </ul></div>
 
 <div class="linkbox" style="float:left"><h4>RICH</h4><ul>
@@ -168,6 +166,8 @@ function openwin(url) {
 <li><a href="monitor.cgi?30-window-EBDisks">Fill-level of disks</a></li>
 <li><a href="monitor.cgi?10-window-EBCPU">Server CPU load</a></li>
 <li><a href="monitor.cgi?10-window-hldlast">Last hld files written</a></li>
+<li><a href="/calib">Calibration Monitor </a>
+<li><a href="monitor.cgi?60-window-TdcCalMon">Calibration Test Plots</a></li>
 </ul></div>
 
 
@@ -176,14 +176,25 @@ function openwin(url) {
 <li><a href="/daqtools/tools/beamabort.pl">Beam Abort</a></li>
 </ul></div>
 
-<div class="linkbox" style="float:left"><h4>Beam</h4><ul>
+<div class="linkbox" style="float:left"><h4>Wall</h4><ul>
+<li><a href="monitor.cgi?2-window-FwRates">Forward Wall Rates</a></li>
+<li><a href="monitor.cgi?10-window-FwHV">Forward Wall HV</a></li>
+<li><a href="monitor.cgi?10-window-FwHVCurrent">Forward Wall HV Currents</a></li>
+</ul></div>
+
+<div class="linkbox" style="float:right"><h4>Beam</h4><ul>
 <li><a href="monitor.cgi?2-window13x21-QFactor-MicroSpillStructure">QFactor & Micro Structure</a></li>
 <li><a href="monitor.cgi?2-window-StarX_spill">Spill Macro Structure</a></li>
 <li><a href="monitor.cgi?1-StartRateNumbers-StartPosition-ItofRateNumbers-StartPositionRMS-HodoRate-QFactor-CTSRates-MicroSpillStructure-StartSpillShapeAnalysisY_0">Beam plots collection similar to HKR</a></li>
+</ul></div>
 
+<div class="linkbox" style="float:left"><h4>Environment</h4><ul>
+<li><a href="monitor.cgi?2-window-CaveTemp">Cave and Cooling Temperature</a></li>
+<li><a href="monitor.cgi?2-window-Environment">Temperature, Humidity and Pressure</a></li>
 </ul></div>
 
 
+
 $;
 
 
index 08f0fb53fa69ae09394a1d5a46634ea91d8466a3..7cef534f0ad3aadc58ff82021686efb1a42ab62d 100755 (executable)
@@ -33,8 +33,8 @@ my @args = split('-',$ENV{'QUERY_STRING'});
       my $str = <$MYF>;
       close($MYF);
       $str =~ /width(\d+)\sheight(\d+)/;
-      $width = 80*$1+4;
-      $height = 50*$2;
+      $width = 80*$1-6;
+      $height = 50*$2+2;
       }
 
   
diff --git a/hmon/permanent/hmon_caveTemp.pl b/hmon/permanent/hmon_caveTemp.pl
new file mode 100755 (executable)
index 0000000..46e2e71
--- /dev/null
@@ -0,0 +1,127 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Time::HiRes qw( gettimeofday usleep time );
+use FileHandle;
+use Data::Dumper;
+use POSIX qw/floor ceil/;
+use List::Util qw'max min';
+use IO::Socket;
+use IO::Handle;
+use Perl2Epics;
+use Encode qw(encode from_to);
+use JSON::XS;
+use Hmon;
+use QA;
+use HPlot;
+
+my $fqa  = QA::OpenQAFile();
+
+my $plotShort = {
+    name    => "CaveTempHistShort",
+    file    => "files/CaveTempHistShort",
+    entries => 200*60/10,#200 minutes with meas every 10 sec
+    type    => HPlot::TYPE_HISTORY,
+    output  => HPlot::OUT_PNG,
+    titles  => ["Cooling Water","Cooling Air","Cave 4 m"],
+    xlabel  => "Minutes",
+    ylabel  => "Temperature / °C",
+    sizex   => 950,
+    sizey   => 360,
+    ymin    => "15",
+    ymax    => "25<*",
+    curves  => 3,
+    xscale  => 60/10,
+    storable=> 1,
+    buffer  => 1,
+    colors  => ["#333333","#00ff00","#ff0000"],
+    additional => "set offsets 0,0,1.5,1.5"
+    };
+HPlot::PlotInit($plotShort);
+
+my $plotLong = {
+    name    => "CaveTempHistLong",
+    file    => "files/CaveTempHistLong",
+    entries => 10*24*60,
+    type    => HPlot::TYPE_HISTORY,
+    output  => HPlot::OUT_PNG,
+    titles  => ["Cooling Water","Cooling Air","Cave 4 m"],
+    xlabel  => "Hours",
+    ylabel  => "Temperature / °C",
+    sizex   => 950,
+    sizey   => 360,
+    ymin    => "15",
+    ymax    => "25<*",
+    curves  => 3,
+    xscale  => 60,
+    storable=> 1,
+    buffer  => 1,
+    colors  => ["#333333","#00ff00","#ff0000"],
+    additional => "set offsets 0,0,1.5,1.5"
+    };
+HPlot::PlotInit($plotLong);
+
+# my $plotLongLong = {
+#     name    => "CaveTempHistLongLong",
+#     file    => "files/CaveTempHistLongLong",
+#     entries => 6000,
+#     type    => HPlot::TYPE_HISTORY,
+#     output  => HPlot::OUT_PNG,
+#     titles  => ["Cooling Water","Cooling Air","Cave 4 m"],
+#     xlabel  => "Hours",
+#     ylabel  => "Temperature / °C",
+#     sizex   => 950,
+#     sizey   => 360,
+#     #ymin    => "*<15",
+#     #ymax    => "40<*",
+#     curves  => 3,
+#     xscale  => 300,
+#     storable=> 1,
+#     buffer  => 1,
+#     colors  => ["#333333","#00ff00","#ff0000"],
+#     # additional => "set offsets 0,0,1.5,1.5"
+# #    colors  => ["#333333","#00ff00","#ff0000"]
+#     };
+# HPlot::PlotInit($plotLongLong);
+
+# HAD:MDC:cooling:water:temp   (funktioniert gerade nicht, wird aber repariert)
+# HAD:MDC:cooling:air:temp        (MDC + RICH Gebläse )
+# HAD:CAVE:cooling:air:4mheight:temp   ( Cave Raumluft )
+
+# HIer noch ein paar Lufttemperaturen in MDC Nähe, auch sehr ähnlich zur Cave Luft.
+# HAD:MDC:P4:S2:M6:temp 
+# HAD:MDC:P4:S1:M6:temp
+# HAD:MDC:P4:S6:M6:temp 
+Perl2Epics::Connect("CoolingWater","HAD:MDC:cooling:water:temp");
+Perl2Epics::Connect("CoolingAir","HAD:MDC:cooling:air:temp");
+Perl2Epics::Connect("Air4m","HAD:CAVE:cooling:air:4mheight:temp");
+
+my  $str = Hmon::MakeTitle(12, 14, "CaveTemp",0);
+$str .= qq@<img src="%ADDPNG files/CaveTempHistShort.png%" type="image/png"><br>\n@;
+$str .= qq@<img src="%ADDPNG files/CaveTempHistLong.png%" type="image/png">@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("CaveTemp",$str);
+
+my $timer = 0;
+while (1) {
+  $timer++;
+  my $data = Perl2Epics::GetAll(10);
+
+  print Dumper $data;
+
+  HPlot::PlotAdd("CaveTempHistShort",$data->{"CoolingWater"}->{val},0);
+  HPlot::PlotAdd("CaveTempHistShort",$data->{"CoolingAir"}->{val},1);
+  HPlot::PlotAdd("CaveTempHistShort",$data->{"Air4m"}->{val},2);
+  HPlot::PlotDraw("CaveTempHistShort");
+
+  if($timer%6 == 0) { #60 seconds  
+    HPlot::PlotAdd("CaveTempHistLong",$data->{"CoolingWater"}->{val},0);
+    HPlot::PlotAdd("CaveTempHistLong",$data->{"CoolingAir"}->{val},1);
+    HPlot::PlotAdd("CaveTempHistLong",$data->{"Air4m"}->{val},2);
+    HPlot::PlotDraw("CaveTempHistLong");
+  }
+  
+  # sleep(9.8);
+}
+  
index 3d7e48ae1e3b6fa3caa60787ea25a1ef13db0eaf..c196295c7ad5e050a654ad1bc119f277510c551a 100755 (executable)
@@ -126,7 +126,7 @@ my $str = "";
 my $s="";
 
 for(my $i = 1; $i <=6; $i++) {
-  if ($i>=2){
+#  if ($i>=2){
   for(my $j = 1; $j<=168; $j++) {
     my $cnt = (($i-1)*168)+$j-1;
     if($j<10) {$s = sprintf("HAD:ECAL:HV:S%i:M00%i:imon",$i,$j);}
@@ -137,7 +137,7 @@ for(my $i = 1; $i <=6; $i++) {
     if($j>=10 and $j<100) {$s = sprintf("HAD:ECAL:HV:S%i:M0%i:vmon",$i,$j);}
     if($j>=100) {$s = sprintf("HAD:ECAL:HV:S%i:M%i:vmon",$i,$j);}
     Perl2Epics::Connect("U$cnt",$s);
-  }
+#  }
   }
 }
 
@@ -258,7 +258,7 @@ while(1) {
  
  
  
-  $str = Hmon::MakeTitle(10, 13, "ECAL HV - Voltage Map", 1, "");
+  $str = Hmon::MakeTitle(10, 11, "ECAL HV - Voltage Map", 1, "");
   $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"files/styles.css\">";
 
   $str .= "<div style=\"text-align:left; margin-top: 10px; width: 200px\">";
@@ -354,7 +354,7 @@ while(1) {
    if($timer%8 == 0) {
      if ($ChnlsOn>0 and $ChnlsOn<$TOTALCHANS and ($TOTALCHANS - $ChnlsOn) < 16) {  #only report if a small number of channels is off
      for(my $i = 1; $i <=6; $i++) {
-        if ($i>=2){
#       if ($i>=2){
             for(my $j = 1; $j<=168; $j++) {
                 my $cnt = (($i-1)*168)+$j-1;
                 if($data->{"U$cnt"}->{val}<1000 and $data->{"I$cnt"}->{val}>=10){ $str .= sprintf("Low voltage on module %i, sector %i.<br>",$j,$i);}
@@ -362,7 +362,7 @@ while(1) {
                 if($data->{"U$cnt"}->{val}<10 and $data->{"I$cnt"}->{val}<10){ $str .= sprintf("Module %i, sector %i is switched off. Check!<br>",$j,$i);}
                 
             }
-        }
+#        }
     }
 #        $value    = sprintf("%i/$TOTALCHANS",$ChnlsOn);
        $longtext = sprintf("HV channels On: %i/$TOTALCHANS<br>Check the current and voltage monitoring plots!<br>%s",$ChnlsOn,$str);
@@ -376,7 +376,7 @@ while(1) {
   
 
     for (my $i = 0; $i <= 5;$i++){
-      if($i>=1){
+#      if($i>=1){
         for (my $j = 0; $j<=167; $j++) {
         my $cnt = ($i*168)+$j;
         HPlot::PlotAdd("EcalCurr$i",$data->{"I$cnt"}->{val}||-1,);
@@ -397,7 +397,7 @@ while(1) {
         }
         
         
-        }
+#        }
     }
     
     
index a1531a955285b4790a0533f40e40fcc2775eaac5..7fe13369a38c9f93dd9ee7e7a3775c4707334936 100755 (executable)
@@ -35,7 +35,7 @@ HPlot::PlotInit({
     curves  => 44,
     type    => HPlot::TYPE_HEATMAP,
     output  => HPlot::OUT_PNG,
-    zlabel  => "Hitrate",
+    zlabel  => "Voltage",
     sizex   => 710,
     sizey   => 610,
     nokey   => 1,
@@ -58,17 +58,55 @@ HPlot::PlotInit({
     showvalues => 0, 
     });
 
+HPlot::PlotInit({
+    name    => "FwHVCurrent",
+    file    => "files/FwHVCurrent",
+    title   => "FwHVCurrent",
+    entries => 44,
+    curves  => 44,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    zlabel  => "Current",
+    sizex   => 710,
+    sizey   => 610,
+    nokey   => 1,
+    buffer  => 1,
+    ymin    => -0.5,
+    ymax    => 43.5,
+    xmin    => -0.5,
+    xmax    => 43.5,
+#    cbmax   => 1800,
+    cbmin   => -1,
+    noinit  => 1,
+#     additional => "set logscale cb;unset ytics;set format cb \"_{10}{\%L}\"",
+    additional => "
+      set obj 1 rect from   11.4, 11.5 to  31.5, 31.5 lw 0.2 fs empty border -1 front \n
+      set obj 2 rect from   15.4, 15.5 to  27.5, 27.5 lw 0.2 fs empty border -1 front \n
+      unset ytics \n
+      unset xtics \n
+#      set palette defined ( -1 \"#000000\", -0.1 \"#0000ff\", 990 \"#00aaff\", 991 \"#00ff00\", 1400 \"#ffff00\", 1800 \"#ff0000\" ) \n
+      ",
+    showvalues => 0, 
+    });
+
 my $str  = Hmon::MakeTitle(9, 13, "FWall HV",0);
 $str .= qq@<img src="%ADDPNG files/FwHV.png%" type="image/png"><br>\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("FwHV",$str);
 
+$str  = Hmon::MakeTitle(9, 13, "FWall HV Current",0);
+$str .= qq@<img src="%ADDPNG files/FwHVCurrent.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+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";
   Perl2Epics::Connect("$i",$s);
+  $s = "HAD:FWHV:S$i:imon";
+  Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 990;
   }
@@ -76,6 +114,8 @@ for(my $i = 1; $i <= 144; $i++) {
 for(my $i = 145; $i <= 208; $i++) {
   $s = "HAD:FWHV:M$i:vmon";
   Perl2Epics::Connect("$i",$s);
+  $s = "HAD:FWHV:M$i:imon";
+  Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 1300;
   }
@@ -85,6 +125,8 @@ for(my $i = 211; $i <= 302; $i++) {
   next if ($i == 283 || $i == 293 || $i == 294 || $i == 295);
   $s = "HAD:FWHV:L$i:vmon";
   Perl2Epics::Connect("$i",$s);
+  $s = "HAD:FWHV:L$i:imon";
+  Perl2Epics::Connect("I$i",$s);
   push(@channels,"$i");
   $minvolt->{"$i"} = 1400;
   }
@@ -179,7 +221,31 @@ while(1) {
       HPlot::PlotFill('FwHV',$val,$x[$i]+2,43-$y[$i]-3);
       HPlot::PlotFill('FwHV',$val,$x[$i]+3,43-$y[$i]-3);
       }      
+
+    $val = $data->{"I$i"}->{val};
+    $val = -1 if $time > (($data->{$i}{tme}//0)+600);
+    HPlot::PlotFill('FwHVCurrent',$val,$x[$i],  43-$y[$i]);
+    if($i>=145) {
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+1,43-$y[$i]);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i],  43-$y[$i]-1);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+1,43-$y[$i]-1);
+      }
+    if($i>=211) {
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+2,43-$y[$i]);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+3,43-$y[$i]);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+2,43-$y[$i]-1);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+3,43-$y[$i]-1);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+0,43-$y[$i]-2);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+1,43-$y[$i]-2);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+2,43-$y[$i]-2);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+3,43-$y[$i]-2);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+0,43-$y[$i]-3);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+1,43-$y[$i]-3);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+2,43-$y[$i]-3);
+      HPlot::PlotFill('FwHVCurrent',$val,$x[$i]+3,43-$y[$i]-3);
+      }      
     }
   HPlot::PlotDraw('FwHV');  
+  HPlot::PlotDraw('FwHVCurrent');  
   sleep(10);
   }
diff --git a/hmon/permanent/hmon_hvcrates.pl b/hmon/permanent/hmon_hvcrates.pl
new file mode 100755 (executable)
index 0000000..8ca6cef
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use FileHandle;
+use Data::Dumper;
+use Hmon;
+use QA;
+use List::Util qw(min max);
+use Perl2Epics;
+use lib ".";
+
+my @crates = qw(14 15 16 17 18 19 20 21 22 23 24 25 26 27);
+my $states;
+
+# 0 = undefined
+# 1 = running
+# 2 = restarted
+# 3 = stalled
+# 4 = disabled
+# 5 = wrong name
+# 6 = timeout
+#HAD:HV:hadhvp14:status:epics:service
+
+sub setstate {
+  my ($name,$state) = @_;
+  print $name." ".$state."\n";
+  $states->{$name} = $state;
+  Perl2Epics::Put($name,$state);
+  }
+
+
+
+for my $v (@crates) {
+  my $name = $v;
+  Perl2Epics::Connect($name,"HAD:HV:hadhvp".$v.":status:epics:service");
+  }
+
+while(1) {
+  Perl2Epics::GetAll();
+  for my $v (@crates) {
+    qx(ping hadhvp$v -c 1 -W 1);
+    setstate($v,"timeout") if $?;
+    next if $?;
+    
+    my $check = "curl 'http://hadhvp".$v."/session_login.cgi' -s -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://hadhvp25' -H 'Connection: keep-alive' -H 'Referer: http://hadhvp".$v."/session_login.cgi' -H 'Upgrade-Insecure-Requests: 1' -H 'Cookie: testing=1;' --data-raw 'page=%2Fcaen_epics%2F&user=admin&pass=admin' -c /dev/shm/hmon_epics_check";
+    qx($check);
+    setstate($v,"timeout") if $?;
+    next if $?;
+    
+    $check = "curl 'http://hadhvp".$v."/caen_epics/' -s -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Referer: http://hadhvp".$v."/session_login.cgi' -H 'Connection: keep-alive' -b /dev/shm/hmon_epics_check -H 'Upgrade-Insecure-Requests: 1'   | grep 'Please restart the EPICS service to update the Process Variables'";
+    qx($check);
+    setstate($v,"running") if $? == 256;
+
+    if ($? == 0) {
+      setstate($v,"stalled");
+      $check = "curl 'http://hadhvp".$v."/caen_epics/restart.cgi?' -s -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'Referer: http://hadhvp".$v."/caen_epics/'  -H 'Upgrade-Insecure-Requests: 1'  -b /dev/shm/hmon_epics_check";
+      qx($check);
+      setstate($v,"restarted");
+      print STDERR time()." ".$v." restarted\n";
+
+      }
+    }
+#   print Dumper $states;
+  Perl2Epics::Update(0.2);
+  sleep 300;
+  }
+  
+