1
0
Fork 0

Merge branch 'next' of gitorious.org:fg/flightgear into next

This commit is contained in:
Durk Talsma 2011-10-09 23:46:52 +02:00
commit 894f066370
14 changed files with 212 additions and 91 deletions

View file

@ -31,7 +31,6 @@
#include <simgear/structure/exception.hxx>
#include <Main/fg_props.hxx>
#include <FDM/fdm_shell.hxx>
#include "replay.hxx"
#include "flightrecorder.hxx"
@ -235,43 +234,52 @@ FGReplay::update( double dt )
if ( disable_replay->getBoolValue() )
{
current_replay_state = replay_master->getIntValue();
replay_master->setIntValue(0);
replay_time->setDoubleValue(0);
replay_time_str->setStringValue("");
disable_replay->setBoolValue(0);
speed_up->setDoubleValue(1.0);
fgSetString("/sim/messages/copilot", "Replay stopped");
if (fgGetBool("/sim/freeze/master",false)||
fgGetBool("/sim/freeze/clock",false))
{
fgSetBool("/sim/freeze/master",false);
fgSetBool("/sim/freeze/clock",false);
last_replay_state = 1;
}
else
if ((replay_master->getIntValue() != 3)||
(last_replay_state == 3))
{
current_replay_state = replay_master->getIntValue();
replay_master->setIntValue(0);
replay_time->setDoubleValue(0);
replay_time_str->setStringValue("");
disable_replay->setBoolValue(0);
speed_up->setDoubleValue(1.0);
speed_up->setDoubleValue(1.0);
if (fgGetBool("/sim/replay/mute",false))
{
fgSetBool("/sim/sound/enabled",true);
fgSetBool("/sim/replay/mute",false);
}
fgSetString("/sim/messages/copilot", "Replay stopped. Your controls!");
}
}
int replay_state = replay_master->getIntValue();
if ((replay_state > 0)&&
(last_replay_state == 0))
{
// replay is starting, suspend FDM
/* FIXME we need to suspend/resume the FDM - not the entire FDM shell.
* FDM isn't available via the global subsystem manager yet, so need a
* method at the FDMshell for now */
((FDMShell*) globals->get_subsystem("flight"))->getFDM()->suspend();
}
else
if ((replay_state == 0)&&
(last_replay_state > 0))
{
if (current_replay_state == 3)
{
// "my controls!" requested: pilot takes control at current replay position...
// take control at current replay position ("My controls!").
// May need to uncrash the aircraft here :)
fgSetBool("/sim/crashed", false);
}
else
{
// replay was active, restore most recent frame
// normal replay exit, restore most recent frame
replay(DBL_MAX);
}
// replay is finished, resume FDM
((FDMShell*) globals->get_subsystem("flight"))->getFDM()->resume();
// replay is finished
last_replay_state = replay_state;
return;
}
// remember recent state
@ -282,7 +290,8 @@ FGReplay::update( double dt )
case 0:
// replay inactive, keep recording
break;
case 1:
case 1: // normal replay
case 3: // prepare to resume normal flight at current replay position
{
// replay active
double current_time = replay_time->getDoubleValue();
@ -312,8 +321,6 @@ FGReplay::update( double dt )
return; // don't record the replay session
}
case 2: // normal replay operation
case 3: // replay operation, prepare to resume normal flight at current replay position
// replay paused, no-op
return; // don't record the replay session
default:
throw sg_range_exception("unknown FGReplay state");

View file

@ -284,16 +284,20 @@ void Gear::calcForce(RigidBody* body, State *s, float* v, float* rot)
// Don't bother if it's not down
if(_extension < 1)
return;
{
_wow = 0;
_frac = 0;
return;
}
// Dont bother if we are in the "wrong" ground
if (!((_onWater&&!_ground_isSolid)||(_onSolid&&_ground_isSolid))) {
_wow = 0;
_frac = 0;
_wow = 0;
_frac = 0;
_compressDist = 0;
_rollSpeed = 0;
_casterAngle = 0;
return;
return;
}
// The ground plane transformed to the local frame.

View file

