JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGInputType.cpp
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGInputType.cpp
4 Author: Paul Chavent
5 Date started: 01/20/15
6 Purpose: Manage input of sim parameters to file or stdout
7
8 ------------- Copyright (C) 2015 Paul Chavent -------------
9
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
12 Software Foundation; either version 2 of the License, or (at your option) any
13 later version.
14
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
18 details.
19
20 You should have received a copy of the GNU Lesser General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc., 59
22 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 Further information about the GNU Lesser General Public License can also be
25 found on the world wide web at http://www.gnu.org.
26
27FUNCTIONAL DESCRIPTION
28--------------------------------------------------------------------------------
29This is the place where you create input routines to dump data for perusal
30later.
31
32HISTORY
33--------------------------------------------------------------------------------
3401/20/15 PC Created
35
36%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#include "FGInputType.h"
41#include "FGLog.h"
42#include "FGFDMExec.h"
43
44using namespace std;
45
46namespace JSBSim {
47
48/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49CLASS IMPLEMENTATION
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
53 FGModel(fdmex), enabled(true)
54{
55 Debug(0);
56}
57
58//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59
61{
62 Debug(1);
63}
64
65//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
67void FGInputType::SetIdx(unsigned int idx)
68{
69 InputIdx = idx;
70}
71
72//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73
75{
76 // Perform base class Load.
77 if(!FGModel::Upload(element, true))
78 return false;
79
80 // no common attributes yet (see FGOutputType for example
81
82 // FIXME : PostLoad should be called in the most derived class ?
83 PostLoad(element, FDMExec);
84
85 return true;
86}
87
88//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89
91{
92 bool ret = FGModel::InitModel();
93
94 Debug(2);
95 return ret;
96}
97
98//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100bool FGInputType::Run(bool Holding)
101{
102 if (FGModel::Run(Holding)) return true;
103 if (!enabled) return true;
104
105 RunPreFunctions();
106 Read(Holding);
107 RunPostFunctions();
108
109 Debug(4);
110
111 return false;
112}
113
114//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115// The bitmasked value choices are as follows:
116// unset: In this case (the default) JSBSim would only print
117// out the normally expected messages, essentially echoing
118// the config files as they are read. If the environment
119// variable is not set, debug_lvl is set to 1 internally
120// 0: This requests JSBSim not to input any messages
121// whatsoever.
122// 1: This value explicity requests the normal JSBSim
123// startup messages
124// 2: This value asks for a message to be printed out when
125// a class is instantiated
126// 4: When this value is set, a message is displayed when a
127// FGModel object executes its Run() method
128// 8: When this value is set, various runtime state variables
129// are printed out periodically
130// 16: When set various parameters are sanity checked and
131// a message is printed out when they go out of bounds
132
133void FGInputType::Debug(int from)
134{
135 if (debug_lvl <= 0) return;
136
137 if (debug_lvl & 1) { // Standard console startup message input
138 if (from == 0) { // Constructor
139
140 }
141 if (from == 2) {
142 }
143 }
144 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
145 FGLogging log(LogLevel::DEBUG);
146 if (from == 0) log << "Instantiated: FGInputType\n";
147 if (from == 1) log << "Destroyed: FGInputType\n";
148 }
149 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
150 }
151 if (debug_lvl & 8 ) { // Runtime state variables
152 }
153 if (debug_lvl & 16) { // Sanity checking
154 }
155 if (debug_lvl & 64) {
156 if (from == 0) { // Constructor
157 }
158 }
159}
160}
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:185
bool Load(Element *el) override
Init the input directives from an XML file (implement the FGModel interface).
~FGInputType() override
Destructor.
void SetIdx(unsigned int idx)
Set the idx for this input instance.
bool Run(bool Holding) override
Executes the input directives (implement the FGModel interface).
bool InitModel(void) override
Init the input model according to its configitation.
virtual void Read(bool Holding)=0
Generate the input.
FGInputType(FGFDMExec *fdmex)
Constructor (implement the FGModel interface).
Base class for all scheduled JSBSim models.
Definition FGModel.h:70
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:90
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition FGModel.cpp:111
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71