File Coverage

blib/lib/BT368i/NMEA/GP/GSA.pm
Criterion Covered Total %
statement 9 62 14.5
branch 0 12 0.0
condition n/a
subroutine 3 6 50.0
pod 2 3 66.6
total 14 83 16.8


line stmt bran cond sub pod time code
1             #
2             # Written by Travis Kent Beste
3             # Fri Aug 6 22:48:49 CDT 2010
4              
5             package BT368i::NMEA::GP::GSA;
6              
7 1     1   6 use strict;
  1         2  
  1         42  
8 1     1   5 use vars qw( );
  1         2  
  1         17  
9              
10 1     1   15 use Data::Dumper;
  1         2  
  1         1005  
11              
12             our @ISA = qw( );
13              
14             our $VERSION = sprintf("%d.%02d", q$Revision: 1.00 $ =~ /(\d+)\.(\d+)/);
15              
16             #----------------------------------------#
17             #
18             #----------------------------------------#
19             sub new {
20 0     0 0   my $class = shift;
21 0           my %args = shift;
22              
23 0           my %fields = (
24             log_fh => '',
25             log_filename => '',
26              
27             mode => '',
28             fix_type => '',
29             prn_00 => '',
30             prn_01 => '',
31             prn_02 => '',
32             prn_03 => '',
33             prn_04 => '',
34             prn_05 => '',
35             prn_06 => '',
36             prn_07 => '',
37             prn_08 => '',
38             prn_10 => '',
39             prn_11 => '',
40             position_diliution => '',
41             horizontal_diliution => '',
42             vertical_diliution => '',
43             );
44              
45 0           my $self = {
46             %fields,
47             };
48 0           bless $self, $class;
49              
50 0           return $self;
51             }
52              
53             #----------------------------------------#
54             #
55             #----------------------------------------#
56             sub print {
57 0     0 1   my $self = shift;
58              
59 0 0         if ($self->{mode} eq 'M') {
    0          
60 0           print "mode : manual\n";
61             } elsif ($self->{mode} eq 'A') {
62 0           print "mode : automatic\n";
63             }
64              
65 0 0         if ($self->{fix_type} == 1) {
    0          
    0          
66 0           print "fix : no fix\n";
67             } elsif ($self->{fix_type} == 2) {
68 0           print "fix : 2D\n";
69             } elsif ($self->{fix_type} == 3) {
70 0           print "fix : 3D\n";
71             }
72              
73 0           print "prn 00 : " . $self->{prn_00} . "\n";
74 0           print "prn 01 : " . $self->{prn_01} . "\n";
75 0           print "prn 02 : " . $self->{prn_02} . "\n";
76 0           print "prn 03 : " . $self->{prn_03} . "\n";
77 0           print "prn 04 : " . $self->{prn_04} . "\n";
78 0           print "prn 05 : " . $self->{prn_05} . "\n";
79 0           print "prn 06 : " . $self->{prn_06} . "\n";
80 0           print "prn 07 : " . $self->{prn_07} . "\n";
81 0           print "prn 08 : " . $self->{prn_08} . "\n";
82 0           print "prn 09 : " . $self->{prn_09} . "\n";
83 0           print "prn 10 : " . $self->{prn_10} . "\n";
84 0           print "prn 11 : " . $self->{prn_11} . "\n";
85              
86 0           print "position diliution : " . $self->{position_diliution} . "\n";
87 0           print "horizontal diliution : " . $self->{horizontal_diliution} . "\n";
88 0           print "vertical diliution : " . $self->{vertical_diliution} . "\n";
89             }
90              
91             #----------------------------------------#
92             #
93             #----------------------------------------#
94             sub parse {
95 0     0 1   my $self = shift;
96 0           my $data = shift;
97              
98             # if we're logging, save data to filehandle
99 0 0         if ($self->{log_fh}) {
100 0           print { $self->{log_fh} } $data . "\n";
  0            
101             }
102              
103 0           $data =~ s/\*..$//; # remove the last three bytes
104 0           my @args = split(/,/, $data);
105              
106             # 1) Mode, M=Manual, A=Automatic
107 0           $self->{mode} = $args[1];
108              
109             # 2) Fix type, 1=no fix, 2=2D, 3=3D
110 0           $self->{fix_type} = $args[2];
111              
112             # 3) PRN number, 01 to 32, of satellites used in solution (leading zeroes sent)
113 0           $self->{prn_00} = $args[3];
114 0           $self->{prn_01} = $args[4];
115 0           $self->{prn_02} = $args[5];
116 0           $self->{prn_03} = $args[6];
117 0           $self->{prn_04} = $args[7];
118 0           $self->{prn_05} = $args[8];
119 0           $self->{prn_06} = $args[9];
120 0           $self->{prn_07} = $args[10];
121 0           $self->{prn_08} = $args[11];
122 0           $self->{prn_09} = $args[12];
123 0           $self->{prn_10} = $args[13];
124 0           $self->{prn_11} = $args[14];
125              
126             # 4) Position dilution of precision, 1.0 to 99.9
127 0           $self->{position_diliution} = $args[15];
128              
129             # 5) Horizontal dilution of precision, 1.0 to 99.9
130 0           $self->{horizontal_diliution} = $args[16];
131              
132             # 6) Vertical dilution of precision, 1.0 to 99.9
133 0           $self->{vertical_diliution} = $args[17];
134             }
135              
136             1;
137              
138             __END__