]> git.mxchange.org Git - flightgear.git/blob - src/Network/ATC-Outputs.hxx
fix another crash on exit by finally converting the rest of unguarded
[flightgear.git] / src / Network / ATC-Outputs.hxx
1 // ATC-Outputs.hxx -- Translate FGFS properties into ATC hardware outputs
2 //
3 // Written by Curtis Olson, started November 2004.
4 //
5 // Copyright (C) 2004  Curtis L. Olson - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_ATC_OUTPUTS_HXX
25 #define _FG_ATC_OUTPUTS_HXX
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <Main/fg_props.hxx>
32
33 #define ATC_RADIO_DISPLAY_BYTES 48
34 #define ATC_COMPASS_CH 5
35 #define ATC_STEPPER_HOME 0xC0
36
37
38 class FGATCOutput {
39
40     int is_open;
41
42     int board;
43     SGPath config;
44
45     int lock_fd;
46     int lamps_fd;
47     int radio_display_fd;
48     int stepper_fd;
49
50     char lamps_file[256];
51     char radio_display_file[256];
52     char stepper_file[256];
53
54     unsigned char radio_display_data[ATC_RADIO_DISPLAY_BYTES];
55
56     SGPropertyNode_ptr lamps_out_node;
57     SGPropertyNode_ptr radio_display_node;
58     SGPropertyNode_ptr steppers_node;
59
60     void init_config();
61     bool do_lamps();
62     bool do_radio_display();
63     bool do_steppers();
64
65     // hardwired stepper motor code
66     float compass_position;
67
68 public:
69
70     // Constructor: The _board parameter specifies which board to
71     // reference.  Possible values are 0 or 1.  The _config_file
72     // parameter specifies the location of the output config file (xml)
73     FGATCOutput( const int _board, const SGPath &_config_file );
74
75     // Destructor
76     ~FGATCOutput() { }
77
78     // need to pass in atc hardware lock_fd so that the radios and
79     // lamps can be blanked and so that the compass can be homed.
80     bool open( int lock_fd );
81
82     // process the hardware outputs.  This code assumes the calling
83     // layer will lock the hardware.
84     bool process();
85
86     bool close();
87 };
88
89
90 #endif // _FG_ATC_OUTPUTS_HXX