Debian Codegraph @

src/Network/AV400WSim.hxx

raw symbols SCIP
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 #pragma once
28
29 #include <simgear/compiler.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #include <string>
34
35 #include "protocol.hxx"
36
37 class FlightProperties;
38
39 //////////////////////////////////////////////////////////////////////////////
40 // Class FGAV400WSimA handles the input/output over the first serial port.
41 // This is very similar to the way previous Garmin non-WAAS models communicated
42 // but some items have been stripped out and just a minimal amount of
43 // info is necessary to be transmitted over this port.
44
45 class FGAV400WSimA : public FGProtocol {
46
47 char buf[ FG_MAX_MSG_SIZE ];
48 int length;
49
50 public:
51
52 FGAV400WSimA();
53 ~FGAV400WSimA();
54
55 bool gen_message();
56 bool parse_message();
57
58 // open hailing frequencies
59 bool open();
60
61 // process work for this port
62 bool process();
63
64 // close the channel
65 bool close();
66 };
67
68 //////////////////////////////////////////////////////////////////////////////
69 // Class FGAV400WSimB handles the input/output over the second serial port
70 // which Garmin refers to as the "GPS Port". Some messages are handled on
71 // fixed cycle (usually 1 and 5 Hz) and some immediate responses are needed
72 // to certain messages upon requet by the GPS unit
73
74 class FGAV400WSimB : public FGProtocol {
75
76 char buf[ FG_MAX_MSG_SIZE ];
77 int length;
78 double hz2;
79 int hz2count;
80 int hz2cycles;
81 char flight_phase;
82 std::string hal;
83 std::string val;
84 std::string sbas_sel;
85 bool req_hostid;
86 bool req_sbas;
87 int outputctr;
88
89 FlightProperties* fdm;
90
91 static const int SOM_SIZE = 2;
92 static const int DEG_TO_MILLIARCSECS = ( 60 * 60 * 1000 );
93
94 // Flight Phases
95 static const int PHASE_OCEANIC = 4;
96 static const int PHASE_ENROUTE = 5;
97 static const int PHASE_TERM = 6;
98 static const int PHASE_NONPREC = 7;
99 static const int PHASE_LNAVVNAV = 8;
100 static const int PHASE_LPVLP = 9;
101
102 public:
103
104 FGAV400WSimB();
105 ~FGAV400WSimB();
106
107 bool gen_hostid_message();
108 bool gen_sbas_message();
109
110 bool gen_Wh_message();
111 bool gen_Wx_message();
112
113 bool gen_Wt_message();
114 bool gen_Wm_message();
115 bool gen_Wv_message();
116
117 bool verify_checksum( std::string message, int datachars );
118 std::string asciitize_message( std::string message );
119 std::string buffer_to_string();
120 bool parse_message();
121
122 // open hailing frequencies
123 bool open();
124
125 // process work for this port
126 bool process();
127
128 // close the channel
129 bool close();
130
131 inline double get_hz2() const { return hz2; }
132 inline void set_hz2( double t ) { hz2 = t, hz2cycles = get_hz() / hz2; }
133
134 };