BT368i/NMEA/GP/GSV.pm

filter: Statementstmt 19.6% 12 / 61 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 66.6% 2 / 3 totaltotal 23.6% 17 / 72 CC 2 SCAR 10.0
CC
2
Cov
19%
parse
6.0
new
2.0
print
2.0
CRAP 2.7
« BT368i.pm ↑ Summary BT368i/NMEA/GP/VTG.pm »
1 #
2 # Written by Travis Kent Beste
3 # Fri Aug 6 23:35:11 CDT 2010
4  
5 package BT368i::NMEA::GP::GSV;
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw( );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @ISA = qw( );
13  
14 1 our $VERSION = sprintf("%d.%02d", q$Revision: 1.00 $ =~ /(\d+)\.(\d+)/);
15  
16 #----------------------------------------#
17 #
18 #----------------------------------------#
19 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my $class = shift;
21 0 my %args = shift;
22  
23 0 my %fields = (
24 log_fh => '',
25 log_filename => '',
26  
27 gsv_sentance_count => '',
28 current_gsv_sentance => '',
29 number_of_satilites => '',
30 sentance_1 => {
31 prn_0 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
32 prn_1 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
33 prn_2 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
34 prn_3 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
35 },
36 sentance_2 => {
37 prn_0 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
38 prn_1 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
39 prn_2 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
40 prn_3 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
41 },
42 sentance_3 => {
43 prn_0 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
44 prn_1 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
45 prn_2 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
46 prn_3 => { id => '', elevation => '', azimuth => '', signal_to_noise => '', },
47 },
48 );
49  
50 0 my $self = {
51 %fields,
52 };
53 0 bless $self, $class;
54  
55 0 return $self;
56 }
57  
58 #----------------------------------------#
59 #
60 #----------------------------------------#
61 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
62 0 my $self = shift;
63  
64 0 print "number of gsv sentances : " . $self->{gsv_sentance_count} . "\n";
65 0 print "number of current gsv sentance : " . $self->{current_gsv_sentance} . "\n";
66 0 print "number of satellites in view : " . $self->{number_of_satilites} . "\n";
67  
68 0 printf "| id | elevation | azimuth | sNr |\n";
69 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_1}->{prn_0}->{id}, $self->{sentance_1}->{prn_0}->{elevation}, $self->{sentance_1}->{prn_0}->{azimuth}, $self->{sentance_1}->{prn_0}->{signal_to_noise};
70 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_1}->{prn_1}->{id}, $self->{sentance_1}->{prn_1}->{elevation}, $self->{sentance_1}->{prn_1}->{azimuth}, $self->{sentance_1}->{prn_1}->{signal_to_noise};
71 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_1}->{prn_2}->{id}, $self->{sentance_1}->{prn_2}->{elevation}, $self->{sentance_1}->{prn_2}->{azimuth}, $self->{sentance_1}->{prn_2}->{signal_to_noise};
72 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_1}->{prn_3}->{id}, $self->{sentance_1}->{prn_3}->{elevation}, $self->{sentance_1}->{prn_3}->{azimuth}, $self->{sentance_1}->{prn_3}->{signal_to_noise};
73 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_2}->{prn_0}->{id}, $self->{sentance_2}->{prn_0}->{elevation}, $self->{sentance_2}->{prn_0}->{azimuth}, $self->{sentance_2}->{prn_0}->{signal_to_noise};
74 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_2}->{prn_1}->{id}, $self->{sentance_2}->{prn_1}->{elevation}, $self->{sentance_2}->{prn_1}->{azimuth}, $self->{sentance_2}->{prn_1}->{signal_to_noise};
75 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_2}->{prn_2}->{id}, $self->{sentance_2}->{prn_2}->{elevation}, $self->{sentance_2}->{prn_2}->{azimuth}, $self->{sentance_2}->{prn_2}->{signal_to_noise};
76 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_2}->{prn_3}->{id}, $self->{sentance_2}->{prn_3}->{elevation}, $self->{sentance_2}->{prn_3}->{azimuth}, $self->{sentance_2}->{prn_3}->{signal_to_noise};
77 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_3}->{prn_0}->{id}, $self->{sentance_3}->{prn_0}->{elevation}, $self->{sentance_3}->{prn_0}->{azimuth}, $self->{sentance_3}->{prn_0}->{signal_to_noise};
78 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_3}->{prn_1}->{id}, $self->{sentance_3}->{prn_1}->{elevation}, $self->{sentance_3}->{prn_1}->{azimuth}, $self->{sentance_3}->{prn_1}->{signal_to_noise};
79 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_3}->{prn_2}->{id}, $self->{sentance_3}->{prn_2}->{elevation}, $self->{sentance_3}->{prn_2}->{azimuth}, $self->{sentance_3}->{prn_2}->{signal_to_noise};
80 0 printf "| %2d | %10.2f | %7d | %3d |\n", $self->{sentance_3}->{prn_3}->{id}, $self->{sentance_3}->{prn_3}->{elevation}, $self->{sentance_3}->{prn_3}->{azimuth}, $self->{sentance_3}->{prn_3}->{signal_to_noise};
81 }
82  
83 #----------------------------------------#
84 #
85 #----------------------------------------#
86 0 ▶sub parse {
Subroutine parse: not called CC=2 SCAR=17.9
Pod documented
87 0 my $self = shift;
88 0 my $data = shift;
89  
90 # if we're logging, save data to filehandle
91 0 ▶ if ($self->{log_fh}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"log_fh"}) 0 0 0
92 0 print { $self->{log_fh} } $data . "\n";
93 }
94  
95 0 $data =~ s/\*..$//; # remove the last three bytes (checksum)
96 0 my @args = split(/,/, $data);
97  
98 # 1) Total number of GSV sentences to be transmitted
99 0 $self->{gsv_sentance_count} = $args[1];
100  
101 # 2) Number of current GSV sentence
102 0 $self->{current_gsv_sentance} = $args[2];
103  
104 # 3) Total number of satellites in view, 00 to 12 (leading zeros sent)
105 0 $self->{number_of_satilites} = $args[3];
106  
107
108 # 4) Satellite PRN number, 01 to 32 (leading zeros sent)
109 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{'prn_0'}->{'id'} = $args[4];
110  
111 # 5) Satellite elevation, 00 to 90 degrees (leading zeros sent)
112 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{'prn_0'}->{'elevation'} = $args[5];
113  
114 # 6) Satellite azimuth, 000 to 359 degrees, true (leading zeros sent)
115 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{'prn_0'}->{'azimuth'} = $args[6];
116  
117 # 7) Signal to Noise ratio (C/No) 00 to 99 dB, null when not tracking (leading zeros sent)
118 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{'prn_0'}->{'signal_to_noise'} = $args[7];
119  
120  
121 # 4) Satellite PRN number, 01 to 32 (leading zeros sent)
122 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_1}->{id} = $args[8];
123  
124 # 5) Satellite elevation, 00 to 90 degrees (leading zeros sent)
125 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_1}->{elevation} = $args[9];
126  
127 # 6) Satellite azimuth, 000 to 359 degrees, true (leading zeros sent)
128 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_1}->{azimuth} = $args[10];
129  
130 # 7) Signal to Noise ratio (C/No) 00 to 99 dB, null when not tracking (leading zeros sent)
131 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_1}->{signal_to_noise} = $args[11];
132  
133  
134 # 4) Satellite PRN number, 01 to 32 (leading zeros sent)
135 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_2}->{id} = $args[12];
136  
137 # 5) Satellite elevation, 00 to 90 degrees (leading zeros sent)
138 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_2}->{elevation} = $args[13];
139  
140 # 6) Satellite azimuth, 000 to 359 degrees, true (leading zeros sent)
141 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_2}->{azimuth} = $args[14];
142  
143 # 7) Signal to Noise ratio (C/No) 00 to 99 dB, null when not tracking (leading zeros sent)
144 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_2}->{signal_to_noise} = $args[15];
145  
146  
147 # 4) Satellite PRN number, 01 to 32 (leading zeros sent)
148 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_3}->{id} = $args[16];
149  
150 # 5) Satellite elevation, 00 to 90 degrees (leading zeros sent)
151 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_3}->{elevation} = $args[17];
152  
153 # 6) Satellite azimuth, 000 to 359 degrees, true (leading zeros sent)
154 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_3}->{azimuth} = $args[18];
155  
156 # 7) Signal to Noise ratio (C/No) 00 to 99 dB, null when not tracking (leading zeros sent)
157 0 $self->{'sentance_' . $self->{current_gsv_sentance}}->{prn_3}->{signal_to_noise} = $args[19];
158 }
159  
160 1 1;
161  
162 __END__
« BT368i.pm ↑ Summary BT368i/NMEA/GP/VTG.pm »