CIGIPP/TrajectoryDefinition.pm

filter: Statementstmt 68.2% 56 / 82 Branchbran 29.1% 7 / 24 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 14 / 16 Podpod 100% 12 / 12 totaltotal 64.7% 90 / 139 CC 15 SCAR 18.6
CC
15
Cov
59%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 6.4
« CIGIPP/CollisionDetectionSegmentNotification.pm ↑ Summary CIGIPP/MaritimeSurfaceConditionsControl.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78ae818-200e-11de-bdb4-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::TrajectoryDefinition;
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::TrajectoryDefinition - Perl extension for the Common Image
42 Generator Interface - Trajectory Definition data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::TrajectoryDefinition;
47 my $traj_def = Rinchi::CIGIPP::TrajectoryDefinition->new();
48  
49 $packet_type = $traj_def->packet_type();
50 $packet_size = $traj_def->packet_size();
51 $entity_ident = $traj_def->entity_ident(55021);
52 $x_acceleration = $traj_def->x_acceleration(60.29);
53 $y_acceleration = $traj_def->y_acceleration(33.53);
54 $z_acceleration = $traj_def->z_acceleration(3.749);
55 $retardation_rate = $traj_def->retardation_rate(5.483);
56 $terminal_velocity = $traj_def->terminal_velocity(84.799);
57  
58 =head1 DESCRIPTION
59  
60 The Trajectory Definition packet enables the Host to describe a trajectory
61 along which an IG-driven entity, such as a tracer round or particulate debris,
62 travels. This is useful for simulating gravity and other static forces acting
63 upon the entity. This packet is commonly used in conjunction with the Rate
64 Control packet.
65  
66 =head2 EXPORT
67  
68 None by default.
69  
70 #==============================================================================
71  
72 =item new $traj_def = Rinchi::CIGIPP::TrajectoryDefinition->new()
73  
74 Constructor for Rinchi::TrajectoryDefinition.
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' => 'f78ae818-200e-11de-bdb4-001c25551abc',
85 '_Pack' => 'CCSfffff',
86 '_Swap1' => 'CCvVVVVV',
87 '_Swap2' => 'CCnNNNNN',
88 'packetType' => 20,
89 'packetSize' => 24,
90 'entityIdent' => 0,
91 'xAcceleration' => 0,
92 'yAcceleration' => 0,
93 'zAcceleration' => 0,
94 'retardationRate' => 0,
95 'terminalVelocity' => 0,
96 };
97  
98 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
99 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
100 0 $self->{'_Buffer'} = $_[0][0];
101 } elsif (ref($_[0]) eq 'HASH') {
102 0 foreach my $attr (keys %{$_[0]}) {
103 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
104 }
105 }
106 }
107  
108 2 bless($self,$class);
109 2 return $self;
110 }
111  
112 #==============================================================================
113  
114 =item sub packet_type()
115  
116 $value = $traj_def->packet_type();
117  
118 Data Packet Identifier.
119  
120 This attribute identifies this data packet as the Trajectory Definition packet.
121 The value of this attribute must be 20.
122  
123 =cut
124  
125 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
126 2 my ($self) = @_;
127 2 return $self->{'packetType'};
128 }
129  
130 #==============================================================================
131  
132 =item sub packet_size()
133  
134 $value = $traj_def->packet_size();
135  
136 Data Packet Size.
137  
138 This attribute indicates the number of bytes in this data packet. The value of
139 this attribute must be 24.
140  
141 =cut
142  
143 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
144 2 my ($self) = @_;
145 2 return $self->{'packetSize'};
146 }
147  
148 #==============================================================================
149  
150 =item sub entity_ident([$newValue])
151  
152 $value = $traj_def->entity_ident($newValue);
153  
154 Entity ID.
155  
156 This attribute identifies the entity for which the trajectory is defined.
157  
158 =cut
159  
160 2 ▶sub entity_ident() {
Subroutine entity_ident: called CC=2 SCAR=7.0
Pod documented
161 2 my ($self,$nv) = @_;
162 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
163 2 $self->{'entityIdent'} = $nv;
164 }
165 2 return $self->{'entityIdent'};
166 }
167  
168 #==============================================================================
169  
170 =item sub x_acceleration([$newValue])
171  
172 $value = $traj_def->x_acceleration($newValue);
173  
174 Acceleration X.
175  
176 This attribute specifies the X component of the acceleration vector.
177  
178 =cut
179  
180 2 ▶sub x_acceleration() {
Subroutine x_acceleration: 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->{'xAcceleration'} = $nv;
184 }
185 2 return $self->{'xAcceleration'};
186 }
187  
188 #==============================================================================
189  
190 =item sub y_acceleration([$newValue])
191  
192 $value = $traj_def->y_acceleration($newValue);
193  
194 Acceleration Y.
195  
196 This attribute specifies the Y component of the acceleration vector.
197  
198 =cut
199  
200 2 ▶sub y_acceleration() {
Subroutine y_acceleration: called CC=2 SCAR=7.0
Pod documented
201 2 my ($self,$nv) = @_;
202 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
203 2 $self->{'yAcceleration'} = $nv;
204 }
205 2 return $self->{'yAcceleration'};
206 }
207  
208 #==============================================================================
209  
210 =item sub z_acceleration([$newValue])
211  
212 $value = $traj_def->z_acceleration($newValue);
213  
214 Acceleration Z.
215  
216 This attribute specifies the Z component of the acceleration vector.
217  
218 =cut
219  
220 2 ▶sub z_acceleration() {
Subroutine z_acceleration: called CC=2 SCAR=7.0
Pod documented
221 2 my ($self,$nv) = @_;
222 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
223 2 $self->{'zAcceleration'} = $nv;
224 }
225 2 return $self->{'zAcceleration'};
226 }
227  
228 #==============================================================================
229  
230 =item sub retardation_rate([$newValue])
231  
232 $value = $traj_def->retardation_rate($newValue);
233  
234 Retardation Rate.
235  
236 This attribute specifies the magnitude of an acceleration applied against the
237 entity's instantaneous linear velocity vector. This is used to simulate drag
238 and other frictional forces acting upon the entity.
239  
240 =cut
241  
242 2 ▶sub retardation_rate() {
Subroutine retardation_rate: called CC=2 SCAR=7.0
Pod documented
243 2 my ($self,$nv) = @_;
244 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
245 2 $self->{'retardationRate'} = $nv;
246 }
247 2 return $self->{'retardationRate'};
248 }
249  
250 #==============================================================================
251  
252 =item sub terminal_velocity([$newValue])
253  
254 $value = $traj_def->terminal_velocity($newValue);
255  
256 Terminal Velocity.
257  
258 This attribute specifies the maximum velocity the entity can sustain.
259  
260 =cut
261  
262 2 ▶sub terminal_velocity() {
Subroutine terminal_velocity: called CC=2 SCAR=7.0
Pod documented
263 2 my ($self,$nv) = @_;
264 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
265 2 $self->{'terminalVelocity'} = $nv;
266 }
267 2 return $self->{'terminalVelocity'};
268 }
269  
270 #==========================================================================
271  
272 =item sub pack()
273  
274 $value = $traj_def->pack();
275  
276 Returns the packed data packet.
277  
278 =cut
279  
280 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
281 2 my $self = shift ;
282
283 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
284 $self->{'packetType'},
285 $self->{'packetSize'},
286 $self->{'entityIdent'},
287 $self->{'xAcceleration'},
288 $self->{'yAcceleration'},
289 $self->{'zAcceleration'},
290 $self->{'retardationRate'},
291 2 $self->{'terminalVelocity'},
292 );
293  
294 2 return $self->{'_Buffer'};
295 }
296  
297 #==========================================================================
298  
299 =item sub unpack()
300  
301 $value = $traj_def->unpack();
302  
303 Unpacks the packed data packet.
304  
305 =cut
306  
307 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
308 0 my $self = shift @_;
309
310 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
311 0 $self->{'_Buffer'} = shift @_;
312 }
313 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
314 0 $self->{'packetType'} = $a;
315 0 $self->{'packetSize'} = $b;
316 0 $self->{'entityIdent'} = $c;
317 0 $self->{'xAcceleration'} = $d;
318 0 $self->{'yAcceleration'} = $e;
319 0 $self->{'zAcceleration'} = $f;
320 0 $self->{'retardationRate'} = $g;
321 0 $self->{'terminalVelocity'} = $h;
322  
323 0 return $self->{'_Buffer'};
324 }
325  
326 #==========================================================================
327  
328 =item sub byte_swap()
329  
330 $obj_name->byte_swap();
331  
332 Byte swaps the packed data packet.
333  
334 =cut
335  
336 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
337 0 my $self = shift @_;
338
339 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
340 0 $self->{'_Buffer'} = shift @_;
341 } else {
342 0 $self->pack();
343 }
344 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
345  
346 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g,$h);
347 0 $self->unpack();
348  
349 0 return $self->{'_Buffer'};
350 }
351  
352 2 1;
353 __END__
« CIGIPP/CollisionDetectionSegmentNotification.pm ↑ Summary CIGIPP/MaritimeSurfaceConditionsControl.pm »