]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Update of dmon scripts
authorCbm Rich <richdaq@wuppertal>
Sun, 16 Nov 2014 11:23:17 +0000 (12:23 +0100)
committerCbm Rich <richdaq@wuppertal>
Sun, 16 Nov 2014 11:23:17 +0000 (12:23 +0100)
16 files changed:
dmon/scripts/dmon_beamintensity.pl
dmon/scripts/dmon_beammonitors.pl [new file with mode: 0755]
dmon/scripts/dmon_billboard.pl
dmon/scripts/dmon_deadtime.pl
dmon/scripts/dmon_heatmaprich.pl
dmon/scripts/dmon_mbs.pl
dmon/scripts/dmon_numfee.pl
dmon/scripts/dmon_padiwatemp.pl
dmon/scripts/dmon_ping.pl
dmon/scripts/dmon_qa.pl
dmon/scripts/dmon_richenvironment.pl [new file with mode: 0755]
dmon/scripts/dmon_trgrate.pl
perllibs/ChannelMapping.pm [new symlink]
tools/HPlot.pm
users/cern_cbmrich/dmon_config.pl
users/cern_cbmrich/makethresholds.sh

index 6d1e5076b96aeb314023947430019ede0ff2590d..ab7877a284f959209a61299ea4c2aedcf1d96062 100755 (executable)
@@ -3,8 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "../tools";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
 use Dmon;
diff --git a/dmon/scripts/dmon_beammonitors.pl b/dmon/scripts/dmon_beammonitors.pl
new file mode 100755 (executable)
index 0000000..c3c2f6d
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+use FileHandle;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use Dmon;
+use HPlot;
+use Data::Dumper;
+
+my %config = Dmon::StartUp();
+
+HPlot::PlotInit({
+  name    => "Beam",
+  file    => Dmon::DMONDIR."BeamMonitors",
+  entries => scalar @{$config{BeamDetectorsName}},
+  type    => HPlot::TYPE_BARGRAPH,
+  output  => HPlot::OUT_PNG,
+  bartitle  => $config{BeamDetectorsName},
+  xlabel  => "",
+  ylabel  => "Counts/s",
+  sizex   => 430,
+  sizey   => 360,
+  curvewidth => 1.5,
+#   ymin    => -1,
+  ymax    => "1000<*",
+#   xscale  => 5,
+  nokey   => 1,
+  buffer  => 1
+  });
+
+my $str = Dmon::MakeTitle(6,8,"BeamMonitors",0);
+   $str .= qq@<img src="%ADDPNG BeamMonitors.png%" type="image/png">@;
+   $str .= Dmon::MakeFooter();
+Dmon::WriteFile("BeamMonitors",$str);
+
+my @old;
+
+while(1) {
+  my @regs;
+  for (my $c = 0; $c < scalar @{$config{BeamDetectorsTrb}}; $c++) {
+    my $t = trb_registertime_read($config{BeamDetectorsTrb}->[$c],$config{BeamDetectorsChan}->[$c]);
+    $regs[$c] = $t->{$config{BeamDetectorsTrb}->[$c]};    
+    }
+
+  for (my $c = 0; $c < scalar @{$config{BeamDetectorsTrb}}; $c++) {
+    my $value = $regs[$c]->{value}[0];
+        
+    $value -= $old[$c]->{value}[0] || 0;
+
+    HPlot::PlotFill('Beam',$value,$c,0);
+    }
+
+
+  HPlot::PlotDraw('Beam');
+  Dmon::WriteQALog($config{flog},"beammonitors",60,Dmon::OK,"Beam Monitors","","Just plotting","1-BeamMonitors");
+
+#   my $curr = $sig->{$config{BeamTRB}} & 0xffffff;
+# 
+#   if($curr - $old > $config{SpillThreshold}) {
+#     $value += $curr - $old||0;
+#     }
+#   else {
+#     if ($value > 0) {
+#       my $longtext = "Number of signals in last spill: ".$value;
+#       my $status = Dmon::OK;
+#       Dmon::WriteQALog($config{flog},"beamintensity",60,$status,$title,$value,$longtext);
+#       $value = 0;
+#       }
+#     }      
+
+
+  @old = @regs;
+  sleep 1;
+  }
index 82cdc7f693fcc19ac3c05e9eba840ec0d6d519b0..755be5a6d6fbde75838ee0850c9be2325ff0f5a9 100755 (executable)
@@ -14,11 +14,16 @@ use Perl2Epics;
 my %config = Dmon::StartUp();
 my $t0;
 
