Moose/Instrument/Keithley2450.pm

filter: Statementstmt 43.9% 29 / 66 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 43.7% 7 / 16 Podpod 87.5% 7 / 8 totaltotal 43.8% 43 / 98 CC 5 SCAR 15.4
CC
5
Cov
39%
source_limit
12.0
source_limit_query
12.0
__ANON__
2.0
CRAP 4.7
« Moose/Instrument/HPE4400B.pm ↑ Summary Moose/Instrument/Lakeshore372.pm »
1 package Lab::Moose::Instrument::Keithley2450;
2 1 $Lab::Moose::Instrument::Keithley2450::VERSION = '3.931';
3 #ABSTRACT: Keithley 2450 voltage/current sourcemeter.
4  
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 use Lab::Moose::Instrument
10 1 ▶ qw/validated_getter validated_setter setter_params/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 extends 'Lab::Moose::Instrument';
16  
17 0 ▶around default_connection_options => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 my $orig = shift;
19 0 my $self = shift;
20 0 my $options = $self->$orig();
21 0 my $usb_opts = { vid => 0x05e6, pid => 0x2450 }; # FIXME
22 0 $options->{USB} = $usb_opts;
23 0 $options->{'VISA::USB'} = $usb_opts;
24 0 return $options;
25 1 };
26  
27 1 has [qw/max_units_per_second max_units_per_step min_units max_units/] =>
28 ( is => 'ro', isa => 'Num', required => 1 );
29  
30 1 has source_level_timestamp => (
31 is => 'rw',
32 isa => 'Num',
33 init_arg => undef,
34 );
35  
36 1 has verbose => (
37 is => 'ro',
38 isa => 'Bool',
39 default => 1
40 );
41  
42 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my $self = shift;
44  
45 0 $self->clear();
46 0 $self->cls();
47 }
48  
49  
50  
51 0 ▶sub set_level {
Subroutine set_level: not called CC=1 SCAR=6.9
Pod documented
52 0 my ( $self, $value, %args ) = validated_setter(
53 \@_,
54 value => { isa => 'Num' },
55 );
56  
57 0 return $self->linear_step_sweep(
58 to => $value, verbose => $self->verbose,
59 %args
60 );
61 }
62  
63  
64 0 ▶sub get_value {
Subroutine get_value: not called CC=1 SCAR=6.9
Pod documented
65 0 my ( $self, %args ) = validated_getter( \@_ );
66 0 return $self->query( command => 'READ?', %args );
67 }
68  
69  
70 0 ▶sub source_limit {
Subroutine source_limit: not called CC=3 SCAR=24.8
Pod documented
71 0 my ( $self, $value, %args ) = validated_setter(
72 \@_,
73 value => { isa => 'Num' },
74 );
75 0 my $func = $self->cached_source_function();
76 0 my $lim_func;
77  
78 0 ▶ if ( $func eq 'VOLT' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($func eq 'VOLT') { } 0 0 0
elsif ($func eq 'CURR') { } 0 0 0
79 0 $lim_func = 'I';
80 }
81 elsif ( $func eq 'CURR' ) {
82 0 $lim_func = 'V';
83 }
84 else {
85 0 croak("unknown source function $func (must one of VOLT or CURR)");
86 }
87 0 $self->write( command => "SOUR:${func}:${lim_func}LIM $value", %args );
88 }
89  
90 0 ▶sub source_limit_query {
Subroutine source_limit_query: not called CC=3 SCAR=24.8
Pod documented
91 0 my ( $self, %args ) = validated_getter( \@_ );
92  
93 0 my $func = $self->cached_source_function();
94 0 my $lim_func;
95  
96 0 ▶ if ( $func eq 'VOLT' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($func eq 'VOLT') { } 0 0 0
elsif ($func eq 'CURR') { } 0 0 0
97 0 $lim_func = 'I';
98 }
99 elsif ( $func eq 'CURR' ) {
100 0 $lim_func = 'V';
101 }
102 else {
103 0 croak("unknown source function $func (must one of VOLT or CURR)");
104 }
105 0 return $self->query( command => "SOUR:${func}:${lim_func}LIM?", %args );
106 }
107  
108 #
109 # Aliases for Lab::XPRESS::Sweep API
110 #
111  
112  
113 0 ▶sub cached_level {
Subroutine cached_level: not called CC=1 SCAR=6.9
Pod documented
114 0 my $self = shift;
115 0 return $self->cached_source_level(@_);
116 }
117  
118  
119 0 ▶sub get_level {
Subroutine get_level: not called CC=1 SCAR=6.9
Pod documented
120 0 my $self = shift;
121 0 return $self->source_level_query(@_);
122 }
123  
124  
125 0 ▶sub set_voltage {
Subroutine set_voltage: not called CC=1 SCAR=6.9
Pod documented
126 0 my $self = shift;
127 0 my $value = shift;
128 0 return $self->set_level( value => $value );
129 }
130  
131 1 with qw(
132 Lab::Moose::Instrument::Common
133 Lab::Moose::Instrument::SCPI::Output::State
134 Lab::Moose::Instrument::SCPI::Sense::Function
135 Lab::Moose::Instrument::SCPI::Sense::Range
136 Lab::Moose::Instrument::SCPI::Sense::NPLC
137 Lab::Moose::Instrument::SCPI::Source::Function
138 Lab::Moose::Instrument::SCPI::Source::Level
139 Lab::Moose::Instrument::SCPI::Source::Range
140 Lab::Moose::Instrument::LinearStepSweep
141 );
142  
143 1 __PACKAGE__->meta()->make_immutable();
144  
145 1 1;
146  
147 __END__
« Moose/Instrument/HPE4400B.pm ↑ Summary Moose/Instrument/Lakeshore372.pm »