CIGIPP/HAT_HOTResponse.pm

filter: Statementstmt 65.5% 57 / 87 Branchbran 30.7% 8 / 26 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 86.6% 13 / 15 Podpod 100% 11 / 11 totaltotal 59.7% 92 / 154 CC 18 SCAR 19.2
CC
18
Cov
56%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 6.8
« CIGIPP/StartOfFrame.pm ↑ Summary CIGIPP/PositionResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78b1b62-200e-11de-bdc7-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::HAT_HOTResponse;
8  
9 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 require Exporter;
15  
16 2 our @ISA = qw(Exporter);
17  
18 # Items to export into callers namespace by default. Note: do not export
19 # names by default without a very good reason. Use EXPORT_OK instead.
20 # Do not simply export all your public functions/methods/constants.
21  
22 # This allows declaration use Rinchi::CIGI::AtmosphereControl ':all';
23 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
24 # will save memory.
25 2 our %EXPORT_TAGS = ( 'all' => [ qw(
26
27 ) ] );
28  
29 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
30  
31 2 our @EXPORT = qw(
32
33 );
34  
35 2 our $VERSION = '0.02';
36  
37 # Preloaded methods go here.
38  
39 =head1 NAME
40  
41 Rinchi::CIGIPP::HAT_HOTResponse - Perl extension for the Common Image Generator
42 Interface - HAT/HOTResponse data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::HAT_HOTResponse;
47 my $hgt_resp = Rinchi::CIGIPP::HAT_HOTResponse->new();
48  
49 $packet_type = $hgt_resp->packet_type();
50 $packet_size = $hgt_resp->packet_size();
51 $response_ident = $hgt_resp->response_ident(47273);
52 $host_frame_number_lsn = $hgt_resp->host_frame_number_lsn(13);
53 $response_type = $hgt_resp->response_type(Rinchi::CIGIPP->HeightAboveTerrain);
54 $valid = $hgt_resp->valid(Rinchi::CIGIPP->Invalid);
55 $height = $hgt_resp->height(51.413);
56  
57 =head1 DESCRIPTION
58  
59 The HAT/HOT Response packet is sent by the IG in response to a HAT/HOT Request
60 packet whose Request Type attribute was set to HAT (0) or HOT (1). This packet
61 provides either the Height Above Terrain (HAT) or Height Of Terrain (HOT) for
62 the test point. This packet does not contain the material code or surface
63 normal of the terrain.
64  
65 If the Update Period attribute of the originating HAT/HOT Request packet was
66 set to a value greater than zero, then the Host Frame Number LSN attribute of
67 each corresponding HAT/HOT Response packet must contain the least significant
68 nybble of the Host Frame Number value last received by the IG before the HAT or
69 HOT value is calculated. The Host may correlate this LSN to an eyepoint
70 position or may use the value to determine latency.
71  
72 The IG can only return the HAT or HOT for a point that is within the bounds of
73 the current database. If the HAT or HOT cannot be returned, the Valid attribute
74 will be set to Invalid (0).
75  
76 =head2 EXPORT
77  
78 None by default.
79  
80 #==============================================================================
81  
82 =item new $hgt_resp = Rinchi::CIGIPP::HAT_HOTResponse->new()
83  
84 Constructor for Rinchi::HAT_HOTResponse.
85  
86 =cut
87  
88 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
89 2 my $class = shift;
90 2 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
91  
92 2 my $self = {
93 '_Buffer' => '',
94 '_ClassIdent' => 'f78b1b62-200e-11de-bdc7-001c25551abc',
95 '_Pack' => 'CCSCCSd',
96 '_Swap1' => 'CCvCCvVV',
97 '_Swap2' => 'CCnCCnNN',
98 'packetType' => 102,
99 'packetSize' => 16,
100 '_responseIdent' => 0,
101 '_bitfields1' => 0, # Includes bitfields hostFrameNumberLSN, responseType, and valid.
102 'hostFrameNumberLSN' => 0,
103 'responseType' => 0,
104 'valid' => 0,
105 '_unused67' => 0,
106 '_unused68' => 0,
107 'height' => 0,
108 };
109  
110 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
111 0 ▶ if (ref($_[0]) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 0 0 0
elsif (ref $_[0] eq 'HASH') { } 0 0 0
112 0 $self->{'_Buffer'} = $_[0][0];
113 } elsif (ref($_[0]) eq 'HASH') {
114 0 foreach my $attr (keys %{$_[0]}) {
115 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
116 }
117 }
118 }
119  
120 2 bless($self,$class);
121 2 return $self;
122 }
123  
124 #==============================================================================
125  
126 =item sub packet_type()
127  
128 $value = $hgt_resp->packet_type();
129  
130 Data Packet Identifier.
131  
132 This attribute identifies this data packet as the HAT/HOT Response packet. The
133 value of this attribute must be 102.
134  
135 =cut
136  
137 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
138 2 my ($self) = @_;
139 2 return $self->{'packetType'};
140 }
141  
142 #==============================================================================
143  
144 =item sub packet_size()
145  
146 $value = $hgt_resp->packet_size();
147  
148 Data Packet Size.
149  
150 This attribute indicates the number of bytes in this data packet. The value of
151 this attribute must be 16.
152  
153 =cut
154  
155 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
156 2 my ($self) = @_;
157 2 return $self->{'packetSize'};
158 }
159  
160 #==============================================================================
161  
162 =item sub response_ident([$newValue])
163  
164 $value = $hgt_resp->response_ident($newValue);
165  
166 HAT/HOT ID.
167  
168 This attribute identifies the HAT/HOT response. This value corresponds to the
169 value of the HAT/HOT ID attribute in the associated HAT/HOT Request packet.
170  
171 =cut
172  
173 2 ▶sub response_ident() {
Subroutine response_ident: called CC=2 SCAR=7.0
Pod documented
174 2 my ($self,$nv) = @_;
175 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
176 2 $self->{'_responseIdent'} = $nv;
177 }
178 2 return $self->{'_responseIdent'};
179 }
180  
181 #==============================================================================
182  
183 =item sub host_frame_number_lsn([$newValue])
184  
185 $value = $hgt_resp->host_frame_number_lsn($newValue);
186  
187 Host Frame Number LSN.
188  
189 This attribute contains the least significant nybble of the Host Frame Number
190 attribute of the last IG Control packet received before the HAT or HOT is
191 calculated.
192  
193 This attribute is ignored if the Update Period attribute of the corresponding
194 HAT/HOT Request packet was set to zero (0).
195  
196 =cut
197  
198 2 ▶sub host_frame_number_lsn() {
Subroutine host_frame_number_lsn: called CC=2 SCAR=7.0
Pod documented
199 2 my ($self,$nv) = @_;
200 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
201 2 $self->{'hostFrameNumberLSN'} = $nv;
202 2 $self->{'_bitfields1'} |= ($nv << 4) &0xF0;
203 }
204 2 return (($self->{'_bitfields1'} & 0xF0) >> 4);
205 }
206  
207 #==============================================================================
208  
209 =item sub response_type([$newValue])
210  
211 $value = $hgt_resp->response_type($newValue);
212  
213 Response Type.
214  
215 This attribute indicates whether the Height attribute represents Height Above
216 Terrain or Height Of Terrain.
217  
218 HeightAboveTerrain 0
219 HeightOfTerrain 1
220  
221 =cut
222  
223 2 ▶sub response_type() {
Subroutine response_type: called CC=4 SCAR=15.5
Pod documented
224 2 my ($self,$nv) = @_;
225 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
226 2 ▶ if (($nv==0) or ($nv==1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1) { } 2 0 2
Condition33%1/3
$nv == 0 or $nv == 1
l!l&&r!l&&!r
200
MC/DC0%0/2
$nv == 0 or $nv == 1
$nv == 0 $nv == 1
Truth table33%1/3
A or B
A= $nv == 0B= $nv == 1
ABresult
1X1
011
000
227 2 $self->{'responseType'} = $nv;
228 2 $self->{'_bitfields1'} |= ($nv << 1) &0x02;
229 } else {
230 0 carp "response_type must be 0 (HeightAboveTerrain), or 1 (HeightOfTerrain).";
231 }
232 }
233 2 return (($self->{'_bitfields1'} & 0x02) >> 1);
234 }
235  
236 #==============================================================================
237  
238 =item sub valid([$newValue])
239  
240 $value = $hgt_resp->valid($newValue);
241  
242 Valid.
243  
244 This attribute indicates whether the remaining attributes in this packet
245 contain valid numbers. A value of zero (0) indicates that the test point was
246 beyond the database bounds.
247  
248 Invalid 0
249 Valid 1
250  
251 =cut
252  
253 2 ▶sub valid() {
Subroutine valid: called CC=4 SCAR=15.5
Pod documented
254 2 my ($self,$nv) = @_;
255 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
256 2 ▶ if (($nv==0) or ($nv==1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1) { } 2 0 2
Condition33%1/3
$nv == 0 or $nv == 1
l!l&&r!l&&!r
200
MC/DC0%0/2
$nv == 0 or $nv == 1
$nv == 0 $nv == 1
Truth table33%1/3
A or B
A= $nv == 0B= $nv == 1
ABresult
1X1
011
000
257 2 $self->{'valid'} = $nv;
258 2 $self->{'_bitfields1'} |= $nv &0x01;
259 } else {
260 0 carp "valid must be 0 (Invalid), or 1 (Valid).";
261 }
262 }
263 2 return ($self->{'_bitfields1'} & 0x01);
264 }
265  
266 #==============================================================================
267  
268 =item sub height([$newValue])
269  
270 $value = $hgt_resp->height($newValue);
271  
272 Height.
273  
274 This attribute contains the requested height. If Request Type is set to HAT
275 (0), this value represents the Height Above Terrain. If Request Type is set to
276 HOT (1), this value represents the Height Of Terrain.
277  
278 This attribute is valid only if the Valid attribute is set to one (1).
279  
280 =cut
281  
282 2 ▶sub height() {
Subroutine height: called CC=2 SCAR=7.0
Pod documented
283 2 my ($self,$nv) = @_;
284 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
285 2 $self->{'height'} = $nv;
286 }
287 2 return $self->{'height'};
288 }
289  
290 #==========================================================================
291  
292 =item sub pack()
293  
294 $value = $hgt_resp->pack();
295  
296 Returns the packed data packet.
297  
298 =cut
299  
300 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
301 2 my $self = shift ;
302
303 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
304 $self->{'packetType'},
305 $self->{'packetSize'},
306 $self->{'_responseIdent'},
307 $self->{'_bitfields1'}, # Includes bitfields hostFrameNumberLSN, unused66, responseType, and valid.
308 $self->{'_unused67'},
309 $self->{'_unused68'},
310 2 $self->{'height'},
311 );
312  
313 2 return $self->{'_Buffer'};
314 }
315  
316 #==========================================================================
317  
318 =item sub unpack()
319  
320 $value = $hgt_resp->unpack();
321  
322 Unpacks the packed data packet.
323  
324 =cut
325  
326 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
327 0 my $self = shift @_;
328
329 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
330 0 $self->{'_Buffer'} = shift @_;
331 }
332 0 my ($a,$b,$c,$d,$e,$f,$g) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
333 0 $self->{'packetType'} = $a;
334 0 $self->{'packetSize'} = $b;
335 0 $self->{'_responseIdent'} = $c;
336 0 $self->{'_bitfields1'} = $d; # Includes bitfields hostFrameNumberLSN, unused66, responseType, and valid.
337 0 $self->{'_unused67'} = $e;
338 0 $self->{'_unused68'} = $f;
339 0 $self->{'height'} = $g;
340  
341 0 $self->{'hostFrameNumberLSN'} = $self->host_frame_number_lsn();
342 0 $self->{'responseType'} = $self->response_type();
343 0 $self->{'valid'} = $self->valid();
344  
345 0 return $self->{'_Buffer'};
346 }
347  
348 #==========================================================================
349  
350 =item sub byte_swap()
351  
352 $obj_name->byte_swap();
353  
354 Byte swaps the packed data packet.
355  
356 =cut
357  
358 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
359 0 my $self = shift @_;
360
361 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
362 0 $self->{'_Buffer'} = shift @_;
363 } else {
364 0 $self->pack();
365 }
366 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
367  
368 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$h,$g);
369 0 $self->unpack();
370  
371 0 return $self->{'_Buffer'};
372 }
373  
374 2 1;
375 __END__
« CIGIPP/StartOfFrame.pm ↑ Summary CIGIPP/PositionResponse.pm »