1
0
Fork 0

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.
This commit is contained in:
curt 2004-12-03 21:21:16 +00:00
parent 8ba9f4e3a4
commit 634e79353f
17 changed files with 76 additions and 275 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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 <config.h>
#endif
#include <stdio.h> // snprintf
#include <simgear/compiler.h>
#include <simgear/math/sg_random.h>
#include <Aircraft/aircraft.hxx>
#include <Navaids/navlist.hxx>
#include "radiostack.hxx"
#include <string>
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();
}

View file

@ -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 <Main/fg_props.hxx>
#include <simgear/compiler.h>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Navaids/navlist.hxx>
#include <Sound/beacon.hxx>
#include <Sound/morse.hxx>
//#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

View file

@ -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 );

View file

@ -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; }

View file

@ -79,7 +79,6 @@
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/xmlauto.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
#ifdef ENABLE_SP_FMDS
@ -109,6 +108,8 @@
#include <Scenery/tilemgr.hxx>
#include <Scripting/NasalSys.hxx>
#include <Sound/fg_fx.hxx>
#include <Sound/beacon.hxx>
#include <Sound/morse.hxx>
#include <Systems/system_mgr.hxx>
#include <Time/light.hxx>
#include <Time/moonpos.hxx>
@ -1714,14 +1715,6 @@ bool fgInitSubsystems() {
////////////////////////////////////////////////////////////////////
// Initialize the radio stack subsystem.
////////////////////////////////////////////////////////////////////
current_radiostack = new FGRadioStack;
current_radiostack->init();
current_radiostack->bind();
////////////////////////////////////////////////////////////////////
// Initialize the cockpit subsystem
////////////////////////////////////////////////////////////////////

View file

@ -59,13 +59,14 @@
#include <Include/general.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/hud.hxx>
#include <Model/panelnode.hxx>
#include <Model/modelmgr.hxx>
#include <Model/acmodel.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Sound/beacon.hxx>
#include <Sound/morse.hxx>
#include <FDM/flight.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
// #include <FDM/ADA.hxx>
@ -184,8 +185,6 @@ void fgUpdateTimeDepCalcs() {
globals->get_time_params()->getLst(),
cur_fdm_state->get_Latitude() );
// Update radio stack model
current_radiostack->update(delta_time_sec);
}

View file

@ -60,7 +60,6 @@
#include <Aircraft/aircraft.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/hud.hxx>
#include <Model/panelnode.hxx>
#include <Model/modelmgr.hxx>

View file

