CIGIPP/LineOfSightResponse.pm

filter: Statementstmt 68.9% 71 / 103 Branchbran 35.2% 12 / 34 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 88.8% 16 / 18 Podpod 100% 14 / 14 totaltotal 61.9% 117 / 189 CC 23 SCAR 18.1
CC
23
Cov
58%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 6.1
« CIGIPP/EnvironmentalConditionsRequest.pm ↑ Summary CIGIPP/EntityControl.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78b20bc-200e-11de-bdc9-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::LineOfSightResponse;
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.01';
36  
37 # Preloaded methods go here.
38  
39 =head1 NAME
40  
41 Rinchi::CIGIPP::LineOfSightResponse - Perl extension for the Common Image
42 Generator Interface - Line Of Sight Response data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::LineOfSightResponse;
47 my $los_resp = Rinchi::CIGIPP::LineOfSightResponse->new();
48  
49 $packet_type = $los_resp->packet_type();
50 $packet_size = $los_resp->packet_size();
51 $request_ident = $los_resp->request_ident(23176);
52 $host_frame_number_lsn = $los_resp->host_frame_number_lsn(15);
53 $visible = $los_resp->visible(Rinchi::CIGIPP->Occluded);
54 $entity_ident_valid = $los_resp->entity_ident_valid(Rinchi::CIGIPP->Invalid);
55 $valid = $los_resp->valid(Rinchi::CIGIPP->Invalid);
56 $response_count = $los_resp->response_count(68);
57 $entity_ident = $los_resp->entity_ident(9383);
58 $range = $los_resp->range(45.403);
59  
60 =head1 DESCRIPTION
61  
62 The Line of Sight Response packet is used in response to both the Line of Sight
63 Segment Request and Line of Sight Vector Request packets. This packet contains
64 the distance from the Line of Sight (LOS) segment or vector source point to the
65 point of intersection with a polygon surface. The packet is sent when the
66 Request Type attribute of the request packet is set to Basic (0).
67  
68 A Line of Sight Response packet will be sent for each intersection along the
69 LOS segment or vector. The Response Count attribute will contain the total
70 number of responses that are being returned. This will allow the Host to
71 determine when all response packets for the given request have been received.
72  
73 If the Update Period attribute of the originating Line of Sight Segment Request
74 or Line of Sight Vector Request packet was set to a value greater than zero,
75 then the Host Frame Number LSN attribute of each corresponding Line of Sight
76 Response packet must contain the least significant nybble of the Host Frame
77 Number value last received by the IG before the range is calculated. The Host
78 may correlate this LSN to an eyepoint position or may use the value to
79 determine latency.
80  
81 =head2 EXPORT
82  
83 None by default.
84  
85 #==============================================================================
86  
87 =item new $los_resp = Rinchi::CIGIPP::LineOfSightResponse->new()
88  
89 Constructor for Rinchi::LineOfSightResponse.
90  
91 =cut
92  
93 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
94 2 my $class = shift;
95 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
96  
97 2 my $self = {
98 '_Buffer' => '',
99 '_ClassIdent' => 'f78b20bc-200e-11de-bdc9-001c25551abc',
100 '_Pack' => 'CCSCCSd',
101 '_Swap1' => 'CCvCCvVV',
102 '_Swap2' => 'CCnCCnNN',
103 'packetType' => 104,
104 'packetSize' => 16,
105 'requestIdent' => 0,
106 '_bitfields1' => 0, # Includes bitfields hostFrameNumberLSN, unused73, visible, entityIdentValid, and valid.
107 'hostFrameNumberLSN' => 0,
108 'visible' => 0,
109 'entityIdentValid' => 0,
110 'valid' => 0,
111 'responseCount' => 0,
112 'entityIdent' => 0,
113 'range' => 0,
114 };
115  
116 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
117 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
118 0 $self->{'_Buffer'} = $_[0][0];
119 } elsif (ref($_[0]) eq 'HASH') {
120 0 foreach my $attr (keys %{$_[0]}) {
121 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
122 }
123 }
124 }
125  
126 2 bless($self,$class);
127 2 return $self;
128 }
129  
130 #==============================================================================
131  
132 =item sub packet_type()
133  
134 $value = $los_resp->packet_type();
135  
136 Data Packet Identifier.
137  
138 This attribute identifies this data packet as the Line of Sight Response
139 packet. The value of this attribute must be 104.
140  
141 =cut
142  
143 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
144 2 my ($self) = @_;
145 2 return $self->{'packetType'};
146 }
147  
148 #==============================================================================
149  
150 =item sub packet_size()
151  
152 $value = $los_resp->packet_size();
153  
154 Data Packet Size.
155  
156 This attribute indicates the number of bytes in this data packet. The value of
157 this attribute must be 16.
158  
159 =cut
160  
161 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
162 2 my ($self) = @_;
163 2 return $self->{'packetSize'};
164 }
165  
166 #==============================================================================
167  
168 =item sub request_ident([$newValue])
169  
170 $value = $los_resp->request_ident($newValue);
171  
172 LOS ID.
173  
174 This attribute identifies the LOS response. This value corresponds to the value
175 of the LOS ID attribute in the associated Line of Sight Segment Request packet
176 or Line of Sight Vector Request packet.
177  
178 =cut
179  
180 2 ▶sub request_ident() {
Subroutine request_ident: called CC=2 SCAR=7.0
Pod documented
181 2 my ($self,$nv) = @_;
182 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
183 2 $self->{'requestIdent'} = $nv;
184 }
185 2 return $self->{'requestIdent'};
186 }
187  
188 #==============================================================================
189  
190 =item sub host_frame_number_lsn([$newValue])
191  
192 $value = $los_resp->host_frame_number_lsn($newValue);
193  
194 Host Frame Number LSN.
195  
196 This attribute contains the least significant nybble of the Host Frame Number
197 attribute of the last IG Control packet received before the LOS data are
198 calculated.
199 This attribute is ignored if the Update Period attribute of the corresponding
200 Line of Sight Segment Request or Line of Sight Vector Request packet was set to
201 zero (0).
202  
203 =cut
204  
205 2 ▶sub host_frame_number_lsn() {
Subroutine host_frame_number_lsn: called CC=2 SCAR=7.0
Pod documented
206 2 my ($self,$nv) = @_;
207 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
208 2 $self->{'hostFrameNumberLSN'} = $nv;
209 2 $self->{'_bitfields1'} |= ($nv << 4) &0xF0;
210 }
211 2 return (($self->{'_bitfields1'} & 0xF0) >> 4);
212 }
213  
214 #==============================================================================
215  
216 =item sub visible([$newValue])
217  
218 $value = $los_resp->visible($newValue);
219  
220 Visible.
221  
222 This attribute is used in response to a Line of Sight Segment Request packet.
223 It indicates whether the destination point is visible from the source point.
224  
225 This value should be ignored if the packet is in response to a Line of Sight
226 Vector Request packet.
227  
228 Note: If the LOS segment destination point is within the body of a target
229 entity model, this attribute will be set to Occluded (0) and the Entity ID
230 attribute will contain the ID of that entity.
231  
232 Occluded 0
233 Visible 1
234  
235 =cut
236  
237 2 ▶sub visible() {
Subroutine visible: called CC=4 SCAR=15.5
Pod documented
238 2 my ($self,$nv) = @_;
239 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
240 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
241 2 $self->{'visible'} = $nv;
242 2 $self->{'_bitfields1'} |= ($nv << 2) &0x04;
243 } else {
244 0 carp "visible must be 0 (Occluded), or 1 (Visible).";
245 }
246 }
247 2 return (($self->{'_bitfields1'} & 0x04) >> 2);
248 }
249  
250 #==============================================================================
251  
252 =item sub entity_ident_valid([$newValue])
253  
254 $value = $los_resp->entity_ident_valid($newValue);
255  
256 Entity ID Valid.
257  
258 This attribute indicates whether the LOS test vector or segment intersects with
259 an entity (Valid) or a non-entity (Invalid).
260  
261 Invalid 0
262 Valid 1
263  
264 =cut
265  
266 2 ▶sub entity_ident_valid() {
Subroutine entity_ident_valid: called CC=4 SCAR=15.5
Pod documented
267 2 my ($self,$nv) = @_;
268 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
269 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
270 2 $self->{'entityIdentValid'} = $nv;
271 2 $self->{'_bitfields1'} |= ($nv << 1) &0x02;
272 } else {
273 0 carp "entity_ident_valid must be 0 (Invalid), or 1 (Valid).";
274 }
275 }
276 2 return (($self->{'_bitfields1'} & 0x02) >> 1);
277 }
278  
279 #==============================================================================
280  
281 =item sub valid([$newValue])
282  
283 $value = $los_resp->valid($newValue);
284  
285 Valid.
286  
287 This attribute indicates whether the Range attribute is valid. The range will
288 be invalid if no intersection occurs, or if an intersection occurs before the
289 minimum range or beyond the maximum range specified in a LOS vector request.
290  
291 Invalid 0
292 Valid 1
293  
294 =cut
295  
296 2 ▶sub valid() {
Subroutine valid: called CC=4 SCAR=15.5
Pod documented
297 2 my ($self,$nv) = @_;
298 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
299 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
300 2 $self->{'valid'} = $nv;
301 2 $self->{'_bitfields1'} |= $nv &0x01;
302 } else {
303 0 carp "valid must be 0 (Invalid), or 1 (Valid).";
304 }
305 }
306 2 return ($self->{'_bitfields1'} & 0x01);
307 }
308  
309 #==============================================================================
310  
311 =item sub response_count([$newValue])
312  
313 $value = $los_resp->response_count($newValue);
314  
315 Response Count.
316  
317 This attribute indicates the total number of Line of Sight Response packets the
318 IG will return for the corresponding request.
319  
320 Note: If Visible is set to Visible (1), then Response Count should be set to 1.
321  
322 =cut
323  
324 2 ▶sub response_count() {
Subroutine response_count: called CC=2 SCAR=7.0
Pod documented
325 2 my ($self,$nv) = @_;
326 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
327 2 $self->{'responseCount'} = $nv;
328 }
329 2 return $self->{'responseCount'};
330 }
331  
332 #==============================================================================
333  
334 =item sub entity_ident([$newValue])
335  
336 $value = $los_resp->entity_ident($newValue);
337  
338 Entity ID.
339  
340 This attribute indicates the entity with which an LOS test vector or segment
341 intersects. This attribute should be ignored if Entity ID Valid is set to
342 Invalid (0).
343  
344 =cut
345  
346 2 ▶sub entity_ident() {
Subroutine entity_ident: called CC=2 SCAR=7.0
Pod documented
347 2 my ($self,$nv) = @_;
348 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
349 2 $self->{'entityIdent'} = $nv;
350 }
351 2 return $self->{'entityIdent'};
352 }
353  
354 #==============================================================================
355  
356 =item sub range([$newValue])
357  
358 $value = $los_resp->range($newValue);
359  
360 Range.
361  
362 This attribute indicates the distance along the LOS test segment or vector from
363 the source point to the point of intersection with a polygon surface.
364  
365 =cut
366  
367 2 ▶sub range() {
Subroutine range: called CC=2 SCAR=7.0
Pod documented
368 2 my ($self,$nv) = @_;
369 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
370 2 $self->{'range'} = $nv;
371 }
372 2 return $self->{'range'};
373 }
374  
375 #==========================================================================
376  
377 =item sub pack()
378  
379 $value = $los_resp->pack();
380  
381 Returns the packed data packet.
382  
383 =cut
384  
385 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
386 2 my $self = shift ;
387
388 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
389 $self->{'packetType'},
390 $self->{'packetSize'},
391 $self->{'requestIdent'},
392 $self->{'_bitfields1'}, # Includes bitfields hostFrameNumberLSN, unused73, visible, entityIdentValid, and valid.
393 $self->{'responseCount'},
394 $self->{'entityIdent'},
395 2 $self->{'range'},
396 );
397  
398 2 return $self->{'_Buffer'};
399 }
400  
401 #==========================================================================
402  
403 =item sub unpack()
404  
405 $value = $los_resp->unpack();
406  
407 Unpacks the packed data packet.
408  
409 =cut
410  
411 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
412 0 my $self = shift @_;
413  
414 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
415 0 $self->{'_Buffer'} = shift @_;
416 }
417 0 my ($a,$b,$c,$d,$e,$f,$g) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
418 0 $self->{'packetType'} = $a;
419 0 $self->{'packetSize'} = $b;
420 0 $self->{'requestIdent'} = $c;
421 0 $self->{'_bitfields1'} = $d; # Includes bitfields hostFrameNumberLSN, unused73, visible, entityIdentValid, and valid.
422 0 $self->{'responseCount'} = $e;
423 0 $self->{'entityIdent'} = $f;
424 0 $self->{'range'} = $g;
425  
426 0 $self->{'hostFrameNumberLSN'} = $self->host_frame_number_lsn();
427 0 $self->{'visible'} = $self->visible();
428 0 $self->{'entityIdentValid'} = $self->entity_ident_valid();
429 0 $self->{'valid'} = $self->valid();
430  
431 0 return $self->{'_Buffer'};
432 }
433  
434 #==========================================================================
435  
436 =item sub byte_swap()
437  
438 $obj_name->byte_swap();
439  
440 Byte swaps the packed data packet.
441  
442 =cut
443  
444 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
445 0 my $self = shift @_;
446  
447 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
448 0 $self->{'_Buffer'} = shift @_;
449 } else {
450 0 $self->pack();
451 }
452 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
453  
454 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$h,$g);
455 0 $self->unpack();
456  
457 0 return $self->{'_Buffer'};
458 }
459  
460 2 1;
461 __END__
« CIGIPP/EnvironmentalConditionsRequest.pm ↑ Summary CIGIPP/EntityControl.pm »