@ -195,9 +195,10 @@ void YASim::update(double dt)
int iterations = _calc_multiloop(dt);
// If we're crashed, then we don't care
if(_fdm->getAirplane()->getModel()->isCrashed()) {
if(fgGetBool("/sim/crashed") || _fdm->getAirplane()->getModel()->isCrashed()) {
if(!fgGetBool("/sim/crashed"))
fgSetBool("/sim/crashed", true);
_fdm->getAirplane()->getModel()->setCrashed(false);
return;
}
@ -311,7 +312,7 @@ void YASim::copyToYASim(bool copyState)
Math::set3(v, s.v);
if(copyState || needCopy)
model->setState(&s);
model->setState(&s);
// wind
Math::tmul33(xyz2ned, wind, wind);
@ -505,3 +506,19 @@ void YASim::copyFromYASim()
}
}
/** Reinit the FDM.
* This is only used after a replay session and when the user requested to resume at
* a past point of time. In thise case the FDM must reload all values from the property
* tree (as given by the replay system). */
void YASim::reinit()
{
// Process inputs. Use excessive value for dt to make sure all transition effects
// have reached their final state (i.e. gear is extended/retracted) - which is vital
// for many properties to be complete before the first FDM run (otherwise the gear may
// still be up, thrust-reversers/speed-brakes/... may still be partially deployed...).
_fdm->getExternalInput(1000);
// get current FDM values from the property tree
copyToYASim(true);
}

View file

@ -13,6 +13,7 @@ public:
// Load externally set stuff into the FDM
virtual void init();
virtual void bind();
virtual void reinit();
// Run an iteration
virtual void update(double dt);

View file

@ -72,6 +72,17 @@ void FDMShell::init()
{
_props = globals->get_props();
fgSetBool("/sim/fdm-initialized", false);
_wind_north = _props->getNode("environment/wind-from-north-fps", true);
_wind_east = _props->getNode("environment/wind-from-east-fps", true);
_wind_down = _props->getNode("environment/wind-from-down-fps", true);
_control_fdm_atmo = _props->getNode("environment/params/control-fdm-atmosphere", true);
_temp_degc = _props->getNode("environment/temperature-degc", true);
_pressure_inhg = _props->getNode("environment/pressure-inhg", true);
_density_slugft = _props->getNode("environment/density-slugft3", true);
_data_logging = _props->getNode("/sim/temp/fdm-data-logging", true);
_replay_master = _props->getNode("/sim/freeze/replay-state", true);
createImplementation();
}
@ -138,30 +149,42 @@ void FDMShell::update(double dt)
// pull environmental data in, since the FDMs are lazy
_impl->set_Velocities_Local_Airmass(
_props->getDoubleValue("environment/wind-from-north-fps", 0.0),
_props->getDoubleValue("environment/wind-from-east-fps", 0.0),
_props->getDoubleValue("environment/wind-from-down-fps", 0.0));
_wind_north->getDoubleValue(),
_wind_east->getDoubleValue(),
_wind_down->getDoubleValue());
if (_props->getBoolValue("environment/params/control-fdm-atmosphere")) {
if (_control_fdm_atmo->getBoolValue()) {
// convert from Rankine to Celsius
double tempDegC = _props->getDoubleValue("environment/temperature-degc");
double tempDegC = _temp_degc->getDoubleValue();
_impl->set_Static_temperature((9.0/5.0) * (tempDegC + 273.15));
// convert from inHG to PSF
double pressureInHg = _props->getDoubleValue("environment/pressure-inhg");
double pressureInHg = _pressure_inhg->getDoubleValue();
_impl->set_Static_pressure(pressureInHg * 70.726566);
// keep in slugs/ft^3
_impl->set_Density(_props->getDoubleValue("environment/density-slugft3"));
_impl->set_Density(_density_slugft->getDoubleValue());
}
bool doLog = _props->getBoolValue("/sim/temp/fdm-data-logging", false);
bool doLog = _data_logging->getBoolValue();
if (doLog != _dataLogging) {
_dataLogging = doLog;
_impl->ToggleDataLogging(doLog);
}
if (!_impl->is_suspended())
_impl->update(dt);
switch(_replay_master->getIntValue())
{
case 0:
// normal FDM operation
_impl->update(dt);
break;
case 3:
// resume FDM operation at current replay position
_impl->reinit();
break;
default:
// replay is active
break;
}
}
void FDMShell::createImplementation()
@ -251,14 +274,3 @@ void FDMShell::createImplementation()
}
}
/*
* Return FDM subsystem.
*/
SGSubsystem* FDMShell::getFDM()
{
/* FIXME we could drop/replace this method, when _impl was a added
* to the global subsystem manager - like other proper subsystems... */
return _impl;
}

View file

@ -41,7 +41,7 @@ class FDMShell : public SGSubsystem
{
public:
FDMShell();
~FDMShell();
virtual ~FDMShell();
virtual void init();
virtual void reinit();
@ -50,7 +50,6 @@ public:
virtual void unbind();
virtual void update(double dt);
SGSubsystem* getFDM();
private:
@ -58,8 +57,12 @@ private:
TankPropertiesList _tankProperties;
FGInterface* _impl;
SGPropertyNode* _props; // root property tree for this FDM instance
SGPropertyNode_ptr _props; // root property tree for this FDM instance
bool _dataLogging;
SGPropertyNode_ptr _wind_north, _wind_east,_wind_down;
SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg;
SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master;
};
#endif // of FG_FDM_SHELL_HXX

