line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::XPRESS::Sweep::LogBlock; |
2
|
|
|
|
|
|
|
#ABSTRACT: Sweep add-on for matrix logging |
3
|
|
|
|
|
|
|
$Lab::XPRESS::Sweep::LogBlock::VERSION = '3.881'; |
4
|
8
|
|
|
8
|
|
4478
|
use v5.20; |
|
8
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
47
|
use Role::Tiny; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
requires qw/LOG write_LOG/; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
1402
|
use Carp; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
500
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
57
|
use Data::Dumper; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
3215
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub LogBlock { |
17
|
11
|
|
|
11
|
0
|
5665
|
my $sweep = shift; |
18
|
|
|
|
|
|
|
|
19
|
11
|
50
|
|
|
|
38
|
if ( @_ % 2 != 0 ) { |
20
|
0
|
|
|
|
|
0
|
croak "expected hash"; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
36
|
my %args = @_; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
23
|
my $block = $args{block}; |
26
|
11
|
50
|
|
|
|
24
|
if ( not defined $block ) { |
27
|
0
|
|
|
|
|
0
|
croak "missing mandatory parameter 'block'"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
11
|
|
|
|
|
17
|
my $prefix = $args{prefix}; |
31
|
11
|
50
|
|
|
|
23
|
if ( not defined $prefix ) { |
32
|
0
|
|
|
|
|
0
|
$prefix = []; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
11
|
|
|
|
|
41
|
my $prefix_len = @$prefix; |
36
|
|
|
|
|
|
|
|
37
|
11
|
|
|
|
|
21
|
my $file = $args{datafile}; |
38
|
11
|
50
|
|
|
|
27
|
if ( not defined $file ) { |
39
|
11
|
|
|
|
|
18
|
$file = 0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
11
|
|
|
|
|
17
|
my $num_rows = @$block; |
43
|
11
|
|
|
|
|
15
|
my $row_len = @{ $block->[0] }; |
|
11
|
|
|
|
|
21
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Extract column header from the DataFile |
46
|
11
|
|
|
|
|
23
|
my $datafile = $sweep->{DataFiles}[$file]; |
47
|
11
|
|
|
|
|
37
|
my $columns = $datafile->add_column(); |
48
|
11
|
|
|
|
|
22
|
my $columns_len = @$columns; |
49
|
|
|
|
|
|
|
|
50
|
11
|
50
|
|
|
|
30
|
if ( $row_len + $prefix_len != $columns_len ) { |
51
|
0
|
|
|
|
|
0
|
croak "The datafile expects $columns_len columns.\n" |
52
|
|
|
|
|
|
|
. "You only supplied $prefix_len + $row_len columns."; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Write external parameters and block to datafile |
56
|
|
|
|
|
|
|
|
57
|
11
|
|
|
|
|
48
|
while ( my ( $i, $row ) = each(@$block) ) { |
58
|
33
|
|
|
|
|
51
|
my %log; |
59
|
33
|
|
|
|
|
124
|
unshift @$row, @$prefix; |
60
|
|
|
|
|
|
|
|
61
|
33
|
|
|
|
|
89
|
while ( my ( $j, $key ) = each(@$columns) ) { |
62
|
99
|
|
|
|
|
292
|
$log{$key} = $row->[$j]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
33
|
|
|
|
|
179
|
$sweep->LOG( {%log}, $file ); |
66
|
|
|
|
|
|
|
|
67
|
33
|
100
|
|
|
|
157
|
if ( $i != $num_rows - 1 ) { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# the last writeLOG is called in Sweep.pm |
70
|
22
|
|
|
|
|
57
|
$sweep->write_LOG(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Lab::XPRESS::Sweep::LogBlock - Sweep add-on for matrix logging |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 3.881 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# define your columns |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# parameters controlled by the XPRESS sweeps |
98
|
|
|
|
|
|
|
$DataFile->add_column('gate'); |
99
|
|
|
|
|
|
|
$DataFile->add_column('bias'); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# parameters in the block, here we have a block with 2 columns. |
102
|
|
|
|
|
|
|
$DataFile->add_column('frequency'); |
103
|
|
|
|
|
|
|
$DataFile->add_column('transmission'); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Define your sweeps ... |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# In your measurement subroutine: Get block and log |
108
|
|
|
|
|
|
|
$matrix = $instrument->get_block(...) |
109
|
|
|
|
|
|
|
$sweep->LogBlock( |
110
|
|
|
|
|
|
|
prefix => [$gate, $bias], |
111
|
|
|
|
|
|
|
block => $matrix); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 DESCRIPTION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This role exports the single method C<LogBlock>. The valid parameters are: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item block (mandatory) |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
List of rows (e.g. C<[[1, 2, 3], [2, 3, 4]]>), which shell be written |
122
|
|
|
|
|
|
|
to the data file. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item prefix |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
List of parameters which shell be prefixed to each row of the block. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item file |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Index of the target data file (default: 0). |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2016 Simon Reinhardt |
139
|
|
|
|
|
|
|
2017 Andreas K. Huettel |
140
|
|
|
|
|
|
|
2020 Andreas K. Huettel |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
144
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |