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.113 2011/09/07 02:37:04 jberndt Exp $";
74 static const char *IdHdr = ID_FDMEXEC;
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
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)--;
192 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194 bool FGFDMExec::Allocate(void)
198 Models.resize(eNumStandardModels);
200 // See the eModels enum specification in the header file. The order of the enums
201 // specifies the order of execution. The Models[] vector is the primary
202 // storage array for the list of models.
203 Models[ePropagate] = new FGPropagate(this);
204 Models[eInput] = new FGInput(this);
205 Models[eInertial] = new FGInertial(this);
206 Models[eAtmosphere] = new FGStandardAtmosphere(this);
207 Models[eWinds] = new FGWinds(this);
208 Models[eAuxiliary] = new FGAuxiliary(this);
209 Models[eSystems] = new FGFCS(this);
210 Models[ePropulsion] = new FGPropulsion(this);
211 Models[eAerodynamics] = new FGAerodynamics (this);
213 GroundCallback = new FGGroundCallback(((FGInertial*)Models[eInertial])->GetRefRadius());
215 Models[eGroundReactions] = new FGGroundReactions(this);
216 Models[eExternalReactions] = new FGExternalReactions(this);
217 Models[eBuoyantForces] = new FGBuoyantForces(this);
218 Models[eMassBalance] = new FGMassBalance(this);
219 Models[eAircraft] = new FGAircraft(this);
220 Models[eAccelerations] = new FGAccelerations(this);
222 // Assign the Model shortcuts for internal executive use only.
223 Propagate = (FGPropagate*)Models[ePropagate];
224 Inertial = (FGInertial*)Models[eInertial];
225 Atmosphere = (FGAtmosphere*)Models[eAtmosphere];
226 Winds = (FGWinds*)Models[eWinds];
227 Auxiliary = (FGAuxiliary*)Models[eAuxiliary];
228 FCS = (FGFCS*)Models[eSystems];
229 Propulsion = (FGPropulsion*)Models[ePropulsion];
230 Aerodynamics = (FGAerodynamics*)Models[eAerodynamics];
231 GroundReactions = (FGGroundReactions*)Models[eGroundReactions];
232 ExternalReactions = (FGExternalReactions*)Models[eExternalReactions];
233 BuoyantForces = (FGBuoyantForces*)Models[eBuoyantForces];
234 MassBalance = (FGMassBalance*)Models[eMassBalance];
235 Aircraft = (FGAircraft*)Models[eAircraft];
236 Accelerations = (FGAccelerations*)Models[eAccelerations];
238 // Initialize planet (environment) constants
239 LoadPlanetConstants();
242 for (unsigned int i = 0; i < Models.size(); i++) {
244 Models[i]->InitModel();
247 IC = new FGInitialCondition(this);
254 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 bool FGFDMExec::DeAllocate(void)
259 for (unsigned int i=0; i<eNumStandardModels; i++) delete Models[i];
262 for (unsigned i=0; i<Outputs.size(); i++) delete Outputs[i];
269 delete GroundCallback;
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279 void FGFDMExec::Schedule(FGModel* model, int rate)
281 model->SetRate(rate);
282 Models.push_back(model);
285 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 bool FGFDMExec::Run(void)
293 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
294 ChildFDMList[i]->AssignState( (FGPropagate*)Models[ePropagate] ); // Transfer state to the child FDM
295 ChildFDMList[i]->Run();
298 if (firstPass && !IntegrationSuspended()) {
299 // Outputs the initial conditions
300 for (unsigned int i = 0; i < Outputs.size(); i++)
301 Outputs[i]->Run(holding);
306 // returns true if success, false if complete
307 if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript();
311 for (unsigned int i = 0; i < Models.size(); i++) {
313 Models[i]->Run(holding);
316 if (Terminate) success = false;
321 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323 void FGFDMExec::LoadInputs(unsigned int idx)
327 Propagate->in.vPQRidot = Accelerations->GetPQRidot();
328 Propagate->in.vQtrndot = Accelerations->GetQuaterniondot();
329 Propagate->in.vUVWidot = Accelerations->GetUVWidot();
330 Propagate->in.DeltaT = dT;
335 Inertial->in.Radius = Propagate->GetRadius();
336 Inertial->in.Latitude = Propagate->GetLatitude();
339 Atmosphere->in.altitudeASL = Propagate->GetAltitudeASL();
342 Winds->in.AltitudeASL = Propagate->GetAltitudeASL();
343 Winds->in.DistanceAGL = Propagate->GetDistanceAGL();
344 Winds->in.Tl2b = Propagate->GetTl2b();
345 Winds->in.Tw2b = Auxiliary->GetTw2b();
346 Winds->in.V = Auxiliary->GetVt();
347 Winds->in.totalDeltaT = dT * Winds->GetRate();
350 Auxiliary->in.Pressure = Atmosphere->GetPressure();
351 Auxiliary->in.Density = Atmosphere->GetDensity();
352 Auxiliary->in.DensitySL = Atmosphere->GetDensitySL();
353 Auxiliary->in.PressureSL = Atmosphere->GetPressureSL();
354 Auxiliary->in.Temperature = Atmosphere->GetTemperature();
355 Auxiliary->in.SoundSpeed = Atmosphere->GetSoundSpeed();
356 Auxiliary->in.KinematicViscosity = Atmosphere->GetKinematicViscosity();
357 Auxiliary->in.DistanceAGL = Propagate->GetDistanceAGL();
358 Auxiliary->in.Mass = MassBalance->GetMass();
359 Auxiliary->in.Tl2b = Propagate->GetTl2b();
360 Auxiliary->in.Tb2l = Propagate->GetTb2l();
361 Auxiliary->in.vPQR = Propagate->GetPQR();
362 Auxiliary->in.vPQRdot = Accelerations->GetPQRdot();
363 Auxiliary->in.vUVW = Propagate->GetUVW();
364 Auxiliary->in.vUVWdot = Accelerations->GetUVWdot();
365 Auxiliary->in.vVel = Propagate->GetVel();
366 Auxiliary->in.vBodyAccel = Accelerations->GetBodyAccel();
367 Auxiliary->in.ToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
368 Auxiliary->in.VRPBody = MassBalance->StructuralToBody(Aircraft->GetXYZvrp());
369 Auxiliary->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
370 Auxiliary->in.vFw = Aerodynamics->GetvFw();
371 Auxiliary->in.vLocation = Propagate->GetLocation();
372 Auxiliary->in.Latitude = Propagate->GetLatitude();
373 Auxiliary->in.Longitude = Propagate->GetLongitude();
374 Auxiliary->in.CosTht = Propagate->GetCosEuler(eTht);
375 Auxiliary->in.SinTht = Propagate->GetSinEuler(eTht);
376 Auxiliary->in.CosPhi = Propagate->GetCosEuler(ePhi);
377 Auxiliary->in.SinPhi = Propagate->GetSinEuler(ePhi);
378 Auxiliary->in.Psi = Propagate->GetEuler(ePsi);
379 Auxiliary->in.TotalWindNED = Winds->GetTotalWindNED();
380 Auxiliary->in.TurbPQR = Winds->GetTurbPQR();
381 Auxiliary->in.WindPsi = Winds->GetWindPsi();
382 Auxiliary->in.Vwind = Winds->GetTotalWindNED().Magnitude();
385 // Dynamic inputs come into the components that FCS manages through properties
388 Propulsion->in.SLPressure = Atmosphere->GetPressureSL();
389 Propulsion->in.Pressure = Atmosphere->GetPressure();
390 Propulsion->in.PressureRatio = Atmosphere->GetPressureRatio();
391 Propulsion->in.Temperature = Atmosphere->GetTemperature();
392 Propulsion->in.DensityRatio = Atmosphere->GetDensityRatio();
393 Propulsion->in.Density = Atmosphere->GetDensity();
394 Propulsion->in.Soundspeed = Atmosphere->GetSoundSpeed();
395 Propulsion->in.TotalPressure = Auxiliary->GetTotalPressure();
396 Propulsion->in.TotalTempearture = Auxiliary->GetTotalTemperature();
397 Propulsion->in.Vc = Auxiliary->GetVcalibratedKTS();
398 Propulsion->in.Vt = Auxiliary->GetVt();
399 Propulsion->in.qbar = Auxiliary->Getqbar();
400 Propulsion->in.TAT_c = Auxiliary->GetTAT_C();
401 Propulsion->in.AeroUVW = Auxiliary->GetAeroUVW();
402 Propulsion->in.AeroPQR = Auxiliary->GetAeroPQR();
403 Propulsion->in.alpha = Auxiliary->Getalpha();
404 Propulsion->in.beta = Auxiliary->Getbeta();
405 Propulsion->in.TotalDeltaT = dT * Propulsion->GetRate();
406 Propulsion->in.ThrottlePos = FCS->GetThrottlePos();
407 Propulsion->in.MixturePos = FCS->GetMixturePos();
408 Propulsion->in.ThrottleCmd = FCS->GetThrottleCmd();
409 Propulsion->in.MixtureCmd = FCS->GetMixtureCmd();
410 Propulsion->in.PropAdvance = FCS->GetPropAdvance();
411 Propulsion->in.PropFeather = FCS->GetPropFeather();
412 Propulsion->in.H_agl = Propagate->GetDistanceAGL();
413 Propulsion->in.PQR = Propagate->GetPQR();
416 Aerodynamics->in.Alpha = Auxiliary->Getalpha();
417 Aerodynamics->in.Beta = Auxiliary->Getbeta();
418 Aerodynamics->in.Qbar = Auxiliary->Getqbar();
419 Aerodynamics->in.Vt = Auxiliary->GetVt();
420 Aerodynamics->in.Tb2w = Auxiliary->GetTb2w();
421 Aerodynamics->in.Tw2b = Auxiliary->GetTw2b();
422 Aerodynamics->in.RPBody = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
424 case eGroundReactions:
425 // There are no external inputs to this model.
426 GroundReactions->in.Vground = Auxiliary->GetVground();
427 GroundReactions->in.VcalibratedKts = Auxiliary->GetVcalibratedKTS();
428 GroundReactions->in.Temperature = Atmosphere->GetTemperature();
429 GroundReactions->in.TakeoffThrottle = (FCS->GetThrottlePos().size() > 0) ? (FCS->GetThrottlePos(0) > 0.90) : false;
430 GroundReactions->in.SteerPosDeg = FCS->GetSteerPosDeg();
431 GroundReactions->in.BrakePos = FCS->GetBrakePos();
432 GroundReactions->in.FCSGearPos = FCS->GetGearPos();
433 GroundReactions->in.EmptyWeight = MassBalance->GetEmptyWeight();
434 GroundReactions->in.Tb2l = Propagate->GetTb2l();
435 GroundReactions->in.Tec2l = Propagate->GetTec2l();
436 GroundReactions->in.Tec2b = Propagate->GetTec2b();
437 GroundReactions->in.PQR = Propagate->GetPQR();
438 GroundReactions->in.UVW = Propagate->GetUVW();
439 GroundReactions->in.DistanceAGL = Propagate->GetDistanceAGL();
440 GroundReactions->in.DistanceASL = Propagate->GetAltitudeASL();
441 GroundReactions->in.TotalDeltaT = dT * GroundReactions->GetRate();
442 GroundReactions->in.WOW = GroundReactions->GetWOW();
443 GroundReactions->in.Location = Propagate->GetLocation();
444 for (unsigned int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
445 GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
448 case eExternalReactions:
449 // There are no external inputs to this model.
452 BuoyantForces->in.Density = Atmosphere->GetDensity();
453 BuoyantForces->in.Pressure = Atmosphere->GetPressure();
454 BuoyantForces->in.Temperature = Atmosphere->GetTemperature();
455 BuoyantForces->in.gravity = Inertial->gravity();
458 MassBalance->in.GasInertia = BuoyantForces->GetGasMassInertia();
459 MassBalance->in.GasMass = BuoyantForces->GetGasMass();
460 MassBalance->in.GasMoment = BuoyantForces->GetGasMassMoment();
461 MassBalance->in.TanksWeight = Propulsion->GetTanksWeight();
462 MassBalance->in.TanksMoment = Propulsion->GetTanksMoment();
463 MassBalance->in.TankInertia = Propulsion->CalculateTankInertias();
466 Aircraft->in.AeroForce = Aerodynamics->GetForces();
467 Aircraft->in.PropForce = Propulsion->GetForces();
468 Aircraft->in.GroundForce = GroundReactions->GetForces();
469 Aircraft->in.ExternalForce = ExternalReactions->GetForces();
470 Aircraft->in.BuoyantForce = BuoyantForces->GetForces();
471 Aircraft->in.AeroMoment = Aerodynamics->GetMoments();
472 Aircraft->in.PropMoment = Propulsion->GetMoments();
473 Aircraft->in.GroundMoment = GroundReactions->GetMoments();
474 Aircraft->in.ExternalMoment = ExternalReactions->GetMoments();
475 Aircraft->in.BuoyantMoment = BuoyantForces->GetMoments();
476 Aircraft->in.Weight = MassBalance->GetWeight();
477 Aircraft->in.Tl2b = Propagate->GetTl2b();
480 Accelerations->in.J = MassBalance->GetJ();
481 Accelerations->in.Jinv = MassBalance->GetJinv();
482 Accelerations->in.Ti2b = Propagate->GetTi2b();
483 Accelerations->in.Tb2i = Propagate->GetTb2i();
484 Accelerations->in.Tec2b = Propagate->GetTec2b();
485 Accelerations->in.Tl2b = Propagate->GetTl2b();
486 Accelerations->in.qAttitudeECI = Propagate->GetQuaternionECI();
487 Accelerations->in.Moment = Aircraft->GetMoments();
488 Accelerations->in.GroundMoment = GroundReactions->GetMoments();
489 Accelerations->in.Force = Aircraft->GetForces();
490 Accelerations->in.GroundForce = GroundReactions->GetForces();
491 Accelerations->in.GAccel = Inertial->GetGAccel(Propagate->GetRadius());
492 Accelerations->in.J2Grav = Inertial->GetGravityJ2(Propagate->GetLocation());
493 Accelerations->in.vPQRi = Propagate->GetPQRi();
494 Accelerations->in.vPQR = Propagate->GetPQR();
495 Accelerations->in.vUVW = Propagate->GetUVW();
496 Accelerations->in.vInertialPosition = Propagate->GetInertialPosition();
497 Accelerations->in.DeltaT = dT;
498 Accelerations->in.Mass = MassBalance->GetMass();
499 Accelerations->in.MultipliersList = GroundReactions->GetMultipliersList();
500 Accelerations->in.TerrainVelocity = Propagate->GetTerrainVelocity();
501 Accelerations->in.TerrainAngularVel = Propagate->GetTerrainAngularVelocity();
508 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510 void FGFDMExec::LoadPlanetConstants(void)
512 Propagate->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
513 Accelerations->in.vOmegaPlanet = Inertial->GetOmegaPlanet();
514 Propagate->in.RefRadius = Inertial->GetRefRadius();
515 Propagate->in.SemiMajor = Inertial->GetSemimajor();
516 Propagate->in.SemiMinor = Inertial->GetSemiminor();
517 Auxiliary->in.SLGravity = Inertial->SLgravity();
518 Auxiliary->in.ReferenceRadius = Inertial->GetRefRadius();
521 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
523 void FGFDMExec::LoadModelConstants(void)
525 Winds->in.wingspan = Aircraft->GetWingSpan();
526 FCS->in.NumGear = GroundReactions->GetNumGearUnits();
527 Aerodynamics->in.Wingarea = Aircraft->GetWingArea();
528 Aerodynamics->in.Wingchord = Aircraft->Getcbar();
529 Aerodynamics->in.Wingincidence = Aircraft->GetWingIncidence();
530 Aerodynamics->in.Wingspan = Aircraft->GetWingSpan();
531 Auxiliary->in.Wingspan = Aircraft->GetWingSpan();
532 Auxiliary->in.Wingchord = Aircraft->Getcbar();
533 for (unsigned int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
534 GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
537 LoadPlanetConstants();
540 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
541 // This call will cause the sim time to reset to 0.0
543 bool FGFDMExec::RunIC(void)
545 SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
548 ResumeIntegration(); // Restores the integration rate to what it was.
553 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 void FGFDMExec::Initialize(FGInitialCondition *FGIC)
559 Propagate->SetInitialState( FGIC );
560 LoadInputs(eAccelerations);
561 Accelerations->Run(false);
562 LoadInputs(ePropagate);
563 Propagate->InitializeDerivatives();
564 LoadInputs(eAtmosphere);
565 Atmosphere->Run(false);
566 Winds->SetWindNED( FGIC->GetWindNFpsIC(),
567 FGIC->GetWindEFpsIC(),
568 FGIC->GetWindDFpsIC() );
569 Auxiliary->Run(false);
572 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
574 // A private, internal function call for Tie-ing to a property, so it needs an
577 void FGFDMExec::ResetToInitialConditions(int mode)
580 for (unsigned int i=0; i<Outputs.size(); i++) {
581 Outputs[i]->SetStartNewFile(true);
585 ResetToInitialConditions();
588 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590 void FGFDMExec::ResetToInitialConditions(void)
592 if (Constructing) return;
594 vector <FGModel*>::iterator it;
595 for (it = Models.begin(); it != Models.end(); ++it) (*it)->InitModel();
598 if (Script) Script->ResetEvents();
601 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
603 bool FGFDMExec::SetOutputFileName(const string& fname)
605 if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
610 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612 string FGFDMExec::GetOutputFileName(void)
614 if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
615 else return string("");
618 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
620 void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
622 delete GroundCallback;
626 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 vector <string> FGFDMExec::EnumerateFDMs(void)
630 vector <string> FDMList;
631 FGAircraft* Aircraft = (FGAircraft*)Models[eAircraft];
633 FDMList.push_back(Aircraft->GetAircraftName());
635 for (unsigned int i=1; i<ChildFDMList.size(); i++) {
636 FDMList.push_back(ChildFDMList[i]->exec->GetAircraft()->GetAircraftName());
642 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644 bool FGFDMExec::LoadScript(const string& script, double deltaT)
648 Script = new FGScript(this);
649 result = Script->LoadScript(RootDir + script, deltaT);
654 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656 bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
657 const string& model, bool addModelToPath)
659 FGFDMExec::AircraftPath = RootDir + AircraftPath;
660 FGFDMExec::EnginePath = RootDir + EnginePath;
661 FGFDMExec::SystemsPath = RootDir + SystemsPath;
663 return LoadModel(model, addModelToPath);
666 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
668 bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
671 string aircraftCfgFileName;
672 Element* element = 0L;
673 bool result = false; // initialize result to false, indicating input file not yet read
675 modelName = model; // Set the class modelName attribute
677 if( AircraftPath.empty() || EnginePath.empty() || SystemsPath.empty()) {
678 cerr << "Error: attempted to load aircraft with undefined ";
679 cerr << "aircraft, engine, and system paths" << endl;
683 FullAircraftPath = AircraftPath;
684 if (addModelToPath) FullAircraftPath += "/" + model;
685 aircraftCfgFileName = FullAircraftPath + "/" + model + ".xml";
692 int saved_debug_lvl = debug_lvl;
694 document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
696 if (IsChild) debug_lvl = 0;
698 ReadPrologue(document);
700 if (IsChild) debug_lvl = saved_debug_lvl;
702 // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
703 element = document->FindElement("fileheader");
705 result = ReadFileHeader(element);
707 cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
712 if (IsChild) debug_lvl = 0;
714 // Process the metrics element. This element is REQUIRED.
715 element = document->FindElement("metrics");
717 result = ((FGAircraft*)Models[eAircraft])->Load(element);
719 cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
723 cerr << endl << "No metrics element was found in the aircraft config file." << endl;
727 // Process the mass_balance element. This element is REQUIRED.
728 element = document->FindElement("mass_balance");
730 result = ((FGMassBalance*)Models[eMassBalance])->Load(element);
732 cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
736 cerr << endl << "No mass_balance element was found in the aircraft config file." << endl;
740 // Process the ground_reactions element. This element is REQUIRED.
741 element = document->FindElement("ground_reactions");
743 result = ((FGGroundReactions*)Models[eGroundReactions])->Load(element);
745 cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl;
748 ((FGFCS*)Models[eSystems])->AddGear(((FGGroundReactions*)Models[eGroundReactions])->GetNumGearUnits());
750 cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
754 // Process the external_reactions element. This element is OPTIONAL.
755 element = document->FindElement("external_reactions");
757 result = ((FGExternalReactions*)Models[eExternalReactions])->Load(element);
759 cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
764 // Process the buoyant_forces element. This element is OPTIONAL.
765 element = document->FindElement("buoyant_forces");
767 result = ((FGBuoyantForces*)Models[eBuoyantForces])->Load(element);
769 cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
774 // Process the propulsion element. This element is OPTIONAL.
775 element = document->FindElement("propulsion");
777 result = ((FGPropulsion*)Models[ePropulsion])->Load(element);
779 cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
782 for (unsigned int i=0; i<((FGPropulsion*)Models[ePropulsion])->GetNumEngines(); i++)
783 ((FGFCS*)Models[eSystems])->AddThrottle();
786 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
787 element = document->FindElement("system");
789 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stSystem);
791 cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
794 element = document->FindNextElement("system");
797 // Process the autopilot element. This element is OPTIONAL.
798 element = document->FindElement("autopilot");
800 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stAutoPilot);
802 cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
807 // Process the flight_control element. This element is OPTIONAL.
808 element = document->FindElement("flight_control");
810 result = ((FGFCS*)Models[eSystems])->Load(element, FGFCS::stFCS);
812 cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
817 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
818 element = document->FindElement("aerodynamics");
820 result = ((FGAerodynamics*)Models[eAerodynamics])->Load(element);
822 cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
826 cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
829 // Process the input element. This element is OPTIONAL.
830 element = document->FindElement("input");
832 result = ((FGInput*)Models[eInput])->Load(element);
834 cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
839 // Process the output element[s]. This element is OPTIONAL, and there may be more than one.
841 typedef double (FGOutput::*iOPMF)(void) const;
842 typedef int (FGFDMExec::*iOPV)(void) const;
843 element = document->FindElement("output");
845 if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " ";
846 FGOutput* Output = new FGOutput(this);
849 result = Output->Load(element);
851 cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl;
854 Outputs.push_back(Output);
855 string outputProp = CreateIndexedPropertyName("simulation/output",idx);
856 instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
857 instance->Tie("simulation/force-output", this, (iOPV)0, &FGFDMExec::ForceOutput, false);
860 element = document->FindNextElement("output");
863 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
864 element = document->FindElement("child");
866 result = ReadChild(element);
868 cerr << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
873 // Since all vehicle characteristics have been loaded, place the values in the Inputs
874 // structure for the FGModel-derived classes.
875 LoadModelConstants();
880 LoadInputs(eMassBalance); // Update all input mass properties for the report.
881 Models[eMassBalance]->Run(false); // Update all mass properties for the report.
882 ((FGMassBalance*)Models[eMassBalance])->GetMassPropertiesReport();
884 cout << endl << fgblue << highint
885 << "End of vehicle configuration loading." << endl
886 << "-------------------------------------------------------------------------------"
890 if (IsChild) debug_lvl = saved_debug_lvl;
894 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
898 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
901 struct PropertyCatalogStructure masterPCS;
902 masterPCS.base_string = "";
903 masterPCS.node = (FGPropertyManager*)Root;
904 BuildPropertyCatalog(&masterPCS);
910 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912 string FGFDMExec::GetPropulsionTankReport()
914 return ((FGPropulsion*)Models[ePropulsion])->GetPropulsionTankReport();
917 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
919 void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
921 struct PropertyCatalogStructure* pcsNew = new struct PropertyCatalogStructure;
924 for (int i=0; i<pcs->node->nChildren(); i++) {
925 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
926 node_idx = pcs->node->getChild(i)->getIndex();
928 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
930 if (pcs->node->getChild(i)->nChildren() == 0) {
931 if (pcsNew->base_string.substr(0,11) == string("/fdm/jsbsim")) {
932 pcsNew->base_string = pcsNew->base_string.erase(0,12);
934 PropertyCatalog.push_back(pcsNew->base_string);
936 pcsNew->node = (FGPropertyManager*)pcs->node->getChild(i);
937 BuildPropertyCatalog(pcsNew);
943 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
945 string FGFDMExec::QueryPropertyCatalog(const string& in)
948 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
949 if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
951 if (results.empty()) return "No matches found\n";
955 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
957 void FGFDMExec::PrintPropertyCatalog(void)
960 cout << " " << fgblue << highint << underon << "Property Catalog for "
961 << modelName << reset << endl << endl;
962 for (unsigned i=0; i<PropertyCatalog.size(); i++) {
963 cout << " " << PropertyCatalog[i] << endl;
967 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 bool FGFDMExec::ReadFileHeader(Element* el)
971 bool result = true; // true for success
973 if (debug_lvl == 0) return result;
976 cout << endl <<highint << fgblue << "Reading child model: " << IdFDM << reset << endl << endl;
979 if (el->FindElement("description"))
980 cout << " Description: " << el->FindElement("description")->GetDataLine() << endl;
981 if (el->FindElement("author"))
982 cout << " Model Author: " << el->FindElement("author")->GetDataLine() << endl;
983 if (el->FindElement("filecreationdate"))
984 cout << " Creation Date: " << el->FindElement("filecreationdate")->GetDataLine() << endl;
985 if (el->FindElement("version"))
986 cout << " Version: " << el->FindElement("version")->GetDataLine() << endl;
991 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993 bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document element
995 bool result = true; // true for success
997 if (!el) return false;
999 string AircraftName = el->GetAttributeValue("name");
1000 ((FGAircraft*)Models[eAircraft])->SetAircraftName(AircraftName);
1002 if (debug_lvl & 1) cout << underon << "Reading Aircraft Configuration File"
1003 << underoff << ": " << highint << AircraftName << normint << endl;
1005 CFGVersion = el->GetAttributeValue("version");
1006 Release = el->GetAttributeValue("release");
1009 cout << " Version: " << highint << CFGVersion
1011 if (CFGVersion != needed_cfg_version) {
1012 cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
1013 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
1014 cerr << "Current version needed is: " << needed_cfg_version << endl;
1015 cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
1019 if (Release == "ALPHA" && (debug_lvl & 1)) {
1020 cout << endl << endl
1021 << highint << "This aircraft model is an " << fgred << Release
1022 << reset << highint << " release!!!" << endl << endl << reset
1023 << "This aircraft model may not even properly load, and probably"
1024 << " will not fly as expected." << endl << endl
1025 << fgred << highint << "Use this model for development purposes ONLY!!!"
1026 << normint << reset << endl << endl;
1027 } else if (Release == "BETA" && (debug_lvl & 1)) {
1028 cout << endl << endl
1029 << highint << "This aircraft model is a " << fgred << Release
1030 << reset << highint << " release!!!" << endl << endl << reset
1031 << "This aircraft model probably will not fly as expected." << endl << endl
1032 << fgblue << highint << "Use this model for development purposes ONLY!!!"
1033 << normint << reset << endl << endl;
1034 } else if (Release == "PRODUCTION" && (debug_lvl & 1)) {
1035 cout << endl << endl
1036 << highint << "This aircraft model is a " << fgblue << Release
1037 << reset << highint << " release." << endl << endl << reset;
1038 } else if (debug_lvl & 1) {
1039 cout << endl << endl
1040 << highint << "This aircraft model is an " << fgred << Release
1041 << reset << highint << " release!!!" << endl << endl << reset
1042 << "This aircraft model may not even properly load, and probably"
1043 << " will not fly as expected." << endl << endl
1044 << fgred << highint << "Use this model for development purposes ONLY!!!"
1045 << normint << reset << endl << endl;
1051 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1053 bool FGFDMExec::ReadChild(Element* el)
1055 // Add a new childData object to the child FDM list
1056 // Populate that childData element with a new FDMExec object
1057 // Set the IsChild flag for that FDMExec object
1058 // Get the aircraft name
1059 // set debug level to print out no additional data for child objects
1060 // Load the model given the aircraft name
1061 // reset debug level to prior setting
1065 struct childData* child = new childData;
1067 child->exec = new FGFDMExec(Root, FDMctr);
1068 child->exec->SetChild(true);
1070 string childAircraft = el->GetAttributeValue("name");
1071 string sMated = el->GetAttributeValue("mated");
1072 if (sMated == "false") child->mated = false; // child objects are mated by default.
1073 string sInternal = el->GetAttributeValue("internal");
1074 if (sInternal == "true") child->internal = true; // child objects are external by default.
1076 child->exec->SetAircraftPath( AircraftPath );
1077 child->exec->SetEnginePath( EnginePath );
1078 child->exec->SetSystemsPath( SystemsPath );
1079 child->exec->LoadModel(childAircraft);
1081 Element* location = el->FindElement("location");
1083 child->Loc = location->FindElementTripletConvertTo("IN");
1085 cerr << endl << highint << fgred << " No location was found for this child object!" << reset << endl;
1089 Element* orientation = el->FindElement("orient");
1091 child->Orient = orientation->FindElementTripletConvertTo("RAD");
1092 } else if (debug_lvl > 0) {
1093 cerr << endl << highint << " No orientation was found for this child object! Assuming 0,0,0." << reset << endl;
1096 ChildFDMList.push_back(child);
1101 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103 FGPropertyManager* FGFDMExec::GetPropertyManager(void)
1108 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1110 FGTrim* FGFDMExec::GetTrim(void)
1113 Trim = new FGTrim(this,tNone);
1117 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1119 void FGFDMExec::DisableOutput(void)
1121 for (unsigned i=0; i<Outputs.size(); i++) {
1122 Outputs[i]->Disable();
1126 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 void FGFDMExec::EnableOutput(void)
1130 for (unsigned i=0; i<Outputs.size(); i++) {
1131 Outputs[i]->Enable();
1135 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1137 void FGFDMExec::ForceOutput(int idx)
1139 if (idx >= (int)0 && idx < (int)Outputs.size()) Outputs[idx]->Print();
1142 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1144 bool FGFDMExec::SetOutputDirectives(const string& fname)
1148 FGOutput* Output = new FGOutput(this);
1149 Output->SetDirectivesFile(RootDir + fname);
1150 Output->InitModel();
1152 result = Output->Load(0);
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);
1164 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1166 void FGFDMExec::DoTrim(int mode)
1170 if (Constructing) return;
1172 if (mode < 0 || mode > JSBSim::tNone) {
1173 cerr << endl << "Illegal trimming mode!" << endl << endl;
1176 saved_time = sim_time;
1177 FGTrim trim(this, (JSBSim::TrimMode)mode);
1178 if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
1180 sim_time = saved_time;
1183 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1184 // The bitmasked value choices are as follows:
1185 // unset: In this case (the default) JSBSim would only print
1186 // out the normally expected messages, essentially echoing
1187 // the config files as they are read. If the environment
1188 // variable is not set, debug_lvl is set to 1 internally
1189 // 0: This requests JSBSim not to output any messages
1191 // 1: This value explicity requests the normal JSBSim
1193 // 2: This value asks for a message to be printed out when
1194 // a class is instantiated
1195 // 4: When this value is set, a message is displayed when a
1196 // FGModel object executes its Run() method
1197 // 8: When this value is set, various runtime state variables
1198 // are printed out periodically
1199 // 16: When set various parameters are sanity checked and
1200 // a message is printed out when they go out of bounds
1202 void FGFDMExec::Debug(int from)
1204 if (debug_lvl <= 0) return;
1206 if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output
1207 if (from == 0) { // Constructor
1209 << "JSBSim Flight Dynamics Model v" << JSBSim_version << endl;
1210 cout << " [JSBSim-ML v" << needed_cfg_version << "]\n\n";
1211 cout << "JSBSim startup beginning ...\n\n";
1212 } else if (from == 3) {
1213 cout << "\n\nJSBSim startup complete\n\n";
1216 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1217 if (from == 0) cout << "Instantiated: FGFDMExec" << endl;
1218 if (from == 1) cout << "Destroyed: FGFDMExec" << endl;
1220 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1222 cout << "================== Frame: " << Frame << " Time: "
1223 << sim_time << " dt: " << dT << endl;
1226 if (debug_lvl & 8 ) { // Runtime state variables
1228 if (debug_lvl & 16) { // Sanity checking
1230 if (debug_lvl & 64) {
1231 if (from == 0) { // Constructor
1232 cout << IdSrc << endl;
1233 cout << IdHdr << endl;