Moose/Sweep/Step/Magnet.pm

filter: Statementstmt 37.5% 21 / 56 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 0.0% 0 / 3 totaltotal 29.6% 24 / 81 CC 7 SCAR 18.8
CC
7
Cov
31%
BUILD
12.0
_field_setter
12.0
set_persistent_mode
6.0
CRAP 6.6
« Moose/Connection/VISA.pm ↑ Summary Moose/Instrument/LinearStepSweep.pm »
1 package Lab::Moose::Sweep::Step::Magnet;
2 1 $Lab::Moose::Sweep::Step::Magnet::VERSION = '3.931';
3 #ABSTRACT: Step/list sweep of magnetic field
4  
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Lab::Moose::Countdown;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 extends 'Lab::Moose::Sweep::Step';
12 1 has instrument =>
13 ( is => 'ro', isa => 'Lab::Moose::Instrument', required => 1 );
14  
15 1 has start_rate =>
16 ( is => 'ro', isa => 'Lab::Moose::PosNum', writer => '_start_rate' );
17 1 has rate => ( is => 'ro', isa => 'Lab::Moose::PosNum', required => 1 );
18  
19 1 has _current_rate => ( is => 'rw', isa => 'Lab::Moose::PosNum' );
20  
21 1 has filename_extension => ( is => 'ro', isa => 'Str', default => 'Field=' );
22  
23 1 has setter => ( is => 'ro', isa => 'CodeRef', builder => '_build_setter' );
24  
25 1 has persistent_mode => ( is => 'ro', isa => 'Bool', default => 0 );
26  
27 0 ▶sub BUILD {
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod undocumented
28 0 my $self = shift;
29 0 ▶ if ( not defined $self->start_rate ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->start_rate) 0 0 0
30 0 $self->_start_rate( $self->rate );
31 }
32  
33 0 ▶ if ( $self->persistent_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->persistent_mode) 0 0 0
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 0 ▶before 'go_to_sweep_start' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 my $self = shift;
43 0 $self->_current_rate( $self->start_rate );
44 1 };
45  
46 0 ▶after 'go_to_sweep_start' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 my $self = shift;
48 0 $self->_current_rate( $self->rate );
49 1 };
50  
51 0 ▶sub _build_setter {
Subroutine _build_setter: not called CC=1 SCAR=6.9
52 0 return \&_field_setter;
53 }
54  
55 0 ▶sub set_persistent_mode {
Subroutine set_persistent_mode: not called CC=2 SCAR=17.9
Pod undocumented
56 0 my $self = shift;
57 0 my $instrument = $self->instrument();
58 0 ▶ if ( $instrument->in_persistent_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($instrument->in_persistent_mode) 0 0 0
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 0 ▶sub unset_persistent_mode {
Subroutine unset_persistent_mode: not called CC=2 SCAR=17.9
Pod undocumented
69 0 my $self = shift;
70 0 my $instrument = $self->instrument();
71 0 ▶ if ( not $instrument->in_persistent_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($instrument->in_persistent_mode) 0 0 0
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 0 ▶sub _field_setter {
Subroutine _field_setter: not called CC=3 SCAR=24.8
81 0 my $self = shift;
82 0 my $value = shift;
83 0 my $rate = $self->_current_rate;
84 0 ▶ if ( $self->persistent_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->persistent_mode) 0 0 0
85 0 $self->unset_persistent_mode();
86 }
87  
88 0 $self->instrument->sweep_to_field( target => $value, rate => $rate );
89  
90 0 ▶ if ( $self->persistent_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->persistent_mode) 0 0 0
91 0 $self->set_persistent_mode();
92 }
93 }
94  
95 1 __PACKAGE__->meta->make_immutable();
96 1 1;
97  
98 __END__
« Moose/Connection/VISA.pm ↑ Summary Moose/Instrument/LinearStepSweep.pm »