Moose/Instrument/SCPI/Sense/Function/Concurrent.pm

filter: Statementstmt 89.2% 58 / 65 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 86.6% 13 / 15 Podpod 100% 8 / 8 totaltotal 89.1% 82 / 92 SCAR 11.0
CC
3
Cov
88%
sense_function_on
3.0
sense_function_query
2.0
sense_function_off_query
2.0
CRAP 3.0
« Moose/Connection.pm ↑ Summary Moose/Instrument/SCPI/Sense/Impedance.pm »
1 package Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent;
2 3 $Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent::VERSION = '3.881';
3 #ABSTRACT: Role for the SCPI SENSe:FUNCtion subsystem with support for concurrent sense
4  
5 3 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 use Lab::Moose::Instrument
10 3 ▶ qw/validated_channel_getter validated_channel_setter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 excludes 'Lab::Moose::Instrument::SCPI::Sense::Function';
17  
18  
19 3 cache sense_function_concurrent =>
20 ( getter => 'sense_function_concurrent_query' );
21  
22 sub sense_function_concurrent_query {
23 2 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_function_concurrent_query: called CC=1 SCAR=0.0
Pod documented
24  
25 2 my $value = $self->query( command => "SENS${channel}:FUNC:CONC?", %args );
26 2 return $self->cached_sense_function_concurrent($value);
27 }
28  
29 sub sense_function_concurrent {
30 4 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter(
Subroutine sense_function_concurrent: called CC=1 SCAR=0.0
Pod documented
31 \@_,
32 value => { isa => 'Bool' }
33 );
34  
35 4 $self->write( command => "SENS${channel}:FUNC:CONC $value", %args );
36 4 return $self->cached_sense_function_concurrent($value);
37 }
38  
39  
40 3 cache sense_function => ( getter => 'sense_function_query' );
41  
42 sub sense_function {
43 2 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ );
Subroutine sense_function: called CC=1 SCAR=0.0
Pod documented
44 2 return $self->cached_sense_function($value);
45 }
46  
47  
48 sub sense_function_query {
49  
50 # overwrite in instrument driver to get different default.
51 0 ▶ return 'CURR';
Subroutine sense_function_query: not called CC=1 SCAR=6.9
Pod documented
52 }
53  
54  
55 3 cache sense_function_on =>
56 ( isa => 'ArrayRef[Str]', getter => 'sense_function_on_query' );
57  
58 sub sense_function_on {
59 6 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter(
Subroutine sense_function_on: called CC=3 SCAR=11.1
Pod documented
60 \@_,
61 value => { isa => 'ArrayRef[Str]' }
62 );
63 6 my @values = @{$value};
64 6 ▶ if ( not $self->cached_sense_function_concurrent ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->cached_sense_function_concurrent) 3 3 6
65 3 ▶ if ( @values != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values != 1) 0 3 3
66 0 croak
67 "sense_function_on without concurrent sense only accepts single function";
68 }
69 }
70 6 @values = map {"'$_'"} @values;
71 6 my $param = join( ',', @values );
72  
73 6 $self->write( command => "SENS${channel}:FUNC:ON $param", %args );
74 6 return $self->sense_function_on_query(%args);
75 }
76  
77 sub sense_function_on_query {
78 13 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_function_on_query: called CC=1 SCAR=0.0
Pod documented
79  
80 13 my $value = $self->query( command => "SENS${channel}:FUNC:ON?", %args );
81 13 $value =~ s/["']//g;
82 13 my @values = split( ',', $value );
83 13 $self->cached_sense_function_on( [@values] );
84 13 return [@values];
85 }
86  
87  
88 sub sense_function_off {
89 2 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter(
Subroutine sense_function_off: called CC=1 SCAR=0.0
Pod documented
90 \@_,
91 value => { isa => 'ArrayRef[Str]' }
92 );
93 2 my @values = @{$value};
94 2 @values = map {"'$_'"} @values;
95 2 my $param = join( ',', @values );
96  
97 2 $self->write( command => "SENS${channel}:FUNC:OFF $param", %args );
98  
99 # update cached_sense_function_on
100 2 $self->sense_function_on_query(%args);
101 }
102  
103 sub sense_function_off_query {
104 0 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_function_off_query: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 my $value = $self->query( command => "SENS${channel}:FUNC:OFF?", %args );
107 0 $value =~ s/["']//g;
108 0 my @values = split( ',', $value );
109 0 return [@values];
110 }
111  
112 3 1;
113  
114 __END__
115  
116 =pod
117  
118 =encoding UTF-8
119  
120 =head1 NAME
121  
122 Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent - Role for the SCPI SENSe:FUNCtion subsystem with support for concurrent sense
123  
124 =head1 VERSION
125  
126 version 3.881
127  
128 =head1 DESCRIPTION
129  
130 This role is intended for instruments which support multiple concurrent sense
131 functions. For example, the Keithley2400 or KeysightB2901A source/measure units
132 which can measure voltage and current simultaneously.
133  
134 The set sense function is used by other SENSE: roles, like SENSE:NPLC. For
135 example, let us enable concurrent measurement of voltage and current and set the integration time for both
136 measured parameters:
137  
138 $source->sense_function_concurrent(value => 1);
139 $source->sense_function_on(value => ['VOLT', 'CURR']);
140  
141 # Set NPLC for current measurement
142 $source->sense_function(value => 'CURR');
143 $source->sense_nplc(value => 10);
144  
145 # Set NPLC for voltage measurement
146 $source->sense_function(value => 'VOLT');
147 $source->sense_nplc(value => 10);
148  
149 =head1 METHODS
150  
151 =head2 sense_function_concurrent_query/sense_function_concurrent
152  
153 Set/Get concurrent property of sensor block. Allowed values: C<0> or C<1>.
154  
155 =head2 sense_function
156  
157 $source->sense_function(value => $function);
158  
159 Unlike the C<sense_function> method from the
160 L<Lab::Moose::Instrument::SCPI::Sense::Function> method, does not send a command, only used by other SENSE: roles, like SENSE:NPLC
161  
162 =head2 cached_sense_function/sense_function_query
163  
164 C<sense_function_query> is only used to initialize the cache.
165  
166 =head2 sense_function_on
167  
168 $source->sense_function_on(value => ['CURR', 'VOLT']);
169  
170 Enable parameters which should be measured.
171  
172 =head2 sense_function_on_query
173  
174 my @params = @{$source->sense_function_on_query()};
175  
176 Query list of parameters which are measured.
177  
178 =head2 sense_function_off_query/sense_function_off
179  
180 $source->sense_function_off(value => ['CURR']);
181  
182 Query/set list of parameters which should not be measured.
183  
184 =head1 COPYRIGHT AND LICENSE
185  
186 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
187  
188 Copyright 2018 Simon Reinhardt
189 2020 Andreas K. Huettel
190  
191  
192 This is free software; you can redistribute it and/or modify it under
193 the same terms as the Perl 5 programming language system itself.
194  
195 =cut
« Moose/Connection.pm ↑ Summary Moose/Instrument/SCPI/Sense/Impedance.pm »