]> git.mxchange.org Git - flightgear.git/blob - src/Network/atc610x.hxx
Compute teh altitude-agl if the remote end isn't sending it.
[flightgear.git] / src / Network / atc610x.hxx
1 // atc610x.hxx -- FGFS interface to ATC 610x hardware
2 //
3 // Written by Curtis Olson, started January 2002.
4 //
5 // Copyright (C) 2002  Curtis L. Olson - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_ATC610X_HXX
25 #define _FG_ATC610X_HXX
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <plib/netChat.h>
32
33 #include <Main/fg_props.hxx>
34
35 #include "protocol.hxx"
36
37
38 #define ATC_ANAL_IN_VALUES 32
39 #define ATC_ANAL_IN_BYTES (2 * ATC_ANAL_IN_VALUES)
40 #define ATC_COMPASS_CH 5
41 #define ATC_STEPPER_HOME 0xC0
42 #define ATC_RADIO_DISPLAY_BYTES 48
43 #define ATC_RADIO_SWITCH_BYTES 32
44 #define ATC_SWITCH_BYTES 16
45 #define ATC_NUM_COLS 8
46
47
48 class FGATC610x : public FGProtocol {
49
50     bool use_rudder;
51
52     int board;
53
54     int lock_fd;
55     int analog_in_fd;
56     int lamps_fd;
57     int radios_fd;
58     int stepper_fd;
59     int switches_fd;
60
61     char lock_file[256];
62     char analog_in_file[256];
63     char lamps_file[256];
64     char radios_file[256];
65     char stepper_file[256];
66     char switches_file[256];
67
68     unsigned char analog_in_bytes[ATC_ANAL_IN_BYTES];
69     int analog_in_data[ATC_ANAL_IN_VALUES];
70     unsigned char radio_display_data[ATC_RADIO_DISPLAY_BYTES];
71     unsigned char radio_switch_data[ATC_RADIO_SWITCH_BYTES];
72     unsigned char switch_data[ATC_SWITCH_BYTES];
73
74     float compass_position;
75
76     // Electrical system state
77     SGPropertyNode *adf_bus_power, *dme_bus_power, *xpdr_bus_power;
78     SGPropertyNode *navcom1_bus_power, *navcom2_bus_power;
79
80     // Property tree variables
81     SGPropertyNode *mag_compass;
82     SGPropertyNode *dme_min, *dme_kt, *dme_nm;
83     SGPropertyNode *dme_in_range;
84     SGPropertyNode *navcom1_power_btn, *navcom2_power_btn;
85     SGPropertyNode *com1_freq, *com1_stby_freq;
86     SGPropertyNode *com2_freq, *com2_stby_freq;
87     SGPropertyNode *nav1_freq, *nav1_stby_freq, *nav1_obs;
88     SGPropertyNode *nav2_freq, *nav2_stby_freq, *nav2_obs;
89     SGPropertyNode *adf_adf_btn, *adf_bfo_btn;
90     SGPropertyNode *adf_power_btn, *adf_vol;
91     SGPropertyNode *adf_freq, *adf_stby_freq;
92     SGPropertyNode *adf_stby_mode, *adf_timer_mode;
93     SGPropertyNode *adf_count_mode, *adf_flight_timer, *adf_elapsed_timer;
94     SGPropertyNode *adf_ant_ann, *adf_adf_ann, *adf_bfo_ann, *adf_frq_ann;
95     SGPropertyNode *adf_flt_ann, *adf_et_ann, *adf_hdg, *hdg_bug;
96     SGPropertyNode *inner, *middle, *outer;
97     SGPropertyNode *xpdr_ident_btn;
98     SGPropertyNode *xpdr_digit1, *xpdr_digit2, *xpdr_digit3, *xpdr_digit4;
99     SGPropertyNode *xpdr_func_knob, *xpdr_id_code, *xpdr_flight_level;
100     SGPropertyNode *xpdr_fl_ann, *xpdr_alt_ann, *xpdr_gnd_ann, *xpdr_on_ann;
101     SGPropertyNode *xpdr_sby_ann, *xpdr_reply_ann;
102     SGPropertyNode *ati_bird, *alt_press;
103
104     // Faults
105     SGPropertyNode *comm1_serviceable, *comm2_serviceable;
106     SGPropertyNode *nav1_serviceable, *nav2_serviceable;
107     SGPropertyNode *adf_serviceable, *xpdr_serviceable, *dme_serviceable;
108
109     // Configuration values
110     SGPropertyNode *elevator_center, *elevator_min, *elevator_max;
111     SGPropertyNode *ailerons_center, *ailerons_min, *ailerons_max;
112     SGPropertyNode *rudder_center, *rudder_min, *rudder_max;
113     SGPropertyNode *brake_left_min, *brake_left_max;
114     SGPropertyNode *brake_right_min, *brake_right_max;
115     SGPropertyNode *throttle_min, *throttle_max;
116     SGPropertyNode *mixture_min, *mixture_max;
117     SGPropertyNode *trim_center, *trim_min, *trim_max;
118     SGPropertyNode *nav1vol_min, *nav1vol_max;
119     SGPropertyNode *nav2vol_min, *nav2vol_max;
120
121     int dme_switch;
122
123     bool do_analog_in();
124     bool do_lights();
125     bool do_radio_switches();
126     bool do_radio_display();
127     bool do_steppers();
128     bool do_switches();
129
130     // convenience
131     inline bool adf_has_power() const {
132         return (adf_bus_power->getDoubleValue() > 1.0)
133             && adf_power_btn->getBoolValue();
134     }
135     inline bool dme_has_power() const {
136         return (dme_bus_power->getDoubleValue() > 1.0)
137             && dme_switch;
138     }
139     inline bool navcom1_has_power() const {
140         return (navcom1_bus_power->getDoubleValue() > 1.0)
141             && navcom1_power_btn->getBoolValue();
142     }
143     inline bool navcom2_has_power() const {
144         return (navcom2_bus_power->getDoubleValue() > 1.0)
145             && navcom2_power_btn->getBoolValue();
146     }
147     inline bool xpdr_has_power() const {
148         return (xpdr_bus_power->getDoubleValue() > 1.0)
149             && (xpdr_func_knob->getIntValue() > 0);
150     }
151
152 public:
153
154     FGATC610x() : use_rudder(true) { }
155     ~FGATC610x() { }
156
157     bool open();
158     void init_config();
159
160     bool process();
161
162     bool close();
163
164     inline void set_use_rudder( bool value ) { use_rudder = value; }
165 };
166
167
168 #endif // _FG_ATC610X_HXX