File Coverage

blib/lib/Lab/Moose/Instrument/HP34410A.pm
Criterion Covered Total %
statement 28 38 73.6
branch 0 4 0.0
condition n/a
subroutine 10 13 76.9
pod 1 5 20.0
total 39 60 65.0


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::HP34410A;
2             $Lab::Moose::Instrument::HP34410A::VERSION = '3.880';
3             #ABSTRACT: HP 34410A digital multimeter.
4              
5 2     2   3324 use v5.20;
  2         10  
6              
7              
8 2     2   12 use Moose;
  2         5  
  2         18  
9 2     2   16676 use Moose::Util::TypeConstraints;
  2         6  
  2         26  
10 2     2   4939 use MooseX::Params::Validate;
  2         8  
  2         21  
11 2     2   1077 use Lab::Moose::Instrument qw/validated_getter validated_setter/;
  2         12  
  2         149  
12 2     2   15 use Carp;
  2         3  
  2         141  
13 2     2   547 use Lab::Moose::Instrument::Cache;
  2         5  
  2         14  
14 2     2   1376 use namespace::autoclean;
  2         5  
  2         15  
15              
16             extends 'Lab::Moose::Instrument';
17              
18             with qw(
19             Lab::Moose::Instrument::Common
20             Lab::Moose::Instrument::SCPI::Sense::Function
21             Lab::Moose::Instrument::SCPI::Sense::Impedance
22             Lab::Moose::Instrument::SCPI::Sense::NPLC
23             Lab::Moose::Instrument::SCPI::Sense::Null
24             Lab::Moose::Instrument::SCPI::Sense::Range
25             Lab::Moose::Instrument::AdjustRange
26             );
27              
28             sub BUILD {
29 1     1 0 2 my $self = shift;
30 1         28 $self->clear();
31 1         27 $self->cls();
32             }
33              
34             around default_connection_options => sub {
35             my $orig = shift;
36             my $self = shift;
37             my $options = $self->$orig();
38             my $usb_opts = { vid => 0x03f0 }; # what is PID??
39              
40             $options->{USB} = $usb_opts;
41             $options->{'VISA::USB'} = $usb_opts;
42             $options->{'Socket'} = { port => 5025 };
43              
44             return $options;
45             };
46              
47              
48              
49             sub get_value {
50 1     1 1 12 my ( $self, %args ) = validated_getter( \@_ );
51 1         494 return $self->query( command => ':read?', %args );
52             }
53              
54             ### Required methods of AdjustRange role
55              
56             sub allowed_ranges {
57 0     0 0   my $self = shift;
58 0           my $function = $self->cached_sense_function();
59 0 0         if ( $function eq 'VOLT' ) {
    0          
60 0           return [ 0.1, 1, 10, 100, 1000 ];
61             }
62             elsif ( $function eq 'CURR' ) {
63 0           return [ 1e-4, 1e-3, 1e-2, 1e-1, 1, 3 ];
64             }
65             else {
66 0           croak "function $function not yet supported";
67             }
68             }
69              
70             sub set_range {
71 0     0 0   my $self = shift;
72 0           return $self->sense_range(@_);
73             }
74              
75             sub get_cached_range {
76 0     0 0   my $self = shift;
77 0           return $self->cached_sense_range(@_);
78             }
79              
80             __PACKAGE__->meta()->make_immutable();
81              
82             1;
83              
84             __END__
85              
86             =pod
87              
88             =encoding UTF-8
89              
90             =head1 NAME
91              
92             Lab::Moose::Instrument::HP34410A - HP 34410A digital multimeter.
93              
94             =head1 VERSION
95              
96             version 3.880
97              
98             =head1 SYNOPSIS
99              
100             my $dmm = instrument(
101             type => 'HP34410A',
102             connection_type => 'VXI11',
103             connection_options => {host => '192.168.3.27'},
104             );
105              
106             $dmm->sense_range(value => 10);
107             $dmm->sense_nplc(value => 2);
108            
109             my $voltage = $dmm->get_value();
110              
111             =head1 METHODS
112              
113             Used roles:
114              
115             =over
116              
117             =item L<Lab::Moose::Instrument::SCPI::Sense::Function>
118              
119             =item L<Lab::Moose::Instrument::SCPI::Sense::Impedance>
120              
121             =item L<Lab::Moose::Instrument::SCPI::Sense::NPLC>
122              
123             =item L<Lab::Moose::Instrument::SCPI::Sense::Null>
124              
125             =item L<Lab::Moose::Instrument::SCPI::Sense::Range>
126              
127             =back
128              
129             =head2 get_value
130              
131             my $voltage = $dmm->get_value();
132              
133             Perform voltage/current measurement.
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
138              
139             Copyright 2017-2018 Simon Reinhardt
140             2020 Andreas K. Huettel
141              
142              
143             This is free software; you can redistribute it and/or modify it under
144             the same terms as the Perl 5 programming language system itself.
145              
146             =cut