File Coverage

blib/lib/Lab/Moose/Instrument/HP3458A.pm
Criterion Covered Total %
statement 23 95 24.2
branch 0 2 0.0
condition n/a
subroutine 8 38 21.0
pod 15 30 50.0
total 46 165 27.8


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::HP3458A;
2             $Lab::Moose::Instrument::HP3458A::VERSION = '3.881';
3             #ABSTRACT: HP 3458A digital multimeter
4              
5 1     1   2294 use v5.20;
  1         3  
6              
7 1     1   6 use Moose;
  1         3  
  1         11  
8 1     1   7671 use Moose::Util::TypeConstraints qw/enum/;
  1         6  
  1         17  
9 1     1   555 use MooseX::Params::Validate;
  1         2  
  1         11  
10 1         77 use Lab::Moose::Instrument qw/
11 1     1   549 validated_getter validated_setter setter_params /;
  1         3  
12 1     1   7 use Lab::Moose::Instrument::Cache;
  1         2  
  1         10  
13 1     1   692 use Carp;
  1         3  
  1         73  
14 1     1   8 use namespace::autoclean;
  1         3  
  1         9  
15              
16             extends 'Lab::Moose::Instrument';
17              
18             with qw(
19             Lab::Moose::Instrument::Common
20             );
21              
22             sub BUILD {
23 0     0 0   my $self = shift;
24 0           $self->clear();
25              
26             # Set EOI after each answer.
27 0           $self->set_end( value => 'ALWAYS' );
28             }
29              
30              
31             sub get_value {
32 0     0 1   my ( $self, %args ) = validated_hash(
33             \@_,
34             setter_params(),
35             );
36 0           return $self->read(%args);
37             }
38              
39              
40             sub get_nplc {
41 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
42 0           return $self->query( command => "NPLC?", %args );
43             }
44              
45             sub set_nplc {
46 0     0 1   my ( $self, $value, %args ) = validated_setter(
47             \@_,
48             value => { isa => 'Num' }
49             );
50 0           $self->write( command => "NPLC $value", %args );
51             }
52              
53              
54             sub get_nrdgs {
55 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
56 0           my $result = $self->query( command => "NRDGS?", %args );
57 0           return split( /,/, $result );
58             }
59              
60             sub set_nrdgs {
61 0     0 1   my ( $self, %args ) = validated_getter(
62             \@_,
63             readings => { isa => 'Int' },
64             sample_event =>
65             { isa => enum( [qw/AUTO EXT HOLD LEVEL LINE SGL SYN TIMER/] ) },
66             );
67 0           my $readings = delete $args{readings};
68 0           my $sample_event = delete $args{sample_event};
69 0           $self->write( command => "NRDGS $readings, $sample_event", %args );
70             }
71              
72             sub get_tarm_event {
73 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
74 0           return $self->query( command => "TARM?", %args );
75             }
76              
77             sub set_tarm_event {
78 0     0 0   my ( $self, $value, %args ) = validated_setter(
79             \@_,
80             value => { isa => enum( [qw/AUTO EXT SGL HOLD SYN/] ) },
81             );
82 0           $self->write( command => "TARM $value", %args );
83             }
84              
85              
86             sub get_trig_event {
87 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
88 0           return $self->query( command => "TRIG?", %args );
89             }
90              
91             sub set_trig_event {
92 0     0 1   my ( $self, $value, %args ) = validated_setter(
93             \@_,
94             value => { isa => enum( [qw/AUTO EXT SGL HOLD SYN LEVEL LINE/] ) },
95             );
96 0           $self->write( command => "TRIG $value", %args );
97             }
98              
99              
100             sub get_end {
101 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
102 0           return $self->query( command => "END?", %args );
103             }
104              
105             sub set_end {
106 0     0 1   my ( $self, $value, %args ) = validated_setter(
107             \@_,
108             value => { isa => enum( [qw/OFF ON ALWAYS/] ) }
109             );
110 0           $self->write( command => "END $value" );
111             }
112              
113              
114             sub get_range {
115 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
116 0           return $self->query( command => "RANGE?", %args );
117             }
118              
119             sub set_range {
120 0     0 1   my ( $self, $value, %args ) = validated_setter(
121             \@_,
122             value => { isa => 'Lab::Moose::PosNum' }
123             );
124 0           $self->write( command => "RANGE $value" );
125             }
126              
127              
128             sub get_auto_range {
129 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
130 0           return $self->query( command => "ARANGE?", %args );
131             }
132              
133             sub set_auto_range {
134 0     0 1   my ( $self, $value, %args ) = validated_setter(
135             \@_,
136             value => { isa => enum( [qw/ON OFF ONCE/] ) }
137             );
138 0           $self->write( command => "ARANGE $value", %args );
139             }
140              
141             sub get_output_format {
142 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
143 0           return $self->query( command => 'OFORMAT?', %args );
144             }
145              
146             sub set_output_format {
147 0     0 0   my ( $self, $value, %args ) = validated_setter(
148             \@_,
149             value => { isa => enum( [qw/ASCII SINT DINT SREAL DREAL/] ) },
150             );
151 0           $self->write( command => "OFORMAT $value", %args );
152             }
153              
154             sub get_memory_format {
155 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
156 0           return $self->query( command => 'MFORMAT?', %args );
157             }
158              
159             sub set_memory_format {
160 0     0 0   my ( $self, $value, %args ) = validated_setter(
161             \@_,
162             value => { isa => enum( [qw/ASCII SINT DINT SREAL DREAL/] ) },
163             );
164 0           $self->write( command => "MFORMAT $value", %args );
165             }
166              
167             sub get_memory {
168 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
169 0           return $self->query( command => 'MEM?', %args );
170             }
171              
172             sub set_memory {
173 0     0 0   my ( $self, $value, %args ) = validated_setter(
174             \@_,
175             value => { isa => enum( [qw/OFF LIFO FIFO CONT/] ) },
176             );
177 0           $self->write( command => "MEM $value", %args );
178             }
179              
180             cache iscale => ( getter => 'get_iscale' );
181              
182             sub get_iscale {
183 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
184 0           return $self->query( command => 'ISCALE?', %args );
185             }
186              
187             sub get_auto_zero {
188 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
189 0           return $self->query( command => 'AZERO?', %args );
190             }
191              
192             sub set_auto_zero {
193 0     0 0   my ( $self, $value, %args ) = validated_setter(
194             \@_,
195             value => { isa => enum( [qw/ON OFF ONCE/] ) },
196             );
197 0           $self->write( command => "AZERO $value", %args );
198             }
199              
200             sub get_disp {
201 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
202 0           return $self->query( command => 'DISP?', %args );
203             }
204              
205             sub set_disp {
206 0     0 0   my ( $self, $value, %args ) = validated_setter(
207             \@_,
208             value => { isa => enum( [qw/OFF ON MSG CLR/] ) },
209             );
210 0           $self->write( command => "DISP $value", %args );
211             }
212              
213             sub set_math_off {
214 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
215 0           $self->write( command => 'MATH OFF', %args );
216             }
217              
218              
219             sub get_mem_size {
220 0     0 1   my ( $self, %args ) = validated_getter( \@_ );
221 0           my $rv = $self->query( command => 'MSIZE?', %args );
222 0           return split( /,/, $rv );
223             }
224              
225              
226             sub set_high_speed_mode {
227 0     0 1   my ( $self, %args ) = validated_getter(
228             \@_,
229             format => { isa => enum( [qw/SINT DINT/] ) },
230             );
231 0           my $format = delete $args{format};
232              
233 0           $self->set_output_format( value => $format );
234 0           $self->set_memory_format( value => $format );
235              
236 0           $self->set_auto_zero( value => 'OFF' );
237 0           $self->set_disp( value => 'OFF' );
238 0           $self->set_math_off();
239              
240 0 0         if ( $self->get_auto_range() ) {
241 0           croak("Autorange mode is on, cannot set high-speed mode");
242             }
243             }
244              
245              
246             __PACKAGE__->meta()->make_immutable();
247              
248             1;
249              
250             __END__
251              
252             =pod
253              
254             =encoding UTF-8
255              
256             =head1 NAME
257              
258             Lab::Moose::Instrument::HP3458A - HP 3458A digital multimeter
259              
260             =head1 VERSION
261              
262             version 3.881
263              
264             =head1 SYNOPSIS
265              
266             use Lab::Moose;
267              
268             my $dmm = instrument(
269             type => 'HP3458A',
270             connection_type => 'LinuxGPIB',
271             connection_options => {
272             gpib_address => 12,
273             timeout => 10, # if not given, use connection's default timeout
274             }
275             );
276              
277             $dmm->set_sample_event(value => 'SYN');
278             $dmm->set_nplc(value => 2);
279            
280             my $value = $dmm->get_value();
281              
282             =head1 METHODS
283              
284             =head2 get_value
285              
286             my $value = $dmm->get_value();
287              
288             Read multimeter output value.
289              
290             =head2 get_nplc/set_nplc
291              
292             $dmm->set_nplc(value => 10);
293             $nplc = $dmm->get_nplc();
294              
295             Get/Set integration time in Number of Power Line Cycles. This also affects the resolution (bits/digits) of the readings:
296              
297             - 0.0001 NPLC: 4.5 digits, 16 bits, 83300 readings/s (OFORMAT SINT)
298             - 0.0006 NPLC: 5.5 digits, 18 bits, 41650 readings/s
299             - 0.01 NPLC: 6.5 digits, 21 bits, 4414 readings/s
300             - 0.1 NPLC: 6.5 digits, 21 bits, 493 readings/s
301             - 1 NPLC: 7.5 digits, 25 bits, 50 readings/s
302             - 10 NPLC: 8.5 digits, 28 bits, 5 readings/s
303              
304             All values for auto-zero disabled.
305              
306             =head2 get_nrdgs/set_nrdgs
307              
308             $dmm->set_nrdgs(readings => 2, sample_event => 'AUTO');
309             ($readings, $sample_event) = $dmm->get_nrdgs();
310              
311             Get/Set number of readings taken per trigger event and the sample event.
312              
313             =head2 get_trig_event/set_trig_event
314              
315             $dmm->set_trig_event(value => 'EXT');
316             $trig_event = $dmm->get_trig_event();
317              
318             Get/Set trigger event.
319              
320             =head2 get_end/set_end
321              
322             $dmm->set_end(value => 'ALWAYS');
323             $end = $dmm->get_end();
324              
325             Get/Set control of GPIB End Or Identify (EOI) function.
326             This driver sets this to 'ALWAYS' on startup.
327              
328             =head2 get_range/set_range
329              
330             $dmm->set_range(value => 100e-3); # select 100mV range (if in DCV mode)
331             $range = $dmm->get_range();
332              
333             Get/Set measurement range.
334              
335             =head2 get_auto_range/set_auto_range
336              
337             $dmm->set_auto_range(value => 'OFF');
338             $auto_range = $dmm->get_auto_range();
339              
340             Get/Set the status of the autorange function.
341             Possible values: C<OFF, ON, ONCE>.
342              
343             =head2 get_mem_size
344              
345             my ($msize, $unused) = $dmm->get_mem_size();
346              
347             =head2 set_high_speed_mode
348              
349             $dmm->set_high_speed_mode(format => 'DINT');
350              
351             C<format> can be 'SINT' or 'DINT'.
352              
353             Croak if autorange is enabled.
354              
355             =head2 Consumed Roles
356              
357             This driver consumes the following roles:
358              
359             =over
360              
361             =item L<Lab::Moose::Instrument::Common>
362              
363             =back
364              
365             =head1 COPYRIGHT AND LICENSE
366              
367             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
368              
369             Copyright 2017 Simon Reinhardt
370             2020 Andreas K. Huettel
371             2021 Simon Reinhardt
372             2022 Andreas K. Huettel, Simon Reinhardt
373              
374              
375             This is free software; you can redistribute it and/or modify it under
376             the same terms as the Perl 5 programming language system itself.
377              
378             =cut