]> jspc29.x-matter.uni-frankfurt.de Git - hades_mdc_settings.git/commitdiff
update scripts
authorHades DAQ <hadaq@lxhadesdaq.gsi.de>
Wed, 5 Feb 2025 15:46:16 +0000 (16:46 +0100)
committerHades DAQ <hadaq@lxhadesdaq.gsi.de>
Wed, 5 Feb 2025 15:46:16 +0000 (16:46 +0100)
scripts/MDC.pm
scripts/README.md
scripts/load_flash_settings.pl
scripts/mdc_voltage.pl
scripts/pasttrec_set_threshold.pl
scripts/powercycle_missing.pl [new file with mode: 0755]

index fdc48c7af3df7e880f5e08ea07be9f94dbe55e8e..9b88e059db6188724f2ffdca370db110659014f8 100644 (file)
@@ -50,7 +50,7 @@ sub get_position {
     $p = (($addr>>8)==0x8e)?0:2;
     $p += 1 if (($addr>>4)&0xf)>=6;
     }
-  elsif($addr > 0xa000 && $addr < 0xbfff) {
+  elsif($addr >= 0xa000 && $addr < 0xbfff) {
     $e = $addr & 0x3;
     $b = ($addr>>4) & 0xf;
     $s = (($addr>>8)&0xf)%6;
index b0bc30e0715a14ae032b42f61abf006b08078f5e..db8e42b1bc6ba6f9e5fd5bc9a5aec1862735e3fc 100644 (file)
@@ -20,6 +20,7 @@
 * `mdc_voltage.pl` set voltages and update voltage database file, switches boards on/off, based on addresses
 * `mdc_powerboard.pl` send commands to a MDC power board, based on raw device and channel numbers
 * `check_voltages.pl` reads voltages and suggests changes
+* `powercycle_missing.pl` takes the Hmon log and powercyles missing MBOs
 
 # Packages
 * `MDC.pm` Library with common functions, like address lookup
index cfa3f371e755f51f9f54c7ccc227390dbfc83d9d..38e8c7697c7d7d624c102168096d3df60e456e1c 100755 (executable)
@@ -49,17 +49,25 @@ if (defined $board){
 elsif (defined $all) {
   trb_init_ports() or die trb_strerror();
   my $boards = trb_read_uid(0xfe90);
+  my $totalboards = scalar keys %$boards;
+  my $i = 1;
   foreach my $uid (keys %$boards) {
     foreach my $k (keys %{$boards->{$uid}}) {
       my $addr = $boards->{$uid}{$k};
+      print("OEP $i/$totalboards\n");
       load_board($addr);
+      $i++;
       }
     }
   $boards = trb_read_uid(0xfe91);
+  $totalboards = scalar keys %$boards;
+  $i = 1;
   foreach my $uid (keys %$boards) {
     foreach my $k (keys %{$boards->{$uid}}) {
       my $addr = $boards->{$uid}{$k};
+      print("TDC $i/$totalboards\n");
       load_board($addr);
+      $i++;
       }
     }
   }
index 0ccc7f97c63853a2ca9374a8df8a84bf9a2c3e3d..c572b96820607b61cc6192cb90d7cbb3aca815e1 100755 (executable)
@@ -147,7 +147,7 @@ if((defined $on || defined $off) && defined $board) {
         }
       }
     if($on && $off) {
-      sleep 1;
+      sleep .2;
       }
     if ($on) {
       foreach my $br (0..15) {
index 7add8d2478daa0415e66836da43e0e67fd6cb356..a65c041c55b3aadcf4a4ee5a8609bf29a5d1f020 100755 (executable)
@@ -2,17 +2,54 @@
 use warnings;
 use HADES::TrbNet;
 use Time::HiRes;
+use Getopt::Long;
+
+
+my $board;
+my $pasttrec;
+
+Getopt::Long::Configure(qw(gnu_getopt));
+GetOptions(
+           'help|h'      => \$help,
+           'board|b=s'   => \$board,
+           'pt|p=s'   => \$pasttrec,
+           );
+
+if($help) {
+print <<HELP;
+Sets the threshold for Pasttrec.
+If no PT number is given, all 4 PT are configured
+If no board address is given, a broadcast to all boards is issued.
+
+Options
+=======
+  -b 0xnnnn    Board address
+  -p 0..3      PT number
+HELP
+       
+exit;
+}
+
 
 my $threshold = $ARGV[0];
+   $board = hex($board) if defined $board && $board =~ /^0x/;
+   $board = 0xfe91 unless defined $board;
+   
+die "Address must be in range 0xa000 to 0xbbf2" if (($board < 0xa000 || $board > 0xbbf2) && $board != 0xfe91);
+   
+my $firstpt = $pasttrec // 0;
+my $lastpt  = $pasttrec // 3;
+
+die "Pasttrec must be in range 0 to 3" if ($firstpt < 0 || $firstpt > 3);
+
 trb_init_ports() or die trb_strerror();
 
 if($threshold < 0 || $threshold > 127) {
-  die "not in valid range 0..127\n";
+  die "Threshold not in valid range 0..127\n";
   }
   
-foreach my $pt (0..3) { 
-  trb_register_write(0xfe91,0xa200+($pt << 4)+3,0x50300+$threshold);
+foreach my $pt ($firstpt..$lastpt) { 
+  trb_register_write($board,0xa200+($pt << 4)+3,0x50300+$threshold);
   }
   
-printf(" Threshold %i set to all available PASTTRECs. \n", $threshold);
+printf(" Threshold %i set to PASTTRECs on %04x \n", $threshold,$board);
diff --git a/scripts/powercycle_missing.pl b/scripts/powercycle_missing.pl
new file mode 100755 (executable)
index 0000000..05d8685
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/perl -w
+use warnings;
+no warnings "portable";
+use FileHandle;
+use Getopt::Long;
+use Data::Dumper;
+use lib '.';
+use Time::HiRes qw(usleep);
+
+
+die "Run on machine with Hmon!" unless -e "/dev/shm/hmon/qalog";
+
+my @logfile = qx(tail -n 250 /dev/shm/hmon/qalog);
+my %cycledboards;
+
+foreach my $l (@logfile) {
+  my @d = split("\t",$l);
+  if (defined $d[2] &&  $d[1] eq 'endp' && $d[2] eq 'mdc') {
+    next if scalar @d < 7;
+    my @boards = split(' ',$d[7]);
+#     die "Looks like too many boards missing" unless scalar @boards < 50;
+    foreach my $b (@boards) {
+      if ($b =~ /0x8[ef]\w\w/) {
+        print ("$b");
+        print(" skipped\n") and next if $cycledboards{hex($b)};
+        system("./mdc_voltage.pl -b $b --on --off");
+        usleep(10000);
+        print("\n");
+        $cycledboards{hex($b)}=1;
+        }
+      if ($b =~ /0x[ab]\w\w\w/) {
+        print($b);
+        $b = 0x8e00 + ((hex($b)>>4)-0xa00);
+        printf (" -> %04x",$b);
+        print(" skipped\n") and next if $cycledboards{$b};
+        system("./mdc_voltage.pl -b $b --on --off");
+        usleep(10000);
+        print("\n");
+        $cycledboards{$b}=1;
+        }
+      }
+  
+    last;
+    }
+}