$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;
* `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
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++;
}
}
}
}
}
if($on && $off) {
- sleep 1;
+ sleep .2;
}
if ($on) {
foreach my $br (0..15) {
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);
--- /dev/null
+#!/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;
+ }
+}