View file

@ -42,6 +42,7 @@ class GraphicsContext;
// gui.cxx
extern void guiStartInit(osg::GraphicsContext*);
extern bool guiFinishInit();
extern bool openBrowser(string address);
extern void mkDialog(const char *txt);
extern void guiErrorMessage(const char *txt);
extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);

View file

@ -156,46 +156,60 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable)
the Gui callback functions
____________________________________________________________________*/
// Hier Neu :-) This is my newly added code
// Added by David Findlay <nedz@bigpond.com>
// on Sunday 3rd of December
void helpCb ()
void helpCb()
{
string command;
SGPath path( globals->get_fg_root() );
path.append( "Docs/index.html" );
openBrowser( "Docs/index.html" );
}
bool openBrowser(string address)
{
bool ok = true;
// do not resolve addresses with given protocol, i.e. "http://...", "ftp://..."
if (address.find("://")==string::npos)
{
// resolve local file path
SGPath path(address);
path = globals->resolve_maybe_aircraft_path(address);
if (!path.isNull())
address = path.str();
else
{
mkDialog ("Sorry, file not found!");
SG_LOG(SG_GENERAL, SG_ALERT, "openBrowser: Cannot find requested file '"
<< address << "'.");
return false;
}
}
#ifndef _WIN32
command = globals->get_browser();
string command = globals->get_browser();
string::size_type pos;
if ((pos = command.find("%u", 0)) != string::npos)
command.replace(pos, 2, path.str());
command.replace(pos, 2, address);
else
command += " " + path.str();
command += " " + address;
command += " &";
system( command.c_str() );
ok = (system( command.c_str() ) == 0);
#else // _WIN32
// Look for favorite browser
char win32_name[1024];
# ifdef __CYGWIN__
cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
cygwin32_conv_to_full_win32_path(address.c_str(),win32_name);
# else
strncpy(win32_name,path.c_str(), 1024);
strncpy(win32_name,address.c_str(), 1024);
# endif
ShellExecute ( NULL, "open", win32_name, NULL, NULL,
SW_SHOWNORMAL ) ;
#endif
mkDialog ("Help started in your web browser window.");
mkDialog("The file is shown in your web browser window.");
return ok;
}
#if defined( TR_HIRES_SNAP)

View file

