my $opt_32channel = 0;
my $opt_finetune = false;
my $opt_sequential = false;
+my $mode = "padiwa";
my $opt_verb;
my $tool = "./thresholds_automatic.pl";
#my $tool = "./thresholds_automatic_jan.pl";
'f|finetune' => \$opt_finetune,
's|sequential' => \$opt_sequential,
't|tool=s' => \$tool,
+ 'm|mode=s' => \$mode,
'v|verb' => \$opt_verb);
my $endpoints = get_ranges(\@opt_endpoints);
+
+if ($mode eq "dirich2") {
+ @opt_chains=(0);
+}
+
my $chains = get_ranges(\@opt_chains);
if( $opt_help ) {
}
-#print Dumper $endpoints;
-#print Dumper $chains;
+print Dumper $endpoints;
+print Dumper $chains;
if($opt_32channel == 1) {
$opt_32channel="--32channel";
foreach my $endpoint (@$endpoints) {
foreach my $chain (@$chains) {
my $endpoint = sprintf("0x%04x", $endpoint);
- $command = "$tool -e $endpoint -o $opt_offset -c $chain -p $opt_polarity $opt_32channel $opt_finetune";
+ $command = "$tool --endpoint $endpoint --offset $opt_offset --chain $chain --polarity $opt_polarity --mode=$mode $opt_32channel $opt_finetune";
print "command: $command\n";
if($opt_sequential) {
my $hitregister = 0xc001;
-my @valid_interval = (0x5000, 0xc000);
+my @valid_interval = (0x4000, 0xc000);
my $interval_step = ($valid_interval[1] - $valid_interval[0])/2;
my $start_value = int ( ($valid_interval[1] + $valid_interval[0])/2 );
trb_init_ports() or die trb_strerror();
-my @current_thresh = ($start_value) x 16;
-my @best_thresh = (0) x 16;
-my @hit_diff = (0) x 16;
-my @crossed_thresh = (0) x 16;
-my @interval_step = ($interval_step) x 16;
+my @current_thresh = ($start_value) x 32;
+my @best_thresh = (0) x 32;
+my @hit_diff = (0) x 32;
+my @crossed_thresh = (0) x 32;
+my @interval_step = ($interval_step) x 32;
-if (defined $opt_skip && $opt_skip < 15) {
+if (defined $opt_skip && $opt_skip < 32) {
$best_thresh[$opt_skip] = 0x7000;
}
my $outermost_channel_loop_counter = 0;
#set default values
-my @zero_array = (0) x 16;
+my @zero_array = ($mode eq "dirich2") ? (0) x 32 : (0) x 16 ;
+
write_thresholds($mode, $chain, \@zero_array);
if($channel_by_channel == true) {
- $outermost_channel_loop_counter = 15;
+ $outermost_channel_loop_counter = ($mode eq "dirich2") ? 31 : 15 ;
}
my @outermost_channel_loop = (0);
#print Dumper $rh_res;
#print Dumper $old_rh_res;
- my @iterate_loop = (0..15);
+ my @iterate_loop = ($mode eq "dirich2") ? (0 .. 31) : (0 .. 15);
if($channel_by_channel) {
@iterate_loop = ($current_channel_outer_loop);
}
map { $_-= ($offset * $default_direction) } @best_thresh;
write_thresholds($mode, $chain, \@best_thresh, $channel_to_set);
-my $uid;
+my $uid = 0;
foreach my $i (reverse (0 .. 3)) {
#print "send command: $endpoint , i: $i\n";
# read uids
- $rh_res = Dmon::PadiwaSendCmd(0x10000000 | $i * 0x10000, $endpoint, $chain);
- $uid .= sprintf("%04x", $rh_res->{$endpoint} &0xffff);
+ #$rh_res = Dmon::PadiwaSendCmd(0x10000000 | $i * 0x10000, $endpoint, $chain);
+ #$uid .= sprintf("%04x", $rh_res->{$endpoint} &0xffff);
#print $uid;
}
#$logger_data->info(sprintf "endpoint: %04x, chain: %02d, uid: $uid", $endpoint, $chain);
#$logger_data->info("\t".time);
-my @range = (0 .. 15);
+my @range = ($mode eq "dirich2") ? (0 .. 31) : (0 .. 15);
if($channel_by_channel) {
@range = ($current_channel_outer_loop .. $current_channel_outer_loop);
my $rh_res;
# $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain);
- foreach my $current_channel (0 .. 15) {
+ my @range = ($mode eq "dirich2") ? (0 .. 31) : (0 .. 15);
+ foreach my $current_channel (@range) {
my $command;
my $fixed_bits;
}
### old and wrong way #my $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain);
- my @range = (0 .. 15);
- if (defined $channel_to_set && $channel_to_set <16 ) {
- @range = ($channel_to_set .. $channel_to_set);
- #print "range: \n";
+ my @range = ($mode eq "dirich2") ? (0 .. 31) : (0 .. 15);
+
+ if (defined $channel_to_set && $channel_to_set <32 ) {
+ @range = ($channel_to_set .. $channel_to_set);
+ #print "range: \n";
}
#print Dumper \@range;
$channel_shift = 16;
}
elsif ($mode eq "dirich2") {
- $fixed_bits = 0x00800000;
+ $fixed_bits = 0x8 << 20;
$shift_bits = 0;
$channel_shift = 24;
}
$command = $fixed_bits | ($current_channel << $channel_shift) | ($ra_thresh->[$current_channel] << $shift_bits);
- Dmon::PadiwaSendCmd($command,$endpoint, $chain);
+
+ if ($mode eq "dirich2") {
+ if ($current_channel<16) {
+ Dmon::PadiwaSendCmd($command,$endpoint, 0);
+ } else {
+ Dmon::PadiwaSendCmd($command,$endpoint, 1);
+ }
+
+ } elsif ($mode eq "padiwa") {
+ Dmon::PadiwaSendCmd($command,$endpoint, $chain);
+ }
+
}
#sleep 10 if($current_channel == 15 && $chain==1);
if($USE_LOCK) {
$share->unlock();
}
-
}
sub send_command {
##idn => "HAMEG,HMP4040,021527872,HW50020001/SW2.41",
idn => "HAMEG,HMP4040,103161,HW50020001/SW2.51",
channels => [ 'clock', 'TDB', 'TBD', 'dirich'],
- commands => {status => 'OUTPUT:STATE?', off => 'OUTPUT:SEL OFF', on => 'OUTPUT:SEL ON'}
+ commands => {status => 'OUTPUT:STATE?', off => 'OUTPUT:SEL OFF', on => 'OUTPUT:SEL ON', select_channel => 'INST OUT4'}
},
{ host => "wiznet03:5000",
idn => "RIGOL TECHNOLOGIES,DP712,DP7B182500302,00.01.02",
my $current_status = write_and_read($actual_setup->{commands}->{status});
print "current status: $current_status\n";
+ print "select channel if appropriate for the device\n";
+ write_and_read($actual_setup->{commands}->{select_channel}) if (defined $actual_setup->{commands}->{select_channel});
+
print "turn off power supply channel\n";
write_and_read($actual_setup->{commands}->{off});