File Coverage

blib/lib/Lab/Moose/Instrument/Yokogawa7651.pm
Criterion Covered Total %
statement 17 36 47.2
branch n/a
condition n/a
subroutine 6 14 42.8
pod 5 8 62.5
total 28 58 48.2


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::Yokogawa7651;
2             $Lab::Moose::Instrument::Yokogawa7651::VERSION = '3.880';
3             #ABSTRACT: Yokogawa7651 voltage/current source.
4              
5 1     1   2065 use v5.20;
  1         5  
6              
7              
8 1     1   6 use Moose;
  1         3  
  1         8  
9 1     1   7019 use MooseX::Params::Validate;
  1         3  
  1         8  
10             use Lab::Moose::Instrument
11 1     1   532 qw/validated_getter validated_setter setter_params/;
  1         2  
  1         54  
12 1     1   7 use Lab::Moose::Instrument::Cache;
  1         2  
  1         10  
13              
14 1     1   714 use namespace::autoclean;
  1         2  
  1         6  
15              
16             extends 'Lab::Moose::Instrument';
17              
18             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             has source_level_timestamp => (
28             is => 'rw',
29             isa => 'Num',
30             init_arg => undef,
31             );
32              
33             sub BUILD {
34 0     0 0   my $self = shift;
35             }
36              
37              
38             cache source_level => ( getter => 'source_level_query' );
39              
40             sub source_level_query {
41 0     0 0   my ( $self, %args ) = validated_getter( \@_ );
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     0 0   my ( $self, $value, %args ) = validated_setter(
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     0 1   my ( $self, $value, %args ) = validated_setter(
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     0 1   my $self = shift;
83 0           return $self->cached_source_level(@_);
84             }
85              
86              
87             sub get_level {
88 0     0 1   my $self = shift;
89 0           return $self->source_level_query(@_);
90             }
91              
92              
93             sub set_voltage {
94 0     0 1   my $self = shift;
95 0           my $value = shift;
96 0           return $self->set_level( value => $value );
97             }
98              
99              
100             sub sweep_to_level {
101 0     0 1   my $self = shift;
102 0           return $self->set_voltage(@_);
103             }
104              
105             with qw(
106             Lab::Moose::Instrument::LinearStepSweep
107             );
108              
109             __PACKAGE__->meta()->make_immutable();
110              
111             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.880
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