]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
add hmon scripts for FW
authorhadaq <jan@lxhadeb07>
Fri, 25 Aug 2023 13:13:48 +0000 (15:13 +0200)
committerhadaq <jan@lxhadeb07>
Fri, 25 Aug 2023 13:13:48 +0000 (15:13 +0200)
hmon/hmon_fwrate.pl [new file with mode: 0755]
hmon/index.cgi
hmon/permanent/hmon_fwhv.pl

diff --git a/hmon/hmon_fwrate.pl b/hmon/hmon_fwrate.pl
new file mode 100755 (executable)
index 0000000..43023e3
--- /dev/null
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Data::Dumper;
+use Data::TreeDumper;
+use Hmon;
+use QA;
+use HADES::TrbNet;
+use HPlot;
+use Time::HiRes qw(usleep time);
+use List::Util qw[min max];
+
+use Encode qw(encode from_to);
+use JSON::XS;
+
+my $fqa  = QA::OpenQAFile();
+
+
+my @x = (0,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,12,14,16,18,20,22,24,26,28,30,12,14,16,18,20,22,24,26,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,16,18,20,22,24,26,28,30,12,14,16,18,20,22,24,26,28,30,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32);
+
+my @y = (0,
+16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,12,12,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,14,14,16,16,16,16,18,18,18,18,20,20,20,20,22,22,22,22,24,24,24,24,26,26,26,26,28,28,28,28,28,28,28,28,28,28,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,12,12,12,12,12,12,16,16,16,16,16,16,20,20,20,20,20,20,24,24,24,24,24,24,28,28,28,28,28,28,32,32,32,32,32,32,32,32,32,32,32,36,36,36,36,36,36,36,36,36,36,36,40,40,40,40,40,40,40,40,40);
+
+my @bo = (0,0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6701, 0x6702, 0, 0, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0, 0, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6702, 0x6703, 0x6703, 0x6703, 0x6703, 0x6722, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6703, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6723, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6710, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6711, 0x6712, 0x6712, 0x6712, 0x6712, 0x6723, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0, 0, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0, 0, 0, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0x6712, 0, 0x6712, 0x6712, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6713, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0x6720, 0, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0, 0, 0, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722, 0x6722);
+
+my @ch = (0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 15, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 0, 1, 2, 3, 4, 30, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 31, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 30, 31, 0, 1, 2, 3, 4, 5, 7, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 31, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 9, 10, 11, 12, 13, 14, 31);
+
+HPlot::PlotInit({
+    name    => "FwRate",
+    file    => "files/FwRates",
+    title   => "FwRates",
+    entries => 44,
+    curves  => 44,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    zlabel  => "Hitrate",
+    sizex   => 710,
+    sizey   => 610,
+    nokey   => 1,
+    buffer  => 1,
+    ymin    => -0.5,
+    ymax    => 43.5,
+    xmin    => -0.5,
+    xmax    => 43.5,
+    cbmin   => 0,
+    noinit  => 1,
+    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 logscale cb \n
+      set format cb \"_{10}{\%L}\" \n
+      ",
+    showvalues => 0, 
+    });
+
+
+my $str  = Hmon::MakeTitle(9, 13, "FW Hit Rate",0);
+$str .= qq@<img src="%ADDPNG files/FwRates.png%" type="image/png"><br>\n@;
+
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("FwRates",$str);
+
+
+my $old;
+my $oldtime = time();
+my $time = time();
+my $diff;
+my $iter = 0;
+
+my $lowratelimit = 500;
+my $highratelimit = 20000;
+my $lowratecount = 400;
+my $highratecount = 7;
+
+my $qastate = QA::OK;  
+my $text = "OK";
+my $shorttext = "OK";
+
+trb_init_ports() or die trb_strerror();
+
+
+while(1) {
+  #my $data;
+  #my $max = 0 ;
+  #my $min = 5E9;
+#   my $lowrate = 0; my $highrate = 0;  
+  my $o = trb_register_read_mem(0xfe47,0xdfc0,0,32) or die trb_strerror() or sleep 5 and next;
+
+  if (defined $old) {
+    my $tdiff = (time() - $oldtime)|1;
+    foreach my $b (keys %$o) {
+      #my $ratesum = 0;
+      next unless ($b>=0x6700 && $b<=0x67ff);
+
+      for my $v (0..31) {
+        my $vdiff = ($o->{$b}->[$v]&0xfffffff) - ($old->{$b}->[$v]&0xfffffff);
+        
+        if ($vdiff < 0) { $vdiff += 2**28;}
+        $diff->{$b}->[$v] = $vdiff/$tdiff;
+#         my $val = $diff->{$b}->[$v];
+        
+#         HPlot::PlotFill('FwRate',$diff->{$b}->[$v],$v,$xpos);
+        
+#         $highrate++ if ($diff->{$b}->[$v] > $highratelimit);
+#         $lowrate++  if ($diff->{$b}->[$v] < $lowratelimit);        
+        }
+      }
+      
+    for(my $i = 1; $i <= 302; $i++) {
+      next if ($i == 66 || $i == 67 || $i == 78 || $i == 79);
+      next if ($i == 209 || $i == 210);
+      next if ($i == 218 || $i == 219 || $i == 220 || $i == 230);
+      next if ($i == 283 || $i == 293 || $i == 294 || $i == 295);  
+      my $val = $diff->{$bo[$i]}->[$ch[$i]];
+      
+  #     $val = $i; #TODO
+        HPlot::PlotFill('FwRate',$val,$x[$i],  43-$y[$i]);
+      if($i>=145) {
+        HPlot::PlotFill('FwRate',$val,$x[$i]+1,43-$y[$i]);
+        HPlot::PlotFill('FwRate',$val,$x[$i],  43-$y[$i]-1);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+1,43-$y[$i]-1);
+        }
+      if($i>=211) {
+        HPlot::PlotFill('FwRate',$val,$x[$i]+2,43-$y[$i]);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+3,43-$y[$i]);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+2,43-$y[$i]-1);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+3,43-$y[$i]-1);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+0,43-$y[$i]-2);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+1,43-$y[$i]-2);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+2,43-$y[$i]-2);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+3,43-$y[$i]-2);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+0,43-$y[$i]-3);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+1,43-$y[$i]-3);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+2,43-$y[$i]-3);
+        HPlot::PlotFill('FwRate',$val,$x[$i]+3,43-$y[$i]-3);
+        }      
+      }      
+    HPlot::PlotDraw('FwRate');    
+
+   }
+# print $highrate." ".$lowrate."\n";
+#   if($lowrate > $lowratecount) {
+#   
+#     $qastate = QA::OK;  
+#     $text = "OK";
+#     $shorttext = "";
+#     
+#     if ($highrate > $highratecount) {
+#       $qastate = QA::ERROR;
+#       $shorttext = "Problem";
+#       $text = "Some TOF channels seem to have too high rates.";
+#       }
+#       
+#     QA::WriteQALog($fqa,"feeerr","tof", 60, $qastate, "TOF Thresh", $shorttext, $text);
+#     }   
+#    
+   
+  $old = $o;
+  $oldtime = time();
+  sleep 2;
+  }
index 01064b5c47dd434f9a921919cc7408790563181f..b0bca6d1e47490ebce27d57a7c13b5caf4ce4dc4 100755 (executable)
@@ -34,14 +34,14 @@ function openwin(url) {
 <li><a href="../daqtools/index.pl" target="_blank">Web Tools (daqtools)</a></li>
 <li><a href="../eb/?browser=fix" target="_blank">Eventbuilder Monitor</a></li>
 <li><a href="../rawmon/" target="_blank">Raw Data Monitor</a></li>
-<li><a href="https://web-docs.gsi.de/~webhades/onlineMon/feb22/hades-online.html" target="_blank">Accumulated Run Statistics</a>
+<li class="outdated"><a href="https://web-docs.gsi.de/~webhades/onlineMon/feb22/hades-online.html" target="_blank">Accumulated Run Statistics</a>
 </ul></div>
 
 <div class="linkbox" style="float:right"><h4>Documents</h4><ul>
-<li><a href="https://jspc29.x-matter.uni-frankfurt.de/docu/hadesoperator.pdf" style="color:#d33">Operator manual</a>
+<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://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://jspc29.x-matter.uni-frankfurt.de/Resources/HADES">Further Documents</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>
@@ -55,16 +55,16 @@ function openwin(url) {
 <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-window13x23-StartFalls-ItofRateNumbers-TriggerRatesPerSector-CTSRates">Main Screen 5</a> Positional map for Start and iTOF, Trigger Rates</li>
-<li style="width:600px;"><a href="monitor.cgi?2-window12x21-RpcTofSectorRate_highres-StartRateX_histbar-StartRateY_histbar">Main Screen 6</a> Beam Intensities</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>
 
 <div class="linkbox" style="clear:both;width:730px;"><h4>Other Ressources</h4><ul>
-<li><a href="/qaweb">QA Plots (web-based)</a>
-<li><a href="files/qa.htm">QA Plots (updated every 5 minutes)</a></li>
-<li><a href="files/vertex.htm">Vertex Plots (updated after each file)</a></li>
+<li class="outdated"><a href="/qaweb">QA Plots (web-based)</a>
+<li class="outdated"><a href="files/qa.htm">QA Plots (updated every 5 minutes)</a></li>
+<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><a href="http://hades63/icingaweb2/dashboard">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><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>
@@ -85,7 +85,7 @@ function openwin(url) {
 <li><a href="monitor.cgi?1-window-eventrateshort">Eventrate histogram (10s)</a></li>
 <li><a href="monitor.cgi?1-window-eventrate">Eventrate histogram (60s)</a></li>
 <li><a href="monitor.cgi?5-window-eventratelong">Eventrate histogram (10m)</a></li>
-<li><a href="monitor.cgi?10-window-StartCountSpill">Start counts per spill</a></li>
+<li class="outdated"><a href="monitor.cgi?10-window-StartCountSpill">Start counts per spill</a></li>
 <li><a href="monitor.cgi?10-window-Pt3AcceptRatio">Ratio of accepted PT3 per spill</a></li>
 <li><a href="monitor.cgi?10-window-EvtsPerSpill">Recorded events per spill</a></li>
 <!--<li><a href="monitor.cgi?5-window-Vetohist">Veto hit count histograms</a></li>-->
@@ -116,9 +116,9 @@ function openwin(url) {
 <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><a href="monitor.cgi?6-StartRateNumbers-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?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 class="outdated"><a href="monitor.cgi?1-StartRateBars-StartBars-StartPosition-VetoHalo-ForwardQuartz">Beam Summary</a></li> -->
 </ul></div>
 
index c354c63722fe0fccd4235bb9254a2227d8645ab3..8bdcf140302e57259301b3f27814433fe4595740 100755 (executable)
@@ -20,28 +20,73 @@ my $s="";
 my @channels;
 my $minvolt;
 
+
+my @x = (0,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,16,17,18,19,20,21,22,23,24,25,26,27,12,14,16,18,20,22,24,26,28,30,12,14,16,18,20,22,24,26,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,28,30,12,14,16,18,20,22,24,26,28,30,12,14,16,18,20,22,24,26,28,30,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32,36,40,0,4,8,12,16,20,24,28,32);
+
+my @y = (0,
+16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,12,12,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,14,14,16,16,16,16,18,18,18,18,20,20,20,20,22,22,22,22,24,24,24,24,26,26,26,26,28,28,28,28,28,28,28,28,28,28,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,12,12,12,12,12,12,16,16,16,16,16,16,20,20,20,20,20,20,24,24,24,24,24,24,28,28,28,28,28,28,32,32,32,32,32,32,32,32,32,32,32,36,36,36,36,36,36,36,36,36,36,36,40,40,40,40,40,40,40,40,40);
+
+
+HPlot::PlotInit({
+    name    => "FwHV",
+    file    => "files/FwHV",
+    title   => "FwHV",
+    entries => 44,
+    curves  => 44,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    zlabel  => "Hitrate",
+    sizex   => 710,
+    sizey   => 610,
+    nokey   => 1,
+    buffer  => 1,
+    ymin    => -0.5,
+    ymax    => 43.5,
+    xmin    => -0.5,
+    xmax    => 43.5,
+    #cbmax   => 1600,
+    cbmin   => 0,
+    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 \"#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);
+
+
+
 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("VS$i",$s);
-  push(@channels,"VS$i");
-  $minvolt->{"VS$i"} = 990;
+  Perl2Epics::Connect("$i",$s);
+  push(@channels,"$i");
+  $minvolt->{"$i"} = 990;
   }
 
 for(my $i = 145; $i <= 208; $i++) {
   $s = "HAD:FWHV:M$i:vmon";
-  Perl2Epics::Connect("VM$i",$s);
-  push(@channels,"VM$i");
-  $minvolt->{"VM$i"} = 1300;
+  Perl2Epics::Connect("$i",$s);
+  push(@channels,"$i");
+  $minvolt->{"$i"} = 1300;
   }
 
 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";
-  Perl2Epics::Connect("VL$i",$s);
-  push(@channels,"VL$i");
-  $minvolt->{"VL$i"} = 1400;
+  Perl2Epics::Connect("$i",$s);
+  push(@channels,"$i");
+  $minvolt->{"$i"} = 1400;
   }
   
   
@@ -63,21 +108,27 @@ print "Connected.\n";
 
 # my @i_integrated=(0,0,0,0,0,0,0,0,0,0,0,0);
 my $ChnlsOn = 0;
+my $ChnlsOld;
 my $cnt;
+my $data;
 
 while(1) {
-
-  my $data = Perl2Epics::GetAll();
+  $data = Perl2Epics::GetAll();
   my $str = "";
-
+  my $time = time();
   $ChnlsOn=0;
+  $ChnlsOld = 0;
   foreach my $c (@channels) {
-    if( $data->{$c}->{val} >= $minvolt->{$c}) {
+    if( ($data->{$c}->{val}//0) >= $minvolt->{$c}) {
       $ChnlsOn++;
       }
     else {
       $str .= "$c off. ";
       }
+    if ($time > ($data->{$c}{tme}//0)+600)  {
+      $ChnlsOld++;
+      }
     } 
   
 
@@ -86,15 +137,50 @@ while(1) {
   
   if(scalar @channels - $ChnlsOn > 20) {$str = "";}
   
-  my $longtext = sprintf("HV channels On: %i/%i<br>%s",$ChnlsOn, scalar @channels,$str);
+  my $longtext = sprintf("HV channels On: %i/%i",$ChnlsOn, scalar @channels);
+     $longtext .= sprintf("<br>Missing data on %i channels",$ChnlsOld) if $ChnlsOld > 0;
+     $longtext .= "<br>".$str;
 
   $qastate = QA::GetQAState('above', $ChnlsOn, @QA::FwHvLimits);   
   if ($ChnlsOn == 0){ $qastate = QA::WARN_2;  $value = "OFF";}
+  if ($ChnlsOld >= 0) { $qastate = QA::WARN_2;}
   if ($QA::FwHvOff == 1) { $qastate = QA::OK;}
 
   
   QA::WriteQALog($flog,"hv","fwhv",30,$qastate,"FW HV",$value,$longtext);
 
   
-  usleep(2500000);
+  for(my $i = 1; $i <= 302; $i++) {
+    next if ($i == 66 || $i == 67 || $i == 78 || $i == 79);
+    next if ($i == 209 || $i == 210);
+    next if ($i == 218 || $i == 219 || $i == 220 || $i == 230);
+    next if ($i == 283 || $i == 293 || $i == 294 || $i == 295);  
+    my $val = $data->{$i}->{val};
+    $val = -1 if $time > ($data->{$i}{tme}//0)+600;
+
+    #     $val = $i; #TODO
+    
+    HPlot::PlotFill('FwHV',$val,$x[$i],  43-$y[$i]);
+    if($i>=145) {
+      HPlot::PlotFill('FwHV',$val,$x[$i]+1,43-$y[$i]);
+      HPlot::PlotFill('FwHV',$val,$x[$i],  43-$y[$i]-1);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+1,43-$y[$i]-1);
+      }
+    if($i>=211) {
+      HPlot::PlotFill('FwHV',$val,$x[$i]+2,43-$y[$i]);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+3,43-$y[$i]);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+2,43-$y[$i]-1);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+3,43-$y[$i]-1);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+0,43-$y[$i]-2);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+1,43-$y[$i]-2);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+2,43-$y[$i]-2);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+3,43-$y[$i]-2);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+0,43-$y[$i]-3);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+1,43-$y[$i]-3);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+2,43-$y[$i]-3);
+      HPlot::PlotFill('FwHV',$val,$x[$i]+3,43-$y[$i]-3);
+      }      
+    }
+  HPlot::PlotDraw('FwHV');  
+  sleep(10);
   }