1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Schedules and runs the model routines.
8 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU 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 General Public License for more
20 You should have received a copy of the GNU 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 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 # include <simgear/compiler.h>
46 # include STL_IOSTREAM
47 # include STL_ITERATOR
49 # if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
50 # include <iostream.h>
57 #include "FGFDMExec.h"
59 #include <models/FGAtmosphere.h>
60 #include <models/atmosphere/FGMSIS.h>
61 #include <models/atmosphere/FGMars.h>
62 #include <models/FGFCS.h>
63 #include <models/FGPropulsion.h>
64 #include <models/FGMassBalance.h>
65 #include <models/FGGroundReactions.h>
66 #include <models/FGAerodynamics.h>
67 #include <models/FGInertial.h>
68 #include <models/FGAircraft.h>
69 #include <models/FGPropagate.h>
70 #include <models/FGAuxiliary.h>
71 #include <models/FGInput.h>
72 #include <models/FGOutput.h>
73 #include <initialization/FGInitialCondition.h>
74 #include <input_output/FGPropertyManager.h>
78 static const char *IdSrc = "$Id$";
79 static const char *IdHdr = ID_FDMEXEC;
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85 unsigned int FGFDMExec::FDMctr = 0;
86 FGPropertyManager* FGFDMExec::master=0;
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92 void checkTied ( FGPropertyManager *node )
94 int N = node->nChildren();
97 for (int i=0; i<N; i++) {
98 if (node->getChild(i)->nChildren() ) {
99 checkTied( (FGPropertyManager*)node->getChild(i) );
100 } else if ( node->getChild(i)->isTied() ) {
101 name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
102 cerr << name << " is tied" << endl;
107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
138 // Multiple FDM's are stopped for now. We need to ensure that
139 // the "user" instance always gets the zeroeth instance number,
140 // because there may be instruments or scripts tied to properties
141 // in the jsbsim[0] node.
142 // ToDo: it could be that when JSBSim is reset and a new FDM is wanted, that
143 // process might try setting FDMctr = 0. Then the line below would not need
144 // to be commented out.
149 char* num = getenv("JSBSIM_DEBUG");
150 if (num) debug_lvl = atoi(num); // set debug level
151 } catch (...) { // if error set to 1
155 if (Root == 0) master= new FGPropertyManager;
158 instance = master->GetNode("/fdm/jsbsim",IdFDM,true);
160 // this is to catch errors in binding member functions to the property tree.
163 } catch ( string msg ) {
164 cout << "Caught error: " << msg << endl;
169 typedef int (FGFDMExec::*iPMF)(void) const;
170 instance->Tie("simulation/do_trim", this, (iPMF)0, &FGFDMExec::DoTrim);
171 Constructing = false;
174 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 FGFDMExec::~FGFDMExec()
178 instance->Untie("simulation/do_trim");
182 checkTied( instance );
183 if (Root == 0) delete master;
184 } catch ( string msg ) {
185 cout << "Caught error: " << msg << endl;
188 for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
189 SlaveFDMList.clear();
194 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196 bool FGFDMExec::Allocate(void)
200 Atmosphere = new FGAtmosphere(this);
201 FCS = new FGFCS(this);
202 Propulsion = new FGPropulsion(this);
203 MassBalance = new FGMassBalance(this);
204 Aerodynamics = new FGAerodynamics (this);
205 Inertial = new FGInertial(this);
206 GroundReactions = new FGGroundReactions(this);
207 Aircraft = new FGAircraft(this);
208 Propagate = new FGPropagate(this);
209 Auxiliary = new FGAuxiliary(this);
210 Input = new FGInput(this);
212 GroundCallback = new FGGroundCallback();
213 State = new FGState(this); // This must be done here, as the FGState
214 // class needs valid pointers to the above
217 // Initialize models so they can communicate with each other
219 if (!Atmosphere->InitModel()) {
220 cerr << fgred << "Atmosphere model init failed" << fgdef << endl;
222 if (!FCS->InitModel()) {
223 cerr << fgred << "FCS model init failed" << fgdef << endl;
225 if (!Propulsion->InitModel()) {
226 cerr << fgred << "FGPropulsion model init failed" << fgdef << endl;
228 if (!MassBalance->InitModel()) {
229 cerr << fgred << "FGMassBalance model init failed" << fgdef << endl;
231 if (!Aerodynamics->InitModel()) {
232 cerr << fgred << "FGAerodynamics model init failed" << fgdef << endl;
234 if (!Inertial->InitModel()) {
235 cerr << fgred << "FGInertial model init failed" << fgdef << endl;
237 if (!GroundReactions->InitModel()) {
238 cerr << fgred << "Ground Reactions model init failed" << fgdef << endl;
240 if (!Aircraft->InitModel()) {
241 cerr << fgred << "Aircraft model init failed" << fgdef << endl;
243 if (!Propagate->InitModel()) {
244 cerr << fgred << "Propagate model init failed" << fgdef << endl;
246 if (!Auxiliary->InitModel()) {
247 cerr << fgred << "Auxiliary model init failed" << fgdef << endl;
249 if (!Input->InitModel()) {
250 cerr << fgred << "Input model init failed" << fgdef << endl;
253 if (Error > 0) result = false;
255 IC = new FGInitialCondition(this);
257 // Schedule a model. The second arg (the integer) is the pass number. For
258 // instance, the atmosphere model could get executed every fifth pass it is called
259 // by the executive. IC and Trim objects are NOT scheduled.
262 Schedule(Atmosphere, 1);
264 Schedule(Propulsion, 1);
265 Schedule(MassBalance, 1);
266 Schedule(Aerodynamics, 1);
267 Schedule(Inertial, 1);
268 Schedule(GroundReactions, 1);
269 Schedule(Aircraft, 1);
270 Schedule(Propagate, 1);
271 Schedule(Auxiliary, 1);
278 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 bool FGFDMExec::DeAllocate(void)
289 delete GroundReactions;
295 for (int i=0; i<Outputs.size(); i++) {
296 if (Outputs[i]) delete Outputs[i];
304 delete GroundCallback;
326 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 int FGFDMExec::Schedule(FGModel* model, int rate)
330 FGModel* model_iterator;
332 model_iterator = FirstModel;
334 if (model_iterator == 0L) { // this is the first model
337 FirstModel->NextModel = 0L;
338 FirstModel->SetRate(rate);
340 } else { // subsequent model
342 while (model_iterator->NextModel != 0L) {
343 model_iterator = model_iterator->NextModel;
345 model_iterator->NextModel = model;
346 model_iterator->NextModel->SetRate(rate);
353 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 bool FGFDMExec::Run(void)
357 FGModel* model_iterator;
359 model_iterator = FirstModel;
360 if (model_iterator == 0L) return false;
364 for (unsigned int i=1; i<SlaveFDMList.size(); i++) {
365 // SlaveFDMList[i]->exec->State->Initialize(); // Transfer state to the slave FDM
366 // SlaveFDMList[i]->exec->Run();
369 while (model_iterator != 0L) {
370 model_iterator->Run();
371 model_iterator = model_iterator->NextModel;
375 if (!Holding()) State->IncrTime();
379 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380 // This call will cause the sim time to reset to 0.0
382 bool FGFDMExec::RunIC(void)
384 State->SuspendIntegration();
385 State->Initialize(IC);
387 State->ResumeIntegration();
392 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394 void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
396 if (GroundCallback) delete GroundCallback;
401 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 vector <string> FGFDMExec::EnumerateFDMs(void)
405 vector <string> FDMList;
407 FDMList.push_back(Aircraft->GetAircraftName());
409 for (unsigned int i=1; i<SlaveFDMList.size(); i++) {
410 FDMList.push_back(SlaveFDMList[i]->exec->GetAircraft()->GetAircraftName());
416 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418 bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model,
421 FGFDMExec::AircraftPath = AircraftPath;
422 FGFDMExec::EnginePath = EnginePath;
424 return LoadModel(model, addModelToPath);
427 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429 bool FGFDMExec::LoadModel(string model, bool addModelToPath)
432 string aircraftCfgFileName;
433 string separator = "/";
439 if( AircraftPath.empty() || EnginePath.empty() ) {
440 cerr << "Error: attempted to load aircraft with undefined ";
441 cerr << "aircraft and engine paths" << endl;
445 aircraftCfgFileName = AircraftPath;
446 if (addModelToPath) aircraftCfgFileName += separator + model;
447 aircraftCfgFileName += separator + model + ".xml";
449 FGXMLParse *XMLParse = new FGXMLParse();
450 Element* element = 0L;
453 ifstream input_file(aircraftCfgFileName.c_str());
454 readXML(input_file, *XMLParse);
455 document = XMLParse->GetDocument();
464 ReadPrologue(document);
465 element = document->GetElement();
468 while (element && result) {
469 string element_name = element->GetName();
470 if (element_name == "fileheader" ) result = ReadFileHeader(element);
471 else if (element_name == "slave") result = ReadSlave(element);
472 else if (element_name == "metrics") result = Aircraft->Load(element);
473 else if (element_name == "mass_balance") result = MassBalance->Load(element);
474 else if (element_name == "ground_reactions") result = GroundReactions->Load(element);
475 else if (element_name == "propulsion") result = Propulsion->Load(element);
476 else if (element_name == "autopilot") result = FCS->Load(element);
477 else if (element_name == "flight_control") result = FCS->Load(element);
478 else if (element_name == "aerodynamics") result = Aerodynamics->Load(element);
479 else if (element_name == "input") result = Input->Load(element);
480 else if (element_name == "output") {
481 FGOutput* Output = new FGOutput(this);
484 Outputs.push_back(Output);
485 result = Output->Load(element);
488 cerr << "Found unexpected subsystem: " << element_name << ", exiting." << endl;
492 element = document->GetNextElement();
500 << " JSBSim failed to load aircraft and/or engine model"
505 struct PropertyCatalogStructure masterPCS;
506 masterPCS.base_string = "";
507 masterPCS.node = (FGPropertyManager*)master;
509 BuildPropertyCatalog(&masterPCS);
514 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516 void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
518 struct PropertyCatalogStructure* pcsNew = new struct PropertyCatalogStructure;
522 for (int i=0; i<pcs->node->nChildren(); i++) {
523 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
524 node_idx = pcs->node->getChild(i)->getIndex();
525 sprintf(int_buf, "[%d]", node_idx);
526 if (node_idx != 0) pcsNew->base_string += string(int_buf);
527 if (pcs->node->getChild(i)->nChildren() == 0) {
528 PropertyCatalog.push_back(pcsNew->base_string);
530 pcsNew->node = (FGPropertyManager*)pcs->node->getChild(i);
531 BuildPropertyCatalog(pcsNew);
537 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 string FGFDMExec::QueryPropertyCatalog(string in)
542 for (int i=0; i<PropertyCatalog.size(); i++) {
543 if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
545 if (results.empty()) return "No matches found\n";
549 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
551 bool FGFDMExec::ReadFileHeader(Element* el)
553 bool result = true; // true for success
555 if (debug_lvl & ~1) return result;
557 if (el->FindElement("author"))
558 cout << " Model Author: " << el->FindElement("author")->GetDataLine() << endl;
559 if (el->FindElement("filecreationdate"))
560 cout << " Creation Date: " << el->FindElement("filecreationdate")->GetDataLine() << endl;
561 if (el->FindElement("version"))
562 cout << " Version: " << el->FindElement("version")->GetDataLine() << endl;
563 if (el->FindElement("description"))
564 cout << " Description: " << el->FindElement("description")->GetDataLine() << endl;
569 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571 bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document element
573 bool result = true; // true for success
575 if (!el) return false;
577 string AircraftName = el->GetAttributeValue("name");
578 Aircraft->SetAircraftName(AircraftName);
580 if (debug_lvl & 1) cout << underon << "Reading Aircraft Configuration File"
581 << underoff << ": " << highint << AircraftName << normint << endl;
583 CFGVersion = el->GetAttributeValue("version");
584 Release = el->GetAttributeValue("release");
587 cout << " Version: " << highint << CFGVersion
589 if (CFGVersion != needed_cfg_version) {
590 cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
591 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
592 cerr << "Current version needed is: " << needed_cfg_version << endl;
593 cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
597 if (Release == "ALPHA" && (debug_lvl & 1)) {
599 << highint << "This aircraft model is an " << fgred << Release
600 << reset << highint << " release!!!" << endl << endl << reset
601 << "This aircraft model may not even properly load, and probably"
602 << " will not fly as expected." << endl << endl
603 << fgred << highint << "Use this model for development purposes ONLY!!!"
604 << normint << reset << endl << endl;
605 } else if (Release == "BETA" && (debug_lvl & 1)) {
607 << highint << "This aircraft model is a " << fgred << Release
608 << reset << highint << " release!!!" << endl << endl << reset
609 << "This aircraft model probably will not fly as expected." << endl << endl
610 << fgblue << highint << "Use this model for development purposes ONLY!!!"
611 << normint << reset << endl << endl;
612 } else if (Release == "PRODUCTION" && (debug_lvl & 1)) {
614 << highint << "This aircraft model is a " << fgblue << Release
615 << reset << highint << " release." << endl << endl << reset;
616 } else if (debug_lvl & 1) {
618 << highint << "This aircraft model is an " << fgred << Release
619 << reset << highint << " release!!!" << endl << endl << reset
620 << "This aircraft model may not even properly load, and probably"
621 << " will not fly as expected." << endl << endl
622 << fgred << highint << "Use this model for development purposes ONLY!!!"
623 << normint << reset << endl << endl;
629 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 bool FGFDMExec::ReadSlave(Element* el)
633 // Add a new slaveData object to the slave FDM list
634 // Populate that slaveData element with a new FDMExec object
635 // Set the IsSlave flag for that FDMExec object
636 // Get the aircraft name
637 // set debug level to print out no additional data for slave objects
638 // Load the model given the aircraft name
639 // reset debug level to prior setting
641 int saved_debug_lvl = debug_lvl;
644 SlaveFDMList.push_back(new slaveData);
645 SlaveFDMList.back()->exec = new FGFDMExec();
646 SlaveFDMList.back()->exec->SetSlave();
648 string AircraftName = AC_cfg->GetValue("file");
650 debug_lvl = 0; // turn off debug output for slave vehicle
652 SlaveFDMList.back()->exec->SetAircraftPath( AircraftPath );
653 SlaveFDMList.back()->exec->SetEnginePath( EnginePath );
654 SlaveFDMList.back()->exec->LoadModel(AircraftName);
655 debug_lvl = saved_debug_lvl; // turn debug output back on for master vehicle
657 AC_cfg->GetNextConfigLine();
658 while ((token = AC_cfg->GetValue()) != string("/SLAVE")) {
660 if (token == "xloc") { *AC_cfg >> SlaveFDMList.back()->x; }
661 else if (token == "yloc") { *AC_cfg >> SlaveFDMList.back()->y; }
662 else if (token == "zloc") { *AC_cfg >> SlaveFDMList.back()->z; }
663 else if (token == "pitch") { *AC_cfg >> SlaveFDMList.back()->pitch;}
664 else if (token == "yaw") { *AC_cfg >> SlaveFDMList.back()->yaw; }
665 else if (token == "roll") { *AC_cfg >> SlaveFDMList.back()->roll; }
666 else cerr << "Unknown identifier: " << token << " in slave vehicle definition" << endl;
670 cout << " X = " << SlaveFDMList.back()->x << endl;
671 cout << " Y = " << SlaveFDMList.back()->y << endl;
672 cout << " Z = " << SlaveFDMList.back()->z << endl;
673 cout << " Pitch = " << SlaveFDMList.back()->pitch << endl;
674 cout << " Yaw = " << SlaveFDMList.back()->yaw << endl;
675 cout << " Roll = " << SlaveFDMList.back()->roll << endl;
681 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683 FGPropertyManager* FGFDMExec::GetPropertyManager(void)
688 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 FGTrim* FGFDMExec::GetTrim(void)
693 Trim = new FGTrim(this,tNone);
697 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
699 void FGFDMExec::DisableOutput(void)
701 for (int i=0; i<Outputs.size(); i++) {
702 Outputs[i]->Disable();
706 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
708 void FGFDMExec::EnableOutput(void)
710 for (int i=0; i<Outputs.size(); i++) {
711 Outputs[i]->Enable();
715 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 void FGFDMExec::DoTrim(int mode)
721 cout << "DoTrim called" << endl;
723 if (Constructing) return;
725 if (mode < 0 || mode > JSBSim::tNone) {
726 cerr << endl << "Illegal trimming mode!" << endl << endl;
729 saved_time = State->Getsim_time();
730 FGTrim trim(this, (JSBSim::TrimMode)mode);
731 if ( !trim.DoTrim() ) cerr << endl << "Trim Failed" << endl << endl;
733 State->Setsim_time(saved_time);
736 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
738 void FGFDMExec::UseAtmosphereMSIS(void)
740 FGAtmosphere *oldAtmosphere = Atmosphere;
741 Atmosphere = new MSIS(this);
742 if (!Atmosphere->InitModel()) {
743 cerr << fgred << "MSIS Atmosphere model init failed" << fgdef << endl;
746 delete oldAtmosphere;
749 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
751 void FGFDMExec::UseAtmosphereMars(void)
754 FGAtmosphere *oldAtmosphere = Atmosphere;
755 Atmosphere = new FGMars(this);
756 if (!Atmosphere->InitModel()) {
757 cerr << fgred << "Mars Atmosphere model init failed" << fgdef << endl;
760 delete oldAtmosphere;
764 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
765 // The bitmasked value choices are as follows:
766 // unset: In this case (the default) JSBSim would only print
767 // out the normally expected messages, essentially echoing
768 // the config files as they are read. If the environment
769 // variable is not set, debug_lvl is set to 1 internally
770 // 0: This requests JSBSim not to output any messages
772 // 1: This value explicity requests the normal JSBSim
774 // 2: This value asks for a message to be printed out when
775 // a class is instantiated
776 // 4: When this value is set, a message is displayed when a
777 // FGModel object executes its Run() method
778 // 8: When this value is set, various runtime state variables
779 // are printed out periodically
780 // 16: When set various parameters are sanity checked and
781 // a message is printed out when they go out of bounds
783 void FGFDMExec::Debug(int from)
785 if (debug_lvl <= 0) return;
787 if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output
788 if (from == 0) { // Constructor
789 cout << "\n\n " << highint << underon << "JSBSim Flight Dynamics Model v"
790 << JSBSim_version << underoff << normint << endl;
791 cout << halfint << " [cfg file spec v" << needed_cfg_version << "]\n\n";
792 cout << normint << "JSBSim startup beginning ...\n\n";
793 } else if (from == 3) {
794 cout << "\n\nJSBSim startup complete\n\n";
797 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
798 if (from == 0) cout << "Instantiated: FGFDMExec" << endl;
799 if (from == 1) cout << "Destroyed: FGFDMExec" << endl;
801 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
803 cout << "================== Frame: " << Frame << " Time: "
804 << State->Getsim_time() << " dt: " << State->Getdt() << endl;
807 if (debug_lvl & 8 ) { // Runtime state variables
809 if (debug_lvl & 16) { // Sanity checking
811 if (debug_lvl & 64) {
812 if (from == 0) { // Constructor
813 cout << IdSrc << endl;
814 cout << IdHdr << endl;