XPRESS/Data/XPRESS_logger.pm

filter: Statementstmt 42.0% 95 / 226 Branchbran 20.8% 20 / 96 Conditioncond 3.0% 1 / 33 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 71.4% 10 / 14 Podpod 0.0% 0 / 6 totaltotal 31.7% 126 / 397 SCAR 73.3
CC
69
Cov
33%
LOG
502.5
LOG_linetrace
210.0
add_plots
30.0
CRAP 1521.8
« Instrument/U2000.pm ↑ Summary Instrument.pm »
1 package Lab::XPRESS::Data::XPRESS_logger;
2 #ABSTRACT: XPRESS logging module
3 8 $Lab::XPRESS::Data::XPRESS_logger::VERSION = '3.881';
4 8 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 8 ▶use Time::HiRes qw/usleep/, qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use Lab::XPRESS::Data::XPRESS_plotter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use File::Path 'make_path';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 2 ▶ my $proto = shift;
Subroutine new: called CC=5 SCAR=19.7
Pod undocumented
16 2 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
17 2 my $filenamebase = shift;
18 2 my $plots = shift;
19  
20 2 my $self = {};
21 2 bless( $self, $class );
22  
23 ( $self->{filehandle}, $self->{filename}, $self->{directory} )
24 2 = $self->open_file($filenamebase);
25 2 $self->{block_num} = 0;
26 2 $self->{line_num} = 0;
27  
28 # check if $plots is an ARRAY-REF or just a single plot
29 2 my $num_of_plots;
30 2 ▶ if ( not defined $plots ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $plots) { } 0 2 2
elsif (ref $plots eq 'ARRAY') { } 2 0 2
31 0 $num_of_plots = 0;
32 }
33 elsif ( ref($plots) eq 'ARRAY' ) {
34 2 $self->{plots} = $plots;
35 2 $num_of_plots = @{ $self->{plots} };
36 }
37 else {
38 0 $self->{plots} = [$plots];
39 0 $num_of_plots = @{ $self->{plots} };
40 }
41  
42 # create gnuplot-pipes for each plot:
43 2 ▶ for ( my $i = 0; $i < $num_of_plots; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_of_plots) 0 2 2
44 $self->{plots}->[$i]->{plotter}
45 = new Lab::XPRESS::Data::XPRESS_plotter(
46 $self->{filename},
47 0 $self->{plots}->[$i]
48 );
49 0 $self->{plots}->[$i]->{plotter}->{ID} = $i;
50 0 $self->{plots}->[$i]->{plotter}->{FILENAME} = $self->{filename};
51 $self->{plots}->[$i]->{plotter}->{COLUMN_NAMES}
52 0 = $self->{COLUMN_NAMES};
53 0 $self->{plots}->[$i]->{plotter}->{BLOCK_NUM} = $self->{block_num};
54 0 $self->{plots}->[$i]->{plotter}->{LINE_NUM} = $self->{line_num};
55 0 $self->{plots}->[$i]->{plotter}->init_gnuplot();
56 }
57  
58 2 return $self;
59  
60 }
61  
62 sub open_file {
63 2 ▶ my $self = shift;
Subroutine open_file: called CC=11 SCAR=27.6
Pod undocumented
64 2 my $filenamebase = shift;
65  
66 # split directory/filname ..
67 2 ▶ if ( $filenamebase =~ /(.+)(\/|\/\/|\\|\\\\)(.+)\b/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filenamebase =~ m[(.+)(/|//|\\|\\\\)(.+)\b]u) 2 0 2
68 2 my $directory = $1;
69 2 my $filename = $3;
70 2 my $filenameextension = ".dat";
71 2 ▶ if ( $filename =~ /(.+)(\..+)\b/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename =~ /(.+)(\..+)\b/u) 2 0 2
72 2 $filename = $1;
73 2 $filenameextension = $2;
74 }
75  
76 #print "$directory $filename $filenameextension\n";
77  
78 # create directory if it doesn't exist:
79 2 ▶ if ( not -d $directory ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $directory) 0 2 2
80 0 carp "directory given by $filenamebase doesn't exist."
81 . "Creating directory $directory";
82 0 ▶ make_path $directory
Branch: 1 branch
BranchTrueFalseTotal
make_path($directory) or croak("cannot create path ${directory}: $!") 0 0 0
83 or croak "cannot create path $directory: $!";
84 }
85  
86 # look for existing files:
87 2 opendir( DIR, $directory );
88 2 my @files = readdir(DIR);
89 2 my $max_index = 0;
90 2 foreach my $file (@files) {
91  
92 8 my $temp_filename = $filename;
93 8 $temp_filename =~ s/\(/\\\(/g;
94 8 $temp_filename =~ s/\)/\\\)/g;
95  
96 #print $temp_filename."\n";
97 8 ▶ if ( $file =~ /($temp_filename)(_(\d+))?($filenameextension)\b/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /($temp_filename)(_(\d+))?($filenameextension)\b/u) 0 8 8
98 {
99 0 ▶ if ( $3 > $max_index ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($3 > $max_index) { } 0 0 0
elsif (not defined $3) { } 0 0 0
100 0 $max_index = $3;
101 }
102 elsif ( not defined $3 ) {
103 0 $max_index = 1;
104 }
105 }
106  
107 }
108 2 closedir(DIR);
109 2 $max_index++;
110  
111 2 my $file_data;
112  
113 # open new file:
114 2 ▶ if ( $max_index > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_index > 1) { } 0 2 2
115 0 $file_data = sprintf(
116 "%s/%s_%03d%s",
117 $directory, $filename, $max_index, $filenameextension
118 );
119 }
120 else {
121 2 $file_data = sprintf(
122 "%s/%s%s", $directory, $filename,
123 $filenameextension
124 );
125 }
126  
127 2 ▶ open( my $LOG, ">" . $file_data ) or die "cannot open $file_data";
Branch: 1 branch
BranchTrueFalseTotal
open my $LOG, '>' . $file_data or die "cannot open $file_data" 0 2 2
128 2 my $old_fh = select($LOG);
129 2 $| = 1;
130 2 select($old_fh);
131 2 print "Output file is \"$file_data\"\n";
132  
133 2 return ( $LOG, $file_data, $directory );
134 }
135  
136 }
137  
138 sub close_file {
139 0 ▶ my $self = shift;
Subroutine close_file: not called CC=1 SCAR=6.9
Pod undocumented
140  
141 0 my $file = $self->{filehandle};
142 0 close $file;
143 0 delete $self->{filehandle};
144  
145 0 return $self;
146 }
147  
148 sub add_plots {
149 0 ▶ my $self = shift;
Subroutine add_plots: not called CC=5 SCAR=34.0
Pod undocumented
150 0 my $plots = shift;
151  
152 # check if $plots is an ARRAY-REF or just a single plot
153 #print "$self->{plots}";
154 0 my $num_of_plots = @{ $self->{plots} };
155 0 my $allready_existing_plots = $num_of_plots;
156  
157 0 ▶ if ( not defined $plots ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $plots) { } 0 0 0
elsif (ref $plots eq 'ARRAY') { } 0 0 0
158 0 return $num_of_plots;
159 }
160 elsif ( ref($plots) eq 'ARRAY' ) {
161 0 foreach ( @{$plots} ) {
162 0 push( @{ $self->{plots} }, $_ );
163 }
164 0 $num_of_plots = @{ $self->{plots} };
165 }
166 else {
167 0 push( @{ $self->{plots} }, $plots );
168 0 $num_of_plots = @{ $self->{plots} };
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 ▶ for ( my $i = $allready_existing_plots; $i < $num_of_plots; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_of_plots) 0 0 0
181 $self->{plots}->[$i]->{plotter}
182 = new Lab::XPRESS::Data::XPRESS_plotter(
183 $self->{filename},
184 0 $self->{plots}->[$i]
185 );
186 0 $self->{plots}->[$i]->{plotter}->{ID} = $i;
187 0 $self->{plots}->[$i]->{plotter}->{FILENAME} = $self->{filename};
188 $self->{plots}->[$i]->{plotter}->{COLUMN_NAMES}
189 0 = $self->{COLUMN_NAMES};
190 $self->{plots}->[$i]->{plotter}->{NUMBER_OF_COLUMNS}
191 0 = $self->{NUMBER_OF_COLUMNS};
192 0 $self->{plots}->[$i]->{plotter}->{BLOCK_NUM} = $self->{block_num};
193 0 $self->{plots}->[$i]->{plotter}->{LINE_NUM} = $self->{line_num};
194 0 $self->{plots}->[$i]->{plotter}->init_gnuplot();
195 }
196  
197 0 return $self;
198 }
199  
200 sub _log_start_block {
201 2 ▶ my $self = shift;
Subroutine _log_start_block: called CC=6 SCAR=21.4
202 2 my @plots = @{ $self->{plots} };
203  
204 2 my $fh = $self->{filehandle};
205 2 ▶ if ( $self->{block_num} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"block_num"}) 0 2 2
206 0 $self->LOG('NEW_BLOCK');
207 }
208 2 $self->{block_num}++;
209 2 $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 ▶ if ( $self->{block_num} == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'block_num'} == 1) { } 2 0 2
elsif ($self->{'block_num'} > 1) { } 0 0 0
234 2 foreach my $plot ( @{ $self->{plots} } ) {
235 0 $plot->{plotter}->init_gnuplot_bindings();
236 }
237 }
238 elsif ( $self->{block_num} > 1 ) {
239 0 foreach my $plot ( @{ $self->{plots} } ) {
240 0 $plot->{plotter}->start_plot( $self->{block_num} );
241 }
242 }
243  
244 2 return $self->{block_num};
245 }
246  
247 sub LOG {
248 46 ▶ my $self = shift;
Subroutine LOG: called CC=32 SCAR=62.2
Pod undocumented
249 46 my $data = shift;
250  
251 46 my $filehandle = $self->{filehandle};
252 46 $self->{line_num}++;
253  
254 46 ▶ if ( $data =~ /^#/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data =~ /^#/u) { } 2 44 46
elsif ($data eq 'NEW_BLOCK') { } 0 44 44
255 2 print $filehandle $data . "\n";
256 2 return 1;
257 }
258 elsif ( $data eq 'NEW_BLOCK' ) {
259 0 print $filehandle "\n";
260 0 return 1;
261 }
262  
263 # log data:
264 44 ▶ if ( ref($data) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data eq 'ARRAY') { } 0 44 44
elsif (ref $data eq 'HASH') { } 44 0 44
265 0 my @data = @$data;
266  
267 0 my $number_of_columns = 0;
268 0 foreach my $item (@data) {
269 0 ▶ if ( ref($item) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 0 0 0
270 0 $number_of_columns++;
271 }
272 else {
273 0 last;
274 }
275 }
276  
277 0 ▶ if ( $number_of_columns >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number_of_columns >= 1) { } 0 0 0
278 0 my $j = 0;
279 0 ▶ while ( defined $data[0][$j] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0][$j]) 0 0 0
280 0 ▶ for ( my $i = 0; $i < $number_of_columns; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $number_of_columns) 0 0 0
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 ▶ if ( $data[$i][$j]
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i][$j] =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/u) { } 0 0 0
293 =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) {
294 0 print $filehandle sprintf( "%+.6e\t", $data[$i][$j] );
295 0 ▶ if ( $data[$i][$j] < $self->{DATA}[$i][0]
Branch: 2 branches
BranchTrueFalseTotal
if ($data[$i][$j] < $self->{'DATA'}[$i][0] or not defined $self->{'DATA'}[$i][0]) { } 0 0 0
elsif ($data[$i][$j] > $self->{'DATA'}[$i][1] or not defined $self->{'DATA'}[$i][0]) { } 0 0 0
Condition0%0/3
$data[$i][$j] < $self->{"DATA"}[$i][0] or not defined $self->{"DATA"}[$i][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$data[$i][$j] < $self->{"DATA"}[$i][0] or not defined $self->{"DATA"}[$i][0]
$data[$i][$j] < $self->{"DATA"}[$i][0] not defined $self->{"DATA"}[$i][0]
Truth table0%0/3
A or not(B)
A= $data[$i][$j] < $self->{"DATA"}[$i][0]B= not defined $self->{"DATA"}[$i][0]
ABresult
1X1
011
000
296 or not defined $self->{DATA}[$i][0] ) {
297 0 $self->{DATA}[$i][0] = $data[$i][$j];
298 }
299 ▶ elsif ( $data[$i][$j] > $self->{DATA}[$i][1]
Condition0%0/3
$data[$i][$j] > $self->{"DATA"}[$i][1] or not defined $self->{"DATA"}[$i][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$data[$i][$j] > $self->{"DATA"}[$i][1] or not defined $self->{"DATA"}[$i][0]
$data[$i][$j] > $self->{"DATA"}[$i][1] not defined $self->{"DATA"}[$i][0]
Truth table0%0/3
A or not(B)
A= $data[$i][$j] > $self->{"DATA"}[$i][1]B= not defined $self->{"DATA"}[$i][0]
ABresult
1X1
011
000
300 or not defined $self->{DATA}[$i][0] ) {
301 0 $self->{DATA}[$i][1] = $data[$i][$j];
302 }
303  
304 #print sprintf("%.6e\t",$data[$i][$j]);
305 }
306 else {
307 0 print $filehandle $data[$i][$j] . "\t";
308  
309 #print $data[$i][$j]."\t";
310 }
311 }
312 0 print $filehandle "\n";
313  
314 #print "\n";
315 0 $j++;
316 }
317  
318 }
319 else {
320 0 my $i = 0;
321 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 ▶ if ( $value
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/u) { } 0 0 0
334 =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) {
335 0 print $filehandle sprintf( "%+.6e\t", $value );
336 0 ▶ if ( $value < $self->{DATA}[$i][0]
Branch: 2 branches
BranchTrueFalseTotal
if ($value < $self->{'DATA'}[$i][0] or not defined $self->{'DATA'}[$i][0]) { } 0 0 0
elsif ($value > $self->{'DATA'}[$i][1] or not defined $self->{'DATA'}[$i][0]) { } 0 0 0
Condition0%0/3
$value < $self->{"DATA"}[$i][0] or not defined $self->{"DATA"}[$i][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$value < $self->{"DATA"}[$i][0] or not defined $self->{"DATA"}[$i][0]
$value < $self->{"DATA"}[$i][0] not defined $self->{"DATA"}[$i][0]
Truth table0%0/3
A or not(B)
A= $value < $self->{"DATA"}[$i][0]B= not defined $self->{"DATA"}[$i][0]
ABresult
1X1
011
000
337 or not defined $self->{DATA}[$i][0] ) {
338 0 $self->{DATA}[$i][0] = $value;
339 }
340 ▶ elsif ( $value > $self->{DATA}[$i][1]
Condition0%0/3
$value > $self->{"DATA"}[$i][1] or not defined $self->{"DATA"}[$i][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$value > $self->{"DATA"}[$i][1] or not defined $self->{"DATA"}[$i][0]
$value > $self->{"DATA"}[$i][1] not defined $self->{"DATA"}[$i][0]
Truth table0%0/3
A or not(B)
A= $value > $self->{"DATA"}[$i][1]B= not defined $self->{"DATA"}[$i][0]
ABresult
1X1
011
000
341 or not defined $self->{DATA}[$i][0] ) {
342 0 $self->{DATA}[$i][1] = $value;
343 }
344  
345 #print sprintf("%.6e\t",$value);
346 }
347 else {
348 0 print $filehandle $value . "\t";
349  
350 #print $value."\t";
351 }
352 0 $i++;
353 }
354 0 print $filehandle "\n";
355  
356 #print "\n";
357 }
358 }
359  
360 elsif ( ref($data) eq 'HASH' ) {
361 44 my @logline;
362 44 ▶ while ( my ( $key, $value ) = each %{ $self->{COLUMN_NAMES} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"COLUMN_NAMES"};}) 110 44 154
363 110 $logline[$value] = $data->{$key};
364 }
365 44 shift @logline;
366 44 my $logline = join( "\t", @logline );
367 44 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 ▶ if ( $data =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /(^[-+]?[0-9]+)\.?([0-9]+)?([eE][-+]?[0-9]+)?$/u) { } 0 0 0
382 0 print $filehandle sprintf( "%+.6e\t", $data );
383 0 ▶ if ( $data < $self->{DATA}[0][0]
Branch: 2 branches
BranchTrueFalseTotal
if ($data < $self->{'DATA'}[0][0] or not defined $self->{'DATA'}[0][0]) { } 0 0 0
elsif ($data > $self->{'DATA'}[0][1] or not defined $self->{'DATA'}[0][0]) { } 0 0 0
Condition0%0/3
$data < $self->{"DATA"}[0][0] or not defined $self->{"DATA"}[0][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$data < $self->{"DATA"}[0][0] or not defined $self->{"DATA"}[0][0]
$data < $self->{"DATA"}[0][0] not defined $self->{"DATA"}[0][0]
Truth table0%0/3
A or not(B)
A= $data < $self->{"DATA"}[0][0]B= not defined $self->{"DATA"}[0][0]
ABresult
1X1
011
000
384 or not defined $self->{DATA}[0][0] ) {
385 0 $self->{DATA}[0][0] = $data;
386 }
387 ▶ elsif ( $data > $self->{DATA}[0][1]
Condition0%0/3
$data > $self->{"DATA"}[0][1] or not defined $self->{"DATA"}[0][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$data > $self->{"DATA"}[0][1] or not defined $self->{"DATA"}[0][0]
$data > $self->{"DATA"}[0][1] not defined $self->{"DATA"}[0][0]
Truth table0%0/3
A or not(B)
A= $data > $self->{"DATA"}[0][1]B= not defined $self->{"DATA"}[0][0]
ABresult
1X1
011
000
388 or not defined $self->{DATA}[0][0] ) {
389 0 $self->{DATA}[0][1] = $data;
390 }
391  
392 #print sprintf("%.6e\t",$value);
393 }
394 else {
395 0 print $filehandle $data . "\t";
396  
397 #print $value."\t";
398 }
399 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 ▶ if ( not defined $self->{plots} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"plots"}) 0 44 44
459 0 return 1;
460 }
461 44 my $number_of_plots = @{ $self->{plots} };
462 44 ▶ for ( my $i = 0; $i < $number_of_plots; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $number_of_plots) 0 44 44
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 ▶ if ( not defined $self->{plots}->[$i]->{plotter}->{plot}->{started} )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'plots'}[$i]{'plotter'}{'plot'}{'started'}) { } 0 0 0
472 {
473  
474 # start plot:
475 0 ▶ if ( $self->{plots}->[$i]->{plotter}->{plot}->{'type'} eq 'pm3d'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'plots'}[$i]{'plotter'}{'plot'}{'type'} eq 'pm3d' and $self->{'block_num'} <= 1) { } 0 0 0
Condition0%0/3
$self->{"plots"}[$i]{"plotter"}{"plot"}{"type"} eq "pm3d" and $self->{"block_num"} <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"plots"}[$i]{"plotter"}{"plot"}{"type"} eq "pm3d" and $self->{"block_num"} <= 1
$self->{"plots"}[$i]{"plotter"}{"plot"}{"type"} eq "pm3d" $self->{"block_num"} <= 1
Truth table0%0/3
A and B
A= $self->{"plots"}[$i]{"plotter"}{"plot"}{"type"} eq "pm3d"B= $self->{"block_num"} <= 1
ABresult
0X0
100
111
476 and $self->{block_num} <= 1 ) {
477  
478 # start plot later
479 }
480 else {
481 $self->{plots}->[$i]->{plotter}
482 0 ->start_plot( $self->{block_num} );
483 }
484 }
485 else {
486 # replot:
487 0 $self->{plots}->[$i]->{plotter}->replot();
488 }
489  
490 }
491  
492 44 return 1;
493  
494 }
495  
496 sub LOG_linetrace {
497 0 ▶ my $self = shift;
Subroutine LOG_linetrace: not called CC=14 SCAR=53.5
Pod undocumented
498 0 my $data = shift;
499  
500 0 my $filehandle = $self->{filehandle};
501  
502 # log data:
503 0 ▶ if ( ref($data) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq 'ARRAY') { } 0 0 0
504 0 my @data = @$data;
505  
506 0 my $number_of_columns = 0;
507 0 foreach my $item (@data) {
508 0 ▶ if ( ref($item) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 0 0 0
509 0 $number_of_columns++;
510 }
511 else {
512 0 last;
513 }
514 }
515  
516 0 ▶ if ( $number_of_columns >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number_of_columns >= 1) { } 0 0 0
517 0 my $j = 0;
518 0 ▶ while ( defined $data[0][$j] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0][$j]) 0 0 0
519 0 ▶ for ( my $i = 0; $i < $number_of_columns; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $number_of_columns) 0 0 0
520 0 ▶ if ( $data[$i][$j] =~ /[[:alpha:]]/
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i][$j] =~ /[[:alpha:]]/u or not $data[$i][$j] =~ /[[:alnum:]]/u) { } 0 0 0
Condition0%0/3
$data[$i][$j] =~ /[[:alpha:]]/u or not $data[$i][$j] =~ /[[:alnum:]]/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$data[$i][$j] =~ /[[:alpha:]]/u or not $data[$i][$j] =~ /[[:alnum:]]/u
$data[$i][$j] =~ /[[:alpha:]]/u not $data[$i][$j] =~ /[[:alnum:]]/u
Truth table0%0/3
A or not(B)
A= $data[$i][$j] =~ /[[:alpha:]]/uB= not $data[$i][$j] =~ /[[:alnum:]]/u
ABresult
1X1
011
000
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 ▶ if ( $value =~ /[[:alpha:]]/ or not $value =~ /[[:alnum:]]/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /[[:alpha:]]/u or not $value =~ /[[:alnum:]]/u) { } 0 0 0
Condition0%0/3
$value =~ /[[:alpha:]]/u or not $value =~ /[[:alnum:]]/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$value =~ /[[:alpha:]]/u or not $value =~ /[[:alnum:]]/u
$value =~ /[[:alpha:]]/u not $value =~ /[[:alnum:]]/u
Truth table0%0/3
A or not(B)
A= $value =~ /[[:alpha:]]/uB= not $value =~ /[[:alnum:]]/u
ABresult
1X1
011
000
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 ▶ if ( $data =~ /[[:alpha:]]/ or not $data =~ /[[:alnum:]]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /[[:alpha:]]/u or not $data =~ /[[:alnum:]]/u) { } 0 0 0
Condition0%0/3
$data =~ /[[:alpha:]]/u or not $data =~ /[[:alnum:]]/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$data =~ /[[:alpha:]]/u or not $data =~ /[[:alnum:]]/u
$data =~ /[[:alpha:]]/u not $data =~ /[[:alnum:]]/u
Truth table0%0/3
A or not(B)
A= $data =~ /[[:alpha:]]/uB= not $data =~ /[[:alnum:]]/u
ABresult
1X1
011
000
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 ▶ my $self = shift;
Subroutine DESTROY: not called CC=2 SCAR=17.9
581  
582 0 foreach my $plot ( @{ $self->{plots} } ) {
583 0 $plot->{plotter}->_stop_live_plot();
584 0 $plot->{plotter};
585 }
586 0 $self->close_file();
587 }
588  
589 8 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
« Instrument/U2000.pm ↑ Summary Instrument.pm »