XPRESS/Sweep/PulseLength.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 74 CC 3 SCAR 14.6
CC
3
Cov
0%
exit_loop
12.0
new
2.0
go_to_sweep_start
2.0
CRAP 4.3
1 package Lab::XPRESS::Sweep::PulseLength;
2 #ABSTRACT: Pulse length sweep
3 $Lab::XPRESS::Sweep::PulseLength::VERSION = '3.899';
4 use v5.20;
5  
6 use Lab::XPRESS::Sweep;
7 use Time::HiRes qw/usleep/, qw/time/;
8 use strict;
9  
10 our @ISA = ('Lab::XPRESS::Sweep');
11  
12 sub new {
13 my $proto = shift;
14 my @args = @_;
15 my $class = ref($proto) || $proto;
16 my $self->{default_config} = {
17 id => 'PulseLength_Sweep',
18 filename_extension => 'PulseLength=',
19 interval => 1,
20 points => [],
21 rate => [1],
22 mode => 'step',
23 allowed_instruments => ['Lab::Instrument::RSSMB100A'],
24 allowed_sweep_modes => [ 'list', 'step' ],
25 number_of_points => [undef]
26 };
27  
28 $self = $class->SUPER::new( $self->{default_config}, @args );
29 bless( $self, $class );
30  
31 return $self;
32 }
33  
34 sub go_to_sweep_start {
35 my $self = shift;
36  
37 # go to start:
38 $self->{config}->{instrument}
39 ->set_pulselength( { value => @{ $self->{config}->{points} }[0] } );
40 }
41  
42 sub start_continuous_sweep {
43 my $self = shift;
44  
45 return;
46  
47 }
48  
49 sub go_to_next_step {
50 my $self = shift;
51  
52 $self->{config}->{instrument}->set_pulselength(
53 { value => @{ $self->{config}->{points} }[ $self->{iterator} ] } );
54  
55 }
56  
57 sub exit_loop {
58 my $self = shift;
59  
60 if ( $self->{config}->{mode} =~ /step|list/ ) {
61 if (
62 not
63 defined @{ $self->{config}->{points} }[ $self->{iterator} + 1 ] )
64 {
65 return 1;
66 }
67 else {
68 return 0;
69 }
70 }
71 }
72  
73 sub get_value {
74 my $self = shift;
75 return $self->{config}->{instrument}->get_pulselength();
76 }
77  
78 sub exit {
79 my $self = shift;
80 $self->{config}->{instrument}->abort();
81 }
82  
83 1;
84  
85 __END__