From: ehofman
Date: Mon, 15 Jan 2007 12:48:54 +0000 (+0000)
Subject: Sync. w. JSB CVS as of 15/01/2007
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3ec74d79c23347add2afa088b05ad29af975f65f;p=flightgear.git
Sync. w. JSB CVS as of 15/01/2007
---
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 54e3194d0..f5b920900 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -8,20 +8,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
@@ -72,6 +72,7 @@ INCLUDES
#include
#include
#include
+#include
namespace JSBSim {
@@ -128,13 +129,12 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
Input = 0;
IC = 0;
Trim = 0;
+ Script = 0;
- terminate = false;
modelLoaded = false;
IsSlave = false;
holding = false;
-
// Multiple FDM's are stopped for now. We need to ensure that
// the "user" instance always gets the zeroeth instance number,
// because there may be instruments or scripts tied to properties
@@ -188,6 +188,8 @@ FGFDMExec::~FGFDMExec()
for (unsigned int i=1; iexec;
SlaveFDMList.clear();
+ //ToDo remove property catalog.
+
Debug(1);
}
@@ -291,11 +293,9 @@ bool FGFDMExec::DeAllocate(void)
delete Propagate;
delete Auxiliary;
delete State;
+ delete Script;
- for (int i=0; iexec->Run();
}
+ if (Script != 0) success = Script->RunScript(); // returns true if success
+ // false if complete
while (model_iterator != 0L) {
model_iterator->Run();
model_iterator = model_iterator->NextModel;
@@ -373,7 +376,7 @@ bool FGFDMExec::Run(void)
frame = Frame++;
if (!Holding()) State->IncrTime();
- return true;
+ return (success);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -393,13 +396,26 @@ bool FGFDMExec::RunIC(void)
void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
{
- if (GroundCallback) delete GroundCallback;
-
+ delete GroundCallback;
GroundCallback = p;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+double FGFDMExec::GetSimTime(void)
+{
+ return (State->Getsim_time());
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFDMExec::GetDeltaT(void)
+{
+ return (State->Getdt());
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
vector FGFDMExec::EnumerateFDMs(void)
{
vector FDMList;
@@ -415,6 +431,18 @@ vector FGFDMExec::EnumerateFDMs(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bool FGFDMExec::LoadScript(string script)
+{
+ bool result;
+
+ Script = new FGScript(this);
+ result = Script->LoadScript(script);
+
+ return result;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model,
bool addModelToPath)
{
@@ -442,9 +470,9 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath)
return false;
}
- aircraftCfgFileName = AircraftPath;
- if (addModelToPath) aircraftCfgFileName += separator + model;
- aircraftCfgFileName += separator + model + ".xml";
+ FullAircraftPath = AircraftPath;
+ if (addModelToPath) FullAircraftPath += separator + model;
+ aircraftCfgFileName = FullAircraftPath + separator + model + ".xml";
FGXMLParse *XMLParse = new FGXMLParse();
Element* element = 0L;
@@ -545,7 +573,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
string FGFDMExec::QueryPropertyCatalog(string in)
{
string results="";
- for (int i=0; iexec = new FGFDMExec();
- SlaveFDMList.back()->exec->SetSlave();
+ SlaveFDMList.back()->exec->SetSlave(true);
/*
string AircraftName = AC_cfg->GetValue("file");
@@ -704,7 +744,7 @@ FGTrim* FGFDMExec::GetTrim(void)
void FGFDMExec::DisableOutput(void)
{
- for (int i=0; iDisable();
}
}
@@ -713,13 +753,33 @@ void FGFDMExec::DisableOutput(void)
void FGFDMExec::EnableOutput(void)
{
- for (int i=0; iEnable();
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bool FGFDMExec::SetOutputDirectives(string fname)
+{
+ bool result=true; // for now always return true
+
+ if (Outputs.size() == 0) {
+ FGOutput* Output = new FGOutput(this);
+ Output->InitModel();
+ Schedule(Output, 1);
+ Output->SetDirectivesFile(fname);
+ Output->Load(0);
+ Outputs.push_back(Output);
+ } else { // Outputs > 1
+ cerr << "First output file being overridden" << endl;
+ Outputs[0]->SetDirectivesFile(fname);
+ }
+ return result;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGFDMExec::DoTrim(int mode)
{
double saved_time;
@@ -792,7 +852,7 @@ void FGFDMExec::Debug(int from)
if (from == 0) { // Constructor
cout << "\n\n " << highint << underon << "JSBSim Flight Dynamics Model v"
<< JSBSim_version << underoff << normint << endl;
- cout << halfint << " [cfg file spec v" << needed_cfg_version << "]\n\n";
+ cout << halfint << " [JSBSim-ML v" << needed_cfg_version << "]\n\n";
cout << normint << "JSBSim startup beginning ...\n\n";
} else if (from == 3) {
cout << "\n\nJSBSim startup complete\n\n";
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index 5d4d473e1..6ae678cfd 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -2,24 +2,25 @@
Header: FGFDMExec.h
Author: Jon Berndt
Date started: 11/17/98
+ file The header file for the JSBSim executive.
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -65,6 +66,8 @@ FORWARD DECLARATIONS
namespace JSBSim {
+class FGScript;
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -121,11 +124,9 @@ CLASS DOCUMENTATION
@code
FDMExec = new JSBSim::FGFDMExec();
- Script = new JSBSim::FGScript( );
- Script->LoadScript( ScriptName ); // the script loads the aircraft and ICs
+ FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs
result = FDMExec->Run();
while (result) { // cyclic execution
- if (Scripted) if (!Script->RunScript()) break; // execute script
result = FDMExec->Run(); // execute JSBSim
}
@endcode
@@ -235,6 +236,11 @@ public:
@return true if successful*/
bool LoadModel(string model, bool addModelToPath = true);
+ /** Loads a script
+ @param Script the full path name and file name for the script to be loaded.
+ @return true if successfully loadsd; false otherwise. */
+ bool LoadScript(string Script);
+
/** Sets the path to the engine config file directories.
@param path path to the directory under which engine config
files are kept, for instance "engine" */
@@ -284,16 +290,70 @@ public:
inline string GetEnginePath(void) {return EnginePath;}
/// Retrieves the aircraft path.
inline string GetAircraftPath(void) {return AircraftPath;}
+ /// Retrieves the full aircraft path name.
+ inline string GetFullAircraftPath(void) {return FullAircraftPath;}
+
+ /** Retrieves the value of a property.
+ @param property the name of the property
+ @result the value of the specified property */
+ inline double GetPropertyValue(string property) {return instance->GetDouble(property);}
+
+ /** Sets a property value.
+ @param property the property to be set
+ @param value the value to set the property to */
+ inline void SetPropertyValue(string property, double value) {
+ instance->SetDouble(property, value);
+ }
/// Returns the model name.
string GetModelName(void) { return modelName; }
+ /// Returns the current time.
+ double GetSimTime(void);
+
+ /// Returns the current frame time (delta T).
+ double GetDeltaT(void);
+
/// Returns a pointer to the property manager object.
FGPropertyManager* GetPropertyManager(void);
/// Returns a vector of strings representing the names of all loaded models (future)
vector EnumerateFDMs(void);
/// Marks this instance of the Exec object as a "slave" object.
- void SetSlave(void) {IsSlave = true;}
+ void SetSlave(bool s) {IsSlave = s;}
+
+ /** Sets the output (logging) mechanism for this run.
+ Calling this function passes the name of an output directives file to
+ the FGOutput object associated with this run. The call to this function
+ should be made prior to loading an aircraft model. This call results in an
+ FGOutput object being built as the first Output object in the FDMExec-managed
+ list of Output objects that may be created for an aircraft model. If this call
+ is made after an aircraft model is loaded, there is no effect. Any Output
+ objects added by the aircraft model itself (in an <output> element) will be
+ added after this one. Care should be taken not to refer to the same file
+ name.
+ An output directives file contains an <output> </output> element, within
+ which should be specified the parameters or parameter groups that should
+ be logged.
+ @param fname the filename of an output directives file.
+ */
+ bool SetOutputDirectives(string fname);
+
+ /** Sets (or overrides) the output filename
+ @param fname the name of the file to output data to
+ @return true if successful, false if there is no output specified for the flight model */
+ bool SetOutputFileName(string fname) {
+ if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
+ else return false;
+ return true;
+ }
+
+ /** Retrieves the current output filename.
+ @return the name of the output file for the first output specified by the flight model.
+ If none is specified, the empty string is returned. */
+ string GetOutputFileName(void) {
+ if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
+ else return string("");
+ }
/** Executes trimming in the selected mode.
* @param mode Specifies how to trim:
@@ -316,6 +376,8 @@ public:
void Resume(void) {holding = false;}
/// Returns true if the simulation is Holding (i.e. simulation time is not moving).
bool Holding(void) {return holding;}
+ /// Sets the debug level.
+ void SetDebugLevel(int level) {debug_lvl = level;}
struct PropertyCatalogStructure {
/// Name of the property.
@@ -338,6 +400,9 @@ public:
* in the catalog. */
string QueryPropertyCatalog(string check);
+ // Print the contents of the property catalog for the loaded aircraft.
+ void PrintPropertyCatalog(void);
+
/// Use the MSIS atmosphere model.
void UseAtmosphereMSIS(void);
@@ -345,22 +410,20 @@ public:
void UseAtmosphereMars(void);
private:
- FGModel* FirstModel;
-
- bool terminate;
- bool holding;
- bool Constructing;
- int Error;
+ static unsigned int FDMctr;
+ int Error;
unsigned int Frame;
unsigned int IdFDM;
- FGPropertyManager* Root;
- static unsigned int FDMctr;
+ bool holding;
+ bool Constructing;
bool modelLoaded;
- string modelName;
bool IsSlave;
- static FGPropertyManager *master;
- FGPropertyManager *instance;
- vector PropertyCatalog;
+ string modelName;
+ string AircraftPath;
+ string FullAircraftPath;
+ string EnginePath;
+ string CFGVersion;
+ string Release;
struct slaveData {
FGFDMExec* exec;
@@ -381,41 +444,41 @@ private:
}
};
- string AircraftPath;
- string EnginePath;
-
- string CFGVersion;
- string Release;
-
- FGGroundCallback* GroundCallback;
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGPropulsion* Propulsion;
- FGMassBalance* MassBalance;
- FGAerodynamics* Aerodynamics;
- FGInertial* Inertial;
- FGGroundReactions* GroundReactions;
- FGAircraft* Aircraft;
- FGPropagate* Propagate;
- FGAuxiliary* Auxiliary;
- FGInput* Input;
- vector Outputs;
+ static FGPropertyManager *master;
+ FGModel* FirstModel;
+ FGGroundCallback* GroundCallback;
+ FGState* State;
+ FGAtmosphere* Atmosphere;
+ FGFCS* FCS;
+ FGPropulsion* Propulsion;
+ FGMassBalance* MassBalance;
+ FGAerodynamics* Aerodynamics;
+ FGInertial* Inertial;
+ FGGroundReactions* GroundReactions;
+ FGAircraft* Aircraft;
+ FGPropagate* Propagate;
+ FGAuxiliary* Auxiliary;
+ FGInput* Input;
+ FGScript* Script;
FGInitialCondition* IC;
- FGTrim *Trim;
+ FGTrim* Trim;
+ FGPropertyManager* Root;
+ FGPropertyManager* instance;
+
+ vector PropertyCatalog;
+ vector Outputs;
vector SlaveFDMList;
bool ReadFileHeader(Element*);
bool ReadSlave(Element*);
bool ReadPrologue(Element*);
-
bool Allocate(void);
bool DeAllocate(void);
+
void Debug(int from);
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
-
diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp
index c6fcc0f6c..bda88a1f8 100644
--- a/src/FDM/JSBSim/FGJSBBase.cpp
+++ b/src/FDM/JSBSim/FGJSBBase.cpp
@@ -8,20 +8,20 @@
------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
@@ -94,7 +94,7 @@ const double FGJSBBase::slugtolb = 32.174049;
const double FGJSBBase::lbtoslug = 1.0/slugtolb;
const string FGJSBBase::needed_cfg_version = "2.0";
-const string FGJSBBase::JSBSim_version = "0.9.10.111805";
+const string FGJSBBase::JSBSim_version = "0.9.12 "__DATE__" "__TIME__;
std::queue FGJSBBase::Messages;
FGJSBBase::Message FGJSBBase::localMsg;
diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h
index c09104c9a..1fda8afc7 100644
--- a/src/FDM/JSBSim/FGJSBBase.h
+++ b/src/FDM/JSBSim/FGJSBBase.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -218,6 +218,13 @@ public:
return (rankine - 491.67)/1.8;
}
+ /** Converts from degrees Rankine to degrees Kelvin.
+ * @param rankine The temperature in degrees Rankine.
+ * @return The temperature in Kelvin. */
+ static double RankineToKelvin (double rankine) {
+ return rankine/1.8;
+ }
+
/** Converts from degrees Fahrenheit to degrees Celsius.
* @param fahrenheit The temperature in degrees Fahrenheit.
* @return The temperature in Celsius. */
diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp
index 73c3529e4..8945abdd4 100644
--- a/src/FDM/JSBSim/FGState.cpp
+++ b/src/FDM/JSBSim/FGState.cpp
@@ -8,20 +8,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h
index 9e5f97039..aad679f37 100644
--- a/src/FDM/JSBSim/FGState.h
+++ b/src/FDM/JSBSim/FGState.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index 44c99315b..80ee3ee03 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -262,6 +262,8 @@ FGJSBsim::FGJSBsim( double dt )
wind_from_east = fgGetNode("/environment/wind-from-east-fps" ,true);
wind_from_down = fgGetNode("/environment/wind-from-down-fps" ,true);
+ slaved = fgGetNode("/sim/slaved/enabled", true);
+
for (unsigned int i = 0; i < Propulsion->GetNumEngines(); i++) {
SGPropertyNode * node = fgGetNode("engines/engine", i, true);
Propulsion->GetEngine(i)->GetThruster()->SetRPM(node->getDoubleValue("rpm") /
@@ -601,6 +603,7 @@ bool FGJSBsim::copy_to_JSBsim()
SGPropertyNode* node = fgGetNode("/systems/refuel", true);
Propulsion->SetRefuel(node->getDoubleValue("contact"));
Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
+ fdmex->SetSlave(slaved->getBoolValue());
return true;
}
diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx
index 3f4d33465..098cc38e3 100644
--- a/src/FDM/JSBSim/JSBSim.hxx
+++ b/src/FDM/JSBSim/JSBSim.hxx
@@ -226,40 +226,42 @@ private:
double trim_elev;
double trim_throttle;
- SGPropertyNode_ptr startup_trim;
- SGPropertyNode_ptr trimmed;
- SGPropertyNode_ptr pitch_trim;
- SGPropertyNode_ptr throttle_trim;
- SGPropertyNode_ptr aileron_trim;
- SGPropertyNode_ptr rudder_trim;
- SGPropertyNode_ptr stall_warning;
-
- /* SGPropertyNode_ptr elevator_pos_deg;
- SGPropertyNode_ptr left_aileron_pos_deg;
- SGPropertyNode_ptr right_aileron_pos_deg;
- SGPropertyNode_ptr rudder_pos_deg;
- SGPropertyNode_ptr flap_pos_deg; */
-
-
- SGPropertyNode_ptr elevator_pos_pct;
- SGPropertyNode_ptr left_aileron_pos_pct;
- SGPropertyNode_ptr right_aileron_pos_pct;
- SGPropertyNode_ptr rudder_pos_pct;
- SGPropertyNode_ptr flap_pos_pct;
- SGPropertyNode_ptr speedbrake_pos_pct;
- SGPropertyNode_ptr spoilers_pos_pct;
-
- SGPropertyNode_ptr gear_pos_pct;
-
- SGPropertyNode_ptr temperature;
- SGPropertyNode_ptr pressure;
- SGPropertyNode_ptr density;
- SGPropertyNode_ptr turbulence_gain;
- SGPropertyNode_ptr turbulence_rate;
-
- SGPropertyNode_ptr wind_from_north;
- SGPropertyNode_ptr wind_from_east;
- SGPropertyNode_ptr wind_from_down;
+ SGPropertyNode *startup_trim;
+ SGPropertyNode *trimmed;
+ SGPropertyNode *pitch_trim;
+ SGPropertyNode *throttle_trim;
+ SGPropertyNode *aileron_trim;
+ SGPropertyNode *rudder_trim;
+ SGPropertyNode *stall_warning;
+
+ /* SGPropertyNode *elevator_pos_deg;
+ SGPropertyNode *left_aileron_pos_deg;
+ SGPropertyNode *right_aileron_pos_deg;
+ SGPropertyNode *rudder_pos_deg;
+ SGPropertyNode *flap_pos_deg; */
+
+
+ SGPropertyNode *elevator_pos_pct;
+ SGPropertyNode *left_aileron_pos_pct;
+ SGPropertyNode *right_aileron_pos_pct;
+ SGPropertyNode *rudder_pos_pct;
+ SGPropertyNode *flap_pos_pct;
+ SGPropertyNode *speedbrake_pos_pct;
+ SGPropertyNode *spoilers_pos_pct;
+
+ SGPropertyNode *gear_pos_pct;
+
+ SGPropertyNode *temperature;
+ SGPropertyNode *pressure;
+ SGPropertyNode *density;
+ SGPropertyNode *turbulence_gain;
+ SGPropertyNode *turbulence_rate;
+
+ SGPropertyNode *wind_from_north;
+ SGPropertyNode *wind_from_east;
+ SGPropertyNode *wind_from_down;
+
+ SGPropertyNode *slaved;
void init_gear(void);
void update_gear(void);
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
index 02262b092..9ee9d094e 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
@@ -731,7 +731,7 @@ double FGInitialCondition::GetWindDirDegIC(void) const {
bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
{
- string resetDef, acpath;
+ string resetDef;
ifstream initialization_file;
FGXMLParse initialization_file_parser;
Element *document, *el;
@@ -739,12 +739,11 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
string sep = "/";
# ifdef macintosh
- string sep = ";";
+ sep = ";";
# endif
if( useStoredPath ) {
- acpath = fdmex->GetAircraftPath() + sep + fdmex->GetModelName();
- resetDef = acpath + sep + rstfile + ".xml";
+ resetDef = fdmex->GetFullAircraftPath() + sep + rstfile + ".xml";
} else {
resetDef = rstfile;
}
@@ -773,20 +772,6 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
SetLatitudeDegIC(document->FindElementValueAsNumberConvertTo("latitude", "DEG"));
if (document->FindElement("longitude"))
SetLongitudeDegIC(document->FindElementValueAsNumberConvertTo("longitude", "DEG"));
- if (document->FindElement("phi"))
- SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG"));
- if (document->FindElement("theta"))
- SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG"));
- if (document->FindElement("psi"))
- SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG"));
- if (document->FindElement("alpha"))
- SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG"));
- if (document->FindElement("beta"))
- SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG"));
- if (document->FindElement("gamma"))
- SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG"));
- if (document->FindElement("roc"))
- SetClimbRateFpmIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC"));
if (document->FindElement("altitude"))
SetAltitudeFtIC(document->FindElementValueAsNumberConvertTo("altitude", "FT"));
if (document->FindElement("winddir"))
@@ -801,6 +786,20 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
SetVcalibratedKtsIC(document->FindElementValueAsNumberConvertTo("vc", "FT/SEC"));
if (document->FindElement("mach"))
SetMachIC(document->FindElementValueAsNumber("mach"));
+ if (document->FindElement("phi"))
+ SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG"));
+ if (document->FindElement("theta"))
+ SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG"));
+ if (document->FindElement("psi"))
+ SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG"));
+ if (document->FindElement("alpha"))
+ SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG"));
+ if (document->FindElement("beta"))
+ SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG"));
+ if (document->FindElement("gamma"))
+ SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG"));
+ if (document->FindElement("roc"))
+ SetClimbRateFpsIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC"));
if (document->FindElement("vground"))
SetVgroundKtsIC(document->FindElementValueAsNumberConvertTo("vground", "FT/SEC"));
if (document->FindElement("running")) {
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.h b/src/FDM/JSBSim/initialization/FGInitialCondition.h
index 67a94e343..077f001f7 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.h
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -70,7 +70,8 @@ typedef enum { setwned, setwmd, setwhc } windset;
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/** Takes a set of initial conditions and provide a kinematically consistent set
+/** Initializes the simulation run.
+ Takes a set of initial conditions (IC) and provide a kinematically consistent set
of body axis velocity components, euler angles, and altitude. This class
does not attempt to trim the model i.e. the sim will most likely start in a
very dynamic state (unless, of course, you have chosen your IC's wisely, or
@@ -449,11 +450,11 @@ public:
inline double GetWindNFpsIC(void) const { return wnorth; }
/** Gets the initial wind velocity in local frame.
- @return Initial wind velocity toward north in feet/second */
+ @return Initial wind velocity eastwards in feet/second */
inline double GetWindEFpsIC(void) const { return weast; }
/** Gets the initial wind velocity in local frame.
- @return Initial wind velocity toward north in feet/second */
+ @return Initial wind velocity downwards in feet/second */
inline double GetWindDFpsIC(void) const { return wdown; }
/** Gets the initial total wind velocity in feet/sec.
diff --git a/src/FDM/JSBSim/initialization/FGTrim.cpp b/src/FDM/JSBSim/initialization/FGTrim.cpp
index c5d42cc7c..854519c61 100644
--- a/src/FDM/JSBSim/initialization/FGTrim.cpp
+++ b/src/FDM/JSBSim/initialization/FGTrim.cpp
@@ -7,20 +7,20 @@
--------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ---------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
diff --git a/src/FDM/JSBSim/initialization/FGTrim.h b/src/FDM/JSBSim/initialization/FGTrim.h
index d41708d4b..9fd38efbd 100644
--- a/src/FDM/JSBSim/initialization/FGTrim.h
+++ b/src/FDM/JSBSim/initialization/FGTrim.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
@@ -79,7 +79,7 @@ typedef enum { tLongitudinal=0, tFull, tGround, tPullup,
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/** FGTrim -- the trimming routine for JSBSim.
+/** The trimming routine for JSBSim.
FGTrim finds the aircraft attitude and control settings needed to maintain
the steady state described by the FGInitialCondition object . It does this
iteratively by assigning a control to each state and adjusting that control
@@ -122,6 +122,7 @@ CLASS DOCUMENTATION
}
fgt.Report();
@endcode
+
@author Tony Peden
@version "$Id$"
*/
diff --git a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
index c7b692a37..8557adc89 100644
--- a/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
+++ b/src/FDM/JSBSim/initialization/FGTrimAxis.cpp
@@ -7,20 +7,20 @@
--------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) ---------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
@@ -181,8 +181,8 @@ void FGTrimAxis::getState(void) {
void FGTrimAxis::getControl(void) {
switch(control) {
case tThrottle: control_value=fdmex->GetFCS()->GetThrottleCmd(0); break;
- case tBeta: control_value=fdmex->GetAuxiliary()->Getalpha(); break;
- case tAlpha: control_value=fdmex->GetAuxiliary()->Getbeta(); break;
+ case tBeta: control_value=fdmex->GetAuxiliary()->Getbeta(); break;
+ case tAlpha: control_value=fdmex->GetAuxiliary()->Getalpha(); break;
case tPitchTrim: control_value=fdmex->GetFCS() -> GetPitchTrimCmd(); break;
case tElevator: control_value=fdmex->GetFCS() -> GetDeCmd(); break;
case tRollTrim:
diff --git a/src/FDM/JSBSim/initialization/FGTrimAxis.h b/src/FDM/JSBSim/initialization/FGTrimAxis.h
index e0754a03c..ac3d45f8f 100644
--- a/src/FDM/JSBSim/initialization/FGTrimAxis.h
+++ b/src/FDM/JSBSim/initialization/FGTrimAxis.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -89,12 +89,20 @@ enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
class FGTrimAxis : public FGJSBBase
{
public:
+ /** Constructor for Trim Axis class.
+ @param fdmex FGFDMExec pointer
+ @param IC pointer to initial conditions instance
+ @param state a State type (enum)
+ @param control a Control type (enum) */
FGTrimAxis(FGFDMExec* fdmex,
- FGInitialCondition *ic,
- State st,
- Control ctrl );
+ FGInitialCondition *IC,
+ State state,
+ Control control );
+ /// Destructor
~FGTrimAxis();
+ /** This function iterates through a call to the FGFDMExec::RunIC()
+ function until the desired trimming condition falls inside a tolerance.*/
void Run(void);
double GetState(void) { getState(); return state_value; }
diff --git a/src/FDM/JSBSim/input_output/FGGroundCallback.cpp b/src/FDM/JSBSim/input_output/FGGroundCallback.cpp
index 8b9a5674b..a0236a2d7 100644
--- a/src/FDM/JSBSim/input_output/FGGroundCallback.cpp
+++ b/src/FDM/JSBSim/input_output/FGGroundCallback.cpp
@@ -7,20 +7,20 @@
------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
diff --git a/src/FDM/JSBSim/input_output/FGGroundCallback.h b/src/FDM/JSBSim/input_output/FGGroundCallback.h
index 8abffcff3..0a5a7af67 100644
--- a/src/FDM/JSBSim/input_output/FGGroundCallback.h
+++ b/src/FDM/JSBSim/input_output/FGGroundCallback.h
@@ -7,20 +7,20 @@
------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
index 63bc58951..61aed893f 100755
--- a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
+++ b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
@@ -8,20 +8,20 @@
------------- Copyright (C) 2002 -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.h b/src/FDM/JSBSim/input_output/FGPropertyManager.h
index 284c74761..001d16db4 100644
--- a/src/FDM/JSBSim/input_output/FGPropertyManager.h
+++ b/src/FDM/JSBSim/input_output/FGPropertyManager.h
@@ -8,20 +8,20 @@
------------- Copyright (C) 2002 -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -78,7 +78,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
/// Constructor
FGPropertyManager(void) {suppress_warning = false;}
/// Destructor
- ~FGPropertyManager(void) {}
+ virtual ~FGPropertyManager(void) {}
/** Property-ify a name
* replaces spaces with '-' and, optionally, makes name all lower case
diff --git a/src/FDM/JSBSim/input_output/FGScript.cpp b/src/FDM/JSBSim/input_output/FGScript.cpp
index 83e87f752..797a5bf49 100755
--- a/src/FDM/JSBSim/input_output/FGScript.cpp
+++ b/src/FDM/JSBSim/input_output/FGScript.cpp
@@ -8,20 +8,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
@@ -55,7 +55,7 @@ INCLUDES
#endif
#include "FGScript.h"
-#include "FGXMLParse.h"
+#include
#include
namespace JSBSim {
@@ -84,6 +84,14 @@ FGScript::FGScript(FGFDMExec* fgex) : FDMExec(fgex)
FGScript::~FGScript()
{
+ int i;
+ for (i=0; iUntie(local_properties[i]->title);
+
+ for (i=0; iGetAttributeValue("name");
+
+ // First, find "run" element and set delta T
+
+ run_element = document->FindElement("run");
+
+ if (!run_element) {
+ cerr << "No \"run\" element found in script." << endl;
+ return false;
+ }
+
+ // Set sim timing
+
+ StartTime = run_element->GetAttributeValueAsNumber("start");
+ State->Setsim_time(StartTime);
+ EndTime = run_element->GetAttributeValueAsNumber("end");
+ dt = run_element->GetAttributeValueAsNumber("dt");
+ State->Setdt(dt);
+
// read aircraft and initialization files
element = document->FindElement("use");
@@ -119,88 +150,108 @@ bool FGScript::LoadScript( string script )
result = FDMExec->LoadModel(aircraft);
if (!result) return false;
} else {
- cerr << "Aircraft must be specified first in script file." << endl;
+ cerr << "Aircraft must be specified in use element." << endl;
return false;
}
- element = document->FindNextElement("use");
initialize = element->GetAttributeValue("initialize");
+ if (initialize.empty()) {
+ cerr << "Initialization file must be specified in use element." << endl;
+ return false;
+ }
} else {
cerr << "No \"use\" directives in the script file." << endl;
return false;
}
- run_element = document->FindElement("run");
-
- if (!run_element) {
- cerr << "No \"run\" element found in script." << endl;
- return false;
+ // Read local property declarations
+ property_element = run_element->FindElement("property");
+ while (property_element) {
+ LocalProps *localProp = new LocalProps();
+ localProp->title = property_element->GetDataLine();
+ local_properties.push_back(localProp);
+ PropertyManager->Tie(localProp->title, (local_properties.back())->value);
+ property_element = run_element->FindNextElement("property");
}
- // Set sim timing
+ // Read "events" from script
- StartTime = run_element->GetAttributeValueAsNumber("start");
- State->Setsim_time(StartTime);
- EndTime = run_element->GetAttributeValueAsNumber("end");
- dt = run_element->GetAttributeValueAsNumber("dt");
- State->Setdt(dt);
+ event_element = run_element->FindElement("event");
+ while (event_element) { // event processing
+
+ // Create the event structure
+ newEvent = new struct event();
+
+ // Retrieve the event name if given
+ newEvent->Name = event_element->GetAttributeValue("name");
- // read "when" tests from script
-
- when_element = run_element->FindElement("when");
- while (when_element) { // "when" processing
- newCondition = new struct condition();
-
- // read parameters
- parameter_element = when_element->FindElement("parameter");
- while (parameter_element) {
- prop_name = parameter_element->GetAttributeValue("name");
- newCondition->TestParam.push_back( PropertyManager->GetNode(prop_name) );
- value = parameter_element->GetAttributeValueAsNumber("value");
- newCondition->TestValue.push_back(value);
- comparison = parameter_element->GetAttributeValue("comparison");
- newCondition->Comparison.push_back(comparison);
- parameter_element = when_element->FindNextElement("parameter");
+ // Is this event persistent? That is, does it execute repeatedly as long as the
+ // condition is true, or does it execute as a one-shot event, only?
+ if (event_element->GetAttributeValue("persistent") == string("true")) {
+ newEvent->Persistent = true;
}
- // read set definitions
- set_element = when_element->FindElement("set");
+ // Process the conditions
+ condition_element = event_element->FindElement("condition");
+ if (condition_element != 0) {
+ newCondition = new FGCondition(condition_element, PropertyManager);
+ newEvent->Condition = newCondition;
+ } else {
+ cerr << "No condition specified in script event " << newEvent->Name << endl;
+ return false;
+ }
+
+ // Is there a delay between the time this event is triggered, and when the event
+ // actions are executed?
+
+ delay_element = event_element->FindElement("delay");
+ if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay");
+ else newEvent->Delay = 0.0;
+
+ // Notify about when this event is triggered?
+ if ((notify_element = event_element->FindElement("notify")) != 0) {
+ newEvent->Notify = true;
+ notify_property_element = notify_element->FindElement("property");
+ while (notify_property_element) {
+ notifyPropertyName = notify_property_element->GetDataLine();
+ newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) );
+ notify_property_element = notify_element->FindNextElement("property");
+ }
+ }
+
+ // Read set definitions (these define the actions to be taken when the event is triggered).
+ set_element = event_element->FindElement("set");
while (set_element) {
prop_name = set_element->GetAttributeValue("name");
- newCondition->SetParam.push_back( PropertyManager->GetNode(prop_name) );
+ newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
value = set_element->GetAttributeValueAsNumber("value");
- newCondition->SetValue.push_back(value);
- newCondition->Triggered.push_back(false);
- newCondition->OriginalValue.push_back(0.0);
- newCondition->newValue.push_back(0.0);
- newCondition->StartTime.push_back(0.0);
- newCondition->EndTime.push_back(0.0);
+ newEvent->SetValue.push_back(value);
+ newEvent->OriginalValue.push_back(0.0);
+ newEvent->newValue.push_back(0.0);
+ newEvent->ValueSpan.push_back(0.0);
string tempCompare = set_element->GetAttributeValue("type");
- if (tempCompare == "FG_DELTA") newCondition->Type.push_back(FG_DELTA);
- else if (tempCompare == "FG_BOOL") newCondition->Type.push_back(FG_BOOL);
- else if (tempCompare == "FG_VALUE") newCondition->Type.push_back(FG_VALUE);
- else newCondition->Type.push_back(FG_VALUE); // DEFAULT
+ if (tempCompare == "FG_DELTA") newEvent->Type.push_back(FG_DELTA);
+ else if (tempCompare == "FG_BOOL") newEvent->Type.push_back(FG_BOOL);
+ else if (tempCompare == "FG_VALUE") newEvent->Type.push_back(FG_VALUE);
+ else newEvent->Type.push_back(FG_VALUE); // DEFAULT
tempCompare = set_element->GetAttributeValue("action");
- if (tempCompare == "FG_RAMP") newCondition->Action.push_back(FG_RAMP);
- else if (tempCompare == "FG_STEP") newCondition->Action.push_back(FG_STEP);
- else if (tempCompare == "FG_EXP") newCondition->Action.push_back(FG_EXP);
- else newCondition->Action.push_back(FG_STEP); // DEFAULT
-
- if (set_element->GetAttributeValue("persistent") == "true")
- newCondition->Persistent.push_back(true);
- else
- newCondition->Persistent.push_back(false); // DEFAULT
+ if (tempCompare == "FG_RAMP") newEvent->Action.push_back(FG_RAMP);
+ else if (tempCompare == "FG_STEP") newEvent->Action.push_back(FG_STEP);
+ else if (tempCompare == "FG_EXP") newEvent->Action.push_back(FG_EXP);
+ else newEvent->Action.push_back(FG_STEP); // DEFAULT
if (!set_element->GetAttributeValue("tc").empty())
- newCondition->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
+ newEvent->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
else
- newCondition->TC.push_back(1.0); // DEFAULT
+ newEvent->TC.push_back(1.0); // DEFAULT
- set_element = when_element->FindNextElement("set");
+ newEvent->Transiting.push_back(false);
+
+ set_element = event_element->FindNextElement("set");
}
- Conditions.push_back(*newCondition);
- when_element = run_element->FindNextElement("when");
+ Events.push_back(*newEvent);
+ event_element = run_element->FindNextElement("event");
}
Debug(4);
@@ -218,89 +269,90 @@ bool FGScript::LoadScript( string script )
bool FGScript::RunScript(void)
{
- vector ::iterator iC = Conditions.begin();
- bool truth = false;
- bool WholeTruth = false;
- unsigned i;
+ vector ::iterator iEvent = Events.begin();
+ unsigned i, j;
+ unsigned event_ctr = 0;
double currentTime = State->Getsim_time();
double newSetValue = 0;
- if (currentTime > EndTime) return false;
-
- while (iC < Conditions.end()) {
- // determine whether the set of conditional tests for this condition equate
- // to true
- for (i=0; iTestValue.size(); i++) {
- if (iC->Comparison[i] == "lt")
- truth = iC->TestParam[i]->getDoubleValue() < iC->TestValue[i];
- else if (iC->Comparison[i] == "le")
- truth = iC->TestParam[i]->getDoubleValue() <= iC->TestValue[i];
- else if (iC->Comparison[i] == "eq")
- truth = iC->TestParam[i]->getDoubleValue() == iC->TestValue[i];
- else if (iC->Comparison[i] == "ge")
- truth = iC->TestParam[i]->getDoubleValue() >= iC->TestValue[i];
- else if (iC->Comparison[i] == "gt")
- truth = iC->TestParam[i]->getDoubleValue() > iC->TestValue[i];
- else if (iC->Comparison[i] == "ne")
- truth = iC->TestParam[i]->getDoubleValue() != iC->TestValue[i];
- else
- cerr << "Bad comparison" << endl;
-
- if (i == 0) WholeTruth = truth;
- else WholeTruth = WholeTruth && truth;
-
- if (!truth && iC->Persistent[i] && iC->Triggered[i]) iC->Triggered[i] = false;
- }
+ if (currentTime > EndTime) return false; //Script done!
- // if the conditions are true, do the setting of the desired parameters
+ // Iterate over all events.
+ while (iEvent < Events.end()) {
+ iEvent->PrevTriggered = iEvent->Triggered;
+ // Determine whether the set of conditional tests for this condition equate
+ // to true and should cause the event to execute.
+ if (iEvent->Condition->Evaluate()) {
+ if (!iEvent->Triggered) {
- if (WholeTruth) {
- for (i=0; iSetValue.size(); i++) {
- if ( ! iC->Triggered[i]) {
- iC->OriginalValue[i] = iC->SetParam[i]->getDoubleValue();
- switch (iC->Type[i]) {
+ // The conditions are true, do the setting of the desired Event parameters
+ for (i=0; iSetValue.size(); i++) {
+ iEvent->OriginalValue[i] = iEvent->SetParam[i]->getDoubleValue();
+ switch (iEvent->Type[i]) {
case FG_VALUE:
- iC->newValue[i] = iC->SetValue[i];
+ case FG_BOOL:
+ iEvent->newValue[i] = iEvent->SetValue[i];
break;
case FG_DELTA:
- iC->newValue[i] = iC->OriginalValue[i] + iC->SetValue[i];
- break;
- case FG_BOOL:
- iC->newValue[i] = iC->SetValue[i];
+ iEvent->newValue[i] = iEvent->OriginalValue[i] + iEvent->SetValue[i];
break;
default:
cerr << "Invalid Type specified" << endl;
break;
}
- iC->Triggered[i] = true;
- iC->StartTime[i] = currentTime;
+ iEvent->StartTime = currentTime + iEvent->Delay;
+ iEvent->ValueSpan[i] = iEvent->newValue[i] - iEvent->OriginalValue[i];
+ iEvent->Transiting[i] = true;
}
+ }
+ iEvent->Triggered = true;
+ } else if (iEvent->Persistent) {
+ iEvent->Triggered = false; // Reset the trigger for persistent events
+ }
- double time_span = currentTime - iC->StartTime[i];
- double value_span = iC->newValue[i] - iC->OriginalValue[i];
-
- switch (iC->Action[i]) {
- case FG_RAMP:
- if (time_span <= iC->TC[i])
- newSetValue = time_span/iC->TC[i] * value_span + iC->OriginalValue[i];
- else
- newSetValue = iC->newValue[i];
- break;
- case FG_STEP:
- newSetValue = iC->newValue[i];
- break;
- case FG_EXP:
- newSetValue = (1 - exp( -time_span/iC->TC[i] )) * value_span + iC->OriginalValue[i];
- break;
- default:
- cerr << "Invalid Action specified" << endl;
- break;
+ if ((currentTime >= iEvent->StartTime) && iEvent->Triggered) {
+
+ if (iEvent->Notify && iEvent->PrevTriggered != iEvent->Triggered) {
+ cout << endl << " Event " << event_ctr << " (" << iEvent->Name << ")"
+ << " executed at time: " << currentTime << endl;
+ for (j=0; jNotifyProperties.size();j++) {
+ cout << " " << iEvent->NotifyProperties[j]->GetName()
+ << " = " << iEvent->NotifyProperties[j]->getDoubleValue() << endl;
+ }
+ cout << endl;
+ }
+
+ for (i=0; iSetValue.size(); i++) {
+ if (iEvent->Transiting[i]) {
+ iEvent->TimeSpan = currentTime - iEvent->StartTime;
+ switch (iEvent->Action[i]) {
+ case FG_RAMP:
+ if (iEvent->TimeSpan <= iEvent->TC[i]) {
+ newSetValue = iEvent->TimeSpan/iEvent->TC[i] * iEvent->ValueSpan[i] + iEvent->OriginalValue[i];
+ } else {
+ newSetValue = iEvent->newValue[i];
+ iEvent->Transiting[i] = false;
+ }
+ break;
+ case FG_STEP:
+ newSetValue = iEvent->newValue[i];
+ iEvent->Transiting[i] = false;
+ break;
+ case FG_EXP:
+ newSetValue = (1 - exp( -iEvent->TimeSpan/iEvent->TC[i] )) * iEvent->ValueSpan[i] + iEvent->OriginalValue[i];
+ break;
+ default:
+ cerr << "Invalid Action specified" << endl;
+ break;
+ }
+ iEvent->SetParam[i]->setDoubleValue(newSetValue);
}
- iC->SetParam[i]->setDoubleValue(newSetValue);
}
}
- iC++;
+
+ iEvent++;
+ event_ctr++;
}
return true;
}
@@ -326,80 +378,67 @@ bool FGScript::RunScript(void)
void FGScript::Debug(int from)
{
- unsigned int i;
-
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
} else if (from == 3) {
} else if (from == 4) { // print out script data
- vector ::iterator iterConditions = Conditions.begin();
- int count=0;
+ cout << endl;
+ cout << "Script: \"" << ScriptName << "\"" << endl;
+ cout << " begins at " << StartTime << " seconds and runs to " << EndTime
+ << " seconds with dt = " << State->Getdt() << endl;
+ cout << endl;
- cout << "\n Script goes from " << StartTime << " to " << EndTime
- << " with dt = " << State->Getdt() << endl << endl;
+ for (unsigned i=0; iTestValue.size(); i++) {
- if (i>0) cout << " and" << endl << " ";
- cout << "(" << iterConditions->TestParam[i]->GetName()
- << " " << iterConditions->Comparison[i] << " "
- << iterConditions->TestValue[i] << ")";
- }
- cout << ") then {";
+ Events[i].Condition->PrintCondition();
- for (i=0; iSetValue.size(); i++) {
- cout << endl << " set " << iterConditions->SetParam[i]->GetName()
- << " to " << iterConditions->SetValue[i];
+ cout << endl << " Actions taken:" << endl << " {";
+ for (unsigned j=0; jGetName()
+ << " to " << Events[i].SetValue[j];
- switch (iterConditions->Type[i]) {
+ switch (Events[i].Type[j]) {
case FG_VALUE:
+ case FG_BOOL:
cout << " (constant";
break;
case FG_DELTA:
cout << " (delta";
break;
- case FG_BOOL:
- cout << " (boolean";
- break;
default:
cout << " (unspecified type";
}
- switch (iterConditions->Action[i]) {
+ switch (Events[i].Action[j]) {
case FG_RAMP:
cout << " via ramp";
break;
case FG_STEP:
- cout << " via step";
+ cout << " via step)";
break;
case FG_EXP:
cout << " via exponential approach";
break;
default:
- cout << " via unspecified action";
+ cout << " via unspecified action)";
}
- if (!iterConditions->Persistent[i]) cout << endl
- << " once";
- else cout << endl
- << " repeatedly";
-
- if (iterConditions->Action[i] == FG_RAMP ||
- iterConditions->Action[i] == FG_EXP) cout << endl
- << " with time constant "
- << iterConditions->TC[i];
+ if (Events[i].Action[j] == FG_RAMP || Events[i].Action[j] == FG_EXP)
+ cout << " with time constant " << Events[i].TC[j] << ")";
}
- cout << ")" << endl << " }" << endl << endl;
+ cout << endl << " }" << endl << endl;
- iterConditions++;
}
-
- cout << endl;
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
diff --git a/src/FDM/JSBSim/input_output/FGScript.h b/src/FDM/JSBSim/input_output/FGScript.h
index 7b4587a92..903057a1d 100644
--- a/src/FDM/JSBSim/input_output/FGScript.h
+++ b/src/FDM/JSBSim/input_output/FGScript.h
@@ -6,20 +6,20 @@
------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -40,6 +40,7 @@ INCLUDES
#include "FGJSBBase.h"
#include "FGState.h"
#include "FGFDMExec.h"
+#include
@author Jon S. Berndt
@version "$Id$"
-
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -136,13 +172,13 @@ public:
~FGScript();
/** Loads a script to drive JSBSim (usually in standalone mode).
- The language is the Simple Script Directives for JSBSim (SSDJ).
+ The language is the Script Directives for JSBSim.
@param script the filename (including path name, if any) for the script.
@return true if successful */
bool LoadScript( string script );
/** This function is called each pass through the executive Run() method IF
- scripting is enabled.
+ scripting is enabled.
@return false if script should exit (i.e. if time limits are violated */
bool RunScript(void);
@@ -159,32 +195,53 @@ private:
FG_BOOL = 3
};
- struct condition {
- vector TestParam;
+ struct event {
+ FGCondition *Condition;
+ bool Persistent;
+ bool Triggered;
+ bool PrevTriggered;
+ bool Notify;
+ double Delay;
+ double StartTime;
+ double TimeSpan;
+ string Name;
vector SetParam;
- vector TestValue;
- vector SetValue;
- vector Comparison;
- vector TC;
- vector Persistent;
+ vector NotifyProperties;
vector Action;
vector Type;
- vector Triggered;
+ vector SetValue;
+ vector TC;
vector newValue;
vector OriginalValue;
- vector StartTime;
- vector EndTime;
-
- condition() {
+ vector ValueSpan;
+ vector Transiting;
+
+ event() {
+ Triggered = false;
+ PrevTriggered = false;
+ Persistent = false;
+ Delay = 0.0;
+ Notify = false;
+ Name = "";
+ StartTime = 0.0;
+ TimeSpan = 0.0;
}
};
- bool Scripted;
+ struct LocalProps {
+ double *value;
+ string title;
+ LocalProps() {
+ value = new double(0.0);
+ title = "";
+ }
+ };
string ScriptName;
double StartTime;
double EndTime;
- vector Conditions;
+ vector Events;
+ vector local_properties;
FGFDMExec* FDMExec;
FGState* State;
diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.cpp b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
index 5b1970441..64d2a38ed 100755
--- a/src/FDM/JSBSim/input_output/FGXMLElement.cpp
+++ b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
@@ -5,6 +5,25 @@
Purpose: XML element class
Called by: FGXMLParse
+ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -78,6 +97,8 @@ Element::Element(string nm)
convert["FT/SEC"]["KTS"] = 1.0/convert["KTS"]["FT/SEC"];
convert["FT*LBS"]["N*M"] = 1.35581795;
convert["N*M"]["FT*LBS"] = 1/convert["FT*LBS"]["N*M"];
+ convert["IN"]["M"] = convert["IN"]["FT"] * convert["FT"]["M"];
+ convert["M"]["IN"] = convert["M"]["FT"] * convert["FT"]["IN"];
convert["M"]["M"] = 1.00;
convert["FT"]["FT"] = 1.00;
@@ -113,7 +134,7 @@ Element::Element(string nm)
Element::~Element(void)
{
- for (int i=0; i el) {
element_index = el;
@@ -170,7 +191,7 @@ Element* Element::GetNextElement(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string Element::GetDataLine(int i)
+string Element::GetDataLine(unsigned int i)
{
if (data_lines.size() > 0) return data_lines[i];
else return string("");
@@ -183,15 +204,16 @@ double Element::GetDataAsNumber(void)
if (data_lines.size() == 1) {
return atof(data_lines[0].c_str());
} else {
- return 99e99;
+ cerr << "Attempting to get single data value from multiple lines" << endl;
+ return 0;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-int Element::GetNumElements(string element_name)
+unsigned int Element::GetNumElements(string element_name)
{
- int number_of_elements=0;
+ unsigned int number_of_elements=0;
Element* el=FindElement(element_name);
while (el) {
number_of_elements++;
@@ -208,7 +230,7 @@ Element* Element::FindElement(string el)
element_index = 1;
return children[0];
}
- for (int i=0; iGetName()) {
element_index = i+1;
return children[i];
@@ -230,7 +252,7 @@ Element* Element::FindNextElement(string el)
return 0L;
}
}
- for (int i=element_index; iGetName()) {
element_index = i+1;
return children[i];
@@ -248,7 +270,8 @@ double Element::FindElementValueAsNumber(string el)
if (element) {
return element->GetDataAsNumber();
} else {
- return 99e99;
+ cerr << "Attempting to get single data value from multiple lines" << endl;
+ return 0;
}
}
@@ -291,7 +314,8 @@ double Element::FindElementValueAsNumberConvertTo(string el, string target_units
}
}
} else {
- return 99e99;
+ cerr << "Attempting to get get non-existent element " << el << endl;
+ return 0;
}
return value;
}
@@ -323,7 +347,8 @@ double Element::FindElementValueAsNumberConvertFromTo( string el,
}
}
} else {
- return 99e99;
+ cerr << "Attempting to get get non-existent element " << el << endl;
+ return 0;
}
return value;
}
@@ -375,9 +400,9 @@ FGColumnVector3 Element::FindElementTripletConvertTo( string target_units)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void Element::Print(int level)
+void Element::Print(unsigned int level)
{
- int i, spaces;
+ unsigned int i, spaces;
level+=2;
for (spaces=0; spaces<=level; spaces++) cout << " "; // format output
@@ -407,7 +432,7 @@ void Element::AddAttribute(string name, string value)
void Element::AddData(string d)
{
- int string_start = d.find_first_not_of(" \t");
+ unsigned int string_start = (unsigned int)d.find_first_not_of(" \t");
if (string_start > 0) {
d.erase(0,string_start);
}
diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.h b/src/FDM/JSBSim/input_output/FGXMLElement.h
index 8248fb8f5..ce3711aed 100755
--- a/src/FDM/JSBSim/input_output/FGXMLElement.h
+++ b/src/FDM/JSBSim/input_output/FGXMLElement.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -183,16 +183,16 @@ public:
@param i the index of the data line to return (0 by default).
@return a string representing the data line requested, or the empty string
if none exists.*/
- string GetDataLine(int i=0);
+ string GetDataLine(unsigned int i=0);
/// Returns the number of lines of data stored
- int GetNumDataLines(void) {return data_lines.size();}
+ unsigned int GetNumDataLines(void) {return (unsigned int)data_lines.size();}
/// Returns the number of child elements for this element.
- int GetNumElements(void) {return children.size();}
+ unsigned int GetNumElements(void) {return (unsigned int)children.size();}
/// Returns the number of named child elements for this element.
- int GetNumElements(string);
+ unsigned int GetNumElements(string);
/** Converts the element data to a number.
This function attempts to convert the first (and presumably only) line of
@@ -208,7 +208,7 @@ public:
GetNextElement() will return NULL.
@param el the index of the requested element (0 by default)
@return a pointer to the Element, or 0 if no valid element exists. */
- Element* GetElement(int el=0);
+ Element* GetElement(unsigned int el=0);
/** Returns a pointer to the next element in the list.
The function GetElement() must be called first to be sure that this
@@ -333,7 +333,7 @@ public:
/** Prints the element.
* Prints this element and calls the Print routine for child elements.
* @param d The tab level. A level corresponds to a single space. */
- void Print(int level=0);
+ void Print(unsigned int level=0);
private:
string name;
@@ -342,7 +342,7 @@ private:
vector children;
vector attribute_key;
Element *parent;
- int element_index;
+ unsigned int element_index;
typedef map > tMapConvert;
tMapConvert convert;
};
diff --git a/src/FDM/JSBSim/input_output/FGXMLParse.cpp b/src/FDM/JSBSim/input_output/FGXMLParse.cpp
index ec051f8d0..d00d074c7 100755
--- a/src/FDM/JSBSim/input_output/FGXMLParse.cpp
+++ b/src/FDM/JSBSim/input_output/FGXMLParse.cpp
@@ -1,11 +1,30 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- Header: FGXMLParse.h
+ Header: FGXMLParse.cpp
Author: Jon Berndt
Date started: 08/20/2004
Purpose: Config file read-in class and XML parser
Called by: Various
+ ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -36,7 +55,7 @@ FGXMLParse::FGXMLParse(void)
FGXMLParse::~FGXMLParse(void)
{
- if (document) delete document;
+ delete document;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -49,7 +68,7 @@ void FGXMLParse::startXML(void)
void FGXMLParse::reset(void)
{
- if (document) delete document;
+ delete document;
first_element_read = false;
current_element = document = 0L;
}
diff --git a/src/FDM/JSBSim/input_output/FGXMLParse.h b/src/FDM/JSBSim/input_output/FGXMLParse.h
index a86cd6e86..2d58acf44 100755
--- a/src/FDM/JSBSim/input_output/FGXMLParse.h
+++ b/src/FDM/JSBSim/input_output/FGXMLParse.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 2004 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/input_output/FGfdmSocket.cpp b/src/FDM/JSBSim/input_output/FGfdmSocket.cpp
index c9db20f94..37f29336e 100644
--- a/src/FDM/JSBSim/input_output/FGfdmSocket.cpp
+++ b/src/FDM/JSBSim/input_output/FGfdmSocket.cpp
@@ -9,20 +9,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
@@ -82,13 +82,13 @@ FGfdmSocket::FGfdmSocket(string address, int port)
memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
int len = sizeof(struct sockaddr_in);
if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
- cout << "Successfully connected to socket ..." << endl;
+ cout << "Successfully connected to socket for output ..." << endl;
connected = true;
} else { // unsuccessful
- cout << "Could not connect to socket ..." << endl;
+ cout << "Could not connect to socket for output ..." << endl;
}
} else { // unsuccessful
- cout << "Could not create socket for FDM, error = " << errno << endl;
+ cout << "Could not create socket for FDM output, error = " << errno << endl;
}
}
Debug(0);
@@ -116,10 +116,9 @@ FGfdmSocket::FGfdmSocket(int port)
memset(&scktName, 0, sizeof(struct sockaddr_in));
scktName.sin_family = AF_INET;
scktName.sin_port = htons(port);
-// memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
int len = sizeof(struct sockaddr_in);
if (bind(sckt, (struct sockaddr*)&scktName, len) == 0) { // successful
- cout << "Successfully bound to socket ..." << endl;
+ cout << "Successfully bound to socket for input on port " << port << endl;
if (listen(sckt, 5) >= 0) { // successful listen()
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
ioctlsocket(sckt, FIONBIO, &NoBlock);
@@ -133,10 +132,10 @@ FGfdmSocket::FGfdmSocket(int port)
}
connected = true;
} else { // unsuccessful
- cerr << "Could not bind to socket ..." << endl;
+ cerr << "Could not bind to socket for input ..." << endl;
}
} else { // unsuccessful
- cerr << "Could not create socket for FDM, error = " << errno << endl;
+ cerr << "Could not create socket for FDM input, error = " << errno << endl;
}
Debug(0);
diff --git a/src/FDM/JSBSim/input_output/FGfdmSocket.h b/src/FDM/JSBSim/input_output/FGfdmSocket.h
index 7eed2fe36..f1d41ef1b 100644
--- a/src/FDM/JSBSim/input_output/FGfdmSocket.h
+++ b/src/FDM/JSBSim/input_output/FGfdmSocket.h
@@ -7,20 +7,20 @@
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
@@ -75,6 +75,12 @@ INCLUDES
#include
#endif
+#ifdef _MSC_VER
+
+#pragma comment (lib,"WSock32.lib")
+
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -91,7 +97,9 @@ namespace JSBSim {
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/** Encapsulates a socket object.
+/** Encapsulates an object that enables JSBSim to communicate via socket (input
+ and/or output).
+
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/math/FGColumnVector3.cpp b/src/FDM/JSBSim/math/FGColumnVector3.cpp
index 0b0fa0351..dfbbca6e0 100644
--- a/src/FDM/JSBSim/math/FGColumnVector3.cpp
+++ b/src/FDM/JSBSim/math/FGColumnVector3.cpp
@@ -1,11 +1,30 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGColumnVector3.cpp
-Author: Originally by Tony Peden [formatted here (and broken??) by JSB]
+Author: Originally by Tony Peden [formatted here by JSB]
Date started: 1998
Purpose: FGColumnVector3 class
Called by: Various
+ ------------- Copyright (C) 1998 Tony Peden and Jon S. Berndt (jsb@hal-pc.org) -
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
diff --git a/src/FDM/JSBSim/math/FGColumnVector3.h b/src/FDM/JSBSim/math/FGColumnVector3.h
index e0d01bf7a..a17c53561 100644
--- a/src/FDM/JSBSim/math/FGColumnVector3.h
+++ b/src/FDM/JSBSim/math/FGColumnVector3.h
@@ -4,6 +4,25 @@ Header: FGColumnVector3.h
Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
Date started: Unknown
+ ------------- Copyright (C) 2001 by Tony Peden and Jon S. Berndt (jsb@hal-pc.org)
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
HISTORY
--------------------------------------------------------------------------------
??/??/???? ?? Initial version and more.
diff --git a/src/FDM/JSBSim/math/FGCondition.cpp b/src/FDM/JSBSim/math/FGCondition.cpp
new file mode 100644
index 000000000..e5cebbcb0
--- /dev/null
+++ b/src/FDM/JSBSim/math/FGCondition.cpp
@@ -0,0 +1,306 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGCondition.cpp
+ Author: Jon S. Berndt
+ Date started: 1/2/2003
+
+ -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.org) --------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGCondition.h"
+
+namespace JSBSim {
+
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_CONDITION;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+string FGCondition::indent = " ";
+
+// This constructor is called when tests are inside an element
+FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
+ PropertyManager(PropertyManager), isGroup(true)
+{
+ string property1, property2, logic;
+ Element* condition_element;
+
+ InitializeConditionals();
+
+ TestParam1 = TestParam2 = 0L;
+ TestValue = 0.0;
+ Comparison = ecUndef;
+ Logic = elUndef;
+ conditions.clear();
+
+ logic = element->GetAttributeValue("logic");
+ if (!logic.empty()) {
+ if (logic == "OR") Logic = eOR;
+ else if (logic == "AND") Logic = eAND;
+ else { // error
+ cerr << "Unrecognized LOGIC token " << logic << endl;
+ }
+ } else {
+ Logic = eAND; // default
+ }
+
+ condition_element = element->GetElement();
+ while (condition_element) {
+ conditions.push_back(FGCondition(condition_element, PropertyManager));
+ condition_element = element->GetNextElement();
+ }
+ for (unsigned int i=0; iGetNumDataLines(); i++) {
+ string data = element->GetDataLine(i);
+ conditions.push_back(FGCondition(data, PropertyManager));
+ }
+
+ Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//This constructor is called when there are no nested test groups inside the
+// condition
+
+FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) :
+ PropertyManager(PropertyManager), isGroup(false)
+{
+ string property1, property2, compare_string;
+
+ InitializeConditionals();
+
+ TestParam1 = TestParam2 = 0L;
+ TestValue = 0.0;
+ Comparison = ecUndef;
+ Logic = elUndef;
+ conditions.clear();
+
+ unsigned int start = 0, end = 0;
+ start = test.find_first_not_of(" ");
+ end = test.find_first_of(" ", start+1);
+ property1 = test.substr(start,end-start);
+ start = test.find_first_not_of(" ",end);
+ end = test.find_first_of(" ",start+1);
+ conditional = test.substr(start,end-start);
+ start = test.find_first_not_of(" ",end);
+ end = test.find_first_of(" ",start+1);
+ property2 = test.substr(start,end-start);
+
+ TestParam1 = PropertyManager->GetNode(property1, true);
+ Comparison = mComparison[conditional];
+ if (property2.find_first_not_of("-.0123456789eE") == string::npos) {
+ TestValue = atof(property2.c_str());
+ } else {
+ TestParam2 = PropertyManager->GetNode(property2, true);
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::InitializeConditionals(void)
+{
+ mComparison["EQ"] = eEQ;
+ mComparison["NE"] = eNE;
+ mComparison["GT"] = eGT;
+ mComparison["GE"] = eGE;
+ mComparison["LT"] = eLT;
+ mComparison["LE"] = eLE;
+ mComparison["eq"] = eEQ;
+ mComparison["ne"] = eNE;
+ mComparison["gt"] = eGT;
+ mComparison["ge"] = eGE;
+ mComparison["lt"] = eLT;
+ mComparison["le"] = eLE;
+ mComparison["=="] = eEQ;
+ mComparison["!="] = eNE;
+ mComparison[">"] = eGT;
+ mComparison[">="] = eGE;
+ mComparison["<"] = eLT;
+ mComparison["<="] = eLE;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGCondition::~FGCondition(void)
+{
+ Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGCondition::Evaluate(void )
+{
+ vector ::iterator iConditions;
+ bool pass = false;
+ double compareValue;
+
+ if (TestParam1 == 0L) {
+
+ if (Logic == eAND) {
+
+ iConditions = conditions.begin();
+ pass = true;
+ while (iConditions < conditions.end()) {
+ if (!iConditions->Evaluate()) pass = false;
+ *iConditions++;
+ }
+
+ } else { // Logic must be eOR
+
+ pass = false;
+ while (iConditions < conditions.end()) {
+ if (iConditions->Evaluate()) pass = true;
+ *iConditions++;
+ }
+
+ }
+
+ } else {
+
+ if (TestParam2 != 0L) compareValue = TestParam2->getDoubleValue();
+ else compareValue = TestValue;
+
+ switch (Comparison) {
+ case ecUndef:
+ cerr << "Undefined comparison operator." << endl;
+ break;
+ case eEQ:
+ pass = TestParam1->getDoubleValue() == compareValue;
+ break;
+ case eNE:
+ pass = TestParam1->getDoubleValue() != compareValue;
+ break;
+ case eGT:
+ pass = TestParam1->getDoubleValue() > compareValue;
+ break;
+ case eGE:
+ pass = TestParam1->getDoubleValue() >= compareValue;
+ break;
+ case eLT:
+ pass = TestParam1->getDoubleValue() < compareValue;
+ break;
+ case eLE:
+ pass = TestParam1->getDoubleValue() <= compareValue;
+ break;
+ default:
+ cerr << "Unknown comparison operator." << endl;
+ }
+ }
+
+ return pass;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::PrintCondition(void )
+{
+ vector ::iterator iConditions;
+ string scratch;
+
+ if (isGroup) {
+ switch(Logic) {
+ case (elUndef):
+ scratch = " UNSET";
+ cerr << "unset logic for test condition" << endl;
+ break;
+ case (eAND):
+ scratch = " if all of the following are true:";
+ break;
+ case (eOR):
+ scratch = " if any of the following are true:";
+ break;
+ default:
+ scratch = " UNKNOWN";
+ cerr << "Unknown logic for test condition" << endl;
+ }
+
+ iConditions = conditions.begin();
+ cout << scratch << endl;
+ while (iConditions < conditions.end()) {
+ iConditions->PrintCondition();
+ *iConditions++;
+ }
+ } else {
+ if (TestParam2 != 0L)
+ cout << " " << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
+ else
+ cout << " " << TestParam1->GetName() << " " << conditional << " " << TestValue;
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGCondition::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGCondition" << endl;
+ if (from == 1) cout << "Destroyed: FGCondition" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+
+} //namespace JSBSim
+
diff --git a/src/FDM/JSBSim/math/FGCondition.h b/src/FDM/JSBSim/math/FGCondition.h
new file mode 100644
index 000000000..c778e0f79
--- /dev/null
+++ b/src/FDM/JSBSim/math/FGCondition.h
@@ -0,0 +1,99 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGCondition.h
+ Author: Jon S. Berndt
+ Date started: 1/02/2003
+
+ ------------- Copyright (C) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGCONDITION_H
+#define FGCONDITION_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include