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.118 2011/10/22 15:11:23 bcoconni Exp $";
74 static const char *IdHdr = ID_FDMEXEC;
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
88 GroundCallback = new FGDefaultGroundCallback();
103 dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
104 // run in standalone mode with no initialization file.
106 AircraftPath = "aircraft";
107 EnginePath = "engine";
108 SystemsPath = "systems";
111 char* num = getenv("JSBSIM_DEBUG");
112 if (num) debug_lvl = atoi(num); // set debug level
113 } catch (...) { // if error set to 1
117 if (Root == 0) { // Then this is the root FDM
118 Root = new FGPropertyManager; // Create the property manager
123 FDMctr = new unsigned int; // Create and initialize the child FDM counter
127 // Store this FDM's ID
128 IdFDM = (*FDMctr); // The main (parent) JSBSim instance is always the "zeroth"
130 // Prepare FDMctr for the next child FDM id
131 (*FDMctr)++; // instance. "child" instances are loaded last.
133 instance = Root->GetNode("/fdm/jsbsim",IdFDM,true);
135 // this is to catch errors in binding member functions to the property tree.
138 } catch ( string msg ) {
139 cout << "Caught error: " << msg << endl;
147 typedef int (FGFDMExec::*iPMF)(void) const;
148 // instance->Tie("simulation/do_trim_analysis", this, (iPMF)0, &FGFDMExec::DoTrimAnalysis, false);
149 instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim, false);
150 instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions, false);
151 instance->Tie("simulation/terminate", (int *)&Terminate);
152 instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
153 instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
154 instance->Tie("simulation/frame", (int *)&Frame, false);
156 Constructing = false;
159 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 FGFDMExec::~FGFDMExec()
167 if (IdFDM == 0) { // Meaning this is no child FDM
178 } catch ( string msg ) {
179 cout << "Caught error: " << msg << endl;
182 for (unsigned int i=1; i<ChildFDMList.size(); i++) delete ChildFDMList[i]->exec;
183 ChildFDMList.clear();
185 PropertyCatalog.clear();
187 if (FDMctr > 0) (*FDMctr)--;
190 delete GroundCallback;
195 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 bool FGFDMExec::Allocate(void)
201 Models.resize(eNumStandardModels);
203 // See the eModels enum specification in the header file. The order of the enums
204 // specifies the order of execution. The Models[] vector is the primary
205 // storage array for the list of models.
206 Models[ePropagate] = new FGPropagate(this);
207 Models[eInput] = new FGInput(this);
208 Models[eInertial] = new FGInertial(this);
209 Models[eAtmosphere] = new FGStandardAtmosphere(this);
210 Models[eWinds] = new FGWinds(this);
211 Models[eAuxiliary] = new FGAuxiliary(this);
212 Models[eSystems] = new FGFCS(this);
213 Models[ePropulsion] = new FGPropulsion(this);
214 Models[eAerodynamics] = new FGAerodynamics (this);
216 GroundCallback->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
218 Models[eGroundReactions] = new FGGroundReactions(this);
219 Models[eExternalReactions] = new FGExternalReactions(this);
220 Models[eBuoyantForces] = new FGBuoyantForces(this);
221 Models[eMassBalance] = new FGMassBalance(this);
222 Models[eAircraft] = new FGAircraft(this);
223 Models[eAccelerations] = new FGAccelerations(this);
225 // Assign the Model shortcuts for internal executive use only.
226 Propagate = (FGPropagate*)Models[ePropagate];
227 Inertial = (FGInertial*)Models[eInertial];
228 Atmosphere = (FGAtmosphere*)Models[eAtmosphere];
229 Winds = (FGWinds*)Models[eWinds];
230 Auxiliary = (FGAuxiliary*)Models[eAuxiliary];
231 FCS = (FGFCS*)Models[eSystems];
232 Propulsion = (FGPropulsion*)Models[ePropulsion];
233 Aerodynamics = (FGAerodynamics*)Models[eAerodynamics];
234 GroundReactions = (FGGroundReactions*)Models[eGroundReactions];
235 ExternalReactions = (FGExternalReactions*)Models[eExternalReactions];
236 BuoyantForces = (FGBuoyantForces*)Models[eBuoyantForces];
237 MassBalance = (FGMassBalance*)Models[eMassBalance];
238 Aircraft = (FGAircraft*)Models[eAircraft];
239 Accelerations = (FGAccelerations*)Models[eAccelerations];
241 // Initialize planet (environment) constants
242 LoadPlanetConstants();
245 for (unsigned int i = 0; i < Models.size(); i++) {
247 Models[i]->InitModel();
250 IC = new FGInitialCondition(this);
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 bool FGFDMExec::DeAllocate(void)
262 for (unsigned int i=0; i<eNumStandardModels; i++) delete Models[i];
265 for (unsigned i=0; i<Outputs.size(); i++) delete Outputs[i];
278 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 void FGFDMExec::Schedule(FGModel* model, int rate)
282 model->SetRate(rate);
283 Models.push_back(model);
286 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 bool FGFDMExec::Run(void)
294 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
295 ChildFDMList[i]->AssignState( (FGPropagate*)Models[ePropagate] ); // Transfer state to the child FDM
296 ChildFDMList[i]->Run();
299 if (firstPass && !IntegrationSuspended()) {
300 // Outputs the initial conditions
301 for (unsigned int i = 0; i < Outputs.size(); i++)
302 Outputs[i]->Run(holding);
309 // returns true if success, false if complete
310 if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript();
312 for (unsigned int i = 0; i < Models.size(); i++) {
314 Models[i]->Run(holding);
317 if (Terminate) success = false;
322 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
324 void FGFDMExec::LoadInputs(unsigned int idx)
328 Propagate->in.vPQRidot = Accelerations->GetPQRidot();
329 Propagate->in.vQtrndot = Accelerations->GetQuaterniondot();
330 Propagate->in.vUVWidot = Accelerations->GetUVWidot();
331 Propagate->in.DeltaT = dT;
336 Inertial->in.Radius = Propagate->GetRadius();
337 Inertial->in.Latitude = Propagate->GetLatitude();
340 Atmosphere->in.altitudeASL = Propagate->GetAltitudeASL();
343 Winds->in.AltitudeASL = Propagate->GetAltitudeASL();
344 Winds->in.DistanceAGL = Propagate->GetDistanceAGL();
345 Winds->in.Tl2b = Propagate->GetTl2b();
346 Winds->in.Tw2b = Auxiliary->GetTw2b();
347 Winds->in.V = Auxiliary->GetVt();
348 Winds->in.totalDeltaT = dT * Winds->GetRate();
351 Auxiliary->in.Pressure = Atmosphere->GetPressure();
352 Auxiliary->in.Density = Atmosphere->GetDensity();
353 Auxiliary->in.DensitySL = Atmosphere->GetDensitySL();
354 Auxiliary->in.PressureSL = Atmosphere->GetPressureSL();
355 Auxiliary->in.Temperature = Atmosphere->GetTemperature();
356 Auxiliary->in.SoundSpeed = Atmosphere->GetSoundSpeed();
357 Auxiliary->in.KinematicViscosity = Atmosphere->GetKinematicViscosity();
358 Auxiliary->in.DistanceAGL = Propagate->GetDistanceAGL();
359 Auxiliary->in.Mass = MassBalance->GetMass();
360 Auxiliary->in.Tl2b = Propagate->GetTl2b();
361 Auxiliary->in.Tb2l = Propagate->GetTb2l();
362 Auxiliary->in.vPQR = Propagate->GetPQR();
363 Auxiliary->in.vPQRdot = Accelerations->GetPQRdot();
364 Auxiliary->in.vUVW = Propagate->GetUVW();
365 Auxiliary->in.vUVWdot = Accelerations->GetUVWdot();
366 Auxiliary->in.vVel = Propagate->GetVel();
367 Auxiliary->in.vBodyAccel = Accelerations->GetBodyAccel();
368 Auxiliary->in.ToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
369 Auxiliary->in.VRPBody = MassBalance->StructuralToBody(Aircraft->GetXYZvrp());
370 Auxiliary->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
371 Auxiliary->in.vFw = Aerodynamics->GetvFw();
372 Auxiliary->in.vLocation = Propagate->GetLocation();
373 Auxiliary->in.Latitude = Propagate->GetLatitude();
374 Auxiliary->in.Longitude = Propagate->GetLongitude();
375 Auxiliary->in.CosTht = Propagate->GetCosEuler(eTht);
376 Auxiliary->in.SinTht = Propagate->GetSinEuler(eTht);
377 Auxiliary->in.CosPhi = Propagate->GetCosEuler(ePhi);
378 Auxiliary->in.SinPhi = Propagate->GetSinEuler(ePhi);
379 Auxiliary->in.Psi = Propagate->GetEuler(ePsi);
380 Auxiliary->in.TotalWindNED = Winds->GetTotalWindNED();
381 Auxiliary->in.TurbPQR = Winds->GetTurbPQR();
382 Auxiliary->in.WindPsi = Winds->GetWindPsi();
383 Auxiliary->in.Vwind = Winds->GetTotalWindNED().Magnitude();
386 // Dynamic inputs come into the components that FCS manages through properties
389 Propulsion->in.SLPressure = Atmosphere->GetPressureSL();
390 Propulsion->in.Pressure = Atmosphere->GetPressure();
391 Propulsion->in.PressureRatio = Atmosphere->GetPressureRatio();
392 Propulsion->in.Temperature = Atmosphere->GetTemperature();
393 Propulsion->in.DensityRatio = Atmosphere->GetDensityRatio();
394 Propulsion->in.Density = Atmosphere->GetDensity();
395 Propulsion->in.Soundspeed = Atmosphere->GetSoundSpeed();
396 Propulsion->in.TotalPressure = Auxiliary->GetTotalPressure();
397 Propulsion->in.TotalTempearture = Auxiliary->GetTotalTemperature();
398 Propulsion->in.Vc = Auxiliary->GetVcalibratedKTS();
399 Propulsion->in.Vt = Auxiliary->GetVt();
400 Propulsion->in.qbar = Auxiliary->Getqbar();
401 Propulsion->in.TAT_c = Auxiliary->GetTAT_C();
402 Propulsion->in.AeroUVW = Auxiliary->GetAeroUVW();
403 Propulsion->in.AeroPQR = Auxiliary->GetAeroPQR();
404 Propulsion->in.alpha = Auxiliary->Getalpha();
405 Propulsion->in.beta = Auxiliary->Getbeta();
406 Propulsion->in.TotalDeltaT = dT * Propulsion->GetRate();
407 Propulsion->in.ThrottlePos = FCS->GetThrottlePos();
408 Propulsion->in.MixturePos = FCS->GetMixturePos();
409 Propulsion->in.ThrottleCmd = FCS->GetThrottleCmd();
410 Propulsion->in.MixtureCmd = FCS->GetMixtureCmd();
411 Propulsion->in.PropAdvance = FCS->GetPropAdvance();
412 Propulsion->in.PropFeather = FCS->GetPropFeather();
413 Propulsion->in.H_agl = Propagate->GetDistanceAGL();
414 Propulsion->in.PQR = Propagate->GetPQR();
417 Aerodynamics->in.Alpha = Auxiliary->Getalpha();
418 Aerodynamics->in.Beta = Auxiliary->Getbeta();
419 Aerodynamics->in.Qbar = Auxiliary->Getqbar();
420 Aerodynamics->in.Vt = Auxiliary->GetVt();
421 Aerodynamics->in.Tb2w = Auxiliary->GetTb2w();
422 Aerodynamics->in.Tw2b = Auxiliary->GetTw2b();
423 Aerodynamics->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
425 case eGroundReactions:
426 // There are no external inputs to this model.
427 GroundReactions->in.Vground = Auxiliary->GetVground();
428 GroundReactions->in.VcalibratedKts = Auxiliary->GetVcalibratedKTS();
429 GroundReactions->in.Temperature = Atmosphere->GetTemperature();
430 GroundReactions->in.TakeoffThrottle = (FCS->GetThrottlePos().size() > 0) ? (FCS->GetThrottlePos(0) > 0.90) : false;
431 GroundReactions->in.SteerPosDeg = FCS->GetSteerPosDeg();
432 GroundReactions->in.BrakePos = FCS->GetBrakePos();
433 GroundReactions->in.FCSGearPos = FCS->GetGearPos();
434 GroundReactions->in.EmptyWeight = MassBalance->GetEmptyWeight();
435 GroundReactions->in.Tb2l = Propagate->GetTb2l();
436 GroundReactions->in.Tec2l = Propagate->GetTec2l();
437 GroundReactions->in.Tec2b = Propagate->GetTec2b();
438 GroundReactions->in.PQR = Propagate->GetPQR();
439 GroundReactions->in.UVW = Propagate->GetUVW();
440 GroundReactions->in.DistanceAGL = Propagate->GetDistanceAGL();
441 GroundReactions->in.DistanceASL = Propagate->GetAltitudeASL();
442 GroundReactions->in.TotalDeltaT = dT * GroundReactions->GetRate();
443 GroundReactions->in.WOW = GroundReactions->GetWOW();
444 GroundReactions->in.Location = Propagate->GetLocation();
445 for (int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
446 GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
449 case eExternalReactions:
450 // There are no external inputs to this model.
453 BuoyantForces->in.Density = Atmosphere->GetDensity();
454 BuoyantForces->in.Pressure = Atmosphere->GetPressure();
455 BuoyantForces->in.Temperature = Atmosphere->GetTemperature();
456 BuoyantForces->in.gravity = Inertial->gravity();
459 MassBalance->in.GasInertia = BuoyantForces->GetGasMassInertia();
460 MassBalance->in.GasMass = BuoyantForces->GetGasMass();
461 MassBalance->in.GasMoment = BuoyantForces->GetGasMassMoment();
462 MassBalance->in.TanksWeight = Propulsion->GetTanksWeight();
463 MassBalance->in.TanksMoment = Propulsion->GetTanksMoment();
464 MassBalance->in.TankInertia = Propulsion->CalculateTankInertias();
467 Aircraft->in.AeroForce = Aerodynamics->GetForces();
468 Aircraft->in.PropForce = Propulsion->GetForces();
469 Aircraft->in.GroundForce = GroundReactions->GetForces();
470 Aircraft->in.ExternalForce = ExternalReactions->GetForces();
471 Aircraft->in.BuoyantForce = BuoyantForces->GetForces();
472 Aircraft->in.AeroMoment = Aerodynamics->GetMoments();
473 Aircraft->in.PropMoment = Propulsion->GetMoments();
474 Aircraft->in.GroundMoment = GroundReactions->GetMoments();
475 Aircraft->in.ExternalMoment = ExternalReactions->GetMoments();
476 Aircraft->in.BuoyantMoment = BuoyantForces->GetMoments();
477 Aircraft->in.Weight = MassBalance->GetWeight();
478 Aircraft->in.Tl2b = Propagate->GetTl2b();
481 Accelerations->in.J = MassBalance->GetJ();
482 Accelerations->in.Jinv = MassBalance->GetJinv();
483 Accelerations->in.Ti2b = Propagate->GetTi2b();
484 Accelerations->in.Tb2i = Propagate->GetTb2i();
485 Accelerations->in.Tec2b = Propagate->GetTec2b();
486 Accelerations->in.Tl2b = Propagate->GetTl2b();
487 Accelerations->in.qAttitudeECI = Propagate->GetQuaternionECI();
488 Accelerations->in.Moment = Aircraft->GetMoments();
489 Accelerations->in.GroundMoment = GroundReactions->GetMoments();
490 Accelerations->in.Force = Aircraft->GetForces();
491 Accelerations->in.GroundForce = GroundReactions->GetForces();
492 Accelerations->in.GAccel = Inertial->GetGAccel(Propagate->GetRadius());
493 Accelerations->in.J2Grav = Inertial->GetGravityJ2(Propagate->GetLocation());
494 Accelerations->in.vPQRi = Propagate->GetPQRi();
495 Accelerations->in.vPQR = Propagate->GetPQR();
496 Accelerations->in.vUVW = Propagate->GetUVW();
497 Accelerations->in.vInertialPosition = Propagate->GetInertialPosition();
498 Accelerations->in.DeltaT = dT;
499 Accelerations->in.Mass = MassBalance->GetMass();
500 Accelerations->in.MultipliersList = GroundReactions->GetMultipliersList();
501 Accelerations->in.TerrainVelocity = Propagate->GetTerrainVelocity();
502 Accelerations->in.TerrainAngularVel = Propagate->GetTerrainAngularVelocity();
509 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 void FGFDMExec::LoadPlanetConstants(void)
513 Propagate->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
514 Accelerations->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
515 Propagate->in.RefRadius = Inertial->GetRefRadius();
516 Propagate->in.SemiMajor = Inertial->GetSemimajor();
517 Propagate->in.SemiMinor = Inertial->GetSemiminor();
518 Auxiliary->in.SLGravity = Inertial->SLgravity();
519 Auxiliary->in.ReferenceRadius = Inertial->GetRefRadius();
522 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
524 void FGFDMExec::LoadModelConstants(void)
526 Winds->in.wingspan = Aircraft->GetWingSpan();
527 FCS->in.NumGear = GroundReactions->GetNumGearUnits();
528 Aerodynamics->in.Wingarea = Aircraft->GetWingArea();
529 Aerodynamics->in.Wingchord = Aircraft->Getcbar();
530 Aerodynamics->in.Wingincidence = Aircraft->GetWingIncidence();
531 Aerodynamics->in.Wingspan = Aircraft->GetWingSpan();
532 Auxiliary->in.Wingspan = Aircraft->GetWingSpan();
533 Auxiliary->in.Wingchord = Aircraft->Getcbar();
534 for (int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
535 GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
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 void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
621 delete GroundCallback;
625 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627 vector <string> FGFDMExec::EnumerateFDMs(void)
629 vector <string> FDMList;
630 FGAircraft* Aircraft = (FGAircraft*)Models[eAircraft];
632 FDMList.push_back(Aircraft->GetAircraftName());
634 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
635 FDMList.push_back(ChildFDMList[i]->exec->GetAircraft()->GetAircraftName());
641 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
643 bool FGFDMExec::LoadScript(const string& script, double deltaT)
647 Script = new FGScript(this);
648 result = Script->LoadScript(RootDir + script, deltaT);
653 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655 bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
656 const string& model, bool addModelToPath)
658 FGFDMExec::AircraftPath = RootDir + AircraftPath;
659 FGFDMExec::EnginePath = RootDir + EnginePath;
660 FGFDMExec::SystemsPath = RootDir + SystemsPath;
662 return LoadModel(model, addModelToPath);
665 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
667 bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
670 string aircraftCfgFileName;
671 Element* element = 0L;
672 bool result = false; // initialize result to false, indicating input file not yet read
674 modelName = model; // Set the class modelName attribute
676 if( AircraftPath.empty() || EnginePath.empty() || SystemsPath.empty()) {
677 cerr << "Error: attempted to load aircraft with undefined ";
678 cerr << "aircraft, engine, and system paths" << endl;
682 FullAircraftPath = AircraftPath;
683 if (addModelToPath) FullAircraftPath += "/" + model;
684 aircraftCfgFileName = FullAircraftPath + "/" + model + ".xml";
691 int saved_debug_lvl = debug_lvl;
693 document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
695 if (IsChild) debug_lvl = 0;
697 ReadPrologue(document);
699 if (IsChild) debug_lvl = saved_debug_lvl;
701 // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
702 element = document->FindElement("fileheader");
704 result = ReadFileHeader(element);
706 cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
711 if (IsChild) debug_lvl = 0;
713 // Process the metrics element. This element is REQUIRED.
714 element = document->FindElement("metrics");
716 result = ((FGAircraft*)Models[eAircraft])->Load(element);
718 cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
722 cerr << endl << "No metrics element was found in the aircraft config file." << endl;
726 // Process the mass_balance element. This element is REQUIRED.
727 element = document->FindElement("mass_balance");
729 result = ((FGMassBalance*)Models[eMassBalance])->Load(element);
731 cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
735 cerr << endl << "No mass_balance element was found in the aircraft config file." << endl;
739 // Process the ground_reactions element. This element is REQUIRED.
740 element = document->FindElement("ground_reactions");
742 result = ((FGGroundReactions*)Models[eGroundReactions])->Load(element);
744 cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl;
747 ((FGFCS*)Models[eSystems])->AddGear(((FGGroundReactions*)Models[eGroundReactions])->GetNumGearUnits());
749 cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
753 // Process the external_reactions element. This element is OPTIONAL.
754 element = document->FindElement("external_reactions");
756 result = ((FGExternalReactions*)Models[eExternalReactions])->Load(element);
758 cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
763 // Process the buoyant_forces element. This element is OPTIONAL.
764 element = document->FindElement("buoyant_forces");
766 result = ((FGBuoyantForces*)Models[eBuoyantForces])->Load(element);
768 cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
773 // Process the propulsion element. This element is OPTIONAL.
774 element = document->FindElement("propulsion");
776 result = ((FGPropulsion*)Models[ePropulsion])->Load(element);
778 cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
781 for (unsigned int i=0; i<((FGPropulsion*)Models[ePropulsion])->GetNumEngines(); i++)
782 ((FGFCS*)Models[eSystems])->AddThrottle();
785 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
786 element = document->FindElement("system");
788 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stSystem);
790 cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
793 element = document->FindNextElement("system");
796 // Process the autopilot element. This element is OPTIONAL.
797 element = document->FindElement("autopilot");
799 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stAutoPilot);
801 cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
806 // Process the flight_control element. This element is OPTIONAL.
807 element = document->FindElement("flight_control");
809 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stFCS);
811 cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
816 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
817 element = document->FindElement("aerodynamics");
819 result = ((FGAerodynamics*)Models[eAerodynamics])->Load(element);
821 cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
825 cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
828 // Process the input element. This element is OPTIONAL.
829 element = document->FindElement("input");
831 result = ((FGInput*)Models[eInput])->Load(element);
833 cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
838 // Process the output element[s]. This element is OPTIONAL, and there may be more than one.
840 typedef double (FGOutput::*iOPMF)(void) const;
841 typedef int (FGFDMExec::*iOPV)(void) const;
842 element = document->FindElement("output");
844 if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " ";
845 FGOutput* Output = new FGOutput(this);
848 result = Output->Load(element);
850 cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl;
853 Outputs.push_back(Output);
854 string outputProp = CreateIndexedPropertyName("simulation/output",idx);
855 instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
856 instance->Tie("simulation/force-output", this, (iOPV)0, &FGFDMExec::ForceOutput, false);
859 element = document->FindNextElement("output");
862 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
863 element = document->FindElement("child");
865 result = ReadChild(element);
867 cerr << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
872 // Since all vehicle characteristics have been loaded, place the values in the Inputs
873 // structure for the FGModel-derived classes.
874 LoadModelConstants();
879 LoadInputs(eMassBalance); // Update all input mass properties for the report.
880 Models[eMassBalance]->Run(false); // Update all mass properties for the report.
881 ((FGMassBalance*)Models[eMassBalance])->GetMassPropertiesReport();
883 cout << endl << fgblue << highint
884 << "End of vehicle configuration loading." << endl
885 << "-------------------------------------------------------------------------------"
889 if (IsChild) debug_lvl = saved_debug_lvl;
893 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
897 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
900 struct PropertyCatalogStructure masterPCS;
901 masterPCS.base_string = "";
902 masterPCS.node = (FGPropertyManager*)Root;
903 BuildPropertyCatalog(&masterPCS);
909 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
911 string FGFDMExec::GetPropulsionTankReport()
913 return ((FGPropulsion*)Models[ePropulsion])->GetPropulsionTankReport();
916 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918 void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
920 struct PropertyCatalogStructure* pcsNew = new struct PropertyCatalogStructure;
923 for (int i=0; i<pcs->node->nChildren(); i++) {
924 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
925 node_idx = pcs->node->getChild(i)->getIndex();
927 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
929 if (pcs->node->getChild(i)->nChildren() == 0) {
930 if (pcsNew->base_string.substr(0,11) == string("/fdm/jsbsim")) {
931 pcsNew->base_string = pcsNew->base_string.erase(0,12);
933 PropertyCatalog.push_back(pcsNew->base_string);
935 pcsNew->node = (FGPropertyManager*)pcs->node->getChild(i);
936 BuildPropertyCatalog(pcsNew);
942 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
944 string FGFDMExec::QueryPropertyCatalog(const string& in)
947 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
948 if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
950 if (results.empty()) return "No matches found\n";
954 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
956 void FGFDMExec::PrintPropertyCatalog(void)
959 cout << " " << fgblue << highint << underon << "Property Catalog for "
960 << modelName << reset << endl << endl;
961 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
962 cout << " " << PropertyCatalog[i] << endl;
966 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 bool FGFDMExec::ReadFileHeader(Element* el)
970 bool result = true; // true for success
972 if (debug_lvl == 0) return result;
975 cout << endl <<highint << fgblue << "Reading child model: " << IdFDM << reset << endl << endl;
978 if (el->FindElement("description"))
979 cout << " Description: " << el->FindElement("description")->GetDataLine() << endl;
980 if (el->FindElement("author"))
981 cout << " Model Author: " << el->FindElement("author")->GetDataLine() << endl;
982 if (el->FindElement("filecreationdate"))
983 cout << " Creation Date: " << el->FindElement("filecreationdate")->GetDataLine() << endl;
984 if (el->FindElement("version"))
985 cout << " Version: " << el->FindElement("version")->GetDataLine() << endl;
990 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
992 bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document element
994 bool result = true; // true for success
996 if (!el) return false;
998 string AircraftName = el->GetAttributeValue("name");
999 ((FGAircraft*)Models[eAircraft])->SetAircraftName(AircraftName);
1001 if (debug_lvl & 1) cout << underon << "Reading Aircraft Configuration File"
1002 << underoff << ": " << highint << AircraftName << normint << endl;
1004 CFGVersion = el->GetAttributeValue("version");
1005 Release = el->GetAttributeValue("release");
1008 cout << " Version: " << highint << CFGVersion
1010 if (CFGVersion != needed_cfg_version) {
1011 cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
1012 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
1013 cerr << "Current version needed is: " << needed_cfg_version << endl;
1014 cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
1018 if (Release == "ALPHA" && (debug_lvl & 1)) {
1019 cout << endl << endl
1020 << highint << "This aircraft model is an " << fgred << Release
1021 << reset << highint << " release!!!" << endl << endl << reset
1022 << "This aircraft model may not even properly load, and probably"
1023 << " will not fly as expected." << endl << endl
1024 << fgred << highint << "Use this model for development purposes ONLY!!!"
1025 << normint << reset << endl << endl;
1026 } else if (Release == "BETA" && (debug_lvl & 1)) {
1027 cout << endl << endl
1028 << highint << "This aircraft model is a " << fgred << Release
1029 << reset << highint << " release!!!" << endl << endl << reset
1030 << "This aircraft model probably will not fly as expected." << endl << endl
1031 << fgblue << highint << "Use this model for development purposes ONLY!!!"
1032 << normint << reset << endl << endl;
1033 } else if (Release == "PRODUCTION" && (debug_lvl & 1)) {
1034 cout << endl << endl
1035 << highint << "This aircraft model is a " << fgblue << Release
1036 << reset << highint << " release." << endl << endl << reset;
1037 } else if (debug_lvl & 1) {
1038 cout << endl << endl
1039 << highint << "This aircraft model is an " << fgred << Release
1040 << reset << highint << " release!!!" << endl << endl << reset
1041 << "This aircraft model may not even properly load, and probably"
1042 << " will not fly as expected." << endl << endl
1043 << fgred << highint << "Use this model for development purposes ONLY!!!"
1044 << normint << reset << endl << endl;
1050 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1052 bool FGFDMExec::ReadChild(Element* el)
1054 // Add a new childData object to the child FDM list
1055 // Populate that childData element with a new FDMExec object
1056 // Set the IsChild flag for that FDMExec object
1057 // Get the aircraft name
1058 // set debug level to print out no additional data for child objects
1059 // Load the model given the aircraft name
1060 // reset debug level to prior setting
1064 struct childData* child = new childData;
1066 child->exec = new FGFDMExec(Root, FDMctr);
1067 child->exec->SetChild(true);
1069 string childAircraft = el->GetAttributeValue("name");
1070 string sMated = el->GetAttributeValue("mated");
1071 if (sMated == "false") child->mated = false; // child objects are mated by default.
1072 string sInternal = el->GetAttributeValue("internal");
1073 if (sInternal == "true") child->internal = true; // child objects are external by default.
1075 child->exec->SetAircraftPath( AircraftPath );
1076 child->exec->SetEnginePath( EnginePath );
1077 child->exec->SetSystemsPath( SystemsPath );
1078 child->exec->LoadModel(childAircraft);
1080 Element* location = el->FindElement("location");
1082 child->Loc = location->FindElementTripletConvertTo("IN");
1084 cerr << endl << highint << fgred << " No location was found for this child object!" << reset << endl;
1088 Element* orientation = el->FindElement("orient");
1090 child->Orient = orientation->FindElementTripletConvertTo("RAD");
1091 } else if (debug_lvl > 0) {
1092 cerr << endl << highint << " No orientation was found for this child object! Assuming 0,0,0." << reset << endl;
1095 ChildFDMList.push_back(child);
1100 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1102 FGPropertyManager* FGFDMExec::GetPropertyManager(void)
1107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1109 FGTrim* FGFDMExec::GetTrim(void)
1112 Trim = new FGTrim(this,tNone);
1116 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1118 void FGFDMExec::DisableOutput(void)
1120 for (unsigned i=0; i<Outputs.size(); i++) {
1121 Outputs[i]->Disable();
1125 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1127 void FGFDMExec::EnableOutput(void)
1129 for (unsigned i=0; i<Outputs.size(); i++) {
1130 Outputs[i]->Enable();
1134 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1136 void FGFDMExec::ForceOutput(int idx)
1138 if (idx >= (int)0 && idx < (int)Outputs.size()) Outputs[idx]->Print();
1141 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1143 bool FGFDMExec::SetOutputDirectives(const string& fname)
1147 FGOutput* Output = new FGOutput(this);
1148 Output->SetDirectivesFile(RootDir + fname);
1149 Output->InitModel();
1151 result = Output->Load(0);
1154 Output->Run(holding);
1155 Outputs.push_back(Output);
1156 typedef double (FGOutput::*iOPMF)(void) const;
1157 string outputProp = CreateIndexedPropertyName("simulation/output",Outputs.size()-1);
1158 instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
1166 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1168 void FGFDMExec::DoTrim(int mode)
1172 if (Constructing) return;
1174 if (mode < 0 || mode > JSBSim::tNone) {
1175 cerr << endl << "Illegal trimming mode!" << endl << endl;
1178 saved_time = sim_time;
1179 FGTrim trim(this, (JSBSim::TrimMode)mode);
1180 if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
1182 sim_time = saved_time;
1185 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1186 // The bitmasked value choices are as follows:
1187 // unset: In this case (the default) JSBSim would only print
1188 // out the normally expected messages, essentially echoing
1189 // the config files as they are read. If the environment
1190 // variable is not set, debug_lvl is set to 1 internally
1191 // 0: This requests JSBSim not to output any messages
1193 // 1: This value explicity requests the normal JSBSim
1195 // 2: This value asks for a message to be printed out when
1196 // a class is instantiated
1197 // 4: When this value is set, a message is displayed when a
1198 // FGModel object executes its Run() method
1199 // 8: When this value is set, various runtime state variables
1200 // are printed out periodically
1201 // 16: When set various parameters are sanity checked and
1202 // a message is printed out when they go out of bounds
1204 void FGFDMExec::Debug(int from)
1206 if (debug_lvl <= 0) return;
1208 if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output
1209 if (from == 0) { // Constructor
1211 << "JSBSim Flight Dynamics Model v" << JSBSim_version << endl;
1212 cout << " [JSBSim-ML v" << needed_cfg_version << "]\n\n";
1213 cout << "JSBSim startup beginning ...\n\n";
1214 } else if (from == 3) {
1215 cout << "\n\nJSBSim startup complete\n\n";
1218 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1219 if (from == 0) cout << "Instantiated: FGFDMExec" << endl;
1220 if (from == 1) cout << "Destroyed: FGFDMExec" << endl;
1222 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1224 cout << "================== Frame: " << Frame << " Time: "
1225 << sim_time << " dt: " << dT << endl;
1228 if (debug_lvl & 8 ) { // Runtime state variables
1230 if (debug_lvl & 16) { // Sanity checking
1232 if (debug_lvl & 64) {
1233 if (from == 0) { // Constructor
1234 cout << IdSrc << endl;
1235 cout << IdHdr << endl;