| 1 | package Lab::Moose::Instrument::OI_IPS; | ||||||||||||||||||||||||||||||||
| 2 | 1 | $Lab::Moose::Instrument::OI_IPS::VERSION = '3.931'; | |||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: Oxford Instruments IPS Intelligent 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/ | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 1 | validated_getter validated_setter validated_no_param_setter setter_params /; | |||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Lab::Moose::Countdown 'countdown'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 1 | extends 'Lab::Moose::Instrument'; | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | # Ideally, max_fields and max_field_rates should be preconfigured in a | ||||||||||||||||||||||||||||||||
| 20 | # subclass, with values specific for the magnet used at the setup | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | has max_fields => | |||||||||||||||||||||||||||||||
| 23 | ( is => 'ro', isa => 'ArrayRef[Lab::Moose::PosNum]', required => 1 ); | ||||||||||||||||||||||||||||||||
| 24 | 1 | has max_field_rates => | |||||||||||||||||||||||||||||||
| 25 | ( is => 'ro', isa => 'ArrayRef[Lab::Moose::PosNum]', required => 1 ); | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 1 | has verbose => ( | |||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 29 | isa => 'Bool', | ||||||||||||||||||||||||||||||||
| 30 | default => 1 | ||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 0 | warn "The IPS driver is work in progress. You have been warned\n"; | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | # Unlike modern GPIB equipment, this device does not assert the EOI | ||||||||||||||||||||||||||||||||
| 39 | # at end of message. The controller shell stop reading when receiving the | ||||||||||||||||||||||||||||||||
| 40 | # eos byte. | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 0 | $self->connection->set_termchar( termchar => "\r" ); | |||||||||||||||||||||||||||||||
| 43 | 0 | $self->connection->enable_read_termchar(); | |||||||||||||||||||||||||||||||
| 44 | 0 | $self->clear(); | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | # Use extended resolution mode (setpoint 10 μT, rate 100 μT/min) | ||||||||||||||||||||||||||||||||
| 47 | 0 | $self->set_communications_protocol( value => 4 ); | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 0 | $self->set_control( value => 3 ); | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 0 | $self->_check_field_rates(); | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub _check_field_rates { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_field_rates: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 56 | 0 | my @max_fields = @{ $self->max_fields }; | |||||||||||||||||||||||||||||||
| 57 | 0 | my @max_field_rates = @{ $self->max_field_rates }; | |||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( @max_fields < 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 0 | croak "Need at least one element in max_fields array"; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( @max_fields != @max_field_rates ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 62 | 0 | croak "Need as many values in max_fields as in max_field_rates"; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | for my $i ( 1 .. $#max_fields ) { | |||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $max_fields[$i] <= $max_fields[ $i - 1 ] ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | 0 | croak "values in max_fields must be in increasing order"; | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( $max_field_rates[$i] > $max_field_rates[ $i - 1 ] ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 0 | croak "values in max_field_rates must decrease"; | |||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub _check_sweep_parameters { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_sweep_parameters: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 76 | 0 | my ( $self, %args ) = validated_hash( | |||||||||||||||||||||||||||||||
| 77 | \@_, | ||||||||||||||||||||||||||||||||
| 78 | current => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 79 | target => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 80 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | my $current = abs( delete $args{current} ); | |||||||||||||||||||||||||||||||
| 84 | 0 | my $target = abs( delete $args{target} ); | |||||||||||||||||||||||||||||||
| 85 | 0 | my $rate = abs( delete $args{rate} ); | |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $max_field = ( $current > $target ) ? $current : $target; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 0 | my @max_fields = @{ $self->max_fields }; | |||||||||||||||||||||||||||||||
| 90 | 0 | my @max_field_rates = @{ $self->max_field_rates }; | |||||||||||||||||||||||||||||||
| 91 | 0 | my $maximum_allowed_field = $max_fields[-1]; | |||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||
| 94 | 0 | while (1) { | |||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ( $max_field <= $max_fields[$i] ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 0 | last; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( $max_field > $maximum_allowed_field ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | 0 | croak | |||||||||||||||||||||||||||||||
| 100 | "target field $max_field exceeds absolute maximum field $maximum_allowed_field"; | ||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | 0 | ++$i; | |||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | 0 | my $max_rate = $max_field_rates[$i]; | |||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( $rate > $max_rate ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | 0 | croak "Rate $rate exceeds maximum allowed rate $max_rate"; | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | # query wrapper with error checking | ||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | around query => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 114 | 0 | my $orig = shift; | |||||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 116 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 0 | my $result = $self->$orig(@_); | |||||||||||||||||||||||||||||||
| 119 | 0 | my $cmd = $args{command}; | |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | # remove trailing "\n" and "\r" | ||||||||||||||||||||||||||||||||
| 122 | 0 | $result =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 123 | 0 | $cmd =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | my $cmd_char = substr( $cmd, 0, 1 ); | |||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | # IPS query answers always start with the command character | ||||||||||||||||||||||||||||||||
| 128 | # if successful. | ||||||||||||||||||||||||||||||||
| 129 | # With a question mark and the command char on failure | ||||||||||||||||||||||||||||||||
| 130 | 0 | my $status = substr( $result, 0, 1 ); | |||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ( $status eq '?' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 132 | 0 | croak "IPS returned error '$result' on command '$cmd'"; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | ▶ | elsif ( defined $cmd_char and ( $status ne $cmd_char ) ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $cmd_char and $status ne $cmd_char
MC/DC0%0/2
defined $cmd_char and $status ne $cmd_char
defined $cmd_char
$status ne $cmd_char
Truth table0%0/3
A and B
A= defined $cmd_charB= $status ne $cmd_char
| |||||||||||||||||||||||||||||||||
| 135 | 0 | croak "IPS returned unexpected answer. Expected '$cmd_char' prefix, | |||||||||||||||||||||||||||||||
| 136 | received '$status' on command '$cmd'"; | ||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | 0 | return substr( $result, 1 ); | |||||||||||||||||||||||||||||||
| 139 | 1 | }; | |||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub sweep_to_field { | ||||||||||||||||||||||||||||||
|
Subroutine
sweep_to_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 143 | 0 | my ( $self, %args ) = validated_getter( | |||||||||||||||||||||||||||||||
| 144 | \@_, | ||||||||||||||||||||||||||||||||
| 145 | target => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 146 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 0 | my $point = delete $args{target}; | |||||||||||||||||||||||||||||||
| 150 | 0 | my $rate = delete $args{rate}; | |||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 0 | $self->config_sweep( point => $point, rate => $rate, %args ); | |||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | $self->trg(%args); | |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | 0 | $self->wait(%args); | |||||||||||||||||||||||||||||||
| 157 | 0 | return $self->get_field(%args); | |||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub config_sweep { | ||||||||||||||||||||||||||||||
|
Subroutine
config_sweep: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 162 | 0 | my ( $self, %args ) = validated_hash( | |||||||||||||||||||||||||||||||
| 163 | \@_, | ||||||||||||||||||||||||||||||||
| 164 | point => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 165 | rate => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||
| 167 | 0 | my $target = delete $args{point}; | |||||||||||||||||||||||||||||||
| 168 | 0 | my $rate = delete $args{rate}; | |||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 0 | $self->set_field_sweep_rate( value => $rate, %args ); | |||||||||||||||||||||||||||||||
| 171 | 0 | $self->set_target_field( value => $target, %args ); | |||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 0 | my $current_field = $self->get_field(); | |||||||||||||||||||||||||||||||
| 174 | 0 | $self->_check_sweep_parameters( | |||||||||||||||||||||||||||||||
| 175 | current => $current_field, target => $target, | ||||||||||||||||||||||||||||||||
| 176 | rate => $rate | ||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $self->verbose() ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 179 | 0 | say "config_sweep: target: $target (T), rate: $rate (T/min)"; | |||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub set_control { | ||||||||||||||||||||||||||||||
|
Subroutine
set_control: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 185 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 186 | \@_, | ||||||||||||||||||||||||||||||||
| 187 | value => { isa => enum( [qw/0 1 2 3/] ) }, | ||||||||||||||||||||||||||||||||
| 188 | ); | ||||||||||||||||||||||||||||||||
| 189 | 0 | my $result = $self->query( command => "C$value\r", %args ); | |||||||||||||||||||||||||||||||
| 190 | 0 | sleep(1); | |||||||||||||||||||||||||||||||
| 191 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub set_communications_protocol { | ||||||||||||||||||||||||||||||
|
Subroutine
set_communications_protocol: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 196 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 197 | \@_, | ||||||||||||||||||||||||||||||||
| 198 | value => { isa => enum( [qw/0 2 4 6/] ) } | ||||||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | # This command does not produce an echo -> use write, not query. | ||||||||||||||||||||||||||||||||
| 202 | 0 | $self->write( command => "Q$value\r" ); | |||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub examine_status { | ||||||||||||||||||||||||||||||
|
Subroutine
examine_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 207 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 208 | 0 | return "X" . $self->query( command => "X\r", %args ); | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub active { | ||||||||||||||||||||||||||||||
|
Subroutine
active: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 213 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 214 | 0 | my $status = $self->examine_status(@_); | |||||||||||||||||||||||||||||||
| 215 | 0 | return substr( $status, 11, 1 ); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub in_persistent_mode { | ||||||||||||||||||||||||||||||
|
Subroutine
in_persistent_mode: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 220 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 221 | 0 | my $status = $self->examine_status(@_); | |||||||||||||||||||||||||||||||
| 222 | 0 | my $n = substr( $status, 8, 1 ); | |||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ( $n == 0 || $n == 2 ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$n == 0 or $n == 2
MC/DC0%0/2
$n == 0 or $n == 2
$n == 0
$n == 2
Truth table0%0/3
A or B
A= $n == 0B= $n == 2
| |||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | # heater off | ||||||||||||||||||||||||||||||||
| 226 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | elsif ( $n == 1 ) { | ||||||||||||||||||||||||||||||||
| 229 | 0 | return; | |||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | else { | ||||||||||||||||||||||||||||||||
| 232 | 0 | croak "bad heater status $n"; | |||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub set_persistent_mode { | ||||||||||||||||||||||||||||||
|
Subroutine
set_persistent_mode: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 237 | 0 | my ( $self, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 238 | \@_, | ||||||||||||||||||||||||||||||||
| 239 | mode => { isa => 'Int' } | ||||||||||||||||||||||||||||||||
| 240 | ); | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 0 | my $mode = delete $args{mode}; | |||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | # return 0 if not $self->{device_settings}->{has_switchheater}; | ||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||
| 246 | 0 | my $switch = $self->get_switch_heater(); | |||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | #print "We are in mode $current_mode \n"; | ||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ( $mode == 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | 0 | $self->hold(); | |||||||||||||||||||||||||||||||
| 253 | 0 | $self->set_switch_heater( value => 0 ); | |||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | 0 | $self->to_zero(); | |||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | #$current_mode = 1; | ||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | ▶ | elsif ( $mode == 0 and $switch == 2 ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$mode == 0 and $switch == 2
MC/DC0%0/2
$mode == 0 and $switch == 2
$mode == 0
$switch == 2
Truth table0%0/3
A and B
A= $mode == 0B= $switch == 2
| |||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||
| 262 | 0 | my $setpoint = $self->get_persistent_field(); | |||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | 0 | $self->set_target_field( value => $setpoint ); | |||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 0 | $self->to_setpoint(); | |||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | #print "Try to start switchheater...\n"; | ||||||||||||||||||||||||||||||||
| 269 | 0 | $self->set_switchheater( value => 1 ); | |||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | #print "Switchheater has status ".$self->get_switchheater(); | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | ▶ | elsif ( $mode == 0 and $switch == 0 ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$mode == 0 and $switch == 0
MC/DC0%0/2
$mode == 0 and $switch == 0
$mode == 0
$switch == 0
Truth table0%0/3
A and B
A= $mode == 0B= $switch == 0
| |||||||||||||||||||||||||||||||||
| 275 | 0 | print "Zero magnetic field. Switch on switchheater.\n"; | |||||||||||||||||||||||||||||||
| 276 | 0 | $self->set_switchheater( value => 1 ); | |||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub get_persistent_field { | ||||||||||||||||||||||||||||||
|
Subroutine
get_persistent_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 283 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | # Are we really in persistent mode? | ||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 0 | return $self->read_parameter( value => 18 ); | |||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub wait { | ||||||||||||||||||||||||||||||
|
Subroutine
wait: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 293 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 294 | 0 | my $verbose = $self->verbose(); | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | # enable autoflush | ||||||||||||||||||||||||||||||||
| 297 | 0 | my $autoflush = STDOUT->autoflush(); | |||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 0 | while (1) { | |||||||||||||||||||||||||||||||
| 300 | 0 | sleep 1; | |||||||||||||||||||||||||||||||
| 301 | 0 | my $field = $self->get_field(%args); | |||||||||||||||||||||||||||||||
| 302 | 0 | printf( "Field: %.6f T \r", $field ); | |||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ( not $self->active ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 0 | last; | |||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 308 | 0 | print " " x 70 . "\r"; | |||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | # reset autoflush to previous value | ||||||||||||||||||||||||||||||||
| 312 | 0 | STDOUT->autoflush($autoflush); | |||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub read_parameter { | ||||||||||||||||||||||||||||||
|
Subroutine
read_parameter: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 317 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 318 | \@_, | ||||||||||||||||||||||||||||||||
| 319 | value => { isa => enum( [ ( 0 .. 24 ) ] ) }, | ||||||||||||||||||||||||||||||||
| 320 | ); | ||||||||||||||||||||||||||||||||
| 321 | 0 | my $result = $self->query( command => "R$value\r", %args ); | |||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | # device bug: sometimes the value is returned with a leading 'R' | ||||||||||||||||||||||||||||||||
| 324 | 0 | $result =~ s/^R//; | |||||||||||||||||||||||||||||||
| 325 | 0 | return sprintf( "%e", $result ); | |||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub get_field { | ||||||||||||||||||||||||||||||
|
Subroutine
get_field: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 330 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 331 | 0 | return $self->read_parameter( value => 7, @_ ); | |||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub get_value { | ||||||||||||||||||||||||||||||
|
Subroutine
get_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 336 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 337 | 0 | return $self->get_field(@_); | |||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub get_field_rate { | ||||||||||||||||||||||||||||||
|
Subroutine
get_field_rate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 341 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 342 | 0 | return $self->read_parameter( value => 9, @_ ); | |||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub set_activity { | ||||||||||||||||||||||||||||||
|
Subroutine
set_activity: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 346 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 347 | \@_, | ||||||||||||||||||||||||||||||||
| 348 | value => { isa => enum( [ 0, 1, 2, 4 ] ) }, | ||||||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | 0 | return $self->query( command => "A$value\r", %args ); | |||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub hold { | ||||||||||||||||||||||||||||||
|
Subroutine
hold: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 355 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 356 | 0 | return $self->set_activity( value => 0, @_ ); | |||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | sub to_setpoint { | ||||||||||||||||||||||||||||||
|
Subroutine
to_setpoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 360 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 361 | 0 | return $self->set_activity( value => 1, @_ ); | |||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub trg { | ||||||||||||||||||||||||||||||
|
Subroutine
trg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 365 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 366 | 0 | return $self->to_setpoint(@_); | |||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub to_zero { | ||||||||||||||||||||||||||||||
|
Subroutine
to_zero: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 370 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 371 | 0 | return $self->set_activity( value => 2, @_ ); | |||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub set_front_panel_display_parameter { | ||||||||||||||||||||||||||||||
|
Subroutine
set_front_panel_display_parameter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 375 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 376 | \@_, | ||||||||||||||||||||||||||||||||
| 377 | value => { isa => enum( [ ( 0 .. 24 ) ] ) }, | ||||||||||||||||||||||||||||||||
| 378 | ); | ||||||||||||||||||||||||||||||||
| 379 | 0 | return $self->query( command => "F$value\r", %args ); | |||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | sub set_switch_heater { | ||||||||||||||||||||||||||||||
|
Subroutine
set_switch_heater: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 384 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 385 | \@_, | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | # Do not implement "2" (without check) | ||||||||||||||||||||||||||||||||
| 388 | value => { isa => enum( [ 0, 1 ] ) }, | ||||||||||||||||||||||||||||||||
| 389 | ); | ||||||||||||||||||||||||||||||||
| 390 | 0 | return $self->query( command => "H$value\r", %args ); | |||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub get_switch_heater { | ||||||||||||||||||||||||||||||
|
Subroutine
get_switch_heater: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 395 | 0 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||||||||||||||||||||||||
| 396 | 0 | my $status = $self->examine_status(@_); | |||||||||||||||||||||||||||||||
| 397 | 0 | return substr( $status, 8, 1 ); | |||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub set_target_field { | ||||||||||||||||||||||||||||||
|
Subroutine
set_target_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 401 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 402 | \@_, | ||||||||||||||||||||||||||||||||
| 403 | value => { isa => 'Num' }, | ||||||||||||||||||||||||||||||||
| 404 | ); | ||||||||||||||||||||||||||||||||
| 405 | 0 | $value = sprintf( "%.5f", $value ); | |||||||||||||||||||||||||||||||
| 406 | 0 | return $self->query( command => "J$value\r", %args ); | |||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | sub get_target_field { | ||||||||||||||||||||||||||||||
|
Subroutine
get_target_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 410 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 411 | 0 | return $self->read_parameter( value => 8, @_ ); | |||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub set_mode { | ||||||||||||||||||||||||||||||
|
Subroutine
set_mode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 415 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 416 | \@_, | ||||||||||||||||||||||||||||||||
| 417 | value => { isa => enum( [ 0, 1, 4, 5, 8, 9 ] ) } | ||||||||||||||||||||||||||||||||
| 418 | ); | ||||||||||||||||||||||||||||||||
| 419 | 0 | return $self->query( command => "M$value\r", %args ); | |||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub set_field_sweep_rate { | ||||||||||||||||||||||||||||||
|
Subroutine
set_field_sweep_rate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 423 | 0 | my ( $self, $value, %args ) = validated_setter( | |||||||||||||||||||||||||||||||
| 424 | \@_, | ||||||||||||||||||||||||||||||||
| 425 | value => { isa => 'Lab::Moose::PosNum' }, | ||||||||||||||||||||||||||||||||
| 426 | ); | ||||||||||||||||||||||||||||||||
| 427 | 0 | $value = sprintf( "%.4f", $value ); | |||||||||||||||||||||||||||||||
| 428 | 0 | return $self->query( command => "T$value\r" ); | |||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||
| 432 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | 1 | 1; | |||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||
| 436 | __END__ | ||||||||||||||||||||||||||||||||