1
0
Fork 0

Allow instruments/systems to reset on sim reset

so they can instantly adjust to the changed environment.
(Not fully working yet, since some environment settings, like environemnt
pressure/temperature, still changes slowly after a sim reset - instead of
immediately jumping to the new setting. Also, METAR sometimes arrives too
late...).
This commit is contained in:
ThorstenB 2012-09-19 20:57:52 +02:00
parent a68716316f
commit f8b689c040
4 changed files with 38 additions and 59 deletions

View file

@ -268,41 +268,72 @@ void FGEnvironment::Tie( SGPropertyNode_ptr base, bool archivable )
_tiedProperties.Tie( "visibility-m", this,
&FGEnvironment::get_visibility_m,
&FGEnvironment::set_visibility_m)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_visibility_m);
_tiedProperties.Tie("temperature-sea-level-degc", this,
&FGEnvironment::get_temperature_sea_level_degc,
&FGEnvironment::set_temperature_sea_level_degc)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_temperature_sea_level_degc);
_tiedProperties.Tie("temperature-degc", this,
&FGEnvironment::get_temperature_degc,
&FGEnvironment::set_temperature_degc)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("temperature-degf", this,
&FGEnvironment::get_temperature_degf);
&FGEnvironment::set_temperature_degc);
_tiedProperties.Tie("dewpoint-sea-level-degc", this,
&FGEnvironment::get_dewpoint_sea_level_degc,
&FGEnvironment::set_dewpoint_sea_level_degc)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_dewpoint_sea_level_degc);
_tiedProperties.Tie("dewpoint-degc", this,
&FGEnvironment::get_dewpoint_degc,
&FGEnvironment::set_dewpoint_degc)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_dewpoint_degc);
_tiedProperties.Tie("pressure-sea-level-inhg", this,
&FGEnvironment::get_pressure_sea_level_inhg,
&FGEnvironment::set_pressure_sea_level_inhg)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_pressure_sea_level_inhg);
_tiedProperties.Tie("pressure-inhg", this,
&FGEnvironment::get_pressure_inhg,
&FGEnvironment::set_pressure_inhg)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
&FGEnvironment::set_pressure_inhg);
_tiedProperties.Tie("atmosphere/altitude-half-to-sun", this,
&FGEnvironment::get_altitude_half_to_sun_m,
&FGEnvironment::set_altitude_half_to_sun_m);
_tiedProperties.Tie("atmosphere/altitude-troposphere-top", this,
&FGEnvironment::get_altitude_tropo_top_m,
&FGEnvironment::set_altitude_tropo_top_m);
_tiedProperties.Tie("wind-from-heading-deg", this,
&FGEnvironment::get_wind_from_heading_deg,
&FGEnvironment::set_wind_from_heading_deg);
_tiedProperties.Tie("wind-speed-kt", this,
&FGEnvironment::get_wind_speed_kt,
&FGEnvironment::set_wind_speed_kt);
_tiedProperties.Tie("wind-from-north-fps", this,
&FGEnvironment::get_wind_from_north_fps,
&FGEnvironment::set_wind_from_north_fps);
_tiedProperties.Tie("wind-from-east-fps", this,
&FGEnvironment::get_wind_from_east_fps,
&FGEnvironment::set_wind_from_east_fps);
_tiedProperties.Tie("wind-from-down-fps", this,
&FGEnvironment::get_wind_from_down_fps,
&FGEnvironment::set_wind_from_down_fps);
_tiedProperties.Tie("turbulence/magnitude-norm", this,
&FGEnvironment::get_turbulence_magnitude_norm,
&FGEnvironment::set_turbulence_magnitude_norm);
_tiedProperties.Tie("turbulence/rate-hz", this,
&FGEnvironment::get_turbulence_rate_hz,
&FGEnvironment::set_turbulence_rate_hz);
_tiedProperties.setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("temperature-degf", this,
&FGEnvironment::get_temperature_degf);
_tiedProperties.Tie("density-slugft3", this,
&FGEnvironment::get_density_slugft3); // read-only
@ -313,50 +344,8 @@ void FGEnvironment::Tie( SGPropertyNode_ptr base, bool archivable )
_tiedProperties.Tie("atmosphere/density-tropo-avg", this,
&FGEnvironment::get_density_tropo_avg_kgm3); //ro
_tiedProperties.Tie("atmosphere/altitude-half-to-sun", this,
&FGEnvironment::get_altitude_half_to_sun_m,
&FGEnvironment::set_altitude_half_to_sun_m)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("atmosphere/altitude-troposphere-top", this,
&FGEnvironment::get_altitude_tropo_top_m,
&FGEnvironment::set_altitude_tropo_top_m)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("wind-from-heading-deg", this,
&FGEnvironment::get_wind_from_heading_deg,
&FGEnvironment::set_wind_from_heading_deg)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("wind-speed-kt", this,
&FGEnvironment::get_wind_speed_kt,
&FGEnvironment::set_wind_speed_kt)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("wind-from-north-fps", this,
&FGEnvironment::get_wind_from_north_fps,
&FGEnvironment::set_wind_from_north_fps)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("wind-from-east-fps", this,
&FGEnvironment::get_wind_from_east_fps,
&FGEnvironment::set_wind_from_east_fps)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("wind-from-down-fps", this,
&FGEnvironment::get_wind_from_down_fps,
&FGEnvironment::set_wind_from_down_fps)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("turbulence/magnitude-norm", this,
&FGEnvironment::get_turbulence_magnitude_norm,
&FGEnvironment::set_turbulence_magnitude_norm)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
_tiedProperties.Tie("turbulence/rate-hz", this,
&FGEnvironment::get_turbulence_rate_hz,
&FGEnvironment::set_turbulence_rate_hz)
->setAttribute( SGPropertyNode::ARCHIVE, archivable );
// do not auto reset/restore attributes on reset
_tiedProperties.setAttribute( SGPropertyNode::PRESERVE, true );
}
void FGEnvironment::Untie()

View file

@ -113,20 +113,6 @@ void FGInstrumentMgr::init()
SGSubsystemGroup::init();
}
void FGInstrumentMgr::reinit()
{
// delete all our instrument
for (unsigned int i=0; i<_instruments.size(); ++i) {
const std::string& nm(_instruments[i]);
SGSubsystem* instr = get_subsystem(nm);
instr->unbind();
remove_subsystem(nm);
delete instr;
}
init();
}
bool FGInstrumentMgr::build (SGPropertyNode* config_props)
{
for ( int i = 0; i < config_props->nChildren(); ++i ) {

View file

@ -34,7 +34,7 @@ public:
virtual void init();
virtual InitStatus incrementalInit();
virtual void reinit();
private:
bool build (SGPropertyNode* config_props);

View file

@ -824,6 +824,10 @@ void fgReInitSubsystems()
// need to bind FDMshell again, since we manually unbound it above...
globals->get_subsystem("flight")->bind();
// need to reset aircraft (systems/instruments) so they can adapt to current environment
globals->get_subsystem("systems")->reinit();
globals->get_subsystem("instrumentation")->reinit();
// setup state to end re-init
fgSetBool("/sim/signals/reinit", false);
if ( !freeze ) {