GPSD3/Return/SKY.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 6 / 6 totaltotal 93.8% 61 / 65 CC 7 SCAR 7.0
CC
7
Cov
92%
satellites
3.1
Satellites
3.0
reported
2.0
CRAP 2.0
« GPSD3/Return/DEVICES.pm ↑ Summary GPSD3/Return/DEVICE.pm »
1 package Net::GPSD3::Return::SKY;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use base qw{Net::GPSD3::Return::Unknown::Timestamp};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION='0.12';
8  
9 =head1 NAME
10  
11 Net::GPSD3::Return::SKY - Net::GPSD3 Return SKY Object
12  
13 =head1 SYNOPSIS
14  
15 =head1 DESCRIPTION
16  
17 Provides a Perl object interface to the SKY object returned by the GPSD daemon.
18  
19 An example JSON object:
20  
21 =head3 Protcol 3.1 versions
22  
23 {
24 "class":"SKY",
25 "tag":"MID4",
26 "device":"/dev/ttyUSB0",
27 "time":1253593665.430,
28 "hdop":23.60,
29 "reported":9,
30 "satellites":
31 [
32 {"PRN":15,"el":77,"az":123,"ss":0, "used":false},
33 {"PRN":18,"el":25,"az":268,"ss":0, "used":false},
34 {"PRN":27,"el":13,"az":150,"ss":0, "used":false},
35 {"PRN":29,"el":47,"az":228,"ss":0, "used":false},
36 {"PRN":5, "el":39,"az":58, "ss":46,"used":true },
37 {"PRN":21,"el":41,"az":309,"ss":33,"used":true },
38 {"PRN":10,"el":32,"az":61, "ss":40,"used":true },
39 {"PRN":8, "el":12,"az":48, "ss":40,"used":true },
40 {"PRN":2, "el":9, "az":124,"ss":0, "used":false}
41 ]
42 }
43  
44 =head3 Protcol 3.4 versions
45  
46 {
47 "class":"SKY",
48 "tag":"0x0120",
49 "device":"/dev/cuaU0",
50 "xdop":0.58,
51 "ydop":0.96,
52 "vdop":1.92,
53 "tdop":1.14,
54 "hdop":1.90,
55 "gdop":2.93,
56 "pdop":2.70,
57 "satellites":[
58 {"PRN":17,"el":76,"az":174,"ss":34,"used":true},
59 {"PRN":28,"el":57,"az":38,"ss":30,"used":false},
60 {"PRN":27,"el":22,"az":314,"ss":18,"used":true},
61 {"PRN":7,"el":15,"az":127,"ss":29,"used":true},
62 {"PRN":15,"el":31,"az":297,"ss":27,"used":true},
63 {"PRN":11,"el":18,"az":54,"ss":28,"used":false},
64 {"PRN":24,"el":18,"az":63,"ss":29,"used":false},
65 {"PRN":9,"el":4,"az":313,"ss":18,"used":false},
66 {"PRN":8,"el":45,"az":117,"ss":33,"used":true},
67 {"PRN":26,"el":49,"az":245,"ss":37,"used":true},
68 {"PRN":4,"el":5,"az":170,"ss":17,"used":false},
69 {"PRN":138,"el":44,"az":157,"ss":40,"used":true}
70 ]
71 }
72  
73 =head1 METHODS PROPERTIES
74  
75 =head2 class
76  
77 Returns the object class
78  
79 =head2 string
80  
81 Returns the JSON string
82  
83 =head2 parent
84  
85 Return the parent Net::GPSD object
86  
87 =head2 device
88  
89 =cut
90  
91 1 ▶sub device {shift->{"device"}};
Subroutine device: called CC=1 SCAR=0.0
Pod documented
92  
93 =head2 tag
94  
95 =cut
96  
97 1 ▶sub tag {shift->{"tag"}};
Subroutine tag: called CC=1 SCAR=0.0
Pod documented
98  
99 =head2 time
100  
101 =head2 timestamp
102  
103 =head2 datetime
104  
105 =head2 reported
106  
107 Count of satellites in view
108  
109 =cut
110  
111 1 ▶sub reported {
Subroutine reported: called CC=2 SCAR=7.0
Pod documented
112 1 my $self=shift;
113 1 $self->{"reported"}=scalar(@{$self->satellites})
114 1 ▶ unless defined $self->{"reported"};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"reported"} 1 0 1
115 1 return $self->{"reported"};
116 }
117  
118 =head2 used
119  
120 Count of satellites used in calculation
121  
122 =cut
123  
124 1 ▶sub used {
Subroutine used: called CC=2 SCAR=7.0
Pod documented
125 1 my $self=shift;
126 1 $self->{"used"}=scalar(@{[grep {$_->{"used"}} $self->satellites]})
127 1 ▶ unless defined $self->{"used"};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"used"} 1 0 1
128 1 return $self->{"used"};
129 }
130  
131 =head2 satellites
132  
133 Returns a list of satellite data structures.
134  
135 my $satellites=$sky->satellites(); #[{},...]
136 my @satellites=$sky->satellites(); #({},...)
137  
138 =cut
139  
140 7 ▶sub satellites {
Subroutine satellites: called CC=3 SCAR=11.3
Pod documented
141 7 my $self=shift;
142 7 ▶ unless (ref($self->{"satellites"}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->{"satellites"} eq "ARRAY") 0 7 7
143 0 $self->{"satellites"}=[];
144 }
145 7 ▶ return wantarray ? @{$self->{"satellites"}} : $self->{"satellites"};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 5 2 7
146 }
147  
148 =head2 Satellites
149  
150 Returns a list of L<Net::GPSD3::Return::Satellite> objects.
151  
152 my @satellites=$sky->Satellites; #(bless{},...)
153 my $satellites=$sky->Satellites; #[bless{},...]
154
155 =cut
156  
157 4 ▶sub Satellites {
Subroutine Satellites: called CC=3 SCAR=11.0
Pod documented
158 4 my $self=shift;
159 4 ▶ unless (defined($self->{"Satellites"})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"Satellites"}) 3 1 4
160 $self->{"Satellites"}=[
161 36 map {$self->parent->constructor(%$_,
162 class=>"Satellite",
163 string=>$self->parent->encode($_))}
164 3 grep {ref($_) eq "HASH"} $self->satellites];
165 }
166 4 ▶ return wantarray ? @{$self->{"Satellites"}} : $self->{"Satellites"};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 3 4
167 }
168  
169 =head1 BUGS
170  
171 Log on RT and Send to gpsd-dev email list
172  
173 =head1 SUPPORT
174  
175 DavisNetworks.com supports all Perl applications including this package.
176  
177 Try gpsd-dev email list
178  
179 =head1 AUTHOR
180  
181 Michael R. Davis
182 CPAN ID: MRDVT
183 STOP, LLC
184 domain=>michaelrdavis,tld=>com,account=>perl
185 http://www.stopllc.com/
186  
187 =head1 COPYRIGHT
188  
189 This program is free software licensed under the...
190  
191 The BSD License
192  
193 The full text of the license can be found in the LICENSE file included with this module.
194  
195 =head1 SEE ALSO
196  
197 L<Net::GPSD3>, L<DateTime>, L<Net::GPSD3::Return::Unknown>
198  
199 =cut
200  
201 4 1;
« GPSD3/Return/DEVICES.pm ↑ Summary GPSD3/Return/DEVICE.pm »