2000-04-24 23:50:59 +00:00
|
|
|
// radiostack.cxx -- class to manage an instance of the radio stack
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 2000.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000 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$
|
|
|
|
|
|
|
|
|
2001-03-21 23:16:21 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-02-05 15:57:46 +00:00
|
|
|
#include <stdio.h> // snprintf
|
|
|
|
|
2001-03-21 23:16:21 +00:00
|
|
|
#include <simgear/compiler.h>
|
2001-03-09 23:35:21 +00:00
|
|
|
#include <simgear/math/sg_random.h>
|
|
|
|
|
2000-05-04 01:18:45 +00:00
|
|
|
#include <Aircraft/aircraft.hxx>
|
2000-04-24 23:50:59 +00:00
|
|
|
#include <Navaids/navlist.hxx>
|
|
|
|
|
|
|
|
#include "radiostack.hxx"
|
|
|
|
|
2001-11-07 17:55:28 +00:00
|
|
|
#include <string>
|
|
|
|
SG_USING_STD(string);
|
|
|
|
|
2001-03-09 23:35:21 +00:00
|
|
|
|
2001-03-14 01:31:04 +00:00
|
|
|
FGRadioStack *current_radiostack;
|
|
|
|
|
|
|
|
|
2000-04-24 23:50:59 +00:00
|
|
|
// Constructor
|
2002-09-26 16:19:06 +00:00
|
|
|
FGRadioStack::FGRadioStack() {
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Destructor
|
2001-01-11 22:44:18 +00:00
|
|
|
FGRadioStack::~FGRadioStack()
|
|
|
|
{
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.unbind();
|
2002-09-26 16:19:06 +00:00
|
|
|
beacon.unbind();
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.unbind();
|
|
|
|
navcom2.unbind();
|
2002-07-04 21:37:34 +00:00
|
|
|
xponder.unbind();
|
2001-01-11 22:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FGRadioStack::init ()
|
|
|
|
{
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.set_bind_index( 0 );
|
|
|
|
navcom1.init();
|
|
|
|
|
|
|
|
navcom2.set_bind_index( 1 );
|
|
|
|
navcom2.init();
|
|
|
|
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.init();
|
2001-03-28 07:12:11 +00:00
|
|
|
beacon.init();
|
2002-09-26 16:19:06 +00:00
|
|
|
xponder.init();
|
2001-03-09 02:41:04 +00:00
|
|
|
|
2001-01-11 22:44:18 +00:00
|
|
|
search();
|
2002-05-11 16:28:50 +00:00
|
|
|
update(0); // FIXME: use dt
|
2001-01-11 22:44:18 +00:00
|
|
|
|
|
|
|
// Search radio database once per second
|
2003-11-25 21:08:36 +00:00
|
|
|
globals->get_event_mgr()->addTask( "fgRadioSearch()", current_radiostack,
|
|
|
|
&FGRadioStack::search, 1 );
|
2001-01-11 22:44:18 +00:00
|
|
|
}
|
|
|
|
|
2002-09-26 15:34:00 +00:00
|
|
|
|
2001-01-11 22:44:18 +00:00
|
|
|
void
|
|
|
|
FGRadioStack::bind ()
|
|
|
|
{
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.bind();
|
2002-09-26 16:19:06 +00:00
|
|
|
beacon.bind();
|
2002-09-26 15:34:00 +00:00
|
|
|
dme.bind();
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.set_bind_index( 0 );
|
|
|
|
navcom1.bind();
|
|
|
|
navcom2.set_bind_index( 1 );
|
|
|
|
navcom2.bind();
|
2002-07-04 21:37:34 +00:00
|
|
|
xponder.bind();
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-26 15:34:00 +00:00
|
|
|
|
2001-01-11 22:44:18 +00:00
|
|
|
void
|
|
|
|
FGRadioStack::unbind ()
|
|
|
|
{
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.unbind();
|
2002-09-26 16:19:06 +00:00
|
|
|
beacon.unbind();
|
2002-09-26 15:34:00 +00:00
|
|
|
dme.unbind();
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.unbind();
|
|
|
|
navcom2.unbind();
|
2002-07-04 21:37:34 +00:00
|
|
|
xponder.unbind();
|
2001-01-11 22:44:18 +00:00
|
|
|
}
|
2000-04-24 23:50:59 +00:00
|
|
|
|
2001-03-14 07:25:14 +00:00
|
|
|
|
2001-03-09 02:41:04 +00:00
|
|
|
// Update the various nav values based on position and valid tuned in navs
|
2001-01-11 22:44:18 +00:00
|
|
|
void
|
2002-05-11 16:28:50 +00:00
|
|
|
FGRadioStack::update(double dt)
|
2001-01-11 22:44:18 +00:00
|
|
|
{
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.update( dt );
|
2002-09-26 16:19:06 +00:00
|
|
|
beacon.update( dt );
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.update( dt );
|
|
|
|
navcom2.update( dt );
|
2002-09-26 15:34:00 +00:00
|
|
|
dme.update( dt ); // dme is updated after the navcom's
|
|
|
|
xponder.update( dt );
|
2000-05-04 01:18:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update current nav/adf radio stations based on current postition
|
2001-03-09 02:41:04 +00:00
|
|
|
void FGRadioStack::search()
|
2001-01-11 22:44:18 +00:00
|
|
|
{
|
2004-08-19 11:54:57 +00:00
|
|
|
//adf.search();
|
2002-09-26 16:19:06 +00:00
|
|
|
beacon.search();
|
2002-09-19 01:11:07 +00:00
|
|
|
navcom1.search();
|
|
|
|
navcom2.search();
|
2002-09-26 15:34:00 +00:00
|
|
|
dme.search();
|
|
|
|
xponder.search();
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|