Moose/Instrument/HP34410A.pm

filter: Statementstmt 80.7% 42 / 52 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 20.0% 1 / 5 totaltotal 72.0% 54 / 75 SCAR 11.4
CC
3
Cov
75%
allowed_ranges
12.0
set_range
2.0
get_cached_range
2.0
CRAP 3.1
« Moose/Instrument/OI_Common.pm ↑ Summary Moose/Instrument/KeysightN9310A.pm »
1 package Lab::Moose::Instrument::HP34410A;
2 2 $Lab::Moose::Instrument::HP34410A::VERSION = '3.881';
3 #ABSTRACT: HP 34410A digital multimeter.
4  
5 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Lab::Moose::Instrument qw/validated_getter validated_setter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 extends 'Lab::Moose::Instrument';
17  
18 2 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 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
30 1 $self->clear();
31 1 $self->cls();
32 }
33  
34 around default_connection_options => sub {
35 1 ▶ my $orig = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
36 1 my $self = shift;
37 1 my $options = $self->$orig();
38 1 my $usb_opts = { vid => 0x03f0 }; # what is PID??
39  
40 1 $options->{USB} = $usb_opts;
41 1 $options->{'VISA::USB'} = $usb_opts;
42 1 $options->{'Socket'} = { port => 5025 };
43  
44 1 return $options;
45 2 };
46  
47  
48  
49 sub get_value {
50 1 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_value: called CC=1 SCAR=0.0
Pod documented
51 1 return $self->query( command => ':read?', %args );
52 }
53  
54 ### Required methods of AdjustRange role
55  
56 sub allowed_ranges {
57 0 ▶ my $self = shift;
Subroutine allowed_ranges: not called CC=3 SCAR=24.8
Pod undocumented
58 0 my $function = $self->cached_sense_function();
59 0 ▶ if ( $function eq 'VOLT' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($function eq 'VOLT') { } 0 0 0
elsif ($function eq 'CURR') { } 0 0 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 ▶ my $self = shift;
Subroutine set_range: not called CC=1 SCAR=6.9
Pod undocumented
72 0 return $self->sense_range(@_);
73 }
74  
75 sub get_cached_range {
76 0 ▶ my $self = shift;
Subroutine get_cached_range: not called CC=1 SCAR=6.9
Pod undocumented
77 0 return $self->cached_sense_range(@_);
78 }
79  
80 2 __PACKAGE__->meta()->make_immutable();
81  
82 2 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.881
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
« Moose/Instrument/OI_Common.pm ↑ Summary Moose/Instrument/KeysightN9310A.pm »