1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Schedules and runs the model routines.
8 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU Lesser General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
20 You should have received a copy of the GNU Lesser General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU Lesser General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
30 This class wraps up the simulation scheduling routines.
33 --------------------------------------------------------------------------------
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 COMMENTS, REFERENCES, and NOTES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #include "FGFDMExec.h"
49 #include "models/atmosphere/FGStandardAtmosphere.h"
50 #include "models/atmosphere/FGWinds.h"
51 #include "models/FGFCS.h"
52 #include "models/FGPropulsion.h"
53 #include "models/FGMassBalance.h"
54 #include "models/FGGroundReactions.h"
55 #include "models/FGExternalReactions.h"
56 #include "models/FGBuoyantForces.h"
57 #include "models/FGAerodynamics.h"
58 #include "models/FGInertial.h"
59 #include "models/FGAircraft.h"
60 #include "models/FGAccelerations.h"
61 #include "models/FGPropagate.h"
62 #include "models/FGAuxiliary.h"
63 #include "models/FGInput.h"
64 #include "models/FGOutput.h"
65 #include "initialization/FGInitialCondition.h"
66 #include "input_output/FGPropertyManager.h"
67 #include "input_output/FGScript.h"
73 static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.133 2012/04/14 18:10:43 bcoconni Exp $";
74 static const char *IdHdr = ID_FDMEXEC;
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
87 SetGroundCallback(new FGDefaultGroundCallback());
101 IncrementThenHolding = false; // increment then hold is off by default
102 TimeStepsUntilHold = -1;
105 dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
106 // run in standalone mode with no initialization file.
108 AircraftPath = "aircraft";
109 EnginePath = "engine";
110 SystemsPath = "systems";
113 char* num = getenv("JSBSIM_DEBUG");
114 if (num) debug_lvl = atoi(num); // set debug level
115 } catch (...) { // if error set to 1
119 if (Root == 0) { // Then this is the root FDM
120 Root = new FGPropertyManager; // Create the property manager
125 FDMctr = new unsigned int; // Create and initialize the child FDM counter
129 // Store this FDM's ID
130 IdFDM = (*FDMctr); // The main (parent) JSBSim instance is always the "zeroth"
132 // Prepare FDMctr for the next child FDM id
133 (*FDMctr)++; // instance. "child" instances are loaded last.
135 instance = Root->GetNode("/fdm/jsbsim",IdFDM,true);
137 // this is to catch errors in binding member functions to the property tree.
140 } catch ( string msg ) {
141 cout << "Caught error: " << msg << endl;
149 typedef int (FGFDMExec::*iPMF)(void) const;
150 // typedef unsigned int (FGFDMExec::*uiPMF)(void) const;
151 // instance->Tie("simulation/do_trim_analysis", this, (iPMF)0, &FGFDMExec::DoTrimAnalysis, false);
152 instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim, false);
153 instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions, false);
154 instance->Tie("simulation/randomseed", this, (iPMF)0, &FGFDMExec::SRand, false);
155 instance->Tie("simulation/terminate", (int *)&Terminate);
156 instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
157 instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
158 instance->Tie("simulation/frame", (int *)&Frame, false);
160 Constructing = false;
163 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 FGFDMExec::~FGFDMExec()
171 if (IdFDM == 0) { // Meaning this is no child FDM
182 } catch ( string msg ) {
183 cout << "Caught error: " << msg << endl;
186 for (unsigned int i=1; i<ChildFDMList.size(); i++) delete ChildFDMList[i]->exec;
187 ChildFDMList.clear();
189 PropertyCatalog.clear();
191 if (FDMctr > 0) (*FDMctr)--;
196 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 bool FGFDMExec::Allocate(void)
202 Models.resize(eNumStandardModels);
204 // See the eModels enum specification in the header file. The order of the enums
205 // specifies the order of execution. The Models[] vector is the primary
206 // storage array for the list of models.
207 Models[ePropagate] = new FGPropagate(this);
208 Models[eInput] = new FGInput(this);
209 Models[eInertial] = new FGInertial(this);
210 Models[eAtmosphere] = new FGStandardAtmosphere(this);
211 Models[eWinds] = new FGWinds(this);
212 Models[eAuxiliary] = new FGAuxiliary(this);
213 Models[eSystems] = new FGFCS(this);
214 Models[ePropulsion] = new FGPropulsion(this);
215 Models[eAerodynamics] = new FGAerodynamics (this);
217 GetGroundCallback()->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
219 Models[eGroundReactions] = new FGGroundReactions(this);
220 Models[eExternalReactions] = new FGExternalReactions(this);
221 Models[eBuoyantForces] = new FGBuoyantForces(this);
222 Models[eMassBalance] = new FGMassBalance(this);
223 Models[eAircraft] = new FGAircraft(this);
224 Models[eAccelerations] = new FGAccelerations(this);
226 // Assign the Model shortcuts for internal executive use only.
227 Propagate = (FGPropagate*)Models[ePropagate];
228 Inertial = (FGInertial*)Models[eInertial];
229 Atmosphere = (FGAtmosphere*)Models[eAtmosphere];
230 Winds = (FGWinds*)Models[eWinds];
231 Auxiliary = (FGAuxiliary*)Models[eAuxiliary];
232 FCS = (FGFCS*)Models[eSystems];
233 Propulsion = (FGPropulsion*)Models[ePropulsion];
234 Aerodynamics = (FGAerodynamics*)Models[eAerodynamics];
235 GroundReactions = (FGGroundReactions*)Models[eGroundReactions];
236 ExternalReactions = (FGExternalReactions*)Models[eExternalReactions];
237 BuoyantForces = (FGBuoyantForces*)Models[eBuoyantForces];
238 MassBalance = (FGMassBalance*)Models[eMassBalance];
239 Aircraft = (FGAircraft*)Models[eAircraft];
240 Accelerations = (FGAccelerations*)Models[eAccelerations];
242 // Initialize planet (environment) constants
243 LoadPlanetConstants();
246 for (unsigned int i = 0; i < Models.size(); i++) {
248 Models[i]->InitModel();
251 IC = new FGInitialCondition(this);
258 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 bool FGFDMExec::DeAllocate(void)
263 for (unsigned int i=0; i<eNumStandardModels; i++) delete Models[i];
266 for (unsigned i=0; i<Outputs.size(); i++) delete Outputs[i];
279 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281 void FGFDMExec::Schedule(FGModel* model, int rate)
283 model->SetRate(rate);
284 Models.push_back(model);
287 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 bool FGFDMExec::Run(void)
295 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
296 ChildFDMList[i]->AssignState( (FGPropagate*)Models[ePropagate] ); // Transfer state to the child FDM
297 ChildFDMList[i]->Run();
300 if (firstPass && !IntegrationSuspended()) {
301 // Outputs the initial conditions
302 for (unsigned int i = 0; i < Outputs.size(); i++)
303 Outputs[i]->Run(holding);
310 // returns true if success, false if complete
311 if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript();
313 for (unsigned int i = 0; i < Models.size(); i++) {
315 Models[i]->Run(holding);
318 if (Terminate) success = false;
323 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325 void FGFDMExec::LoadInputs(unsigned int idx)
329 Propagate->in.vPQRidot = Accelerations->GetPQRidot();
330 Propagate->in.vQtrndot = Accelerations->GetQuaterniondot();
331 Propagate->in.vUVWidot = Accelerations->GetUVWidot();
332 Propagate->in.DeltaT = dT;
337 Inertial->in.Radius = Propagate->GetRadius();
338 Inertial->in.Latitude = Propagate->GetLatitude();
341 Atmosphere->in.altitudeASL = Propagate->GetAltitudeASL();
344 Winds->in.AltitudeASL = Propagate->GetAltitudeASL();
345 Winds->in.DistanceAGL = Propagate->GetDistanceAGL();
346 Winds->in.Tl2b = Propagate->GetTl2b();
347 Winds->in.Tw2b = Auxiliary->GetTw2b();
348 Winds->in.V = Auxiliary->GetVt();
349 Winds->in.totalDeltaT = dT * Winds->GetRate();
352 Auxiliary->in.Pressure = Atmosphere->GetPressure();
353 Auxiliary->in.Density = Atmosphere->GetDensity();
354 Auxiliary->in.DensitySL = Atmosphere->GetDensitySL();
355 Auxiliary->in.PressureSL = Atmosphere->GetPressureSL();
356 Auxiliary->in.Temperature = Atmosphere->GetTemperature();
357 Auxiliary->in.SoundSpeed = Atmosphere->GetSoundSpeed();
358 Auxiliary->in.KinematicViscosity = Atmosphere->GetKinematicViscosity();
359 Auxiliary->in.DistanceAGL = Propagate->GetDistanceAGL();
360 Auxiliary->in.Mass = MassBalance->GetMass();
361 Auxiliary->in.Tl2b = Propagate->GetTl2b();
362 Auxiliary->in.Tb2l = Propagate->GetTb2l();
363 Auxiliary->in.vPQR = Propagate->GetPQR();
364 Auxiliary->in.vPQRdot = Accelerations->GetPQRdot();
365 Auxiliary->in.vUVW = Propagate->GetUVW();
366 Auxiliary->in.vUVWdot = Accelerations->GetUVWdot();
367 Auxiliary->in.vVel = Propagate->GetVel();
368 Auxiliary->in.vBodyAccel = Accelerations->GetBodyAccel();
369 Auxiliary->in.ToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
370 Auxiliary->in.VRPBody = MassBalance->StructuralToBody(Aircraft->GetXYZvrp());
371 Auxiliary->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
372 Auxiliary->in.vFw = Aerodynamics->GetvFw();
373 Auxiliary->in.vLocation = Propagate->GetLocation();
374 Auxiliary->in.Latitude = Propagate->GetLatitude();
375 Auxiliary->in.Longitude = Propagate->GetLongitude();
376 Auxiliary->in.CosTht = Propagate->GetCosEuler(eTht);
377 Auxiliary->in.SinTht = Propagate->GetSinEuler(eTht);
378 Auxiliary->in.CosPhi = Propagate->GetCosEuler(ePhi);
379 Auxiliary->in.SinPhi = Propagate->GetSinEuler(ePhi);
380 Auxiliary->in.Psi = Propagate->GetEuler(ePsi);
381 Auxiliary->in.TotalWindNED = Winds->GetTotalWindNED();
382 Auxiliary->in.TurbPQR = Winds->GetTurbPQR();
383 Auxiliary->in.WindPsi = Winds->GetWindPsi();
384 Auxiliary->in.Vwind = Winds->GetTotalWindNED().Magnitude();
387 // Dynamic inputs come into the components that FCS manages through properties
390 Propulsion->in.SLPressure = Atmosphere->GetPressureSL();
391 Propulsion->in.Pressure = Atmosphere->GetPressure();
392 Propulsion->in.PressureRatio = Atmosphere->GetPressureRatio();
393 Propulsion->in.Temperature = Atmosphere->GetTemperature();
394 Propulsion->in.DensityRatio = Atmosphere->GetDensityRatio();
395 Propulsion->in.Density = Atmosphere->GetDensity();
396 Propulsion->in.Soundspeed = Atmosphere->GetSoundSpeed();
397 Propulsion->in.TotalPressure = Auxiliary->GetTotalPressure();
398 Propulsion->in.TotalTempearture = Auxiliary->GetTotalTemperature();
399 Propulsion->in.Vc = Auxiliary->GetVcalibratedKTS();
400 Propulsion->in.Vt = Auxiliary->GetVt();
401 Propulsion->in.qbar = Auxiliary->Getqbar();
402 Propulsion->in.TAT_c = Auxiliary->GetTAT_C();
403 Propulsion->in.AeroUVW = Auxiliary->GetAeroUVW();
404 Propulsion->in.AeroPQR = Auxiliary->GetAeroPQR();
405 Propulsion->in.alpha = Auxiliary->Getalpha();
406 Propulsion->in.beta = Auxiliary->Getbeta();
407 Propulsion->in.TotalDeltaT = dT * Propulsion->GetRate();
408 Propulsion->in.ThrottlePos = FCS->GetThrottlePos();
409 Propulsion->in.MixturePos = FCS->GetMixturePos();
410 Propulsion->in.ThrottleCmd = FCS->GetThrottleCmd();
411 Propulsion->in.MixtureCmd = FCS->GetMixtureCmd();
412 Propulsion->in.PropAdvance = FCS->GetPropAdvance();
413 Propulsion->in.PropFeather = FCS->GetPropFeather();
414 Propulsion->in.H_agl = Propagate->GetDistanceAGL();
415 Propulsion->in.PQR = Propagate->GetPQR();
416 Propulsion->in.vXYZcg = MassBalance->GetXYZcg();
420 Aerodynamics->in.Alpha = Auxiliary->Getalpha();
421 Aerodynamics->in.Beta = Auxiliary->Getbeta();
422 Aerodynamics->in.Qbar = Auxiliary->Getqbar();
423 Aerodynamics->in.Vt = Auxiliary->GetVt();
424 Aerodynamics->in.Tb2w = Auxiliary->GetTb2w();
425 Aerodynamics->in.Tw2b = Auxiliary->GetTw2b();
426 Aerodynamics->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
428 case eGroundReactions:
429 // There are no external inputs to this model.
430 GroundReactions->in.Vground = Auxiliary->GetVground();
431 GroundReactions->in.VcalibratedKts = Auxiliary->GetVcalibratedKTS();
432 GroundReactions->in.Temperature = Atmosphere->GetTemperature();
433 GroundReactions->in.TakeoffThrottle = (FCS->GetThrottlePos().size() > 0) ? (FCS->GetThrottlePos(0) > 0.90) : false;
434 GroundReactions->in.SteerPosDeg = FCS->GetSteerPosDeg();
435 GroundReactions->in.BrakePos = FCS->GetBrakePos();
436 GroundReactions->in.FCSGearPos = FCS->GetGearPos();
437 GroundReactions->in.EmptyWeight = MassBalance->GetEmptyWeight();
438 GroundReactions->in.Tb2l = Propagate->GetTb2l();
439 GroundReactions->in.Tec2l = Propagate->GetTec2l();
440 GroundReactions->in.Tec2b = Propagate->GetTec2b();
441 GroundReactions->in.PQR = Propagate->GetPQR();
442 GroundReactions->in.UVW = Propagate->GetUVW();
443 GroundReactions->in.DistanceAGL = Propagate->GetDistanceAGL();
444 GroundReactions->in.DistanceASL = Propagate->GetAltitudeASL();
445 GroundReactions->in.TotalDeltaT = dT * GroundReactions->GetRate();
446 GroundReactions->in.WOW = GroundReactions->GetWOW();
447 GroundReactions->in.Location = Propagate->GetLocation();
448 GroundReactions->in.vXYZcg = MassBalance->GetXYZcg();
450 case eExternalReactions:
451 // There are no external inputs to this model.
454 BuoyantForces->in.Density = Atmosphere->GetDensity();
455 BuoyantForces->in.Pressure = Atmosphere->GetPressure();
456 BuoyantForces->in.Temperature = Atmosphere->GetTemperature();
457 BuoyantForces->in.gravity = Inertial->gravity();
460 MassBalance->in.GasInertia = BuoyantForces->GetGasMassInertia();
461 MassBalance->in.GasMass = BuoyantForces->GetGasMass();
462 MassBalance->in.GasMoment = BuoyantForces->GetGasMassMoment();
463 MassBalance->in.TanksWeight = Propulsion->GetTanksWeight();
464 MassBalance->in.TanksMoment = Propulsion->GetTanksMoment();
465 MassBalance->in.TankInertia = Propulsion->CalculateTankInertias();
468 Aircraft->in.AeroForce = Aerodynamics->GetForces();
469 Aircraft->in.PropForce = Propulsion->GetForces();
470 Aircraft->in.GroundForce = GroundReactions->GetForces();
471 Aircraft->in.ExternalForce = ExternalReactions->GetForces();
472 Aircraft->in.BuoyantForce = BuoyantForces->GetForces();
473 Aircraft->in.AeroMoment = Aerodynamics->GetMoments();
474 Aircraft->in.PropMoment = Propulsion->GetMoments();
475 Aircraft->in.GroundMoment = GroundReactions->GetMoments();
476 Aircraft->in.ExternalMoment = ExternalReactions->GetMoments();
477 Aircraft->in.BuoyantMoment = BuoyantForces->GetMoments();
478 Aircraft->in.Weight = MassBalance->GetWeight();
479 Aircraft->in.Tl2b = Propagate->GetTl2b();
482 Accelerations->in.J = MassBalance->GetJ();
483 Accelerations->in.Jinv = MassBalance->GetJinv();
484 Accelerations->in.Ti2b = Propagate->GetTi2b();
485 Accelerations->in.Tb2i = Propagate->GetTb2i();
486 Accelerations->in.Tec2b = Propagate->GetTec2b();
487 Accelerations->in.Tec2i = Propagate->GetTec2i();
488 Accelerations->in.qAttitudeECI = Propagate->GetQuaternionECI();
489 Accelerations->in.Moment = Aircraft->GetMoments();
490 Accelerations->in.GroundMoment = GroundReactions->GetMoments();
491 Accelerations->in.Force = Aircraft->GetForces();
492 Accelerations->in.GroundForce = GroundReactions->GetForces();
493 Accelerations->in.GAccel = Inertial->GetGAccel(Propagate->GetRadius());
494 Accelerations->in.J2Grav = Inertial->GetGravityJ2(Propagate->GetLocation());
495 Accelerations->in.vPQRi = Propagate->GetPQRi();
496 Accelerations->in.vPQR = Propagate->GetPQR();
497 Accelerations->in.vUVW = Propagate->GetUVW();
498 Accelerations->in.vInertialPosition = Propagate->GetInertialPosition();
499 Accelerations->in.DeltaT = dT;
500 Accelerations->in.Mass = MassBalance->GetMass();
501 Accelerations->in.MultipliersList = GroundReactions->GetMultipliersList();
502 Accelerations->in.TerrainVelocity = Propagate->GetTerrainVelocity();
503 Accelerations->in.TerrainAngularVel = Propagate->GetTerrainAngularVelocity();
510 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
512 void FGFDMExec::LoadPlanetConstants(void)
514 Propagate->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
515 Accelerations->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
516 Propagate->in.RefRadius = Inertial->GetRefRadius();
517 Propagate->in.SemiMajor = Inertial->GetSemimajor();
518 Propagate->in.SemiMinor = Inertial->GetSemiminor();
519 Auxiliary->in.SLGravity = Inertial->SLgravity();
520 Auxiliary->in.ReferenceRadius = Inertial->GetRefRadius();
523 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525 void FGFDMExec::LoadModelConstants(void)
527 Winds->in.wingspan = Aircraft->GetWingSpan();
528 FCS->in.NumGear = GroundReactions->GetNumGearUnits();
529 Aerodynamics->in.Wingarea = Aircraft->GetWingArea();
530 Aerodynamics->in.Wingchord = Aircraft->Getcbar();
531 Aerodynamics->in.Wingincidence = Aircraft->GetWingIncidence();
532 Aerodynamics->in.Wingspan = Aircraft->GetWingSpan();
533 Auxiliary->in.Wingspan = Aircraft->GetWingSpan();
534 Auxiliary->in.Wingchord = Aircraft->Getcbar();
535 GroundReactions->in.vXYZcg = MassBalance->GetXYZcg();
536 Propulsion->in.vXYZcg = MassBalance->GetXYZcg();
538 LoadPlanetConstants();
541 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 // This call will cause the sim time to reset to 0.0
544 bool FGFDMExec::RunIC(void)
546 SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
549 ResumeIntegration(); // Restores the integration rate to what it was.
554 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 void FGFDMExec::Initialize(FGInitialCondition *FGIC)
560 Propagate->SetInitialState( FGIC );
561 LoadInputs(eAccelerations);
562 Accelerations->Run(false);
563 LoadInputs(ePropagate);
564 Propagate->InitializeDerivatives();
565 LoadInputs(eAtmosphere);
566 Atmosphere->Run(false);
567 Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
568 Auxiliary->Run(false);
571 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 // A private, internal function call for Tie-ing to a property, so it needs an
576 void FGFDMExec::ResetToInitialConditions(int mode)
579 for (unsigned int i=0; i<Outputs.size(); i++) {
580 Outputs[i]->SetStartNewFile(true);
584 ResetToInitialConditions();
587 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589 void FGFDMExec::ResetToInitialConditions(void)
591 if (Constructing) return;
593 vector <FGModel*>::iterator it;
594 for (it = Models.begin(); it != Models.end(); ++it) (*it)->InitModel();
597 if (Script) Script->ResetEvents();
600 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602 bool FGFDMExec::SetOutputFileName(const string& fname)
604 if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
609 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 string FGFDMExec::GetOutputFileName(void)
613 if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
614 else return string("");
617 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 vector <string> FGFDMExec::EnumerateFDMs(void)
621 vector <string> FDMList;
622 FGAircraft* Aircraft = (FGAircraft*)Models[eAircraft];
624 FDMList.push_back(Aircraft->GetAircraftName());
626 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
627 FDMList.push_back(ChildFDMList[i]->exec->GetAircraft()->GetAircraftName());
633 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635 bool FGFDMExec::LoadScript(const string& script, double deltaT)
639 Script = new FGScript(this);
640 result = Script->LoadScript(RootDir + script, deltaT);
645 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
647 bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
648 const string& model, bool addModelToPath)
650 FGFDMExec::AircraftPath = RootDir + AircraftPath;
651 FGFDMExec::EnginePath = RootDir + EnginePath;
652 FGFDMExec::SystemsPath = RootDir + SystemsPath;
654 return LoadModel(model, addModelToPath);
657 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
662 string aircraftCfgFileName;
663 Element* element = 0L;
664 bool result = false; // initialize result to false, indicating input file not yet read
666 modelName = model; // Set the class modelName attribute
668 if( AircraftPath.empty() || EnginePath.empty() || SystemsPath.empty()) {
669 cerr << "Error: attempted to load aircraft with undefined ";
670 cerr << "aircraft, engine, and system paths" << endl;
674 FullAircraftPath = AircraftPath;
675 if (addModelToPath) FullAircraftPath += "/" + model;
676 aircraftCfgFileName = FullAircraftPath + "/" + model + ".xml";
683 int saved_debug_lvl = debug_lvl;
685 document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
687 if (IsChild) debug_lvl = 0;
689 ReadPrologue(document);
691 if (IsChild) debug_lvl = saved_debug_lvl;
693 // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
694 element = document->FindElement("fileheader");
696 result = ReadFileHeader(element);
698 cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
703 if (IsChild) debug_lvl = 0;
705 // Process the metrics element. This element is REQUIRED.
706 element = document->FindElement("metrics");
708 result = ((FGAircraft*)Models[eAircraft])->Load(element);
710 cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
714 cerr << endl << "No metrics element was found in the aircraft config file." << endl;
718 // Process the mass_balance element. This element is REQUIRED.
719 element = document->FindElement("mass_balance");
721 result = ((FGMassBalance*)Models[eMassBalance])->Load(element);
723 cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
727 cerr << endl << "No mass_balance element was found in the aircraft config file." << endl;
731 // Process the ground_reactions element. This element is REQUIRED.
732 element = document->FindElement("ground_reactions");
734 result = ((FGGroundReactions*)Models[eGroundReactions])->Load(element);
736 cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl;
739 ((FGFCS*)Models[eSystems])->AddGear(((FGGroundReactions*)Models[eGroundReactions])->GetNumGearUnits());
741 cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
745 // Process the external_reactions element. This element is OPTIONAL.
746 element = document->FindElement("external_reactions");
748 result = ((FGExternalReactions*)Models[eExternalReactions])->Load(element);
750 cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
755 // Process the buoyant_forces element. This element is OPTIONAL.
756 element = document->FindElement("buoyant_forces");
758 result = ((FGBuoyantForces*)Models[eBuoyantForces])->Load(element);
760 cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
765 // Process the propulsion element. This element is OPTIONAL.
766 element = document->FindElement("propulsion");
768 result = ((FGPropulsion*)Models[ePropulsion])->Load(element);
770 cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
773 for (unsigned int i=0; i<((FGPropulsion*)Models[ePropulsion])->GetNumEngines(); i++)
774 ((FGFCS*)Models[eSystems])->AddThrottle();
777 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
778 element = document->FindElement("system");
780 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stSystem);
782 cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
785 element = document->FindNextElement("system");
788 // Process the autopilot element. This element is OPTIONAL.
789 element = document->FindElement("autopilot");
791 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stAutoPilot);
793 cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
798 // Process the flight_control element. This element is OPTIONAL.
799 element = document->FindElement("flight_control");
801 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stFCS);
803 cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
808 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
809 element = document->FindElement("aerodynamics");
811 result = ((FGAerodynamics*)Models[eAerodynamics])->Load(element);
813 cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
817 cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
820 // Process the input element. This element is OPTIONAL.
821 element = document->FindElement("input");
823 result = ((FGInput*)Models[eInput])->Load(element);
825 cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
830 // Process the output element[s]. This element is OPTIONAL, and there may be more than one.
832 typedef double (FGOutput::*iOPMF)(void) const;
833 typedef int (FGFDMExec::*iOPV)(void) const;
834 element = document->FindElement("output");
836 if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " ";
837 FGOutput* Output = new FGOutput(this);
838 result = Output->Load(element);
840 cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl;
846 Outputs.push_back(Output);
847 string outputProp = CreateIndexedPropertyName("simulation/output",idx);
848 instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
851 element = document->FindNextElement("output");
854 instance->Tie("simulation/force-output", this, (iOPV)0, &FGFDMExec::ForceOutput, false);
856 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
857 element = document->FindElement("child");
859 result = ReadChild(element);
861 cerr << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
866 // Since all vehicle characteristics have been loaded, place the values in the Inputs
867 // structure for the FGModel-derived classes.
868 LoadModelConstants();
873 LoadInputs(eMassBalance); // Update all input mass properties for the report.
874 Models[eMassBalance]->Run(false); // Update all mass properties for the report.
875 ((FGMassBalance*)Models[eMassBalance])->GetMassPropertiesReport();
877 cout << endl << fgblue << highint
878 << "End of vehicle configuration loading." << endl
879 << "-------------------------------------------------------------------------------"
883 if (IsChild) debug_lvl = saved_debug_lvl;
887 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
891 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
894 struct PropertyCatalogStructure masterPCS;
895 masterPCS.base_string = "";
896 masterPCS.node = (FGPropertyManager*)Root;
897 BuildPropertyCatalog(&masterPCS);
903 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
905 string FGFDMExec::GetPropulsionTankReport()
907 return ((FGPropulsion*)Models[ePropulsion])->GetPropulsionTankReport();
910 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912 void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
914 struct PropertyCatalogStructure* pcsNew = new struct PropertyCatalogStructure;
917 for (int i=0; i<pcs->node->nChildren(); i++) {
918 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
919 node_idx = pcs->node->getChild(i)->getIndex();
921 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
923 if (pcs->node->getChild(i)->nChildren() == 0) {
924 if (pcsNew->base_string.substr(0,11) == string("/fdm/jsbsim")) {
925 pcsNew->base_string = pcsNew->base_string.erase(0,12);
927 PropertyCatalog.push_back(pcsNew->base_string);
929 pcsNew->node = (FGPropertyManager*)pcs->node->getChild(i);
930 BuildPropertyCatalog(pcsNew);
936 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938 string FGFDMExec::QueryPropertyCatalog(const string& in)
941 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
942 if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
944 if (results.empty()) return "No matches found\n";
948 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950 void FGFDMExec::PrintPropertyCatalog(void)
953 cout << " " << fgblue << highint << underon << "Property Catalog for "
954 << modelName << reset << endl << endl;
955 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
956 cout << " " << PropertyCatalog[i] << endl;
960 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
962 bool FGFDMExec::ReadFileHeader(Element* el)
964 bool result = true; // true for success
966 if (debug_lvl == 0) return result;
969 cout << endl <<highint << fgblue << "Reading child model: " << IdFDM << reset << endl << endl;
972 if (el->FindElement("description"))
973 cout << " Description: " << el->FindElement("description")->GetDataLine() << endl;
974 if (el->FindElement("author"))
975 cout << " Model Author: " << el->FindElement("author")->GetDataLine() << endl;
976 if (el->FindElement("filecreationdate"))
977 cout << " Creation Date: " << el->FindElement("filecreationdate")->GetDataLine() << endl;
978 if (el->FindElement("version"))
979 cout << " Version: " << el->FindElement("version")->GetDataLine() << endl;
984 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
986 bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document element
988 bool result = true; // true for success
990 if (!el) return false;
992 string AircraftName = el->GetAttributeValue("name");
993 ((FGAircraft*)Models[eAircraft])->SetAircraftName(AircraftName);
995 if (debug_lvl & 1) cout << underon << "Reading Aircraft Configuration File"
996 << underoff << ": " << highint << AircraftName << normint << endl;
998 CFGVersion = el->GetAttributeValue("version");
999 Release = el->GetAttributeValue("release");
1002 cout << " Version: " << highint << CFGVersion
1004 if (CFGVersion != needed_cfg_version) {
1005 cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
1006 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
1007 cerr << "Current version needed is: " << needed_cfg_version << endl;
1008 cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
1012 if (Release == "ALPHA" && (debug_lvl & 1)) {
1013 cout << endl << endl
1014 << highint << "This aircraft model is an " << fgred << Release
1015 << reset << highint << " release!!!" << endl << endl << reset
1016 << "This aircraft model may not even properly load, and probably"
1017 << " will not fly as expected." << endl << endl
1018 << fgred << highint << "Use this model for development purposes ONLY!!!"
1019 << normint << reset << endl << endl;
1020 } else if (Release == "BETA" && (debug_lvl & 1)) {
1021 cout << endl << endl
1022 << highint << "This aircraft model is a " << fgred << Release
1023 << reset << highint << " release!!!" << endl << endl << reset
1024 << "This aircraft model probably will not fly as expected." << endl << endl
1025 << fgblue << highint << "Use this model for development purposes ONLY!!!"
1026 << normint << reset << endl << endl;
1027 } else if (Release == "PRODUCTION" && (debug_lvl & 1)) {
1028 cout << endl << endl
1029 << highint << "This aircraft model is a " << fgblue << Release
1030 << reset << highint << " release." << endl << endl << reset;
1031 } else if (debug_lvl & 1) {
1032 cout << endl << endl
1033 << highint << "This aircraft model is an " << fgred << Release
1034 << reset << highint << " release!!!" << endl << endl << reset
1035 << "This aircraft model may not even properly load, and probably"
1036 << " will not fly as expected." << endl << endl
1037 << fgred << highint << "Use this model for development purposes ONLY!!!"
1038 << normint << reset << endl << endl;
1044 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1046 bool FGFDMExec::ReadChild(Element* el)
1048 // Add a new childData object to the child FDM list
1049 // Populate that childData element with a new FDMExec object
1050 // Set the IsChild flag for that FDMExec object
1051 // Get the aircraft name
1052 // set debug level to print out no additional data for child objects
1053 // Load the model given the aircraft name
1054 // reset debug level to prior setting
1058 struct childData* child = new childData;
1060 child->exec = new FGFDMExec(Root, FDMctr);
1061 child->exec->SetChild(true);
1063 string childAircraft = el->GetAttributeValue("name");
1064 string sMated = el->GetAttributeValue("mated");
1065 if (sMated == "false") child->mated = false; // child objects are mated by default.
1066 string sInternal = el->GetAttributeValue("internal");
1067 if (sInternal == "true") child->internal = true; // child objects are external by default.
1069 child->exec->SetAircraftPath( AircraftPath );
1070 child->exec->SetEnginePath( EnginePath );
1071 child->exec->SetSystemsPath( SystemsPath );
1072 child->exec->LoadModel(childAircraft);
1074 Element* location = el->FindElement("location");
1076 child->Loc = location->FindElementTripletConvertTo("IN");
1078 cerr << endl << highint << fgred << " No location was found for this child object!" << reset << endl;
1082 Element* orientation = el->FindElement("orient");
1084 child->Orient = orientation->FindElementTripletConvertTo("RAD");
1085 } else if (debug_lvl > 0) {
1086 cerr << endl << highint << " No orientation was found for this child object! Assuming 0,0,0." << reset << endl;
1089 ChildFDMList.push_back(child);
1094 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1096 FGPropertyManager* FGFDMExec::GetPropertyManager(void)
1101 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103 FGTrim* FGFDMExec::GetTrim(void)
1106 Trim = new FGTrim(this,tNone);
1110 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1112 void FGFDMExec::DisableOutput(void)
1114 for (unsigned i=0; i<Outputs.size(); i++) {
1115 Outputs[i]->Disable();
1119 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1121 void FGFDMExec::EnableOutput(void)
1123 for (unsigned i=0; i<Outputs.size(); i++) {
1124 Outputs[i]->Enable();
1128 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1130 void FGFDMExec::CheckIncrementalHold(void)
1132 // Only check if increment then hold is on
1133 if( IncrementThenHolding ) {
1135 if (TimeStepsUntilHold == 0) {
1137 // Should hold simulation if TimeStepsUntilHold has reached zero
1140 // Still need to decrement TimeStepsUntilHold as value of -1
1141 // indicates that incremental then hold is turned off
1142 IncrementThenHolding = false;
1143 TimeStepsUntilHold--;
1145 } else if ( TimeStepsUntilHold > 0 ) {
1146 // Keep decrementing until 0 is reached
1147 TimeStepsUntilHold--;
1152 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1154 void FGFDMExec::ForceOutput(int idx)
1156 if (idx >= (int)0 && idx < (int)Outputs.size()) Outputs[idx]->Print();
1159 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1161 bool FGFDMExec::SetOutputDirectives(const string& fname)
1165 FGOutput* Output = new FGOutput(this);
1166 Output->SetDirectivesFile(RootDir + fname);
1167 result = Output->Load(0);
1170 Output->InitModel();
1172 Output->Run(holding);
1173 Outputs.push_back(Output);
1174 typedef double (FGOutput::*iOPMF)(void) const;
1175 string outputProp = CreateIndexedPropertyName("simulation/output",Outputs.size()-1);
1176 instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
1184 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1186 void FGFDMExec::DoTrim(int mode)
1190 if (Constructing) return;
1192 if (mode < 0 || mode > JSBSim::tNone) {
1193 cerr << endl << "Illegal trimming mode!" << endl << endl;
1196 saved_time = sim_time;
1197 FGTrim trim(this, (JSBSim::TrimMode)mode);
1198 if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
1200 sim_time = saved_time;
1203 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1205 void FGFDMExec::SRand(int sr)
1210 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1211 // The bitmasked value choices are as follows:
1212 // unset: In this case (the default) JSBSim would only print
1213 // out the normally expected messages, essentially echoing
1214 // the config files as they are read. If the environment
1215 // variable is not set, debug_lvl is set to 1 internally
1216 // 0: This requests JSBSim not to output any messages
1218 // 1: This value explicity requests the normal JSBSim
1220 // 2: This value asks for a message to be printed out when
1221 // a class is instantiated
1222 // 4: When this value is set, a message is displayed when a
1223 // FGModel object executes its Run() method
1224 // 8: When this value is set, various runtime state variables
1225 // are printed out periodically
1226 // 16: When set various parameters are sanity checked and
1227 // a message is printed out when they go out of bounds
1229 void FGFDMExec::Debug(int from)
1231 if (debug_lvl <= 0) return;
1233 if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output
1234 if (from == 0) { // Constructor
1236 << "JSBSim Flight Dynamics Model v" << JSBSim_version << endl;
1237 cout << " [JSBSim-ML v" << needed_cfg_version << "]\n\n";
1238 cout << "JSBSim startup beginning ...\n\n";
1239 } else if (from == 3) {
1240 cout << "\n\nJSBSim startup complete\n\n";
1243 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1244 if (from == 0) cout << "Instantiated: FGFDMExec" << endl;
1245 if (from == 1) cout << "Destroyed: FGFDMExec" << endl;
1247 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1249 cout << "================== Frame: " << Frame << " Time: "
1250 << sim_time << " dt: " << dT << endl;
1253 if (debug_lvl & 8 ) { // Runtime state variables
1255 if (debug_lvl & 16) { // Sanity checking
1257 if (debug_lvl & 64) {
1258 if (from == 0) { // Constructor
1259 cout << IdSrc << endl;
1260 cout << IdHdr << endl;