Moose/Instrument/Yokogawa7651.pm

filter: Statementstmt 56.8% 25 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 6 / 14 Podpod 62.5% 5 / 8 totaltotal 54.5% 36 / 66 SCAR 0.8
CC
1
Cov
57%
BUILD
2.0
source_level_query
2.0
source_level
2.0
CRAP 1.1
« Moose/Instrument/HP83732A.pm ↑ Summary Moose/Instrument/OI_ILM210.pm »
1 package Lab::Moose::Instrument::Yokogawa7651;
2 1 $Lab::Moose::Instrument::Yokogawa7651::VERSION = '3.881';
3 #ABSTRACT: Yokogawa7651 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 use Lab::Moose::Instrument
11 1 ▶ qw/validated_getter validated_setter setter_params/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 extends 'Lab::Moose::Instrument';
17  
18 1 has [
19 qw/
20 max_units_per_second
21 max_units_per_step
22 min_units
23 max_units
24 /
25 ] => ( is => 'ro', isa => 'Num', required => 1 );
26  
27 1 has source_level_timestamp => (
28 is => 'rw',
29 isa => 'Num',
30 init_arg => undef,
31 );
32  
33 sub BUILD {
34 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
35 }
36  
37  
38 1 cache source_level => ( getter => 'source_level_query' );
39  
40 sub source_level_query {
41 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine source_level_query: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 0 my $value = $self->query( command => "OD", %args );
44 # Typical result: NDCV+0.0000E-00
45  
46 # we need to drop the uppercase letters at the start
47 0 $value =~ s/^[A-Z]*//;
48  
49 0 return $self->cached_source_level($value);
50 }
51  
52 sub source_level {
53 0 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine source_level: not called CC=1 SCAR=6.9
Pod undocumented
54 \@_,
55 value => { isa => 'Num' }
56 );
57  
58 0 $self->write(
59  
60 # Trailing 'e' is trigger.
61 command => sprintf( "S%.10ge", $value ),
62 %args
63 );
64 0 $self->cached_source_level($value);
65 }
66  
67  
68 sub set_level {
69 0 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine set_level: not called CC=1 SCAR=6.9
Pod documented
70 \@_,
71 value => { isa => 'Num' },
72 );
73 0 return $self->linear_step_sweep( to => $value, %args );
74 }
75  
76 #
77 # Aliases for Lab::XPRESS::Sweep API
78 #
79  
80  
81 sub cached_level {
82 0 ▶ my $self = shift;
Subroutine cached_level: not called CC=1 SCAR=6.9
Pod documented
83 0 return $self->cached_source_level(@_);
84 }
85  
86  
87 sub get_level {
88 0 ▶ my $self = shift;
Subroutine get_level: not called CC=1 SCAR=6.9
Pod documented
89 0 return $self->source_level_query(@_);
90 }
91  
92  
93 sub set_voltage {
94 0 ▶ my $self = shift;
Subroutine set_voltage: not called CC=1 SCAR=6.9
Pod documented
95 0 my $value = shift;
96 0 return $self->set_level( value => $value );
97 }
98  
99  
100 sub sweep_to_level {
101 0 ▶ my $self = shift;
Subroutine sweep_to_level: not called CC=1 SCAR=6.9
Pod documented
102 0 return $self->set_voltage(@_);
103 }
104  
105 1 with qw(
106 Lab::Moose::Instrument::LinearStepSweep
107 );
108  
109 1 __PACKAGE__->meta()->make_immutable();
110  
111 1 1;
112  
113 __END__
114  
115 =pod
116  
117 =encoding UTF-8
118  
119 =head1 NAME
120  
121 Lab::Moose::Instrument::Yokogawa7651 - Yokogawa7651 voltage/current source.
122  
123 =head1 VERSION
124  
125 version 3.881
126  
127 =head1 SYNOPSIS
128  
129 use Lab::Moose;
130  
131 my $yoko = instrument(
132 type => 'Yokogawa7651',
133 connection_type => 'LinuxGPIB',
134 connection_options => {gpib_address => 15},
135 # mandatory protection settings
136 max_units_per_step => 0.001, # max step is 1mV/1mA
137 max_units_per_second => 0.01,
138 min_units => -10,
139 max_units => 10,
140 );
141  
142 # Step-sweep to new level.
143 # Stepsize and speed is given by (max|min)_units* settings.
144 $yoko->set_level(value => 9);
145  
146 # Get current level from device cache (without sending a query to the
147 # instrument):
148 my $level = $yoko->cached_level();
149  
150 =head1 METHODS
151  
152 Used roles:
153  
154 =over
155  
156 =item L<Lab::Moose::Instrument::LinearStepSweep>
157  
158 =back
159  
160 =head2 set_level
161  
162 $yoko->set_level(value => $new_level);
163  
164 Go to new level. Sweep with multiple steps if the distance between current and
165 new level is larger than C<max_units_per_step>.
166  
167 =head2 cached_level
168  
169 my $current_level = $yoko->cached_level();
170  
171 Get current value from device cache.
172  
173 =head2 get_level
174  
175 my $current_level = $yoko->get_level();
176  
177 Query current level.
178  
179 =head2 set_voltage
180  
181 $yoko->set_voltage($value);
182  
183 For XPRESS voltage sweep. Equivalent to C<< set_level(value => $value) >>.
184  
185 =head2 sweep_to_level
186  
187 $yoko->sweep_to_level($value);
188  
189 For XPRESS voltage sweep. Equivalent to C<set_voltage>.
190  
191 =head1 COPYRIGHT AND LICENSE
192  
193 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
194  
195 Copyright 2017 Simon Reinhardt
196 2020-2021 Andreas K. Huettel
197  
198  
199 This is free software; you can redistribute it and/or modify it under
200 the same terms as the Perl 5 programming language system itself.
201  
202 =cut
« Moose/Instrument/HP83732A.pm ↑ Summary Moose/Instrument/OI_ILM210.pm »