XPRESS/Sweep/Repeater.pm

filter: Statementstmt 38.8% 14 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 35.8% 19 / 53 SCAR 21.9
CC
4
Cov
33%
new
12.0
get_value
6.0
BEGIN
1.0
CRAP 8.9
« Moose/Countdown.pm ↑ Summary Moose/Instrument/AH2700A.pm »
1 package Lab::XPRESS::Sweep::Repeater;
2 #ABSTRACT: Simple repeater
3 1 $Lab::XPRESS::Sweep::Repeater::VERSION = '3.881';
4 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Lab::XPRESS::Sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Time::HiRes qw/usleep/, qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @ISA = ('Lab::XPRESS::Sweep');
11  
12 sub new {
13 0 ▶ my $proto = shift;
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
14 0 my @args = @_;
15 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
16 my $self->{default_config} = {
17 0 id => 'Repeater',
18 filename_extension => '#',
19 repetitions => 1,
20 stepwidth => 1,
21 points => [1],
22 rate => [1],
23 mode => 'list',
24 allowed_sweep_modes => ['list'],
25 backsweep => 0,
26 values => undef,
27 };
28  
29 0 $self = $class->SUPER::new( $self->{default_config}, @args );
30 0 bless( $self, $class );
31 0 $self->{config}->{points} = [1];
32 0 $self->{config}->{duration} = [1];
33  
34 0 ▶ if ( ref( $self->{config}->{repetitions} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"config"}{"repetitions"} eq "ARRAY") 0 0 0
35 0 $self->{config}->{values} = $self->{config}->{repetitions};
36 $self->{config}->{repetitions}
37 0 = scalar @{ $self->{config}->{repetitions} };
38 }
39  
40 0 $self->{config}->{mode} = 'list';
41 0 $self->{loop}->{interval} = $self->{config}->{interval};
42  
43 0 $self->{DataFile_counter} = 0;
44  
45 0 $self->{DataFiles} = ();
46  
47 0 return $self;
48 }
49  
50 sub get_value {
51 0 ▶ my $self = shift;
Subroutine get_value: not called CC=2 SCAR=17.9
Pod documented
52  
53 0 ▶ if ( defined $self->{config}->{values} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'config'}{'values'}) { } 0 0 0
54 0 return @{ $self->{config}->{values} }[ $self->{repetition} - 1 ];
55 }
56 else {
57 0 return $self->{repetition};
58 }
59 }
60  
61 1 1;
62  
63 __END__
64  
65 =pod
66  
67 =encoding UTF-8
68  
69 =head1 NAME
70  
71 Lab::XPRESS::Sweep::Repeater - Simple repeater
72  
73 =head1 VERSION
74  
75 version 3.881
76  
77 =head1 SYNOPSIS
78  
79 use Lab::XPRESS::hub;
80 my $hub = new Lab::XPRESS::hub();
81
82
83
84 my $repeater = $hub->Sweep('Repeater',
85 {
86 repetitions => 5
87 });
88  
89 =head1 DESCRIPTION
90  
91 Parent: Lab::XPRESS::Sweep
92  
93 The Lab::XPRESS::Sweep::Repeater class implements a simple repeater module in the Lab::XPRESS::Sweep framework.
94  
95 =head1 CONSTRUCTOR
96  
97 my $repeater = $hub->Sweep('Repeater',
98 {
99 repetitions => 5
100 });
101  
102 Instantiates a new repeater with 5 repetitions. Alternatively
103  
104 my $repeater_array = $hub->Sweep('Repeater',
105 {
106 repetitions => [10, 20, 30, 40, 50]
107 });
108  
109 Instantiates also a repeater with 5 repetitions. However, the function
110  
111 $repeater->get_value(); # <-- returns 1,2,3,4,5 depending on the repetition,
112 $repeater->get_array(); # <-- returns 10,20,30,40,50 depending on the repetition.
113 .
114  
115 =head1 PARAMETERS
116  
117 =head2 repetitions [int / array] (default = 1)
118  
119 number of repetitions. default value is 1, negative values indicate a infinit number of repetitions.
120 When an array is given, the number of reetitions corresponds to the length of the array.
121  
122 =head2 id [string] (default = 'Repeater')
123  
124 Just an ID.
125  
126 =head2 filename_extention [string] (default = '#=')
127  
128 Defines a postfix, that will be appended to the filenames if necessary.
129  
130 =head2 delay_before_loop [float] (default = 0)
131  
132 defines the time in seconds to wait after the starting point has been reached.
133  
134 =head2 delay_in_loop [float] (default = 0)
135  
136 This parameter is relevant only if mode = 'step' or 'list' has been selected.
137 Defines the time in seconds to wait after the value for the next step has been reached.
138  
139 =head2 delay_after_loop [float] (default = 0)
140  
141 Defines the time in seconds to wait after the sweep has been finished. This delay will be executed before an optional backsweep or optional repetitions of the sweep.
142  
143 =head1 METHODS
144  
145 =head2 get_value()
146  
147 Returns an integer number n corresponding to the nth repetition or if an array @a was given for the parameter 'repetitions' it returns @a[n].
148  
149 =head1 CAVEATS/BUGS
150  
151 probably none
152  
153 =head1 SEE ALSO
154  
155 =over 4
156  
157 =item L<Lab::XPRESS::Sweep>
158  
159 =back
160  
161 =head1 COPYRIGHT AND LICENSE
162  
163 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
164  
165 Copyright 2012 Stefan Geissler
166 2013 Andreas K. Huettel, Christian Butschkow, Stefan Geissler
167 2015 Christian Butschkow
168 2016 Simon Reinhardt
169 2017 Andreas K. Huettel
170 2020 Andreas K. Huettel
171  
172  
173 This is free software; you can redistribute it and/or modify it under
174 the same terms as the Perl 5 programming language system itself.
175  
176 =cut
« Moose/Countdown.pm ↑ Summary Moose/Instrument/AH2700A.pm »