2002-02-05 04:42:39 +00:00
|
|
|
// atc610x.hxx -- FGFS interface to ATC 610x hardware
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started January 2002.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _FG_ATC610X_HXX
|
|
|
|
#define _FG_ATC610X_HXX
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <plib/netChat.h>
|
|
|
|
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
|
|
#include "protocol.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
#define ATC_ANAL_IN_VALUES 32
|
|
|
|
#define ATC_ANAL_IN_BYTES (2 * ATC_ANAL_IN_VALUES)
|
|
|
|
#define ATC_COMPASS_CH 5
|
|
|
|
#define ATC_STEPPER_HOME 0xC0
|
|
|
|
#define ATC_RADIO_DISPLAY_BYTES 48
|
|
|
|
#define ATC_RADIO_SWITCH_BYTES 32
|
|
|
|
#define ATC_SWITCH_BYTES 16
|
|
|
|
#define ATC_NUM_COLS 8
|
|
|
|
|
|
|
|
|
|
|
|
class FGATC610x : public FGProtocol {
|
|
|
|
|
|
|
|
int board;
|
|
|
|
|
|
|
|
int lock_fd;
|
|
|
|
int analog_in_fd;
|
2002-06-05 05:22:42 +00:00
|
|
|
int lamps_fd;
|
2002-02-05 04:42:39 +00:00
|
|
|
int radios_fd;
|
|
|
|
int stepper_fd;
|
|
|
|
int switches_fd;
|
|
|
|
|
|
|
|
char lock_file[256];
|
|
|
|
char analog_in_file[256];
|
2002-06-05 05:22:42 +00:00
|
|
|
char lamps_file[256];
|
2002-02-05 04:42:39 +00:00
|
|
|
char radios_file[256];
|
|
|
|
char stepper_file[256];
|
|
|
|
char switches_file[256];
|
|
|
|
|
|
|
|
unsigned char analog_in_bytes[ATC_ANAL_IN_BYTES];
|
|
|
|
int analog_in_data[ATC_ANAL_IN_VALUES];
|
|
|
|
unsigned char radio_display_data[ATC_RADIO_DISPLAY_BYTES];
|
|
|
|
unsigned char radio_switch_data[ATC_RADIO_SWITCH_BYTES];
|
|
|
|
unsigned char switch_data[ATC_SWITCH_BYTES];
|
|
|
|
|
|
|
|
float compass_position;
|
2002-09-12 03:15:27 +00:00
|
|
|
|
2002-09-26 17:26:34 +00:00
|
|
|
SGPropertyNode *adf_bus_power, *dme_bus_power, *xpdr_bus_power;
|
2002-09-26 14:13:42 +00:00
|
|
|
SGPropertyNode *navcom1_bus_power, *navcom2_bus_power;
|
|
|
|
|
2002-02-05 04:42:39 +00:00
|
|
|
SGPropertyNode *mag_compass;
|
|
|
|
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
|
2002-09-26 04:45:45 +00:00
|
|
|
SGPropertyNode *navcom1_power_btn, *navcom2_power_btn;
|
2002-02-05 04:42:39 +00:00
|
|
|
SGPropertyNode *com1_freq, *com1_stby_freq;
|
|
|
|
SGPropertyNode *com2_freq, *com2_stby_freq;
|
|
|
|
SGPropertyNode *nav1_freq, *nav1_stby_freq;
|
|
|
|
SGPropertyNode *nav2_freq, *nav2_stby_freq;
|
2002-07-03 04:48:44 +00:00
|
|
|
SGPropertyNode *adf_adf_btn, *adf_bfo_btn;
|
2002-09-26 17:26:34 +00:00
|
|
|
SGPropertyNode *adf_power_btn, *adf_vol;
|
2002-07-03 04:48:44 +00:00
|
|
|
SGPropertyNode *adf_freq, *adf_stby_freq;
|
|
|
|
SGPropertyNode *adf_stby_mode, *adf_timer_mode;
|
2002-06-30 22:46:34 +00:00
|
|
|
SGPropertyNode *adf_count_mode, *adf_flight_timer, *adf_elapsed_timer;
|
2002-07-03 23:35:21 +00:00
|
|
|
SGPropertyNode *adf_ant_ann, *adf_adf_ann, *adf_bfo_ann, *adf_frq_ann;
|
|
|
|
SGPropertyNode *adf_flt_ann, *adf_et_ann;
|
2002-06-05 05:22:42 +00:00
|
|
|
SGPropertyNode *inner, *middle, *outer;
|
2002-07-04 21:38:37 +00:00
|
|
|
SGPropertyNode *xpdr_ident_btn;
|
|
|
|
SGPropertyNode *xpdr_digit1, *xpdr_digit2, *xpdr_digit3, *xpdr_digit4;
|
|
|
|
SGPropertyNode *xpdr_func_knob, *xpdr_id_code, *xpdr_flight_level;
|
|
|
|
SGPropertyNode *xpdr_fl_ann, *xpdr_alt_ann, *xpdr_gnd_ann, *xpdr_on_ann;
|
|
|
|
SGPropertyNode *xpdr_sby_ann, *xpdr_reply_ann;
|
2002-02-05 04:42:39 +00:00
|
|
|
|
2002-09-12 03:15:27 +00:00
|
|
|
// configuration values
|
|
|
|
SGPropertyNode *elevator_center, *elevator_min, *elevator_max;
|
|
|
|
SGPropertyNode *ailerons_center, *ailerons_min, *ailerons_max;
|
|
|
|
SGPropertyNode *rudder_center, *rudder_min, *rudder_max;
|
|
|
|
SGPropertyNode *throttle_min, *throttle_max;
|
|
|
|
SGPropertyNode *mixture_min, *mixture_max;
|
|
|
|
SGPropertyNode *trim_center, *trim_min, *trim_max;
|
|
|
|
SGPropertyNode *nav1vol_min, *nav1vol_max;
|
|
|
|
SGPropertyNode *nav2vol_min, *nav2vol_max;
|
|
|
|
|
2002-02-05 04:42:39 +00:00
|
|
|
int dme_switch;
|
|
|
|
|
|
|
|
bool do_analog_in();
|
2002-07-03 23:35:21 +00:00
|
|
|
bool do_lights();
|
2002-02-05 04:42:39 +00:00
|
|
|
bool do_radio_switches();
|
|
|
|
bool do_radio_display();
|
|
|
|
bool do_steppers();
|
|
|
|
bool do_switches();
|
|
|
|
|
2002-09-26 04:45:45 +00:00
|
|
|
// convenience
|
2002-09-26 17:26:34 +00:00
|
|
|
inline bool adf_has_power() const {
|
|
|
|
return (adf_bus_power->getDoubleValue() > 1.0)
|
|
|
|
&& adf_power_btn->getBoolValue();
|
|
|
|
}
|
2002-09-26 14:13:42 +00:00
|
|
|
inline bool dme_has_power() const {
|
|
|
|
return (dme_bus_power->getDoubleValue() > 1.0)
|
|
|
|
&& dme_switch;
|
|
|
|
}
|
2002-09-26 04:45:45 +00:00
|
|
|
inline bool navcom1_has_power() const {
|
|
|
|
return (navcom1_bus_power->getDoubleValue() > 1.0)
|
|
|
|
&& navcom1_power_btn->getBoolValue();
|
|
|
|
}
|
|
|
|
inline bool navcom2_has_power() const {
|
|
|
|
return (navcom2_bus_power->getDoubleValue() > 1.0)
|
|
|
|
&& navcom2_power_btn->getBoolValue();
|
|
|
|
}
|
2002-09-26 17:26:34 +00:00
|
|
|
inline bool xpdr_has_power() const {
|
|
|
|
return (xpdr_bus_power->getDoubleValue() > 1.0)
|
|
|
|
&& (xpdr_func_knob->getIntValue() > 0);
|
|
|
|
}
|
2002-09-26 04:45:45 +00:00
|
|
|
|
2002-02-05 04:42:39 +00:00
|
|
|
public:
|
|
|
|
|
2002-07-03 23:35:21 +00:00
|
|
|
FGATC610x() { }
|
2002-02-05 04:42:39 +00:00
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
~FGATC610x() { }
|
2002-02-05 04:42:39 +00:00
|
|
|
|
|
|
|
bool open();
|
2002-09-12 03:15:27 +00:00
|
|
|
void init_config();
|
2002-02-05 04:42:39 +00:00
|
|
|
|
|
|
|
bool process();
|
|
|
|
|
|
|
|
bool close();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_ATC610X_HXX
|