CIGIPP/MaritimeSurfaceConditionsControl.pm

filter: Statementstmt 67.3% 70 / 104 Branchbran 35.2% 12 / 34 Conditioncond 33.3% 5 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 88.8% 16 / 18 Podpod 100% 14 / 14 totaltotal 60.3% 117 / 194 CC 24 SCAR 18.5
CC
24
Cov
57%
new
19.6
scope
6.7
unpack
6.0
CRAP 6.3
« CIGIPP/TrajectoryDefinition.pm ↑ Summary CIGIPP/AtmosphereControl.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78ad594-200e-11de-bdad-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::MaritimeSurfaceConditionsControl;
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::MaritimeSurfaceConditionsControl - Perl extension for the
42 Common Image Generator Interface - Maritime Surface Conditions Control data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::MaritimeSurfaceConditionsControl;
47 my $msc_ctl = Rinchi::CIGIPP::MaritimeSurfaceConditionsControl->new();
48  
49 $packet_type = $msc_ctl->packet_type();
50 $packet_size = $msc_ctl->packet_size();
51 $entity_ident = $msc_ctl->entity_ident(51957);
52 $region_ident = $msc_ctl->region_ident(64233);
53 $scope = $msc_ctl->scope(Rinchi::CIGIPP->GlobalScope);
54 $whitecap_enable = $msc_ctl->whitecap_enable(Rinchi::CIGIPP->Disable);
55 $surface_conditions_enable = $msc_ctl->surface_conditions_enable(Rinchi::CIGIPP->Disable);
56 $sea_surface_height = $msc_ctl->sea_surface_height(32.113);
57 $surface_water_temperature = $msc_ctl->surface_water_temperature(0.898);
58 $surface_clarity = $msc_ctl->surface_clarity(56.091);
59  
60 =head1 DESCRIPTION
61  
62 The Maritime Surface Conditions Control packet is used to specify the surface
63 behavior for seas and other bodies of water. This packet is used in conjunction
64 with the Weather Control and Wave Control packets to define sea states.
65  
66 Regional maritime surface conditions always take precedence over the global
67 surface conditions. Once the surface conditions of a region are set, global
68 changes will not affect the surface conditions within that region unless it is
69 disabled. Global changes will, however, contribute to the conditions within a
70 region's transition perimeter.
71  
72 If two or more regions overlap, the value of each surface condition attribute
73 defining the sea state within the area of overlap should be the average of the
74 values determined by overlapping the regions.
75  
76 To determine the maritime surface conditions within areas of overlap or through
77 a transition perimeter, the Host can request the conditions at a specific
78 latitude and longitude by issuing an Environmental Conditions Request packet.
79 The Host can request the instantaneous height of the water surface at a
80 specific latitude and longitude by sending a HAT/HOT Request packet.
81  
82 =head2 EXPORT
83  
84 None by default.
85  
86 #==============================================================================
87  
88 =item new $msc_ctl = Rinchi::CIGIPP::MaritimeSurfaceConditionsControl->new()
89  
90 Constructor for Rinchi::MaritimeSurfaceConditionsControl.
91  
92 =cut
93  
94 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
95 2 my $class = shift;
96 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
97  
98 2 my $self = {
99 '_Buffer' => '',
100 '_ClassIdent' => 'f78ad594-200e-11de-bdad-001c25551abc',
101 '_Pack' => 'CCSCCSfffI',
102 '_Swap1' => 'CCvCCvVVVV',
103 '_Swap2' => 'CCnCCnNNNN',
104 'packetType' => 13,
105 'packetSize' => 24,
106 'region_entityIdent' => 0,
107 '_bitfields1' => 0, # Includes bitfields unused22, scope, whitecapEnable, and surfaceConditionsEnable.
108 'scope' => 0,
109 'whitecapEnable' => 0,
110 'surfaceConditionsEnable' => 0,
111 '_unused23' => 0,
112 '_unused24' => 0,
113 'seaSurfaceHeight' => 0,
114 'surfaceWaterTemperature' => 0,
115 'surfaceClarity' => 0,
116 '_unused25' => 0,
117 };
118  
119 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
120 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
121 0 $self->{'_Buffer'} = $_[0][0];
122 } elsif (ref($_[0]) eq 'HASH') {
123 0 foreach my $attr (keys %{$_[0]}) {
124 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
125 }
126 }
127 }
128  
129 2 bless($self,$class);
130 2 return $self;
131 }
132  
133 #==============================================================================
134  
135 =item sub packet_type()
136  
137 $value = $msc_ctl->packet_type();
138  
139 Data Packet Identifier.
140  
141 This attribute identifies this data packet as the Maritime Surface Conditions
142 Control packet. The value of this attribute must be 13.
143  
144 =cut
145  
146 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
147 2 my ($self) = @_;
148 2 return $self->{'packetType'};
149 }
150  
151 #==============================================================================
152  
153 =item sub packet_size()
154  
155 $value = $msc_ctl->packet_size();
156  
157 Data Packet Size.
158  
159 This attribute indicates the number of bytes in this data packet. The value of
160 this attribute must be 24.
161  
162 =cut
163  
164 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
165 2 my ($self) = @_;
166 2 return $self->{'packetSize'};
167 }
168  
169 #==============================================================================
170  
171 =item sub entity_ident([$newValue])
172  
173 $value = $msc_ctl->entity_ident($newValue);
174  
175 Entity ID. (Entity-based Surface Conditions)
176  
177 This attribute specifies the entity to which the surface attributes in this
178 packet are applied.
179  
180 =cut
181  
182 2 ▶sub entity_ident() {
Subroutine entity_ident: called CC=2 SCAR=7.0
Pod documented
183 2 my ($self,$nv) = @_;
184 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
185 2 $self->{'region_entityIdent'} = $nv;
186 }
187 2 return $self->{'region_entityIdent'};
188 }
189  
190 #==============================================================================
191  
192 =item sub region_ident([$newValue])
193  
194 $value = $msc_ctl->region_ident($newValue);
195  
196 Region ID. (Regional Surface Conditions)
197  
198 This attribute specifies the region to which the surface attributes are
199 confined.
200 Note: Entity ID/Region ID is ignored if Scope is set to Global (0).
201  
202 =cut
203  
204 2 ▶sub region_ident() {
Subroutine region_ident: called CC=2 SCAR=7.0
Pod documented
205 2 my ($self,$nv) = @_;
206 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
207 2 $self->{'region_entityIdent'} = $nv;
208 }
209 2 return $self->{'region_entityIdent'};
210 }
211  
212 #==============================================================================
213  
214 =item sub scope([$newValue])
215  
216 $value = $msc_ctl->scope($newValue);
217  
218 Scope.
219  
220 This attribute specifies whether this packet is applied globally, applied to a
221 region, or assigned to an entity. If this value is set to Regional (1), the
222 surface condition properties are applied only within the region specified by
223 Region ID. If this value is set to Entity (2), the properties are applied to
224 the area defined by the moving model specified by Entity ID.
225  
226 GlobalScope 0
227 RegionalScope 1
228 EntityScope 2
229  
230 =cut
231  
232 2 ▶sub scope() {
Subroutine scope: called CC=5 SCAR=19.1
Pod documented
233 2 my ($self,$nv) = @_;
234 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
235 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
200
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
236 2 $self->{'scope'} = $nv;
237 2 $self->{'_bitfields1'} |= ($nv << 2) &0x0C;
238 } else {
239 0 carp "scope must be 0 (GlobalScope), 1 (RegionalScope), or 2 (EntityScope).";
240 }
241 }
242 2 return (($self->{'_bitfields1'} & 0x0C) >> 2);
243 }
244  
245 #==============================================================================
246  
247 =item sub whitecap_enable([$newValue])
248  
249 $value = $msc_ctl->whitecap_enable($newValue);
250  
251 Whitecap Enable.
252  
253 This attribute determines whether whitecaps are enabled.
254  
255 Disable 0
256 Enable 1
257  
258 =cut
259  
260 2 ▶sub whitecap_enable() {
Subroutine whitecap_enable: called CC=4 SCAR=15.5
Pod documented
261 2 my ($self,$nv) = @_;
262 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
263 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
264 2 $self->{'whitecapEnable'} = $nv;
265 2 $self->{'_bitfields1'} |= ($nv << 1) &0x02;
266 } else {
267 0 carp "whitecap_enable must be 0 (Disable), or 1 (Enable).";
268 }
269 }
270 2 return (($self->{'_bitfields1'} & 0x02) >> 1);
271 }
272  
273 #==============================================================================
274  
275 =item sub surface_conditions_enable([$newValue])
276  
277 $value = $msc_ctl->surface_conditions_enable($newValue);
278  
279 Surface Conditions Enable.
280  
281 This attribute determines the state of the specified surface conditions. If
282 this attribute is set to Disable (0), the surface conditions within the region
283 or entity are the same as the global maritime surface conditions. If the
284 attribute is set to Enable (1), the surface conditions are defined by this
285 packet.
286 This attribute is ignored if Scope is set to Global (0).
287  
288 Disable 0
289 Enable 1
290  
291 =cut
292  
293 2 ▶sub surface_conditions_enable() {
Subroutine surface_conditions_enable: called CC=4 SCAR=15.5
Pod documented
294 2 my ($self,$nv) = @_;
295 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
296 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
297 2 $self->{'surfaceConditionsEnable'} = $nv;
298 2 $self->{'_bitfields1'} |= $nv &0x01;
299 } else {
300 0 carp "surface_conditions_enable must be 0 (Disable), or 1 (Enable).";
301 }
302 }
303 2 return ($self->{'_bitfields1'} & 0x01);
304 }
305  
306 #==============================================================================
307  
308 =item sub sea_surface_height([$newValue])
309  
310 $value = $msc_ctl->sea_surface_height($newValue);
311  
312 Sea Surface Height.
313  
314 This attribute specifies the height of the water above MSL at equilibrium. This
315 attribute can also be used to specify the tide level within the surf zone.
316  
317 =cut
318  
319 2 ▶sub sea_surface_height() {
Subroutine sea_surface_height: called CC=2 SCAR=7.0
Pod documented
320 2 my ($self,$nv) = @_;
321 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
322 2 $self->{'seaSurfaceHeight'} = $nv;
323 }
324 2 return $self->{'seaSurfaceHeight'};
325 }
326  
327 #==============================================================================
328  
329 =item sub surface_water_temperature([$newValue])
330  
331 $value = $msc_ctl->surface_water_temperature($newValue);
332  
333 Surface Water Temperature.
334  
335 This attribute specifies in degrees Celsius the water temperature at the surface.
336  
337 =cut
338  
339 2 ▶sub surface_water_temperature() {
Subroutine surface_water_temperature: called CC=2 SCAR=7.0
Pod documented
340 2 my ($self,$nv) = @_;
341 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
342 2 $self->{'surfaceWaterTemperature'} = $nv;
343 }
344 2 return $self->{'surfaceWaterTemperature'};
345 }
346  
347 #==============================================================================
348  
349 =item sub surface_clarity([$newValue])
350  
351 $value = $msc_ctl->surface_clarity($newValue);
352  
353 Surface Clarity.
354  
355 This attribute specifies the clarity of the water at its surface. This is used
356 to control the visual effect of the water's turbidity and sediment type. A
357 value of 100% indicates pristine water. A value of 0% indicates extremely
358 turbid water.
359  
360 =cut
361  
362 2 ▶sub surface_clarity() {
Subroutine surface_clarity: called CC=2 SCAR=7.0
Pod documented
363 2 my ($self,$nv) = @_;
364 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
365 2 $self->{'surfaceClarity'} = $nv;
366 }
367 2 return $self->{'surfaceClarity'};
368 }
369  
370 #==========================================================================
371  
372 =item sub pack()
373  
374 $value = $msc_ctl->pack();
375  
376 Returns the packed data packet.
377  
378 =cut
379  
380 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
381 2 my $self = shift ;
382
383 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
384 $self->{'packetType'},
385 $self->{'packetSize'},
386 $self->{'region_entityIdent'},
387 $self->{'_bitfields1'}, # Includes bitfields unused22, scope, whitecapEnable, and surfaceConditionsEnable.
388 $self->{'_unused23'},
389 $self->{'_unused24'},
390 $self->{'seaSurfaceHeight'},
391 $self->{'surfaceWaterTemperature'},
392 $self->{'surfaceClarity'},
393 2 $self->{'_unused25'},
394 );
395  
396 2 return $self->{'_Buffer'};
397 }
398  
399 #==========================================================================
400  
401 =item sub unpack()
402  
403 $value = $msc_ctl->unpack();
404  
405 Unpacks the packed data packet.
406  
407 =cut
408  
409 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
410 0 my $self = shift @_;
411
412 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
413 0 $self->{'_Buffer'} = shift @_;
414 }
415 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
416 0 $self->{'packetType'} = $a;
417 0 $self->{'packetSize'} = $b;
418 0 $self->{'region_entityIdent'} = $c;
419 0 $self->{'_bitfields1'} = $d; # Includes bitfields unused22, scope, whitecapEnable, and surfaceConditionsEnable.
420 0 $self->{'_unused23'} = $e;
421 0 $self->{'_unused24'} = $f;
422 0 $self->{'seaSurfaceHeight'} = $g;
423 0 $self->{'surfaceWaterTemperature'} = $h;
424 0 $self->{'surfaceClarity'} = $i;
425 0 $self->{'_unused25'} = $j;
426  
427 0 $self->{'scope'} = $self->scope();
428 0 $self->{'whitecapEnable'} = $self->whitecap_enable();
429 0 $self->{'surfaceConditionsEnable'} = $self->surface_conditions_enable();
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,$i,$j) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
453  
454 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g,$h,$i,$j);
455 0 $self->unpack();
456  
457 0 return $self->{'_Buffer'};
458 }
459  
460 2 1;
461 __END__
« CIGIPP/TrajectoryDefinition.pm ↑ Summary CIGIPP/AtmosphereControl.pm »