1 /*******************************************************************************
6 Purpose: Schedules and runs the model routines.
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
31 This class wraps up the simulation scheduling routines.
35 --------------------------------------------------------------------------------
39 --------------------------------------------------------------------------------
42 ********************************************************************************
44 *******************************************************************************/
46 #include "FGFDMExec.h"
52 /*******************************************************************************
53 ************************************ CODE **************************************
54 *******************************************************************************/
59 FGFDMExec::FGFDMExec(void)
63 State = new FGState();
64 Atmosphere = new FGAtmosphere();
66 Aircraft = new FGAircraft();
67 Translation = new FGTranslation();
68 Rotation = new FGRotation();
69 Position = new FGPosition();
70 Auxiliary = new FGAuxiliary();
71 Output = new FGOutput();
73 Schedule(Atmosphere, 5);
75 Schedule(Aircraft, 1);
76 Schedule(Rotation, 1);
77 Schedule(Translation, 1);
78 Schedule(Position, 1);
79 Schedule(Auxiliary, 1);
87 FGFDMExec::~FGFDMExec(void)
92 int FGFDMExec::Schedule(FGModel* model, int rate)
94 FGModel* model_iterator;
96 model_iterator = FirstModel;
98 if (model_iterator == 0L) { // this is the first model
101 FirstModel->NextModel = 0L;
102 FirstModel->SetRate(rate);
104 } else { // subsequent model
106 while (model_iterator->NextModel != 0L) {
107 model_iterator = model_iterator->NextModel;
109 model_iterator->NextModel = model;
110 model_iterator->NextModel->SetRate(rate);
117 bool FGFDMExec::Run(void)
119 FGModel* model_iterator;
121 model_iterator = FirstModel;
122 if (model_iterator == 0L) return false;
124 while (!model_iterator->Run())
126 model_iterator = model_iterator->NextModel;
127 if (model_iterator == 0L) break;