JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGScript.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  Header: FGScript.h
3  Author: Jon Berndt
4  Date started: 12/21/2001
5 
6  ------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) -------------
7 
8  This program is free software; you can redistribute it and/or modify it under
9  the terms of the GNU Lesser General Public License as published by the Free Software
10  Foundation; either version 2 of the License, or (at your option) any later
11  version.
12 
13  This program is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22  Further information about the GNU Lesser General Public License can also be found on
23  the world wide web at http://www.gnu.org.
24 
25 HISTORY
26 --------------------------------------------------------------------------------
27 12/21/01 JSB Created
28 
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32 
33 #ifndef FGSCRIPT_HEADER_H
34 #define FGSCRIPT_HEADER_H
35 
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 
40 #include <vector>
41 #include <map>
42 
43 #include "FGJSBBase.h"
44 #include "FGPropertyReader.h"
45 #include "input_output/FGPropertyManager.h"
46 #include "simgear/misc/sg_path.hxx"
47 
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 FORWARD DECLARATIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 namespace JSBSim {
53 
54 class FGFDMExec;
55 class FGCondition;
56 class FGFunction;
57 class FGPropertyValue;
58 
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 
162 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 CLASS DECLARATION
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
165 
166 class FGScript : public FGJSBBase
167 {
168 public:
170  FGScript(FGFDMExec* exec);
171 
173  ~FGScript();
174 
186  bool LoadScript(const SGPath& script, double default_dT,
187  const SGPath& initfile);
188 
192  bool RunScript(void);
193 
194  void ResetEvents(void);
195 
196 private:
197  enum eAction {
198  FG_RAMP = 1,
199  FG_STEP = 2,
200  FG_EXP = 3
201  };
202 
203  enum eType {
204  FG_VALUE = 1,
205  FG_DELTA = 2,
206  FG_BOOL = 3
207  };
208 
209  struct event {
210  FGCondition *Condition;
211  bool Persistent;
212  bool Continuous;
213  bool Triggered;
214  bool Notify;
215  bool NotifyKML;
216  bool Notified;
217  double Delay;
218  double StartTime;
219  double TimeSpan;
220  std::string Name;
221  std::string Description;
222  std::vector <FGPropertyNode_ptr> SetParam;
223  std::vector <std::string> SetParamName;
224  std::vector <FGPropertyValue*> NotifyProperties;
225  std::vector <std::string> DisplayString;
226  std::vector <eAction> Action;
227  std::vector <eType> Type;
228  std::vector <double> SetValue;
229  std::vector <double> TC;
230  std::vector <double> newValue;
231  std::vector <double> OriginalValue;
232  std::vector <double> ValueSpan;
233  std::vector <bool> Transiting;
234  std::vector <FGFunction*> Functions;
235 
236  event() {
237  Triggered = false;
238  Persistent = false;
239  Continuous = false;
240  Delay = 0.0;
241  Notify = Notified = NotifyKML = false;
242  Name = "";
243  StartTime = 0.0;
244  TimeSpan = 0.0;
245  }
246 
247  void reset(void) {
248  Triggered = false;
249  Notified = false;
250  StartTime = 0.0;
251  }
252  };
253 
254  std::string ScriptName;
255  double StartTime;
256  double EndTime;
257  std::vector <struct event> Events;
258 
259  FGPropertyReader LocalProperties;
260 
261  FGFDMExec* FDMExec;
262  FGPropertyManager* PropertyManager;
263  void Debug(int from);
264 };
265 }
266 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267 #endif
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGPropertyReader
Definition: FGPropertyReader.h:62
JSBSim::FGScript::RunScript
bool RunScript(void)
This function is called each pass through the executive Run() method IF scripting is enabled.
Definition: FGScript.cpp:379
JSBSim::FGJSBBase
JSBSim Base class.
Definition: FGJSBBase.h:78
JSBSim::FGScript
Encapsulates the JSBSim scripting capability.
Definition: FGScript.h:166
JSBSim::FGScript::FGScript
FGScript(FGFDMExec *exec)
Default constructor.
Definition: FGScript.cpp:64
JSBSim::FGJSBBase::reset
static char reset[5]
resets text properties
Definition: FGJSBBase.h:129
JSBSim::FGScript::~FGScript
~FGScript()
Default destructor.
Definition: FGScript.cpp:73
JSBSim::FGScript::LoadScript
bool LoadScript(const SGPath &script, double default_dT, const SGPath &initfile)
Loads a script to drive JSBSim (usually in standalone mode).
Definition: FGScript.cpp:91
JSBSim::FGCondition
Encapsulates a condition, which is used in parts of JSBSim including switches.
Definition: FGCondition.h:66
JSBSim::FGPropertyManager
Definition: FGPropertyManager.h:373