CIGIPP/ConformalClampedEntityControl.pm

filter: Statementstmt 65.3% 51 / 78 Branchbran 30.7% 8 / 26 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 85.7% 12 / 14 Podpod 100% 10 / 10 totaltotal 57.4% 85 / 148 CC 19 SCAR 19.8
CC
19
Cov
54%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 7.2
« CIGIPP/AerosolConcentrationResponse.pm ↑ Summary CIGIPP/MaritimeSurfaceConditionsResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78aba5a-200e-11de-bda3-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::ConformalClampedEntityControl;
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::ConformalClampedEntityControl - Perl extension for the Common
42 Image Generator Interface - Conformal Clamped Entity Control data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::ConformalClampedEntityControl;
47 my $ccent_ctl = Rinchi::CIGIPP::ConformalClampedEntityControl->new();
48  
49 $packet_type = $ccent_ctl->packet_type();
50 $packet_size = $ccent_ctl->packet_size();
51 $entity_ident = $ccent_ctl->entity_ident(57935);
52 $yaw = $ccent_ctl->yaw(39.75);
53 $latitude = $ccent_ctl->latitude(57.645);
54 $longitude = $ccent_ctl->longitude(70.599);
55  
56 =head1 DESCRIPTION
57  
58 The Conformal Clamped Entity Control packet is used to set spatial data for
59 conformal, ground- or ocean-clamped entities. This packet is offered as a
60 lightweight alternative to the Entity Control packet.
61  
62 Because the entity type and other necessary attributes are not specified in
63 this packet, it may not be used to instantiate (create) an entity. Before using
64 this packet to manipulate an entity, the Host must first instantiate that
65 entity by sending an Entity Control packet and should set the Ground/Ocean
66 Clamp attribute to Conformal (2). If a non-existent entity is referenced by a
67 Conformal Clamped Entity Control packet, the packet will be ignored.
68  
69 An entity's current roll, pitch, and altitude offsets (specified in the last
70 Entity Control packet referencing the entity) will be maintained when the IG
71 receives a Conformal Clamped Entity Control packet describing that entity. If
72 this packet is applied to an unclamped or non-conformal clamped entity, its
73 current absolute roll, pitch, and altitude will be maintained.
74  
75 =head2 EXPORT
76  
77 None by default.
78  
79 #==============================================================================
80  
81 =item new $ccent_ctl = Rinchi::CIGIPP::ConformalClampedEntityControl->new()
82  
83 Constructor for Rinchi::ConformalClampedEntityControl.
84  
85 =cut
86  
87 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
88 2 my $class = shift;
89 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
90  
91 2 my $self = {
92 '_Buffer' => '',
93 '_ClassIdent' => 'f78aba5a-200e-11de-bda3-001c25551abc',
94 '_Pack' => 'CCSfdd',
95 '_Swap1' => 'CCvVVVVV',
96 '_Swap2' => 'CCnNNNNN',
97 'packetType' => 3,
98 'packetSize' => 24,
99 'entityIdent' => 0,
100 'yaw' => 0,
101 'latitude' => 0,
102 'longitude' => 0,
103 };
104  
105 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
106 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
107 0 $self->{'_Buffer'} = $_[0][0];
108 } elsif (ref($_[0]) eq 'HASH') {
109 0 foreach my $attr (keys %{$_[0]}) {
110 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
111 }
112 }
113 }
114  
115 2 bless($self,$class);
116 2 return $self;
117 }
118  
119 #==============================================================================
120  
121 =item sub packet_type()
122  
123 $value = $ccent_ctl->packet_type();
124  
125 Data Packet Identifier.
126  
127 This attribute identifies this data packet as the Conformal Clamped Entity
128 Control packet. The value of this attribute must be 3.
129  
130 =cut
131  
132 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
133 2 my ($self) = @_;
134 2 return $self->{'packetType'};
135 }
136  
137 #==============================================================================
138  
139 =item sub packet_size()
140  
141 $value = $ccent_ctl->packet_size();
142  
143 Data Packet Size.
144  
145 This attribute indicates the number of bytes in this data packet. Thevalue of
146 this attribute must be 24.
147  
148 =cut
149  
150 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
151 2 my ($self) = @_;
152 2 return $self->{'packetSize'};
153 }
154  
155 #==============================================================================
156  
157 =item sub entity_ident([$newValue])
158  
159 $value = $ccent_ctl->entity_ident($newValue);
160  
161 Entity ID.
162  
163 This attribute epresents the entity to which this packet will be applied. A
164 value of zero (0) corresponds to the Ownship.
165  
166 =cut
167  
168 2 ▶sub entity_ident() {
Subroutine entity_ident: called CC=2 SCAR=7.0
Pod documented
169 2 my ($self,$nv) = @_;
170 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
171 2 $self->{'entityIdent'} = $nv;
172 }
173 2 return $self->{'entityIdent'};
174 }
175  
176 #==============================================================================
177  
178 =item sub yaw([$newValue])
179  
180 $value = $ccent_ctl->yaw($newValue);
181  
182 Yaw.
183  
184 This attribute specifies the instantaneous heading of the entity as measured
185 from True North.
186  
187 =cut
188  
189 2 ▶sub yaw() {
Subroutine yaw: called CC=4 SCAR=15.9
Pod documented
190 2 my ($self,$nv) = @_;
191 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
192 2 ▶ if (($nv>=0) and ($nv<=360.0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv >= 0 and $nv <= 360.0) { } 2 0 2
Condition33%1/3
$nv >= 0 and $nv <= 360
!ll&&!rl&&r
002
MC/DC0%0/2
$nv >= 0 and $nv <= 360
$nv >= 0 $nv <= 360
Truth table33%1/3
A and B
A= $nv >= 0B= $nv <= 360
ABresult
0X0
100
111
193 2 $self->{'yaw'} = $nv;
194 } else {
195 0 carp "yaw must be from 0.0 to +360.0.";
196 }
197 }
198 2 return $self->{'yaw'};
199 }
200  
201 #==============================================================================
202  
203 =item sub latitude([$newValue])
204  
205 $value = $ccent_ctl->latitude($newValue);
206  
207 Latitude.
208  
209 This attribute specifies the entity's geodetic latitude.
210  
211 =cut
212  
213 2 ▶sub latitude() {
Subroutine latitude: called CC=4 SCAR=15.9
Pod documented
214 2 my ($self,$nv) = @_;
215 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
216 2 ▶ if (($nv>=-90) and ($nv<=90.0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv >= -90 and $nv <= 90.0) { } 2 0 2
Condition33%1/3
$nv >= -90 and $nv <= 90
!ll&&!rl&&r
002
MC/DC0%0/2
$nv >= -90 and $nv <= 90
$nv >= -90 $nv <= 90
Truth table33%1/3
A and B
A= $nv >= -90B= $nv <= 90
ABresult
0X0
100
111
217 2 $self->{'latitude'} = $nv;
218 } else {
219 0 carp "latitude must be from -90.0 to +90.0.";
220 }
221 }
222 2 return $self->{'latitude'};
223 }
224  
225 #==============================================================================
226  
227 =item sub longitude([$newValue])
228  
229 $value = $ccent_ctl->longitude($newValue);
230  
231 Longitude.
232  
233 This attribute specifies the entity's geodetic longitude.
234  
235 =cut
236  
237 2 ▶sub longitude() {
Subroutine longitude: called CC=4 SCAR=15.9
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>=-180.0) and ($nv<=180.0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv >= -180.0 and $nv <= 180.0) { } 2 0 2
Condition33%1/3
$nv >= -180 and $nv <= 180
!ll&&!rl&&r
002
MC/DC0%0/2
$nv >= -180 and $nv <= 180
$nv >= -180 $nv <= 180
Truth table33%1/3
A and B
A= $nv >= -180B= $nv <= 180
ABresult
0X0
100
111
241 2 $self->{'longitude'} = $nv;
242 } else {
243 0 carp "longitude must be from -180.0 to +180.0.";
244 }
245 }
246 2 return $self->{'longitude'};
247 }
248  
249 #==========================================================================
250  
251 =item sub pack()
252  
253 $value = $ccent_ctl->pack();
254  
255 Returns the packed data packet.
256  
257 =cut
258  
259 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
260 2 my $self = shift ;
261
262 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
263 $self->{'packetType'},
264 $self->{'packetSize'},
265 $self->{'entityIdent'},
266 $self->{'yaw'},
267 $self->{'latitude'},
268 2 $self->{'longitude'},
269 );
270  
271 2 return $self->{'_Buffer'};
272 }
273  
274 #==========================================================================
275  
276 =item sub unpack()
277  
278 $value = $ccent_ctl->unpack();
279  
280 Unpacks the packed data packet.
281  
282 =cut
283  
284 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
285 0 my $self = shift @_;
286
287 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
288 0 $self->{'_Buffer'} = shift @_;
289 }
290 0 my ($a,$b,$c,$d,$e,$f) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
291 0 $self->{'packetType'} = $a;
292 0 $self->{'packetSize'} = $b;
293 0 $self->{'entityIdent'} = $c;
294 0 $self->{'yaw'} = $d;
295 0 $self->{'latitude'} = $e;
296 0 $self->{'longitude'} = $f;
297  
298 0 return $self->{'_Buffer'};
299 }
300  
301 #==========================================================================
302  
303 =item sub byte_swap()
304  
305 $obj_name->byte_swap();
306  
307 Byte swaps the packed data packet.
308  
309 =cut
310  
311 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
312 0 my $self = shift @_;
313
314 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
315 0 $self->{'_Buffer'} = shift @_;
316 } else {
317 0 $self->pack();
318 }
319 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
320  
321 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$f,$e,$h,$g);
322 0 $self->unpack();
323  
324 0 return $self->{'_Buffer'};
325 }
326  
327 2 1;
328 __END__
« CIGIPP/AerosolConcentrationResponse.pm ↑ Summary CIGIPP/MaritimeSurfaceConditionsResponse.pm »