1
0
Fork 0

Sync. w. JSB CVS as of 15/01/2007

This commit is contained in:
ehofman 2007-01-15 12:48:54 +00:00
parent 4a79d82ba6
commit 3ec74d79c2
125 changed files with 2629 additions and 1403 deletions

View file

@ -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 <models/FGOutput.h>
#include <initialization/FGInitialCondition.h>
#include <input_output/FGPropertyManager.h>
#include <input_output/FGScript.h>
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; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
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; i<Outputs.size(); i++) {
if (Outputs[i]) delete Outputs[i];
}
for (unsigned i=0; i<Outputs.size(); i++) delete Outputs[i];
Outputs.clear();
delete IC;
@ -354,6 +354,7 @@ int FGFDMExec::Schedule(FGModel* model, int rate)
bool FGFDMExec::Run(void)
{
bool success;
FGModel* model_iterator;
model_iterator = FirstModel;
@ -366,6 +367,8 @@ bool FGFDMExec::Run(void)
// SlaveFDMList[i]->exec->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 <string> FGFDMExec::EnumerateFDMs(void)
{
vector <string> FDMList;
@ -415,6 +431,18 @@ vector <string> 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; i<PropertyCatalog.size(); i++) {
for (unsigned i=0; i<PropertyCatalog.size(); i++) {
if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
}
if (results.empty()) return "No matches found\n";
@ -554,6 +582,18 @@ string FGFDMExec::QueryPropertyCatalog(string in)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFDMExec::PrintPropertyCatalog(void)
{
cout << endl;
cout << " " << fgblue << highint << underon << "Property Catalog for "
<< modelName << reset << endl << endl;
for (unsigned i=0; i<PropertyCatalog.size(); i++) {
cout << " " << PropertyCatalog[i] << endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFDMExec::ReadFileHeader(Element* el)
{
bool result = true; // true for success
@ -649,7 +689,7 @@ bool FGFDMExec::ReadSlave(Element* el)
SlaveFDMList.push_back(new slaveData);
SlaveFDMList.back()->exec = 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; i<Outputs.size(); i++) {
for (unsigned i=0; i<Outputs.size(); i++) {
Outputs[i]->Disable();
}
}
@ -713,13 +753,33 @@ void FGFDMExec::DisableOutput(void)
void FGFDMExec::EnableOutput(void)
{
for (int i=0; i<Outputs.size(); i++) {
for (unsigned i=0; i<Outputs.size(); i++) {
Outputs[i]->Enable();
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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";

View file

@ -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 <string> 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 &lt;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 &lt;output> &lt;/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 <string> 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 <FGOutput*> 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 <string> PropertyCatalog;
vector <FGOutput*> Outputs;
vector <slaveData*> SlaveFDMList;
bool ReadFileHeader(Element*);
bool ReadSlave(Element*);
bool ReadPrologue(Element*);
bool Allocate(void);
bool DeAllocate(void);
void Debug(int from);
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -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::Message*> FGJSBBase::Messages;
FGJSBBase::Message FGJSBBase::localMsg;

View file

@ -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. */

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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 *startup_trim;
SGPropertyNode *trimmed;
SGPropertyNode *pitch_trim;
SGPropertyNode *throttle_trim;
SGPropertyNode *aileron_trim;
SGPropertyNode *rudder_trim;
SGPropertyNode *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 *elevator_pos_deg;
SGPropertyNode *left_aileron_pos_deg;
SGPropertyNode *right_aileron_pos_deg;
SGPropertyNode *rudder_pos_deg;
SGPropertyNode *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 *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_ptr gear_pos_pct;
SGPropertyNode *gear_pos_pct;
SGPropertyNode_ptr temperature;
SGPropertyNode_ptr pressure;
SGPropertyNode_ptr density;
SGPropertyNode_ptr turbulence_gain;
SGPropertyNode_ptr turbulence_rate;
SGPropertyNode *temperature;
SGPropertyNode *pressure;
SGPropertyNode *density;
SGPropertyNode *turbulence_gain;
SGPropertyNode *turbulence_rate;
SGPropertyNode_ptr wind_from_north;
SGPropertyNode_ptr wind_from_east;
SGPropertyNode_ptr wind_from_down;
SGPropertyNode *wind_from_north;
SGPropertyNode *wind_from_east;
SGPropertyNode *wind_from_down;
SGPropertyNode *slaved;
void init_gear(void);
void update_gear(void);

View file

@ -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")) {

View file

@ -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.

View file

@ -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.

View file

@ -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$"
*/

View file

@ -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:

View file

@ -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; }

View file

@ -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

View file

@ -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

View file

@ -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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -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

View file

@ -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 <input_output/FGXMLParse.h>
#include <initialization/FGTrim.h>
namespace JSBSim {
@ -84,6 +84,14 @@ FGScript::FGScript(FGFDMExec* fgex) : FDMExec(fgex)
FGScript::~FGScript()
{
int i;
for (i=0; i<local_properties.size(); i++)
PropertyManager->Untie(local_properties[i]->title);
for (i=0; i<local_properties.size(); i++)
delete local_properties[i];
local_properties.clear();
Debug(1);
}
@ -92,12 +100,16 @@ FGScript::~FGScript()
bool FGScript::LoadScript( string script )
{
string aircraft="", initialize="", comparison = "", prop_name="";
Element *document=0, *element=0, *run_element=0, *when_element=0;
Element *parameter_element=0, *set_element=0;
string notifyPropertyName="";
Element *document=0, *element=0, *run_element=0, *event_element=0;
Element *condition_element=0, *set_element=0, *delay_element=0;
Element *notify_element = 0L, *notify_property_element = 0L;
Element *property_element = 0L;
bool result = false;
double dt = 0.0, value = 0.0;
FGXMLParse script_file_parser;
struct condition *newCondition;
struct event *newEvent;
FGCondition *newCondition;
ifstream script_file(script.c_str());
if ( !script_file ) return false;
@ -110,26 +122,9 @@ bool FGScript::LoadScript( string script )
return false;
}
// read aircraft and initialization files
ScriptName = document->GetAttributeValue("name");
element = document->FindElement("use");
if (element) {
aircraft = element->GetAttributeValue("aircraft");
if (!aircraft.empty()) {
result = FDMExec->LoadModel(aircraft);
if (!result) return false;
} else {
cerr << "Aircraft must be specified first in script file." << endl;
return false;
}
element = document->FindNextElement("use");
initialize = element->GetAttributeValue("initialize");
} else {
cerr << "No \"use\" directives in the script file." << endl;
return false;
}
// First, find "run" element and set delta T
run_element = document->FindElement("run");
@ -146,61 +141,117 @@ bool FGScript::LoadScript( string script )
dt = run_element->GetAttributeValueAsNumber("dt");
State->Setdt(dt);
// read "when" tests from script
// read aircraft and initialization files
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");
element = document->FindElement("use");
if (element) {
aircraft = element->GetAttributeValue("aircraft");
if (!aircraft.empty()) {
result = FDMExec->LoadModel(aircraft);
if (!result) return false;
} else {
cerr << "Aircraft must be specified in use element." << endl;
return false;
}
// read set definitions
set_element = when_element->FindElement("set");
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;
}
// 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");
}
// Read "events" from script
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");
// 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;
}
// 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 <struct condition>::iterator iC = Conditions.begin();
bool truth = false;
bool WholeTruth = false;
unsigned i;
vector <struct event>::iterator iEvent = Events.begin();
unsigned i, j;
unsigned event_ctr = 0;
double currentTime = State->Getsim_time();
double newSetValue = 0;
if (currentTime > EndTime) return false;
if (currentTime > EndTime) return false; //Script done!
while (iC < Conditions.end()) {
// determine whether the set of conditional tests for this condition equate
// to true
for (i=0; i<iC->TestValue.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;
// 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 (i == 0) WholeTruth = truth;
else WholeTruth = WholeTruth && truth;
if (!truth && iC->Persistent[i] && iC->Triggered[i]) iC->Triggered[i] = false;
}
// if the conditions are true, do the setting of the desired parameters
if (WholeTruth) {
for (i=0; i<iC->SetValue.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; i<iEvent->SetValue.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];
if ((currentTime >= iEvent->StartTime) && iEvent->Triggered) {
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 (iEvent->Notify && iEvent->PrevTriggered != iEvent->Triggered) {
cout << endl << " Event " << event_ctr << " (" << iEvent->Name << ")"
<< " executed at time: " << currentTime << endl;
for (j=0; j<iEvent->NotifyProperties.size();j++) {
cout << " " << iEvent->NotifyProperties[j]->GetName()
<< " = " << iEvent->NotifyProperties[j]->getDoubleValue() << endl;
}
cout << endl;
}
for (i=0; i<iEvent->SetValue.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 <struct condition>::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; i<Events.size(); i++) {
cout << "Event " << i;
if (!Events[i].Name.empty()) cout << " (" << Events[i].Name << ")";
cout << ":" << endl;
while (iterConditions < Conditions.end()) {
cout << " Condition: " << count++ << endl;
cout << " if (";
if (Events[i].Persistent)
cout << " " << "Always executes";
else
cout << " " << "Executes once";
for (i=0; i<iterConditions->TestValue.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; i<iterConditions->SetValue.size(); i++) {
cout << endl << " set " << iterConditions->SetParam[i]->GetName()
<< " to " << iterConditions->SetValue[i];
cout << endl << " Actions taken:" << endl << " {";
for (unsigned j=0; j<Events[i].SetValue.size(); j++) {
cout << endl << " set " << Events[i].SetParam[j]->GetName()
<< " 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

View file

@ -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 <math/FGCondition.h>
#include <vector>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -61,65 +62,100 @@ CLASS DOCUMENTATION
/** Encapsulates the JSBSim scripting capability.
<h4>Scripting support provided via FGScript.</h4>
<p>There is simple scripting support provided in the FGScript
class. Commands are specified using the <em>Simple Scripting
Directives for JSBSim</em> (SSDJ). The script file is in XML
format. A test condition (or conditions) can be set up in the
<p>There is support for scripting provided in the FGScript
class. Commands are specified using the <em>Scripting
Directives for JSBSim</em>. The script file is in XML
format. A test condition (or conditions) can be set up in an event in a
script and when the condition evaluates to true, the specified
action[s] is/are taken. A test condition can be <em>persistent</em>,
meaning that if a test condition evaluates to true, then passes
and evaluates to false, the condition is reset and may again be
triggered. When the set of tests evaluates to true for a given
condition, an item may be set to another value. This value might
be a boolean, a value, or a delta value, and the change from the
action[s] is/are taken. An event can be <em>persistent</em>,
meaning that at all times when the test condition evaluates to true
the specified <em>set</em> actions take place. When the set of
tests evaluates to true for a given
condition, an item may be set to another value. This value may
be a value, or a delta value, and the change from the
current value to the new value can be either via a step function,
a ramp, or an exponential approach. The speed of a ramp or
approach is specified via the time constant. Here is the format
of the script file:</p>
approach is specified via the time constant. Here is an example
illustrating the format of the script file:
<pre><strong>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;runscript name=&quot;C172-01A&quot;&gt;
@code
<?xml version="1.0"?>
<runscript name="C172-01A takeoff run">
<!--
This run is for testing the C172 altitude hold autopilot
-->
&lt;!--
This run is for testing C172 runs
--&gt;
<use aircraft="c172x"/>
<use initialize="reset00"/>
<run start="0.0" end="3000" dt="0.0083333">
&lt;use aircraft=&quot;c172&quot;&gt;
&lt;use initialize=&quot;reset00&quot;&gt;
<event name="engine start">
<notify/>
<condition>
sim-time-sec >= 0.25
</condition>
<set name="fcs/throttle-cmd-norm" value="1.0" action="FG_RAMP" tc ="0.5"/>
<set name="fcs/mixture-cmd-norm" value="0.87" action="FG_RAMP" tc ="0.5"/>
<set name="propulsion/magneto_cmd" value="3"/>
<set name="propulsion/starter_cmd" value="1"/>
</event>
&lt;run start=&quot;0.0&quot; end=&quot;4.5&quot; dt=&quot;0.05&quot;&gt;
&lt;when&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.25&quot;&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;0.50&quot;&gt;
&lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_VALUE&quot; value=&quot;0.25&quot;
action=&quot;FG_STEP&quot; persistent=&quot;false&quot; tc =&quot;0.25&quot;&gt;
&lt;/when&gt;
&lt;when&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.5&quot;&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;1.5&quot;&gt;
&lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
action=&quot;FG_EXP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
&lt;/when&gt;
&lt;when&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;1.5&quot;&gt;
&lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;2.5&quot;&gt;
&lt;set name=&quot;FG_RUDDER_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
action=&quot;FG_RAMP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
&lt;/when&gt;
&lt;/run&gt;
<event name="set heading hold">
<!-- Set Heading when reach 5 ft -->
<notify/>
<condition>
position/h-agl-ft >= 5
</condition>
<set name="ap/heading_setpoint" value="200"/>
<set name="ap/attitude_hold" value="0"/>
<set name="ap/heading_hold" value="1"/>
</event>
&lt;/runscript&gt;</strong></pre>
<event name="set autopilot">
<!-- Set Autopilot for 20 ft -->
<notify/>
<condition>
aero/qbar-psf >= 4
</condition>
<set name="ap/altitude_setpoint" value="100.0" action="FG_EXP" tc ="2.0"/>
<set name="ap/altitude_hold" value="1"/>
<set name="fcs/flap-cmd-norm" value=".33"/>
</event>
<p>The first line must always be present. The second line
<event name="set autopilot 2" persistent="true">
<!-- Set Autopilot for 6000 ft -->
<notify/>
<condition>
aero/qbar-psf > 5
</condition>
<set name="ap/altitude_setpoint" value="6000.0"/>
</event>
<event name="Time Notify">
<notify/>
<condition> sim-time-sec >= 500 </condition>
</event>
<event name="Time Notify">
<notify/>
<condition> sim-time-sec >= 1000 </condition>
</event>
</run>
</runscript>
@endcode
The first line must always be present - it identifies the file
as an XML format file. The second line
identifies this file as a script file, and gives a descriptive
name to the script file. Comments are next, delineated by the
&lt;!-- and --&gt; symbols. The aircraft and initialization files
to be used are specified in the &quot;use&quot; lines. Next,
comes the &quot;run&quot; section, where the conditions are
described in &quot;when&quot; clauses.</p>
described in &quot;event&quot; clauses.</p>
@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 <FGPropertyManager*> TestParam;
struct event {
FGCondition *Condition;
bool Persistent;
bool Triggered;
bool PrevTriggered;
bool Notify;
double Delay;
double StartTime;
double TimeSpan;
string Name;
vector <FGPropertyManager*> SetParam;
vector <double> TestValue;
vector <double> SetValue;
vector <string> Comparison;
vector <double> TC;
vector <bool> Persistent;
vector <FGPropertyManager*> NotifyProperties;
vector <eAction> Action;
vector <eType> Type;
vector <bool> Triggered;
vector <double> SetValue;
vector <double> TC;
vector <double> newValue;
vector <double> OriginalValue;
vector <double> StartTime;
vector <double> EndTime;
vector <double> ValueSpan;
vector <bool> Transiting;
condition() {
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 <struct condition> Conditions;
vector <struct event> Events;
vector <LocalProps*> local_properties;
FGFDMExec* FDMExec;
FGState* State;

View file

@ -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<children.size(); i++) delete children[i];
for (unsigned int i=0; i<children.size(); i++) delete children[i];
data_lines.clear();
attributes.clear();
attribute_key.clear();
@ -124,7 +145,7 @@ Element::~Element(void)
string Element::GetAttributeValue(string attr)
{
int select=-1;
for (int i=0; i<attribute_key.size(); i++) {
for (unsigned int i=0; i<attribute_key.size(); i++) {
if (attribute_key[i] == attr) select = i;
}
if (select < 0) return string("");
@ -143,7 +164,7 @@ double Element::GetAttributeValueAsNumber(string attr)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Element* Element::GetElement(int el)
Element* Element::GetElement(unsigned int el)
{
if (children.size() > 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; i<children.size(); i++) {
for (unsigned int i=0; i<children.size(); i++) {
if (el == children[i]->GetName()) {
element_index = i+1;
return children[i];
@ -230,7 +252,7 @@ Element* Element::FindNextElement(string el)
return 0L;
}
}
for (int i=element_index; i<children.size(); i++) {
for (unsigned int i=element_index; i<children.size(); i++) {
if (el == children[i]->GetName()) {
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);
}

View file

@ -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 <Element*> children;
vector <string> attribute_key;
Element *parent;
int element_index;
unsigned int element_index;
typedef map <string, map <string, double> > tMapConvert;
tMapConvert convert;
};

View file

@ -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;
}

View file

@ -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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -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);

View file

@ -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 <sys/ioctl.h>
#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).
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -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
--------------------------------------------------------------------------------

View file

@ -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.

View file

@ -7,20 +7,20 @@
-------------- 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 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
@ -47,7 +47,7 @@ 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)
{
@ -63,30 +63,37 @@ FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
conditions.clear();
logic = element->GetAttributeValue("logic");
if (logic == "OR") Logic = eOR;
else if (logic == "AND") Logic = eAND;
else { // error
cerr << "Unrecognized LOGIC token " << logic << " in switch component: " << logic << endl;
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 (int i=0; i<element->GetNumDataLines(); i++) {
conditions.push_back(FGCondition(element->GetDataLine(i), PropertyManager));
for (unsigned int i=0; i<element->GetNumDataLines(); 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;
Element* condition_element;
InitializeConditionals();
@ -96,7 +103,7 @@ FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) :
Logic = elUndef;
conditions.clear();
int start = 0, end = 0;
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);
@ -155,21 +162,25 @@ bool FGCondition::Evaluate(void )
bool pass = false;
double compareValue;
if (Logic == eAND) {
if (TestParam1 == 0L) {
iConditions = conditions.begin();
pass = true;
while (iConditions < conditions.end()) {
if (!iConditions->Evaluate()) pass = false;
*iConditions++;
}
if (Logic == eAND) {
} else if (Logic == eOR) {
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++;
}
pass = false;
while (iConditions < conditions.end()) {
if (iConditions->Evaluate()) pass = true;
*iConditions++;
}
} else {
@ -221,7 +232,7 @@ void FGCondition::PrintCondition(void )
cerr << "unset logic for test condition" << endl;
break;
case (eAND):
scratch = " if all of the following are true";
scratch = " if all of the following are true:";
break;
case (eOR):
scratch = " if any of the following are true:";
@ -239,9 +250,9 @@ void FGCondition::PrintCondition(void )
}
} else {
if (TestParam2 != 0L)
cout << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
cout << " " << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
else
cout << TestParam1->GetName() << " " << conditional << " " << TestValue;
cout << " " << TestParam1->GetName() << " " << conditional << " " << TestValue;
}
}

View file

@ -7,20 +7,20 @@
------------- Copyright (C) -------------
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

View file

@ -5,6 +5,25 @@ Author: Jon Berndt
Date started: 8/25/2004
Purpose: Stores various parameter types for functions
------------- 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 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -37,9 +56,9 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
Name = el->GetAttributeValue("name");
operation = el->GetName();
if (operation == string("function")) {
Type = eTopLevel;
bind();
} else if (operation == string("product")) {
Type = eProduct;
} else if (operation == string("difference")) {
@ -54,6 +73,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
Type = eAbs;
} else if (operation == string("sin")) {
Type = eSin;
} else if (operation == string("exp")) {
Type = eExp;
} else if (operation == string("cos")) {
Type = eCos;
} else if (operation == string("tan")) {
@ -94,6 +115,7 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
operation == string("sum") ||
operation == string("quotient") ||
operation == string("pow") ||
operation == string("exp") ||
operation == string("abs") ||
operation == string("sin") ||
operation == string("cos") ||
@ -110,6 +132,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
element = el->GetNextElement();
}
bind(); // Allow any function to save its value
Debug(0);
}
@ -117,8 +141,14 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
FGFunction::~FGFunction(void)
{
string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case
PropertyManager->Untie(tmp);
if (!Name.empty()) {
string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case
PropertyManager->Untie(tmp);
}
for (int i=0; i<Parameters.size(); i++) {
delete Parameters[i];
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -161,6 +191,9 @@ double FGFunction::GetValue(void) const
case ePow:
temp = pow(temp,Parameters[1]->GetValue());
break;
case eExp:
temp = exp(temp);
break;
case eAbs:
temp = fabs(temp);
break;
@ -245,8 +278,8 @@ void FGFunction::Debug(int from)
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGGroundReactions" << endl;
if (from == 1) cout << "Destroyed: FGGroundReactions" << endl;
if (from == 0) cout << "Instantiated: FGFunction" << endl;
if (from == 1) cout << "Destroyed: FGFunction" << endl;
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}

View file

@ -4,6 +4,25 @@ Header: FGFunction.h
Author: Jon Berndt
Date started: August 25 2004
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -37,9 +56,82 @@ namespace JSBSim {
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Represents various types of parameters.
@author Jon Berndt
*/
/** Represents a mathematical function.
The FGFunction class is a powerful and versatile resource that allows
algebraic functions to be defined in a JSBSim configuration file. It is
similar in concept to MathML (Mathematical Markup Language, www.w3.org/Math/),
but simpler and more terse.
A function definition consists of an operation, a value, a table, or a property
(which evaluates to a value). The currently supported operations are:
- sum (takes n args)
- difference (takes n args)
- product (takes n args)
- quotient (takes 2 args)
- pow (takes 2 args)
- exp (takes 2 args)
- abs (takes n args)
- sin (takes 1 arg)
- cos (takes 1 arg)
- tan (takes 1 arg)
- asin (takes 1 arg)
- acos (takes 1 arg)
- atan (takes 1 arg)
- atan2 (takes 2 args)
An operation is defined in the configuration file as in the following example:
@code
<sum>
<value> 3.14159 </value>
<property> velocities/qbar </property>
<product>
<value> 0.125 </value>
<property> metrics/wingarea </property>
</product>
</sum>
@endcode
A full function definition, such as is used in the aerodynamics section of a
configuration file includes the function element, and other elements. It should
be noted that there can be only one non-optional (non-documentation) element -
that is, one operation element - in the top-level function definition.
Multiple value and/or property elements cannot be immediate child
members of the function element. Almost always, the first operation within the
function element will be a product or sum. For example:
@code
<function name="aero/coefficient/Clr">
<description>Roll moment due to yaw rate</description>
<product>
<property>aero/qbar-area</property>
<property>metrics/bw-ft</property>
<property>aero/bi2vel</property>
<property>velocities/r-aero-rad_sec</property>
<table>
<independentVar>aero/alpha-rad</independentVar>
<tableData>
0.000 0.08
0.094 0.19
</tableData>
</table>
</product>
</function>
@endcode
The "lowest level" in a function is always a value or a property, which cannot
itself contain another element. As shown, operations can contain values,
properties, tables, or other operations. In the first above example, the sum
element contains all three. What is evaluated is written algebraically as:
@code 3.14159 + qbar + (0.125 * wingarea) @endcode
Some operations can take only a single argument. That argument, however, can be
an operation (such as sum) which can contain other items. The point to keep in
mind is that it evaluates to a single value - which is just what the trigonometric
functions require (except atan2, which takes two arguments).
@author Jon Berndt
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DECLARATION: FGFunction
@ -49,13 +141,43 @@ class FGFunction : public FGParameter
{
public:
FGFunction(FGPropertyManager* propMan, Element* el, string prefix="");
~FGFunction();
/** Constructor.
When this constructor is called, the XML element pointed to in memory by the
element argument is traversed. If other FGParameter-derived objects (values,
functions, properties, or tables) are encountered, this instance of the
FGFunction object will store a pointer to the found object and pass the relevant
Element pointer to the constructor for the new object. In other words, each
FGFunction object maintains a list of "child" FGParameter-derived objects which
in turn may each contain its own list, and so on. At runtime, each object
evaluates its child parameters, which each may have its own child parameters to
evaluate.
@param PropertyManager a pointer to the property manager instance.
@param element a pointer to the Element object containing the function definition.
@param prefix an optional prefix to prepend to the name given to the property
that represents this function (if given).
*/
FGFunction(FGPropertyManager* PropertyManager, Element* element, string prefix="");
/// Destructor.
virtual ~FGFunction();
/** Retrieves the value of the function object.
@return the total value of the function. */
double GetValue(void) const;
/** The value that the function evaluates to, as a string.
@return the value of the function as a string. */
string GetValueAsString(void) const;
/// Retrieves the name of the function.
string GetName(void) const {return Name;}
void cacheValue(bool);
/** Specifies whether to cache the value of the function, so it is calculated only
once per frame.
If shouldCache is true, then the value of the function is calculated, and
a flag is set so further calculations done this frame will use the cached value.
In order to turn off caching, cacheValue must be called with a false argument.
@param shouldCache specifies whether the function should cache the computed value. */
void cacheValue(bool shouldCache);
private:
vector <FGParameter*> Parameters;
@ -64,7 +186,7 @@ private:
string Prefix;
double cachedValue;
enum functionType {eTopLevel=0, eProduct, eDifference, eSum, eQuotient, ePow,
eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type;
eExp, eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type;
string Name;
void bind(void);
void Debug(int from);

View file

@ -9,20 +9,20 @@
------- (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.
FUNCTIONAL DESCRIPTION

View file

@ -8,20 +8,20 @@
------- (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

View file

@ -6,6 +6,25 @@ Date started: 1998
Purpose: FGMatrix33 class
Called by: Various
------------- Copyright (C) 1998 by the authors above -------------
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
--------------------------------------------------------------------------------

View file

@ -4,6 +4,25 @@ Header: FGMatrix33.h
Author: Tony Peden, Jon Berndt, Mathias Frolich
Date started: Unknown
------------- 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.
HISTORY
--------------------------------------------------------------------------------
??/??/?? TP Created

View file

@ -4,6 +4,25 @@ Header: FGParameter.h
Author: Jon Berndt
Date started: August 25 2004
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -44,7 +63,7 @@ DECLARATION: FGParameter
class FGParameter : public FGJSBBase
{
public:
virtual ~FGParameter(void) {};
virtual double GetValue(void) const = 0;
protected:

View file

@ -5,6 +5,25 @@ Author: Jon Berndt
Date started: 12/10/2004
Purpose: Stores property values
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

View file

@ -4,6 +4,25 @@ Header: FGPropertyValue.h
Author: Jon Berndt
Date started: December 10 2004
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

View file

@ -8,20 +8,20 @@
------- (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

View file

@ -8,20 +8,20 @@
------- (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

View file

@ -5,6 +5,25 @@ Author: Jon Berndt
Date started: 12/10/2004
Purpose: Stores real values
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

View file

@ -4,6 +4,25 @@ Header: FGRealValue.h
Author: Jon Berndt
Date started: December 10 2004
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

View file

@ -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
@ -80,6 +80,10 @@ FGTable::FGTable(const FGTable& t) : PropertyManager(t.PropertyManager)
nTables = t.nTables;
dimension = t.dimension;
internal = t.internal;
Name = t.Name;
lookupProperty[0] = t.lookupProperty[0];
lookupProperty[1] = t.lookupProperty[1];
lookupProperty[2] = t.lookupProperty[2];
Tables = t.Tables;
Data = Allocate();
@ -117,6 +121,7 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
// Is this an internal lookup table?
internal = false;
Name = el->GetAttributeValue("name"); // Allow this table to be named with a property
call_type = el->GetAttributeValue("type");
if (call_type == string("internal")) {
parent_element = el->GetParent();
@ -271,6 +276,9 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
cout << "No dimension given" << endl;
break;
}
bind();
if (debug_lvl & 1) Print();
}
@ -292,13 +300,18 @@ double** FGTable::Allocate(void)
FGTable::~FGTable()
{
if (!Name.empty() && !internal) {
string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper case
PropertyManager->Untie(tmp);
}
if (nTables > 0) {
cout << "nTables = " << nTables << endl;
for (int i=0; i<nTables; i++) delete Tables[i];
Tables.clear();
}
for (int r=0; r<=nRows; r++) if (Data[r]) delete[] Data[r];
if (Data) delete[] Data;
for (int r=0; r<=nRows; r++) delete[] Data[r];
delete[] Data;
Debug(1);
}
@ -562,6 +575,16 @@ void FGTable::Print(void)
cout.setf(flags); // reset
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTable::bind(void)
{
typedef double (FGTable::*PMF)(void) const;
if ( !Name.empty() && !internal) {
string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper
PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue);
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print

View file

@ -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
@ -64,138 +64,177 @@ CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Lookup table class.
Models a one, two, or three dimensional lookup table for use in FGCoefficient,
FGPropeller, etc. A one-dimensional table is called a "VECTOR" in a coefficient
definition. For example:
<pre>
\<COEFFICIENT NAME="{short name}" TYPE="VECTOR">
{name}
{number of rows}
{row lookup property}
{non-dimensionalizing properties}
{row_1_key} {col_1_data}
{row_2_key} {... }
{ ... } {... }
{row_n_key} {... }
\</COEFFICIENT>
</pre>
A "real life" example is as shown here:
<pre>
\<COEFFICIENT NAME="CLDf" TYPE="VECTOR">
Delta_lift_due_to_flap_deflection
4
fcs/flap-pos-deg
aero/qbar-psf | metrics/Sw-sqft
0 0
10 0.20
20 0.30
30 0.35
\</COEFFICIENT>
</pre>
The first column in the data table represents the lookup index (or "key"). In
this case, the lookup index is fcs/flap-pos-deg (flap extension in degrees).
If the flap position is 10 degrees, the value returned from the lookup table
would be 0.20. This value would be multiplied by qbar (aero/qbar-psf) and wing
area (metrics/Sw-sqft) to get the total lift force that is a result of flap
deflection (measured in pounds force). If the value of the flap-pos-deg property
was 15 (degrees), the value output by the table routine would be 0.25 - an
interpolation. If the flap position in degrees ever went below 0.0, or above
30 (degrees), the output from the table routine would be 0 and 0.35, respectively.
That is, there is no _extrapolation_ to values outside the range of the lookup
index. This is why it is important to chose the data for the table wisely.
Models a one, two, or three dimensional lookup table for use in aerodynamics
and function definitions.
The definition for a 2D table - referred to simply as a TABLE, is as follows:
<pre>
\<COEFFICIENT NAME="{short name}" TYPE="TABLE">
{name}
{number of rows}
{number of columns}
{row lookup property}
{column lookup property}
{non-dimensionalizing}
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
\</COEFFICIENT>
</pre>
A "real life" example is as shown here:
<pre>
\<COEFFICIENT NAME="CYb" TYPE="TABLE">
Side_force_due_to_beta
3
2
aero/beta-rad
fcs/flap-pos-deg
aero/qbar-psf | metrics/Sw-sqft
0 30
-0.349 0.137 0.106
0 0 0
0.349 -0.137 -0.106
\</COEFFICIENT>
</pre>
The definition for a 3D table in a coefficient would be (for example):
<pre>
\<COEFFICIENT NAME="{short name}" TYPE="TABLE3D">
{name}
{number of rows}
{number of columns}
{number of tables}
{row lookup property}
{column lookup property}
{table lookup property}
{non-dimensionalizing}
{first table key}
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
For a single "vector" lookup table, the format is as follows:
{second table key}
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
@code
<table name="property_name">
<independentVar lookup="row"> property_name </independentVar>
<tableData>
key_1 value_1
key_2 value_2
... ...
key_n value_n
</tableData>
</table>
@endcode
...
The lookup="row" attribute in the independentVar element is option in this case;
it is assumed that the independentVar is a row variable.
\</COEFFICIENT>
</pre>
[At the present time, all rows and columns for each table must have the
same dimension.]
A "real life" example is as shown here:
In addition to using a Table for something like a coefficient, where all the
row and column elements are read in from a file, a Table could be created
and populated completely within program code:
<pre>
// First column is thi, second is neta (combustion efficiency)
Lookup_Combustion_Efficiency = new FGTable(12);
*Lookup_Combustion_Efficiency << 0.00 << 0.980;
*Lookup_Combustion_Efficiency << 0.90 << 0.980;
*Lookup_Combustion_Efficiency << 1.00 << 0.970;
*Lookup_Combustion_Efficiency << 1.05 << 0.950;
*Lookup_Combustion_Efficiency << 1.10 << 0.900;
*Lookup_Combustion_Efficiency << 1.15 << 0.850;
*Lookup_Combustion_Efficiency << 1.20 << 0.790;
*Lookup_Combustion_Efficiency << 1.30 << 0.700;
*Lookup_Combustion_Efficiency << 1.40 << 0.630;
*Lookup_Combustion_Efficiency << 1.50 << 0.570;
*Lookup_Combustion_Efficiency << 1.60 << 0.525;
*Lookup_Combustion_Efficiency << 2.00 << 0.345;
</pre>
The first column in the table, above, is thi (the lookup index, or key). The
second column is the output data - in this case, "neta" (the Greek letter
referring to combustion efficiency). Later on, the table is used like this:
@code
<table>
<independentVar lookup="row"> aero/alpha-rad </independentVar>
<tableData>
-1.57 1.500
-0.26 0.033
0.00 0.025
0.26 0.033
1.57 1.500
</tableData>
</table>
@endcode
combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
The first column in the data table represents the lookup index (or "key"). In
this case, the lookup index is aero/alpha-rad (angle of attack in radians).
If alpha is 0.26 radians, the value returned from the lookup table
would be 0.033.
@author Jon S. Berndt
@version $Id$
@see FGCoefficient
@see FGPropeller
The definition for a 2D table, is as follows:
@code
<table name="property_name">
<independentVar lookup="row"> property_name </independentVar>
<independentVar lookup="column"> property_name </independentVar>
<tableData>
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
</tableData>
</table>
@endcode
The data is in a gridded format.
A "real life" example is as shown below. Alpha in radians is the row lookup (alpha
breakpoints are arranged in the first column) and flap position in degrees is
@code
<table>
<independentVar lookup="row">aero/alpha-rad</independentVar>
<independentVar lookup="column">fcs/flap-pos-deg</independentVar>
<tableData>
0.0 10.0 20.0 30.0
-0.0523599 8.96747e-05 0.00231942 0.0059252 0.00835082
-0.0349066 0.000313268 0.00567451 0.0108461 0.0140545
-0.0174533 0.00201318 0.0105059 0.0172432 0.0212346
0.0 0.0051894 0.0168137 0.0251167 0.0298909
0.0174533 0.00993967 0.0247521 0.0346492 0.0402205
0.0349066 0.0162201 0.0342207 0.0457119 0.0520802
0.0523599 0.0240308 0.0452195 0.0583047 0.0654701
0.0698132 0.0333717 0.0577485 0.0724278 0.0803902
0.0872664 0.0442427 0.0718077 0.088081 0.0968405
</tableData>
</table>
@endcode
The definition for a 3D table in a coefficient would be (for example):
@code
<table name="property_name">
<independentVar lookup="row"> property_name </independentVar>
<independentVar lookup="column"> property_name </independentVar>
<tableData breakpoint="table_1_key">
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
</tableData>
<tableData breakpoint="table_2_key">
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
</tableData>
...
<tableData breakpoint="table_n_key">
{col_1_key col_2_key ... col_n_key }
{row_1_key} {col_1_data col_2_data ... col_n_data}
{row_2_key} {... ... ... ... }
{ ... } {... ... ... ... }
{row_n_key} {... ... ... ... }
</tableData>
</table>
@endcode
[Note the "breakpoint" attribute in the tableData element, above.]
Here's an example:
@code
<table>
<independentVar lookup="row">fcs/row-value</independentVar>
<independentVar lookup="column">fcs/column-value</independentVar>
<independentVar lookup="table">fcs/table-value</independentVar>
<tableData breakPoint="-1.0">
-1.0 1.0
0.0 1.0000 2.0000
1.0 3.0000 4.0000
</tableData>
<tableData breakPoint="0.0000">
0.0 10.0
2.0 1.0000 2.0000
3.0 3.0000 4.0000
</tableData>
<tableData breakPoint="1.0">
0.0 10.0 20.0
2.0 1.0000 2.0000 3.0000
3.0 4.0000 5.0000 6.0000
10.0 7.0000 8.0000 9.0000
</tableData>
</table>
@endcode
In addition to using a Table for something like a coefficient, where all the
row and column elements are read in from a file, a Table could be created
and populated completely within program code:
@code
// First column is thi, second is neta (combustion efficiency)
Lookup_Combustion_Efficiency = new FGTable(12);
*Lookup_Combustion_Efficiency << 0.00 << 0.980;
*Lookup_Combustion_Efficiency << 0.90 << 0.980;
*Lookup_Combustion_Efficiency << 1.00 << 0.970;
*Lookup_Combustion_Efficiency << 1.05 << 0.950;
*Lookup_Combustion_Efficiency << 1.10 << 0.900;
*Lookup_Combustion_Efficiency << 1.15 << 0.850;
*Lookup_Combustion_Efficiency << 1.20 << 0.790;
*Lookup_Combustion_Efficiency << 1.30 << 0.700;
*Lookup_Combustion_Efficiency << 1.40 << 0.630;
*Lookup_Combustion_Efficiency << 1.50 << 0.570;
*Lookup_Combustion_Efficiency << 1.60 << 0.525;
*Lookup_Combustion_Efficiency << 2.00 << 0.345;
@endcode
The first column in the table, above, is thi (the lookup index, or key). The
second column is the output data - in this case, "neta" (the Greek letter
referring to combustion efficiency). Later on, the table is used like this:
@code
combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
@endcode
@author Jon S. Berndt
@version $Id$
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -266,6 +305,8 @@ private:
mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
double** Allocate(void);
FGPropertyManager* const PropertyManager;
string Name;
void bind(void);
void Debug(int from);
};

View file

@ -1,9 +1,11 @@
noinst_LIBRARIES = libMath.a
libMath_a_SOURCES = FGColumnVector3.cpp FGFunction.cpp FGLocation.cpp FGMatrix33.cpp \
FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp
FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp \
FGCondition.cpp
noinst_HEADERS = FGColumnVector3.h FGFunction.h FGLocation.h FGMatrix33.h \
FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h
FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h \
FGCondition.h
INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim

View file

@ -8,20 +8,20 @@
------------- Copyright (C) 2000 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
@ -76,6 +76,9 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
clsq = lod = 0.0;
alphaw = 0.0;
bi2vel = ci2vel = 0.0;
AeroRPShift = 0;
vDeltaRP.InitMatrix();
bind();
Debug(0);
@ -87,8 +90,6 @@ FGAerodynamics::~FGAerodynamics()
{
unsigned int i,j;
unbind();
for (i=0; i<6; i++)
for (j=0; j<Coeff[i].size(); j++)
delete Coeff[i][j];
@ -98,6 +99,10 @@ FGAerodynamics::~FGAerodynamics()
for (i=0; i<variables.size(); i++)
delete variables[i];
if (AeroRPShift) delete AeroRPShift;
unbind();
Debug(1);
}
@ -153,6 +158,11 @@ bool FGAerodynamics::Run(void)
}
}
// Calculate aerodynamic reference point shift, if any
if (AeroRPShift) {
vDeltaRP(eX) = AeroRPShift->GetValue()*Aircraft->Getcbar()*12.0;
}
// calculate lift coefficient squared
if ( Auxiliary->Getqbar() > 0) {
clsq = vFs(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar());
@ -170,7 +180,7 @@ bool FGAerodynamics::Run(void)
// transform stability axis forces into body axes
vForces = State->GetTs2b()*vFs;
vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp() + vDeltaRP);
vMoments = vDXYZcg*vForces; // M = r X F
@ -202,6 +212,11 @@ bool FGAerodynamics::Load(Element *element)
alphahystmax = temp_element->FindElementValueAsNumberConvertTo("max", "DEG");
}
if (temp_element = element->FindElement("aero_ref_pt_shift_x")) {
function_element = temp_element->FindElement("function");
AeroRPShift = new FGFunction(PropertyManager, function_element);
}
function_element = element->FindElement("function");
while (function_element) {
variables.push_back( new FGFunction(PropertyManager, function_element) );
@ -243,7 +258,11 @@ string FGAerodynamics::GetCoefficientStrings(string delimeter)
for (axis = 0; axis < 6; axis++) {
for (sd = 0; sd < Coeff[axis].size(); sd++) {
CoeffStrings += delimeter;
if (firstime) {
firstime = false;
} else {
CoeffStrings += delimeter;
}
CoeffStrings += Coeff[axis][sd]->GetName();
}
}
@ -269,7 +288,11 @@ string FGAerodynamics::GetCoefficientValues(string delimeter)
for (unsigned int axis = 0; axis < 6; axis++) {
for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
SDValues += delimeter;
if (firstime) {
firstime = false;
} else {
SDValues += delimeter;
}
SDValues += Coeff[axis][sd]->GetValueAsString();
}
}

View file

@ -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,7 +75,8 @@ CLASS DOCUMENTATION
/** Encapsulates the aerodynamic calculations.
This class owns and contains the list of force/coefficients that define the
aerodynamic properties of an aircraft. Here also, such unique phenomena
as ground effect and maximum lift curve tailoff are handled.
as ground effect, aerodynamic reference point shift, and maximum lift curve
tailoff are handled.
@code
<aerodynamics>
@ -133,17 +134,24 @@ public:
similar call to GetForces(int n).*/
double GetMoments(int n) const {return vMoments(n);}
FGColumnVector3& GetvLastFs(void) { return vLastFs; }
double GetvLastFs(int axis) const { return vLastFs(axis); }
/** Retrieves the aerodynamic forces in the stability axes.
@return a reference to a column vector containing the stability axis forces. */
FGColumnVector3& GetvFs(void) { return vFs; }
/** Retrieves the aerodynamic forces in the stability axes, given an axis.
@param axis the axis to return the force for (eX, eY, eZ).
@return a reference to a column vector containing the requested stability
axis force. */
double GetvFs(int axis) const { return vFs(axis); }
/** Retrieves the lift over drag ratio */
inline double GetLoD(void) const { return lod; }
/** Retrieves the square of the lift coefficient. */
inline double GetClSquared(void) const { return clsq; }
inline double GetAlphaCLMax(void) const { return alphaclmax; }
inline double GetAlphaCLMin(void) const { return alphaclmin; }
inline double GetAlphaHystMax(void) const { return alphahystmax; }
inline double GetAlphaHystMin(void) const { return alphahystmin; }
inline double GetHysteresisParm(void) const { return stall_hyst; }
inline double GetStallWarn(void) const { return impending_stall; }
double GetAlphaW(void) const { return alphaw; }
@ -168,6 +176,7 @@ public:
private:
typedef map<string,int> AxisIndex;
AxisIndex AxisIdx;
FGFunction* AeroRPShift;
vector <FGFunction*> variables;
typedef vector <FGFunction*> CoeffArray;
CoeffArray* Coeff;
@ -176,6 +185,7 @@ private:
FGColumnVector3 vMoments;
FGColumnVector3 vLastFs;
FGColumnVector3 vDXYZcg;
FGColumnVector3 vDeltaRP;
double alphaclmax, alphaclmin;
double alphahystmax, alphahystmin;
double impending_stall, stall_hyst;

View file

@ -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
@ -125,10 +125,8 @@ bool FGAircraft::Run(void)
vMoments += Propulsion->GetMoments();
vMoments += GroundReactions->GetMoments();
// printf("%s:%i\n", __FILE__, __LINE__);
vBodyAccel = vForces/MassBalance->GetMass();
// printf("%s:%i\n", __FILE__, __LINE__);
vNcg = vBodyAccel/Inertial->gravity();
vNwcg = State->GetTb2s() * vNcg;

View file

@ -1,32 +1,32 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGAircraft.h
Author: Jon S. Berndt
Date started: 12/12/98
------------- 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
--------------------------------------------------------------------------------
12/12/98 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -102,7 +102,7 @@ public:
/** Constructor
@param Executive a pointer to the parent executive object */
FGAircraft(FGFDMExec *Executive);
/// Destructor
~FGAircraft();
@ -110,17 +110,17 @@ public:
@see JSBSim.cpp documentation
@return false if no error */
bool Run(void);
/** Loads the aircraft.
The executive calls this method to load the aircraft into JSBSim.
@param el a pointer to the element tree
@return true if successful */
bool Load(Element* el);
/** Gets the aircraft name
@return the name of the aircraft as a string type */
inline string GetAircraftName(void) { return AircraftName; }
/// Gets the wing area
double GetWingArea(void) const { return WingArea; }
/// Gets the wing span
@ -152,6 +152,8 @@ public:
inline double GetXYZep(int idx) const { return vXYZep(idx); }
inline void SetAircraftName(string name) {AircraftName = name;}
void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;}
double GetNlf(void);
inline FGColumnVector3& GetNwcg(void) { return vNwcg; }

View file

@ -10,20 +10,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

View file

@ -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.
HISTORY

View file

@ -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
@ -107,7 +107,8 @@ bool FGAuxiliary::Run()
const FGColumnVector3& vUVWdot = Propagate->GetUVWdot();
const FGColumnVector3& vVel = Propagate->GetVel();
if (FGModel::Run()) return true;
if (FGModel::Run()) return true; // return true if error returned from base class
if (FDMExec->Holding()) return false;
p = Atmosphere->GetPressure();
@ -118,13 +119,14 @@ bool FGAuxiliary::Run()
// Rotation
double cTht = Propagate->GetCosEuler(eTht);
double sTht = Propagate->GetSinEuler(eTht);
double cPhi = Propagate->GetCosEuler(ePhi);
double sPhi = Propagate->GetSinEuler(ePhi);
vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
if (cTht != 0.0) {
vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht;
vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sPhi;
vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht;
}
// 12/16/2005, JSB: For ground handling purposes, at this time, let's ramp
@ -185,11 +187,12 @@ bool FGAuxiliary::Run()
if (psigt < 0.0) psigt += 2*M_PI;
if (Vt != 0) {
hdot_Vt = -vVel(eDown)/Vt;
if (fabs(hdot_Vt) <= 1) gamma = asin(hdot_Vt);
if (Vground == 0.0) {
if (vVel(eDown) == 0.0) gamma = 0.0;
else if (vVel(eDown) < 0.0) gamma = 90.0*degtorad;
else gamma = -90.0*degtorad;
} else {
gamma = 0.0;
gamma = atan2(-vVel(eDown), Vground);
}
tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
@ -275,14 +278,14 @@ void FGAuxiliary::bind(void)
{
typedef double (FGAuxiliary::*PMF)(int) const;
typedef double (FGAuxiliary::*PF)(void) const;
PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
PropertyManager->Tie("velocities/tat-r", this, &FGAuxiliary::GetTotalTemperature);
PropertyManager->Tie("velocities/tat-c", this, &FGAuxiliary::GetTAT_C);
PropertyManager->Tie("velocities/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);
PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);
PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);
@ -327,17 +330,18 @@ void FGAuxiliary::bind(void)
void FGAuxiliary::unbind(void)
{
PropertyManager->Untie("propulsion/tat-r");
PropertyManager->Untie("propulsion/tat-c");
PropertyManager->Untie("propulsion/pt-lbs_sqft");
PropertyManager->Untie("velocities/vc-fps");
PropertyManager->Untie("velocities/vc-kts");
PropertyManager->Untie("velocities/ve-fps");
PropertyManager->Untie("velocities/ve-kts");
PropertyManager->Untie("velocities/machU");
PropertyManager->Untie("velocities/tat-r");
PropertyManager->Untie("velocities/tat-c");
PropertyManager->Untie("velocities/p-aero-rad_sec");
PropertyManager->Untie("velocities/q-aero-rad_sec");
PropertyManager->Untie("velocities/r-aero-rad_sec");
PropertyManager->Untie("velocities/pt-lbs_sqft");
PropertyManager->Untie("velocities/phidot-rad_sec");
PropertyManager->Untie("velocities/thetadot-rad_sec");
PropertyManager->Untie("velocities/psidot-rad_sec");

View file

@ -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

View file

@ -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
@ -45,6 +45,7 @@ INCLUDES
#include <models/flight_control/FGFilter.h>
#include <models/flight_control/FGDeadBand.h>
#include <models/flight_control/FGGain.h>
#include <models/flight_control/FGPID.h>
#include <models/flight_control/FGGradient.h>
#include <models/flight_control/FGSwitch.h>
#include <models/flight_control/FGSummer.h>
@ -453,10 +454,9 @@ void FGFCS::SetPropFeather(int engineNum, bool setting)
bool FGFCS::Load(Element* el)
{
string name, file, fname, comp_name, interface_property_string;
unsigned i;
string name, file, fname, interface_property_string;
vector <FGFCSComponent*> *Components;
Element *FCS_cfg, *document, *component_element, *property_element, *sensor_element;
Element *document, *component_element, *property_element, *sensor_element;
Element *channel_element;
ifstream* controls_file = new ifstream();
FGXMLParse controls_file_parser;
@ -474,7 +474,7 @@ bool FGFCS::Load(Element* el)
if (name.empty()) {
fname = el->GetAttributeValue("file");
file = FDMExec->GetAircraftPath() + separator + FDMExec->GetModelName() + separator + fname + ".xml";
file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
if (fname.empty()) {
cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
return false;
@ -527,60 +527,42 @@ bool FGFCS::Load(Element* el)
channel_element = document->FindElement("channel");
while (channel_element) {
component_element = channel_element->FindElement("component");
if (component_element) {
cout << "This form of the component specification is being deprecated" << endl;
} else {
component_element = channel_element->GetElement();
}
component_element = channel_element->GetElement();
while (component_element) {
comp_name = component_element->GetAttributeValue("type");
try {
if ((comp_name == "LAG_FILTER") ||
(comp_name == "LEAD_LAG_FILTER") ||
(comp_name == "SECOND_ORDER_FILTER") ||
(comp_name == "WASHOUT_FILTER") ||
(comp_name == "INTEGRATOR") ||
(component_element->GetName() == string("lag_filter")) ||
if ((component_element->GetName() == string("lag_filter")) ||
(component_element->GetName() == string("lead_lag_filter")) ||
(component_element->GetName() == string("washout_filter")) ||
(component_element->GetName() == string("second_order_filter")) ||
(component_element->GetName() == string("integrator")) )
{
Components->push_back(new FGFilter(this, component_element));
} else if ((comp_name == "PURE_GAIN") ||
(comp_name == "SCHEDULED_GAIN") ||
(comp_name == "AEROSURFACE_SCALE") ||
(component_element->GetName() == string("pure_gain")) ||
} else if ((component_element->GetName() == string("pure_gain")) ||
(component_element->GetName() == string("scheduled_gain")) ||
(component_element->GetName() == string("aerosurface_scale")))
{
Components->push_back(new FGGain(this, component_element));
} else if ((comp_name == "SUMMER") || (component_element->GetName() == string("summer"))) {
} else if (component_element->GetName() == string("summer")) {
Components->push_back(new FGSummer(this, component_element));
} else if ((comp_name == "DEADBAND") || (component_element->GetName() == string("deadband"))) {
} else if (component_element->GetName() == string("deadband")) {
Components->push_back(new FGDeadBand(this, component_element));
} else if (comp_name == "GRADIENT") {
Components->push_back(new FGGradient(this, component_element));
} else if ((comp_name == "SWITCH") || (component_element->GetName() == string("switch"))) {
} else if (component_element->GetName() == string("switch")) {
Components->push_back(new FGSwitch(this, component_element));
} else if ((comp_name == "KINEMAT") || (component_element->GetName() == string("kinematic"))) {
} else if (component_element->GetName() == string("kinematic")) {
Components->push_back(new FGKinemat(this, component_element));
} else if ((comp_name == "FUNCTION") || (component_element->GetName() == string("fcs_function"))) {
} else if (component_element->GetName() == string("fcs_function")) {
Components->push_back(new FGFCSFunction(this, component_element));
} else if (component_element->GetName() == string("pid")) {
Components->push_back(new FGPID(this, component_element));
} else {
cerr << "Unknown FCS component: " << comp_name << endl;
cerr << "Unknown FCS component: " << component_element->GetName() << endl;
}
} catch(string s) {
cerr << highint << fgred << endl << " " << s << endl;
cerr << reset << endl;
return false;
}
if (comp_name.empty()) { // comp_name will be empty if using new format
component_element = channel_element->GetNextElement();
} else {
component_element = channel_element->FindNextElement("component");
}
component_element = channel_element->GetNextElement();
}
channel_element = document->FindNextElement("channel");
}
@ -635,7 +617,7 @@ string FGFCS::GetComponentValues(string delimeter)
{
unsigned int comp;
string CompValues = "";
char buffer[12];
char buffer[17];
bool firstime = true;
for (comp = 0; comp < FCSComponents.size(); comp++) {
@ -651,6 +633,7 @@ string FGFCS::GetComponentValues(string delimeter)
CompValues += string(buffer);
}
CompValues += "\0";
return CompValues;
}
@ -667,7 +650,7 @@ void FGFCS::AddThrottle(void)
PropFeatherCmd.push_back(false);
PropFeather.push_back(false);
unsigned int num = ThrottleCmd.size()-1;
unsigned int num = (unsigned int)ThrottleCmd.size()-1;
bindThrottle(num);
}
@ -685,14 +668,12 @@ void FGFCS::bind(void)
PropertyManager->Tie("fcs/aileron-cmd-norm", this, &FGFCS::GetDaCmd, &FGFCS::SetDaCmd);
PropertyManager->Tie("fcs/elevator-cmd-norm", this, &FGFCS::GetDeCmd, &FGFCS::SetDeCmd);
PropertyManager->Tie("fcs/rudder-cmd-norm", this, &FGFCS::GetDrCmd, &FGFCS::SetDrCmd);
PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd);
PropertyManager->Tie("fcs/flap-cmd-norm", this, &FGFCS::GetDfCmd, &FGFCS::SetDfCmd);
PropertyManager->Tie("fcs/speedbrake-cmd-norm", this, &FGFCS::GetDsbCmd, &FGFCS::SetDsbCmd);
PropertyManager->Tie("fcs/spoiler-cmd-norm", this, &FGFCS::GetDspCmd, &FGFCS::SetDspCmd);
PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this, &FGFCS::GetPitchTrimCmd, &FGFCS::SetPitchTrimCmd);
PropertyManager->Tie("fcs/roll-trim-cmd-norm", this, &FGFCS::GetRollTrimCmd, &FGFCS::SetRollTrimCmd);
PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this, &FGFCS::GetYawTrimCmd, &FGFCS::SetYawTrimCmd);
PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd);
PropertyManager->Tie("fcs/left-aileron-pos-rad", this, ofRad, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
PropertyManager->Tie("fcs/left-aileron-pos-deg", this, ofDeg, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
@ -729,6 +710,11 @@ void FGFCS::bind(void)
PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this, ofMag, &FGFCS::GetDspPos);
PropertyManager->Tie("gear/gear-pos-norm", this, &FGFCS::GetGearPos, &FGFCS::SetGearPos);
PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd);
PropertyManager->Tie("fcs/left-brake-cmd-norm", this, &FGFCS::GetLBrake, &FGFCS::SetLBrake);
PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake);
PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake);
PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -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
@ -501,6 +501,18 @@ public:
@param bg which brakegroup to retrieve the command for
@return the brake setting for the supplied brake group argument */
double GetBrake(FGLGear::BrakeGroup bg);
/** Gets the left brake.
@return the left brake setting. */
double GetLBrake(void) const {return LeftBrake;}
/** Gets the right brake.
@return the right brake setting. */
double GetRBrake(void) const {return RightBrake;}
/** Gets the center brake.
@return the center brake setting. */
double GetCBrake(void) const {return CenterBrake;}
//@}
/** Loads the Flight Control System.

View file

@ -8,20 +8,20 @@
------------- Copyright (C) 2000 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
@ -142,26 +142,28 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter)
std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
string name = lGear[i].GetName();
buf << name << "_WOW" << delimeter
<< name << "_stroke" << delimeter
<< name << "_strokeVel" << delimeter
<< name << "_CompressForce" << delimeter
<< name << "_WhlSideForce" << delimeter
<< name << "_WhlVelVecX" << delimeter
<< name << "_WhlVelVecY" << delimeter
<< name << "_WhlRollForce" << delimeter
<< name << "_BodyXForce" << delimeter
<< name << "_BodyYForce" << delimeter
<< name << "_WhlSlipDegrees" << delimeter;
if (lGear[i].IsBogey()) {
string name = lGear[i].GetName();
buf << name << " WOW" << delimeter
<< name << " stroke (ft)" << delimeter
<< name << " stroke velocity (ft/sec)" << delimeter
<< name << " compress force (lbs)" << delimeter
<< name << " wheel side force (lbs)" << delimeter
<< name << " wheel velocity vec X (ft/sec)" << delimeter
<< name << " wheel velocity vec Y (ft/sec)" << delimeter
<< name << " wheel roll force (lbs)" << delimeter
<< name << " body X force (lbs)" << delimeter
<< name << " body Y force (lbs)" << delimeter
<< name << " wheel slip (deg)" << delimeter;
}
}
buf << "TotalGearForce_X" << delimeter
<< "TotalGearForce_Y" << delimeter
<< "TotalGearForce_Z" << delimeter
<< "TotalGearMoment_L" << delimeter
<< "TotalGearMoment_M" << delimeter
<< "TotalGearMoment_N";
buf << " Total Gear Force_X (lbs)" << delimeter
<< " Total Gear Force_Y (lbs)" << delimeter
<< " Total Gear Force_Z (lbs)" << delimeter
<< " Total Gear Moment_L (ft-lbs)" << delimeter
<< " Total Gear Moment_M (ft-lbs)" << delimeter
<< " Total Gear Moment_N (ft-lbs)";
return buf.str();
}
@ -173,18 +175,20 @@ string FGGroundReactions::GetGroundReactionValues(string delimeter)
std::ostringstream buf;
for (unsigned int i=0;i<lGear.size();i++) {
FGLGear& gear = lGear[i];
buf << (gear.GetWOW() ? "1, " : "0, ")
<< setprecision(5) << gear.GetCompLen() << delimeter
<< setprecision(6) << gear.GetCompVel() << delimeter
<< setprecision(10) << gear.GetCompForce() << delimeter
<< setprecision(6) << gear.GetWheelVel(eX) << delimeter
<< gear.GetWheelVel(eY) << delimeter
<< gear.GetWheelSideForce() << delimeter
<< gear.GetWheelRollForce() << delimeter
<< gear.GetBodyXForce() << delimeter
<< gear.GetBodyYForce() << delimeter
<< gear.GetWheelSlipAngle() << delimeter;
if (lGear[i].IsBogey()) {
FGLGear& gear = lGear[i];
buf << (gear.GetWOW() ? "1, " : "0, ")
<< setprecision(5) << gear.GetCompLen() << delimeter
<< setprecision(6) << gear.GetCompVel() << delimeter
<< setprecision(10) << gear.GetCompForce() << delimeter
<< setprecision(6) << gear.GetWheelVel(eX) << delimeter
<< gear.GetWheelVel(eY) << delimeter
<< gear.GetWheelSideForce() << delimeter
<< gear.GetWheelRollForce() << delimeter
<< gear.GetBodyXForce() << delimeter
<< gear.GetBodyYForce() << delimeter
<< gear.GetWheelSlipAngle() << delimeter;
}
}
buf << vForces(eX) << delimeter

View file

@ -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
@ -89,7 +89,7 @@ public:
string GetGroundReactionValues(string delimeter);
bool GetWOW(void);
inline int GetNumGearUnits(void) const { return lGear.size(); }
int GetNumGearUnits(void) const { return lGear.size(); }
/** Gets a gear instance
@param gear index of gear instance
@ -103,8 +103,6 @@ private:
vector <FGLGear> lGear;
FGColumnVector3 vForces;
FGColumnVector3 vMoments;
FGColumnVector3 vMaxStaticGrip;
FGColumnVector3 vMaxMomentResist;
void Debug(int from);
};

View file

@ -8,20 +8,20 @@
------------- Copyright (C) 2000 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

View file

@ -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

View file

@ -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
@ -69,8 +69,7 @@ FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
FGInput::~FGInput()
{
if (socket) delete socket;
delete socket;
Debug(1);
}
@ -89,7 +88,8 @@ bool FGInput::Run(void)
FGPropertyManager* node=0;
if (FGModel::Run()) return true; // fast exit if nothing to do
if (port == 0) return true; // Do nothing here if port not defined
if (port == 0) return false; // Do nothing here if port not defined
// return false if no error
// This model DOES execute if "Exec->Holding"
data = socket->Receive(); // get socket transmission if present

View file

@ -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

View file

@ -10,20 +10,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
@ -135,6 +135,40 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
<< sSteerType << " is undefined." << endl;
}
RFRV = 0.7; // Rolling force relaxation velocity, default value
SFRV = 0.7; // Side force relaxation velocity, default value
Element* relax_vel = el->FindElement("relaxation_velocity");
if (relax_vel) {
if (relax_vel->FindElement("rolling")) {
RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
}
if (relax_vel->FindElement("side")) {
SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
}
}
State = Exec->GetState();
LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
if (force_lag_filter_elem) {
if (force_lag_filter_elem->FindElement("rolling")) {
LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
}
if (force_lag_filter_elem->FindElement("side")) {
LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
}
}
WheelSlipLagFilterCoeff = 1/State->Getdt();
Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
if (wheel_slip_angle_lag_elem) {
WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
}
GearUp = false;
GearDown = true;
Servicable = true;
@ -168,8 +202,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
brakePct = 0.0;
maxCompLen = 0.0;
WheelSlip = last_WheelSlip = 0.0;
slipIn = last_SlipIn = 0;
WheelSlip = 0.0;
TirePressureNorm = 1.0;
Debug(0);
@ -237,12 +270,15 @@ FGLGear::FGLGear(const FGLGear& lgear)
ForceY_Table = lgear.ForceY_Table;
CosWheel = lgear.CosWheel;
SinWheel = lgear.SinWheel;
In = lgear.In;
prevIn = lgear.prevIn;
prevOut = lgear.prevOut;
slipIn = lgear.slipIn;
last_SlipIn = lgear.last_SlipIn;
last_WheelSlip = lgear.last_WheelSlip;
prevIn = lgear.prevIn;
prevSlipIn = lgear.prevSlipIn;
prevSlipOut = lgear.prevSlipOut;
RFRV = lgear.RFRV;
SFRV = lgear.SFRV;
LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -259,6 +295,7 @@ FGColumnVector3& FGLGear::Force(void)
FGColumnVector3 normal, cvel;
FGLocation contact, gearLoc;
double t = Exec->GetState()->Getsim_time();
dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
vForce.InitMatrix();
vMoment.InitMatrix();
@ -308,20 +345,42 @@ FGColumnVector3& FGLGear::Force(void)
vForce = Propagate->GetTl2b() * vLocalForce;
// Lag and attenuate the XY-plane forces dependent on velocity
// Start experimental section for gear jitter reduction
//
// Lag and attenuate the XY-plane forces dependent on velocity
double RFRV = 0.015; // Rolling force relaxation velocity
double SFRV = 0.25; // Side force relaxation velocity
double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
double ca, cb, denom;
FGColumnVector3 Output;
In = vForce;
vForce(eX) = (0.25)*(In(eX) + prevIn(eX)) + (0.50)*prevOut(eX);
vForce(eY) = (0.15)*(In(eY) + prevIn(eY)) + (0.70)*prevOut(eY);
prevOut = vForce;
prevIn = In;
// This code implements a lag filter, C/(s + C) where
// "C" is the filter coefficient. When "C" is chosen at the
// frame rate (in Hz), the jittering is significantly reduced. This is because
// the jitter is present *at* the execution rate.
// If a coefficient is set to something equal to or less than zero, the filter
// is bypassed.
if (fabs(RollingWhlVel) <= RFRV) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
if (fabs(SideWhlVel) <= SFRV) vForce(eY) *= fabs(SideWhlVel)/SFRV;
if (LongForceLagFilterCoeff > 0) {
denom = 2.00 + dT*LongForceLagFilterCoeff;
ca = dT*LongForceLagFilterCoeff / denom;
cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
vForce(eX) = Output(eX);
}
if (LatForceLagFilterCoeff > 0) {
denom = 2.00 + dT*LatForceLagFilterCoeff;
ca = dT*LatForceLagFilterCoeff / denom;
cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
vForce(eY) = Output(eY);
}
prevIn = vForce;
prevOut = Output;
if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
// End experimental section for attentuating gear jitter
vMoment = vWhlBodyVec * vForce;
@ -362,24 +421,31 @@ void FGLGear::ComputeRetractionState(void)
void FGLGear::ComputeSlipAngle(void)
{
double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
// Transform the wheel velocities from the local axis system to the wheel axis system.
RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
// Calculate tire slip angle.
if (fabs(RollingWhlVel) < 0.1 && fabs(SideWhlVel) < 0.01) {
if (fabs(RollingWhlVel) < 0.02 && fabs(SideWhlVel) < 0.02) {
WheelSlip = -SteerAngle*radtodeg;
} else {
WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
}
slipIn = WheelSlip;
WheelSlip = (0.46)*(slipIn + last_SlipIn) + (0.08)*last_WheelSlip;
last_WheelSlip = WheelSlip;
last_SlipIn = slipIn;
// Filter the wheel slip angle
double SlipOutput, ca, cb, denom;
if (WheelSlipLagFilterCoeff > 0) {
denom = 2.00 + dT*WheelSlipLagFilterCoeff;
ca = dT*WheelSlipLagFilterCoeff / denom;
cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
prevSlipIn = WheelSlip;
WheelSlip = prevSlipOut = SlipOutput;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -484,10 +550,10 @@ void FGLGear::ReportTakeoffOrLanding(void)
void FGLGear::CrashDetect(void)
{
if (compressLength > 500.0 ||
if ( (compressLength > 500.0 ||
vForce.Magnitude() > 100000000.0 ||
vMoment.Magnitude() > 5000000000.0 ||
SinkRate > 1.4666*30)
SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
{
PutMessage("Crash Detected: Simulation FREEZE.");
State->SuspendIntegration();
@ -670,6 +736,9 @@ void FGLGear::Debug(int from)
cout << " Grouping: " << sBrakeGroup << endl;
cout << " Max Steer Angle: " << maxSteerAngle << endl;
cout << " Retractable: " << isRetractable << endl;
cout << " Relaxation Velocities:" << endl;
cout << " Rolling: " << RFRV << endl;
cout << " Side: " << SFRV << endl;
}
}
}

View file

@ -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
@ -264,10 +264,9 @@ private:
FGColumnVector3 last_vForce; // remove this
FGColumnVector3 vLocalForce;
FGColumnVector3 vWhlVelVec; // Velocity of this wheel (Local)
FGColumnVector3 In;
FGColumnVector3 prevIn;
FGColumnVector3 prevOut;
FGColumnVector3 prevOut, prevIn;
FGTable *ForceY_Table;
double dT;
double SteerAngle;
double kSpring;
double bDamp;
@ -288,9 +287,8 @@ private:
double SideWhlVel, RollingWhlVel;
double RollingForce, SideForce, FCoeff;
double WheelSlip;
double last_WheelSlip;
double slipIn;
double last_SlipIn;
double prevSlipIn;
double prevSlipOut;
double TirePressureNorm;
double SinWheel, CosWheel;
bool WOW;
@ -312,6 +310,11 @@ private:
BrakeGroup eBrakeGrp;
SteerType eSteerType;
double maxSteerAngle;
double RFRV; // Rolling force relaxation velocity
double SFRV; // Side force relaxation velocity
double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient
double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
FGFDMExec* Exec;
FGState* State;

View file

@ -8,20 +8,20 @@
------------- Copyright (C) 2000 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
@ -139,7 +139,6 @@ bool FGMassBalance::Run(void)
// Calculate new CG
// printf("%s:%i\n", __FILE__, __LINE__);
vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg
+ GetPointMassMoment() ) / Weight;
@ -189,19 +188,14 @@ void FGMassBalance::AddPointMass(Element* el)
{
Element* loc_element = el->FindElement("location");
string pointmass_name = el->GetAttributeValue("name");
if (!el) {
cerr << "Pointmass " << pointmass_name << "has no location." << endl;
if (!loc_element) {
cerr << "Pointmass " << pointmass_name << " has no location." << endl;
exit(-1);
}
string loc_unit = loc_element->GetAttributeValue("unit");
double w, x, y, z;
w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
x = loc_element->FindElementValueAsNumberConvertTo("x", loc_unit);
y = loc_element->FindElementValueAsNumberConvertTo("y", loc_unit);
z = loc_element->FindElementValueAsNumberConvertTo("z", loc_unit);
PointMasses.push_back(PointMass(w, x, y, z));
double w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
FGColumnVector3 vXYZ = loc_element->FindElementTripletConvertTo("IN");
PointMasses.push_back(PointMass(w, vXYZ));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 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
@ -146,9 +146,9 @@ private:
FGMatrix33& CalculatePMInertias(void);
struct PointMass {
PointMass(double w, double x, double y, double z) {
PointMass(double w, FGColumnVector3& vXYZ) {
Weight = w;
Location.InitMatrix(x, y, z);
Location = vXYZ;
}
FGColumnVector3 Location;
double Weight;

View file

@ -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
@ -136,13 +136,10 @@ bool FGModel::Run()
{
if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
if (exe_ctr == 1) {
if (exe_ctr++ >= rate) exe_ctr = 1;
return false;
} else {
if (exe_ctr++ >= rate) exe_ctr = 1;
return true;
}
if (exe_ctr++ >= rate) exe_ctr = 1;
if (exe_ctr == 1) return false;
else return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -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

View file

@ -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
@ -73,6 +73,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
enabled = true;
delimeter = ", ";
Filename = "";
DirectivesFile = "";
Debug(0);
}
@ -81,9 +82,8 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
FGOutput::~FGOutput()
{
if (socket) delete socket;
delete socket;
OutputProperties.clear();
Debug(1);
}
@ -152,70 +152,70 @@ void FGOutput::DelimitedOutput(string fname)
}
if (SubSystems & ssAerosurfaces) {
outstream << delimeter;
outstream << "Aileron Cmd" + delimeter;
outstream << "Elevator Cmd" + delimeter;
outstream << "Rudder Cmd" + delimeter;
outstream << "Flap Cmd" + delimeter;
outstream << "Left Aileron Pos" + delimeter;
outstream << "Right Aileron Pos" + delimeter;
outstream << "Elevator Pos" + delimeter;
outstream << "Rudder Pos" + delimeter;
outstream << "Flap Pos";
outstream << "Aileron Command (norm)" + delimeter;
outstream << "Elevator Command (norm)" + delimeter;
outstream << "Rudder Command (norm)" + delimeter;
outstream << "Flap Command (norm)" + delimeter;
outstream << "Left Aileron Position (deg)" + delimeter;
outstream << "Right Aileron Position (deg)" + delimeter;
outstream << "Elevator Position (deg)" + delimeter;
outstream << "Rudder Position (deg)" + delimeter;
outstream << "Flap Position (deg)";
}
if (SubSystems & ssRates) {
outstream << delimeter;
outstream << "P" + delimeter + "Q" + delimeter + "R" + delimeter;
outstream << "Pdot" + delimeter + "Qdot" + delimeter + "Rdot";
outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter;
outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)";
}
if (SubSystems & ssVelocities) {
outstream << delimeter;
outstream << "QBar" + delimeter;
outstream << "Vtotal" + delimeter;
outstream << "q bar (psf)" + delimeter;
outstream << "V_{Total} (ft/s)" + delimeter;
outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
outstream << "UAero" + delimeter + "VAero" + delimeter + "WAero" + delimeter;
outstream << "Vn" + delimeter + "Ve" + delimeter + "Vd";
outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
}
if (SubSystems & ssForces) {
outstream << delimeter;
outstream << "Drag" + delimeter + "Side" + delimeter + "Lift" + delimeter;
outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter;
outstream << "L/D" + delimeter;
outstream << "Xforce" + delimeter + "Yforce" + delimeter + "Zforce";
outstream << "F_X (lbs)" + delimeter + "F_Y (lbs)" + delimeter + "F_Z (lbs)";
}
if (SubSystems & ssMoments) {
outstream << delimeter;
outstream << "L" + delimeter + "M" + delimeter + "N";
outstream << "L (ft-lbs)" + delimeter + "M (ft-lbs)" + delimeter + "N (ft-lbs)";
}
if (SubSystems & ssAtmosphere) {
outstream << delimeter;
outstream << "Rho" + delimeter;
outstream << "SL pressure" + delimeter;
outstream << "Ambient pressure" + delimeter;
outstream << "NWind" + delimeter + "EWind" + delimeter + "DWind";
outstream << "Rho (slugs/ft^3)" + delimeter;
outstream << "P_{SL} (psf)" + delimeter;
outstream << "P_{Ambient} (psf)" + delimeter;
outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)";
}
if (SubSystems & ssMassProps) {
outstream << delimeter;
outstream << "Ixx" + delimeter;
outstream << "Ixy" + delimeter;
outstream << "Ixz" + delimeter;
outstream << "Iyx" + delimeter;
outstream << "Iyy" + delimeter;
outstream << "Iyz" + delimeter;
outstream << "Izx" + delimeter;
outstream << "Izy" + delimeter;
outstream << "Izz" + delimeter;
outstream << "I_xx" + delimeter;
outstream << "I_xy" + delimeter;
outstream << "I_xz" + delimeter;
outstream << "I_yx" + delimeter;
outstream << "I_yy" + delimeter;
outstream << "I_yz" + delimeter;
outstream << "I_zx" + delimeter;
outstream << "I_zy" + delimeter;
outstream << "I_zz" + delimeter;
outstream << "Mass" + delimeter;
outstream << "Xcg" + delimeter + "Ycg" + delimeter + "Zcg";
outstream << "X_cg" + delimeter + "Y_cg" + delimeter + "Z_cg";
}
if (SubSystems & ssPropagate) {
outstream << delimeter;
outstream << "Altitude" + delimeter;
outstream << "Phi" + delimeter + "Tht" + delimeter + "Psi" + delimeter;
outstream << "Alpha" + delimeter;
outstream << "Beta" + delimeter;
outstream << "Latitude (Deg)" + delimeter;
outstream << "Longitude (Deg)" + delimeter;
outstream << "Distance AGL" + delimeter;
outstream << "Runway Radius";
outstream << "Altitude (ft)" + delimeter;
outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter;
outstream << "Alpha (deg)" + delimeter;
outstream << "Beta (deg)" + delimeter;
outstream << "Latitude (deg)" + delimeter;
outstream << "Longitude (deg)" + delimeter;
outstream << "Distance AGL (ft)" + delimeter;
outstream << "Runway Radius (ft)";
}
if (SubSystems & ssCoefficients) {
scratch = Aerodynamics->GetCoefficientStrings(delimeter);
@ -252,11 +252,11 @@ void FGOutput::DelimitedOutput(string fname)
outstream << FCS->GetDeCmd() << delimeter;
outstream << FCS->GetDrCmd() << delimeter;
outstream << FCS->GetDfCmd() << delimeter;
outstream << FCS->GetDaLPos() << delimeter;
outstream << FCS->GetDaRPos() << delimeter;
outstream << FCS->GetDePos() << delimeter;
outstream << FCS->GetDrPos() << delimeter;
outstream << FCS->GetDfPos();
outstream << FCS->GetDaLPos(ofDeg) << delimeter;
outstream << FCS->GetDaRPos(ofDeg) << delimeter;
outstream << FCS->GetDePos(ofDeg) << delimeter;
outstream << FCS->GetDrPos(ofDeg) << delimeter;
outstream << FCS->GetDfPos(ofDeg);
}
if (SubSystems & ssRates) {
outstream << delimeter;
@ -583,14 +583,28 @@ bool FGOutput::Load(Element* element)
separator = ";";
# endif
fname = element->GetAttributeValue("file");
if (!fname.empty()) {
output_file_name = FDMExec->GetAircraftPath() + separator
+ FDMExec->GetModelName() + separator + fname + ".xml";
if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
fname = DirectivesFile; // one found in the config file.
} else {
fname = element->GetAttributeValue("file");
}
if (!fname.empty()) {
int len = fname.size();
if (fname.find(".xml") != string::npos) {
output_file_name = fname; // Use supplied name if last four letters are ".xml"
} else {
output_file_name = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
}
output_file->open(output_file_name.c_str());
readXML(*output_file, output_file_parser);
delete output_file;
if (output_file->is_open()) {
readXML(*output_file, output_file_parser);
delete output_file;
} else {
delete output_file;
cerr << "Could not open directives file: " << output_file_name << endl;
return false;
}
document = output_file_parser.GetDocument();
} else {
document = element;
@ -644,7 +658,7 @@ bool FGOutput::Load(Element* element)
property_element = document->FindNextElement("property");
}
OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate);
rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
Debug(2);
@ -694,7 +708,7 @@ void FGOutput::Debug(int from)
}
switch (Type) {
case otCSV:
cout << scratch << " in CSV format output at rate " << 120/rate << " Hz" << endl;
cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl;
break;
case otNone:
cout << " No log output" << endl;

View file

@ -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
@ -140,6 +140,9 @@ public:
inline void Disable(void) { enabled = false; }
inline bool Toggle(void) {enabled = !enabled; return enabled;}
bool Load(Element* el);
void SetOutputFileName(string fname) {Filename = fname;}
void SetDirectivesFile(string fname) {DirectivesFile = fname;}
string GetOutputFileName(void) const {return Filename;}
/// Subsystem types for specifying which will be output in the FDM data logging
enum eSubSystems {
@ -159,13 +162,14 @@ public:
} subsystems;
private:
enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
bool sFirstPass, dFirstPass, enabled;
int SubSystems;
string output_file_name, delimeter, Filename;
enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
string output_file_name, delimeter, Filename, DirectivesFile;
ofstream datafile;
FGfdmSocket* socket;
vector <FGPropertyManager*> OutputProperties;
void Debug(int from);
};
}

View file

@ -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
@ -96,6 +96,7 @@ CLASS IMPLEMENTATION
FGPropagate::FGPropagate(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGPropagate";
// vQtrndot.zero();
bind();
Debug(0);
@ -231,22 +232,58 @@ bool FGPropagate::Run(void)
vUVWdot += Tl2b*gAccel;
// Compute vehicle velocity wrt EC frame, expressed in EC frame
FGColumnVector3 vLocationDot = Tl2ec * vVel;
vLocationDot = Tl2ec * vVel;
FGColumnVector3 omegaLocal( rInv*vVel(eEast),
-rInv*vVel(eNorth),
-rInv*vVel(eEast)*VState.vLocation.GetTanLatitude() );
// Compute quaternion orientation derivative on current body rates
FGQuaternion vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal );
vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal );
// Propagate velocities
VState.vPQR += dt*vPQRdot;
VState.vUVW += dt*vUVWdot;
// Integrate to propagate the state
// Propagate positions
VState.vQtrn += dt*vQtrndot;
VState.vLocation += dt*vLocationDot;
// Propagate rotational velocity
// VState.vPQR += dt*(1.5*vPQRdot - 0.5*last_vPQRdot); // Adams-Bashforth
VState.vPQR += (1/12.0)*dt*(23.0*vPQRdot - 16.0*last_vPQRdot + 5.0*last2_vPQRdot); // Adams-Bashforth 3
// VState.vPQR += dt*vPQRdot; // Rectangular Euler
// VState.vPQR += 0.5*dt*(vPQRdot + last_vPQRdot); // Trapezoidal
// Propagate translational velocity
// VState.vUVW += dt*(1.5*vUVWdot - 0.5*last_vUVWdot); // Adams Bashforth
VState.vUVW += (1/12.0)*dt*(23.0*vUVWdot - 16.0*last_vUVWdot + 5.0*last2_vUVWdot); // Adams-Bashforth 3
// VState.vUVW += dt*vUVWdot; // Rectangular Euler
// VState.vUVW += 0.5*dt*(vUVWdot + last_vUVWdot); // Trapezoidal
// Propagate angular position
// VState.vQtrn += dt*(1.5*vQtrndot - 0.5*last_vQtrndot); // Adams Bashforth
VState.vQtrn += (1/12.0)*dt*(23.0*vQtrndot - 16.0*last_vQtrndot + 5.0*last2_vQtrndot); // Adams-Bashforth 3
// VState.vQtrn += dt*vQtrndot; // Rectangular Euler
// VState.vQtrn += 0.5*dt*(vQtrndot + last_vQtrndot); // Trapezoidal
// Propagate translational position
// VState.vLocation += dt*(1.5*vLocationDot - 0.5*last_vLocationDot); // Adams Bashforth
VState.vLocation += (1/12.0)*dt*(23.0*vLocationDot - 16.0*last_vLocationDot + 5.0*last2_vLocationDot); // Adams-Bashforth 3
// VState.vLocation += dt*vLocationDot; // Rectangular Euler
// VState.vLocation += 0.5*dt*(vLocationDot + last_vLocationDot); // Trapezoidal
// Set past values
last2_vPQRdot = last_vPQRdot;
last_vPQRdot = vPQRdot;
last2_vUVWdot = last_vUVWdot;
last_vUVWdot = vUVWdot;
last2_vQtrndot = last_vQtrndot;
last_vQtrndot = vQtrndot;
last2_vLocationDot = last_vLocationDot;
last_vLocationDot = vLocationDot;
return false;
}

View file

@ -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
@ -154,9 +154,11 @@ private:
struct VehicleState VState;
FGColumnVector3 vVel;
FGColumnVector3 vPQRdot;
FGColumnVector3 vUVWdot;
FGColumnVector3 vPQRdot, last_vPQRdot, last2_vPQRdot;
FGColumnVector3 vUVWdot, last_vUVWdot, last2_vUVWdot;
FGColumnVector3 vLocationDot, last_vLocationDot, last2_vLocationDot;
FGQuaternion vQtrndot, last_vQtrndot, last2_vQtrndot;
double RunwayRadius, SeaLevelRadius;
void Debug(int from);

View file

@ -9,20 +9,20 @@
------------- Copyright (C) 2000 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
@ -124,7 +124,7 @@ bool FGPropulsion::Run(void)
Tanks[i]->Calculate( dt * rate );
if (Tanks[i]->GetType() == FGTank::ttFUEL) {
TotalFuelQuantity += Tanks[i]->GetContents();
}
}
}
if (refuel) DoRefuel( dt * rate );
@ -282,7 +282,7 @@ string FGPropulsion::FindEngineFullPathname(string engine_filename)
{
string fullpath, localpath;
string enginePath = FDMExec->GetEnginePath();
string aircraftPath = FDMExec->GetAircraftPath();
string aircraftPath = FDMExec->GetFullAircraftPath();
ifstream* engine_file = new ifstream();
string separator = "/";
@ -313,7 +313,7 @@ ifstream* FGPropulsion::FindEngineFile(string engine_filename)
{
string fullpath, localpath;
string enginePath = FDMExec->GetEnginePath();
string aircraftPath = FDMExec->GetAircraftPath();
string aircraftPath = FDMExec->GetFullAircraftPath();
ifstream* engine_file = new ifstream();
string separator = "/";
@ -572,6 +572,8 @@ void FGPropulsion::bind(void)
void FGPropulsion::unbind(void)
{
if (!IsBound) return;
if (HaveTurbineEngine) {
PropertyManager->Untie("propulsion/starter_cmd");
PropertyManager->Untie("propulsion/cutoff_cmd");

View file

@ -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
@ -119,7 +119,7 @@ public:
bool Load(Element* el);
/// Retrieves the number of engines defined for the aircraft.
inline unsigned int GetNumEngines(void) const {return Engines.size();}
inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
/** Retrieves an engine object pointer from the list of engines.
@param index the engine index within the vector container
@ -130,7 +130,7 @@ public:
else return 0L; }
/// Retrieves the number of tanks defined for the aircraft.
inline unsigned int GetNumTanks(void) const {return Tanks.size();}
inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
/** Retrieves a tank object pointer from the list of tanks.
@param index the tank index within the vector container

View file

@ -9,20 +9,20 @@
------------- Copyright (C) 2003 David P. Culp (davidculp2@comcast.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.
FUNCTIONAL DESCRIPTION

View file

@ -8,20 +8,20 @@
------------- Copyright (C) 2003 David P. Culp (davidculp2@comcast.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

View file

@ -9,20 +9,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.
FUNCTIONAL DESCRIPTION

View file

@ -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.
HISTORY

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2001 Jon S. Berndt -------------
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
@ -59,20 +59,25 @@ CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Models a deadband object.
Here is the format of the deadband control specification:
<pre>
\<COMPONENT NAME="Deadbeat1" TYPE="DEADBAND">
INPUT {input}
WIDTH {deadband width}
MIN {minimum value}
MAX {maximum value}
[GAIN {optional deadband gain}]
[OUTPUT {optional output parameter to set}]
\</COMPONENT>
</pre>
The WIDTH value is the total deadband region within which an input will
produce no output. For example, say that the WIDTH value is 2.0. If the
input is between -1.0 and +1.0, the output will be zero.
This is a component that allows for some play in a control path, in the
form of a dead zone, or deadband. The form of the deadband component
specification is:
@code
<deadband name="Windup Trigger">
<input> [-]property </input>
<width> number </width>
[<clipto>
<min> {[-]property name | value} </min>
<max> {[-]property name | value} </max>
</clipto>]
[<output> {property} </output>]
</deadband>
@endcode
The width value is the total deadband region within which an input will
produce no output. For example, say that the width value is 2.0. If the
input is between 1.0 and +1.0, the output will be zero.
@author Jon S. Berndt
@version $Id$
*/

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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
@ -59,43 +59,44 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
string input, clip_string;
PropertyManager = fcs->GetPropertyManager();
Type = element->GetAttributeValue("type"); // Old, deprecated format
if (Type.empty()) {
if (element->GetName() == string("lag_filter")) {
Type = "LAG_FILTER";
} else if (element->GetName() == string("lead_lag_filter")) {
Type = "LEAD_LAG_FILTER";
} else if (element->GetName() == string("washout_filter")) {
Type = "WASHOUT_FILTER";
} else if (element->GetName() == string("second_order_filter")) {
Type = "SECOND_ORDER_FILTER";
} else if (element->GetName() == string("integrator")) {
Type = "INTEGRATOR";
} else if (element->GetName() == string("summer")) {
Type = "SUMMER";
} else if (element->GetName() == string("pure_gain")) {
Type = "PURE_GAIN";
} else if (element->GetName() == string("scheduled_gain")) {
Type = "SCHEDULED_GAIN";
} else if (element->GetName() == string("aerosurface_scale")) {
Type = "AEROSURFACE_SCALE";
} else if (element->GetName() == string("switch")) {
Type = "SWITCH";
} else if (element->GetName() == string("kinematic")) {
Type = "KINEMATIC";
} else if (element->GetName() == string("deadband")) {
Type = "DEADBAND";
} else if (element->GetName() == string("fcs_function")) {
Type = "FCS_FUNCTION";
} else if (element->GetName() == string("sensor")) {
Type = "SENSOR";
} else { // illegal component in this channel
Type = "UNKNOWN";
}
if (element->GetName() == string("lag_filter")) {
Type = "LAG_FILTER";
} else if (element->GetName() == string("lead_lag_filter")) {
Type = "LEAD_LAG_FILTER";
} else if (element->GetName() == string("washout_filter")) {
Type = "WASHOUT_FILTER";
} else if (element->GetName() == string("second_order_filter")) {
Type = "SECOND_ORDER_FILTER";
} else if (element->GetName() == string("integrator")) {
Type = "INTEGRATOR";
} else if (element->GetName() == string("summer")) {
Type = "SUMMER";
} else if (element->GetName() == string("pure_gain")) {
Type = "PURE_GAIN";
} else if (element->GetName() == string("scheduled_gain")) {
Type = "SCHEDULED_GAIN";
} else if (element->GetName() == string("aerosurface_scale")) {
Type = "AEROSURFACE_SCALE";
} else if (element->GetName() == string("switch")) {
Type = "SWITCH";
} else if (element->GetName() == string("kinematic")) {
Type = "KINEMATIC";
} else if (element->GetName() == string("deadband")) {
Type = "DEADBAND";
} else if (element->GetName() == string("fcs_function")) {
Type = "FCS_FUNCTION";
} else if (element->GetName() == string("pid")) {
Type = "PID";
} else if (element->GetName() == string("sensor")) {
Type = "SENSOR";
} else { // illegal component in this channel
Type = "UNKNOWN";
}
Name = element->GetAttributeValue("name");
FGPropertyManager *tmp=0;
input_element = element->FindElement("input");
while (input_element) {
input = input_element->GetDataLine();
@ -105,7 +106,14 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
} else {
InputSigns.push_back( 1.0);
}
InputNodes.push_back( resolveSymbol(input) );
tmp = PropertyManager->GetNode(input);
if (tmp) {
InputNodes.push_back( tmp );
} else {
cerr << fgred << " In component: " << Name << " unknown property "
<< input << " referenced. Aborting" << endl;
exit(-1);
}
input_element = element->FindNextElement("input");
}
@ -144,9 +152,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
FGFCSComponent::~FGFCSComponent()
{
// string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
// PropertyManager->Untie( tmp);
Debug(1);
}
@ -177,25 +182,21 @@ void FGFCSComponent::Clip(void)
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGPropertyManager* FGFCSComponent::resolveSymbol(string token)
{
string prop;
FGPropertyManager* tmp = PropertyManager->GetNode(token,false);
if (!tmp) {
if (token.find("/") == token.npos) prop = "model/" + token;
cerr << "Creating new property " << prop << endl;
tmp = PropertyManager->GetNode(token,true);
}
return tmp;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// The old way of naming FCS components allowed upper or lower case, spaces, etc.
// but then the names were modified to fit into a property name heirarchy. This
// was confusing (it wasn't done intentionally - it was a carryover from the early
// design). We now support the direct naming of properties in the FCS component
// name attribute. The old way is supported in code at this time, but deprecated.
void FGFCSComponent::bind(void)
{
string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
string tmp;
if (Name.find("/") == string::npos) {
tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
} else {
tmp = Name;
}
PropertyManager->Tie( tmp, this, &FGFCSComponent::GetOutput);
}

View file

@ -7,20 +7,20 @@
------------- Copyright (C) -------------
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
@ -78,7 +78,9 @@ CLASS DOCUMENTATION
- FGFilter
- FGDeadBand
- FGSummer
- FGGradient
- FGSensor
- FGFCSFunction
- FGPID
@author Jon S. Berndt
@version $Id$
@ -125,8 +127,6 @@ protected:
void Clip(void);
virtual void bind();
FGPropertyManager* resolveSymbol(string token);
virtual void Debug(int from);
};

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2005 -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2005 Jon S. Berndt -------------
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
@ -61,6 +61,48 @@ CLASS DOCUMENTATION
/** Models a FCSFunction object.
@author Jon S. Berndt
One of the most recent additions to the FCS component set is the FCS Function
component. This component allows a function to be created when no other component
is suitable. The function component is defined as follows:
@code
<fcs_function name="Windup Trigger">
[<input> [-]property </input>]
<function>
</function>
[<clipto>
<min> {[-]property name | value} </min>
<max> {[-]property name | value} </max>
</clipto>]
[<output> {property} </output>]
</ fcs_function >
@endcode
The function definition itself can include a nested series of products, sums,
quotients, etc. as well as trig and other math functions. Heres an example of
a function (from an aero specification):
@code
<function name="aero/coefficient/CDo">
<description>Drag_at_zero_lift</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar>velocities/mach</independentVar>
<tableData>
0.0000 0.0220
0.2000 0.0200
0.6500 0.0220
0.9000 0.0240
0.9700 0.0500
</tableData>
</table>
</product>
</function>
@endcode
@version $Id$
*/

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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
@ -71,7 +71,7 @@ FGFilter::FGFilter(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
if (element->FindElement("c5")) C5 = element->FindElementValueAsNumber("c5");
if (element->FindElement("c6")) C6 = element->FindElementValueAsNumber("c6");
if (element->FindElement("trigger")) {
Trigger = resolveSymbol(element->FindElementValue("trigger"));
Trigger = PropertyManager->GetNode(element->FindElementValue("trigger"));
}
Initialize = true;

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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
@ -69,6 +69,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
if ( element->FindElement("gain") ) {
gain_string = element->FindElementValue("gain");
//ToDo allow for negative sign here for property
if (gain_string.find_first_not_of("+-.0123456789") != string::npos) { // property
GainPropertyNode = PropertyManager->GetNode(gain_string);
} else {
@ -98,6 +99,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
}
ZeroCentered = true;
zero_centered = element->FindElement("zero_centered");
//ToDo if zero centered, then mins must be <0 and max's must be >0
if (zero_centered) {
sZeroCentered = zero_centered->FindElementValue("zero_centered");
if (sZeroCentered == string("0") || sZeroCentered == string("false")) {

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 1998 by 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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 Anthony K. Peden -------------
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

View file

@ -1,31 +1,31 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGKinemat.h
Author: Tony Peden, for flight control system authored by Jon S. Berndt
Date started: 12/02/01
Date started: 12/02/01
------------- Copyright (C) Anthony K. Peden -------------
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
--------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -68,7 +68,52 @@ namespace JSBSim {
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Encapsulates a kinematic component for the flight control system.
/** Encapsulates a kinematic (mechanical) component for the flight control system.
This component models the action of a moving effector, such as an aerosurface or
other mechanized entity such as a landing gear strut for the purpose of effecting
vehicle control or configuration. The form of the component specification is:
@code
<kinematic name="Gear Control">
<input> [-]property </input>
<traverse>
<setting>
<position> number </position>
<time> number </time>
</setting>
</traverse>
[<clipto>
<min> {[-]property name | value} </min>
<max> {[-]property name | value} </max>
</clipto>]
[<gain> {property name | value} </gain>]
[<output> {property} </output>]
</kinematic>
@endcode
The detent is the position that the component takes, and the lag is the time it
takes to get to that position from an adjacent setting. For example:
@code
<kinematic name="Gear Control">
<input>gear/gear-cmd-norm</input>
<traverse>
<setting>
<position>0</position>
<time>0</time>
</setting>
<setting>
<position>1</position>
<time>5</time>
</setting>
</traverse>
<output>gear/gear-pos-norm</output>
</kinematic>
@endcode
In this case, it takes 5 seconds to get to a 1 setting. As this is a software
mechanization of a servo-actuator, there should be an output specified.
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -77,31 +122,28 @@ CLASS DECLARATION
class FGKinemat : public FGFCSComponent {
public:
/** Initializer.
/** Constructor.
@param fcs A reference to the ccurrent flightcontrolsystem.
@param AC_cfg reference to the current aircraft configuration file.
Initializes the FGKinemat object from the given configuration
file. The Configuration file is expected to be at the stream
position where the KINEMAT object starts. Also it is expected to
be past the end of the current KINEMAT configuration on exit.
position where the kinematic object starts. Also it is expected to
be past the end of the current kinematic configuration on exit.
*/
FGKinemat(FGFCS* fcs, Element* element);
/** Destructor.
*/
/// Destructor.
~FGKinemat();
/** Kinemat output value.
@return the current output of the kinemat object on the range of [0,1].
*/
/** Kinematic component output value.
@return the current output of the kinematic object on the range of [0,1]. */
double GetOutputPct() const { return OutputPct; }
/** Run method, overwrites FGModel::Run().
/** Run method, overrides FGModel::Run().
@return false on success, true on failure.
The routine doing the work.
*/
The routine doing the work. */
bool Run (void);
private:
vector<double> Detents;
vector<double> TransitionTimes;

View file

@ -0,0 +1,155 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGPID.cpp
Author: Jon S. Berndt
Date started: 6/17/2006
------------- Copyright (C) 2006 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 code 6/17/2006 JSB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGPID.h"
namespace JSBSim {
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_PID;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
{
dt = fcs->GetState()->Getdt();
Kp = Ki = Kd = 0.0;
P_out = D_out = I_out = 0.0;
Input_prev = Input_prev2 = 0.0;
Trigger = 0;
if (element->FindElement("kp")) Kp = element->FindElementValueAsNumber("kp");
if (element->FindElement("ki")) Ki = element->FindElementValueAsNumber("ki");
if (element->FindElement("kd")) Kd = element->FindElementValueAsNumber("kd");
if (element->FindElement("trigger")) {
Trigger = PropertyManager->GetNode(element->FindElementValue("trigger"));
}
FGFCSComponent::bind();
Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGPID::~FGPID()
{
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGPID::Run(void )
{
Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
P_out = Kp * (Input - Input_prev);
I_out = Ki * dt * Input;
D_out = (Kd / dt) * (Input - 2*Input_prev + Input_prev2);
if (Trigger != 0) {
double test = Trigger->getDoubleValue();
if (fabs(test) > 0.000001) {
I_out = 0.0;
}
}
Input_prev = Input;
Input_prev2 = Input_prev;
Output += P_out + I_out + D_out;
Clip();
if (IsOutput) SetOutput();
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 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 FGPID::Debug(int from)
{
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
if (InputSigns[0] < 0)
cout << " INPUT: -" << InputNodes[0]->getName() << endl;
else
cout << " INPUT: " << InputNodes[0]->getName() << endl;
if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl;
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGPID" << endl;
if (from == 1) cout << "Destroyed: FGPID" << 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;
}
}
}
}

View file

@ -0,0 +1,98 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPID.h
Author: Jon Berndt
Date started: 6/17/2006
------------- Copyright (C) 2006 by 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 Code 6/17/2006 JSB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPID_H
#define FGPID_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifdef FGFS
# include <simgear/compiler.h>
# include STL_STRING
SG_USING_STD(string);
#else
# include <string>
#endif
#include "FGFCSComponent.h"
#include <input_output/FGXMLElement.h>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PID "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
namespace JSBSim {
class FGFCS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Encapsulates a PID control component for the flight control system.
@author Jon S. Berndt
@version $Revision$
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGPID : public FGFCSComponent
{
public:
FGPID(FGFCS* fcs, Element* element);
~FGPID();
bool Run (void);
private:
double dt;
FGPropertyManager *Trigger;
double Kp, Ki, Kd;
double P_out, D_out, I_out;
double Input_prev, Input_prev2;
void Debug(int from);
};
}
#endif

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2005 -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2005 -------------
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
@ -62,6 +62,7 @@ CLASS DOCUMENTATION
Syntax:
@code
<sensor name=name rate_group=name>
<input> property </input>
<lag> number </lag>
@ -74,9 +75,11 @@ Syntax:
<drift_rate> number </drift_rate>
<bias> number </bias>
</sensor>
@endcode
Example:
@code
<sensor name=aero/sensor/qbar rate_group=HFCS>
<input> aero/qbar </input>
<lag> 0.5 </lag>
@ -88,6 +91,7 @@ Example:
</quantization>
<bias> 0.5 </bias>
</sensor>
@endcode
The only required element in the sensor definition is the input element. In that
case, no degradation would be modeled, and the output would simply be the input.
@ -101,7 +105,7 @@ time.
@author Jon S. Berndt
@version $Revision$
*/
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) -------------
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

View file

@ -7,20 +7,20 @@
------------- Copyright (C) 2000 -------------
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
@ -33,24 +33,27 @@ HISTORY
COMMENTS, REFERENCES, and NOTES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The SWITCH component is defined as follows (see the API documentation for more
The switch component is defined as follows (see the API documentation for more
information):
<COMPONENT NAME="switch1" TYPE="SWITCH">
<TEST LOGIC="{AND|OR|DEFAULT}" OUTPUT="{property|value}">
@code
<switch name="switch1">
<default value="{property|value}"/>
<test logic="{AND|OR}" value="{property|value}">
{property} {conditional} {property|value}
<CONDITION_GROUP LOGIC="{AND|OR}">
<test logic="{AND|OR}">
{property} {conditional} {property|value}
...
</CONDITION_GROUP>
</test>
...
</TEST>
<TEST LOGIC="{AND|OR}" OUTPUT="{property|value}">
</test>
<test logic="{AND|OR}" value="{property|value}">
{property} {conditional} {property|value}
...
</TEST>
</test>
...
</COMPONENT>
</switch>
@endcode
Also, see the header file (FGSwitch.h) for further details.

View file

@ -4,23 +4,23 @@
Author: Jon S. Berndt
Date started: 12/23/2002
------------- Copyright (C) -------------
------------- Copyright (C) 2002 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
@ -39,7 +39,7 @@ INCLUDES
#include "FGFCSComponent.h"
#include <input_output/FGXMLElement.h>
#include "FGCondition.h"
#include <math/FGCondition.h>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
@ -59,60 +59,64 @@ CLASS DOCUMENTATION
/** Encapsulates a switch for the flight control system.
The SWITCH component models a switch - either on/off or a multi-choice rotary
The switch component models a switch - either on/off or a multi-choice rotary
switch. The switch can represent a physical cockpit switch, or can represent a
logical switch, where several conditions might need to be satisfied before a
particular state is reached. The VALUE of the switch - the output value for the
particular state is reached. The value of the switch - the output value for the
component - is chosen depending on the state of the switch. Each switch is
comprised of two or more TESTs. Each TEST has a VALUE associated with it. The
first TEST that evaluates to TRUE will set the output value of the switch
according to the VALUE parameter belonging to that TEST. Each TEST contains one
or more CONDITIONS, which each must be logically related (if there are more than
one) given the value of the LOGIC parameter, and which takes the form:
comprised of one or more tests. Each test has a value associated with it. The
first test that evaluates to true will set the output value of the switch
according to the value parameter belonging to that test. Each test contains one
or more conditions, which each must be logically related (if there are more than
one) given the value of the logic attribute, and which takes the form:
property conditional property|value
e.g.
qbar GE 21.0
qbar ge 21.0
or,
roll_rate < pitch_rate
roll_rate == pitch_rate
Within a TEST, a CONDITION_GROUP can be specified. A CONDITION_GROUP allows for
complex groupings of logical comparisons. Each CONDITION_GROUP contains
additional conditions, as well as possibly additional CONDITION_GROUPs.
Within a test, additional tests can be specified, which allows for
complex groupings of logical comparisons. Each test contains
additional conditions, as well as possibly additional tests.
<pre>
\<COMPONENT NAME="switch1" TYPE="SWITCH"\>
\<TEST LOGIC="{AND|OR|DEFAULT}" VALUE="{property|value}"\>
@code
<switch name="switch1">
<default value="{property|value}"/>
<test logic="{AND|OR}" value="{property|value}">
{property} {conditional} {property|value}
\<CONDITION_GROUP LOGIC="{AND|OR}"\>
<test logic="{AND|OR}">
{property} {conditional} {property|value}
...
\</CONDITION_GROUP\>
</test>
...
\</TEST>
\<TEST LOGIC="{AND|OR}" VALUE="{property|value}"\>
</test>
<test logic="{AND|OR}" value="{property|value}">
{property} {conditional} {property|value}
...
\</TEST\>
</test>
...
[OUTPUT \<property>]
\</COMPONENT\>
</pre>
[<output> {property} </output>]
</switch>
@endcode
Here's an example:
<pre>
\<COMPONENT NAME="Roll A/P Autoswitch" TYPE="SWITCH">
\<TEST LOGIC="DEFAULT" VALUE="0.0">
\</TEST>
\<TEST LOGIC="AND" VALUE="fcs/roll-ap-error-summer">
@code
<switch name="roll a/p autoswitch">
<default value="0.0"/>
<test value="fcs/roll-ap-error-summer">
ap/attitude_hold == 1
\</TEST>
\</COMPONENT>
</pre>
</test>
</switch>
@endcode
Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.
The above example specifies that the default value of the component (i.e. the
output property of the component, addressed by the property, ap/roll-ap-autoswitch)
is 0.0. If or when the attitude hold switch is selected (property
@ -129,16 +133,23 @@ CLASS DECLARATION
class FGSwitch : public FGFCSComponent
{
public:
/** Constructor
@param fcs a pointer to the parent FGFCS class
@param element a pointer to the Element (from the config file XML tree)
that represents this switch component */
FGSwitch(FGFCS* fcs, Element* element);
/// Destructor
~FGSwitch();
/** Executes the switch logic.
@return true - always*/
bool Run(void);
enum eLogic {elUndef=0, eAND, eOR, eDefault};
enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
private:
FGFCS* fcs;
struct test {
vector <FGCondition> conditions;

Some files were not shown because too many files have changed in this diff Show more