CIGIPP/EnvironmentalConditionsRequest.pm

filter: Statementstmt 67.9% 72 / 106 Branchbran 36.1% 13 / 36 Conditioncond 53.3% 8 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 88.8% 16 / 18 Podpod 100% 14 / 14 totaltotal 61.8% 123 / 199 CC 25 SCAR 18.1
CC
25
Cov
59%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 6.1
« CIGIPP/CelestialSphereControl.pm ↑ Summary CIGIPP/LineOfSightResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78afdd0-200e-11de-bdbc-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::EnvironmentalConditionsRequest;
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::EnvironmentalConditionsRequest - Perl extension for the Common
42 Image Generator Interface - Environmental Conditions Request data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::EnvironmentalConditionsRequest;
47 my $ec_rqst = Rinchi::CIGIPP::EnvironmentalConditionsRequest->new();
48  
49 $packet_type = $ec_rqst->packet_type();
50 $packet_size = $ec_rqst->packet_size();
51 $request_type_ac = $ec_rqst->request_type_ac(0);
52 $request_type_wc = $ec_rqst->request_type_wc(1);
53 $request_type_tsc = $ec_rqst->request_type_tsc(0);
54 $request_type_msc = $ec_rqst->request_type_msc(0);
55 $request_ident = $ec_rqst->request_ident(167);
56 $latitude = $ec_rqst->latitude(28.347);
57 $longitude = $ec_rqst->longitude(82.085);
58 $altitude = $ec_rqst->altitude(38.01);
59  
60 =head1 DESCRIPTION
61  
62 At any given location, it may be impossible for the Host to determine exactly
63 the visibility range, air temperature, or other atmospheric or surface
64 conditions. One factor is that various IG implementations may differ in how
65 they calculate values across transition bands and within overlapping regions.
66 Random phenomena such as winds aloft, scud, and wave activity may also make
67 determining instantaneous conditions at a specific point impossible.
68  
69 The Environmental Conditions Request packet is used by the Host to request the
70 state of the environment at a specific location. The Request Type attribute
71 determines what data are returned by the IG. Each request type is represented
72 by a power of two (i.e., a unique bit), so request types may be combined by
73 adding or bit-wise ORing the values together.
74  
75 For a given test point, the IG may respond with no more than one of each of the
76 Maritime Surface Conditions Response and Weather Conditions Response packets.
77 For terrestrial surface conditions requests, the IG should respond with one
78 Terrestrial Surface Conditions Response packet for each surface condition type
79 or attribute present at the test point. If the Request Type attribute specifies
80 that aerosol concentrations should be returned, the IG must send a Weather
81 Conditions Aerosol Response packet for each weather layer that encompasses the
82 test point.
83  
84 =head2 EXPORT
85  
86 None by default.
87  
88 #==============================================================================
89  
90 =item new $ec_rqst = Rinchi::CIGIPP::EnvironmentalConditionsRequest->new()
91  
92 Constructor for Rinchi::EnvironmentalConditionsRequest.
93  
94 =cut
95  
96 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
97 2 my $class = shift;
98 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
99  
100 2 my $self = {
101 '_Buffer' => '',
102 '_ClassIdent' => 'f78afdd0-200e-11de-bdbc-001c25551abc',
103 '_Pack' => 'CCCCIddd',
104 '_Swap1' => 'CCCCVVVVVVV',
105 '_Swap2' => 'CCCCNNNNNNN',
106 'packetType' => 28,
107 'packetSize' => 32,
108 '_bitfields1' => 0, # Includes bitfields unused49, requestTypeAC, requestTypeWC, requestTypeTSC, and requestTypeMSC.
109 'requestTypeAC' => 0,
110 'requestTypeWC' => 0,
111 'requestTypeTSC' => 0,
112 'requestTypeMSC' => 0,
113 'requestIdent' => 0,
114 '_unused50' => 0,
115 'latitude' => 0,
116 'longitude' => 0,
117 'altitude' => 0,
118 };
119  
120 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
121 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
122 0 $self->{'_Buffer'} = $_[0][0];
123 } elsif (ref($_[0]) eq 'HASH') {
124 0 foreach my $attr (keys %{$_[0]}) {
125 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
126 }
127 }
128 }
129  
130 2 bless($self,$class);
131 2 return $self;
132 }
133  
134 #==============================================================================
135  
136 =item sub packet_type()
137  
138 $value = $ec_rqst->packet_type();
139  
140 Data Packet Identifier.
141  
142 This attribute identifies this data packet as the Environmental Conditions
143 Request packet. The value of this attribute must be 28.
144  
145 =cut
146  
147 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
148 2 my ($self) = @_;
149 2 return $self->{'packetType'};
150 }
151  
152 #==============================================================================
153  
154 =item sub packet_size()
155  
156 $value = $ec_rqst->packet_size();
157  
158 Data Packet Size.
159  
160 This attribute indicates the number of bytes in this data packet. The value of
161 this attribute must be 32.
162  
163 =cut
164  
165 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
166 2 my ($self) = @_;
167 2 return $self->{'packetSize'};
168 }
169  
170 #==============================================================================
171  
172 =item sub request_type_ac([$newValue])
173  
174 $value = $ec_rqst->request_type_ac($newValue);
175  
176 Request Type.
177  
178 This attribute specifies the desired response type for the request. The
179 numerical values listed at left may be combined by addition or bit-wise OR. The
180 resulting value may be any combination of the following:
181  
182 Aerosol Concentrations – The IG will send exactly one Aerosol Concentration
183 Response packet for each weather layer (regardless of scope) that encompasses
184 that location.
185  
186 =cut
187  
188 2 ▶sub request_type_ac() {
Subroutine request_type_ac: called CC=4 SCAR=14.8
Pod documented
189 2 my ($self,$nv) = @_;
190 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
191 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
192 2 $self->{'requestTypeAC'} = $nv;
193 2 $self->{'_bitfields1'} |= ($nv << 3) &0x08;
194 } else {
195 0 carp "request_type_ac must be 0 or 1.";
196 }
197 }
198 2 return (($self->{'_bitfields1'} & 0x08) >> 3);
199 }
200  
201 #==============================================================================
202  
203 =item sub request_type_wc([$newValue])
204  
205 $value = $ec_rqst->request_type_wc($newValue);
206  
207 Request Type.
208  
209 This attribute specifies the desired response type for the request. The
210 numerical values listed at left may be combined by addition or bit-wise OR. The
211 resulting value may be any combination of the following:
212  
213 Weather Conditions – The IG will respond with a Weather Conditions Response packet.
214  
215 =cut
216  
217 2 ▶sub request_type_wc() {
Subroutine request_type_wc: called CC=4 SCAR=14.8
Pod documented
218 2 my ($self,$nv) = @_;
219 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
220 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
221 2 $self->{'requestTypeWC'} = $nv;
222 2 $self->{'_bitfields1'} |= ($nv << 2) &0x04;
223 } else {
224 0 carp "request_type_wc must be 0 or 1.";
225 }
226 }
227 2 return (($self->{'_bitfields1'} & 0x04) >> 2);
228 }
229  
230 #==============================================================================
231  
232 =item sub request_type_tsc([$newValue])
233  
234 $value = $ec_rqst->request_type_tsc($newValue);
235  
236 Request Type.
237  
238 This attribute specifies the desired response type for the request. The
239 numerical values listed at left may be combined by addition or bit-wise OR. The
240 resulting value may be any combination of the following:
241  
242 Terrestrial Surface Conditions – The IG will respond with a Terrestrial Surface
243 Conditions Response packet.
244  
245 =cut
246  
247 2 ▶sub request_type_tsc() {
Subroutine request_type_tsc: called CC=4 SCAR=14.8
Pod documented
248 2 my ($self,$nv) = @_;
249 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
250 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
251 2 $self->{'requestTypeTSC'} = $nv;
252 2 $self->{'_bitfields1'} |= ($nv << 1) &0x02;
253 } else {
254 0 carp "request_type_tsc must be 0 or 1.";
255 }
256 }
257 2 return (($self->{'_bitfields1'} & 0x02) >> 1);
258 }
259  
260 #==============================================================================
261  
262 =item sub request_type_msc([$newValue])
263  
264 $value = $ec_rqst->request_type_msc($newValue);
265  
266 Request Type.
267  
268 This attribute specifies the desired response type for the request. The
269 numerical values listed at left may be combined by addition or bit-wise OR. The
270 resulting value may be any combination of the following:
271  
272 Maritime Surface Conditions – The IG will respond with a Maritime Surface
273 Conditions Response packet.
274  
275 =cut
276  
277 2 ▶sub request_type_msc() {
Subroutine request_type_msc: called CC=4 SCAR=15.5
Pod documented
278 2 my ($self,$nv) = @_;
279 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
280 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
281 2 $self->{'requestTypeMSC'} = $nv;
282 2 $self->{'_bitfields1'} |= $nv &0x01;
283 } else {
284 0 carp "request_type_msc must be 0 or 1.";
285 }
286 }
287 2 return ($self->{'_bitfields1'} & 0x01);
288 }
289  
290 #==============================================================================
291  
292 =item sub request_ident([$newValue])
293  
294 $value = $ec_rqst->request_ident($newValue);
295  
296 Request ID.
297  
298 This attribute identifies the environmental conditions request. When the IG
299 returns a responds to the request, each response packet(s) will contain this
300 value in its Request ID attribute.
301  
302 =cut
303  
304 2 ▶sub request_ident() {
Subroutine request_ident: called CC=2 SCAR=7.0
Pod documented
305 2 my ($self,$nv) = @_;
306 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
307 2 $self->{'requestIdent'} = $nv;
308 }
309 2 return $self->{'requestIdent'};
310 }
311  
312 #==============================================================================
313  
314 =item sub latitude([$newValue])
315  
316 $value = $ec_rqst->latitude($newValue);
317  
318 Latitude.
319  
320 This attribute specifies the geodetic latitude at which the environmental state
321 is requested.
322  
323 =cut
324  
325 2 ▶sub latitude() {
Subroutine latitude: called CC=2 SCAR=7.0
Pod documented
326 2 my ($self,$nv) = @_;
327 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
328 2 $self->{'latitude'} = $nv;
329 }
330 2 return $self->{'latitude'};
331 }
332  
333 #==============================================================================
334  
335 =item sub longitude([$newValue])
336  
337 $value = $ec_rqst->longitude($newValue);
338  
339 Longitude.
340  
341 This attribute specifies the geodetic longitude at which the environmental
342 state is requested.
343  
344 =cut
345  
346 2 ▶sub longitude() {
Subroutine longitude: called CC=2 SCAR=7.0
Pod documented
347 2 my ($self,$nv) = @_;
348 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
349 2 $self->{'longitude'} = $nv;
350 }
351 2 return $self->{'longitude'};
352 }
353  
354 #==============================================================================
355  
356 =item sub altitude([$newValue])
357  
358 $value = $ec_rqst->altitude($newValue);
359  
360 Altitude.
361  
362 This attribute specifies the geodetic altitude in meters above mean sea level
363 at which the environmental state is requested.
364  
365 This attribute is used only for weather conditions and aerosol concentrations requests.
366  
367 =cut
368  
369 2 ▶sub altitude() {
Subroutine altitude: called CC=2 SCAR=7.0
Pod documented
370 2 my ($self,$nv) = @_;
371 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
372 2 $self->{'altitude'} = $nv;
373 }
374 2 return $self->{'altitude'};
375 }
376  
377 #==========================================================================
378  
379 =item sub pack()
380  
381 $value = $ec_rqst->pack();
382  
383 Returns the packed data packet.
384  
385 =cut
386  
387 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
388 2 my $self = shift ;
389
390 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
391 $self->{'packetType'},
392 $self->{'packetSize'},
393 $self->{'_bitfields1'}, # Includes bitfields unused49, requestTypeAC, requestTypeWC, requestTypeTSC, and requestTypeMSC.
394 $self->{'requestIdent'},
395 $self->{'_unused50'},
396 $self->{'latitude'},
397 $self->{'longitude'},
398 2 $self->{'altitude'},
399 );
400  
401 2 return $self->{'_Buffer'};
402 }
403  
404 #==========================================================================
405  
406 =item sub unpack()
407  
408 $value = $ec_rqst->unpack();
409  
410 Unpacks the packed data packet.
411  
412 =cut
413  
414 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
415 0 my $self = shift @_;
416
417 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
418 0 $self->{'_Buffer'} = shift @_;
419 }
420 0 my ($a,$b,$c,$d,$e,$f,$g,$h) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
421 0 $self->{'packetType'} = $a;
422 0 $self->{'packetSize'} = $b;
423 0 $self->{'_bitfields1'} = $c; # Includes bitfields unused49, requestTypeAC, requestTypeWC, requestTypeTSC, and requestTypeMSC.
424 0 $self->{'requestIdent'} = $d;
425 0 $self->{'_unused50'} = $e;
426 0 $self->{'latitude'} = $f;
427 0 $self->{'longitude'} = $g;
428 0 $self->{'altitude'} = $h;
429  
430 0 $self->{'requestTypeAC'} = $self->request_type_ac();
431 0 $self->{'requestTypeWC'} = $self->request_type_wc();
432 0 $self->{'requestTypeTSC'} = $self->request_type_tsc();
433 0 $self->{'requestTypeMSC'} = $self->request_type_msc();
434  
435 0 return $self->{'_Buffer'};
436 }
437  
438 #==========================================================================
439  
440 =item sub byte_swap()
441  
442 $obj_name->byte_swap();
443  
444 Byte swaps the packed data packet.
445  
446 =cut
447  
448 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
449 0 my $self = shift @_;
450
451 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
452 0 $self->{'_Buffer'} = shift @_;
453 } else {
454 0 $self->pack();
455 }
456 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
457  
458 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$g,$f,$i,$h,$k,$j);
459 0 $self->unpack();
460  
461 0 return $self->{'_Buffer'};
462 }
463  
464 2 1;
465 __END__
« CIGIPP/CelestialSphereControl.pm ↑ Summary CIGIPP/LineOfSightResponse.pm »