BT368i/NMEA/GP/VTG.pm

filter: Statementstmt 35.2% 12 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 66.6% 2 / 3 totaltotal 37.7% 17 / 45 CC 2 SCAR 10.0
CC
2
Cov
33%
parse
6.0
new
2.0
print
2.0
CRAP 2.7
« BT368i/NMEA/GP/GSV.pm ↑ Summary
1 #
2 # Written by Travis Kent Beste
3 # Fri Aug 6 22:13:22 CDT 2010
4  
5 package BT368i::NMEA::GP::VTG;
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 true_track => '',
28 magnetic_track => '',
29 ground_speed_knots => '',
30 ground_speed_kilometers => '',
31 );
32  
33 0 my $self = {
34 %fields,
35 };
36 0 bless $self, $class;
37  
38 0 return $self;
39 }
40  
41 #----------------------------------------#
42 #
43 #----------------------------------------#
44 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
45 0 my $self = shift;
46  
47 0 print "true track : " . $self->{true_track} . "\n";
48 0 print "magnetic track : " . $self->{magnetic_track} . "\n";
49 0 print "ground speed knots : " . $self->{ground_speed_knots} . "\n";
50 0 print "ground speed kilometers : " . $self->{ground_speed_kilometers} . "\n";
51 }
52  
53 #----------------------------------------#
54 #
55 #----------------------------------------#
56 0 ▶sub parse {
Subroutine parse: not called CC=2 SCAR=17.9
Pod documented
57 0 my $self = shift;
58 0 my $data = shift;
59  
60 # if we're logging, save data to filehandle
61 0 ▶ if ($self->{log_fh}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"log_fh"}) 0 0 0
62 0 print { $self->{log_fh} } $data . "\n";
63 }
64  
65 0 $data =~ s/\*..$//; # remove the last three bytes
66 0 my @args = split(/,/, $data);
67  
68 # 1) 054.7,T True track made good (degrees)
69 0 $self->{true_track} = $args[1];
70  
71 # 2) 034.4,M Magnetic track made good
72 0 $self->{magnetic_track} = $args[3];
73  
74 # 3) 005.5,N Ground speed, knots
75 0 $self->{ground_speed_knots} = $args[5];
76  
77 # 4) 010.2,K Ground speed, Kilometers per hour
78 0 $self->{ground_speed_kilometers} = $args[7];
79 }
80  
81 1 1;
82  
83 __END__
« BT368i/NMEA/GP/GSV.pm ↑ Summary