1
0
Fork 0

Modified FGSubsystem::update() to take an int parameter for delta time

(i.e. multiloop).  Most subsystems currently ignore the parameter, but
eventually, it will allow all subsystems to update by time rather than
by framerate.
This commit is contained in:
david 2001-12-22 17:33:27 +00:00
parent b9dc522882
commit aabdd355f0
37 changed files with 81 additions and 73 deletions

View file

@ -253,7 +253,7 @@ FGPanel::unbind ()
* Update the panel.
*/
void
FGPanel::update ()
FGPanel::update (int dt)
{
// Do nothing if the panel isn't visible.
if ( !fgPanelVisible() ) {

View file

@ -141,7 +141,7 @@ public:
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update ();
virtual void update (int dt);
virtual void update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh);
// transfer pointer ownership!!!

View file

@ -140,7 +140,7 @@ FGRadioStack::init ()
blink.stamp();
search();
update();
update(1); // FIXME: use dt
// Search radio database once per second
global_events.Register( "fgRadioSearch()", fgRadioSearch,
@ -400,7 +400,7 @@ double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
// Update the various nav values based on position and valid tuned in navs
void
FGRadioStack::update()
FGRadioStack::update(int dt)
{
//DCL
string transmission;

View file

@ -215,7 +215,7 @@ public:
void init ();
void bind ();
void unbind ();
void update ();
void update (int dt);
// Update nav/adf radios based on current postition
void search ();

View file

@ -176,7 +176,7 @@ FGControls::unbind ()
void
FGControls::update ()
FGControls::update (int dt)
{
}

View file

@ -92,7 +92,7 @@ public:
void init ();
void bind ();
void unbind ();
void update ();
void update (int dt);
// Reset function
void reset_all(void);

View file

@ -198,7 +198,7 @@ void FGADA::init() {
// Run an iteration of the EOM. This is essentially a NOP here
// because these values are getting filled in elsewhere based on
// external input.
bool FGADA::update( int multiloop ) {
void FGADA::update( int multiloop ) {
// cout << "FGADA::update()" << endl;
char Buffer[numberofbytes];
@ -223,8 +223,6 @@ bool FGADA::update( int multiloop ) {
memcpy (&OutBuffer, &visuals_to_sixdof, sizeof (OutBuffer));
int result = fdmsock->write(OutBuffer, nbytes);
}
return true;
}
// Convert from the FGInterface struct to the FGADA struct (output)

View file

@ -79,7 +79,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update(int dt);
};

View file

@ -113,7 +113,7 @@ void FGBalloonSim::init() {
// Run an iteration of the EOM (equations of motion)
bool FGBalloonSim::update( int multiloop ) {
void FGBalloonSim::update( int multiloop ) {
double save_alt = 0.0;
// lets try to avoid really screwing up the BalloonSim model
@ -162,8 +162,6 @@ bool FGBalloonSim::update( int multiloop ) {
if ( save_alt < -9000.0 ) {
set_Altitude( save_alt );
}
return true;
}

View file

@ -75,7 +75,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update( int multiloop );
};

View file

@ -43,12 +43,9 @@ void FGExternal::init() {
// Run an iteration of the EOM. This is essentially a NOP here
// because these values are getting filled in elsewhere based on
// external input.
bool FGExternal::update( int multiloop ) {
void FGExternal::update( int multiloop ) {
// cout << "FGExternal::update()" << endl;
// double time_step = (1.0 / fgGetInt("/sim/model-hz"))
// * multiloop;
return true;
}

View file

@ -38,7 +38,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update( int multiloop );
};

View file

@ -65,8 +65,6 @@ void FGExternalNet::init() {
// Run an iteration of the EOM. This is a NOP here because the flight
// model values are getting filled in elsewhere (most likely from some
// external source.)
bool FGExternalNet::update( int multiloop ) {
void FGExternalNet::update( int multiloop ) {
// cout << "FGExternalNet::update()" << endl;
return true;
}

View file

@ -53,7 +53,7 @@ public:
void init();
// update the fdm
bool update( int multiloop );
void update( int multiloop );
};

View file

@ -230,7 +230,8 @@ void FGJSBsim::init() {
// Run an iteration of the EOM (equations of motion)
bool FGJSBsim::update( int multiloop ) {
void
FGJSBsim::update( int multiloop ) {
int i;
@ -306,7 +307,6 @@ bool FGJSBsim::update( int multiloop ) {
// translate JSBsim back to FG structure so that the
// autopilot (and the rest of the sim can use the updated values
copy_from_JSBsim();
return true;
}
/******************************************************************************/

View file

@ -215,7 +215,7 @@ public:
/** Update the position based on inputs, positions, velocities, etc.
@param multiloop number of times to loop through the FDM
@return true if successful */
bool update( int multiloop );
void update( int multiloop );
bool ToggleDataLogging(bool state);
bool ToggleDataLogging(void);
void do_trim(void);

View file

@ -107,16 +107,14 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
WingIncidence=0;
impending_stall = 0;
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGAircraft::~FGAircraft()
{
if (debug_lvl & 2) cout << "Destroyed: FGAircraft" << endl;
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -376,9 +374,43 @@ bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
// out the normally expected messages, essentially echoing
// the config files as they are read. If the environment
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
// 4: When this value is set, a message is displayed when a
// FGModel object executes its Run() method
// 8: When this value is set, various runtime state variables
// are printed out periodically
// 16: When set various parameters are sanity checked and
// a message is printed out when they go out of bounds
void FGAircraft::Debug(int from)
{
//TODO: Add your source code here
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGAircraft" << endl;
if (from == 1) cout << "Destroyed: FGAircraft" << endl;
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
if (debug_lvl & 8 ) { // Runtime state variables
}
if (debug_lvl & 16) { // Sanity checking
}
if (debug_lvl & 32) { // Turbulence
}
}

View file

@ -97,7 +97,7 @@ void FGLaRCsim::init() {
// Run an iteration of the EOM (equations of motion)
bool FGLaRCsim::update( int multiloop ) {
void FGLaRCsim::update( int multiloop ) {
if ( aero->getStringValue() == "c172" ) {
// set control inputs
@ -215,8 +215,6 @@ bool FGLaRCsim::update( int multiloop ) {
if ( save_alt < -9000.0 ) {
set_Altitude( save_alt );
}
return true;
}

View file

@ -58,7 +58,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update( int multiloop );
// Positions
void set_Latitude(double lat); //geocentric

View file

@ -49,7 +49,7 @@ void FGMagicCarpet::init() {
// Run an iteration of the EOM (equations of motion)
bool FGMagicCarpet::update( int multiloop ) {
void FGMagicCarpet::update( int multiloop ) {
// cout << "FGLaRCsim::update()" << endl;
double time_step = get_delta_t() * multiloop;
@ -102,6 +102,4 @@ bool FGMagicCarpet::update( int multiloop ) {
// cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl;
_set_Sea_level_radius( sl_radius * SG_METER_TO_FEET);
_set_Altitude( get_Altitude() + climb );
return true;
}

View file

@ -38,7 +38,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update( int multiloop );
};

View file

@ -43,8 +43,6 @@ void FGNullFDM::init() {
// Run an iteration of the EOM. This is a NOP here because the flight
// model values are getting filled in elsewhere (most likely from some
// external source.)
bool FGNullFDM::update( int multiloop ) {
void FGNullFDM::update( int multiloop ) {
// cout << "FGNullFDM::update()" << endl;
return true;
}

View file

@ -39,7 +39,7 @@ public:
void init();
// update position based on inputs, positions, velocities, etc.
bool update( int multiloop );
void update( int multiloop );
};

View file

@ -172,11 +172,11 @@ void YASim::init()
set_inited(true);
}
bool YASim::update(int iterations)
void YASim::update(int iterations)
{
// If we're crashed, then we don't care
if(_fdm->getAirplane()->getModel()->isCrashed())
return true;
return;
int i;
for(i=0; i<iterations; i++) {
@ -193,8 +193,6 @@ bool YASim::update(int iterations)
_updateCount = 0;
}
}
return true; // what does this mean?
}
void YASim::copyToYASim(bool copyState)

View file

@ -13,7 +13,7 @@ public:
virtual void init();
// Run an iteration
virtual bool update(int iterations);
virtual void update(int iterations);
private:
void report();

View file

@ -495,15 +495,9 @@ FGInterface::free_gear_units ()
* Update the state of the FDM (i.e. run the equations of motion).
*/
void
FGInterface::update ()
FGInterface::update (int dt)
{
update(1);
}
bool FGInterface::update( int multi_loop ) {
cout << "dummy update() ... SHOULDN'T BE CALLED!" << endl;
return false;
}

View file

@ -522,8 +522,7 @@ public:
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update ();
virtual bool update( int multi_loop );
virtual void update(int dt);
virtual bool ToggleDataLogging(bool state) { return false; }
virtual bool ToggleDataLogging(void) { return false; }

View file

@ -204,7 +204,7 @@ FGInput::unbind ()
}
void
FGInput::update ()
FGInput::update (int dt)
{
_update_keyboard();
_update_joystick();

View file

@ -185,7 +185,7 @@ public:
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update ();
virtual void update (int dt);
/**

View file

@ -150,7 +150,7 @@ public:
* update its state. If the subsystem requires delta time information,
* it should track it itself.</p>
*/
virtual void update () = 0;
virtual void update (int dt) = 0;
};

View file

@ -861,10 +861,10 @@ void fgRenderFrame( void ) {
// glDisable( GL_TEXTURE_2D );
// update the input subsystem
current_input.update();
current_input.update(1); // FIXME: use real dt
// update the controls subsystem
globals->get_controls()->update();
globals->get_controls()->update(1); // FIXME: use real dt
hud_and_panel->apply();
fgCockpitUpdate();
@ -875,7 +875,7 @@ void fgRenderFrame( void ) {
// update the panel subsystem
if ( current_panel != NULL ) {
current_panel->update();
current_panel->update(1); // FIXME: use real dt
}
// We can do translucent menus, so why not. :-)
@ -1024,7 +1024,7 @@ void fgUpdateTimeDepCalcs() {
cur_fdm_state->get_Latitude() );
// Update radio stack model
current_radiostack->update();
current_radiostack->update(1); // FIXME: use dt
}
@ -1229,8 +1229,8 @@ static void fgMainLoop( void ) {
// Run audio scheduler
#ifdef ENABLE_AUDIO_SUPPORT
if ( fgGetBool("/sim/sound") && globals->get_soundmgr()->is_working() ) {
globals->get_fx()->update();
globals->get_soundmgr()->update();
globals->get_fx()->update(1); // FIXME: use dt
globals->get_soundmgr()->update(1); // FIXME: use dt
}
#endif

View file

@ -61,7 +61,7 @@ FGScenery::~FGScenery() {
void FGScenery::init() {
}
void FGScenery::update() {
void FGScenery::update(int dt) {
}
void FGScenery::bind() {

View file

@ -67,7 +67,7 @@ public:
void init ();
void bind ();
void unbind ();
void update ();
void update (int dt);
inline double get_cur_elev() const { return cur_elev; }
inline void set_cur_elev( double e ) { cur_elev = e; }

View file

@ -215,7 +215,7 @@ FGFX::unbind ()
}
void
FGFX::update ()
FGFX::update (int dt)
{
FGSoundMgr * mgr = globals->get_soundmgr();
int i;

View file

@ -58,7 +58,7 @@ public:
virtual void init ();
virtual void bind ();
virtual void unbind ();
virtual void update ();
virtual void update (int dt);
private:

View file

@ -121,7 +121,7 @@ void FGSoundMgr::unbind ()
// run the audio scheduler
void FGSoundMgr::update() {
void FGSoundMgr::update(int dt) {
SGTimeStamp current;
current.stamp();

View file

@ -121,7 +121,7 @@ public:
/**
* Run the audio scheduler.
*/
void update();
void update(int dt);
// is audio working?