@ -37,14 +37,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
}
#endif // TR_HIRES_SNAP
extern void helpCb ();
static bool
do_help_dialog (const SGPropertyNode * arg)
{
helpCb();
return true;
}
static struct {
const char * name;
SGCommandMgr::command_t command;
@ -52,7 +44,6 @@ static struct {
#if defined(TR_HIRES_SNAP)
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
#endif
{ "old-help-dialog", do_help_dialog },
{ 0, 0 }
};

View file

@ -119,8 +119,17 @@ DME::update (double delta_time_sec)
if (_time_before_search_sec < 0) {
_time_before_search_sec = 1.0;
_navrecord = globals->get_dmelist()->findByFreq( frequency_mhz,
globals->get_aircraft_position());
if( fgGetBool( "/sim/realism/dme-fallback-to-loc", true ) ) {
if( NULL == (_navrecord = globals->get_loclist()->findByFreq( frequency_mhz,
globals->get_aircraft_position())) ) {
_navrecord = globals->get_dmelist()->findByFreq( frequency_mhz,
globals->get_aircraft_position());
}
} else {
_navrecord = globals->get_dmelist()->findByFreq( frequency_mhz,
globals->get_aircraft_position());
}
}
// If it's off, don't bother.

View file

@ -3,7 +3,7 @@
// Written by Curtis Olson, started April 2000.
// Rewritten by Torsten Dreyer, August 2011
//
// Copyright (C) 2000 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
// Copyright (C) 2000 - 2011 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
@ -33,6 +33,7 @@
#include <simgear/math/interpolater.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/props/propertyObject.hxx>
#include <simgear/misc/strutils.hxx>
#include <Main/fg_props.hxx>
#include <Navaids/navlist.hxx>
@ -144,6 +145,7 @@ public:
virtual double getRange_nm( const SGGeod & aircraftPosition );
virtual void display( NavIndicator & navIndicator ) = 0;
virtual bool valid() const { return NULL != _navRecord && true == _serviceable; }
virtual const std::string getIdent() const { return _ident; }
protected:
virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition );
@ -220,7 +222,7 @@ void NavRadioComponentWithIdent::update( double dt, const SGGeod & aircraftPosit
_audioIdent->setIdent("", 0.0 );
return;
}
_audioIdent->setIdent( _navRecord->get_trans_ident(), SGMiscd::clip(_identVolume, 0.0, 1.0) );
_audioIdent->setIdent( _ident, SGMiscd::clip(_identVolume, 0.0, 1.0) );
}
NavRadioComponent::NavRadioComponent( const std::string & name, SGPropertyNode_ptr rootNode ) :
@ -851,6 +853,11 @@ private:
NavRadioImpl * _navRadioImpl;
SGPropertyNode_ptr is_valid_node;
SGPropertyNode_ptr nav_serviceable_node;
SGPropertyNode_ptr nav_id_node;
SGPropertyNode_ptr id_c1_node;
SGPropertyNode_ptr id_c2_node;
SGPropertyNode_ptr id_c3_node;
SGPropertyNode_ptr id_c4_node;
} _legacy;
const static int VOR_COMPONENT = 0;
@ -937,7 +944,7 @@ void NavRadioImpl::update( double dt )
if( _stationTTL <= 0.0 )
_stationTTL = 30.0;
_legacy.init();
_legacy.update( dt );
}
void NavRadioImpl::Legacy::init()
@ -945,6 +952,12 @@ void NavRadioImpl::Legacy::init()
is_valid_node = _navRadioImpl->_rootNode->getChild("data-is-valid", 0, true);
nav_serviceable_node = _navRadioImpl->_rootNode->getChild("serviceable", 0, true);
nav_id_node = _navRadioImpl->_rootNode->getChild("nav-id", 0, true );
id_c1_node = _navRadioImpl->_rootNode->getChild("nav-id_asc1", 0, true );
id_c2_node = _navRadioImpl->_rootNode->getChild("nav-id_asc2", 0, true );
id_c3_node = _navRadioImpl->_rootNode->getChild("nav-id_asc3", 0, true );
id_c4_node = _navRadioImpl->_rootNode->getChild("nav-id_asc4", 0, true );
}
void NavRadioImpl::Legacy::update( double dt )
@ -952,6 +965,18 @@ void NavRadioImpl::Legacy::update( double dt )
is_valid_node->setBoolValue(
_navRadioImpl->_components[VOR_COMPONENT]->valid() || _navRadioImpl->_components[LOC_COMPONENT]->valid()
);
string ident = _navRadioImpl->_components[VOR_COMPONENT]->getIdent();
if( ident.empty() )
ident = _navRadioImpl->_components[LOC_COMPONENT]->getIdent();
nav_id_node->setStringValue( ident );
ident = simgear::strutils::rpad( ident, 4, ' ' );
id_c1_node->setIntValue( (int)ident[0] );
id_c2_node->setIntValue( (int)ident[1] );
id_c3_node->setIntValue( (int)ident[2] );
id_c4_node->setIntValue( (int)ident[3] );
}

View file

@ -1,3 +1,23 @@
// navradio.hxx -- class to manage a nav radio instance
//
// Written by Torsten Dreyer, started August 2011
//
// Copyright (C) 2000 - 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef _FG_INSTRUMENTATION_NAVRADIO_HXX

View file

@ -215,11 +215,13 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
button = 3;
else if (ea.getScrollingDeltaY() < 0)
button = 4;
else
button = -1;
} else if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP)
button = 3;
else
button = 4;
if (mouseClickHandler) {
if (mouseClickHandler && button != -1) {
(*mouseClickHandler)(button, 0, x, y, mainWindow, &ea);
(*mouseClickHandler)(button, 1, x, y, mainWindow, &ea);
}

View file

@ -1040,6 +1040,20 @@ do_dialog_update (const SGPropertyNode * arg)
}
}
static bool
do_open_browser (const SGPropertyNode * arg)
{
string path;
if (arg->hasValue("path"))
path = arg->getStringValue("path");
else
if (arg->hasValue("url"))
path = arg->getStringValue("url");
else
return false;
return openBrowser(path);
}
/**
* Apply a value in the active XML-configured dialog.
@ -1468,6 +1482,7 @@ static struct {
{ "dialog-close", do_dialog_close },
{ "dialog-update", do_dialog_update },
{ "dialog-apply", do_dialog_apply },
{ "open-browser", do_open_browser },
{ "gui-redraw", do_gui_redraw },
{ "add-model", do_add_model },
{ "set-cursor", do_set_cursor },