Instrument/SR830/AuxIn.pm

filter: Statementstmt 86.0% 37 / 43 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 66.6% 2 / 3 totaltotal 75.7% 53 / 70 SCAR 20.5
CC
7
Cov
75%
empty_buffer
7.0
new
4.6
BEGIN
1.0
CRAP 7.8
« Moose/Instrument/AH2700A.pm ↑ Summary MultiChannelInstrument/DeviceCache.pm »
1 package Lab::Instrument::SR830::AuxIn;
2 #ABSTRACT: Aux Inputs of the Stanford Research SR830 Lock-In Amplifier
3 2 $Lab::Instrument::SR830::AuxIn::VERSION = '3.881';
4 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use parent 'Lab::Instrument';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 2 our %fields = (
17 channel => undef,
18 supported_connections => [ 'GPIB', 'VISA_GPIB', 'DEBUG' ],
19 );
20  
21 sub new {
22 2 ▶ my $proto = shift;
Subroutine new: called CC=4 SCAR=15.2
Pod documented
23 2 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
24 2 my $self = $class->SUPER::new(@_);
25 2 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
26 2 $self->empty_buffer();
27 2 my $channel = $self->channel;
28 2 ▶ if ( not defined $channel ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $channel) { } 0 2 2
elsif (not $channel =~ /^[1-4]$/u) { } 0 2 2
29 0 croak "need channel (1-4) in constructor for ", __PACKAGE__;
30 }
31 elsif ( $channel !~ /^[1-4]$/ ) {
32 0 croak "channel '$channel' is not in the range (1..4)";
33 }
34 2 return $self;
35 }
36  
37 sub empty_buffer {
38 2 ▶ my $self = shift;
Subroutine empty_buffer: called CC=4 SCAR=19.4
Pod undocumented
39 2 my ($times) = $self->_check_args( \@_, ['times'] );
40 2 ▶ if ($times) {
Branch: 1 branch
BranchTrueFalseTotal
if ($times) { } 0 2 2
41 0 ▶ for ( my $i = 0; $i < $times; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $times) 0 0 0
42 0 eval { $self->read( brutal => 1 ) };
43 }
44 }
45 else {
46 2 ▶ while ( $self->read( brutal => 1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->read("brutal", 1)) 0 2 2
47 0 print "Cleaning buffer.";
48 }
49 }
50 }
51  
52  
53 sub get_value {
54 2 ▶ my $self = shift;
Subroutine get_value: called CC=1 SCAR=0.0
Pod documented
55 2 my ($tail) = $self->_check_args( \@_, [] );
56 2 my $channel = $self->channel;
57 2 return $self->query("OAUX? $channel");
58 }
59  
60 2 1;
61  
62 __END__
63  
64 =pod
65  
66 =encoding UTF-8
67  
68 =head1 NAME
69  
70 Lab::Instrument::SR830::AuxIn - Aux Inputs of the Stanford Research SR830 Lock-In Amplifier
71  
72 =head1 VERSION
73  
74 version 3.881
75  
76 =head1 SYNOPSIS
77  
78 use Lab::Instrument::SR830::AuxIn
79 my $multimeter = Lab::Instrument::SR830::AuxIn->new(%options, channel => 1);
80  
81 print $multimeter->get_value();
82  
83 =head1 DESCRIPTION
84  
85 This class provides access to the four DC inputs of the SR830. You have to
86 provide a C<channel> (1..4) parameter in the constructor.
87  
88 B<To use multiple virtual instruments, which use the same physical device, you have to share the connection between the virtual instruments:>
89  
90 use Lab::Measurement;
91  
92 # Create the shared connection.
93 my $connection = Connection('LinuxGPIB', {gpib_address => 8});
94
95 # Array of instrument objects. Each element belongs to one of the four
96 # channels.
97 my @inputs;
98
99 for my $channel (1..4) {
100 $inputs[$channel] = Instrument('SR830::AuxIn', {
101 connection => $connection,
102 channel => $channel,
103 });
104 }
105
106 for my $channel (1..4) {
107 say "channel $channel: ", $inputs[$channel]->get_value();
108 }
109  
110 =head1 Methods
111  
112 =head2 get_value()
113  
114 Return the input voltage.
115  
116 =head1 COPYRIGHT AND LICENSE
117  
118 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
119  
120 Copyright 2016 Simon Reinhardt
121 2017 Andreas K. Huettel
122 2020 Andreas K. Huettel
123  
124  
125 This is free software; you can redistribute it and/or modify it under
126 the same terms as the Perl 5 programming language system itself.
127  
128 =cut
« Moose/Instrument/AH2700A.pm ↑ Summary MultiChannelInstrument/DeviceCache.pm »