| 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_ANALOG_OUT_CHANNELS 48 |
| 35 | #define ATC_COMPASS_CH 5 |
| 36 | #define ATC_STEPPER_HOME 0xC0 |
| 37 | |
| 38 | |
| 39 | class FGATCOutput { |
| 40 | |
| 41 | int is_open; |
| 42 | |
| 43 | int board; |
| 44 | SGPath config; |
| 45 | |
| 46 | int analog_out_fd; |
| 47 | int lamps_fd; |
| 48 | int radio_display_fd; |
| 49 | int stepper_fd; |
| 50 | |
| 51 | char analog_out_file[256]; |
| 52 | char lamps_file[256]; |
| 53 | char radio_display_file[256]; |
| 54 | char stepper_file[256]; |
| 55 | |
| 56 | unsigned char analog_out_data[ATC_ANALOG_OUT_CHANNELS*2]; |
| 57 | unsigned char radio_display_data[ATC_RADIO_DISPLAY_BYTES]; |
| 58 | |
| 59 | SGPropertyNode_ptr analog_out_node; |
| 60 | SGPropertyNode_ptr lamps_out_node; |
| 61 | SGPropertyNode_ptr radio_display_node; |
| 62 | SGPropertyNode_ptr steppers_node; |
| 63 | |
| 64 | void init_config(); |
| 65 | bool do_analog_out(); |
| 66 | bool do_lamps(); |
| 67 | bool do_radio_display(); |
| 68 | bool do_steppers(); |
| 69 | |
| 70 | // hardwired stepper motor code |
| 71 | float compass_position; |
| 72 | |
| 73 | public: |
| 74 | |
| 75 | // Constructor: The _board parameter specifies which board to |
| 76 | // reference. Possible values are 0 or 1. The _config_file |
| 77 | // parameter specifies the location of the output config file (xml) |
| 78 | FGATCOutput( const int _board, const SGPath &_config_file ); |
| 79 | |
| 80 | // Destructor |
| 81 | ~FGATCOutput() { } |
| 82 | |
| 83 | // need to pass in atc hardware lock_fd so that the radios and |
| 84 | // lamps can be blanked and so that the compass can be homed. |
| 85 | bool open( int lock_fd ); |
| 86 | |
| 87 | // process the hardware outputs. This code assumes the calling |
| 88 | // layer will lock the hardware. |
| 89 | bool process(); |
| 90 | |
| 91 | bool close(); |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | #endif // _FG_ATC_OUTPUTS_HXX |