JSBSim Flight Dynamics Model  1.0 (02 March 2017)
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 DEFINITIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 #define ID_FGSCRIPT "$Id: FGScript.h,v 1.31 2017/02/25 14:23:18 bcoconni Exp $"
53 
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 FORWARD DECLARATIONS
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 
58 namespace JSBSim {
59 
60 class FGFDMExec;
61 class FGCondition;
62 class FGFunction;
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
168 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 CLASS DECLARATION
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
171 
172 class FGScript : public FGJSBBase
173 {
174 public:
176  FGScript(FGFDMExec* exec);
177 
179  ~FGScript();
180 
192  bool LoadScript(const SGPath& script, double default_dT,
193  const SGPath& initfile);
194 
198  bool RunScript(void);
199 
200  void ResetEvents(void);
201 
202 private:
203  enum eAction {
204  FG_RAMP = 1,
205  FG_STEP = 2,
206  FG_EXP = 3
207  };
208 
209  enum eType {
210  FG_VALUE = 1,
211  FG_DELTA = 2,
212  FG_BOOL = 3
213  };
214 
215  struct event {
216  FGCondition *Condition;
217  bool Persistent;
218  bool Continuous;
219  bool Triggered;
220  bool Notify;
221  bool NotifyKML;
222  bool Notified;
223  double Delay;
224  double StartTime;
225  double TimeSpan;
226  std::string Name;
227  std::string Description;
228  std::vector <FGPropertyNode_ptr> SetParam;
229  std::vector <std::string> SetParamName;
230  std::vector <FGPropertyNode_ptr> NotifyProperties;
231  std::vector <std::string> NotifyPropertyNames;
232  std::vector <std::string> DisplayString;
233  std::vector <eAction> Action;
234  std::vector <eType> Type;
235  std::vector <double> SetValue;
236  std::vector <double> TC;
237  std::vector <double> newValue;
238  std::vector <double> OriginalValue;
239  std::vector <double> ValueSpan;
240  std::vector <bool> Transiting;
241  std::vector <FGFunction*> Functions;
242 
243  event() {
244  Triggered = false;
245  Persistent = false;
246  Continuous = false;
247  Delay = 0.0;
248  Notify = Notified = NotifyKML = false;
249  Name = "";
250  StartTime = 0.0;
251  TimeSpan = 0.0;
252  }
253 
254  void reset(void) {
255  Triggered = false;
256  Notified = false;
257  StartTime = 0.0;
258  }
259  };
260 
261  std::string ScriptName;
262  double StartTime;
263  double EndTime;
264  std::vector <struct event> Events;
265 
266  FGPropertyReader LocalProperties;
267 
268  FGFDMExec* FDMExec;
269  FGPropertyManager* PropertyManager;
270  void Debug(int from);
271 };
272 }
273 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 #endif
275 
static char reset[5]
resets text properties
Definition: FGJSBBase.h:131
bool LoadScript(const SGPath &script, double default_dT, const SGPath &initfile)
Loads a script to drive JSBSim (usually in standalone mode).
Definition: FGScript.cpp:99
bool RunScript(void)
This function is called each pass through the executive Run() method IF scripting is enabled...
Definition: FGScript.cpp:366
JSBSim Base class.
Definition: FGJSBBase.h:80
Encapsulates the JSBSim scripting capability.
Definition: FGScript.h:172
~FGScript()
Default destructor.
Definition: FGScript.cpp:83
FGScript(FGFDMExec *exec)
Default constructor.
Definition: FGScript.cpp:74
Encapsulates a condition, which is used in parts of JSBSim including switches.
Definition: FGCondition.h:70
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189