line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Instrument::AMI_430; |
2
|
|
|
|
|
|
|
#ABSTRACT: American Magnetics magnet power supply |
3
|
|
|
|
|
|
|
$Lab::Moose::Instrument::AMI_430::VERSION = '3.900'; |
4
|
1
|
|
|
1
|
|
2837
|
use v5.20; |
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
12
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
7179
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
457
|
use Moose::Util::TypeConstraints qw/enum/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
use Lab::Moose::Instrument |
10
|
1
|
|
|
1
|
|
502
|
qw/validated_getter validated_setter setter_params validated_no_param_setter/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
60
|
|
11
|
1
|
|
|
1
|
|
10
|
use Lab::Moose::Instrument::Cache; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
14
|
|
12
|
1
|
|
|
1
|
|
644
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
13
|
1
|
|
|
1
|
|
16
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
14
|
1
|
|
|
1
|
|
84
|
use Time::HiRes qw (usleep); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
extends 'Lab::Moose::Instrument'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has max_field => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => 'Lab::Moose::PosNum', |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has max_rate => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => 'Lab::Moose::PosNum', |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has verbose => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
isa => 'Bool', |
34
|
|
|
|
|
|
|
default => 1 |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub BUILD { |
39
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->clear(); |
42
|
0
|
|
|
|
|
|
$self->cls(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
around default_connection_options => sub { |
46
|
|
|
|
|
|
|
my $orig = shift; |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
my $options = $self->$orig(); |
49
|
|
|
|
|
|
|
$options->{Socket}{port} = 7180; |
50
|
|
|
|
|
|
|
$options->{Socket}{timeout} = 10; |
51
|
|
|
|
|
|
|
$options->{Socket}{write_termchar} = "\r\n"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return $options; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub cls { |
57
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
58
|
0
|
|
|
|
|
|
return $self->query( command => "*CLS", %args ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub idn { |
62
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
63
|
0
|
|
|
|
|
|
return $self->query( command => "*IDN?", %args ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_field_ramp_rate { |
67
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
68
|
|
|
|
|
|
|
\@_ |
69
|
|
|
|
|
|
|
); |
70
|
0
|
|
|
|
|
|
return $self->query( command => "RAMP:RATE:FIELD:1?", %args ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub set_field_ramp_rate { |
74
|
0
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( |
75
|
|
|
|
|
|
|
\@_, |
76
|
|
|
|
|
|
|
value => { isa => 'Lab::Moose::PosNum' } |
77
|
|
|
|
|
|
|
); |
78
|
0
|
|
|
|
|
|
my $max_rate = $self->max_rate(); |
79
|
0
|
0
|
|
|
|
|
if( $value > $max_rate ) { |
80
|
0
|
|
|
|
|
|
croak("Ramp rate $value T/min higher than max rate $max_rate T/min!"); |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
my $max_field = $self->max_field(); |
83
|
0
|
|
|
|
|
|
return $self->write( command => "CONFIGURE:RAMP:RATE:FIELD 1,$value,$max_field", %args ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_field { |
87
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
88
|
|
|
|
|
|
|
\@_ |
89
|
|
|
|
|
|
|
); |
90
|
0
|
|
|
|
|
|
return $self->query( command => "FIELD:MAGNET?", %args ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub get_value { |
94
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
95
|
|
|
|
|
|
|
\@_ |
96
|
|
|
|
|
|
|
); |
97
|
0
|
|
|
|
|
|
return $self->get_field(@_); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub get_target_field { |
101
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
102
|
|
|
|
|
|
|
\@_ |
103
|
|
|
|
|
|
|
); |
104
|
0
|
|
|
|
|
|
return $self->query( command => "FIELD:TARGET?", %args ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub set_target_field { |
108
|
0
|
|
|
0
|
0
|
|
my ( $self, $value, %args ) = validated_setter( |
109
|
|
|
|
|
|
|
\@_, |
110
|
|
|
|
|
|
|
value => { isa => 'Num' } |
111
|
|
|
|
|
|
|
); |
112
|
0
|
|
|
|
|
|
my $max_field = $self->max_field(); |
113
|
0
|
0
|
|
|
|
|
if( $value > $max_field ) { |
114
|
0
|
|
|
|
|
|
croak("Requested field $value T higher than allowed maximum field strength $max_field T!"); |
115
|
|
|
|
|
|
|
} |
116
|
0
|
|
|
|
|
|
return $self->write( command => "CONFIGURE:FIELD:TARGET $value", %args ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub sweep_to_field { |
120
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = validated_getter( |
121
|
|
|
|
|
|
|
\@_, |
122
|
|
|
|
|
|
|
target => { isa => 'Num' }, |
123
|
|
|
|
|
|
|
rate => { isa => 'Num' }, |
124
|
|
|
|
|
|
|
); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
my $point = delete $args{target}; |
127
|
0
|
|
|
|
|
|
my $rate = delete $args{rate}; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
$self->config_sweep( point => $point, rate => $rate, %args ); |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->trg(%args); |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$self->wait(%args); |
134
|
0
|
|
|
|
|
|
return $self->get_field(%args); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub ramp { |
138
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( \@_ ); |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
my $ret_val = $self->write( command => "RAMP", %args ); |
141
|
0
|
|
|
|
|
|
while ($self->active()) { |
142
|
0
|
|
|
|
|
|
sleep(2); |
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
return $ret_val; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub to_zero { |
148
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = validated_getter( |
149
|
|
|
|
|
|
|
\@_ |
150
|
|
|
|
|
|
|
); |
151
|
0
|
|
|
|
|
|
my $ret_val = $self->write( command => "ZERO", %args ); |
152
|
0
|
|
|
|
|
|
while ($self->active()) { |
153
|
0
|
|
|
|
|
|
sleep(2); |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
|
return $ret_val; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Methods for sweep |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub config_sweep { |
161
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_hash( |
162
|
|
|
|
|
|
|
\@_, |
163
|
|
|
|
|
|
|
point => { isa => 'Num' }, |
164
|
|
|
|
|
|
|
rate => { isa => 'Num' }, |
165
|
|
|
|
|
|
|
); |
166
|
0
|
|
|
|
|
|
my $target = delete $args{point}; |
167
|
0
|
|
|
|
|
|
my $rate = delete $args{rate}; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$self->set_target_field( value => $target, %args ); |
170
|
0
|
|
|
|
|
|
$self->set_field_ramp_rate( value => $rate, %args ); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $current_field = $self->get_field(); |
173
|
0
|
|
|
|
|
|
$self->_check_sweep_parameters( |
174
|
|
|
|
|
|
|
current => $current_field, target => $target, |
175
|
|
|
|
|
|
|
rate => $rate |
176
|
|
|
|
|
|
|
); |
177
|
0
|
0
|
|
|
|
|
if ( $self->verbose() ) { |
178
|
0
|
|
|
|
|
|
say "config_sweep: target: $target (T), rate: $rate (T/min)"; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub trg { |
183
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
184
|
|
|
|
|
|
|
\@_ |
185
|
|
|
|
|
|
|
); |
186
|
0
|
|
|
|
|
|
return $self->write( command => "RAMP", %args ); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub active { |
190
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
191
|
|
|
|
|
|
|
\@_, |
192
|
|
|
|
|
|
|
); |
193
|
0
|
|
|
|
|
|
my $status = $self->query( command => "STATE?", %args ); |
194
|
|
|
|
|
|
|
# Holding at the target field OR At zero current |
195
|
0
|
0
|
0
|
|
|
|
if($status eq 2 || $status eq 8) { |
196
|
0
|
|
|
|
|
|
return 0 |
197
|
|
|
|
|
|
|
} else { |
198
|
0
|
|
|
|
|
|
return 1 |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub wait { |
203
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_getter( |
204
|
|
|
|
|
|
|
\@_, |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
my $autoflush = STDOUT->autoflush(); |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
while ($self->active()) { |
210
|
0
|
|
|
|
|
|
sleep(1); |
211
|
0
|
|
|
|
|
|
printf( "Field: %.3fT\r", $self->get_field(%args) ); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
STDOUT->autoflush($autoflush); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub _check_sweep_parameters { |
218
|
0
|
|
|
0
|
|
|
my ( $self, %args ) = validated_hash( |
219
|
|
|
|
|
|
|
\@_, |
220
|
|
|
|
|
|
|
current => { isa => 'Num' }, |
221
|
|
|
|
|
|
|
target => { isa => 'Num' }, |
222
|
|
|
|
|
|
|
rate => { isa => 'Num' }, |
223
|
|
|
|
|
|
|
); |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
my $current = abs( delete $args{current} ); |
226
|
0
|
|
|
|
|
|
my $target = abs( delete $args{target} ); |
227
|
0
|
|
|
|
|
|
my $rate = abs( delete $args{rate} ); |
228
|
|
|
|
|
|
|
|
229
|
0
|
0
|
|
|
|
|
my $max_field = ( $current > $target ) ? $current : $target; |
230
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
my $maximum_allowed_field = $self->max_field(); |
232
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
my $i = 0; |
234
|
|
|
|
|
|
|
|
235
|
0
|
0
|
|
|
|
|
if ( $max_field > $maximum_allowed_field ) { |
236
|
0
|
|
|
|
|
|
croak |
237
|
|
|
|
|
|
|
"target field $max_field exceeds absolute maximum field $maximum_allowed_field"; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
my $max_rate = $self->max_rate(); |
242
|
0
|
0
|
|
|
|
|
if ( $rate > $max_rate ) { |
243
|
0
|
|
|
|
|
|
croak "Rate $rate exceeds maximum allowed rate $max_rate"; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
__END__ |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=pod |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=encoding UTF-8 |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 NAME |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Lab::Moose::Instrument::AMI_430 - American Magnetics magnet power supply |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 VERSION |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
version 3.900 |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 SYNOPSIS |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
use Lab::Moose; |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# Constructor |
270
|
|
|
|
|
|
|
my $magnet_z = instrument( |
271
|
|
|
|
|
|
|
type => 'AMI_430', |
272
|
|
|
|
|
|
|
connection_type => 'Socket', |
273
|
|
|
|
|
|
|
connection_options => { host => '169.254.226.70' }, |
274
|
|
|
|
|
|
|
max_field => 1.0, |
275
|
|
|
|
|
|
|
max_rate => 0.1, |
276
|
|
|
|
|
|
|
); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
$magnet_sweep = sweep( |
279
|
|
|
|
|
|
|
type => 'Continuous::Magnet', |
280
|
|
|
|
|
|
|
instrument => $magnet_z, |
281
|
|
|
|
|
|
|
from => -0.2, to => 0.2, interval => 1, |
282
|
|
|
|
|
|
|
) |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Setting the maximum allowed field strength and the maximum rate are mandatory. |
285
|
|
|
|
|
|
|
This model allows to change the units for field strength (kG/T) and time (min/s). |
286
|
|
|
|
|
|
|
You can check this in the menu on the front panel. |
287
|
|
|
|
|
|
|
For security purposes this driver does not allow changing those critical settings. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head1 METHODS |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head2 idn |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
say $magnet_z->idn(); |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Returns the identification string of the device. It contains the AMI model |
296
|
|
|
|
|
|
|
number and firmware revision code. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 sweep_to_field |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
$magnet_z->sweep_to_field( target => 0.5, rate => 0.02 ); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Checks the provided field strength and rate and starts a sweep. |
303
|
|
|
|
|
|
|
This function waits for the device to finish. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head2 to_zero |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
$magnet_z->to_zero() |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
Sweeps back to zero with the maximum allowed rate. |
310
|
|
|
|
|
|
|
This function waits for the device to finish. |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Copyright 2023 Mia Schambeck |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
320
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=cut |