]> git.mxchange.org Git - flightgear.git/blob - src/Network/AV400WSim.hxx
Bruce Hellstrom @ ATC Flight Sim.
[flightgear.git] / src / Network / AV400WSim.hxx
1 // AV400Sim.hxx -- Garmin 400 series protocal class.  This AV400Sim
2 // protocol generates the set of "simulator" commands a garmin 400
3 // series gps would expect as input in simulator mode.  The AV400
4 // protocol generates the set of commands that a garmin 400 series gps
5 // would emit.
6 //
7 // Written by Curtis Olson, started Januar 2009.
8 //
9 // Copyright (C) 2009  Curtis L. Olson - http://www.flightgear.org/~curt
10 //
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of the
14 // License, or (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24 //
25 // $Id$
26
27
28 #ifndef _FG_AV400WSIM_HXX
29 #define _FG_AV400WSIM_HXX
30
31
32 #include <simgear/compiler.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 #include <string>
37
38 #include "protocol.hxx"
39
40 using std::string;
41
42 class FlightProperties;
43
44 //////////////////////////////////////////////////////////////////////////////
45 // Class FGAV400WSimA handles the input/output over the first serial port.
46 // This is very similar to the way previous Garmin non-WAAS models communicated
47 // but some items have been stripped out and just a minimal amount of
48 // info is necessary to be transmitted over this port.
49
50 class FGAV400WSimA : public FGProtocol {
51
52     char buf[ FG_MAX_MSG_SIZE ];
53     int length;
54
55 public:
56
57     FGAV400WSimA();
58     ~FGAV400WSimA();
59
60     bool gen_message();
61     bool parse_message();
62  
63     // open hailing frequencies
64     bool open();
65
66     // process work for this port
67     bool process();
68
69     // close the channel
70     bool close();
71 };
72
73 //////////////////////////////////////////////////////////////////////////////
74 // Class FGAV400WSimB handles the input/output over the second serial port
75 // which Garmin refers to as the "GPS Port".  Some messages are handled on
76 // fixed cycle (usually 1 and 5 Hz) and some immediate responses are needed
77 // to certain messages upon requet by the GPS unit
78
79 class FGAV400WSimB : public FGProtocol {
80
81     char buf[ FG_MAX_MSG_SIZE ];
82     int length;
83     double hz2;
84     int hz2count;
85     int hz2cycles;
86     char flight_phase;
87     string hal;
88     string val;
89     string sbas_sel;
90     bool req_hostid;
91     bool req_raimap;
92     bool req_sbas;
93     int outputctr;
94
95     FlightProperties* fdm;
96     
97     static const int SOM_SIZE = 2;
98     static const int DEG_TO_MILLIARCSECS = ( 60.0 * 60.0 * 1000 );
99     
100     // Flight Phases
101     static const int PHASE_OCEANIC  =   4;
102     static const int PHASE_ENROUTE  =   5;
103     static const int PHASE_TERM     =   6;
104     static const int PHASE_NONPREC  =   7;
105     static const int PHASE_LNAVVNAV =   8;
106     static const int PHASE_LPVLP    =   9;
107     
108 public:
109
110     FGAV400WSimB();
111     ~FGAV400WSimB();
112
113     bool gen_hostid_message();
114     bool gen_sbas_message();
115     
116     bool gen_Wh_message();
117     bool gen_Wx_message();
118
119     bool gen_Wt_message();
120     bool gen_Wm_message();
121     bool gen_Wv_message();
122     
123     bool verify_checksum( string message, int datachars );
124     string asciitize_message( string message );
125     string buffer_to_string();
126     bool parse_message();
127  
128     // open hailing frequencies
129     bool open();
130
131     // process work for this port
132     bool process();
133
134     // close the channel
135     bool close();
136     
137     inline double get_hz2() const { return hz2; }
138     inline void set_hz2( double t ) { hz2 = t, hz2cycles = get_hz() / hz2; }
139     
140 };
141
142
143
144 #endif // _FG_AV400WSIM_HXX