From e9b70e3ab8ab098a5a59f5ea2c13bed9e8c5695c Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 19 Nov 2004 23:01:34 +0000 Subject: [PATCH] Changes by Roy Ovesen to begin migrating the avionics out of the Cockpit directory and over to the Instrumentation directory and make them modular in the sense of being able to pick and choose what you include with any particular aircraft. --- src/Cockpit/Makefile.am | 3 -- src/Cockpit/radiostack.cxx | 32 +++++++++++----------- src/Cockpit/radiostack.hxx | 14 +++++----- src/Instrumentation/Makefile.am | 3 ++ src/Instrumentation/attitude_indicator.cxx | 24 ++++++++++------ src/Instrumentation/heading_indicator.cxx | 25 +++++++++++------ src/Instrumentation/instrument_mgr.cxx | 18 ++++++++++-- src/Instrumentation/turn_indicator.cxx | 25 +++++++++++------ 8 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/Cockpit/Makefile.am b/src/Cockpit/Makefile.am index 307f8f2f8..74d3bce80 100644 --- a/src/Cockpit/Makefile.am +++ b/src/Cockpit/Makefile.am @@ -2,15 +2,12 @@ noinst_LIBRARIES = libCockpit.a libCockpit_a_SOURCES = \ cockpit.cxx cockpit.hxx \ - dme.cxx dme.hxx \ hud.cxx hud.hxx hud_opts.hxx \ hud_card.cxx hud_dnst.cxx hud_gaug.cxx hud_inst.cxx \ hud_labl.cxx hud_ladr.cxx \ hud_lat.cxx hud_lon.cxx \ hud_rwy.cxx \ hud_scal.cxx hud_tbi.cxx \ - kt_70.cxx kt_70.hxx \ - marker_beacon.cxx marker_beacon.hxx \ navcom.cxx navcom.hxx \ panel.cxx panel.hxx \ panel_io.cxx panel_io.hxx \ diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 4b07bfd2b..09986f096 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -51,10 +51,10 @@ FGRadioStack::FGRadioStack() { FGRadioStack::~FGRadioStack() { //adf.unbind(); - beacon.unbind(); + //beacon.unbind(); navcom1.unbind(); navcom2.unbind(); - xponder.unbind(); + //xponder.unbind(); } @@ -68,8 +68,8 @@ FGRadioStack::init () navcom2.init(); //adf.init(); - beacon.init(); - xponder.init(); + //beacon.init(); + //xponder.init(); search(); update(0); // FIXME: use dt @@ -84,13 +84,13 @@ void FGRadioStack::bind () { //adf.bind(); - beacon.bind(); - dme.bind(); + //beacon.bind(); + //dme.bind(); navcom1.set_bind_index( 0 ); navcom1.bind(); navcom2.set_bind_index( 1 ); navcom2.bind(); - xponder.bind(); + //xponder.bind(); } @@ -98,11 +98,11 @@ void FGRadioStack::unbind () { //adf.unbind(); - beacon.unbind(); - dme.unbind(); + //beacon.unbind(); + //dme.unbind(); navcom1.unbind(); navcom2.unbind(); - xponder.unbind(); + //xponder.unbind(); } @@ -111,11 +111,11 @@ void FGRadioStack::update(double dt) { //adf.update( dt ); - beacon.update( dt ); + //beacon.update( dt ); navcom1.update( dt ); navcom2.update( dt ); - dme.update( dt ); // dme is updated after the navcom's - xponder.update( dt ); + //dme.update( dt ); // dme is updated after the navcom's + //xponder.update( dt ); } @@ -123,9 +123,9 @@ FGRadioStack::update(double dt) void FGRadioStack::search() { //adf.search(); - beacon.search(); + //beacon.search(); navcom1.search(); navcom2.search(); - dme.search(); - xponder.search(); + //dme.search(); + //xponder.search(); } diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index 7da4f4447..fb6e87586 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -36,18 +36,18 @@ #include #include -#include "dme.hxx" -#include "kt_70.hxx" // Transponder -#include "marker_beacon.hxx" +//#include "dme.hxx" +//#include "kt_70.hxx" // Transponder +//#include "marker_beacon.hxx" #include "navcom.hxx" class FGRadioStack : public SGSubsystem { - FGDME dme; + //FGDME dme; //FGKR_87 adf; // King KR 87 Digital ADF model - FGKT_70 xponder; // Bendix/King KT 70 Panel-Mounted Transponder - FGMarkerBeacon beacon; + //FGKT_70 xponder; // Bendix/King KT 70 Panel-Mounted Transponder + //FGMarkerBeacon beacon; FGNavCom navcom1; FGNavCom navcom2; @@ -64,7 +64,7 @@ public: // Update nav/adf radios based on current postition void search (); - inline FGDME *get_dme() { return &dme; } + //inline FGDME *get_dme() { return &dme; } inline FGNavCom *get_navcom1() { return &navcom1; } inline FGNavCom *get_navcom2() { return &navcom2; } }; diff --git a/src/Instrumentation/Makefile.am b/src/Instrumentation/Makefile.am index 579e0a27f..949da0e20 100644 --- a/src/Instrumentation/Makefile.am +++ b/src/Instrumentation/Makefile.am @@ -14,7 +14,10 @@ libInstrumentation_a_SOURCES = \ gyro.cxx gyro.hxx \ heading_indicator.cxx heading_indicator.hxx \ kr_87.hxx kr_87.cxx \ + kt_70.cxx kt_70.hxx \ mag_compass.cxx mag_compass.hxx \ + marker_beacon.cxx marker_beacon.hxx \ + navradio.cxx navradio.hxx \ slip_skid_ball.cxx slip_skid_ball.hxx \ transponder.cxx transponder.hxx \ turn_indicator.cxx turn_indicator.hxx \ diff --git a/src/Instrumentation/attitude_indicator.cxx b/src/Instrumentation/attitude_indicator.cxx index d57947663..1555c2c74 100644 --- a/src/Instrumentation/attitude_indicator.cxx +++ b/src/Instrumentation/attitude_indicator.cxx @@ -6,6 +6,12 @@ // TODO: // - better spin-up +#include + +#include STL_IOSTREAM +#include STL_STRING +#include + #include // fabs() #include "attitude_indicator.hxx" @@ -72,25 +78,27 @@ AttitudeIndicator::init () void AttitudeIndicator::bind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; - fgTie(branch.c_str(), + fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); - branch = "/instrumentation/" + name + "/spin"; - fgTie(branch.c_str(), + fgTie((branch + "/spin").c_str(), &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm); } void AttitudeIndicator::unbind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; - fgUntie(branch.c_str()); - branch = "/instrumentation/" + name + "/spin"; - fgUntie(branch.c_str()); + fgUntie((branch + "/serviceable").c_str()); + fgUntie((branch + "/spin").c_str()); } void diff --git a/src/Instrumentation/heading_indicator.cxx b/src/Instrumentation/heading_indicator.cxx index 9c2877cf2..4ab01a60f 100644 --- a/src/Instrumentation/heading_indicator.cxx +++ b/src/Instrumentation/heading_indicator.cxx @@ -3,6 +3,11 @@ // // This file is in the Public Domain and comes with no warranty. +#include +#include STL_IOSTREAM +#include STL_STRING +#include + #include "heading_indicator.hxx" #include
#include
@@ -61,23 +66,27 @@ HeadingIndicator::init () void HeadingIndicator::bind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; - fgTie(branch.c_str(), + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + + fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); - branch = "/instrumentation/" + name + "/spin"; - fgTie(branch.c_str(), + fgTie((branch + "/spin").c_str(), &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm); } void HeadingIndicator::unbind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; - fgUntie(branch.c_str()); - branch = "/instrumentation/" + name + "/spin"; - fgUntie(branch.c_str()); + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + + fgUntie((branch + "/serviceable").c_str()); + fgUntie((branch + "/spin").c_str()); } void diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 5a47f63a3..85e8b8779 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -27,7 +27,10 @@ #include "gps.hxx" #include "heading_indicator.hxx" #include "kr_87.hxx" +#include "kt_70.hxx" #include "mag_compass.hxx" +#include "marker_beacon.hxx" +#include "navradio.hxx" #include "slip_skid_ball.hxx" #include "transponder.hxx" #include "turn_indicator.hxx" @@ -111,15 +114,27 @@ bool FGInstrumentMgr::build () } else if ( name == "encoder" ) { set_subsystem( "instrument" + temp.str(), new Encoder( node ) ); + } else if ( name == "gps" ) { + set_subsystem( "instrument" + temp.str(), + new GPS( node ), 0.45 ); } else if ( name == "heading-indicator" ) { set_subsystem( "instrument" + temp.str(), new HeadingIndicator( node ) ); } else if ( name == "KR-87" ) { set_subsystem( "instrument" + temp.str(), new FGKR_87( node ) ); + } else if ( name == "KT-70" ) { + set_subsystem( "instrument" + temp.str(), + new FGKT_70( node ) ); } else if ( name == "magnetic-compass" ) { set_subsystem( "instrument" + temp.str(), new MagCompass( node ) ); + } else if ( name == "marker-beacon" ) { + set_subsystem( "instrument" + temp.str(), + new FGMarkerBeacon( node ) ); + } else if ( name == "nav-radio" ) { + set_subsystem( "instrument" + temp.str(), + new FGNavRadio( node ) ); } else if ( name == "slip-skid-ball" ) { set_subsystem( "instrument" + temp.str(), new SlipSkidBall( node ) ); @@ -132,9 +147,6 @@ bool FGInstrumentMgr::build () } else if ( name == "vertical-speed-indicator" ) { set_subsystem( "instrument" + temp.str(), new VerticalSpeedIndicator( node ) ); - } else if ( name == "gps" ) { - set_subsystem( "instrument" + temp.str(), - new GPS( node ), 0.45 ); } else { SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: " << name ); diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 2a4565790..be03a8879 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -3,6 +3,11 @@ // // This file is in the Public Domain and comes with no warranty. +#include +#include STL_IOSTREAM +#include STL_STRING +#include + #include "turn_indicator.hxx" #include
#include
@@ -62,23 +67,27 @@ TurnIndicator::init () void TurnIndicator::bind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; - fgTie(branch.c_str(), + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + + fgTie((branch + "/serviceable").c_str(), &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable); - branch = "/instrumentation/" + name + "/spin"; - fgTie(branch.c_str(), + fgTie((branch + "/spin").c_str(), &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm); } void TurnIndicator::unbind () { + std::ostringstream temp; string branch; - branch = "/instrumentation/" + name + "/serviceable"; - fgUntie(branch.c_str()); - branch = "/instrumentation/" + name + "/spin"; - fgUntie(branch.c_str()); + temp << num; + branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + + fgUntie((branch + "/serviceable").c_str()); + fgUntie((branch + "/serviceable").c_str()); } void