@ -136,9 +136,8 @@ bool FGATCInput::open() {
init_config();
SG_LOG( SG_IO, SG_ALERT,
"Initializing ATC 610x hardware, please wait ..." );
"Initializing ATC hardware, please wait ..." );
snprintf( lock_file, 256, "/proc/atc610x/board%d/lock", board );
snprintf( analog_in_file, 256, "/proc/atc610x/board%d/analog_in", board );
snprintf( radios_file, 256, "/proc/atc610x/board%d/radios", board );
snprintf( switches_file, 256, "/proc/atc610x/board%d/switches", board );
@ -149,15 +148,6 @@ bool FGATCInput::open() {
// Open the /proc files
/////////////////////////////////////////////////////////////////////
lock_fd = ::open( lock_file, O_RDWR );
if ( lock_fd == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
char msg[256];
snprintf( msg, 256, "Error opening %s", lock_file );
perror( msg );
exit( -1 );
}
analog_in_fd = ::open( analog_in_file, O_RDONLY );
if ( analog_in_fd == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
@ -192,7 +182,7 @@ bool FGATCInput::open() {
/////////////////////////////////////////////////////////////////////
SG_LOG( SG_IO, SG_ALERT,
"Done initializing ATC 610x hardware." );
"Done initializing ATC hardware." );
is_open = true;
@ -871,15 +861,6 @@ bool FGATCInput::close() {
int result;
result = ::close( lock_fd );
if ( result == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
char msg[256];
snprintf( msg, 256, "Error closing %s", lock_file );
perror( msg );
exit( -1 );
}
result = ::close( analog_in_fd );
if ( result == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );

View file

@ -44,16 +44,12 @@ class FGATCInput {
int board;
SGPath config;
int lock_fd;
int analog_in_fd;
int radios_fd;
int switches_fd;
char lock_file[256];
char analog_in_file[256];
char lamps_file[256];
char radios_file[256];
char stepper_file[256];
char switches_file[256];
unsigned char analog_in_bytes[ATC_ANAL_IN_BYTES];

View file

@ -25,9 +25,11 @@
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/io/iochannel.hxx>
#include <Cockpit/radiostack.hxx>
#include <FDM/flight.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/fg_init.hxx>
#include "atlas.hxx"
@ -65,6 +67,10 @@ bool FGAtlas::gen_message() {
static SGPropertyNode *adf_freq
= fgGetNode("/instrumentation/kr-87/outputs/selected-khz", true);
static SGPropertyNode *nav_freq
= fgGetNode("/instrumentation/nav/frequencies/selected-mhz", false);
static SGPropertyNode *nav_sel_radial
= fgGetNode("/instrumentation/van/radials/selected-deg", false);
char rmc[256], gga[256], patla[256];
char rmc_sum[10], gga_sum[10], patla_sum[10];
@ -129,10 +135,10 @@ bool FGAtlas::gen_message() {
sprintf( gga_sum, "%02X", calc_atlas_cksum(gga) );
sprintf( patla, "PATLA,%.2f,%.1f,%.2f,%.1f,%.0f",
current_radiostack->get_navcom1()->get_nav_freq(),
current_radiostack->get_navcom1()->get_nav_sel_radial(),
current_radiostack->get_navcom1()->get_nav_freq(),
current_radiostack->get_navcom1()->get_nav_sel_radial(),
nav_freq->getDoubleValue(),
nav_sel_radial->getDoubleValue(),
nav_freq->getDoubleValue(),
nav_sel_radial->getDoubleValue(),
adf_freq->getDoubleValue() );
sprintf( patla_sum, "%02X", calc_atlas_cksum(patla) );

View file

@ -30,7 +30,6 @@
#include <simgear/io/iochannel.hxx>
#include <simgear/timing/sg_time.hxx>
#include <Cockpit/radiostack.hxx>
#include <FDM/flight.hxx>
#include <Time/tmp.hxx>
#include <Main/fg_props.hxx>
@ -121,6 +120,22 @@ bool FGNativeGUI::open() {
void FGProps2NetGUI( FGNetGUI *net ) {
static SGPropertyNode *nav_freq
= fgGetNode("/instrumentation/nav/frequencies/selected-mhz", false);
static SGPropertyNode *nav_target_radial
= fgGetNode("/instrumentation/nav/radials/target-radial2-deg", false);
static SGPropertyNode *nav_inrange
= fgGetNode("instrumentation/nav/in-range", false);
static SGPropertyNode *nav_loc
= fgGetNode("instrumentation/nav/nav-loc", false);
static SGPropertyNode *nav_gs_dist_signed
= fgGetNode("instrumentation/nav/gs-distance", false);
static SGPropertyNode *nav_loc_dist
= fgGetNode("instrumentation/nav/nav-distance", false);
static SGPropertyNode *nav_reciprocal_radial
= fgGetNode("instrumentation/nav/reciprocal-radial-deg", false);
static SGPropertyNode *nav_gs_deflection
= fgGetNode("instrumentation/nav/gs-needle-deflection", false);
int i;
// Version sanity checking
@ -151,24 +166,25 @@ void FGProps2NetGUI( FGNetGUI *net ) {
net->ground_elev = globals->get_scenery()->get_cur_elev();
// Approach
net->tuned_freq = current_radiostack->get_navcom1()->get_nav_freq();
net->nav_radial = current_radiostack->get_navcom1()->get_nav_target_radial();
net->in_range = current_radiostack->get_navcom1()->get_nav_inrange();
net->tuned_freq = nav_freq->getDoubleValue();
net->nav_radial = nav_target_radial->getDoubleValue();
net->in_range = nav_inrange->getBoolValue();
if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
if ( nav_loc->getBoolValue() ) {
// is an ILS
net->dist_nm
= current_radiostack->get_navcom1()->get_nav_gs_dist_signed()
= nav_gs_dist_signed->getDoubleValue()
* SG_METER_TO_NM;
} else {
// is a VOR
net->dist_nm = current_radiostack->get_navcom1()->get_nav_loc_dist()
net->dist_nm = nav_loc_dist->getDoubleValue()
* SG_METER_TO_NM;
}
net->course_deviation_deg
= current_radiostack->get_navcom1()->get_nav_reciprocal_radial()
- current_radiostack->get_navcom1()->get_nav_target_radial();
= nav_reciprocal_radial->getDoubleValue()
- nav_target_radial->getDoubleValue();
if ( net->course_deviation_deg < -1000.0
|| net->course_deviation_deg > 1000.0 )
{
@ -187,10 +203,10 @@ void FGProps2NetGUI( FGNetGUI *net ) {
? -net->course_deviation_deg - 180.0
: -net->course_deviation_deg + 180.0 );
if ( current_radiostack->get_navcom1()->get_nav_loc() ) {
if ( nav_loc->getBoolValue() ) {
// is an ILS
net->gs_deviation_deg
= current_radiostack->get_navcom1()->get_nav_gs_deflection()
= nav_gs_deflection->getDoubleValue()
/ 5.0;
} else {
// is an ILS

View file

@ -36,7 +36,6 @@
#include "opengc.hxx"
#include <FDM/flight.hxx>
#include <Main/globals.hxx>
#include <Cockpit/radiostack.hxx>
#include <Controls/controls.hxx>
#include <Main/fg_props.hxx>