line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::XPRESS::Data::XPRESS_logger; |
2
|
|
|
|
|
|
|
#ABSTRACT: XPRESS logging module |
3
|
|
|
|
|
|
|
$Lab::XPRESS::Data::XPRESS_logger::VERSION = '3.881'; |
4
|
8
|
|
|
8
|
|
105
|
use v5.20; |
|
8
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
55
|
use Time::HiRes qw/usleep/, qw/time/; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
56
|
|
8
|
8
|
|
|
8
|
|
886
|
use strict; |
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
208
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
5008
|
use Lab::XPRESS::Data::XPRESS_plotter; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
305
|
|
11
|
8
|
|
|
8
|
|
62
|
use Carp; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
526
|
|
12
|
8
|
|
|
8
|
|
65
|
use File::Path 'make_path'; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
21718
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
0
|
6
|
my $proto = shift; |
16
|
2
|
|
33
|
|
|
11
|
my $class = ref($proto) || $proto; |
17
|
2
|
|
|
|
|
4
|
my $filenamebase = shift; |
18
|
2
|
|
|
|
|
4
|
my $plots = shift; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
5
|
my $self = {}; |
21
|
2
|
|
|
|
|
6
|
bless( $self, $class ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
( $self->{filehandle}, $self->{filename}, $self->{directory} ) |
24
|
2
|
|
|
|
|
11
|
= $self->open_file($filenamebase); |
25
|
2
|
|
|
|
|
11
|
$self->{block_num} = 0; |
26
|
2
|
|
|
|
|
7
|
$self->{line_num} = 0; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# check if $plots is an ARRAY-REF or just a single plot |
29
|
2
|
|
|
|
|
4
|
my $num_of_plots; |
30
|
2
|
50
|
|
|
|
16
|
if ( not defined $plots ) { |
|
|
50
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$num_of_plots = 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( ref($plots) eq 'ARRAY' ) { |
34
|
2
|
|
|
|
|
8
|
$self->{plots} = $plots; |
35
|
2
|
|
|
|
|
4
|
$num_of_plots = @{ $self->{plots} }; |
|
2
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
0
|
$self->{plots} = [$plots]; |
39
|
0
|
|
|
|
|
0
|
$num_of_plots = @{ $self->{plots} }; |
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# create gnuplot-pipes for each plot: |
43
|
2
|
|
|
|
|
12
|
for ( my $i = 0; $i < $num_of_plots; $i++ ) { |
44
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter} |
45
|
|
|
|
|
|
|
= new Lab::XPRESS::Data::XPRESS_plotter( |
46
|
|
|
|
|
|
|
$self->{filename}, |
47
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i] |
48
|
|
|
|
|
|
|
); |
49
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{ID} = $i; |
50
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{FILENAME} = $self->{filename}; |
51
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter}->{COLUMN_NAMES} |
52
|
0
|
|
|
|
|
0
|
= $self->{COLUMN_NAMES}; |
53
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{BLOCK_NUM} = $self->{block_num}; |
54
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{LINE_NUM} = $self->{line_num}; |
55
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->init_gnuplot(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
10
|
return $self; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub open_file { |
63
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
64
|
2
|
|
|
|
|
5
|
my $filenamebase = shift; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# split directory/filname .. |
67
|
2
|
50
|
|
|
|
28
|
if ( $filenamebase =~ /(.+)(\/|\/\/|\\|\\\\)(.+)\b/ ) { |
68
|
2
|
|
|
|
|
8
|
my $directory = $1; |
69
|
2
|
|
|
|
|
8
|
my $filename = $3; |
70
|
2
|
|
|
|
|
5
|
my $filenameextension = ".dat"; |
71
|
2
|
50
|
|
|
|
13
|
if ( $filename =~ /(.+)(\..+)\b/ ) { |
72
|
2
|
|
|
|
|
6
|
$filename = $1; |
73
|
2
|
|
|
|
|
6
|
$filenameextension = $2; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#print "$directory $filename $filenameextension\n"; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# create directory if it doesn't exist: |
79
|
2
|
50
|
|
|
|
34
|
if ( not -d $directory ) { |
80
|
0
|
|
|
|
|
0
|
carp "directory given by $filenamebase doesn't exist." |
81
|
|
|
|
|
|
|
. "Creating directory $directory"; |
82
|
0
|
0
|
|
|
|
0
|
make_path $directory |
83
|
|
|
|
|
|
|
or croak "cannot create path $directory: $!"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# look for existing files: |
87
|
2
|
|
|
|
|
41
|
opendir( DIR, $directory ); |
88
|
2
|
|
|
|
|
55
|
my @files = readdir(DIR); |
89
|
2
|
|
|
|
|
8
|
my $max_index = 0; |
90
|
2
|
|
|
|
|
7
|
foreach my $file (@files) { |
91
|
|
|
|
|
|
|
|
92
|
8
|
|
|
|
|
14
|
my $temp_filename = $filename; |
93
|
8
|
|
|
|
|
17
|
$temp_filename =~ s/\(/\\\(/g; |
94
|
8
|
|
|
|
|
12
|
$temp_filename =~ s/\)/\\\)/g; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#print $temp_filename."\n"; |
97
|
8
|
50
|
|
|
|
72
|
if ( $file =~ /($temp_filename)(_(\d+))?($filenameextension)\b/ ) |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
0
|
|
|
|
0
|
if ( $3 > $max_index ) { |
|
|
0
|
|
|
|
|
|
100
|
0
|
|
|
|
|
0
|
$max_index = $3; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
elsif ( not defined $3 ) { |
103
|
0
|
|
|
|
|
0
|
$max_index = 1; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
2
|
|
|
|
|
24
|
closedir(DIR); |
109
|
2
|
|
|
|
|
12
|
$max_index++; |
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
6
|
my $file_data; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# open new file: |
114
|
2
|
50
|
|
|
|
10
|
if ( $max_index > 1 ) { |
115
|
0
|
|
|
|
|
0
|
$file_data = sprintf( |
116
|
|
|
|
|
|
|
"%s/%s_%03d%s", |
117
|
|
|
|
|
|
|
$directory, $filename, $max_index, $filenameextension |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
2
|
|
|
|
|
14
|
$file_data = sprintf( |
122
|
|
|
|
|
|
|
"%s/%s%s", $directory, $filename, |
123
|
|
|
|
|
|
|
$filenameextension |
124
|
|
|
|
|
|
|
); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
2
|
50
|
|
|
|
153
|
open( my $LOG, ">" . $file_data ) or die "cannot open $file_data"; |
128
|
2
|
|
|
|
|
18
|
my $old_fh = select($LOG); |
129
|
2
|
|
|
|
|
10
|
$| = 1; |
130
|
2
|
|
|
|
|
19
|
select($old_fh); |
131
|
2
|
|
|
|
|
176
|
print "Output file is \"$file_data\"\n"; |
132
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
40
|
return ( $LOG, $file_data, $directory ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub close_file { |
139
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
0
|
my $file = $self->{filehandle}; |
142
|
0
|
|
|
|
|
0
|
close $file; |
143
|
0
|
|
|
|
|
0
|
delete $self->{filehandle}; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
return $self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub add_plots { |
149
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
150
|
0
|
|
|
|
|
0
|
my $plots = shift; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# check if $plots is an ARRAY-REF or just a single plot |
153
|
|
|
|
|
|
|
#print "$self->{plots}"; |
154
|
0
|
|
|
|
|
0
|
my $num_of_plots = @{ $self->{plots} }; |
|
0
|
|
|
|
|
0
|
|
155
|
0
|
|
|
|
|
0
|
my $allready_existing_plots = $num_of_plots; |
156
|
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
0
|
if ( not defined $plots ) { |
|
|
0
|
|
|
|
|
|
158
|
0
|
|
|
|
|
0
|
return $num_of_plots; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
elsif ( ref($plots) eq 'ARRAY' ) { |
161
|
0
|
|
|
|
|
0
|
foreach ( @{$plots} ) { |
|
0
|
|
|
|
|
0
|
|
162
|
0
|
|
|
|
|
0
|
push( @{ $self->{plots} }, $_ ); |
|
0
|
|
|
|
|
0
|
|
163
|
|
|
|
|
|
|
} |
164
|
0
|
|
|
|
|
0
|
$num_of_plots = @{ $self->{plots} }; |
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
else { |
167
|
0
|
|
|
|
|
0
|
push( @{ $self->{plots} }, $plots ); |
|
0
|
|
|
|
|
0
|
|
168
|
0
|
|
|
|
|
0
|
$num_of_plots = @{ $self->{plots} }; |
|
0
|
|
|
|
|
0
|
|
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# foreach my $plot (@{$self->{plots}}) |
172
|
|
|
|
|
|
|
# { |
173
|
|
|
|
|
|
|
# foreach (@{$plot->{'y-axis'}}) |
174
|
|
|
|
|
|
|
# { |
175
|
|
|
|
|
|
|
# print "y-axis = ".$_."\n"; |
176
|
|
|
|
|
|
|
# } |
177
|
|
|
|
|
|
|
# } |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# create gnuplot-pipes for each plot: |
180
|
0
|
|
|
|
|
0
|
for ( my $i = $allready_existing_plots; $i < $num_of_plots; $i++ ) { |
181
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter} |
182
|
|
|
|
|
|
|
= new Lab::XPRESS::Data::XPRESS_plotter( |
183
|
|
|
|
|
|
|
$self->{filename}, |
184
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i] |
185
|
|
|
|
|
|
|
); |
186
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{ID} = $i; |
187
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{FILENAME} = $self->{filename}; |
188
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter}->{COLUMN_NAMES} |
189
|
0
|
|
|
|
|
0
|
= $self->{COLUMN_NAMES}; |
190
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter}->{NUMBER_OF_COLUMNS} |
191
|
0
|
|
|
|
|
0
|
= $self->{NUMBER_OF_COLUMNS}; |
192
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{BLOCK_NUM} = $self->{block_num}; |
193
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->{LINE_NUM} = $self->{line_num}; |
194
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->init_gnuplot(); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
0
|
return $self; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub _log_start_block { |
201
|
2
|
|
|
2
|
|
12
|
my $self = shift; |
202
|
2
|
|
|
|
|
4
|
my @plots = @{ $self->{plots} }; |
|
2
|
|
|
|
|
15
|
|
203
|
|
|
|
|
|
|
|
204
|
2
|
|
|
|
|
7
|
my $fh = $self->{filehandle}; |
205
|
2
|
50
|
|
|
|
8
|
if ( $self->{block_num} ) { |
206
|
0
|
|
|
|
|
0
|
$self->LOG('NEW_BLOCK'); |
207
|
|
|
|
|
|
|
} |
208
|
2
|
|
|
|
|
5
|
$self->{block_num}++; |
209
|
2
|
|
|
|
|
5
|
$self->{line_num} = 0; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#my $num_of_plots = @plots; |
212
|
|
|
|
|
|
|
#for( my $i = 0; $i < $num_of_plots; $i++) |
213
|
|
|
|
|
|
|
# { |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
#if ( $self->{plots}->[$i]->{'type'} =~/\b(linetrace|LINETRACE|trace|TRACE)\b/ ) |
216
|
|
|
|
|
|
|
# { |
217
|
|
|
|
|
|
|
# my $filename = $self->{filename}; |
218
|
|
|
|
|
|
|
# if ( defined $self->{plots}->[$i]->{plotter}->{'started'}) |
219
|
|
|
|
|
|
|
# { |
220
|
|
|
|
|
|
|
# $self->{plots}->[$i]->{plotter}->{linetrace_logger}->close_file(); |
221
|
|
|
|
|
|
|
# delete $self->{plots}->[$i]->{plotter}; |
222
|
|
|
|
|
|
|
# print "delete plotter\n"; |
223
|
|
|
|
|
|
|
# } |
224
|
|
|
|
|
|
|
# my $block_num = $self->{'block_num'}; |
225
|
|
|
|
|
|
|
# $filename =~ /\b(.+)\.(.+)\b/; |
226
|
|
|
|
|
|
|
# my $linetrace = sprintf("%s_linetrace", $1); |
227
|
|
|
|
|
|
|
# $self->{plots}->[$i]->{plotter} = new Lab::Data::SG_plotter($linetrace,$self->{plots}->[$i]); |
228
|
|
|
|
|
|
|
# $self->{plots}->[$i]->{plotter}->{linetrace_logger} = new Lab::Data::SG_logger($linetrace, $self->{plots}->[$i]); |
229
|
|
|
|
|
|
|
# } |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# } |
232
|
|
|
|
|
|
|
|
233
|
2
|
50
|
|
|
|
15
|
if ( $self->{block_num} == 1 ) { |
|
|
0
|
|
|
|
|
|
234
|
2
|
|
|
|
|
6
|
foreach my $plot ( @{ $self->{plots} } ) { |
|
2
|
|
|
|
|
9
|
|
235
|
0
|
|
|
|
|
0
|
$plot->{plotter}->init_gnuplot_bindings(); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
elsif ( $self->{block_num} > 1 ) { |
239
|
0
|
|
|
|
|
0
|
foreach my $plot ( @{ $self->{plots} } ) { |
|
0
|
|
|
|
|
0
|
|
240
|
0
|
|
|
|
|
0
|
$plot->{plotter}->start_plot( $self->{block_num} ); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
2
|
|
|
|
|
9
|
return $self->{block_num}; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub LOG { |
248
|
46
|
|
|
46
|
0
|
75
|
my $self = shift; |
249
|
46
|
|
|
|
|
73
|
my $data = shift; |
250
|
|
|
|
|
|
|
|
251
|
46
|
|
|
|
|
71
|
my $filehandle = $self->{filehandle}; |
252
|
46
|
|
|
|
|
73
|
$self->{line_num}++; |
253
|
|
|
|
|
|
|
|
254
|
46
|
100
|
|
|
|
195
|
if ( $data =~ /^#/ ) { |
|
|
50
|
|
|
|
|
|
255
|
2
|
|
|
|
|
66
|
print $filehandle $data . "\n"; |
256
|
2
|
|
|
|
|
16
|
return 1; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
elsif ( $data eq 'NEW_BLOCK' ) { |
259
|
0
|
|
|
|
|
0
|
print $filehandle "\n"; |
260
|
0
|
|
|
|
|
0
|
return 1; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# log data: |
264
|
44
|
50
|
|
|
|
114
|
if ( ref($data) eq 'ARRAY' ) { |
|
|
50
|
|
|
|
|
|
265
|
0
|
|
|
|
|
0
|
my @data = @$data; |
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
0
|
my $number_of_columns = 0; |
268
|
0
|
|
|
|
|
0
|
foreach my $item (@data) { |
269
|
0
|
0
|
|
|
|
0
|
if ( ref($item) eq 'ARRAY' ) { |
270
|
0
|
|
|
|
|
0
|
$number_of_columns++; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
else { |
273
|
0
|
|
|
|
|
0
|
last; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
0
|
0
|
|
|
|
0
|
if ( $number_of_columns >= 1 ) { |
278
|
0
|
|
|
|
|
0
|
my $j = 0; |
279
|
0
|
|
|
|
|
0
|
while ( defined $data[0][$j] ) { |
280
|
0
|
|
|
|
|
0
|
for ( my $i = 0; $i < $number_of_columns; $i++ ) { |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# if ($data[$i][$j] =~ /[[:alpha:]]/ or not $data[$i][$j] =~ /[[:alnum:]]/) |
283
|
|
|
|
|
|
|
# { |
284
|
|
|
|
|
|
|
# print $filehandle $data[$i][$j]."\t"; |
285
|
|
|
|
|
|
|
# #print $data[$i][$j]."\t"; |
286
|
|
|
|
|
|
|
# } |
287
|
|
|
|
|
|
|
# else |
288
|
|
|
|
|
|
|
# { |
289
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\t",$data[$i][$j]); |
290
|
|
|
|
|
|
|
# #print sprintf("%.6e\t",$data[$i][$j]); |
291
|
|
|
|
|
|
|
# } |
292
|
0
|
0
|
|
|
|
0
|
if ( $data[$i][$j] |
293
|
|
|
|
|
|
|
=~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) { |
294
|
0
|
|
|
|
|
0
|
print $filehandle sprintf( "%+.6e\t", $data[$i][$j] ); |
295
|
0
|
0
|
0
|
|
|
0
|
if ( $data[$i][$j] < $self->{DATA}[$i][0] |
|
|
0
|
0
|
|
|
|
|
296
|
|
|
|
|
|
|
or not defined $self->{DATA}[$i][0] ) { |
297
|
0
|
|
|
|
|
0
|
$self->{DATA}[$i][0] = $data[$i][$j]; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
elsif ( $data[$i][$j] > $self->{DATA}[$i][1] |
300
|
|
|
|
|
|
|
or not defined $self->{DATA}[$i][0] ) { |
301
|
0
|
|
|
|
|
0
|
$self->{DATA}[$i][1] = $data[$i][$j]; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$data[$i][$j]); |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
else { |
307
|
0
|
|
|
|
|
0
|
print $filehandle $data[$i][$j] . "\t"; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
#print $data[$i][$j]."\t"; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
} |
312
|
0
|
|
|
|
|
0
|
print $filehandle "\n"; |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
#print "\n"; |
315
|
0
|
|
|
|
|
0
|
$j++; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
else { |
320
|
0
|
|
|
|
|
0
|
my $i = 0; |
321
|
0
|
|
|
|
|
0
|
foreach my $value (@data) { |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
# if ($value =~ /[[:alpha:]]/ or not $value =~ /[[:alnum:]]/) |
324
|
|
|
|
|
|
|
# { |
325
|
|
|
|
|
|
|
# print $filehandle $value."\t"; |
326
|
|
|
|
|
|
|
# #print $value."\t"; |
327
|
|
|
|
|
|
|
# } |
328
|
|
|
|
|
|
|
# else |
329
|
|
|
|
|
|
|
# { |
330
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\t",$value); |
331
|
|
|
|
|
|
|
# #print sprintf("%.6e\t",$value); |
332
|
|
|
|
|
|
|
# } |
333
|
0
|
0
|
|
|
|
0
|
if ( $value |
334
|
|
|
|
|
|
|
=~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) { |
335
|
0
|
|
|
|
|
0
|
print $filehandle sprintf( "%+.6e\t", $value ); |
336
|
0
|
0
|
0
|
|
|
0
|
if ( $value < $self->{DATA}[$i][0] |
|
|
0
|
0
|
|
|
|
|
337
|
|
|
|
|
|
|
or not defined $self->{DATA}[$i][0] ) { |
338
|
0
|
|
|
|
|
0
|
$self->{DATA}[$i][0] = $value; |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
elsif ( $value > $self->{DATA}[$i][1] |
341
|
|
|
|
|
|
|
or not defined $self->{DATA}[$i][0] ) { |
342
|
0
|
|
|
|
|
0
|
$self->{DATA}[$i][1] = $value; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$value); |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
else { |
348
|
0
|
|
|
|
|
0
|
print $filehandle $value . "\t"; |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
#print $value."\t"; |
351
|
|
|
|
|
|
|
} |
352
|
0
|
|
|
|
|
0
|
$i++; |
353
|
|
|
|
|
|
|
} |
354
|
0
|
|
|
|
|
0
|
print $filehandle "\n"; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
#print "\n"; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
elsif ( ref($data) eq 'HASH' ) { |
361
|
44
|
|
|
|
|
70
|
my @logline; |
362
|
44
|
|
|
|
|
61
|
while ( my ( $key, $value ) = each %{ $self->{COLUMN_NAMES} } ) { |
|
154
|
|
|
|
|
448
|
|
363
|
110
|
|
|
|
|
224
|
$logline[$value] = $data->{$key}; |
364
|
|
|
|
|
|
|
} |
365
|
44
|
|
|
|
|
72
|
shift @logline; |
366
|
44
|
|
|
|
|
211
|
my $logline = join( "\t", @logline ); |
367
|
44
|
|
|
|
|
923
|
print $filehandle $logline . "\n"; |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
else { |
371
|
|
|
|
|
|
|
# if ($data =~ /[[:alpha:]]/ or not $data =~ /[[:alnum:]]/) |
372
|
|
|
|
|
|
|
# { |
373
|
|
|
|
|
|
|
# print $filehandle $data."\t"; |
374
|
|
|
|
|
|
|
# #print $value."\t"; |
375
|
|
|
|
|
|
|
# } |
376
|
|
|
|
|
|
|
# else |
377
|
|
|
|
|
|
|
# { |
378
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\t",$data); |
379
|
|
|
|
|
|
|
# #print sprintf("%.6e\t",$value); |
380
|
|
|
|
|
|
|
# } |
381
|
0
|
0
|
|
|
|
0
|
if ( $data =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) { |
382
|
0
|
|
|
|
|
0
|
print $filehandle sprintf( "%+.6e\t", $data ); |
383
|
0
|
0
|
0
|
|
|
0
|
if ( $data < $self->{DATA}[0][0] |
|
|
0
|
0
|
|
|
|
|
384
|
|
|
|
|
|
|
or not defined $self->{DATA}[0][0] ) { |
385
|
0
|
|
|
|
|
0
|
$self->{DATA}[0][0] = $data; |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
elsif ( $data > $self->{DATA}[0][1] |
388
|
|
|
|
|
|
|
or not defined $self->{DATA}[0][0] ) { |
389
|
0
|
|
|
|
|
0
|
$self->{DATA}[0][1] = $data; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$value); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
else { |
395
|
0
|
|
|
|
|
0
|
print $filehandle $data . "\t"; |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
#print $value."\t"; |
398
|
|
|
|
|
|
|
} |
399
|
0
|
|
|
|
|
0
|
print $filehandle "\n"; |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
#print "\n"; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
# foreach my $item (@data) |
405
|
|
|
|
|
|
|
# { |
406
|
|
|
|
|
|
|
# if ( ref($item) eq 'ARRAY') |
407
|
|
|
|
|
|
|
# { |
408
|
|
|
|
|
|
|
# my @item = @$item; |
409
|
|
|
|
|
|
|
# |
410
|
|
|
|
|
|
|
# foreach my $value (@item) |
411
|
|
|
|
|
|
|
# { |
412
|
|
|
|
|
|
|
# if ($value =~ /[[:alpha:]]/ or not $value =~ /[[:alnum:]]/) |
413
|
|
|
|
|
|
|
# { |
414
|
|
|
|
|
|
|
# print $filehandle $value."\t"; |
415
|
|
|
|
|
|
|
# #print $value."\t"; |
416
|
|
|
|
|
|
|
# } |
417
|
|
|
|
|
|
|
# else |
418
|
|
|
|
|
|
|
# { |
419
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\t",$value); |
420
|
|
|
|
|
|
|
# #print sprintf("%.6e\t",$value); |
421
|
|
|
|
|
|
|
# } |
422
|
|
|
|
|
|
|
# } |
423
|
|
|
|
|
|
|
# print $filehandle "\n"; |
424
|
|
|
|
|
|
|
# #print "\n"; |
425
|
|
|
|
|
|
|
# } |
426
|
|
|
|
|
|
|
# else |
427
|
|
|
|
|
|
|
# { |
428
|
|
|
|
|
|
|
# if ( $item =~ /[[:alpha:]]/ or not $item =~ /[[:alnum:]]/) |
429
|
|
|
|
|
|
|
# { |
430
|
|
|
|
|
|
|
# print $filehandle $item."\t"; |
431
|
|
|
|
|
|
|
# #print $item."\t"; |
432
|
|
|
|
|
|
|
# } |
433
|
|
|
|
|
|
|
# else |
434
|
|
|
|
|
|
|
# { |
435
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\t",$item); |
436
|
|
|
|
|
|
|
# #print sprintf("%.6e\t",$item); |
437
|
|
|
|
|
|
|
# } |
438
|
|
|
|
|
|
|
# } |
439
|
|
|
|
|
|
|
# } |
440
|
|
|
|
|
|
|
# print $filehandle "\n"; |
441
|
|
|
|
|
|
|
# #print "\n"; |
442
|
|
|
|
|
|
|
# } |
443
|
|
|
|
|
|
|
# else |
444
|
|
|
|
|
|
|
# { |
445
|
|
|
|
|
|
|
# if ( $data =~ /[[:alpha:]]/ or not $data =~ /[[:alnum:]]/) |
446
|
|
|
|
|
|
|
# { |
447
|
|
|
|
|
|
|
# print $filehandle $data."\n"; |
448
|
|
|
|
|
|
|
# #print $data."\n"; |
449
|
|
|
|
|
|
|
# } |
450
|
|
|
|
|
|
|
# else |
451
|
|
|
|
|
|
|
# { |
452
|
|
|
|
|
|
|
# print $filehandle sprintf("%.6e\n",$data); |
453
|
|
|
|
|
|
|
# #print sprintf("%.6e\n",$data); |
454
|
|
|
|
|
|
|
# } |
455
|
|
|
|
|
|
|
# } |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# update plots: |
458
|
44
|
50
|
|
|
|
198
|
if ( not defined $self->{plots} ) { |
459
|
0
|
|
|
|
|
0
|
return 1; |
460
|
|
|
|
|
|
|
} |
461
|
44
|
|
|
|
|
103
|
my $number_of_plots = @{ $self->{plots} }; |
|
44
|
|
|
|
|
94
|
|
462
|
44
|
|
|
|
|
123
|
for ( my $i = 0; $i < $number_of_plots; $i++ ) { |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
# log data for linetrace-plots: |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
#if ( $self->{plots}->[$i]->{plotter}->{plot}->{'type'} =~ /\b(linetrace|LINETRACE|trace|TRACE)\b/ ) |
467
|
|
|
|
|
|
|
# { |
468
|
|
|
|
|
|
|
# $self->{plots}->[$i]->{plotter}->{linetrace_logger}->LOG_linetrace($data); |
469
|
|
|
|
|
|
|
# } |
470
|
|
|
|
|
|
|
|
471
|
0
|
0
|
|
|
|
0
|
if ( not defined $self->{plots}->[$i]->{plotter}->{plot}->{started} ) |
472
|
|
|
|
|
|
|
{ |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
# start plot: |
475
|
0
|
0
|
0
|
|
|
0
|
if ( $self->{plots}->[$i]->{plotter}->{plot}->{'type'} eq 'pm3d' |
476
|
|
|
|
|
|
|
and $self->{block_num} <= 1 ) { |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
# start plot later |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
else { |
481
|
|
|
|
|
|
|
$self->{plots}->[$i]->{plotter} |
482
|
0
|
|
|
|
|
0
|
->start_plot( $self->{block_num} ); |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
else { |
486
|
|
|
|
|
|
|
# replot: |
487
|
0
|
|
|
|
|
0
|
$self->{plots}->[$i]->{plotter}->replot(); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
44
|
|
|
|
|
144
|
return 1; |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub LOG_linetrace { |
497
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
498
|
0
|
|
|
|
|
|
my $data = shift; |
499
|
|
|
|
|
|
|
|
500
|
0
|
|
|
|
|
|
my $filehandle = $self->{filehandle}; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
# log data: |
503
|
0
|
0
|
|
|
|
|
if ( ref($data) eq 'ARRAY' ) { |
504
|
0
|
|
|
|
|
|
my @data = @$data; |
505
|
|
|
|
|
|
|
|
506
|
0
|
|
|
|
|
|
my $number_of_columns = 0; |
507
|
0
|
|
|
|
|
|
foreach my $item (@data) { |
508
|
0
|
0
|
|
|
|
|
if ( ref($item) eq 'ARRAY' ) { |
509
|
0
|
|
|
|
|
|
$number_of_columns++; |
510
|
|
|
|
|
|
|
} |
511
|
|
|
|
|
|
|
else { |
512
|
0
|
|
|
|
|
|
last; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
} |
515
|
|
|
|
|
|
|
|
516
|
0
|
0
|
|
|
|
|
if ( $number_of_columns >= 1 ) { |
517
|
0
|
|
|
|
|
|
my $j = 0; |
518
|
0
|
|
|
|
|
|
while ( defined $data[0][$j] ) { |
519
|
0
|
|
|
|
|
|
for ( my $i = 0; $i < $number_of_columns; $i++ ) { |
520
|
0
|
0
|
0
|
|
|
|
if ( $data[$i][$j] =~ /[[:alpha:]]/ |
521
|
|
|
|
|
|
|
or not $data[$i][$j] =~ /[[:alnum:]]/ ) { |
522
|
0
|
|
|
|
|
|
print $filehandle $data[$i][$j] . "\t"; |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
#print $data[$i][$j]."\t"; |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
else { |
527
|
0
|
|
|
|
|
|
print $filehandle sprintf( "%.6e\t", $data[$i][$j] ); |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$data[$i][$j]); |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
} |
532
|
0
|
|
|
|
|
|
print $filehandle "\n"; |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
#print "\n"; |
535
|
0
|
|
|
|
|
|
$j++; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
else { |
540
|
0
|
|
|
|
|
|
foreach my $value (@data) { |
541
|
0
|
0
|
0
|
|
|
|
if ( $value =~ /[[:alpha:]]/ or not $value =~ /[[:alnum:]]/ ) |
542
|
|
|
|
|
|
|
{ |
543
|
0
|
|
|
|
|
|
print $filehandle $value . "\t"; |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
#print $value."\t"; |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
else { |
548
|
0
|
|
|
|
|
|
print $filehandle sprintf( "%.6e\t", $value ); |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$value); |
551
|
|
|
|
|
|
|
} |
552
|
|
|
|
|
|
|
} |
553
|
0
|
|
|
|
|
|
print $filehandle "\n"; |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
#print "\n"; |
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
else { |
559
|
0
|
0
|
0
|
|
|
|
if ( $data =~ /[[:alpha:]]/ or not $data =~ /[[:alnum:]]/ ) { |
560
|
0
|
|
|
|
|
|
print $filehandle $data . "\t"; |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
#print $value."\t"; |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
else { |
565
|
0
|
|
|
|
|
|
print $filehandle sprintf( "%.6e\t", $data ); |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
#print sprintf("%.6e\t",$value); |
568
|
|
|
|
|
|
|
} |
569
|
0
|
|
|
|
|
|
print $filehandle "\n"; |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
#print "\n"; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
0
|
|
|
|
|
|
return 1; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
sub DESTROY { |
579
|
|
|
|
|
|
|
|
580
|
0
|
|
|
0
|
|
|
my $self = shift; |
581
|
|
|
|
|
|
|
|
582
|
0
|
|
|
|
|
|
foreach my $plot ( @{ $self->{plots} } ) { |
|
0
|
|
|
|
|
|
|
583
|
0
|
|
|
|
|
|
$plot->{plotter}->_stop_live_plot(); |
584
|
0
|
|
|
|
|
|
$plot->{plotter}; |
585
|
|
|
|
|
|
|
} |
586
|
0
|
|
|
|
|
|
$self->close_file(); |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
1; |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
__END__ |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=pod |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=encoding UTF-8 |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 NAME |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
Lab::XPRESS::Data::XPRESS_logger - XPRESS logging module |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=head1 VERSION |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
version 3.881 |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
Copyright 2012 Stefan Geissler |
610
|
|
|
|
|
|
|
2013 Andreas K. Huettel, Christian Butschkow, Stefan Geissler |
611
|
|
|
|
|
|
|
2016 Simon Reinhardt |
612
|
|
|
|
|
|
|
2017 Andreas K. Huettel |
613
|
|
|
|
|
|
|
2020 Andreas K. Huettel |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
617
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=cut |