BT368i/NMEA/GP/RMC.pm

filter: Statementstmt 16.2% 12 / 74 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 66.6% 2 / 3 totaltotal 17.1% 17 / 99 CC 9 SCAR 37.5
CC
9
Cov
13%
print
72.0
parse
6.0
new
2.0
CRAP 42.4
« BT368i/NMEA/GP/GGA.pm ↑ Summary BT368i/NMEA/GP/GSA.pm »
1 #
2 # Written by Travis Kent Beste
3 # Fri Aug 6 22:13:22 CDT 2010
4  
5 package BT368i::NMEA::GP::RMC;
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 utc_time => '',
28 status => '',
29 latitude => '',
30 latitude_hemisphere => '',
31 longitude => '',
32 longitude_hemisphere => '',
33 speed => '',
34 course => '',
35 utc_date => '',
36 magnetic_variation => '',
37 magnetic_variation_direction => '',
38 );
39  
40 0 my $self = {
41 %fields,
42 };
43 0 bless $self, $class;
44  
45 0 return $self;
46 }
47  
48 #----------------------------------------#
49 #
50 #----------------------------------------#
51 0 ▶sub print {
Subroutine print: not called CC=8 SCAR=42.8
Pod documented
52 0 my $self = shift;
53  
54 0 print "utc_time : " . $self->{utc_time} . "\n";
55 0 ▶ if ($self->{status} eq 'A') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'status'} eq 'A') { } 0 0 0
elsif ($self->{'status'} eq 'V') { } 0 0 0
56 0 print "status : valid position\n";
57 } elsif ($self->{status} eq 'V') {
58 0 print "status : NAV receiver warning\n";
59 }
60 0 print "latitude : " . $self->{latitude} . "\n";
61 0 ▶ if ($self->{latitude_hemisphere} eq 'N') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'latitude_hemisphere'} eq 'N') { } 0 0 0
elsif ($self->{'latitude_hemisphere'} eq 'N') { } 0 0 0
62 0 print "latitude hemisphere : NORTH\n";
63 } elsif ($self->{latitude_hemisphere} eq 'N') {
64 0 print "latitude hemisphere : SOUTH\n";
65 }
66 0 print "longitude : " . $self->{longitude} . "\n";
67 0 ▶ if ($self->{longitude_hemisphere} eq 'E') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'longitude_hemisphere'} eq 'E') { } 0 0 0
elsif ($self->{'longitude_hemisphere'} eq 'W') { } 0 0 0
68 0 print "hemisphere : EAST\n";
69 } elsif ($self->{longitude_hemisphere} eq 'W') {
70 0 print "hemisphere : WEST\n";
71 }
72 0 print "course : " . $self->{course} . " degrees\n";
73 0 print "speed : " . $self->{speed} . " knots\n";
74 0 print "utc date : " . $self->{utc_date} . "\n";
75 0 print "magnetic variation : ";
76 0 ▶ if ($self->{magnetic_variation} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'magnetic_variation'} ne '') { } 0 0 0
77 0 print $self->{magnetic_variation} . " degrees\n";
78 } else {
79 0 print "\n";
80 }
81 0 print "magnetic variation direction : " . $self->{magnetic_variation_direction} . "\n";
82 }
83  
84 #----------------------------------------#
85 #
86 #----------------------------------------#
87 0 ▶sub parse {
Subroutine parse: not called CC=2 SCAR=17.9
Pod documented
88 0 my $self = shift;
89 0 my $data = shift;
90  
91 # if we're logging, save data to filehandle
92 0 ▶ if ($self->{log_fh}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"log_fh"}) 0 0 0
93 0 print { $self->{log_fh} } $data . "\n";
94 }
95  
96 0 $data =~ s/\*..$//; # remove the last three bytes
97 0 my @args = split(/,/, $data);
98  
99 # 1) UTC time of position fix, hhmmss format
100 0 my @utc_time = split(//, $args[1]);
101 0 my $hh = $utc_time[0]; $hh .= $utc_time[1];
102 0 my $mm = $utc_time[2]; $mm .= $utc_time[3];
103 0 my $ss = $utc_time[4]; $ss .= $utc_time[5];
104 0 my $ms = $utc_time[7]; $ms .= $utc_time[8]; $ms .= $utc_time[9];
105 #print "utc_time : $hh, $mm, $ss $ms - $args[1]\n";
106 0 $self->{utc_time} = $hh . ':' . $mm . ':' . $ss . '.' . $ms;
107  
108 # 2) Status, A=Valid position, V=NAV receiver warning
109 0 $self->{status} = $args[2];
110  
111 # 3) Latitude, ddmm.mmmm format (leading zeros sent)
112 0 $self->{latitude} = $args[3];
113  
114 # 4) Latitude hemisphere, N or S
115 0 $self->{latitude_hemisphere} = $args[4];
116  
117 # 5) Longitude, dddmm.mmmm format (leading zeros sent)
118 0 $self->{longitude} = $args[5];
119  
120 # 6) Longitude hemisphere, E or W
121 0 $self->{longitude_hemisphere} = $args[6];
122  
123 # 7) Speed over ground, 0.0 to 999.9 knots
124 0 $self->{speed} = $args[7];
125  
126 # 8) Course over ground, 000.0 to 359.9 degrees, true (leading zeros sent)
127 0 $self->{course} = $args[8];
128  
129 # 9) UTC date of position fix, ddmmyy format
130 0 my @utc_date = split(//, $args[9]);
131 0 my $dd = $utc_date[0]; $dd .= $utc_date[1];
132 0 my $mm = $utc_date[2]; $mm .= $utc_date[3];
133 0 my $yy = $utc_date[4]; $yy .= $utc_date[5];
134 0 $self->{utc_date} = $yy . '-' . $mm . '-' . $dd;
135  
136 # 10) Magnetic variation, 000.0 to 180.0 degrees (leading zeros sent)
137 0 $self->{magnetic_variation} = $args[10];
138  
139 # 11) Magnetic variation direction, E or W (westerly variation adds to true course)
140 0 $self->{magnetic_variation_direction} = $args[11];
141 }
142  
143 1 1;
144  
145 __END__
« BT368i/NMEA/GP/GGA.pm ↑ Summary BT368i/NMEA/GP/GSA.pm »