CIGIPP/WeatherConditionsResponse.pm

filter: Statementstmt 68.4% 65 / 95 Branchbran 33.3% 10 / 30 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 88.8% 16 / 18 Podpod 100% 14 / 14 totaltotal 63.1% 108 / 171 CC 20 SCAR 18.4
CC
20
Cov
58%
new
19.6
humidity
7.1
unpack
6.0
CRAP 6.3
« CIGIPP/AtmosphereControl.pm ↑ Summary CIGIPP/CelestialSphereControl.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78b30ac-200e-11de-bdcf-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::WeatherConditionsResponse;
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::WeatherConditionsResponse - Perl extension for the Common Image
42 Generator Interface - Weather Conditions Response data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::WeatherConditionsResponse;
47 my $wthr_resp = Rinchi::CIGIPP::WeatherConditionsResponse->new();
48  
49 $packet_type = $wthr_resp->packet_type();
50 $packet_size = $wthr_resp->packet_size();
51 $request_ident = $wthr_resp->request_ident(41);
52 $humidity = $wthr_resp->humidity(45);
53 $air_temperature = $wthr_resp->air_temperature(76.992);
54 $visibility_range = $wthr_resp->visibility_range(36.303);
55 $horizontal_wind_speed = $wthr_resp->horizontal_wind_speed(47.571);
56 $vertical_wind_speed = $wthr_resp->vertical_wind_speed(45.084);
57 $wind_direction = $wthr_resp->wind_direction(0.137);
58 $barometric_pressure = $wthr_resp->barometric_pressure(89.194);
59  
60 =head1 DESCRIPTION
61  
62 The Weather Conditions Response packet is sent in response to an Environmental
63 Conditions Request packet whose Request Type attribute specifies Weather
64 Conditions. The packet describes atmosphere properties at the requested
65 geodetic position.
66  
67 =head2 EXPORT
68  
69 None by default.
70  
71 #==============================================================================
72  
73 =item new $wthr_resp = Rinchi::CIGIPP::WeatherConditionsResponse->new()
74  
75 Constructor for Rinchi::WeatherConditionsResponse.
76  
77 =cut
78  
79 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
80 2 my $class = shift;
81 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
82  
83 2 my $self = {
84 '_Buffer' => '',
85 '_ClassIdent' => 'f78b30ac-200e-11de-bdcf-001c25551abc',
86 '_Pack' => 'CCCCffffffI',
87 '_Swap1' => 'CCCCVVVVVVV',
88 '_Swap2' => 'CCCCNNNNNNN',
89 'packetType' => 109,
90 'packetSize' => 32,
91 'requestIdent' => 0,
92 'humidity' => 0,
93 'airTemperature' => 0,
94 'visibilityRange' => 0,
95 'horizontalWindSpeed' => 0,
96 'verticalWindSpeed' => 0,
97 'windDirection' => 0,
98 'barometricPressure' => 0,
99 '_unused80' => 0,
100 };
101  
102 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
103 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
104 0 $self->{'_Buffer'} = $_[0][0];
105 } elsif (ref($_[0]) eq 'HASH') {
106 0 foreach my $attr (keys %{$_[0]}) {
107 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
108 }
109 }
110 }
111  
112 2 bless($self,$class);
113 2 return $self;
114 }
115  
116 #==============================================================================
117  
118 =item sub packet_type()
119  
120 $value = $wthr_resp->packet_type();
121  
122 Data Packet Identifier.
123  
124 This attribute identifies this data packet as the Weather Conditions Response
125 packet. The value of this attribute must be 109.
126  
127 =cut
128  
129 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
130 2 my ($self) = @_;
131 2 return $self->{'packetType'};
132 }
133  
134 #==============================================================================
135  
136 =item sub packet_size()
137  
138 $value = $wthr_resp->packet_size();
139  
140 Data Packet Size.
141  
142 This attribute indicates the number of bytes in this data packet. The value of
143 this attribute must be 32.
144  
145 =cut
146  
147 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
148 2 my ($self) = @_;
149 2 return $self->{'packetSize'};
150 }
151  
152 #==============================================================================
153  
154 =item sub request_ident([$newValue])
155  
156 $value = $wthr_resp->request_ident($newValue);
157  
158 Request ID.
159  
160 This attribute identifies the environmental conditions request to which this
161 response packet corresponds.
162  
163 =cut
164  
165 2 ▶sub request_ident() {
Subroutine request_ident: called CC=2 SCAR=7.0
Pod documented
166 2 my ($self,$nv) = @_;
167 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
168 2 $self->{'requestIdent'} = $nv;
169 }
170 2 return $self->{'requestIdent'};
171 }
172  
173 #==============================================================================
174  
175 =item sub humidity([$newValue])
176  
177 $value = $wthr_resp->humidity($newValue);
178  
179 Humidity.
180  
181 This attribute indicates the humidity at the requested location.
182  
183 =cut
184  
185 2 ▶sub humidity() {
Subroutine humidity: called CC=5 SCAR=19.6
Pod documented
186 2 my ($self,$nv) = @_;
187 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
188 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
189 2 $self->{'humidity'} = $nv;
190 } else {
191 0 carp "humidity must be an integer 0-100 (percent).";
192 }
193 }
194 2 return $self->{'humidity'};
195 }
196  
197 #==============================================================================
198  
199 =item sub air_temperature([$newValue])
200  
201 $value = $wthr_resp->air_temperature($newValue);
202  
203 Air Temperature.
204  
205 This attribute indicates the air temperature, measured in degrees Celcius, at
206 the requested location.
207  
208 =cut
209  
210 2 ▶sub air_temperature() {
Subroutine air_temperature: called CC=2 SCAR=7.0
Pod documented
211 2 my ($self,$nv) = @_;
212 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
213 2 $self->{'airTemperature'} = $nv;
214 }
215 2 return $self->{'airTemperature'};
216 }
217  
218 #==============================================================================
219  
220 =item sub visibility_range([$newValue])
221  
222 $value = $wthr_resp->visibility_range($newValue);
223  
224 Visibility Range.
225  
226 This attribute indicates the visibility range, measured in meters, at the
227 requested location.
228  
229 =cut
230  
231 2 ▶sub visibility_range() {
Subroutine visibility_range: 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->{'visibilityRange'} = $nv;
235 }
236 2 return $self->{'visibilityRange'};
237 }
238  
239 #==============================================================================
240  
241 =item sub horizontal_wind_speed([$newValue])
242  
243 $value = $wthr_resp->horizontal_wind_speed($newValue);
244  
245 Horizontal Wind Speed.
246  
247 This attribute indicates the local wind speed, measured in meters/second,
248 parallel to the ellipsoid-tangential reference plane.
249  
250 =cut
251  
252 2 ▶sub horizontal_wind_speed() {
Subroutine horizontal_wind_speed: 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->{'horizontalWindSpeed'} = $nv;
256 }
257 2 return $self->{'horizontalWindSpeed'};
258 }
259  
260 #==============================================================================
261  
262 =item sub vertical_wind_speed([$newValue])
263  
264 $value = $wthr_resp->vertical_wind_speed($newValue);
265  
266 Vertical Wind Speed.
267  
268 This attribute indicates the local vertical wind speed, measured in
269 meters/second.
270 Note: A positive value indicates an updraft, while a negative value indicates a downdraft.
271  
272 =cut
273  
274 2 ▶sub vertical_wind_speed() {
Subroutine vertical_wind_speed: called CC=2 SCAR=7.0
Pod documented
275 2 my ($self,$nv) = @_;
276 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
277 2 $self->{'verticalWindSpeed'} = $nv;
278 }
279 2 return $self->{'verticalWindSpeed'};
280 }
281  
282 #==============================================================================
283  
284 =item sub wind_direction([$newValue])
285  
286 $value = $wthr_resp->wind_direction($newValue);
287  
288 Wind Direction.
289  
290 This attribute indicates the local wind direction.
291  
292 Note: This is the direction from which the wind is blowing.
293  
294 Datum: True North
295  
296 =cut
297  
298 2 ▶sub wind_direction() {
Subroutine wind_direction: called CC=2 SCAR=7.0
Pod documented
299 2 my ($self,$nv) = @_;
300 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
301 2 $self->{'windDirection'} = $nv;
302 }
303 2 return $self->{'windDirection'};
304 }
305  
306 #==============================================================================
307  
308 =item sub barometric_pressure([$newValue])
309  
310 $value = $wthr_resp->barometric_pressure($newValue);
311  
312 Barometric Pressure.
313  
314 This attribute indicates the atmospheric pressure at the requested location.
315  
316 =cut
317  
318 2 ▶sub barometric_pressure() {
Subroutine barometric_pressure: called CC=2 SCAR=7.0
Pod documented
319 2 my ($self,$nv) = @_;
320 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
321 2 $self->{'barometricPressure'} = $nv;
322 }
323 2 return $self->{'barometricPressure'};
324 }
325  
326 #==========================================================================
327  
328 =item sub pack()
329  
330 $value = $wthr_resp->pack();
331  
332 Returns the packed data packet.
333  
334 =cut
335  
336 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
337 2 my $self = shift ;
338
339 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
340 $self->{'packetType'},
341 $self->{'packetSize'},
342 $self->{'requestIdent'},
343 $self->{'humidity'},
344 $self->{'airTemperature'},
345 $self->{'visibilityRange'},
346 $self->{'horizontalWindSpeed'},
347 $self->{'verticalWindSpeed'},
348 $self->{'windDirection'},
349 $self->{'barometricPressure'},
350 2 $self->{'_unused80'},
351 );
352  
353 2 return $self->{'_Buffer'};
354 }
355  
356 #==========================================================================
357  
358 =item sub unpack()
359  
360 $value = $wthr_resp->unpack();
361  
362 Unpacks the packed data packet.
363  
364 =cut
365  
366 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
367 0 my $self = shift @_;
368
369 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
370 0 $self->{'_Buffer'} = shift @_;
371 }
372 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
373 0 $self->{'packetType'} = $a;
374 0 $self->{'packetSize'} = $b;
375 0 $self->{'requestIdent'} = $c;
376 0 $self->{'humidity'} = $d;
377 0 $self->{'airTemperature'} = $e;
378 0 $self->{'visibilityRange'} = $f;
379 0 $self->{'horizontalWindSpeed'} = $g;
380 0 $self->{'verticalWindSpeed'} = $h;
381 0 $self->{'windDirection'} = $i;
382 0 $self->{'barometricPressure'} = $j;
383 0 $self->{'_unused80'} = $k;
384  
385 0 return $self->{'_Buffer'};
386 }
387  
388 #==========================================================================
389  
390 =item sub byte_swap()
391  
392 $obj_name->byte_swap();
393  
394 Byte swaps the packed data packet.
395  
396 =cut
397  
398 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
399 0 my $self = shift @_;
400
401 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
402 0 $self->{'_Buffer'} = shift @_;
403 } else {
404 0 $self->unpack();
405 }
406 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
407  
408 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k);
409 0 $self->unpack();
410  
411 0 return $self->{'_Buffer'};
412 }
413  
414 2 1;
415 __END__
« CIGIPP/AtmosphereControl.pm ↑ Summary CIGIPP/CelestialSphereControl.pm »