Finnigan/RawFileInfoPreamble.pm

filter: Statementstmt 95.2% 40 / 42 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 6 / 6 totaltotal 93.6% 59 / 63 CC 3 SCAR 3.9
CC
3
Cov
91%
decode
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Finnigan/GenericDataHeader.pm ↑ Summary Finnigan/Error.pm »
1 package Finnigan::RawFileInfoPreamble;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings FATAL => qw( all );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = 0.0206;
6  
7 2 ▶use Finnigan;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use base 'Finnigan::Decoder';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use overload ('""' => 'stringify');
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub decode {
Subroutine decode: called CC=3 SCAR=11.3
Pod documented
13 1 my ($class, $stream, $version) = @_;
14  
15 1 my @common_fields = (
16 "method file present" => ['V', 'UInt32'],
17 year => ['v', 'UInt16'],
18 month => ['v', 'UInt16'],
19 "day of the week" => ['v', 'UInt16'],
20 day => ['v', 'UInt16'],
21 hour => ['v', 'UInt16'],
22 minute => ['v', 'UInt16'],
23 second => ['v', 'UInt16'],
24 millisecond => ['v', 'UInt16'],
25 );
26  
27 1 my %specific_fields;
28 $specific_fields{8} = [],
29 1 $specific_fields{57} = [
30 "unknown_long[2]" => ['V', 'UInt32'],
31 "data addr" => ['V', 'UInt32'],
32 "unknown_long[3]" => ['V', 'UInt32'],
33 "unknown_long[4]" => ['V', 'UInt32'],
34 "unknown_long[5]" => ['V', 'UInt32'],
35 "unknown_long[6]" => ['V', 'UInt32'],
36 "run header addr" => ['V', 'UInt32'],
37 unknown_area => ['C756', 'RawBytes'], # 804 - 12 * 4 (804 is the fixed size of RawFileInfoPreamble prior to v.64)
38 ];
39  
40 1 $specific_fields{60} = $specific_fields{57};
41 1 $specific_fields{62} = $specific_fields{57};
42 1 $specific_fields{63} = $specific_fields{57};
43  
44 1 $specific_fields{64} = [
45 "unknown_long[2]" => ['V', 'UInt32'],
46 "32-bit data addr (unused)" => ['V', 'UInt32'],
47 "unknown_long[3]" => ['V', 'UInt32'],
48 "unknown_long[4]" => ['V', 'UInt32'],
49 "unknown_long[5]" => ['V', 'UInt32'],
50 "unknown_long[6]" => ['V', 'UInt32'],
51 "32-b run header addr (unused)" => ['V', 'UInt32'],
52 "unknown_area[1]" => ['C760', 'RawBytes'],
53 "data addr" => ['Q<', 'UInt64'],
54 "unknown_long[7]" => ['V', 'UInt32'],
55 "unknown_long[8]" => ['V', 'UInt32'],
56 "run header addr" => ['Q<', 'UInt64'],
57 "unknown_area[2]" => ['C1008', 'RawBytes'],
58 ];
59  
60 1 ▶ if ($version == 66) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version == 66) 0 1 1
61 0 $specific_fields{66} = $specific_fields{64};
62 0 $specific_fields{66}->[-1]->[0] = 'C1024'; # unknown_area[2] has been extended
63 }
64  
65 1 ▶ die "don't know how to parse version $version" unless $specific_fields{$version};
Branch: 1 branch
BranchTrueFalseTotal
unless $specific_fields{$version} 0 1 1
66 1 my $self = Finnigan::Decoder->read($stream, [@common_fields, @{$specific_fields{$version}}]);
67  
68 1 return bless $self, $class;
69 }
70  
71 1 ▶sub timestamp {
Subroutine timestamp: called CC=1 SCAR=0.0
Pod documented
72 1 my $self = shift;
73 1 my @dow_abbr = qw/X Mon Tue Wed Thu Fri Sat Sun/;
74 1 my @month_abbr = qw/X Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
75 $dow_abbr[$self->{data}->{"day of the week"}->{value}] . " "
76 . $month_abbr[$self->{data}->{month}->{value}]
77 . " "
78 . $self->{data}->{day}->{value}
79 . " "
80 . $self->{data}->{year}->{value}
81 . " "
82 . $self->{data}->{hour}->{value}
83 . ":"
84 . $self->{data}->{minute}->{value}
85 . ":"
86 . $self->{data}->{second}->{value}
87 . "."
88 . $self->{data}->{millisecond}->{value}
89 1 ;
90 }
91  
92 1 ▶sub xmlTimestamp {
Subroutine xmlTimestamp: called CC=1 SCAR=0.0
Pod documented
93 1 my $self = shift;
94 sprintf(
95 '%04d-%02d-%02dT%02d:%02d:%02.0fZ',
96 $self->{data}->{year}->{value},
97 $self->{data}->{month}->{value},
98 $self->{data}->{day}->{value},
99 $self->{data}->{hour}->{value},
100 $self->{data}->{minute}->{value},
101 1 $self->{data}->{second}->{value} + $self->{data}->{millisecond}->{value} / 1000
102 );
103 }
104  
105 3 ▶sub run_header_addr {
Subroutine run_header_addr: called CC=1 SCAR=0.0
Pod documented
106 3 shift->{data}->{"run header addr"}->{value};
107 }
108  
109 2 ▶sub data_addr {
Subroutine data_addr: called CC=1 SCAR=0.0
Pod documented
110 2 shift->{data}->{"data addr"}->{value};
111 }
112  
113 1 ▶sub stringify {
Subroutine stringify: called CC=1 SCAR=0.0
Pod documented
114 1 my $self = shift;
115 1 return $self->timestamp
116 . "; "
117 . "data addr: " . $self->data_addr
118 . "; "
119 . "RunHeader addr: " . $self->run_header_addr
120 ;
121 }
122  
123 2 1;
124 __END__
« Finnigan/GenericDataHeader.pm ↑ Summary Finnigan/Error.pm »