CIGIPP/AtmosphereControl.pm

filter: Statementstmt 67.6% 67 / 99 Branchbran 34.3% 11 / 32 Conditioncond 41.6% 5 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 88.8% 16 / 18 Podpod 100% 14 / 14 totaltotal 62.0% 113 / 182 CC 22 SCAR 18.4
CC
22
Cov
58%
new
19.6
humidity
7.1
unpack
6.0
CRAP 6.3
« CIGIPP/MaritimeSurfaceConditionsControl.pm ↑ Summary CIGIPP/WeatherConditionsResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78acd92-200e-11de-bdaa-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::AtmosphereControl;
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::AtmosphereControl - Perl extension for the Common Image
42 Generator Interface - Atmosphere Control data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::AtmosphereControl;
47 my $atmos_ctl = Rinchi::CIGIPP::AtmosphereControl->new();
48  
49 $packet_type = $atmos_ctl->packet_type();
50 $packet_size = $atmos_ctl->packet_size();
51 $atmospheric_model_enable = $atmos_ctl->atmospheric_model_enable(Rinchi::CIGIPP->Disable);
52 $humidity = $atmos_ctl->humidity(35);
53 $air_temperature = $atmos_ctl->air_temperature(23.357);
54 $visibility_range = $atmos_ctl->visibility_range(47.803);
55 $horizontal_wind_speed = $atmos_ctl->horizontal_wind_speed(55.727);
56 $vertical_wind_speed = $atmos_ctl->vertical_wind_speed(40.386);
57 $wind_direction = $atmos_ctl->wind_direction(47.212);
58 $barometric_pressure = $atmos_ctl->barometric_pressure(17.871);
59  
60 =head1 DESCRIPTION
61  
62 The Atmosphere Control data packet allows the Host to control global
63 atmospheric properties within the simulation.
64  
65 Weather layers and weather entities always take precedence over the global
66 atmospheric conditions. Once the atmospheric properties of a layer or entity
67 are set, global atmospheric changes will not affect the weather inside the
68 layer or entity unless that layer or entity is disabled. The global atmospheric
69 changes will, however, affect the weather within a transition band or
70 transition perimeter.
71  
72 CIGI supports the use of FASCODE, MODTRAN, SEDRIS, or other atmospheric models
73 for determining radiance and transmittance within a heterogeneous atmosphere
74 for sensor simulations. The Atmospheric Model Enable attribute determines
75 whether an atmospheric model is used. The particular model is not specified and
76 is determined by the IG.
77  
78 =head2 EXPORT
79  
80 None by default.
81  
82 #==============================================================================
83  
84 =item new $atmos_ctl = Rinchi::CIGIPP::AtmosphereControl->new()
85  
86 Constructor for Rinchi::AtmosphereControl.
87  
88 =cut
89  
90 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
91 2 my $class = shift;
92 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
93  
94 2 my $self = {
95 '_Buffer' => '',
96 '_ClassIdent' => 'f78acd92-200e-11de-bdaa-001c25551abc',
97 '_Pack' => 'CCCCffffffI',
98 '_Swap1' => 'CCCCVVVVVVV',
99 '_Swap2' => 'CCCCNNNNNNN',
100 'packetType' => 10,
101 'packetSize' => 32,
102 '_bitfields1' => 0, # Includes bitfields unused15, and atmosphericModelEnable.
103 'atmosphericModelEnable' => 0,
104 'humidity' => 0,
105 'airTemperature' => 0,
106 'visibilityRange' => 0,
107 'horizontalWindSpeed' => 0,
108 'verticalWindSpeed' => 0,
109 'windDirection' => 0,
110 'barometricPressure' => 0,
111 '_unused16' => 0,
112 };
113  
114 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
115 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
116 0 $self->{'_Buffer'} = $_[0][0];
117 } elsif (ref($_[0]) eq 'HASH') {
118 0 foreach my $attr (keys %{$_[0]}) {
119 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
120 }
121 }
122 }
123  
124 2 bless($self,$class);
125 2 return $self;
126 }
127  
128 #==============================================================================
129  
130 =item sub packet_type()
131  
132 $value = $atmos_ctl->packet_type();
133  
134 Data Packet Identifier.
135  
136 This attribute identifies this data packet as the Atmosphere Control packet.
137 The value of this attribute must be 10.
138  
139 =cut
140  
141 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
142 2 my ($self) = @_;
143 2 return $self->{'packetType'};
144 }
145  
146 #==============================================================================
147  
148 =item sub packet_size()
149  
150 $value = $atmos_ctl->packet_size();
151  
152 Data Packet Size.
153  
154 This attribute indicates the number of bytes in this data packet. The value of
155 this attribute must be 32.
156  
157 =cut
158  
159 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
160 2 my ($self) = @_;
161 2 return $self->{'packetSize'};
162 }
163  
164 #==============================================================================
165  
166 =item sub atmospheric_model_enable([$newValue])
167  
168 $value = $atmos_ctl->atmospheric_model_enable($newValue);
169  
170 Atmospheric Model Enable.
171  
172 This attribute specifies whether the IG should use an atmospheric model to
173 determine spectral radiances for sensor applications. If this attribute is set
174 to Disable (0), source radiances will be calculated. If this attribute is set
175 to Enable (1), apparent radiances will be calculated using the appropriate models.
176  
177 Disable 0
178 Enable 1
179  
180 =cut
181  
182 2 ▶sub atmospheric_model_enable() {
Subroutine atmospheric_model_enable: called CC=4 SCAR=14.8
Pod documented
183 2 my ($self,$nv) = @_;
184 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
185 2 ▶ if (($nv==0) or ($nv==1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1) { } 2 0 2
Condition66%2/3
$nv == 0 or $nv == 1
l!l&&r!l&&!r
110
MC/DC0%0/2
$nv == 0 or $nv == 1
$nv == 0 $nv == 1
Truth table66%2/3
A or B
A= $nv == 0B= $nv == 1
ABresult
1X1
011
000
186 2 $self->{'atmosphericModelEnable'} = $nv;
187 2 $self->{'_bitfields1'} |= $nv &0x01;
188 } else {
189 0 carp "atmospheric_model_enable must be 0 (Disable), or 1 (Enable).";
190 }
191 }
192 2 return ($self->{'_bitfields1'} & 0x01);
193 }
194  
195 #==============================================================================
196  
197 =item sub humidity([$newValue])
198  
199 $value = $atmos_ctl->humidity($newValue);
200  
201 Global Humidity.
202  
203 This attribute specifies the global humidity of the environment.
204  
205 =cut
206  
207 2 ▶sub humidity() {
Subroutine humidity: called CC=5 SCAR=19.6
Pod documented
208 2 my ($self,$nv) = @_;
209 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
210 2 ▶ if ($nv>=0 and $nv<=100 and int($nv)==$nv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv >= 0 and $nv <= 100 and int $nv == $nv) { } 2 0 2
Condition33%2/6
$nv >= 0 and $nv <= 100 and int $nv == $nv
!ll&&!rl&&r
002
$nv >= 0 and $nv <= 100
!ll&&!rl&&r
002
MC/DC0%0/3
$nv >= 0 and $nv <= 100 and int $nv == $nv
$nv >= 0 $nv <= 100 int $nv == $nv
Truth table25%1/4
A and B and C
A= $nv >= 0B= $nv <= 100C= int $nv == $nv
ABCresult
0XX0
10X0
1100
1111
211 2 $self->{'humidity'} = $nv;
212 } else {
213 0 carp "humidity must be an integer 0-100 (percent).";
214 }
215 }
216 2 return $self->{'humidity'};
217 }
218  
219 #==============================================================================
220  
221 =item sub air_temperature([$newValue])
222  
223 $value = $atmos_ctl->air_temperature($newValue);
224  
225 Global Air Temperature.
226  
227 This attribute specifies the global air temperature of the environment.
228  
229 =cut
230  
231 2 ▶sub air_temperature() {
Subroutine air_temperature: called CC=2 SCAR=7.0
Pod documented
232 2 my ($self,$nv) = @_;
233 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
234 2 $self->{'airTemperature'} = $nv;
235 }
236 2 return $self->{'airTemperature'};
237 }
238  
239 #==============================================================================
240  
241 =item sub visibility_range([$newValue])
242  
243 $value = $atmos_ctl->visibility_range($newValue);
244  
245 Global Visibility Range.
246  
247 This attribute specifies the global visibility range through the atmosphere
248 measured in meters.
249  
250 =cut
251  
252 2 ▶sub visibility_range() {
Subroutine visibility_range: called CC=2 SCAR=7.0
Pod documented
253 2 my ($self,$nv) = @_;
254 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
255 2 $self->{'visibilityRange'} = $nv;
256 }
257 2 return $self->{'visibilityRange'};
258 }
259  
260 #==============================================================================
261  
262 =item sub horizontal_wind_speed([$newValue])
263  
264 $value = $atmos_ctl->horizontal_wind_speed($newValue);
265  
266 Global Horizontal Wind Speed.
267  
268 This attribute specifies the global wind speed, measured in meters/second,
269 parallel to the ellipsoid-tangential reference plane.
270  
271 =cut
272  
273 2 ▶sub horizontal_wind_speed() {
Subroutine horizontal_wind_speed: called CC=2 SCAR=7.0
Pod documented
274 2 my ($self,$nv) = @_;
275 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
276 2 $self->{'horizontalWindSpeed'} = $nv;
277 }
278 2 return $self->{'horizontalWindSpeed'};
279 }
280  
281 #==============================================================================
282  
283 =item sub vertical_wind_speed([$newValue])
284  
285 $value = $atmos_ctl->vertical_wind_speed($newValue);
286  
287 Global Vertical Wind Speed.
288  
289 This attribute specifies the global vertical wind speed measured in
290 meters/second. A positive value produces an updraft, while a negative value
291 produces a downdraft.
292  
293 =cut
294  
295 2 ▶sub vertical_wind_speed() {
Subroutine vertical_wind_speed: called CC=2 SCAR=7.0
Pod documented
296 2 my ($self,$nv) = @_;
297 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
298 2 $self->{'verticalWindSpeed'} = $nv;
299 }
300 2 return $self->{'verticalWindSpeed'};
301 }
302  
303 #==============================================================================
304  
305 =item sub wind_direction([$newValue])
306  
307 $value = $atmos_ctl->wind_direction($newValue);
308  
309 Global Wind Direction.
310  
311 This attribute specifies the global wind direction.
312  
313 Note: This is the direction from which the wind is blowing.
314  
315 =cut
316  
317 2 ▶sub wind_direction() {
Subroutine wind_direction: called CC=2 SCAR=7.0
Pod documented
318 2 my ($self,$nv) = @_;
319 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
320 2 $self->{'windDirection'} = $nv;
321 }
322 2 return $self->{'windDirection'};
323 }
324  
325 #==============================================================================
326  
327 =item sub barometric_pressure([$newValue])
328  
329 $value = $atmos_ctl->barometric_pressure($newValue);
330  
331 Global Barometric Pressure.
332  
333 This attribute specifies the global atmospheric pressure measured in millibars
334 (mb) or hectopascals (hPa). The units are interchangeable.
335  
336 =cut
337  
338 2 ▶sub barometric_pressure() {
Subroutine barometric_pressure: called CC=2 SCAR=7.0
Pod documented
339 2 my ($self,$nv) = @_;
340 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
341 2 $self->{'barometricPressure'} = $nv;
342 }
343 2 return $self->{'barometricPressure'};
344 }
345  
346 #==========================================================================
347  
348 =item sub pack()
349  
350 $value = $atmos_ctl->pack();
351  
352 Returns the packed data packet.
353  
354 =cut
355  
356 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
357 2 my $self = shift ;
358
359 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
360 $self->{'packetType'},
361 $self->{'packetSize'},
362 $self->{'_bitfields1'}, # Includes bitfields unused15, and atmosphericModelEnable.
363 $self->{'humidity'},
364 $self->{'airTemperature'},
365 $self->{'visibilityRange'},
366 $self->{'horizontalWindSpeed'},
367 $self->{'verticalWindSpeed'},
368 $self->{'windDirection'},
369 $self->{'barometricPressure'},
370 2 $self->{'_unused16'},
371 );
372  
373 2 return $self->{'_Buffer'};
374 }
375  
376 #==========================================================================
377  
378 =item sub unpack([$buffer])
379  
380 $value = $atmos_ctl->unpack($buffer);
381  
382 Unpacks the packed data packet.
383  
384 =cut
385  
386 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
387 0 my $self = shift @_;
388
389 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
390 0 $self->{'_Buffer'} = shift @_;
391 }
392 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
393 0 $self->{'packetType'} = $a;
394 0 $self->{'packetSize'} = $b;
395 0 $self->{'_bitfields1'} = $c; # Includes bitfields unused15, and atmosphericModelEnable.
396 0 $self->{'humidity'} = $d;
397 0 $self->{'airTemperature'} = $e;
398 0 $self->{'visibilityRange'} = $f;
399 0 $self->{'horizontalWindSpeed'} = $g;
400 0 $self->{'verticalWindSpeed'} = $h;
401 0 $self->{'windDirection'} = $i;
402 0 $self->{'barometricPressure'} = $j;
403 0 $self->{'_unused16'} = $k;
404 0 $self->{'atmosphericModelEnable'} = $self->atmospheric_model_enable();
405  
406 0 return $self->{'_Buffer'};
407 }
408  
409 #==========================================================================
410  
411 =item sub byte_swap()
412  
413 $value = $atmos_ctl->byte_swap();
414  
415 Byte swaps the packed data packet.
416  
417 =cut
418  
419 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
420 0 my $self = shift @_;
421
422 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
423 0 $self->{'_Buffer'} = shift @_;
424 } else {
425 0 $self->pack();
426 }
427 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
428  
429 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k);
430 0 $self->unpack();
431  
432 0 return $self->{'_Buffer'};
433 }
434  
435 #==========================================================================
436  
437 2 1;
438 __END__
« CIGIPP/MaritimeSurfaceConditionsControl.pm ↑ Summary CIGIPP/WeatherConditionsResponse.pm »