| 1 | package Lab::Moose::Instrument::AMI_430; | ||||||||||||||||||||||||||||
| 2 | 1 | $Lab::Moose::Instrument::AMI_430::VERSION = '3.931'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: American Magnetics magnet power supply | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use v5.20; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
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 | use Lab::Moose::Instrument | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | qw/validated_getter validated_setter setter_params validated_no_param_setter/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Time::HiRes qw (usleep); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | extends 'Lab::Moose::Instrument'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | has max_field => ( | |||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||
| 21 | isa => 'Lab::Moose::PosNum', | ||||||||||||||||||||||||||||
| 22 | required => 1, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | has max_rate => ( | |||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||
| 27 | isa => 'Lab::Moose::PosNum', | ||||||||||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | has verbose => ( | |||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||
| 33 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 34 | default => 1 | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | has persistent_mode => ( | |||||||||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||||||||||
| 39 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 40 | builder => '_persistent_builder', | ||||||||||||||||||||||||||||
| 41 | lazy => 1, | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | #subroutines needed: heater_off, in_persistent_mode, get_persistent_field, heater_on | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | #heater off: turns off the switch heater | ||||||||||||||||||||||||||||
| 47 | #heater on: turns on the switch heater | ||||||||||||||||||||||||||||
| 48 | #get_persistent_field: gives back the applied persistent field - done | ||||||||||||||||||||||||||||
| 49 | #in_persistent_mode: gives back whether the magnet is in the persistent mode or not - done | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub _persistent_builder { | ||||||||||||||||||||||||||
|
Subroutine
_persistent_builder: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 0 | return $self -> query( command => " PSwitch:INSTalled?"); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $self->clear(); | |||||||||||||||||||||||||||
| 60 | 0 | $self->cls(); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | around default_connection_options => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 64 | 0 | my $orig = shift; | |||||||||||||||||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 66 | 0 | my $options = $self->$orig(); | |||||||||||||||||||||||||||
| 67 | 0 | $options->{Socket}{port} = 7180; | |||||||||||||||||||||||||||
| 68 | 0 | $options->{Socket}{timeout} = 10; | |||||||||||||||||||||||||||
| 69 | 0 | $options->{Socket}{write_termchar} = "\r\n"; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return $options; | |||||||||||||||||||||||||||
| 72 | 1 | }; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub cls { | ||||||||||||||||||||||||||
|
Subroutine
cls: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 76 | 0 | return $self->query( command => "*CLS", %args ); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub idn { | ||||||||||||||||||||||||||
|
Subroutine
idn: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 82 | 0 | return $self->query( command => "*IDN?", %args ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub get_field_ramp_rate { | ||||||||||||||||||||||||||
|
Subroutine
get_field_ramp_rate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 87 | \@_ | ||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||
| 89 | 0 | return $self->query( command => "RAMP:RATE:FIELD:1?", %args ); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub set_field_ramp_rate { | ||||||||||||||||||||||||||
|
Subroutine
set_field_ramp_rate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 94 | \@_, | ||||||||||||||||||||||||||||
| 95 | value => { isa => 'Lab::Moose::PosNum' } | ||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||
| 97 | 0 | my $max_rate = $self->max_rate(); | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | if( $value > $max_rate ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | croak("Ramp rate $value T/min higher than max rate $max_rate T/min!"); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | 0 | my $max_field = $self->max_field(); | |||||||||||||||||||||||||||
| 102 | 0 | return $self->write( command => "CONFIGURE:RAMP:RATE:FIELD 1,$value,$max_field", %args ); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub get_field { | ||||||||||||||||||||||||||
|
Subroutine
get_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 107 | \@_ | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | 0 | return $self->query( command => "FIELD:MAGNET?", %args ); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub get_voltage { | ||||||||||||||||||||||||||
|
Subroutine
get_voltage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 114 | \@_ | ||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||
| 116 | 0 | return $self->query( command => "VOLTage:SUPPly?", %args ); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub get_persistent_field { | ||||||||||||||||||||||||||
|
Subroutine
get_persistent_field: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( $self -> persistent_mode == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | croak ( "No persistent switch installed!" ); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 0 | return $self->query( command => "FIELD:MAGnet?"); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub in_persistent_mode { | ||||||||||||||||||||||||||
|
Subroutine
in_persistent_mode: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $self -> persistent_mode == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | croak ( "No persistent switch installed!" ); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 0 | my $status = $self->query( command => "PERSistent?"); | |||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( $status == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | return 0; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | else { | ||||||||||||||||||||||||||||
| 137 | 0 | return 1; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub set_switch_heater { | ||||||||||||||||||||||||||
|
Subroutine
set_switch_heater: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 143 | \@_, | ||||||||||||||||||||||||||||
| 144 | value => {isa => enum( [ 0,1 ] ) }, | ||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( $self -> persistent_mode == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | croak ( "No persistent switch installed!" ); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($value == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | return $self->query( command => "PSwitch 0" ); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||
| 153 | 0 | return $self->query( command => "PSwitch 1" ); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub heater_on { | ||||||||||||||||||||||||||
|
Subroutine
heater_on: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 159 | \@_, | ||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ( $self -> persistent_mode == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | croak ( "No persistent switch installed!" ); | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 0 | $self ->query( command => "PSwitch?"); | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($self == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | return $self->set_switch_heater(value => 1); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||
| 169 | 0 | croak ( "The switch heater is already turned on." ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub heater_off { | ||||||||||||||||||||||||||
|
Subroutine
heater_off: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 175 | \@_, | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( $self -> persistent_mode == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | croak ( "No persistent switch installed!" ); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 0 | $self ->query( command => "PSwitch?"); | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | if ($self == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | return $self->set_switch_heater(value => 0); | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||
| 185 | 0 | croak("The switch heater is already turned off."); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub get_value { | ||||||||||||||||||||||||||
|
Subroutine
get_value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 190 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 191 | \@_ | ||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||
| 193 | 0 | return $self->get_field(@_); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub get_target_field { | ||||||||||||||||||||||||||
|
Subroutine
get_target_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 197 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 198 | \@_ | ||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||
| 200 | 0 | return $self->query( command => "FIELD:TARGET?", %args ); | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub set_target_field { | ||||||||||||||||||||||||||
|
Subroutine
set_target_field: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||
| 205 | \@_, | ||||||||||||||||||||||||||||
| 206 | value => { isa => 'Num' } | ||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||
| 208 | 0 | my $max_field = $self->max_field(); | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | if( $value > $max_field ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | croak("Requested field $value T higher than allowed maximum field strength $max_field T!"); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 0 | return $self->write( command => "CONFIGURE:FIELD:TARGET $value", %args ); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub sweep_to_field { | ||||||||||||||||||||||||||
|
Subroutine
sweep_to_field: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 217 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 218 | \@_, | ||||||||||||||||||||||||||||
| 219 | target => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 220 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | my $point = delete $args{target}; | |||||||||||||||||||||||||||
| 224 | 0 | my $rate = delete $args{rate}; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | $self->config_sweep( point => $point, rate => $rate, %args ); | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | $self->trg(%args); | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | $self->wait(%args); | |||||||||||||||||||||||||||
| 231 | 0 | return $self->get_field(%args); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub ramp { | ||||||||||||||||||||||||||
|
Subroutine
ramp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 235 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my $ret_val = $self->write( command => "RAMP", %args ); | |||||||||||||||||||||||||||
| 238 | 0 | ▶ | while ($self->active()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | sleep(2); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 0 | return $ret_val; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub to_zero { | ||||||||||||||||||||||||||
|
Subroutine
to_zero: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 247 | \@_ | ||||||||||||||||||||||||||||
| 248 | ); | ||||||||||||||||||||||||||||
| 249 | 0 | my $ret_val = $self->write( command => "ZERO", %args ); | |||||||||||||||||||||||||||
| 250 | 0 | ▶ | while ($self->active()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 0 | sleep(2); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | 0 | return $ret_val; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | # Methods for sweep | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | sub config_sweep { | ||||||||||||||||||||||||||
|
Subroutine
config_sweep: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 259 | 0 | my ( $self, %args ) = validated_hash( | |||||||||||||||||||||||||||
| 260 | \@_, | ||||||||||||||||||||||||||||
| 261 | point => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 262 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||
| 264 | 0 | my $target = delete $args{point}; | |||||||||||||||||||||||||||
| 265 | 0 | my $rate = delete $args{rate}; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | $self->set_target_field( value => $target, %args ); | |||||||||||||||||||||||||||
| 268 | 0 | $self->set_field_ramp_rate( value => $rate, %args ); | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | my $current_field = $self->get_field(); | |||||||||||||||||||||||||||
| 271 | 0 | $self->_check_sweep_parameters( | |||||||||||||||||||||||||||
| 272 | current => $current_field, target => $target, | ||||||||||||||||||||||||||||
| 273 | rate => $rate | ||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ( $self->verbose() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | say "config_sweep: target: $target (T), rate: $rate (T/min)"; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub trg { | ||||||||||||||||||||||||||
|
Subroutine
trg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 282 | \@_ | ||||||||||||||||||||||||||||
| 283 | ); | ||||||||||||||||||||||||||||
| 284 | 0 | return $self->write( command => "RAMP", %args ); | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub active { | ||||||||||||||||||||||||||
|
Subroutine
active: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 288 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 289 | \@_, | ||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||
| 291 | 0 | my $status = $self->query( command => "STATE?", %args ); | |||||||||||||||||||||||||||
| 292 | # Holding at the target field OR At zero current | ||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if($status eq 2 || $status eq 8) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status eq 2 or $status eq 8
MC/DC0%0/2
$status eq 2 or $status eq 8
$status eq 2
$status eq 8
Truth table0%0/3
A or B
A= $status eq 2B= $status eq 8
| |||||||||||||||||||||||||||||
| 294 | 0 | return 0 | |||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||
| 296 | 0 | return 1 | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | sub wait { | ||||||||||||||||||||||||||
|
Subroutine
wait: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 301 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||
| 302 | \@_, | ||||||||||||||||||||||||||||
| 303 | ); | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 0 | my $autoflush = STDOUT->autoflush(); | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | while ($self->active()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 0 | sleep(1); | |||||||||||||||||||||||||||
| 309 | 0 | printf( "Field: %.3fT\r", $self->get_field(%args) ); | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | STDOUT->autoflush($autoflush); | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub _check_sweep_parameters { | ||||||||||||||||||||||||||
|
Subroutine
_check_sweep_parameters: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 316 | 0 | my ( $self, %args ) = validated_hash( | |||||||||||||||||||||||||||
| 317 | \@_, | ||||||||||||||||||||||||||||
| 318 | current => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 319 | target => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 320 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||
| 321 | ); | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | my $current = abs( delete $args{current} ); | |||||||||||||||||||||||||||
| 324 | 0 | my $target = abs( delete $args{target} ); | |||||||||||||||||||||||||||
| 325 | 0 | my $rate = abs( delete $args{rate} ); | |||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my $max_field = ( $current > $target ) ? $current : $target; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | my $maximum_allowed_field = $self->max_field(); | |||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if ( $max_field > $maximum_allowed_field ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | 0 | croak | |||||||||||||||||||||||||||
| 335 | "target field $max_field exceeds absolute maximum field $maximum_allowed_field"; | ||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | my $max_rate = $self->max_rate(); | |||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( $rate > $max_rate ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 0 | croak "Rate $rate exceeds maximum allowed rate $max_rate"; | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 1 | 1; | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | __END__ | ||||||||||||||||||||||||||||