| 1 | package Lab::Instrument::SR830::AuxIn; | ||
| 2 | #ABSTRACT: Aux Inputs of the Stanford Research SR830 Lock-In Amplifier | ||
| 3 | $Lab::Instrument::SR830::AuxIn::VERSION = '3.899'; | ||
| 4 | use v5.20; | ||
| 5 | |||
| 6 | |||
| 7 | use warnings; | ||
| 8 | use strict; | ||
| 9 | |||
| 10 | use Data::Dumper; | ||
| 11 | use Carp; | ||
| 12 | |||
| 13 | use parent 'Lab::Instrument'; | ||
| 14 | |||
| 15 | |||
| 16 | our %fields = ( | ||
| 17 | channel => undef, | ||
| 18 | supported_connections => [ 'GPIB', 'VISA_GPIB', 'DEBUG' ], | ||
| 19 | ); | ||
| 20 | |||
| 21 | sub new { | ||
| 22 | my $proto = shift; | ||
| 23 | my $class = ref($proto) || $proto; | ||
| 24 | my $self = $class->SUPER::new(@_); | ||
| 25 | $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__); | ||
| 26 | $self->empty_buffer(); | ||
| 27 | my $channel = $self->channel; | ||
| 28 | if ( not defined $channel ) { | ||
| 29 | croak "need channel (1-4) in constructor for ", __PACKAGE__; | ||
| 30 | } | ||
| 31 | elsif ( $channel !~ /^[1-4]$/ ) { | ||
| 32 | croak "channel '$channel' is not in the range (1..4)"; | ||
| 33 | } | ||
| 34 | return $self; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub empty_buffer { | ||
| 38 | my $self = shift; | ||
| 39 | my ($times) = $self->_check_args( \@_, ['times'] ); | ||
| 40 | if ($times) { | ||
| 41 | for ( my $i = 0; $i < $times; $i++ ) { | ||
| 42 | eval { $self->read( brutal => 1 ) }; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | else { | ||
| 46 | while ( $self->read( brutal => 1 ) ) { | ||
| 47 | print "Cleaning buffer."; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | sub get_value { | ||
| 54 | my $self = shift; | ||
| 55 | my ($tail) = $self->_check_args( \@_, [] ); | ||
| 56 | my $channel = $self->channel; | ||
| 57 | return $self->query("OAUX? $channel"); | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |