Instrument/AH2700A.pm

filter: Statementstmt 9.8% 15 / 152 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 11.1% 4 / 36 Podpod 3.2% 1 / 31 totaltotal 6.6% 20 / 301 SCAR 64.9
CC
28
Cov
7%
set_bright
132.0
get_single
42.0
set_bias
20.0
CRAP 660.4
« Moose/Instrument/Cache.pm ↑ Summary Moose/Instrument/Lakeshore372.pm »
1 package Lab::Instrument::AH2700A;
2 #ABSTRACT: Andeen-Hagerling AH2700A ultra-precision capacitance bridge
3 1 $Lab::Instrument::AH2700A::VERSION = '3.881';
4 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Time::HiRes qw (usleep);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Lab::Instrument;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @ISA = ("Lab::Instrument");
11  
12 1 our %fields = (
13 supported_connections => [ 'VISA_GPIB', 'GPIB', 'DEBUG', 'DUMMY' ],
14  
15 # default settings for the supported connections
16 connection_settings => {
17 gpib_board => 0,
18 gpib_address => undef,
19 timeout => 2,
20 termchar => "\n"
21 },
22  
23 device_settings => {
24  
25 },
26  
27 device_cache => {
28 aver => undef,
29 frq => undef,
30 bias => undef
31 },
32  
33 device_cache_order => [],
34  
35 );
36  
37 sub new {
38 0 ▶ my $proto = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
39 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
40 0 my $self = $class->SUPER::new(@_);
41 0 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
42  
43 0 return $self;
44 }
45  
46 ▶sub _device_init {
Subroutine _device_init: not called CC=1 SCAR=0.0
47  
48 }
49  
50 sub set_frq {
51 0 ▶ my $self = shift;
Subroutine set_frq: not called CC=3 SCAR=24.8
Pod undocumented
52  
53 # read from cache or from device?
54 0 my ( $frq, $tail ) = $self->_check_args( \@_, ['frq'] );
55  
56 0 ▶ if ( $frq < 50 or $frq > 20000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frq < 50 or $frq > 20000) { } 0 0 0
Condition0%0/3
$frq < 50 or $frq > 20000
l!l&&r!l&&!r
000
MC/DC0%0/2
$frq < 50 or $frq > 20000
$frq < 50 $frq > 20000
Truth table0%0/3
A or B
A= $frq < 50B= $frq > 20000
ABresult
1X1
011
000
57 0 Lab::Exception::CorruptParameter->throw(
58 error => "bad frequency-parameter!\n" );
59 }
60 else {
61 0 $self->write( sprintf( "FREQ %d", $frq ), $tail );
62 }
63  
64 }
65  
66 sub get_frq {
67 0 ▶ my $self = shift;
Subroutine get_frq: not called CC=1 SCAR=6.9
Pod undocumented
68  
69 0 my $result = $self->query( sprintf("SH FR") );
70  
71 0 $result =~ /(\D+)(\d+\.\d+)(\D+)/;
72  
73 0 return $2;
74  
75 }
76  
77 sub set_aver {
78 0 ▶ my $self = shift;
Subroutine set_aver: not called CC=3 SCAR=24.8
Pod undocumented
79  
80 # read from cache or from device?
81 0 my ( $aver, $tail ) = $self->_check_args( \@_, ['aver'] );
82  
83 0 ▶ if ( $aver < 0 or $aver > 15 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aver < 0 or $aver > 15) { } 0 0 0
Condition0%0/3
$aver < 0 or $aver > 15
l!l&&r!l&&!r
000
MC/DC0%0/2
$aver < 0 or $aver > 15
$aver < 0 $aver > 15
Truth table0%0/3
A or B
A= $aver < 0B= $aver > 15
ABresult
1X1
011
000
84 0 Lab::Exception::CorruptParameter->throw(
85 error => "bad average-parameter!\n" );
86 }
87 else {
88 0 $self->write( sprintf( "AV %d", $aver ), $tail );
89 }
90 }
91  
92 sub get_aver {
93 0 ▶ my $self = shift;
Subroutine get_aver: not called CC=1 SCAR=6.9
Pod undocumented
94  
95 0 my $result = $self->query( sprintf("SH AV") );
96  
97 0 $result =~ /(\D+)(\D+\=)(\d+)/;
98  
99 0 return $3;
100  
101 }
102  
103 sub set_bias {
104 0 ▶ my $self = shift;
Subroutine set_bias: not called CC=4 SCAR=30.0
Pod undocumented
105  
106 # read from cache or from device?
107 0 my ( $bias, $tail ) = $self->_check_args( \@_, ['bias'] );
108  
109 0 ▶ if ( $bias eq "OFF" or $bias eq "IHIGH" or $bias eq "ILOW" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bias eq 'OFF' or $bias eq 'IHIGH' or $bias eq 'ILOW') { } 0 0 0
Condition0%0/6
$bias eq "OFF" or $bias eq "IHIGH" or $bias eq "ILOW"
l!l&&r!l&&!r
000
$bias eq "OFF" or $bias eq "IHIGH"
l!l&&r!l&&!r
000
MC/DC0%0/3
$bias eq "OFF" or $bias eq "IHIGH" or $bias eq "ILOW"
$bias eq "OFF" $bias eq "IHIGH" $bias eq "ILOW"
Truth table0%0/4
A or B or C
A= $bias eq "OFF"B= $bias eq "IHIGH"C= $bias eq "ILOW"
ABCresult
1XX1
01X1
0011
0000
110 0 $self->write( sprintf( "BI %s", $bias ), $tail );
111 }
112 else {
113 0 Lab::Exception::CorruptParameter->throw(
114 error => "bad bias-parameter!\n" );
115 }
116  
117 }
118  
119 sub get_bias {
120 0 ▶ my $self = shift;
Subroutine get_bias: not called CC=1 SCAR=6.9
Pod undocumented
121  
122 0 my $result = $self->query( sprintf("SH BI") );
123  
124 0 $result =~ /(\D+\s)(\D+)/;
125  
126 0 return $2;
127  
128 }
129  
130 sub set_bright {
131 0 ▶ my $self = shift;
Subroutine set_bright: not called CC=11 SCAR=48.8
Pod undocumented
132  
133 # read from cache or from device?
134 0 my ( $bright1, $bright2, $tail )
135 = $self->_check_args( \@_, [ 'bright1', 'bright2' ] );
136  
137 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($bright1 ne "ALL" || $bright1 ne "C" || $bright1 ne "LOS" || $bright1 ne "OT" and $bright2 < 0 || $bright2 > 9) 0 0 0
Condition0%0/15
$bright1 ne "ALL" || $bright1 ne "C" || $bright1 ne "LOS" || $bright1 ne "OT" and $bright2 < 0 || $bright2 > 9
!ll&&!rl&&r
000
$bright1 ne "ALL" or $bright1 ne "C" or $bright1 ne "LOS" or $bright1 ne "OT"
l!l&&r!l&&!r
000
$bright1 ne "ALL" or $bright1 ne "C" or $bright1 ne "LOS"
l!l&&r!l&&!r
000
$bright1 ne "ALL" or $bright1 ne "C"
l!l&&r!l&&!r
000
$bright2 < 0 or $bright2 > 9
l!l&&r!l&&!r
000
MC/DC0%0/6
$bright1 ne "ALL" || $bright1 ne "C" || $bright1 ne "LOS" || $bright1 ne "OT" and $bright2 < 0 || $bright2 > 9
$bright1 ne "ALL" $bright1 ne "C" $bright1 ne "LOS" $bright1 ne "OT" $bright2 < 0 $bright2 > 9
Truth table0%0/13
A or B or C or D and E or F
A= $bright1 ne "ALL"B= $bright1 ne "C"C= $bright1 ne "LOS"D= $bright1 ne "OT"E= $bright2 < 0F= $bright2 > 9
ABCDEFresult
0000XX0
1XXX000
01XX000
001X000
0001000
1XXX1X1
1XXX011
01XX1X1
01XX011
001X1X1
001X011
00011X1
0001011
138 (
139 $bright1 ne 'ALL'
140 or $bright1 ne 'C'
141 or $bright1 ne 'LOS'
142 or $bright1 ne 'OT'
143 )
144 and ( $bright2 < 0 or $bright2 > 9 )
145 ) {
146 0 Lab::Exception::CorruptParameter->throw(
147 error => "bad brightness-parameter!\n" );
148 }
149 0 ▶ if ( $bright1 eq 'ALL' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bright1 eq "ALL") 0 0 0
150 0 $self->write( sprintf( "BR %s %d", $bright1, $bright2 ), $tail );
151 }
152 0 ▶ if ( $bright1 eq 'C' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bright1 eq "C") 0 0 0
153 0 $self->write( sprintf( "BR %s %d", $bright1, $bright2 ), $tail );
154 }
155 0 ▶ if ( $bright1 eq 'LOS' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bright1 eq "LOS") 0 0 0
156 0 $self->write( sprintf( "BR %s %d", $bright1, $bright2 ), $tail );
157 }
158 0 ▶ if ( $bright1 eq 'OT' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bright1 eq "OT") 0 0 0
159 0 $self->write( sprintf( "BR %s %d", $bright1, $bright2 ), $tail );
160 }
161  
162 }
163  
164 sub get_bright {
165 0 ▶ my $self = shift;
Subroutine get_bright: not called CC=1 SCAR=6.9
Pod undocumented
166  
167 0 my $result = $self->query( sprintf("SH BR") );
168  
169 0 $result =~ /(\D+\s)(\D\=\d\s\D\=\d\s\D\=\d)/;
170  
171 0 return $2;
172  
173 }
174  
175 sub set_cable {
176 0 ▶ my $self = shift;
Subroutine set_cable: not called CC=2 SCAR=17.9
Pod undocumented
177  
178 # read from cache or from device?
179 0 my ( $cab1, $cab2, $tail )
180 = $self->_check_args( \@_, [ 'cab1', 'cab2' ] );
181  
182 0 ▶ if ( not $cab1 =~ m/L|RES|I|C/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $cab1 =~ /L|RES|I|C/u) { } 0 0 0
183 0 Lab::Exception::CorruptParameter->throw(
184 error => "bad cable-parameter!\n" );
185 }
186 else {
187 0 $self->write( sprintf( "CAB %s %d", $cab1, $cab2 ), $tail );
188 }
189  
190 }
191  
192 sub get_cable {
193 0 ▶ my $self = shift;
Subroutine get_cable: not called CC=2 SCAR=17.9
Pod undocumented
194  
195 0 my $result = $self->write( sprintf("SH CAB") );
196  
197 0 my @results;
198  
199 0 ▶ for ( my $i = 0; $i < 4; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 4) 0 0 0
200 0 my $result = $self->read();
201 0 push( @results, $result );
202 }
203  
204 0 print " @results ";
205  
206 0 return @results;
207  
208 }
209  
210 # set number of measurements for continuous-mode
211 sub set_cont {
212 0 ▶ my $self = shift;
Subroutine set_cont: not called CC=2 SCAR=17.9
Pod undocumented
213  
214 # read from cache or from device?
215 0 my ( $cont, $tail ) = $self->_check_args( \@_, ['cont'] );
216  
217 0 ▶ if ( $cont > 10 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont > 10) { } 0 0 0
218 0 Lab::Exception::CorruptParameter->throw(
219 error => "number of measurements higher than 10!\n" );
220 }
221 else {
222 0 $self->write( sprintf( "CO TO %d", $cont ), $tail );
223 }
224 }
225  
226 # get number of measurements for continuous-mode
227 sub get_cont {
228 0 ▶ my $self = shift;
Subroutine get_cont: not called CC=1 SCAR=6.9
Pod undocumented
229  
230 0 my $result = $self->query( sprintf("SH CO TO") );
231  
232 0 $result =~ /(\D+)(\D+\=)(\d+)/;
233  
234 0 return $result;
235  
236 }
237  
238 # start continuous-mode
239 sub cont {
240 0 ▶ my $self = shift;
Subroutine cont: not called CC=1 SCAR=6.9
Pod undocumented
241  
242 0 $self->write("CO");
243  
244 }
245  
246 sub get_single {
247 0 ▶ my $self = shift;
Subroutine get_single: not called CC=6 SCAR=37.4
Pod undocumented
248  
249 # read from cache or from device?
250 0 my ($tail) = $self->_check_args( \@_ );
251  
252 0 my $average = $self->get_aver( { read_mode => "cache" } );
253 0 my $frequency = $self->get_frq( { read_mode => "cache" } );
254  
255 0 my $time_table_highf = {
256 0 => [ 0.28, 80 ],
257 1 => [ 0.29, 110 ],
258 2 => [ 0.30, 150 ],
259 3 => [ 0.33, 200 ],
260 4 => [ 0.37, 260 ],
261 5 => [ 0.44, 350 ],
262 6 => [ 0.58, 520 ],
263 7 => [ 3.2, 3200 ],
264 8 => [ 4.8, 5200 ],
265 9 => [ 7.2, 8800 ],
266 10 => [ 12.0, 16000 ],
267 11 => [ 20.0, 28000 ],
268 12 => [ 36.0, 56000 ],
269 13 => [ 68.0, 108000 ],
270 14 => [ 140.0, 220000 ],
271 15 => [ 280.0, 480000 ],
272  
273 };
274  
275 0 my $timeout = @{ $time_table_highf->{$average} }[0]
276 0 + @{ $time_table_highf->{$average} }[1] / $frequency;
277  
278 0 ▶ if ( not defined $tail->{timeout} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tail->{"timeout"}) 0 0 0
279 0 $tail->{timeout} = 100;
280 }
281  
282 0 my $result = $self->request( sprintf("SI"), $tail );
283 0 my $values;
284 0 ▶ while ( $result =~ /([A-Z])=\s(\d+\.\d+)/g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ /([A-Z])=\s(\d+\.\d+)/gu) 0 0 0
285 0 $values->{$1} = $2;
286 }
287 0 $values->{E} = 00;
288 0 ▶ if ( $result =~ /^(\d+)/ and $result != /00/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ /^(\d+)/u and $result != /00/u) 0 0 0
Condition0%0/3
$result =~ /^(\d+)/u and $result != /00/u
!ll&&!rl&&r
000
MC/DC0%0/2
$result =~ /^(\d+)/u and $result != /00/u
$result =~ /^(\d+)/u $result != /00/u
Truth table0%0/3
A and B
A= $result =~ /^(\d+)/uB= $result != /00/u
ABresult
0X0
100
111
289 0 $values->{E} = $1;
290 print new Lab::Exception::Warning(
291 error => "Error in get_single. Errorcode = "
292 . $values->{E}
293 0 . "\n" );
294 }
295  
296 0 ▶ if ( wantarray() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
297 return (
298 $values->{C} * 1e-12,
299 $values->{L} * 1e-9,
300 $values->{V}, $values->{S}, $values->{E}
301 0 );
302 }
303 else {
304 0 return $values->{C} * 1e-12;
305 }
306  
307 }
308  
309 sub get_value {
310 0 ▶ my $self = shift;
Subroutine get_value: not called CC=1 SCAR=6.9
Pod undocumented
311  
312 0 return $self->get_single(@_);
313 }
314  
315 sub set_wait {
316 0 ▶ my $self = shift;
Subroutine set_wait: not called CC=1 SCAR=6.9
Pod undocumented
317  
318 # read from cache or from device?
319 0 my ( $wait, $tail ) = $self->_check_args( \@_, ['wait'] );
320  
321 0 $self->write( sprintf( "WAIT DELAY %d", $wait ), $tail );
322  
323 }
324  
325 sub reset {
326 0 ▶ my $self = shift;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
327  
328 0 $self->write("*RST");
329  
330 }
331  
332 # fetch-function
333 sub get_last {
334 0 ▶ my $self = shift;
Subroutine get_last: not called CC=1 SCAR=6.9
Pod undocumented
335  
336 0 $self->write("FE");
337  
338 }
339  
340 # controls which fields are sent to GPIB port
341 sub set_field {
342 0 ▶ my $self = shift;
Subroutine set_field: not called CC=1 SCAR=6.9
Pod undocumented
343  
344 # read from cache or from device?
345 0 my ( $fi1, $fi2, $fi3, $fi4, $fi5, $fi6, $tail ) = $self->_check_args(
346 \@_,
347 [ 'fi1', 'fi2', 'fi3', 'fi4', 'fi5', 'fi6' ]
348 );
349  
350 0 $self->write(
351 sprintf(
352 "FIELD %s,%s,%d,%d,%s,%s", $fi1, $fi2, $fi3, $fi4, $fi5, $fi6
353 ),
354 $tail
355 );
356  
357 }
358  
359 sub get_field {
360 0 ▶ my $self = shift;
Subroutine get_field: not called CC=1 SCAR=6.9
Pod undocumented
361  
362 0 $self->write("SH FI");
363  
364 }
365  
366 sub set_gpib {
367 0 ▶ my $self = shift;
Subroutine set_gpib: not called CC=1 SCAR=6.9
Pod undocumented
368  
369 # read from cache or from device?
370 0 my ( $gp1, $gp2, $gp3, $gp4, $gp5, $tail )
371 = $self->_check_args( \@_, [ 'gp1', 'gp2', 'gp3', 'gp4', 'gp5' ] );
372  
373 0 $self->write(
374 sprintf( "GP %d,%d,%s,%s,%s", $gp1, $gp2, $gp3, $gp4, $gp5 ),
375 $tail
376 );
377  
378 }
379  
380 sub get_gpib {
381 0 ▶ my $self = shift;
Subroutine get_gpib: not called CC=1 SCAR=6.9
Pod undocumented
382  
383 0 $self->write("SH GP");
384  
385 }
386  
387 # stops remote mode (switches to local mode)
388 sub go_to_local {
389 0 ▶ my $self = shift;
Subroutine go_to_local: not called CC=1 SCAR=6.9
Pod undocumented
390  
391 0 $self->write("LOC");
392  
393 }
394  
395 sub set_date {
396 0 ▶ my $self = shift;
Subroutine set_date: not called CC=1 SCAR=6.9
Pod undocumented
397  
398 # read from cache or from device?
399 0 my ( $yr, $mo, $day, $tail )
400 = $self->_check_args( \@_, [ 'yr', 'mo', 'day' ] );
401  
402 0 $self->write( sprintf( "STO %d,%d,%d", $yr, $mo, $day ), $tail );
403  
404 }
405  
406 sub get_date {
407 0 ▶ my $self = shift;
Subroutine get_date: not called CC=1 SCAR=6.9
Pod undocumented
408  
409 0 $self->write("SH DATE");
410  
411 }
412  
413 sub set_time {
414 0 ▶ my $self = shift;
Subroutine set_time: not called CC=1 SCAR=6.9
Pod undocumented
415  
416 # read from cache or from device?
417 0 my ( $hr, $min, $sec, $tail )
418 = $self->_check_args( \@_, [ 'hr', 'min', 'sec' ] );
419  
420 0 $self->write( sprintf( "STO %d,%d,%d", $hr, $min, $sec ), $tail );
421  
422 }
423  
424 sub get_time {
425 0 ▶ my $self = shift;
Subroutine get_time: not called CC=1 SCAR=6.9
Pod undocumented
426  
427 0 $self->write("SH TIME");
428  
429 }
430  
431 sub set_units {
432 0 ▶ my $self = shift;
Subroutine set_units: not called CC=2 SCAR=17.9
Pod undocumented
433  
434 # read from cache or from device?
435 0 my ( $units, $tail ) = $self->_check_args( \@_, ['units'] );
436  
437 0 ▶ if ( not $units =~ m/NS|DS|KO|GO|JP/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $units =~ /NS|DS|KO|GO|JP/u) { } 0 0 0
438 0 Lab::Exception::CorruptParameter->throw(
439 error => "bad units-parameter!\n" );
440 }
441 else {
442 0 $self->write( sprintf( "UN %s", $units ), $tail );
443 }
444  
445 }
446  
447 sub set_volt {
448 0 ▶ my $self = shift;
Subroutine set_volt: not called CC=1 SCAR=6.9
Pod undocumented
449  
450 # read from cache or from device?
451 0 my ( $volt, $tail ) = $self->_check_args( \@_, ['volt'] );
452  
453 0 $self->write( sprintf( "V %2.2f", $volt ), $tail );
454  
455 }
456  
457 sub get_volt {
458 0 ▶ my $self = shift;
Subroutine get_volt: not called CC=1 SCAR=6.9
Pod undocumented
459  
460 0 my $result = $self->query( sprintf("SH V") );
461  
462 0 $result =~ /(\D+)(\d+\.\d+)(\D+)/;
463  
464 0 return $2;
465  
466 }
467  
468 #sub sample_select {} # only in conjunction with the sample switch port
469  
470 1 1;
471  
472 __END__
473  
474 =pod
475  
476 =encoding UTF-8
477  
478 =head1 NAME
479  
480 Lab::Instrument::AH2700A - Andeen-Hagerling AH2700A ultra-precision capacitance bridge
481  
482 =head1 VERSION
483  
484 version 3.881
485  
486 =head1 COPYRIGHT AND LICENSE
487  
488 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
489  
490 Copyright 2013 Christian Butschkow
491 2016 Andreas K. Huettel, Simon Reinhardt
492 2017 Andreas K. Huettel
493 2020 Andreas K. Huettel
494  
495  
496 This is free software; you can redistribute it and/or modify it under
497 the same terms as the Perl 5 programming language system itself.
498  
499 =cut
« Moose/Instrument/Cache.pm ↑ Summary Moose/Instrument/Lakeshore372.pm »