Moose/Instrument/KeysightE3633E.pm

filter: Statementstmt 53.1% 34 / 64 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.1% 8 / 19 Podpod 70.0% 7 / 10 totaltotal 52.6% 49 / 93 SCAR 1.0
CC
1
Cov
53%
__ANON__
2.0
BUILD
2.0
source_level_query
2.0
CRAP 1.1
« Moose/Instrument/HP33120A.pm ↑ Summary Moose/Instrument/HP83732A.pm »
1 package Lab::Moose::Instrument::KeysightE3633E;
2 1 $Lab::Moose::Instrument::KeysightE3633E::VERSION = '3.881';
3 #ABSTRACT: Keysight E3633E voltage/current source.
4  
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moose::Util::TypeConstraints qw(enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 use Lab::Moose::Instrument
12 1 ▶ qw/validated_getter validated_setter setter_params/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 extends 'Lab::Moose::Instrument';
18  
19 around default_connection_options => sub {
20 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 my $self = shift;
22 0 my $options = $self->$orig();
23  
24 #my $usb_opts = { vid => 0x0b21, pid => 0x0039 };
25 #$options->{USB} = $usb_opts;
26 #$options->{'VISA::USB'} = $usb_opts;
27 0 return $options;
28 1 };
29  
30 1 has [qw/max_units_per_second max_units_per_step min_units max_units/] =>
31 ( is => 'ro', isa => 'Num', required => 1 );
32  
33 1 has source_level_timestamp => (
34 is => 'rw',
35 isa => 'Num',
36 init_arg => undef,
37 );
38  
39 1 has verbose => (
40 is => 'ro',
41 isa => 'Bool',
42 default => 1
43 );
44  
45 1 has mode => (
46 is => 'ro',
47 isa => enum( [ 'CURR', 'VOLT' ] ),
48 required => 1,
49 );
50  
51 sub BUILD {
52 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
53 0 $self->clear();
54 0 $self->cls();
55 }
56  
57  
58  
59 1 cache source_level => ( getter => 'source_level_query' );
60  
61 sub source_level_query {
62 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine source_level_query: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $mode = $self->mode();
64  
65 0 return $self->cached_source_level(
66 $self->query( command => "$mode?", %args ) );
67 }
68  
69 sub source_level {
70 0 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine source_level: not called CC=1 SCAR=6.9
Pod undocumented
71 \@_,
72 value => { isa => 'Num' }
73 );
74 0 my $mode = $self->mode();
75 0 $self->write(
76 command => sprintf( "$mode %.15g", $value ),
77 %args
78 );
79 0 $self->cached_source_level($value);
80 }
81  
82  
83 sub set_level {
84 0 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine set_level: not called CC=1 SCAR=6.9
Pod documented
85 \@_,
86 value => { isa => 'Num' },
87 );
88  
89 0 return $self->linear_step_sweep(
90 to => $value, verbose => $self->verbose,
91 %args
92 );
93 }
94  
95 #
96 # Aliases for Lab::XPRESS::Sweep API
97 #
98  
99  
100 sub cached_level {
101 0 ▶ my $self = shift;
Subroutine cached_level: not called CC=1 SCAR=6.9
Pod documented
102 0 return $self->cached_source_level(@_);
103 }
104  
105  
106 sub get_level {
107 0 ▶ my $self = shift;
Subroutine get_level: not called CC=1 SCAR=6.9
Pod documented
108 0 return $self->source_level_query(@_);
109 }
110  
111  
112 sub get_voltage {
113 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_voltage: not called CC=1 SCAR=6.9
Pod documented
114 0 return $self->query( command => "VOLT?", %args );
115 }
116  
117  
118 sub get_current {
119 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_current: not called CC=1 SCAR=6.9
Pod documented
120 0 return $self->query( command => "CURR?", %args );
121 }
122  
123  
124 sub set_voltage {
125 0 ▶ my $self = shift;
Subroutine set_voltage: not called CC=1 SCAR=6.9
Pod documented
126 0 my $value = shift;
127 0 return $self->set_level( value => $value );
128 }
129  
130  
131 sub sweep_to_level {
132 0 ▶ my $self = shift;
Subroutine sweep_to_level: not called CC=1 SCAR=6.9
Pod documented
133 0 my $target = shift;
134 0 return $self->set_level( value => $target );
135 }
136  
137 1 with qw(
138 Lab::Moose::Instrument::Common
139 Lab::Moose::Instrument::LinearStepSweep
140 );
141  
142 1 __PACKAGE__->meta()->make_immutable();
143  
144 1 1;
145  
146 __END__
147  
148 =pod
149  
150 =encoding UTF-8
151  
152 =head1 NAME
153  
154 Lab::Moose::Instrument::KeysightE3633E - Keysight E3633E voltage/current source.
155  
156 =head1 VERSION
157  
158 version 3.881
159  
160 =head1 SYNOPSIS
161  
162 use Lab::Moose;
163  
164 my $source = instrument(
165 type => 'KeysightE3633E',
166 connection_type => 'LinuxGPIB',
167 connection_options => {gpib_address => 15},
168 # mandatory protection settings
169 max_units_per_step => 0.001, # max step is 1mV/1mA
170 max_units_per_second => 0.01,
171 min_units => -10,
172 max_units => 10,
173  
174 mode => 'CURR', # or 'VOLT'
175  
176 );
177  
178 # The source is either in 'CURR' or 'VOLT' mode.
179  
180 # Step-sweep to new level.
181 # Stepsize and speed is given by (max|min)_units* settings.
182 $source->set_level(value => 9);
183  
184 # Get level from device cache (without sending a query to the
185 # instrument):
186 my $level = $source->cached_level();
187  
188 # Measure voltage and current (independent of used mode).
189 my $current = $source->get_current();
190 my $voltage = $source->get_voltage();
191  
192 =head1 METHODS
193  
194 Used roles:
195  
196 =over
197  
198 =item L<Lab::Moose::Instrument::Common>
199  
200 =item L<Lab::Moose::Instrument::LinearStepSweep>
201  
202 =back
203  
204 =head2 source_range/source_range_query
205  
206 Set/Get the output source range.
207  
208 =head2 set_level
209  
210 $source->set_level(value => $new_level);
211  
212 Go to new level. Sweep with multiple steps if the distance between current and
213 new level is larger than C<max_units_per_step>.
214  
215 =head2 cached_level
216  
217 my $current_level = $source->cached_level();
218  
219 Get current value from device cache.
220  
221 =head2 get_level
222  
223 my $current_level = $source->get_level();
224  
225 Query current level.
226  
227 =head2 get_voltage
228  
229 my $voltage = $source->get_voltage();
230  
231 =head2 get_current
232  
233 my $current = $source->get_current();
234  
235 =head2 set_voltage
236  
237 $source->set_voltage($value);
238  
239 For XPRESS voltage sweep. Equivalent to C<< set_level(value => $value) >>.
240  
241 =head2 sweep_to_level
242  
243 Use rate limits (max_units_per_second, max_units_per_step) for sweep steps.
244  
245 =head1 COPYRIGHT AND LICENSE
246  
247 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
248  
249 Copyright 2019 Simon Reinhardt
250 2020 Andreas K. Huettel
251  
252  
253 This is free software; you can redistribute it and/or modify it under
254 the same terms as the Perl 5 programming language system itself.
255  
256 =cut
« Moose/Instrument/HP33120A.pm ↑ Summary Moose/Instrument/HP83732A.pm »