From 634e79353f72dab2d6b76dcca3788437403fb6a0 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 3 Dec 2004 21:21:16 +0000 Subject: [PATCH] Roy Vegard Ovesen: I've finished the emigration of the radiostack, and I've also removed it completely. It turned out that the comm radio is completely implemented in the ATC subsystem. I've changed the affected ATC files to point to /instrumentation/com, but I guess that the maintainer of the ATC code should decide wether to make it configureable, and how. I also had to change some files in Network and Main. The changes in network should be obvious, but the changes in Main were a bit suspect. The files included radiostack.hxx, but they weren't directly depending on radiostack-hxx. They were depending on other files that were included by radiostack.hxx. I got it to compile, but I'm not sure if I included the correct directly depending file. For the data directory I changed every occurrence of /radios/ with /instrumentation/ with this simple one-liner that I found on the net: find -name '*.xml' -type f | xargs perl -pi -e 's/\/radios\//\/instrumentation\//g' Instead of me sending all the files that got changed by this I suggest that you execute the one-liner yourself. Of course I can not guarantee that this will work perfectly, but I considered hand editing to be not an option (I'm lazy). I don't want to test every aircraft to see if everything still works, I think it's better to wait and see if anyone complaints about broken nav radios/instruments. --- src/ATC/AIPlane.cxx | 6 +- src/ATC/ATC.cxx | 2 +- src/ATC/ATCmgr.cxx | 4 +- src/ATC/approach.cxx | 4 +- src/Cockpit/Makefile.am | 3 +- src/Cockpit/radiostack.cxx | 131 ------------------------------- src/Cockpit/radiostack.hxx | 75 ------------------ src/Instrumentation/navradio.cxx | 20 ++++- src/Instrumentation/navradio.hxx | 7 +- src/Main/fg_init.cxx | 11 +-- src/Main/main.cxx | 5 +- src/Main/renderer.cxx | 1 - src/Network/ATC-Inputs.cxx | 23 +----- src/Network/ATC-Inputs.hxx | 4 - src/Network/atlas.cxx | 16 ++-- src/Network/native_gui.cxx | 38 ++++++--- src/Network/opengc.cxx | 1 - 17 files changed, 76 insertions(+), 275 deletions(-) delete mode 100644 src/Cockpit/radiostack.cxx delete mode 100644 src/Cockpit/radiostack.hxx diff --git a/src/ATC/AIPlane.cxx b/src/ATC/AIPlane.cxx index 97789d7d2..6191558b4 100644 --- a/src/ATC/AIPlane.cxx +++ b/src/ATC/AIPlane.cxx @@ -90,8 +90,8 @@ void FGAIPlane::Update(double dt) { // TODO - turn it off if user switches to another freq - keep track of where in message we are etc. if(_transmit) { //cout << "transmit\n"; - double user_freq0 = fgGetDouble("/radios/comm[0]/frequencies/selected-mhz"); - double user_freq1 = fgGetDouble("/radios/comm[1]/frequencies/selected-mhz"); + double user_freq0 = fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz"); + double user_freq1 = fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz"); _counter = 0.0; _max_count = 5.0; // FIXME - hardwired length of message - need to calculate it! @@ -191,7 +191,7 @@ void FGAIPlane::Render(string refname, bool repeating) { SGSoundSample* simple = new SGSoundSample(buf, len, 8000, false); // TODO - at the moment the volume is always set off comm1 // and can't be changed after the transmission has started. - simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume")); + simple->set_volume(5.0 * fgGetDouble("/instrumentation/comm[0]/volume")); globals->get_soundmgr()->add(simple, refname); if(repeating) { globals->get_soundmgr()->play_looped(refname); diff --git a/src/ATC/ATC.cxx b/src/ATC/ATC.cxx index 955cb8195..f6ee03ae4 100644 --- a/src/ATC/ATC.cxx +++ b/src/ATC/ATC.cxx @@ -230,7 +230,7 @@ void FGATC::Render(string msg, string refname, bool repeating) { = new SGSoundSample(buf, len, 8000, false); // TODO - at the moment the volume is always set off comm1 // and can't be changed after the transmission has started. - simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume")); + simple->set_volume(5.0 * fgGetDouble("/instrumentation/comm[0]/volume")); globals->get_soundmgr()->add(simple, refname); if(repeating) { globals->get_soundmgr()->play_looped(refname); diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx index 6f8b911aa..e4a5407c5 100644 --- a/src/ATC/ATCmgr.cxx +++ b/src/ATC/ATCmgr.cxx @@ -86,8 +86,8 @@ void FGATCMgr::unbind() { void FGATCMgr::init() { //cout << "ATCMgr::init called..." << endl; - comm_node[0] = fgGetNode("/radios/comm[0]/frequencies/selected-mhz", true); - comm_node[1] = fgGetNode("/radios/comm[1]/frequencies/selected-mhz", true); + comm_node[0] = fgGetNode("/instrumentation/comm[0]/frequencies/selected-mhz", true); + comm_node[1] = fgGetNode("/instrumentation/comm[1]/frequencies/selected-mhz", true); lon_node = fgGetNode("/position/longitude-deg", true); lat_node = fgGetNode("/position/latitude-deg", true); elev_node = fgGetNode("/position/altitude-ft", true); diff --git a/src/ATC/approach.cxx b/src/ATC/approach.cxx index f8901029d..ec68db500 100644 --- a/src/ATC/approach.cxx +++ b/src/ATC/approach.cxx @@ -36,8 +36,8 @@ //Constructor FGApproach::FGApproach(){ - comm1_node = fgGetNode("/radios/comm[0]/frequencies/selected-mhz", true); - comm2_node = fgGetNode("/radios/comm[1]/frequencies/selected-mhz", true); + comm1_node = fgGetNode("/instrumentation/comm[0]/frequencies/selected-mhz", true); + comm2_node = fgGetNode("/instrumentation/comm[1]/frequencies/selected-mhz", true); _type = APPROACH; diff --git a/src/Cockpit/Makefile.am b/src/Cockpit/Makefile.am index 74d3bce80..c79daf8f4 100644 --- a/src/Cockpit/Makefile.am +++ b/src/Cockpit/Makefile.am @@ -10,8 +10,7 @@ libCockpit_a_SOURCES = \ hud_scal.cxx hud_tbi.cxx \ navcom.cxx navcom.hxx \ panel.cxx panel.hxx \ - panel_io.cxx panel_io.hxx \ - radiostack.cxx radiostack.hxx + panel_io.cxx panel_io.hxx INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx deleted file mode 100644 index 09986f096..000000000 --- a/src/Cockpit/radiostack.cxx +++ /dev/null @@ -1,131 +0,0 @@ -// radiostack.cxx -- class to manage an instance of the radio stack -// -// Written by Curtis Olson, started April 2000. -// -// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt -// -// 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$ - - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include // snprintf - -#include -#include - -#include -#include - -#include "radiostack.hxx" - -#include -SG_USING_STD(string); - - -FGRadioStack *current_radiostack; - - -// Constructor -FGRadioStack::FGRadioStack() { -} - - -// Destructor -FGRadioStack::~FGRadioStack() -{ - //adf.unbind(); - //beacon.unbind(); - navcom1.unbind(); - navcom2.unbind(); - //xponder.unbind(); -} - - -void -FGRadioStack::init () -{ - navcom1.set_bind_index( 0 ); - navcom1.init(); - - navcom2.set_bind_index( 1 ); - navcom2.init(); - - //adf.init(); - //beacon.init(); - //xponder.init(); - - search(); - update(0); // FIXME: use dt - - // Search radio database once per second - globals->get_event_mgr()->addTask( "fgRadioSearch()", current_radiostack, - &FGRadioStack::search, 1 ); -} - - -void -FGRadioStack::bind () -{ - //adf.bind(); - //beacon.bind(); - //dme.bind(); - navcom1.set_bind_index( 0 ); - navcom1.bind(); - navcom2.set_bind_index( 1 ); - navcom2.bind(); - //xponder.bind(); -} - - -void -FGRadioStack::unbind () -{ - //adf.unbind(); - //beacon.unbind(); - //dme.unbind(); - navcom1.unbind(); - navcom2.unbind(); - //xponder.unbind(); -} - - -// Update the various nav values based on position and valid tuned in navs -void -FGRadioStack::update(double dt) -{ - //adf.update( dt ); - //beacon.update( dt ); - navcom1.update( dt ); - navcom2.update( dt ); - //dme.update( dt ); // dme is updated after the navcom's - //xponder.update( dt ); -} - - -// Update current nav/adf radio stations based on current postition -void FGRadioStack::search() -{ - //adf.search(); - //beacon.search(); - navcom1.search(); - navcom2.search(); - //dme.search(); - //xponder.search(); -} diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx deleted file mode 100644 index fb6e87586..000000000 --- a/src/Cockpit/radiostack.hxx +++ /dev/null @@ -1,75 +0,0 @@ -// radiostack.hxx -- class to manage an instance of the radio stack -// -// Written by Curtis Olson, started April 2000. -// -// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt -// -// 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_RADIOSTACK_HXX -#define _FG_RADIOSTACK_HXX - - -#include
- -#include -#include -#include -#include - -#include -#include -#include - -//#include "dme.hxx" -//#include "kt_70.hxx" // Transponder -//#include "marker_beacon.hxx" -#include "navcom.hxx" - - -class FGRadioStack : public SGSubsystem -{ - //FGDME dme; - //FGKR_87 adf; // King KR 87 Digital ADF model - //FGKT_70 xponder; // Bendix/King KT 70 Panel-Mounted Transponder - //FGMarkerBeacon beacon; - FGNavCom navcom1; - FGNavCom navcom2; - -public: - - FGRadioStack(); - ~FGRadioStack(); - - void init (); - void bind (); - void unbind (); - void update (double dt); - - // Update nav/adf radios based on current postition - void search (); - - //inline FGDME *get_dme() { return &dme; } - inline FGNavCom *get_navcom1() { return &navcom1; } - inline FGNavCom *get_navcom2() { return &navcom2; } -}; - - -extern FGRadioStack *current_radiostack; - -#endif // _FG_RADIOSTACK_HXX diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 6d00f42b2..414595cd8 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -128,9 +128,15 @@ FGNavRadio::init () cdi_serviceable = (node->getChild("cdi", 0, true)) ->getChild("serviceable", 0, true); gs_serviceable = (node->getChild("gs", 0, true)) - ->getNode("serviceable"); + ->getChild("serviceable"); tofrom_serviceable = (node->getChild("to-from", 0, true)) ->getChild("serviceable", 0, true); + + std::ostringstream temp; + temp << name << "nav-ident" << num; + nav_fx_name = temp.str(); + temp << name << "dme-ident" << num; + dme_fx_name = temp.str(); } void @@ -176,6 +182,12 @@ FGNavRadio::bind () fgTie( (branch + "/radials/target-radial-deg").c_str(), this, &FGNavRadio::get_nav_target_radial_true ); + fgTie( (branch + "/radials/reciprocal-radial-deg").c_str(), + this, &FGNavRadio::get_nav_reciprocal_radial ); + + fgTie( (branch + "/radials/target-radial2-deg").c_str(), + this, &FGNavRadio::get_nav_target_radial ); + fgTie( (branch + "/radials/target-auto-hdg-deg").c_str(), this, &FGNavRadio::get_nav_target_auto_hdg ); @@ -206,6 +218,12 @@ FGNavRadio::bind () fgTie( (branch + "/gs-needle-deflection").c_str(), this, &FGNavRadio::get_nav_gs_deflection ); + fgTie( (branch + "/gs-distance").c_str(), + this, &FGNavRadio::get_nav_gs_dist_signed ); + + fgTie( (branch + "/nav-distance").c_str(), + this, &FGNavRadio::get_nav_loc_dist ); + fgTie( (branch + "/nav-id").c_str(), this, &FGNavRadio::get_nav_id ); diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 24ca32a6d..b75c5aa15 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -56,8 +56,8 @@ class FGNavRadio : public SGSubsystem time_t nav_last_time; int index; // used for property binding - char nav_fx_name[256]; - char dme_fx_name[256]; + string nav_fx_name; + string dme_fx_name; bool need_update; @@ -136,12 +136,13 @@ public: // Update nav/adf radios based on current postition void search (); - +/* inline void set_bind_index( int i ) { index = i; sprintf( nav_fx_name, "nav%d-vor-ident", index ); sprintf( dme_fx_name, "dme%d-vor-ident", index ); } +*/ // NavCom Setters inline void set_power_btn( bool val ) { power_btn = val; } diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 791a141e6..7d29df4d2 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -79,7 +79,6 @@ #include #include #include -#include #include #include #ifdef ENABLE_SP_FMDS @@ -109,6 +108,8 @@ #include #include #include +#include +#include #include #include