line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Sweep::Step::Magnet; |
2
|
|
|
|
|
|
|
$Lab::Moose::Sweep::Step::Magnet::VERSION = '3.880'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Step/list sweep of magnetic field |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2692
|
use v5.20; |
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
7491
|
use Lab::Moose::Countdown; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
510
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Lab::Moose::Sweep::Step'; |
12
|
|
|
|
|
|
|
has instrument => |
13
|
|
|
|
|
|
|
( is => 'ro', isa => 'Lab::Moose::Instrument', required => 1 ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has start_rate => |
16
|
|
|
|
|
|
|
( is => 'ro', isa => 'Lab::Moose::PosNum', writer => '_start_rate' ); |
17
|
|
|
|
|
|
|
has rate => ( is => 'ro', isa => 'Lab::Moose::PosNum', required => 1 ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has _current_rate => ( is => 'rw', isa => 'Lab::Moose::PosNum' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has filename_extension => ( is => 'ro', isa => 'Str', default => 'Field=' ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has setter => ( is => 'ro', isa => 'CodeRef', builder => '_build_setter' ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has persistent_mode => ( is => 'ro', isa => 'Bool', default => 0 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub BUILD { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
0
|
|
|
|
|
if ( not defined $self->start_rate ) { |
30
|
0
|
|
|
|
|
|
$self->_start_rate( $self->rate ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if ( $self->persistent_mode ) { |
34
|
0
|
|
|
|
|
|
$self->_current_rate( $self->start_rate ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# the _field_setter needs a well-defined initial state |
37
|
0
|
|
|
|
|
|
$self->set_persistent_mode(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
before 'go_to_sweep_start' => sub { |
42
|
|
|
|
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
$self->_current_rate( $self->start_rate ); |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
after 'go_to_sweep_start' => sub { |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
$self->_current_rate( $self->rate ); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_setter { |
52
|
0
|
|
|
0
|
|
|
return \&_field_setter; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_persistent_mode { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my $instrument = $self->instrument(); |
58
|
0
|
0
|
|
|
|
|
if ( $instrument->in_persistent_mode ) { |
59
|
0
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$instrument->heater_off(); |
63
|
0
|
|
|
|
|
|
my $rate = $self->_current_rate; |
64
|
0
|
|
|
|
|
|
$instrument->sweep_to_field( target => 0, rate => $rate ); |
65
|
0
|
|
|
|
|
|
countdown( 10, "Set persistent mode: " ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub unset_persistent_mode { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
0
|
|
|
|
|
|
my $instrument = $self->instrument(); |
71
|
0
|
0
|
|
|
|
|
if ( not $instrument->in_persistent_mode ) { |
72
|
0
|
|
|
|
|
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
my $persistent_field = $instrument->get_persistent_field(); |
75
|
0
|
|
|
|
|
|
my $rate = $self->_current_rate; |
76
|
0
|
|
|
|
|
|
$instrument->sweep_to_field( target => $persistent_field, rate => $rate ); |
77
|
0
|
|
|
|
|
|
$instrument->heater_on(); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _field_setter { |
81
|
0
|
|
|
0
|
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
my $value = shift; |
83
|
0
|
|
|
|
|
|
my $rate = $self->_current_rate; |
84
|
0
|
0
|
|
|
|
|
if ( $self->persistent_mode ) { |
85
|
0
|
|
|
|
|
|
$self->unset_persistent_mode(); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->instrument->sweep_to_field( target => $value, rate => $rate ); |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if ( $self->persistent_mode ) { |
91
|
0
|
|
|
|
|
|
$self->set_persistent_mode(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=encoding UTF-8 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Lab::Moose::Sweep::Step::Magnet - Step/list sweep of magnetic field |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version 3.880 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SYNOPSIS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $sweep = sweep( |
115
|
|
|
|
|
|
|
type => 'Step::Magnet', |
116
|
|
|
|
|
|
|
instrument => $ips, |
117
|
|
|
|
|
|
|
from => -1, # Tesla |
118
|
|
|
|
|
|
|
to => 1, # Tesla |
119
|
|
|
|
|
|
|
step => 0.1, # Tesla |
120
|
|
|
|
|
|
|
rate => 1, # Tesla/min, mandatory, always positive, |
121
|
|
|
|
|
|
|
# used to change the magnetic field |
122
|
|
|
|
|
|
|
start_rate => 1, # Tesla/min, default equals rate, always positive, |
123
|
|
|
|
|
|
|
# used when switch heater is off |
124
|
|
|
|
|
|
|
persistent_mode => 1, # use persistent mode, default 0 |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 Description |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Step sweep with following properties: |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Uses instruments C<sweep_to_field> method to set the field. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Uses instruments C<in_persistent_mode> and C<get_persistent_field> methods to query persistent mode status |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Uses instruments C<heater_off> and C<heater_on> to control persistent mode switch |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Default filename extension: C<'Field='> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Copyright 2018-2019 Simon Reinhardt |
156
|
|
|
|
|
|
|
2020 Andreas K. Huettel, Simon Reinhardt |
157
|
|
|
|
|
|
|
2021 Andreas K. Huettel, Fabian Weinelt |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
161
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |