From: maps Date: Fri, 31 Oct 2014 17:47:16 +0000 (+0100) Subject: pack and unpack to save the signedness X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=e4d6968189954f540eca04a4d63a680790687d0b;p=coral.git pack and unpack to save the signedness --- diff --git a/user_interface/plot.png b/user_interface/plot.png index e69de29..8f57cba 100644 Binary files a/user_interface/plot.png and b/user_interface/plot.png differ diff --git a/user_interface/plotalldat.sh b/user_interface/plotalldat.sh index dceb247..d490adf 100755 --- a/user_interface/plotalldat.sh +++ b/user_interface/plotalldat.sh @@ -6,9 +6,24 @@ datfile=$i datfilebase=$(echo $datfile| sed 's/.dat//') cat <] + +count on a specific channel for a specific time (default 1 sec) +./pmt_ro.pl action=count channel=signal [delay=2.5] + +read from a register, either by name or by address +./pmt_ro.pl action=read_register regName=signal_thresh + +./pmt_ro.pl action=read_register addr=21 + + + =head1 DESCRIPTION @@ -105,7 +118,8 @@ sub main { read_register => 1, write_register => 1, find_baseline => 1, - signal_range => 1 + signal_range => 1, + count => 1 }; # if method exists, execute it, if not complain and show help message @@ -116,7 +130,7 @@ sub main { my $return = $self->$action(%$args); # does it return anything? if(defined($return)){ # we get a return value - if(ref($return) eq "SCALAR"){ # just print it if it is a scalar + if(ref(\$return) eq "SCALAR"){ # just print it if it is a scalar print "$return\n"; } else { # use Data::Dumper to display a hash print "method returns a hash:\n"; @@ -129,6 +143,42 @@ sub main { } } +sub count { # count for a given time on a given channel + # return number of counts + my $self = shift; + my %options = @_; + + my $channel = $options{channel}; # can be "signal" or "veto" or "net" + my $delay = $options{delay} || 1; + + my $counter_addr; + my $threshold_addr; + + if( $channel eq "signal" ){ + $counter_addr = $self->{regaddr_lookup}->{signal_counter}; + $threshold_addr = $self->{regaddr_lookup}->{signal_thresh}; + } elsif ( $channel eq "veto" ){ + $counter_addr = $self->{regaddr_lookup}->{veto_counter}; + $threshold_addr = $self->{regaddr_lookup}->{veto_thresh}; + } elsif ( $channel eq "net" ){ + $counter_addr = $self->{regaddr_lookup}->{net_counter}; + $threshold_addr = $self->{regaddr_lookup}->{net_thresh}; + } else { + die "$channel is not a valid channel!\n possible channels are \"signal\",\"veto\" and \"net\"\n!"; + } + + $self->{regio}->write($self->{regaddr_lookup}->{acquisition},0); # stop acquisition + $self->{regio}->read($self->{regaddr_lookup}->{reset_counter}); # reset counter + $self->{regio}->write($self->{regaddr_lookup}->{acquisition},1); # start acquisition + Time::HiRes::sleep($delay); # let the counter count + $self->{regio}->write($self->{regaddr_lookup}->{acquisition},0); # stop acquisition + my $counts = $self->{regio}->read($counter_addr); # read counter value + $self->{regio}->write($self->{regaddr_lookup}->{acquisition},1); # start acquisition + + die "Padiwa does not answer!\n" unless defined($counts); + return $counts; +} + sub signal_range { # determine the range and the position the signal/noise in terms of # DAC setting my $self = shift; diff --git a/user_interface/regio.pm b/user_interface/regio.pm index bebf65e..abb23f5 100644 --- a/user_interface/regio.pm +++ b/user_interface/regio.pm @@ -128,11 +128,12 @@ sub communicate { } if($ack){ - my $byte3 = ord(substr($rstring,0,1)); - my $byte2 = ord(substr($rstring,1,1)); - my $byte1 = ord(substr($rstring,2,1)); - my $byte0 = ord(substr($rstring,3,1)); - my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0); +# my $byte3 = ord(substr($rstring,0,1)); +# my $byte2 = ord(substr($rstring,1,1)); +# my $byte1 = ord(substr($rstring,2,1)); +# my $byte0 = ord(substr($rstring,3,1)); +# my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0); + my $val = unpack('l',reverse pack('a4',substr($rstring,0,4))); return $val; } else { print "no answer\n" if $self->{verbose};