File Coverage

blib/lib/Finnigan/RunHeader.pm
Criterion Covered Total %
statement 54 60 90.0
branch 7 14 50.0
condition n/a
subroutine 16 18 88.8
pod 14 14 100.0
total 91 106 85.8


line stmt bran cond sub pod time code
1             package Finnigan::RunHeader;
2              
3 2     2   10 use strict;
  2         4  
  2         71  
4 2     2   9 use warnings FATAL => qw( all );
  2         3  
  2         80  
5             our $VERSION = 0.0206;
6              
7 2     2   24 use Finnigan;
  2         2  
  2         37  
8 2     2   9 use base 'Finnigan::Decoder';
  2         4  
  2         2420  
9              
10              
11             sub decode {
12 1     1 1 2 my ($class, $stream, $version) = @_;
13              
14 1         6 my @common_fields = (
15             "sample info" => ['object', 'Finnigan::SampleInfo'],
16             );
17              
18 1         3 my %specific_fields;
19 1         7 $specific_fields{8} = [
20             "orig file name" => ['varstr', 'PascalStringWin32'],
21             "file name[1]" => ['varstr', 'PascalStringWin32'],
22             "file name[2]" => ['varstr', 'PascalStringWin32'],
23             "file name[3]" => ['varstr', 'PascalStringWin32'],
24             ];
25              
26 1         24 $specific_fields{57} = [
27             "file name[1]" => ['U0C520', 'UTF16LE'],
28             "file name[2]" => ['U0C520', 'UTF16LE'],
29             "file name[3]" => ['U0C520', 'UTF16LE'],
30             "file name[4]" => ['U0C520', 'UTF16LE'],
31             "file name[5]" => ['U0C520', 'UTF16LE'],
32             "file name[6]" => ['U0C520', 'UTF16LE'],
33             "unknown double[1]" => ['d<', 'Float64'],
34             "unknown double[2]" => ['d<', 'Float64'],
35             "file name[7]" => ['U0C520', 'UTF16LE'],
36             "file name[8]" => ['U0C520', 'UTF16LE'],
37             "file name[9]" => ['U0C520', 'UTF16LE'],
38             "file name[a]" => ['U0C520', 'UTF16LE'],
39             "file name[b]" => ['U0C520', 'UTF16LE'],
40             "file name[c]" => ['U0C520', 'UTF16LE'],
41             "file name[d]" => ['U0C520', 'UTF16LE'],
42             "scan trailer addr" => ['V', 'UInt32'],
43             "scan params addr" => ['V', 'UInt32'],
44             "unknown length[1]" => ['V', 'UInt32'],
45             "unknown length[2]" => ['V', 'UInt32'],
46             "nsegs" => ['V', 'UInt32'],
47             "unknown long[1]" => ['V', 'UInt32'],
48             "unknown long[2]" => ['V', 'UInt32'],
49             "own addr" => ['V', 'UInt32'],
50             "unknown long[3]" => ['V', 'UInt32'],
51             "unknown long[4]" => ['V', 'UInt32'],
52             ];
53              
54 1         4 $specific_fields{60} = $specific_fields{57};
55 1         2 $specific_fields{62} = $specific_fields{57};
56 1         2 $specific_fields{63} = $specific_fields{57};
57              
58 1         46 $specific_fields{64} = [
59             "file name[1]" => ['U0C520', 'UTF16LE'],
60             "file name[2]" => ['U0C520', 'UTF16LE'],
61             "file name[3]" => ['U0C520', 'UTF16LE'],
62             "file name[4]" => ['U0C520', 'UTF16LE'],
63             "file name[5]" => ['U0C520', 'UTF16LE'],
64             "file name[6]" => ['U0C520', 'UTF16LE'],
65             "unknown double[1]" => ['d<', 'Float64'],
66             "unknown double[2]" => ['d<', 'Float64'],
67             "file name[7]" => ['U0C520', 'UTF16LE'],
68             "file name[8]" => ['U0C520', 'UTF16LE'],
69             "file name[9]" => ['U0C520', 'UTF16LE'],
70             "file name[a]" => ['U0C520', 'UTF16LE'],
71             "file name[b]" => ['U0C520', 'UTF16LE'],
72             "file name[c]" => ['U0C520', 'UTF16LE'],
73             "file name[d]" => ['U0C520', 'UTF16LE'],
74             "32-bit scan trailer addr (defunct)" => ['V', 'UInt32'],
75             "32-bit scan params addr (defunct)" => ['V', 'UInt32'],
76             "unknown length[1]" => ['V', 'UInt32'],
77             "unknown length[2]" => ['V', 'UInt32'],
78             "nsegs" => ['V', 'UInt32'],
79             "unknown long[1]" => ['V', 'UInt32'],
80             "unknown long[2]" => ['V', 'UInt32'],
81             "32-bit own addr (defunct)" => ['V', 'UInt32'],
82             "unknown long[3]" => ['V', 'UInt32'],
83             "unknown long[4]" => ['V', 'UInt32'],
84              
85             "scan index addr" => ['Q<', 'Uint64'],
86             "data addr" => ['Q<', 'Uint64'],
87             "inst log addr" => ['Q<', 'Uint64'],
88             "error log addr" => ['Q<', 'Uint64'],
89             "unknown addr[1]" => ['Q<', 'Uint64'],
90             "scan trailer addr" => ['Q<', 'Uint64'],
91             "scan params addr" => ['Q<', 'Uint64'],
92             "unknown addr[2]" => ['Q<', 'Uint64'],
93             "own addr" => ['Q<', 'Uint64'],
94              
95             "unknown long[5]" => ['V', 'UInt32'],
96             "unknown long[6]" => ['V', 'UInt32'],
97             "unknown long[7]" => ['V', 'UInt32'],
98             "unknown long[8]" => ['V', 'UInt32'],
99             "unknown long[9]" => ['V', 'UInt32'],
100             "unknown long[10]" => ['V', 'UInt32'],
101             "unknown long[11]" => ['V', 'UInt32'],
102             "unknown long[12]" => ['V', 'UInt32'],
103             "unknown long[13]" => ['V', 'UInt32'],
104             "unknown long[14]" => ['V', 'UInt32'],
105             "unknown long[15]" => ['V', 'UInt32'],
106             "unknown long[16]" => ['V', 'UInt32'],
107             "unknown long[17]" => ['V', 'UInt32'],
108             "unknown long[18]" => ['V', 'UInt32'],
109             "unknown long[19]" => ['V', 'UInt32'],
110             "unknown long[20]" => ['V', 'UInt32'],
111             "unknown long[21]" => ['V', 'UInt32'],
112             "unknown long[22]" => ['V', 'UInt32'],
113             "unknown long[23]" => ['V', 'UInt32'],
114             "unknown long[24]" => ['V', 'UInt32'],
115             "unknown long[25]" => ['V', 'UInt32'],
116             "unknown long[26]" => ['V', 'UInt32'],
117             "unknown long[27]" => ['V', 'UInt32'],
118             "unknown long[28]" => ['V', 'UInt32'],
119             ];
120 1         6 $specific_fields{66} = $specific_fields{64};
121              
122 1 50       5 die "don't know how to parse version $version" unless $specific_fields{$version};
123 1         3 my $self = Finnigan::Decoder->read($stream, [@common_fields, @{$specific_fields{$version}}]);
  1         13  
124 1         8 $self->{version} = $version;
125              
126 1         31 return bless $self, $class;
127             }
128              
129             sub sample_info {
130 5     5 1 569 shift->{data}->{"sample info"}->{value};
131             }
132              
133             sub self_addr {
134 1     1 1 23 shift->{data}->{"own addr"}->{value};
135             }
136              
137             sub trailer_addr {
138 1     1 1 5 shift->{data}->{"scan trailer addr"}->{value};
139             }
140              
141             sub params_addr {
142 1     1 1 522 shift->{data}->{"scan params addr"}->{value};
143             }
144              
145             sub scan_index_addr {
146 1     1 1 3 my $self = shift;
147 1 50       7 if ($self->{version} >= 64 ) {
148 0         0 return $self->{data}->{"scan index addr"}->{value};
149             }
150             else {
151 1         6 return $self->sample_info->{data}->{"scan index addr"}->{value};
152             }
153             }
154              
155             sub data_addr {
156 1     1 1 477 my $self = shift;
157 1 50       5 if ($self->{version} >= 64 ) {
158 0         0 return $self->{data}->{"data addr"}->{value};
159             }
160             else {
161 1         4 return $self->sample_info->{data}->{"data addr"}->{value};
162             }
163             }
164              
165             sub inst_log_addr {
166 1     1 1 3 my $self = shift;
167 1 50       6 if ($self->{version} >= 64 ) {
168 0         0 return $self->{data}->{"inst log addr"}->{value};
169             }
170             else {
171 1         4 return $self->sample_info->{data}->{"inst log addr"}->{value};
172             }
173             }
174              
175             sub error_log_addr {
176 1     1 1 536 my $self = shift;
177 1 50       6 if ($self->{version} >= 64 ) {
178 0         0 return $self->{data}->{"error log addr"}->{value};
179             }
180             else {
181 1         4 return $self->sample_info->{data}->{"error log addr"}->{value};
182             }
183             }
184              
185             sub ntrailer {
186 1     1 1 497 my $self = shift;
187 1         4 my $l1 = $self->{data}->{"unknown length[1]"}->{value};
188 1         4 my $l2 = $self->{data}->{"unknown length[2]"}->{value};
189 1 50       6 die "It\'s a happy day! We\'ve run into a case where the two lengths differ: l1 = $l1 and l2 = $l2"
190             unless $l1 = $l2;
191              
192             # I am assuming it is the length of TrailerScanEvent
193 1         7 return $l1;
194             }
195              
196             sub nparams {
197 1     1 1 6 my $self = shift;
198 1         5 my $l1 = $self->{data}->{"unknown length[1]"}->{value};
199 1         4 my $l2 = $self->{data}->{"unknown length[2]"}->{value};
200 1 50       6 die "It\'s a happy day! We\'ve run into a case where the two lengths differ: l1 = $l1 and l2 = $l2"
201             unless $l1 = $l2;
202              
203             # I am assuming it is the length of ScanParams
204 1         6 return $l2;
205             }
206              
207             sub nsegs {
208 1     1 1 8 shift->{data}->{"nsegs"}->{value};
209             }
210              
211             sub u1 {
212 0     0 1   shift->{data}->{"unknown double[1]"}->{value};
213             }
214              
215             sub u2 {
216 0     0 1   shift->{data}->{"unknown double[2]"}->{value};
217             }
218              
219             1;
220             __END__