-for(my $i = 1; $i<=20; $i++) {
-  my $name = sprintf('CBM:PWRSWITCH:GetCurrent%02x',$i);
-  Perl2Epics::Connect("C".$i,$name);
+for(my $i = 0; $i< 16 ; $i++) {
+  Perl2Epics::Connect("PC".$i, sprintf('CBM:PWRSWITCH:GetCurrent%02x',$i));
+
+  Perl2Epics::Connect("HV_U".$i, sprintf('OUTPUT_TERMINAL_VOLTAGE_U%d',$i));
+  Perl2Epics::Connect("HV_I".$i, sprintf('MEASUREMENT_CURRENT_U%d',$i));
 }
 
+Perl2Epics::Connect("Pres","CBM:BMP180:GetPressure");
+Perl2Epics::Connect("Temp","CBM:BMP180:GetTemp");
+
 while(1) {
 # update billboard
   my @billboardValues = ();
@@ -27,19 +32,33 @@ while(1) {
   my $epicsData = Perl2Epics::GetAll();
 
   # temp & pressure
-  $billboardValues[0] = 0xdeadc0de;
+  push @billboardValues,
+    (($billboardVersion  & 0x3)      << 30) | # version   2 bit
+    (($epicsData{"Pres"} & 0x1fffff) <<  9) | # pressure 21 bit
+    (($epicsData{"Temp"} & 0x1ff   ) <<  0);  # temp      9 bit
 
-  # currents
-  for(my $i = 1; $i<=20; $i++) {
-    my $milAmp = $epicsData->{"C".$i}->{"val"} * 1000;
+  # padiwa currents
+  for(my $i = 0; $i < 16; $i++) {
+    my $milAmp = $epicsData->{"PC".$i}->{"val"} * 1000;
     $reg = 0 unless $i & 1;
     $reg |= ($milAmp & 0xffff) << (16 * ($i&1));
-    $billboardValues[$i / 2 + 1] = $reg;
+    push @billboardValues, $reg if $i & 1;
   }
 
+  # threshold timestamp
+  my $threshTime = do($config{UserDirectory} . '/thresh/billboard_info') || 0;
+  push @billboardValues, $threshTime & 0xffffffff;
+  
+  # hv values
+  for(my $i=0; $i < 16; $i++) {
+    push @billboardValues,
+      ((("HV_I".$i) * 1e6) & 0xffff) << 16) |
+      ((("HV_U".$i) * 1e2) & 0xffff) <<  0);
+  }
+  
   trb_register_write_mem($config{BillboardAddress}, 0xb100, 0, \@billboardValues, scalar @billboardValues); # copy data
   trb_register_write($config{BillboardAddress}, 0xb000, scalar @billboardValues); # commit
-
+  
 # build statistics
   my $title = "Billboard";
   my $longtext='';
index b8a837aa4d03f74066a8bcc3ecd406e21da07582..e53e86a2c692a7d7db4b2f3cfa3ae1d8fc8ca774 100755 (executable)
@@ -3,8 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "../tools";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
 use Dmon;
index 234c55d98a47601b3379bd17cdcda7b0cc6bc8c3..b79db389bbc886820987c0fd42cbf54c967bc8bb 100755 (executable)
@@ -4,8 +4,6 @@ use warnings;
 use strict;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "../tools";
 use lib "../users/cern_cbmrich";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
@@ -36,53 +34,26 @@ $plot2->{xmax}    = 32.5;
 $plot2->{ymin}    = 0.5;
 $plot2->{ymax}    = 32.5;
 $plot2->{cbmin}   = "0";
-$plot2->{cbmax}   = "100<*<1000000";
+$plot2->{cbmax}   = "100<*";
 $plot2->{showvalues} = 0;
 $plot2->{xlabel} = "column";
 $plot2->{ylabel} = "row";
-$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.80\nset bmargin at screen 0.07\nset tmargin at screen 0.95";
+$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.85\nset bmargin at screen 0.07\nset tmargin at screen 0.95";
 HPlot::PlotInit($plot2);
 
 my $str = Dmon::MakeTitle(9,14,"HeatmapRich",0);
-   $str .= qq@<div style="padding:0"><img src="%ADDPNG HeatmapRich.png%" type="image/png" id="heatmap-img"></div><div id="heatmap-caption" style="margin-top: -5px;"></div>@;
+   $str .= qq@<img src="%ADDPNG HeatmapRich.png%" type="image/png">@;
    $str .= Dmon::MakeFooter();
 Dmon::WriteFile("HeatmapRich",$str);
 
-sub generateDef {
-  my $x = 56; my $y = 51; my $w = (564-$x) / 32.0; my $h = (619-$y) / 32.0;
-
-  $str = qq@
-  var HeatmapDef = {
-    'x': $x, 'y': $y, 'w': $w, 'h': $h,
-    'labels': [
-  @;
-
-  for my $ix (1..32) {
-    $str .= '[';
-    for my $iy (1..32) {
-      my $fpga    = $ChannelMapping::chanmap->{fpga}->[$ix]->[$iy];
-      my $channel = ($ChannelMapping::chanmap->{chan}->[$ix]->[$iy]-1) / 2;
-
-      $str .= sprintf("'0x%04x CH: %d'", $fpga, $channel) . ($iy == 32 ? '' : ',');
-    }
-    $str .= ']' . ($ix == 32 ? '' : ',') . "\n";
-  }
-
-  $str .= ']};';
-  return $str;
-}
-
-open FH, ">", Dmon::DMONDIR . '/HeatmapRichDefs.js';
-print FH generateDef;
-close FH;
 
 my $old;
 my $oldtime = time();
 my $time = time();
 my $diff;
 
-
 while (1) {
+  my $sum = 0;
   my $o = trb_register_read_mem($config{PadiwaBroadcastAddress},0xc000,0,33);
 
   if (defined $old) {
@@ -100,14 +71,15 @@ while (1) {
         my $fpga    = $ChannelMapping::chanmap->{fpga}->[$x]->[$y];
         my $channel = $ChannelMapping::chanmap->{chan}->[$x]->[$y];
         HPlot::PlotFill('HeatmapRich',$diff->{$fpga}->[$channel],$x,$y);
+        $sum += $diff->{$fpga}->[$channel];
         }
       }
     HPlot::PlotDraw('HeatmapRich');      
     }
   my $status = Dmon::OK;
   my $title  = "Heatmap";
-  my $value = "";
-  my $longtext = "See plot";
+  my $value = Dmon::SciNotation($sum);
+  my $longtext = "Total: ".$value;
   Dmon::WriteQALog($config{flog},"heatmaprich",5,$status,$title,$value,$longtext,'1-HeatmapRich');
   $old = $o;
   $oldtime = time();
index 73ff2c8778995d11f6b0025ac5b857861bbe52ee..71210b28682e66fc1db9080dc34c85cb65dfe8a4 100755 (executable)
@@ -3,8 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "../tools";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
 use Dmon;
index b3b96700441a9d6a782108cdd9289e653702665a..50c815159adee553617600e6f3d77c6cb8ae1f30 100755 (executable)
@@ -3,7 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
 use HADES::TrbNet;
 use Dmon;
 
index cd61e5d9cf025215659f0c7a64778e137f5c3395..8166ff72c5cf7628340dea93d9e69d89913503f8 100755 (executable)
@@ -1,8 +1,6 @@
 #!/usr/bin/perl -w
 
 use warnings;
-use lib "./code";
-use lib "../tools";
 use HADES::TrbNet;
 use Dmon;
 use HPlot;
index 219d8012196c9c269eb6adff6d3342e5f1560e5c..de2e66e9c65f8eeca9ddfae5a7bbd3fcb482e650 100755 (executable)
@@ -3,8 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "./tools";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
 use Dmon;
@@ -21,7 +19,6 @@ while(1) {
   my $total = scalar @{$config{TrbIP}};
   foreach my $p (@{$config{TrbIP}}) {
     my $r = $ping->ping($p,1);
-#     print $p."\t$r\n";
     $found    += $r || 0;
     $notavail += 1-($r||0);
     $list .= " $p" unless $r;
index c06ccd80dbc6f4cd16ec611cf8f657ee0685fb0f..e31cd41cd05069173012b36469a93855364c3bde 100755 (executable)
@@ -50,7 +50,7 @@ while($a = <FLOG>) {
 #Generate output file at most once per second
   if(1 || $oldtime < time) {
     $oldtime = scalar time();
-    $str  = Dmon::MakeTitle($width,7,"Tactical Overview",1);
+    $str  = Dmon::MakeTitle($width,8,"Tactical Overview",1);
     $str .= "<div class=\"QA\">";
     foreach my $row (@{$config{activeScripts}}) {
       $str .= "<div class=\"header\" style=\"clear:both\">".($config{qaNames}->[$i++])."</div>\n";
diff --git a/dmon/scripts/dmon_richenvironment.pl b/dmon/scripts/dmon_richenvironment.pl
new file mode 100755 (executable)
index 0000000..fe21c32
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+use FileHandle;
+use HADES::TrbNet;
+# use List::Util qw(min max);
+# use Time::HiRes qw(usleep);
+use Dmon;
+use HPlot;
+use Perl2Epics;
+# use Data::Dumper;
+
+my %config = Dmon::StartUp();
+
+HPlot::PlotInit({
+  name    => "temperature",
+  file    => Dmon::DMONDIR."RichEnvironmentTemperature",
+  curves  => 1,
+  entries => 3000,
+  type    => HPlot::TYPE_HISTORY,
+  output  => HPlot::OUT_PNG,
+  xlabel  => "Time [m]",
+  ylabel  => "Temperature",
+  sizex   => 750,
+  sizey   => 270,
+  ymin    => 10,
+  ymax    => "30<*",
+  nokey   => 1,
+  storable=> 1,
+  buffer  => 1
+  });
+HPlot::PlotInit({
+  name    => "pressure",
+  file    => Dmon::DMONDIR."RichEnvironmentPressure",
+  curves  => 1,
+  entries => 3000,
+  type    => HPlot::TYPE_HISTORY,
+  output  => HPlot::OUT_PNG,
+  xlabel  => "Time [m]",
+  ylabel  => "Pressure",
+  sizex   => 750,
+  sizey   => 270,
+  ymin    => 900,
+  ymax    => 1000,
+  nokey   => 1,
+  storable=> 1,
+  buffer  => 1
+  });
+
+my $str = Dmon::MakeTitle(10,12,"RichEnvironment",0);
+   $str .= qq@<img src="%ADDPNG RichEnvironmentTemperature.png%" type="image/png">@."\n";
+   $str .= qq@<img src="%ADDPNG RichEnvironmentPressure.png%" type="image/png">\n@;
+   $str .= Dmon::MakeFooter();
+Dmon::WriteFile("RichEnvironment",$str);
+
+Perl2Epics::Connect("T","CBM:BMP180:GetTemp");
+Perl2Epics::Connect("P","CBM:BMP180:GetPressure");
+
+my $iter = 0;
+
+while (1) {
+
+  # get data from epics
+  my $data = Perl2Epics::GetAll();
+  my $temperature = $data->{"T"}->{"val"} / 10.;
+  my $pressure = $data->{"P"}->{"val"} / 100.;
+
+  my $title    = "Environment";
+  my $value    = sprintf("%.1f / %.1f", $pressure, $temperature);
+  my $longtext = "Pressue (mbar) / Temperatur (°C): ". $value;
+  my $status   = Dmon::OK;
+#   print time."\t".$data->{"P"}->{"tme"}."\t".$data->{"T"}->{"tme"}."\n";
+  if (time - $data->{"P"}->{"tme"} > 240 || time - $data->{"T"}->{"tme"} > 240) {
+    $status = Dmon::WARN;
+    $longtext .="<br>Updates missing";
+    }
+
+  Dmon::WriteQALog($config{flog},"richenvironment",15,$status,$title,$value,$longtext,'30-RichEnvironment');
+
+  if($iter++ % 12 == 0) {
+    HPlot::PlotAdd('temperature',$temperature);
+    HPlot::PlotAdd('pressure',$pressure);
+    HPlot::PlotDraw('temperature');
+    HPlot::PlotDraw('pressure');
+    }
+  sleep 5;
+  }
+
+
+
+
+
index 9bb4a1de3bd04f9e5d2358625faa4c4160d2c947..aa178e7c58c3b40f8f9ab545b2b9eff784c7d507 100755 (executable)
@@ -3,8 +3,6 @@
 use warnings;
 use POSIX qw(strftime);
 use FileHandle;
-use lib "./code";
-use lib "../tools";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
 use Dmon;
diff --git a/perllibs/ChannelMapping.pm b/perllibs/ChannelMapping.pm
new file mode 120000 (symlink)
index 0000000..dc585e9
--- /dev/null
@@ -0,0 +1 @@
+../users/cern_cbmrich/ChannelMapping.pm
\ No newline at end of file
index 7990a7afbbbf8a516eecd481467d43feafd96476..dd49f877448dd50d7357e16771b9217d733078e9 100755 (executable)
@@ -77,9 +77,10 @@ sub PlotInit {
 
   my $filename = $p->{$name}->{file};
   $filename =~ s%/%%;
-  $storefile->{$name} = "/dev/shm/".$name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
-
-    
+  $storefile->{$name} = $name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
+  $storefile->{$name} =~ s%/%%g;
+  $storefile->{$name} = "/dev/shm/".$storefile->{$name};
+  
   foreach my $i (0..($c->{entries}-1)) {
     for my $j (0..($c->{curves}-1)) {
       push(@{$p->{$name}->{value}->[$j]},0) ;
index 81c8b3618a981d36292ee7c32736ac8cbbf93cd8..509153176d1b9fe29f639a57300d149861fb274c 100755 (executable)
@@ -4,7 +4,7 @@
 #Scripts to start & order of icons in the Overview
 activeScripts => [['time','ping','-','-','daqop'],
                   ['numfee','temperature','reftime','billboard','mbs'],
-                  ['beamintensity','-','-','-','-'],
+                  ['beamintensity','beammonitors','-','-','richenvironment'],
                   ['trgrate','datarate','deadtime','-','-'],
                   ['heatmaprich','padiwatemp','padiwaonline','currents','pscurrents'],
                   ['cbmnetlink','cbmnetdata','cbmnetsync','-','-']],
@@ -13,7 +13,7 @@ activeScripts => [['time','ping','-','-','daqop'],
 qaNames => ['sys','main','beam','rate','Pdwa','CNet','-'],                  
 
 #Expected number of FPGAs in system
-NumberOfFpga => 90,       
+NumberOfFpga => 90,
 
 #The address of the individual boards
 CtsAddress   => 0x7005,   
@@ -88,8 +88,9 @@ BeamChan => 0xc005,
 SpillThreshold => 30,
 
 #Name detectors 
-BeamDetectorsTrb  => [0x0111,0x0111,0x0111,0x0110],
-BeamDetectorsChan => [0xc001,0xc005,0xc009,0xc005],
+BeamDetectorsTrb  => [0x0111,0x0110,0x0111,0x0110,0x0113,0x0110],
+BeamDetectorsChan => [0xc001,0xc009,0xc005,0xc00b,0xc009,0xc005],
+BeamDetectorsName => ['C1',  'C1d', 'C2',  'C2d', 'Lead', 'Hodo'],
 
 #User directory
 UserDirectory => '/home/hadaq/trbsoft/daqtools/users/cern_cbmrich/',
index c30607b0b9f7a45a0c9bfd601645d413f4480183..d767ac2eedc6b9793f7cc5529d0c9e66e7d1ecea 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 rm padiwa_threshold_results.log
 ./write_thresholds.pl thresh/dummythresholds.thr -o 0
-
+trbcmd setbit 0x7005 0xa00c 0x80000000
 
 # ./run_thresh_on_system.pl \
 #  --endpoints=0x0013,0x0021,0x0033,0x0041,0x0053,0x0061,0x0073,0x0081,0x0093,0x00a1,0x00b3,0x00c1,0x00d3,0x00e1,0x00f3,0x0101 \
@@ -26,4 +26,5 @@ rm padiwa_threshold_results.log
 ./run_thresh_on_system.pl --endpoints=0x0010-0x0013,0x0020-0x0023,0x0030-0x0033,0x0040-0x0043,0x0050-0x0053,0x0060-0x0063,0x0070-0x0073,0x0080-0x0083,0x0090-0x0093,0x00a0-0x00a3,0x00b0-0x00b3,0x00c0-0x00c3,0x00d0-0x00d3,0x00e0-0x00e3,0x00f0-0x00f3,0x0100-0x0103\
   --32channel --chains=0 --offset=0 --polarity 1  --tool ./thresholds_new.pl 
 
-./write_thresholds.pl padiwa_threshold_results.log -o 0
\ No newline at end of file
+./write_thresholds.pl padiwa_threshold_results.log -o 0
+trbcmd clearbit 0x7005 0xa00c 0x80000000