Moose/Instrument/Cryomagnetics_4G.pm

filter: Statementstmt 31.5% 29 / 92 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 23.5% 8 / 34 Podpod 91.6% 22 / 24 totaltotal 38.8% 59 / 152 SCAR 12.0
CC
2
Cov
31%
BUILD
6.0
_remove_unit
2.0
_kG_to_tesla
2.0
CRAP 3.3
« Moose/Connection/Debug.pm ↑ Summary Instrument/TemperatureControl.pm »
1 package Lab::Moose::Instrument::Cryomagnetics_4G;
2 1 $Lab::Moose::Instrument::Cryomagnetics_4G::VERSION = '3.881';
3 #ABSTRACT: Cryomagnetics 4G superconducting magnet power supply
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 Moose::Util::TypeConstraints qw/enum/;
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 Lab::Moose::Instrument qw/
11 1 ▶ 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 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 extends 'Lab::Moose::Instrument';
17  
18 1 with qw(
19 Lab::Moose::Instrument::Common
20 );
21  
22 sub BUILD {
23 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=2 SCAR=17.9
Pod undocumented
24 0 my $units = $self->get_units();
25 0 ▶ if ( $units eq 'A' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($units eq "A") 0 0 0
26 0 carp
27 'Warning: Cryomagnetics 4G Power supply uses current units (A) not field units';
28 }
29 }
30  
31  
32 sub _remove_unit {
33 0 ▶ my $rv = shift;
Subroutine _remove_unit: not called CC=1 SCAR=6.9
34 0 $rv =~ s/[a-zA-Z]*$//;
35 0 return $rv;
36 }
37  
38 sub _kG_to_tesla {
39 0 ▶ my $kG = shift;
Subroutine _kG_to_tesla: not called CC=1 SCAR=6.9
40 0 return 0.1 * $kG;
41 }
42  
43  
44 sub get_field {
45 0 ▶ my $self = shift;
Subroutine get_field: not called CC=1 SCAR=6.9
Pod undocumented
46 0 return _kg_to_tesla( $self->get_imag(@_) );
47 }
48  
49 # =head1 sweep_to_field
50  
51 # my $new_field = $magnet->sweep_to_field(
52 # target => $target_field, # Tesla
53 # rate => $rate, # Tesla/min
54 # );
55  
56 # =cut
57  
58 # sub sweep_to_field {
59 # my ( $self, %args ) = validated_getter(
60 # \@_,
61 # target => { isa => 'Num' },
62 # rate => { isa => 'Num' },
63 # );
64  
65 # my $point = delete $args{target};
66 # my $rate = delete $args{rate};
67  
68 # $self->config_sweep( point => $point, rate => $rate, %args );
69  
70 # $self->trg(%args);
71  
72 # $self->wait(%args);
73 # return $self->get_field(%args);
74 # }
75  
76 # =head1 config_sweep
77  
78 # $magnet->config_sweep(point => $target, rate => $rate);
79  
80 # Only define setpoints, do not start sweep.
81  
82 # =cut
83  
84 # sub config_sweep {
85 # my ( $self, %args ) = validated_hash(
86 # \@_,
87 # point => { isa => 'Num' },
88 # rate => { isa => 'Num' },
89 # );
90 # my $target = delete $args{point};
91 # my $rate = delete $args{rate};
92  
93 # $self->set_field_sweep_rate( value => $rate, %args );
94 # $self->set_target_field( value => $target, %args );
95  
96 # my $current_field = $self->get_field();
97 # $self->_check_sweep_parameters(
98 # current => $current_field, target => $target,
99 # rate => $rate
100 # );
101 # if ( $self->verbose() ) {
102 # say "config_sweep: target: $target (T), rate: $rate (T/min)";
103 # }
104 # }
105  
106 # sub trg {
107  
108 # }
109  
110 # sub wait {
111  
112 # }
113  
114 # sub active {
115  
116 # }
117  
118 # sub in_persistent_mode {
119  
120 # }
121  
122 # sub get_persistent_field {
123  
124 # }
125  
126 # =head2 heater_on/heater_off
127  
128 # $magnet->heater_on();
129 # $magnet->heater_off();
130  
131 # sub heater_on {
132  
133 # }
134  
135 # sub heater_off {
136  
137 # }
138  
139  
140 sub get_imag {
141 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_imag: not called CC=1 SCAR=6.9
Pod documented
142 0 return $self->query( command => "IMAG?", %args );
143 }
144  
145  
146 sub get_iout {
147 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_iout: not called CC=1 SCAR=6.9
Pod documented
148 0 my $rv = $self->query( command => 'IOUT?', %args );
149 0 return _remove_unit($rv);
150 }
151  
152  
153 sub set_llim {
154 0 ▶ my ( $self, $value, %args ) = validated_setter( \@_ );
Subroutine set_llim: not called CC=1 SCAR=6.9
Pod documented
155 0 $self->write( command => "LLIM $value", %args );
156 }
157  
158 sub get_llim {
159 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_llim: not called CC=1 SCAR=6.9
Pod documented
160 0 my $rv = $self->query( command => 'LLIM?', %args );
161 0 return _remove_unit($rv);
162 }
163  
164  
165 sub local {
166 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine local: not called CC=1 SCAR=6.9
Pod documented
167 0 $self->write( command => "LOCAL", %args );
168 }
169  
170  
171 sub get_mode {
172 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_mode: not called CC=1 SCAR=6.9
Pod documented
173 0 return $self->query( command => 'MODE?', %args );
174 }
175  
176  
177 sub set_pshtr {
178 0 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine set_pshtr: not called CC=1 SCAR=6.9
Pod documented
179 \@_,
180 value => { isa => enum( [ 0, 1 ] ) },
181 );
182 0 $self->write( command => "PSHTR $value", %args );
183 }
184  
185 sub get_pshtr {
186 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_pshtr: not called CC=1 SCAR=6.9
Pod documented
187 0 return $self->query( command => "PSHTR?", %args );
188 }
189  
190  
191 sub set_range {
192 0 ▶ my ( $self, %args ) = validated_getter(
Subroutine set_range: not called CC=1 SCAR=6.9
Pod documented
193 select => { isa => enum( [ ( 0 .. 4 ) ] ) },
194 limit => { isa => 'Num' },
195 );
196 0 my $select = delete $args{select};
197 0 my $limit = delete $args{limit};
198 0 $self->write( command => "RANGE $select $limit", %args );
199 }
200  
201 sub get_range {
202 0 ▶ my ( $self, %args ) = validated_getter(
Subroutine get_range: not called CC=1 SCAR=6.9
Pod documented
203 select => { isa => enum( [ ( 0 .. 4 ) ] ) },
204 );
205 0 my $select = delete $args{select};
206 0 return $self->query( command => "RANGE? $select", %args );
207 }
208  
209  
210 sub set_rate {
211 0 ▶ my ( $self, %args ) = validated_getter(
Subroutine set_rate: not called CC=1 SCAR=6.9
Pod documented
212 range => { isa => enum( [ ( 0 .. 5 ) ] ) },
213 rate => { isa => 'Num' },
214 );
215 0 my $range = delete $args{range};
216 0 my $rate = delete $args{rate};
217 0 $self->write( command => "RATE $range $rate", %args );
218 }
219  
220 sub get_rate {
221 0 ▶ my ( $self, %args ) = validated_getter(
Subroutine get_rate: not called CC=1 SCAR=6.9
Pod documented
222 range => { isa => enum( [ ( 0 .. 5 ) ] ) },
223 );
224 0 my $range = delete $args{range};
225 0 return $self->query( command => "RATE? $range", %args );
226 }
227  
228  
229 sub set_sweep {
230 0 ▶ my ( $self, $value, %args ) = validated_getter(
Subroutine set_sweep: not called CC=1 SCAR=6.9
Pod documented
231 \@_,
232 value => {
233 isa => enum(
234 [ qw/UP DOWN PAUSE ZERO LIMIT/, 'UP FAST', 'DOWN FAST' ]
235 )
236 },
237 );
238  
239 0 $self->write( command => "SWEEP $value", %args );
240 }
241  
242 sub get_sweep {
243 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_sweep: not called CC=1 SCAR=6.9
Pod documented
244 0 return $self->query( command => "SWEEP?", %args );
245 }
246  
247  
248 sub set_ulim {
249 0 ▶ my ( $self, $value, %args ) = validated_getter(
Subroutine set_ulim: not called CC=1 SCAR=6.9
Pod documented
250 \@_,
251 value => { isa => 'Num' },
252 );
253  
254 0 $self->write( command => "ULIM $value", %args );
255 }
256  
257 sub get_ulim {
258 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_ulim: not called CC=1 SCAR=6.9
Pod documented
259 0 return _remove_unit( $self->query( command => "ULIM?", %args ) );
260 }
261  
262  
263 1 cache units => ( getter => 'get_units' );
264  
265 sub set_units {
266 0 ▶ my ( $self, $value, %args ) = validated_getter(
Subroutine set_units: not called CC=1 SCAR=6.9
Pod documented
267 \@_,
268 value => { isa => enum( [qw/A G/] ) },
269 );
270 0 $self->write( command => "UNITS $value", %args );
271 }
272  
273 sub get_units {
274 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_units: not called CC=1 SCAR=6.9
Pod documented
275 0 return $self->query( command => "UNITS?", %args );
276 }
277  
278  
279 sub set_vlim {
280 0 ▶ my ( $self, $value, %args ) = validated_getter(
Subroutine set_vlim: not called CC=1 SCAR=6.9
Pod documented
281 \@_,
282 value => { isa => 'Num' },
283 );
284  
285 0 $self->write( command => "VLIM $value", %args );
286 }
287  
288 sub get_vlim {
289 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_vlim: not called CC=1 SCAR=6.9
Pod documented
290 0 return _remove_unit( $self->query( command => "VLIM?", %args ) );
291 }
292  
293  
294 sub get_vmag {
295 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_vmag: not called CC=1 SCAR=6.9
Pod documented
296 0 return _remove_unit( $self->query( command => "VMAG?", %args ) );
297 }
298  
299  
300 sub get_vout {
301 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_vout: not called CC=1 SCAR=6.9
Pod documented
302 0 return _remove_unit( $self->query( command => "VOUT?", %args ) );
303 }
304  
305  
306 1 __PACKAGE__->meta()->make_immutable();
307  
308 1 1;
309  
310 __END__
311  
312 =pod
313  
314 =encoding UTF-8
315  
316 =head1 NAME
317  
318 Lab::Moose::Instrument::Cryomagnetics_4G - Cryomagnetics 4G superconducting magnet power supply
319  
320 =head1 VERSION
321  
322 version 3.881
323  
324 =head1 SYNOPSIS
325  
326 use Lab::Moose;
327  
328 # Constructor
329 my $magnet = instrument(
330 type => 'Cryomagnetics_4G',
331 connection_type => 'VISA::GPIB',
332 connection_options => {'gpib_address' => 10}
333 );
334  
335 =head1 METHODS
336  
337 =head1 LOW-LEVEL DEVICE METHODS
338  
339 =head2 get_imag
340  
341 my $value = $magnet->get_imag();
342  
343 Uses either Amps or kilo Gauss, depending on units setting.
344  
345 =head2 get_iout
346  
347 my $value = $magnet->get_iout();
348  
349 Uses either Amps or kilo Gauss, depending on units setting.
350  
351 =head2 set_llim/get_llim
352  
353 $magnet->set_llim(value => 10);
354 my $value = $magnet->get_llim();
355  
356 Uses either Amps or kilo Gauss, depending on units setting.
357  
358 =head2 local
359  
360 $magnet->local();
361  
362 =head2 get_mode
363  
364 my $mode = $magnet->get_mode();
365  
366 Possible return values: Shim, Manual
367  
368 =head2 set_pshtr/get_pshtr
369  
370 $magnet->set_pshtr(value => 0);
371 my $value = $magnet->get_pshtr();
372  
373 Returns 0 or 1.
374  
375 =head2 set_range/get_range
376  
377 $magnet->set_range(select => 1, limit => 2); # 2 Amps
378 my $range = $magnet->get_range(select => 1);
379  
380 C<select> is in range 0,..,4.
381  
382 =head2 set_rate/get_rate
383  
384 $magnet->set_rate(range => 1, rate => 0.001); # 1mA / sec
385 my $rate = $magnet->get_rate(range => 1);
386  
387 C<range> is in range 0,...5, where 5 specifies the rate in fast sweep mode.
388 C<rate> arg is given in Amps per second.
389  
390 =head2 set_sweep/get_sweep
391  
392 $magnet->set_sweep(value => 'UP');
393 $magnet->set_sweep(value => 'UP FAST'); # with switch heater off
394 my $mode = $magnet->get_sweep();
395  
396 C<value> is one off 'UP', 'UP FAST', 'DOWN', 'DOWN FAST', 'PAUSE', 'ZERO', 'LIMIT'
397  
398 =head2 set_ulim/get_ulim
399  
400 $magnet->set_ulim(value => 10);
401 my $value = $magnet->get_ulim();
402  
403 Uses either Amps or kilo Gauss, depending on units setting.
404  
405 =head2 set_units/get_units
406  
407 $magnet->set_units(value => 'A'); # use Amps
408 $magnet->set_units(value => 'G'); # use kiloGauss
409 my $units = $magnet->get_units(); # 'A' or 'G'
410  
411 =head2 set_vlim/get_vlim
412  
413 $magnet->set_vlim(value => 2); # 2V
414 my $vlim = $magnet->get_vlim();
415  
416 =head2 get_vmag
417  
418 my $vmag = $magnet->get_vmag();
419  
420 =head2 get_vout
421  
422 my $vmag = $magnet->get_vout();
423  
424 =head2 Consumed Roles
425  
426 This driver consumes the following roles:
427  
428 =over
429  
430 =item L<Lab::Moose::Instrument::Common>
431  
432 =back
433  
434 =head1 COPYRIGHT AND LICENSE
435  
436 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
437  
438 Copyright 2022 Simon Reinhardt
439  
440  
441 This is free software; you can redistribute it and/or modify it under
442 the same terms as the Perl 5 programming language system itself.
443  
444 =cut
« Moose/Connection/Debug.pm ↑ Summary Instrument/TemperatureControl.pm »