my $help;
my $board;
+my $sector;
+my $plane;
my $channel;
my $setting;
my $write;
my $relative;
my $on;
my $off;
+my $fullchamber;
Getopt::Long::Configure(qw(gnu_getopt));
GetOptions(
'help|h' => \$help,
'board|b=s' => \$board,
+ 'sector|s=i' => \$sector,
+ 'plane|p=i' => \$plane,
'channel|c=i' => \$channel,
+ 'chamber' => \$chamber,
'value|v=i' => \$setting,
'relative|r=i'=> \$relative,
'write|w' => \$write,
print <<HELP;
Reads the current voltage setting from configuration file.
Sets the current voltage, optionally changes configuration file.
-Board needs to be a valid OEP address.
+Board needs to be a valid OEP address, or plane,sector,board number.
Options
=======
-b 0xnnnn Board address
+ -b (0..15) Board number in sector (if sector/plane is given)
+ -s (0..5) Sector
+ -p (0..3) Plane
-c (0|1) Channel number
-r (-7..7) relative change of setting
-v (0-7) absolute change of setting
-w write to configuration file
--on/--off switch power (power cycle if both are specified)
+ --chamber switch full chamber instead of individual boards
-l load settings from file
-
+Board addressing schemes (ADDR):
+ * (-board|-b) 0xnnnn #using a valid OEP address
+ * (-plane|-p) (0..3) (-sector|-s) (0..5) (-board|-b) (0..15) #by position
+ * (-plane|-p) (0..3) (-sector|-s) (0..5) #if used with --chamber
Examples
========
-mdc_voltage.pl (-board|-b) 0xnnnn
+mdc_voltage.pl ADDR
display settings from file
-mdc_voltage.pl (-board|-b) 0x8nnn (-load|-l)
+mdc_voltage.pl ADDR (-load|-l)
load settings from file to board
mdc_voltage.pl (-load|-l)
load all settings from file to boards
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-value|-v) (0-7)
+mdc_voltage.pl ADDR (-channel|-c) (0|1) (-value|-v) (0-7)
change setting on board only
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-value|-v) (0-7) (-write|-w)
+mdc_voltage.pl ADDR (-channel|-c) (0|1) (-value|-v) (0-7) (-write|-w)
change setting on board and store in file
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-relative|-r) (-7..7) [(-write|-w)]
+mdc_voltage.pl ADDR (-channel|-c) (0|1) (-relative|-r) (-7..7) [(-write|-w)]
change setting relative to the setting in file
-mdc_voltage.pl (-board|-b) 0xnnnn (--on|--off)
+mdc_voltage.pl ADDR (--on|--off)
switches board on/off
-
+
+mdc_voltage.pl ADDR --chamber (--on|--off)
+ switch full chamber on/off
+
HELP
}
-$board = hex($board) if defined $board;
-if(defined $board && ($board < 0x8e00 || $board > 0x8fff)) {
- die "Wrong board address (8e00 - 8fff)\n";
+$board = hex($board) if defined $board && $board =~ /^0x/;
+
+if(defined $sector && defined $plane) {
+ if($sector < 0 || $sector > 5) {
+ die "Wrong sector number \n";
+ }
+ if($plane < 0 || $plane > 3) {
+ die "Wrong plane number \n";
+ }
+ if(!defined $board || $board < 0 || $board > 15 || ($board > 13 && $plane == 0)) {
+ die "Wrong board number \n" if !$chamber;
+
+ $board = 0;
+ }
+ $board = MDC::get_address($plane,$sector,$board // 0,5);
+ }
+else {
+ if(defined $board && ($board < 0x8e00 || $board > 0x8fff)) {
+ die "Wrong board address (8e00 - 8fff)\n";
+ }
+ $plane = 5;
+ $plane = 0 if ($board < 0x8e60);
}
if(defined $channel && ($channel < 0 || $channel > 1)) {
die "Wrong relative number (-7-7)\n";
}
+
#Switch boards on/off
if((defined $on || defined $off) && defined $board) {
- if(defined $on && defined $off) {$on = 2;}
- my $ret = MDCPower::power_switch($board,$on//0);
- die "Board not found.\n" if $ret == -1;
+
+ if($chamber) {
+ $board = $board & 0xfff0;
+ if ($off) {
+ foreach my $br (0..15) {
+ my $ret = MDCPower::power_switch($board+$br,0);
+ die "Board not found.\n" if $ret == -1;
+ last if $br==13 && $plane == 0;
+ }
+ }
+ if($on && $off) {
+ sleep 1;
+ }
+ if ($on) {
+ foreach my $br (0..15) {
+ my $ret = MDCPower::power_switch($board+$br,1);
+ die "Board not found.\n" if $ret == -1;
+ last if $br==13 && $plane == 0;
+ }
+ }
+ }
+ else {
+ if(defined $on && defined $off) {$on = 2;}
+ my $ret = MDCPower::power_switch($board,$on//0);
+ die "Board not found.\n" if $ret == -1;
+ }
}
#Load all settings