FlightGear next
FGScript.h
Go to the documentation of this file.
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
25HISTORY
26--------------------------------------------------------------------------------
2712/21/01 JSB Created
28
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30SENTRY
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33#ifndef FGSCRIPT_HEADER_H
34#define FGSCRIPT_HEADER_H
35
36/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#include <vector>
41#include <map>
42
43#include "FGJSBBase.h"
44#include "FGPropertyReader.h"
46#include "simgear/misc/sg_path.hxx"
47
48/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49FORWARD DECLARATIONS
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52namespace JSBSim {
53
54class FGFDMExec;
55class FGCondition;
56class FGFunction;
57class FGPropertyValue;
58
59/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60CLASS DOCUMENTATION
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
161
162/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163CLASS DECLARATION
164%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
165
166class FGScript : public FGJSBBase
167{
168public:
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
196private:
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
Encapsulates a condition, which is used in parts of JSBSim including switches.
Definition FGCondition.h:67
Represents a mathematical function.
Definition FGFunction.h:753
FGJSBBase()
Constructor for FGJSBBase.
Definition FGJSBBase.h:81
static char reset[5]
resets text properties
Definition FGJSBBase.h:129
Represents a property value which can use late binding.
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
void ResetEvents(void)
Definition FGScript.cpp:368
~FGScript()
Default destructor.
Definition FGScript.cpp:73
bool RunScript(void)
This function is called each pass through the executive Run() method IF scripting is enabled.
Definition FGScript.cpp:379
FGScript(FGFDMExec *exec)
Default constructor.
Definition FGScript.cpp:64