CIGIPP/PositionRequest.pm

filter: Statementstmt 66.2% 57 / 86 Branchbran 30.7% 8 / 26 Conditioncond 33.3% 7 / 21 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 86.6% 13 / 15 Podpod 100% 11 / 11 totaltotal 56.8% 96 / 169 CC 22 SCAR 21.2
CC
22
Cov
54%
new
19.6
object_class
12.4
coordinate_system
6.7
CRAP 8.4
« CIGIPP/AnimationStopNotification.pm ↑ Summary CIGIPP/TerrestrialSurfaceConditionsResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78afb28-200e-11de-bdbb-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::PositionRequest;
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::PositionRequest - Perl extension for the Common Image Generator
42 Interface - Position Request data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::PositionRequest;
47 my $pos_rqst = Rinchi::CIGIPP::PositionRequest->new();
48  
49 $packet_type = $pos_rqst->packet_type();
50 $packet_size = $pos_rqst->packet_size();
51 $object_ident = $pos_rqst->object_ident(43377);
52 $articulated_part_ident = $pos_rqst->articulated_part_ident(145);
53 $coordinate_system = $pos_rqst->coordinate_system(Rinchi::CIGIPP->ParentEntityCS);
54 $object_class = $pos_rqst->object_class(Rinchi::CIGIPP->EntityOC);
55 $update_mode = $pos_rqst->update_mode(0);
56  
57 =head1 DESCRIPTION
58  
59 The Position Request packet is used to query the IG for the current position of
60 an entity, articulated part, view,view group, or motion tracker. This feature
61 is useful for determining the locations of autonomous IG-driven entities, child
62 entities and articulated parts, and view eyepoints. It can also be used for
63 determining the instantaneous position and orientation of head trackers and
64 other tracked input devices.
65  
66 =head2 EXPORT
67  
68 None by default.
69  
70 #==============================================================================
71  
72 =item new $pos_rqst = Rinchi::CIGIPP::PositionRequest->new()
73  
74 Constructor for Rinchi::PositionRequest.
75  
76 =cut
77  
78 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
79 2 my $class = shift;
80 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
81  
82 2 my $self = {
83 '_Buffer' => '',
84 '_ClassIdent' => 'f78afb28-200e-11de-bdbb-001c25551abc',
85 '_Pack' => 'CCSCCS',
86 '_Swap1' => 'CCvCCv',
87 '_Swap2' => 'CCnCCn',
88 'packetType' => 27,
89 'packetSize' => 8,
90 'objectIdent' => 0,
91 'articulatedPartIdent' => 0,
92 '_bitfields1' => 0, # Includes bitfields unused47, coordinateSystem, objectClass, and updateMode.
93 'coordinateSystem' => 0,
94 'objectClass' => 0,
95 'updateMode' => 0,
96 '_unused48' => 0,
97 };
98  
99 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
100 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
101 0 $self->{'_Buffer'} = $_[0][0];
102 } elsif (ref($_[0]) eq 'HASH') {
103 0 foreach my $attr (keys %{$_[0]}) {
104 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
105 }
106 }
107 }
108  
109 2 bless($self,$class);
110 2 return $self;
111 }
112  
113 #==============================================================================
114  
115 =item sub packet_type()
116  
117 $value = $pos_rqst->packet_type();
118  
119 Data Packet Identifier.
120  
121 This attribute identifies this data packet as the Position Request packet. The
122 value of this attribute must be 27.
123  
124 =cut
125  
126 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
127 2 my ($self) = @_;
128 2 return $self->{'packetType'};
129 }
130  
131 #==============================================================================
132  
133 =item sub packet_size()
134  
135 $value = $pos_rqst->packet_size();
136  
137 Data Packet Size.
138  
139 This attribute indicates the number of bytes in this data packet. The value of
140 this attribute must be 8.
141  
142 =cut
143  
144 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
145 2 my ($self) = @_;
146 2 return $self->{'packetSize'};
147 }
148  
149 #==============================================================================
150  
151 =item sub object_ident([$newValue])
152  
153 $value = $pos_rqst->object_ident($newValue);
154  
155 Object ID.
156  
157 This attribute identifies the entity, view, view group, or motion tracking
158 device whose position is being requested.
159  
160 If Object Class is set to Articulated Part (1), this attribute specifies the
161 entity whose part is identified by the Articulated Part ID attribute.
162  
163 =cut
164  
165 2 ▶sub object_ident() {
Subroutine object_ident: called CC=2 SCAR=7.0
Pod documented
166 2 my ($self,$nv) = @_;
167 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
168 2 $self->{'objectIdent'} = $nv;
169 }
170 2 return $self->{'objectIdent'};
171 }
172  
173 #==============================================================================
174  
175 =item sub articulated_part_ident([$newValue])
176  
177 $value = $pos_rqst->articulated_part_ident($newValue);
178  
179 Articulated Part ID.
180  
181 This attribute identifies the articulated part whose position is being
182 requested. The entity to which the part belongs is specified by the Object ID
183 attribute. This attribute is valid only when Object Class is set to Articulated
184 Part (1).
185  
186 =cut
187  
188 2 ▶sub articulated_part_ident() {
Subroutine articulated_part_ident: called CC=2 SCAR=7.0
Pod documented
189 2 my ($self,$nv) = @_;
190 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
191 2 $self->{'articulatedPartIdent' } = $nv;
192 }
193 2 return $self->{'articulatedPartIdent' };
194 }
195  
196 #==============================================================================
197  
198 =item sub coordinate_system([$newValue])
199  
200 $value = $pos_rqst->coordinate_system($newValue);
201  
202 Coordinate System.
203  
204 This attribute specifies the desired coordinate system relative to which the
205 position and orientation should be given.
206  
207 Geodetic – Position will be specified as a geodetic latitude, longitude, and
208 altitude. Orientation is given with respect to the reference plane.
209  
210 Parent Entity – Position and orientation are with respect to the entity to
211 which the specified entity or view is attached. This value is invalid for
212 top-level entities.
213  
214 Submodel – Position and orientation will be specified with respect to the
215 articulated part's reference coordinate system. This value is valid only when
216 Object Class is set to Articulated Part (1).
217  
218 Note: If Object Class is set to Motion Tracker (3), The coordinate system is
219 defined by the tracking device and this attribute is ignored.
220  
221 GeodeticCS 0
222 ParentEntityCS 1
223 SubmodelCS 2
224  
225 =cut
226  
227 2 ▶sub coordinate_system() {
Subroutine coordinate_system: called CC=5 SCAR=19.1
Pod documented
228 2 my ($self,$nv) = @_;
229 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
230 2 ▶ if (($nv==0) or ($nv==1) or ($nv==2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1 or $nv == 2) { } 2 0 2
Condition33%2/6
$nv == 0 or $nv == 1 or $nv == 2
l!l&&r!l&&!r
200
$nv == 0 or $nv == 1
l!l&&r!l&&!r
020
MC/DC0%0/3
$nv == 0 or $nv == 1 or $nv == 2
$nv == 0 $nv == 1 $nv == 2
Truth table25%1/4
A or B or C
A= $nv == 0B= $nv == 1C= $nv == 2
ABCresult
1XX1
01X1
0011
0000
231 2 $self->{'coordinateSystem'} = $nv;
232 2 $self->{'_bitfields1'} |= ($nv << 4) &0x30;
233 } else {
234 0 carp "coordinate_system must be 0 (GeodeticCS), 1 (ParentEntityCS), or 2 (SubmodelCS).";
235 }
236 }
237 2 return (($self->{'_bitfields1'} & 0x30) >> 4);
238 }
239  
240 #==============================================================================
241  
242 =item sub object_class([$newValue])
243  
244 $value = $pos_rqst->object_class($newValue);
245  
246 Object Class.
247  
248 This attribute specifies the type of object whose position is being requested.
249  
250 EntityOC 0
251 ArticulatedPartOC 1
252 ViewOC 2
253 ViewGroupOC 3
254 MotionTrackerOC 4
255  
256 =cut
257  
258 2 ▶sub object_class() {
Subroutine object_class: called CC=7 SCAR=25.1
Pod documented
259 2 my ($self,$nv) = @_;
260 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
261 2 ▶ if (($nv==0) or ($nv==1) or ($nv==2) or ($nv==3) or ($nv==4)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1 or $nv == 2 or $nv == 3 or $nv == 4) { } 2 0 2
Condition33%4/12
$nv == 0 or $nv == 1 or $nv == 2 or $nv == 3 or $nv == 4
l!l&&r!l&&!r
200
$nv == 0 or $nv == 1 or $nv == 2 or $nv == 3
l!l&&r!l&&!r
200
$nv == 0 or $nv == 1 or $nv == 2
l!l&&r!l&&!r
200
$nv == 0 or $nv == 1
l!l&&r!l&&!r
200
MC/DC0%0/5
$nv == 0 or $nv == 1 or $nv == 2 or $nv == 3 or $nv == 4
$nv == 0 $nv == 1 $nv == 2 $nv == 3 $nv == 4
Truth table16%1/6
A or B or C or D or E
A= $nv == 0B= $nv == 1C= $nv == 2D= $nv == 3E= $nv == 4
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
262 2 $self->{'objectClass'} = $nv;
263 2 $self->{'_bitfields1'} |= ($nv << 1) &0x0E;
264 } else {
265 0 carp "object_class must be 0 (EntityOC), 1 (ArticulatedPartOC), 2 (ViewOC), 3 (ViewGroupOC), or 4 (MotionTrackerOC).";
266 }
267 }
268 2 return (($self->{'_bitfields1'} & 0x0E) >> 1);
269 }
270  
271 #==============================================================================
272  
273 =item sub update_mode([$newValue])
274  
275 $value = $pos_rqst->update_mode($newValue);
276  
277 Update Mode.
278  
279 This attribute specifies whether the IG should report the position of the
280 requested object each frame. If this attribute is set to One-Shot (0), the IG
281 should report the position only one time.
282  
283 =cut
284  
285 2 ▶sub update_mode() {
Subroutine update_mode: called CC=2 SCAR=7.0
Pod documented
286 2 my ($self,$nv) = @_;
287 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
288 2 $self->{'updateMode'} = $nv;
289 2 $self->{'_bitfields1'} |= $nv &0x01;
290 }
291 2 return ($self->{'_bitfields1'} & 0x01);
292 }
293  
294 #==========================================================================
295  
296 =item sub pack()
297  
298 $value = $pos_rqst->pack();
299  
300 Returns the packed data packet.
301  
302 =cut
303  
304 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
305 2 my $self = shift ;
306
307 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
308 $self->{'packetType'},
309 $self->{'packetSize'},
310 $self->{'objectIdent'},
311 $self->{'articulatedPartIdent' },
312 $self->{'_bitfields1'}, # Includes bitfields unused47, coordinateSystem, objectClass, and updateMode.
313 2 $self->{'_unused48'},
314 );
315  
316 2 return $self->{'_Buffer'};
317 }
318  
319 #==========================================================================
320  
321 =item sub unpack()
322  
323 $value = $pos_rqst->unpack();
324  
325 Unpacks the packed data packet.
326  
327 =cut
328  
329 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
330 0 my $self = shift @_;
331
332 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
333 0 $self->{'_Buffer'} = shift @_;
334 }
335 0 my ($a,$b,$c,$d,$e,$f) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
336 0 $self->{'packetType'} = $a;
337 0 $self->{'packetSize'} = $b;
338 0 $self->{'objectIdent'} = $c;
339 0 $self->{'articulatedPartIdent' } = $d;
340 0 $self->{'_bitfields1'} = $e; # Includes bitfields unused47, coordinateSystem, objectClass, and updateMode.
341 0 $self->{'_unused48'} = $f;
342  
343 0 $self->{'coordinateSystem'} = $self->coordinate_system();
344 0 $self->{'objectClass'} = $self->object_class();
345 0 $self->{'updateMode'} = $self->update_mode();
346  
347 0 return $self->{'_Buffer'};
348 }
349  
350 #==========================================================================
351  
352 =item sub byte_swap()
353  
354 $obj_name->byte_swap();
355  
356 Byte swaps the packed data packet.
357  
358 =cut
359  
360 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
361 0 my $self = shift @_;
362
363 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
364 0 $self->{'_Buffer'} = shift @_;
365 } else {
366 0 $self->pack();
367 }
368 0 my ($a,$b,$c,$d,$e,$f) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
369  
370 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f);
371 0 $self->unpack();
372  
373 0 return $self->{'_Buffer'};
374 }
375  
376 2 1;
377 __END__
« CIGIPP/AnimationStopNotification.pm ↑ Summary CIGIPP/TerrestrialSurfaceConditionsResponse.pm »