File Coverage

blib/lib/Lab/XPRESS/Sweep/Power.pm
Criterion Covered Total %
statement 11 36 30.5
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 11 36.3
pod 1 7 14.2
total 16 61 26.2


line stmt bran cond sub pod time code
1             package Lab::XPRESS::Sweep::Power;
2             #ABSTRACT: Signal generator power sweep
3             $Lab::XPRESS::Sweep::Power::VERSION = '3.880';
4 1     1   1711 use v5.20;
  1         4  
5              
6 1     1   8 use Lab::XPRESS::Sweep;
  1         2  
  1         30  
7 1     1   6 use Time::HiRes qw/usleep/, qw/time/;
  1         3  
  1         8  
8 1     1   100 use strict;
  1         2  
  1         481  
9              
10             our @ISA = ('Lab::XPRESS::Sweep');
11              
12             sub new {
13 0     0 0   my $proto = shift;
14 0           my @args = @_;
15 0   0       my $class = ref($proto) || $proto;
16             my $self->{default_config} = {
17 0           id => 'Power_Sweep',
18             filename_extension => 'POW=',
19             interval => 1,
20             points => [],
21             rate => [1],
22             mode => 'step',
23             allowed_instruments => [
24             'Lab::Instrument::HP83732A', 'Lab::Instrument::MG369xB',
25             'Lab::Instrument::RSSMB100A'
26             ],
27             allowed_sweep_modes => [ 'list', 'step' ],
28             number_of_points => [undef]
29             };
30              
31 0           $self = $class->SUPER::new( $self->{default_config}, @args );
32 0           bless( $self, $class );
33              
34 0           return $self;
35             }
36              
37             sub go_to_sweep_start {
38 0     0 0   my $self = shift;
39              
40             # go to start:
41             $self->{config}->{instrument}
42 0           ->set_power( { value => @{ $self->{config}->{points} }[0] } );
  0            
43             }
44              
45             sub start_continuous_sweep {
46 0     0 0   my $self = shift;
47              
48 0           return;
49              
50             }
51              
52             sub go_to_next_step {
53 0     0 0   my $self = shift;
54              
55             $self->{config}->{instrument}->set_power(
56 0           { value => @{ $self->{config}->{points} }[ $self->{iterator} ] } );
  0            
57              
58             }
59              
60             sub exit_loop {
61 0     0 0   my $self = shift;
62              
63 0 0         if ( $self->{config}->{mode} =~ /step|list/ ) {
64 0 0         if (
65             not
66 0           defined @{ $self->{config}->{points} }[ $self->{iterator} + 1 ] )
67             {
68 0           return 1;
69             }
70             else {
71 0           return 0;
72             }
73             }
74             }
75              
76             sub get_value {
77 0     0 1   my $self = shift;
78 0           return $self->{config}->{instrument}->get_power();
79             }
80              
81             sub exit {
82 0     0 0   my $self = shift;
83 0           $self->{config}->{instrument}->abort();
84             }
85              
86             1;
87              
88             __END__
89              
90             =pod
91              
92             =encoding UTF-8
93              
94             =head1 NAME
95              
96             Lab::XPRESS::Sweep::Power - Signal generator power sweep
97              
98             =head1 VERSION
99              
100             version 3.880
101              
102             =head1 SYNOPSIS
103              
104             use Lab::XPRESS::hub;
105             my $hub = new Lab::XPRESS::hub();
106            
107            
108             my $Osc = $hub->Instrument('HP83732A',
109             {
110             connection_type => 'VISA_GPIB',
111             gpib_address => 2
112             });
113            
114             my $sweep_voltage = $hub->Sweep('Power',
115             {
116             instrument => $Osc,
117             points => [0,10],
118             stepwidth => [1],
119             mode => 'step',
120             backsweep => 0
121             });
122              
123             .
124              
125             =head1 DESCRIPTION
126              
127             Parent: Lab::XPRESS::Sweep
128              
129             The Lab::XPRESS::Sweep::Power class implements a module for power sweeps in the Lab::XPRESS::Sweep framework.
130              
131             .
132              
133             =head1 CONSTRUCTOR
134              
135             my $sweep_voltage = $hub->Sweep('Power',
136             {
137             instrument => $Osc,
138             points => [100,1e5],
139             stepwidth => [1e5,100],
140             mode => 'step',
141             backsweep => 0
142             });
143              
144             Instantiates a new power sweep.
145              
146             .
147              
148             =head1 PARAMETERS
149              
150             =head2 instrument [Lab::Instrument] (mandatory)
151              
152             Instrument, conducting the sweep. Must be of type Lab:Instrument.
153             Allowed instruments: Lab::Instrument::SignalRecovery726x
154              
155             .
156              
157             =head2 mode [string] (default = 'step' | 'list')
158              
159             step: measurements will be performed at discrete values of the power between start and end points defined in parameter points, seperated by steps defined in parameter stepwidth
160              
161             list: measurements will be performed at a list frequencies defined in parameter points
162              
163             .
164              
165             =head2 points [float array] (mandatory)
166              
167             array of values (in Hz) that defines the characteristic points of the sweep.
168             First value is appraoched before measurement begins.
169              
170             Case mode => 'step' :
171             Same as in 'continuous' but power will be swept in stop and go mode.
172              
173             Case mode => 'list' :
174             Array of values, with minimum length 1, that are approached in sequence to perform a measurment.
175              
176             .
177              
178             =head2 stepwidth [float array]
179              
180             This parameter is relevant only if mode = 'step' has been selected.
181             Stepwidth has to be an array of length '1' or greater. The values define the width for each step within the corresponding sweep sequence.
182             If the length of the defined sweep sequence devided by the stepwidth is not an integer number, the last step will be smaller in order to reach the defined points-value.
183              
184             points = [100, 3000, 300]
185             stepwidth = [500, 1000]
186            
187             ==> steps: 100, 600, 1100, 1600, 2100, 2600, 3000, 2000, 1000, 300
188              
189             .
190              
191             =head2 number_of_points [int array]
192              
193             can be used instead of 'stepwidth'. Attention: Use only the 'number_of_points' or the 'stepwidth' parameter. Using both will cause an Error!
194             This parameter is relevant only if mode = 'step' has been selected.
195             Number_of_points has to be an array of length '1' or greater. The values defines the number of steps within the corresponding sweep sequence.
196              
197             points = [100, 3000, 300]
198             number_of_points = [10, 2]
199            
200             ==> steps: 100, 390, 680, 970, 1260, 1550, 1840, 2130, 2420, 2710, 3000, 1650, 300
201              
202             =head2 backsweep [int] (default = 0 | 1 | 2)
203              
204             0 : no backsweep (default)
205             1 : a backsweep will be performed
206             2 : no backsweep performed automatically, but sweep sequence will be reverted every second time the sweep is started (relevant eg. if sweep operates as a slave. This way the sweep sequence is reverted at every second step of the master)
207              
208             =head2 id [string] (default = 'Power_Sweep')
209              
210             Just an ID.
211              
212             =head2 filename_extention [string] (default = 'FRQ=')
213              
214             Defines a postfix, that will be appended to the filenames if necessary.
215              
216             =head2 delay_before_loop [int] (default = 0)
217              
218             defines the time in seconds to wait after the starting point has been reached.
219              
220             =head2 delay_in_loop [int] (default = 0)
221              
222             This parameter is relevant only if mode = 'step' or 'list' has been selected.
223             Defines the time in seconds to wait after the value for the next step has been reached.
224              
225             =head2 delay_after_loop [int] (default = 0)
226              
227             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.
228              
229             =head1 CAVEATS/BUGS
230              
231             probably none
232              
233             =head1 SEE ALSO
234              
235             =over 4
236              
237             =item L<Lab::XPRESS::Sweep>
238              
239             =back
240              
241             =head1 COPYRIGHT AND LICENSE
242              
243             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
244              
245             Copyright 2013 Alois Dirnaichner, Andreas K. Huettel, Christian Butschkow, Stefan Geissler
246             2014 Andreas K. Huettel
247             2016 Simon Reinhardt
248             2017 Andreas K. Huettel
249             2020 Andreas K. Huettel
250              
251              
252             This is free software; you can redistribute it and/or modify it under
253             the same terms as the Perl 5 programming language system itself.
254              
255             =cut