------------- 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
#include <models/FGOutput.h>
#include <initialization/FGInitialCondition.h>
#include <input_output/FGPropertyManager.h>
+#include <input_output/FGScript.h>
namespace JSBSim {
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
for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
SlaveFDMList.clear();
+ //ToDo remove property catalog.
+
Debug(1);
}
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;
bool FGFDMExec::Run(void)
{
+ bool success;
FGModel* model_iterator;
model_iterator = FirstModel;
// 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;
frame = Frame++;
if (!Holding()) State->IncrTime();
- return true;
+ return (success);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+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)
{
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;
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";
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+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
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");
void FGFDMExec::DisableOutput(void)
{
- for (int i=0; i<Outputs.size(); i++) {
+ for (unsigned i=0; i<Outputs.size(); i++) {
Outputs[i]->Disable();
}
}
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;
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";
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
namespace JSBSim {
+class FGScript;
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@code
FDMExec = new JSBSim::FGFDMExec();
- Script = new JSBSim::FGScript( \85 );
- 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
@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" */
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 <output> element) will be
+ added after this one. Care should be taken not to refer to the same file
+ name.
+ An output directives file contains an <output> </output> element, within
+ which should be specified the parameters or parameter groups that should
+ be logged.
+ @param fname the filename of an output directives file.
+ */
+ bool SetOutputDirectives(string fname);
+
+ /** Sets (or overrides) the output filename
+ @param fname the name of the file to output data to
+ @return true if successful, false if there is no output specified for the flight model */
+ bool SetOutputFileName(string fname) {
+ if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
+ else return false;
+ return true;
+ }
+
+ /** Retrieves the current output filename.
+ @return the name of the output file for the first output specified by the flight model.
+ If none is specified, the empty string is returned. */
+ string GetOutputFileName(void) {
+ if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
+ else return string("");
+ }
/** Executes trimming in the selected mode.
* @param mode Specifies how to trim:
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.
* 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);
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;
}
};
- 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
-
------------- 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
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;
------------- 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
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. */
------------- 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
------------- 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
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") /
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;
}
double trim_elev;
double trim_throttle;
- SGPropertyNode_ptr startup_trim;
- SGPropertyNode_ptr trimmed;
- SGPropertyNode_ptr pitch_trim;
- SGPropertyNode_ptr throttle_trim;
- SGPropertyNode_ptr aileron_trim;
- SGPropertyNode_ptr rudder_trim;
- SGPropertyNode_ptr stall_warning;
-
- /* SGPropertyNode_ptr elevator_pos_deg;
- SGPropertyNode_ptr left_aileron_pos_deg;
- SGPropertyNode_ptr right_aileron_pos_deg;
- SGPropertyNode_ptr rudder_pos_deg;
- SGPropertyNode_ptr flap_pos_deg; */
-
-
- SGPropertyNode_ptr elevator_pos_pct;
- SGPropertyNode_ptr left_aileron_pos_pct;
- SGPropertyNode_ptr right_aileron_pos_pct;
- SGPropertyNode_ptr rudder_pos_pct;
- SGPropertyNode_ptr flap_pos_pct;
- SGPropertyNode_ptr speedbrake_pos_pct;
- SGPropertyNode_ptr spoilers_pos_pct;
-
- SGPropertyNode_ptr gear_pos_pct;
-
- SGPropertyNode_ptr temperature;
- SGPropertyNode_ptr pressure;
- SGPropertyNode_ptr density;
- SGPropertyNode_ptr turbulence_gain;
- SGPropertyNode_ptr turbulence_rate;
-
- SGPropertyNode_ptr wind_from_north;
- SGPropertyNode_ptr wind_from_east;
- SGPropertyNode_ptr wind_from_down;
+ SGPropertyNode *startup_trim;
+ SGPropertyNode *trimmed;
+ SGPropertyNode *pitch_trim;
+ SGPropertyNode *throttle_trim;
+ SGPropertyNode *aileron_trim;
+ SGPropertyNode *rudder_trim;
+ SGPropertyNode *stall_warning;
+
+ /* SGPropertyNode *elevator_pos_deg;
+ SGPropertyNode *left_aileron_pos_deg;
+ SGPropertyNode *right_aileron_pos_deg;
+ SGPropertyNode *rudder_pos_deg;
+ SGPropertyNode *flap_pos_deg; */
+
+
+ SGPropertyNode *elevator_pos_pct;
+ SGPropertyNode *left_aileron_pos_pct;
+ SGPropertyNode *right_aileron_pos_pct;
+ SGPropertyNode *rudder_pos_pct;
+ SGPropertyNode *flap_pos_pct;
+ SGPropertyNode *speedbrake_pos_pct;
+ SGPropertyNode *spoilers_pos_pct;
+
+ SGPropertyNode *gear_pos_pct;
+
+ SGPropertyNode *temperature;
+ SGPropertyNode *pressure;
+ SGPropertyNode *density;
+ SGPropertyNode *turbulence_gain;
+ SGPropertyNode *turbulence_rate;
+
+ SGPropertyNode *wind_from_north;
+ SGPropertyNode *wind_from_east;
+ SGPropertyNode *wind_from_down;
+
+ SGPropertyNode *slaved;
void init_gear(void);
void update_gear(void);
------------- 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.
bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
{
- string resetDef, acpath;
+ string resetDef;
ifstream initialization_file;
FGXMLParse initialization_file_parser;
Element *document, *el;
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;
}
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"))
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")) {
------------- 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
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
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.
--------- 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.
------------- 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.
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
}
fgt.Report();
@endcode
+
@author Tony Peden
@version "$Id$"
*/
--------- 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.
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:
------------- 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
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; }
------ 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
------ 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
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/// 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
------------- 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
#endif
#include "FGScript.h"
-#include "FGXMLParse.h"
+#include <input_output/FGXMLParse.h>
#include <initialization/FGTrim.h>
namespace JSBSim {
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);
}
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;
return false;
}
+ ScriptName = document->GetAttributeValue("name");
+
+ // First, find "run" element and set delta T
+
+ run_element = document->FindElement("run");
+
+ if (!run_element) {
+ cerr << "No \"run\" element found in script." << endl;
+ return false;
+ }
+
+ // Set sim timing
+
+ StartTime = run_element->GetAttributeValueAsNumber("start");
+ State->Setsim_time(StartTime);
+ EndTime = run_element->GetAttributeValueAsNumber("end");
+ dt = run_element->GetAttributeValueAsNumber("dt");
+ State->Setdt(dt);
+
// read aircraft and initialization files
element = document->FindElement("use");
result = FDMExec->LoadModel(aircraft);
if (!result) return false;
} else {
- cerr << "Aircraft must be specified first in script file." << endl;
+ cerr << "Aircraft must be specified in use element." << endl;
return false;
}
- element = document->FindNextElement("use");
initialize = element->GetAttributeValue("initialize");
+ if (initialize.empty()) {
+ cerr << "Initialization file must be specified in use element." << endl;
+ return false;
+ }
} else {
cerr << "No \"use\" directives in the script file." << endl;
return false;
}
- run_element = document->FindElement("run");
-
- if (!run_element) {
- cerr << "No \"run\" element found in script." << endl;
- return false;
+ // Read local property declarations
+ property_element = run_element->FindElement("property");
+ while (property_element) {
+ LocalProps *localProp = new LocalProps();
+ localProp->title = property_element->GetDataLine();
+ local_properties.push_back(localProp);
+ PropertyManager->Tie(localProp->title, (local_properties.back())->value);
+ property_element = run_element->FindNextElement("property");
}
- // Set sim timing
+ // Read "events" from script
- StartTime = run_element->GetAttributeValueAsNumber("start");
- State->Setsim_time(StartTime);
- EndTime = run_element->GetAttributeValueAsNumber("end");
- dt = run_element->GetAttributeValueAsNumber("dt");
- State->Setdt(dt);
+ event_element = run_element->FindElement("event");
+ while (event_element) { // event processing
+
+ // Create the event structure
+ newEvent = new struct event();
+
+ // Retrieve the event name if given
+ newEvent->Name = event_element->GetAttributeValue("name");
- // read "when" tests from script
-
- when_element = run_element->FindElement("when");
- while (when_element) { // "when" processing
- newCondition = new struct condition();
-
- // read parameters
- parameter_element = when_element->FindElement("parameter");
- while (parameter_element) {
- prop_name = parameter_element->GetAttributeValue("name");
- newCondition->TestParam.push_back( PropertyManager->GetNode(prop_name) );
- value = parameter_element->GetAttributeValueAsNumber("value");
- newCondition->TestValue.push_back(value);
- comparison = parameter_element->GetAttributeValue("comparison");
- newCondition->Comparison.push_back(comparison);
- parameter_element = when_element->FindNextElement("parameter");
+ // Is this event persistent? That is, does it execute repeatedly as long as the
+ // condition is true, or does it execute as a one-shot event, only?
+ if (event_element->GetAttributeValue("persistent") == string("true")) {
+ newEvent->Persistent = true;
}
- // read set definitions
- set_element = when_element->FindElement("set");
+ // Process the conditions
+ condition_element = event_element->FindElement("condition");
+ if (condition_element != 0) {
+ newCondition = new FGCondition(condition_element, PropertyManager);
+ newEvent->Condition = newCondition;
+ } else {
+ cerr << "No condition specified in script event " << newEvent->Name << endl;
+ return false;
+ }
+
+ // Is there a delay between the time this event is triggered, and when the event
+ // actions are executed?
+
+ delay_element = event_element->FindElement("delay");
+ if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay");
+ else newEvent->Delay = 0.0;
+
+ // Notify about when this event is triggered?
+ if ((notify_element = event_element->FindElement("notify")) != 0) {
+ newEvent->Notify = true;
+ notify_property_element = notify_element->FindElement("property");
+ while (notify_property_element) {
+ notifyPropertyName = notify_property_element->GetDataLine();
+ newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) );
+ notify_property_element = notify_element->FindNextElement("property");
+ }
+ }
+
+ // Read set definitions (these define the actions to be taken when the event is triggered).
+ set_element = event_element->FindElement("set");
while (set_element) {
prop_name = set_element->GetAttributeValue("name");
- newCondition->SetParam.push_back( PropertyManager->GetNode(prop_name) );
+ newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
value = set_element->GetAttributeValueAsNumber("value");
- newCondition->SetValue.push_back(value);
- newCondition->Triggered.push_back(false);
- newCondition->OriginalValue.push_back(0.0);
- newCondition->newValue.push_back(0.0);
- newCondition->StartTime.push_back(0.0);
- newCondition->EndTime.push_back(0.0);
+ newEvent->SetValue.push_back(value);
+ newEvent->OriginalValue.push_back(0.0);
+ newEvent->newValue.push_back(0.0);
+ newEvent->ValueSpan.push_back(0.0);
string tempCompare = set_element->GetAttributeValue("type");
- if (tempCompare == "FG_DELTA") newCondition->Type.push_back(FG_DELTA);
- else if (tempCompare == "FG_BOOL") newCondition->Type.push_back(FG_BOOL);
- else if (tempCompare == "FG_VALUE") newCondition->Type.push_back(FG_VALUE);
- else newCondition->Type.push_back(FG_VALUE); // DEFAULT
+ if (tempCompare == "FG_DELTA") newEvent->Type.push_back(FG_DELTA);
+ else if (tempCompare == "FG_BOOL") newEvent->Type.push_back(FG_BOOL);
+ else if (tempCompare == "FG_VALUE") newEvent->Type.push_back(FG_VALUE);
+ else newEvent->Type.push_back(FG_VALUE); // DEFAULT
tempCompare = set_element->GetAttributeValue("action");
- if (tempCompare == "FG_RAMP") newCondition->Action.push_back(FG_RAMP);
- else if (tempCompare == "FG_STEP") newCondition->Action.push_back(FG_STEP);
- else if (tempCompare == "FG_EXP") newCondition->Action.push_back(FG_EXP);
- else newCondition->Action.push_back(FG_STEP); // DEFAULT
-
- if (set_element->GetAttributeValue("persistent") == "true")
- newCondition->Persistent.push_back(true);
- else
- newCondition->Persistent.push_back(false); // DEFAULT
+ if (tempCompare == "FG_RAMP") newEvent->Action.push_back(FG_RAMP);
+ else if (tempCompare == "FG_STEP") newEvent->Action.push_back(FG_STEP);
+ else if (tempCompare == "FG_EXP") newEvent->Action.push_back(FG_EXP);
+ else newEvent->Action.push_back(FG_STEP); // DEFAULT
if (!set_element->GetAttributeValue("tc").empty())
- newCondition->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
+ newEvent->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
else
- newCondition->TC.push_back(1.0); // DEFAULT
+ newEvent->TC.push_back(1.0); // DEFAULT
- set_element = when_element->FindNextElement("set");
+ newEvent->Transiting.push_back(false);
+
+ set_element = event_element->FindNextElement("set");
}
- Conditions.push_back(*newCondition);
- when_element = run_element->FindNextElement("when");
+ Events.push_back(*newEvent);
+ event_element = run_element->FindNextElement("event");
}
Debug(4);
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;
-
- 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;
-
- if (i == 0) WholeTruth = truth;
- else WholeTruth = WholeTruth && truth;
-
- if (!truth && iC->Persistent[i] && iC->Triggered[i]) iC->Triggered[i] = false;
- }
+ if (currentTime > EndTime) return false; //Script done!
- // if the conditions are true, do the setting of the desired parameters
+ // Iterate over all events.
+ while (iEvent < Events.end()) {
+ iEvent->PrevTriggered = iEvent->Triggered;
+ // Determine whether the set of conditional tests for this condition equate
+ // to true and should cause the event to execute.
+ if (iEvent->Condition->Evaluate()) {
+ if (!iEvent->Triggered) {
- if (WholeTruth) {
- for (i=0; 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];
-
- switch (iC->Action[i]) {
- case FG_RAMP:
- if (time_span <= iC->TC[i])
- newSetValue = time_span/iC->TC[i] * value_span + iC->OriginalValue[i];
- else
- newSetValue = iC->newValue[i];
- break;
- case FG_STEP:
- newSetValue = iC->newValue[i];
- break;
- case FG_EXP:
- newSetValue = (1 - exp( -time_span/iC->TC[i] )) * value_span + iC->OriginalValue[i];
- break;
- default:
- cerr << "Invalid Action specified" << endl;
- break;
+ if ((currentTime >= iEvent->StartTime) && iEvent->Triggered) {
+
+ if (iEvent->Notify && iEvent->PrevTriggered != iEvent->Triggered) {
+ cout << endl << " Event " << event_ctr << " (" << iEvent->Name << ")"
+ << " executed at time: " << currentTime << endl;
+ for (j=0; 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;
}
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
------------- 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
#include "FGJSBBase.h"
#include "FGState.h"
#include "FGFDMExec.h"
+#include <math/FGCondition.h>
#include <vector>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** 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>
-
- <pre><strong><?xml version="1.0"?>
- <runscript name="C172-01A">
-
- <!--
- This run is for testing C172 runs
- -->
-
- <use aircraft="c172">
- <use initialize="reset00">
-
- <run start="0.0" end="4.5" dt="0.05">
- <when>
- <parameter name="FG_TIME" comparison="ge" value="0.25">
- <parameter name="FG_TIME" comparison="le" value="0.50">
- <set name="FG_AILERON_CMD" type="FG_VALUE" value="0.25"
- action="FG_STEP" persistent="false" tc ="0.25">
- </when>
- <when>
- <parameter name="FG_TIME" comparison="ge" value="0.5">
- <parameter name="FG_TIME" comparison="le" value="1.5">
- <set name="FG_AILERON_CMD" type="FG_DELTA" value="0.5"
- action="FG_EXP" persistent="false" tc ="0.5">
- </when>
- <when>
- <parameter name="FG_TIME" comparison="ge" value="1.5">
- <parameter name="FG_TIME" comparison="le" value="2.5">
- <set name="FG_RUDDER_CMD" type="FG_DELTA" value="0.5"
- action="FG_RAMP" persistent="false" tc ="0.5">
- </when>
- </run>
-
- </runscript></strong></pre>
-
- <p>The first line must always be present. The second line
+ approach is specified via the time constant. Here is an example
+ illustrating the format of the script file:
+
+ @code
+<?xml version="1.0"?>
+<runscript name="C172-01A takeoff run">
+ <!--
+ This run is for testing the C172 altitude hold autopilot
+ -->
+
+ <use aircraft="c172x"/>
+ <use initialize="reset00"/>
+ <run start="0.0" end="3000" dt="0.0083333">
+
+ <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>
+
+ <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>
+
+ <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>
+
+ <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
<!-- and --> symbols. The aircraft and initialization files
to be used are specified in the "use" lines. Next,
comes the "run" section, where the conditions are
- described in "when" clauses.</p>
+ described in "event" clauses.</p>
@author Jon S. Berndt
@version "$Id$"
-
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~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);
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;
-
- condition() {
+ vector <double> ValueSpan;
+ vector <bool> Transiting;
+
+ event() {
+ Triggered = false;
+ PrevTriggered = false;
+ Persistent = false;
+ Delay = 0.0;
+ Notify = false;
+ Name = "";
+ StartTime = 0.0;
+ TimeSpan = 0.0;
}
};
- bool Scripted;
+ struct LocalProps {
+ double *value;
+ string title;
+ LocalProps() {
+ value = new double(0.0);
+ title = "";
+ }
+ };
string ScriptName;
double StartTime;
double EndTime;
- vector <struct condition> Conditions;
+ vector <struct event> Events;
+ vector <LocalProps*> local_properties;
FGFDMExec* FDMExec;
FGState* State;
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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;
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();
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("");
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-Element* Element::GetElement(int el)
+Element* Element::GetElement(unsigned int el)
{
if (children.size() > el) {
element_index = el;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string Element::GetDataLine(int i)
+string Element::GetDataLine(unsigned int i)
{
if (data_lines.size() > 0) return data_lines[i];
else return string("");
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++;
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];
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];
if (element) {
return element->GetDataAsNumber();
} else {
- return 99e99;
+ cerr << "Attempting to get single data value from multiple lines" << endl;
+ return 0;
}
}
}
}
} else {
- return 99e99;
+ cerr << "Attempting to get get non-existent element " << el << endl;
+ return 0;
}
return value;
}
}
}
} else {
- return 99e99;
+ cerr << "Attempting to get get non-existent element " << el << endl;
+ return 0;
}
return value;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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
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);
}
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@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
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
/** 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;
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;
};
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGXMLParse::~FGXMLParse(void)
{
- if (document) delete document;
+ delete document;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::reset(void)
{
- if (document) delete document;
+ delete document;
first_element_read = false;
current_element = document = 0L;
}
------------- 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------- 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
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);
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);
}
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);
------------- 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
#include <sys/ioctl.h>
#endif
+#ifdef _MSC_VER
+
+#pragma comment (lib,"WSock32.lib")
+
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/** Encapsulates a socket object.
+/** Encapsulates an object that enables JSBSim to communicate via socket (input
+ and/or output).
+
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
--------------------------------------------------------------------------------
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.
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGCondition.cpp
+ Author: Jon S. Berndt
+ Date started: 1/2/2003
+
+ -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.org) --------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGCondition.h"
+
+namespace JSBSim {
+
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_CONDITION;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+string FGCondition::indent = " ";
+
+// This constructor is called when tests are inside an element
+FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
+ PropertyManager(PropertyManager), isGroup(true)
+{
+ string property1, property2, logic;
+ Element* condition_element;
+
+ InitializeConditionals();
+
+ TestParam1 = TestParam2 = 0L;
+ TestValue = 0.0;
+ Comparison = ecUndef;
+ Logic = elUndef;
+ conditions.clear();
+
+ logic = element->GetAttributeValue("logic");
+ if (!logic.empty()) {
+ if (logic == "OR") Logic = eOR;
+ else if (logic == "AND") Logic = eAND;
+ else { // error
+ cerr << "Unrecognized LOGIC token " << logic << endl;
+ }
+ } else {
+ Logic = eAND; // default
+ }
+
+ condition_element = element->GetElement();
+ while (condition_element) {
+ conditions.push_back(FGCondition(condition_element, PropertyManager));
+ condition_element = element->GetNextElement();
+ }
+ for (unsigned int i=0; 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;
+
+ InitializeConditionals();
+
+ TestParam1 = TestParam2 = 0L;
+ TestValue = 0.0;
+ Comparison = ecUndef;
+ Logic = elUndef;
+ conditions.clear();
+
+ unsigned int start = 0, end = 0;
+ start = test.find_first_not_of(" ");
+ end = test.find_first_of(" ", start+1);
+ property1 = test.substr(start,end-start);
+ start = test.find_first_not_of(" ",end);
+ end = test.find_first_of(" ",start+1);
+ conditional = test.substr(start,end-start);
+ start = test.find_first_not_of(" ",end);
+ end = test.find_first_of(" ",start+1);
+ property2 = test.substr(start,end-start);
+
+ TestParam1 = PropertyManager->GetNode(property1, true);
+ Comparison = mComparison[conditional];
+ if (property2.find_first_not_of("-.0123456789eE") == string::npos) {
+ TestValue = atof(property2.c_str());
+ } else {
+ TestParam2 = PropertyManager->GetNode(property2, true);
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::InitializeConditionals(void)
+{
+ mComparison["EQ"] = eEQ;
+ mComparison["NE"] = eNE;
+ mComparison["GT"] = eGT;
+ mComparison["GE"] = eGE;
+ mComparison["LT"] = eLT;
+ mComparison["LE"] = eLE;
+ mComparison["eq"] = eEQ;
+ mComparison["ne"] = eNE;
+ mComparison["gt"] = eGT;
+ mComparison["ge"] = eGE;
+ mComparison["lt"] = eLT;
+ mComparison["le"] = eLE;
+ mComparison["=="] = eEQ;
+ mComparison["!="] = eNE;
+ mComparison[">"] = eGT;
+ mComparison[">="] = eGE;
+ mComparison["<"] = eLT;
+ mComparison["<="] = eLE;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGCondition::~FGCondition(void)
+{
+ Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGCondition::Evaluate(void )
+{
+ vector <FGCondition>::iterator iConditions;
+ bool pass = false;
+ double compareValue;
+
+ if (TestParam1 == 0L) {
+
+ if (Logic == eAND) {
+
+ iConditions = conditions.begin();
+ pass = true;
+ while (iConditions < conditions.end()) {
+ if (!iConditions->Evaluate()) pass = false;
+ *iConditions++;
+ }
+
+ } else { // Logic must be eOR
+
+ pass = false;
+ while (iConditions < conditions.end()) {
+ if (iConditions->Evaluate()) pass = true;
+ *iConditions++;
+ }
+
+ }
+
+ } else {
+
+ if (TestParam2 != 0L) compareValue = TestParam2->getDoubleValue();
+ else compareValue = TestValue;
+
+ switch (Comparison) {
+ case ecUndef:
+ cerr << "Undefined comparison operator." << endl;
+ break;
+ case eEQ:
+ pass = TestParam1->getDoubleValue() == compareValue;
+ break;
+ case eNE:
+ pass = TestParam1->getDoubleValue() != compareValue;
+ break;
+ case eGT:
+ pass = TestParam1->getDoubleValue() > compareValue;
+ break;
+ case eGE:
+ pass = TestParam1->getDoubleValue() >= compareValue;
+ break;
+ case eLT:
+ pass = TestParam1->getDoubleValue() < compareValue;
+ break;
+ case eLE:
+ pass = TestParam1->getDoubleValue() <= compareValue;
+ break;
+ default:
+ cerr << "Unknown comparison operator." << endl;
+ }
+ }
+
+ return pass;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::PrintCondition(void )
+{
+ vector <FGCondition>::iterator iConditions;
+ string scratch;
+
+ if (isGroup) {
+ switch(Logic) {
+ case (elUndef):
+ scratch = " UNSET";
+ cerr << "unset logic for test condition" << endl;
+ break;
+ case (eAND):
+ scratch = " if all of the following are true:";
+ break;
+ case (eOR):
+ scratch = " if any of the following are true:";
+ break;
+ default:
+ scratch = " UNKNOWN";
+ cerr << "Unknown logic for test condition" << endl;
+ }
+
+ iConditions = conditions.begin();
+ cout << scratch << endl;
+ while (iConditions < conditions.end()) {
+ iConditions->PrintCondition();
+ *iConditions++;
+ }
+ } else {
+ if (TestParam2 != 0L)
+ cout << " " << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
+ else
+ cout << " " << TestParam1->GetName() << " " << conditional << " " << TestValue;
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGCondition::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGCondition" << endl;
+ if (from == 1) cout << "Destroyed: FGCondition" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+
+} //namespace JSBSim
+
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGCondition.h
+ Author: Jon S. Berndt
+ Date started: 1/02/2003
+
+ ------------- Copyright (C) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGCONDITION_H
+#define FGCONDITION_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <map>
+#include <FGJSBBase.h>
+#include <input_output/FGXMLElement.h>
+#include <input_output/FGPropertyManager.h>
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_CONDITION "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Encapsulates a condition, which is used in parts of JSBSim including switches
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGCondition : public FGJSBBase
+{
+public:
+ FGCondition(Element* element, FGPropertyManager* PropertyManager);
+ FGCondition(string test, FGPropertyManager* PropertyManager);
+ ~FGCondition(void);
+
+ bool Evaluate(void);
+ void PrintCondition(void);
+
+private:
+ enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
+ enum eLogic {elUndef=0, eAND, eOR};
+ map <string, eComparison> mComparison;
+ eLogic Logic;
+
+ FGPropertyManager *TestParam1, *TestParam2, *PropertyManager;
+ double TestValue;
+ eComparison Comparison;
+ bool isGroup;
+ string conditional;
+
+ static string indent;
+
+ vector <FGCondition> conditions;
+ void InitializeConditionals(void);
+
+ void Debug(int from);
+};
+}
+#endif
+
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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")) {
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")) {
operation == string("sum") ||
operation == string("quotient") ||
operation == string("pow") ||
+ operation == string("exp") ||
operation == string("abs") ||
operation == string("sin") ||
operation == string("cos") ||
element = el->GetNextElement();
}
+ bind(); // Allow any function to save its value
+
Debug(0);
}
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];
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case ePow:
temp = pow(temp,Parameters[1]->GetValue());
break;
+ case eExp:
+ temp = exp(temp);
+ break;
case eAbs:
temp = fabs(temp);
break;
}
}
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
}
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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
{
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;
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);
------- (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
------- (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
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
--------------------------------------------------------------------------------
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
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGParameter : public FGJSBBase
{
public:
-
+ virtual ~FGParameter(void) {};
virtual double GetValue(void) const = 0;
protected:
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
------- (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
------- (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
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
------------- 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
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();
// 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();
cout << "No dimension given" << endl;
break;
}
+
+ bind();
+
if (debug_lvl & 1) Print();
}
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);
}
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
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** 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.
-
- 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} {... ... ... ... }
-
- {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} {... ... ... ... }
-
- ...
-
- \</COEFFICIENT>
-</pre>
- [At the present time, all rows and columns for each table must have the
- same dimension.]
-
- 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:
-
- combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
-
- @author Jon S. Berndt
- @version $Id$
- @see FGCoefficient
- @see FGPropeller
+Models a one, two, or three dimensional lookup table for use in aerodynamics
+and function definitions.
+
+For a single "vector" lookup table, the format is as follows:
+
+@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.
+
+A "real life" example is as shown here:
+
+@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
+
+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.
+
+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$
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
double** Allocate(void);
FGPropertyManager* const PropertyManager;
+ string Name;
+ void bind(void);
void Debug(int from);
};
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
------------- 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
clsq = lod = 0.0;
alphaw = 0.0;
bi2vel = ci2vel = 0.0;
+ AeroRPShift = 0;
+ vDeltaRP.InitMatrix();
+
bind();
Debug(0);
{
unsigned int i,j;
- unbind();
-
for (i=0; i<6; i++)
for (j=0; j<Coeff[i].size(); j++)
delete Coeff[i][j];
for (i=0; i<variables.size(); i++)
delete variables[i];
+ if (AeroRPShift) delete AeroRPShift;
+
+ unbind();
+
Debug(1);
}
}
}
+ // 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());
// 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
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) );
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();
}
}
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();
}
}
------------- 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
/** 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>
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; }
private:
typedef map<string,int> AxisIndex;
AxisIndex AxisIdx;
+ FGFunction* AeroRPShift;
vector <FGFunction*> variables;
typedef vector <FGFunction*> CoeffArray;
CoeffArray* Coeff;
FGColumnVector3 vMoments;
FGColumnVector3 vLastFs;
FGColumnVector3 vDXYZcg;
+ FGColumnVector3 vDeltaRP;
double alphaclmax, alphaclmin;
double alphahystmax, alphahystmin;
double impending_stall, stall_hyst;
------------- 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
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;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Constructor
@param Executive a pointer to the parent executive object */
FGAircraft(FGFDMExec *Executive);
-
+
/// Destructor
~FGAircraft();
@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
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; }
------------- 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
------------- 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
------------- 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
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();
// 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
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
{
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);
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");
------------- 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
------------- 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
#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>
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;
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;
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");
}
{
unsigned int comp;
string CompValues = "";
- char buffer[12];
+ char buffer[17];
bool firstime = true;
for (comp = 0; comp < FCSComponents.size(); comp++) {
CompValues += string(buffer);
}
+ CompValues += "\0";
return CompValues;
}
PropFeatherCmd.push_back(false);
PropFeather.push_back(false);
- unsigned int num = ThrottleCmd.size()-1;
+ unsigned int num = (unsigned int)ThrottleCmd.size()-1;
bindThrottle(num);
}
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);
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);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------- 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
@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.
------------- 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
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();
}
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
------------- 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
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
vector <FGLGear> lGear;
FGColumnVector3 vForces;
FGColumnVector3 vMoments;
- FGColumnVector3 vMaxStaticGrip;
- FGColumnVector3 vMaxMomentResist;
void Debug(int from);
};
------------- 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
------------- 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
------------- 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
FGInput::~FGInput()
{
- if (socket) delete socket;
-
+ delete socket;
Debug(1);
}
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
------------- 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
------------- 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
<< 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;
brakePct = 0.0;
maxCompLen = 0.0;
- WheelSlip = last_WheelSlip = 0.0;
- slipIn = last_SlipIn = 0;
+ WheelSlip = 0.0;
TirePressureNorm = 1.0;
Debug(0);
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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3 normal, cvel;
FGLocation contact, gearLoc;
double t = Exec->GetState()->Getsim_time();
+ dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
vForce.InitMatrix();
vMoment.InitMatrix();
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 ca, cb, denom;
+ FGColumnVector3 Output;
+
+// 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 (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);
+ }
- double RFRV = 0.015; // Rolling force relaxation velocity
- double SFRV = 0.25; // Side force relaxation velocity
- double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
+ prevIn = vForce;
+ prevOut = 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;
+ if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
+ if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
- if (fabs(RollingWhlVel) <= RFRV) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
- if (fabs(SideWhlVel) <= SFRV) vForce(eY) *= fabs(SideWhlVel)/SFRV;
+// End experimental section for attentuating gear jitter
vMoment = vWhlBodyVec * vForce;
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;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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();
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;
}
}
}
------------- 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
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;
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;
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;
------------- 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
// Calculate new CG
-// printf("%s:%i\n", __FILE__, __LINE__);
vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg
+ GetPointMassMoment() ) / Weight;
{
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));
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------- 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
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;
------------- 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
{
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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------- 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
------------- 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
enabled = true;
delimeter = ", ";
Filename = "";
+ DirectivesFile = "";
Debug(0);
}
FGOutput::~FGOutput()
{
- if (socket) delete socket;
+ delete socket;
OutputProperties.clear();
-
Debug(1);
}
}
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);
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;
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;
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);
}
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;
------------- 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
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 {
} 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);
};
}
------------- 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
FGPropagate::FGPropagate(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGPropagate";
+// vQtrndot.zero();
bind();
Debug(0);
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;
}
------------- 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
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);
------------- 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
Tanks[i]->Calculate( dt * rate );
if (Tanks[i]->GetType() == FGTank::ttFUEL) {
TotalFuelQuantity += Tanks[i]->GetContents();
- }
+ }
}
if (refuel) DoRefuel( dt * rate );
{
string fullpath, localpath;
string enginePath = FDMExec->GetEnginePath();
- string aircraftPath = FDMExec->GetAircraftPath();
+ string aircraftPath = FDMExec->GetFullAircraftPath();
ifstream* engine_file = new ifstream();
string separator = "/";
{
string fullpath, localpath;
string enginePath = FDMExec->GetEnginePath();
- string aircraftPath = FDMExec->GetAircraftPath();
+ string aircraftPath = FDMExec->GetFullAircraftPath();
ifstream* engine_file = new ifstream();
string separator = "/";
void FGPropulsion::unbind(void)
{
+ if (!IsBound) return;
+
if (HaveTurbineEngine) {
PropertyManager->Untie("propulsion/starter_cmd");
PropertyManager->Untie("propulsion/cutoff_cmd");
------------- 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
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
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
------------- 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
------------- 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
------------- 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
------------- 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
+++ /dev/null
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Module: FGCondition.cpp
- Author: Jon S. Berndt
- Date started: 1/2/2003
-
- -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.org) --------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU 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
- details.
-
- You should have received a copy of the GNU 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
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES, and NOTES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include "FGCondition.h"
-
-namespace JSBSim {
-
-static const char *IdSrc = "$Id$";
-static const char *IdHdr = ID_CONDITION;
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS IMPLEMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-string FGCondition::indent = " ";
-
-
-FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
- PropertyManager(PropertyManager), isGroup(true)
-{
- string property1, property2, logic;
- Element* condition_element;
-
- InitializeConditionals();
-
- TestParam1 = TestParam2 = 0L;
- TestValue = 0.0;
- Comparison = ecUndef;
- Logic = elUndef;
- conditions.clear();
-
- logic = element->GetAttributeValue("logic");
- if (logic == "OR") Logic = eOR;
- else if (logic == "AND") Logic = eAND;
- else { // error
- cerr << "Unrecognized LOGIC token " << logic << " in switch component: " << logic << endl;
- }
- 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));
- }
-
- Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) :
- PropertyManager(PropertyManager), isGroup(false)
-{
- string property1, property2, compare_string;
- Element* condition_element;
-
- InitializeConditionals();
-
- TestParam1 = TestParam2 = 0L;
- TestValue = 0.0;
- Comparison = ecUndef;
- Logic = elUndef;
- conditions.clear();
-
- int start = 0, end = 0;
- start = test.find_first_not_of(" ");
- end = test.find_first_of(" ", start+1);
- property1 = test.substr(start,end-start);
- start = test.find_first_not_of(" ",end);
- end = test.find_first_of(" ",start+1);
- conditional = test.substr(start,end-start);
- start = test.find_first_not_of(" ",end);
- end = test.find_first_of(" ",start+1);
- property2 = test.substr(start,end-start);
-
- TestParam1 = PropertyManager->GetNode(property1, true);
- Comparison = mComparison[conditional];
- if (property2.find_first_not_of("-.0123456789eE") == string::npos) {
- TestValue = atof(property2.c_str());
- } else {
- TestParam2 = PropertyManager->GetNode(property2, true);
- }
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGCondition::InitializeConditionals(void)
-{
- mComparison["EQ"] = eEQ;
- mComparison["NE"] = eNE;
- mComparison["GT"] = eGT;
- mComparison["GE"] = eGE;
- mComparison["LT"] = eLT;
- mComparison["LE"] = eLE;
- mComparison["eq"] = eEQ;
- mComparison["ne"] = eNE;
- mComparison["gt"] = eGT;
- mComparison["ge"] = eGE;
- mComparison["lt"] = eLT;
- mComparison["le"] = eLE;
- mComparison["=="] = eEQ;
- mComparison["!="] = eNE;
- mComparison[">"] = eGT;
- mComparison[">="] = eGE;
- mComparison["<"] = eLT;
- mComparison["<="] = eLE;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGCondition::~FGCondition(void)
-{
- Debug(1);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-bool FGCondition::Evaluate(void )
-{
- vector <FGCondition>::iterator iConditions;
- bool pass = false;
- double compareValue;
-
- if (Logic == eAND) {
-
- iConditions = conditions.begin();
- pass = true;
- while (iConditions < conditions.end()) {
- if (!iConditions->Evaluate()) pass = false;
- *iConditions++;
- }
-
- } else if (Logic == eOR) {
-
- pass = false;
- while (iConditions < conditions.end()) {
- if (iConditions->Evaluate()) pass = true;
- *iConditions++;
- }
-
- } else {
-
- if (TestParam2 != 0L) compareValue = TestParam2->getDoubleValue();
- else compareValue = TestValue;
-
- switch (Comparison) {
- case ecUndef:
- cerr << "Undefined comparison operator." << endl;
- break;
- case eEQ:
- pass = TestParam1->getDoubleValue() == compareValue;
- break;
- case eNE:
- pass = TestParam1->getDoubleValue() != compareValue;
- break;
- case eGT:
- pass = TestParam1->getDoubleValue() > compareValue;
- break;
- case eGE:
- pass = TestParam1->getDoubleValue() >= compareValue;
- break;
- case eLT:
- pass = TestParam1->getDoubleValue() < compareValue;
- break;
- case eLE:
- pass = TestParam1->getDoubleValue() <= compareValue;
- break;
- default:
- cerr << "Unknown comparison operator." << endl;
- }
- }
-
- return pass;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGCondition::PrintCondition(void )
-{
- vector <FGCondition>::iterator iConditions;
- string scratch;
-
- if (isGroup) {
- switch(Logic) {
- case (elUndef):
- scratch = " UNSET";
- cerr << "unset logic for test condition" << endl;
- break;
- case (eAND):
- scratch = " if all of the following are true";
- break;
- case (eOR):
- scratch = " if any of the following are true:";
- break;
- default:
- scratch = " UNKNOWN";
- cerr << "Unknown logic for test condition" << endl;
- }
-
- iConditions = conditions.begin();
- cout << scratch << endl;
- while (iConditions < conditions.end()) {
- iConditions->PrintCondition();
- *iConditions++;
- }
- } else {
- if (TestParam2 != 0L)
- cout << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
- else
- cout << TestParam1->GetName() << " " << conditional << " " << TestValue;
- }
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The bitmasked value choices are as follows:
-// unset: In this case (the default) JSBSim would only print
-// out the normally expected messages, essentially echoing
-// the config files as they are read. If the environment
-// variable is not set, debug_lvl is set to 1 internally
-// 0: This requests JSBSim not to output any messages
-// whatsoever.
-// 1: This value explicity requests the normal JSBSim
-// startup messages
-// 2: This value asks for a message to be printed out when
-// a class is instantiated
-// 4: When this value is set, a message is displayed when a
-// FGModel object executes its Run() method
-// 8: When this value is set, various runtime state variables
-// are printed out periodically
-// 16: When set various parameters are sanity checked and
-// a message is printed out when they go out of bounds
-
-void FGCondition::Debug(int from)
-{
- if (debug_lvl <= 0) return;
-
- if (debug_lvl & 1) { // Standard console startup message output
- if (from == 0) { // Constructor
-
- }
- }
- if (debug_lvl & 2 ) { // Instantiation/Destruction notification
- if (from == 0) cout << "Instantiated: FGCondition" << endl;
- if (from == 1) cout << "Destroyed: FGCondition" << endl;
- }
- if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
- }
- if (debug_lvl & 8 ) { // Runtime state variables
- }
- if (debug_lvl & 16) { // Sanity checking
- }
- if (debug_lvl & 64) {
- if (from == 0) { // Constructor
- cout << IdSrc << endl;
- cout << IdHdr << endl;
- }
- }
-}
-
-} //namespace JSBSim
-
+++ /dev/null
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Header: FGCondition.h
- Author: Jon S. Berndt
- Date started: 1/02/2003
-
- ------------- Copyright (C) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU 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
- details.
-
- You should have received a copy of the GNU 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
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-SENTRY
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#ifndef FGCONDITION_H
-#define FGCONDITION_H
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include <map>
-#include <FGJSBBase.h>
-#include <input_output/FGXMLElement.h>
-#include <input_output/FGPropertyManager.h>
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-DEFINITIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#define ID_CONDITION "$Id$"
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FORWARD DECLARATIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-namespace JSBSim {
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS DOCUMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/** Encapsulates a condition, which is used in parts of JSBSim including switches
-*/
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS DECLARATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-class FGCondition : public FGJSBBase
-{
-public:
- FGCondition(Element* element, FGPropertyManager* PropertyManager);
- FGCondition(string test, FGPropertyManager* PropertyManager);
- ~FGCondition(void);
-
- bool Evaluate(void);
- void PrintCondition(void);
-
-private:
- enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
- enum eLogic {elUndef=0, eAND, eOR};
- map <string, eComparison> mComparison;
- eLogic Logic;
-
- FGPropertyManager *TestParam1, *TestParam2, *PropertyManager;
- double TestValue;
- eComparison Comparison;
- bool isGroup;
- string conditional;
-
- static string indent;
-
- vector <FGCondition> conditions;
- void InitializeConditionals(void);
-
- void Debug(int from);
-};
-}
-#endif
-
------------- 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
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** 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 \93play\94 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 \961.0 and +1.0, the output will be zero.
@author Jon S. Berndt
@version $Id$
*/
------------- 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
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();
} 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");
}
FGFCSComponent::~FGFCSComponent()
{
-// string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
-// PropertyManager->Untie( tmp);
-
Debug(1);
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-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);
}
------------- 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
- FGFilter
- FGDeadBand
- FGSummer
- - FGGradient
+ - FGSensor
+ - FGFCSFunction
+ - FGPID
@author Jon S. Berndt
@version $Id$
void Clip(void);
virtual void bind();
- FGPropertyManager* resolveSymbol(string token);
-
virtual void Debug(int from);
};
------------- 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
------------- 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
/** 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>
+ \85
+ </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. Here\92s 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$
*/
------------- 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
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;
------------- 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
------------- 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
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 {
}
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")) {
------------- 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
------------- 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
------------- 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
------------- 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
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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>
+ \85
+ </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.
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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;
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ 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;
+ }
+ }
+}
+}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ 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
------------- 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
------------- 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
Syntax:
+@code
<sensor name=\94name\94 rate_group=\94name\94>
<input> property </input>
<lag> number </lag>
<drift_rate> number </drift_rate>
<bias> number </bias>
</sensor>
+@endcode
Example:
+@code
<sensor name=\94aero/sensor/qbar\94 rate_group=\94HFCS\94>
<input> aero/qbar </input>
<lag> 0.5 </lag>
</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.
@author Jon S. Berndt
@version $Revision$
- */
+*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
------------- 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
------------- 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
------------- 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
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.
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
#include "FGFCSComponent.h"
#include <input_output/FGXMLElement.h>
-#include "FGCondition.h"
+#include <math/FGCondition.h>
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
/** 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
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;
noinst_LIBRARIES = libFlightControl.a
-libFlightControl_a_SOURCES = FGCondition.cpp FGDeadBand.cpp FGFCSComponent.cpp \
+libFlightControl_a_SOURCES = FGPID.cpp FGDeadBand.cpp FGFCSComponent.cpp \
FGFilter.cpp FGGain.cpp FGGradient.cpp FGKinemat.cpp \
FGSummer.cpp FGSwitch.cpp FGFCSFunction.cpp FGSensor.cpp
-noinst_HEADERS = FGCondition.h FGDeadBand.h FGFCSComponent.h FGFilter.h \
+noinst_HEADERS = FGPID.h FGDeadBand.h FGFCSComponent.h FGFilter.h \
FGGain.h FGGradient.h FGKinemat.h FGSummer.h FGSwitch.h FGFCSFunction.h \
FGSensor.h
--------- Copyright (C) 2004 David 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
----- Copyright (C) 2004 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
------------- 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 details.
+ 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
FGEngine::~FGEngine()
{
- if (Thruster) delete Thruster;
+ delete Thruster;
Debug(1);
}
double xLoc, yLoc, zLoc, Pitch, Yaw;
double P_Factor = 0, Sense = 0.0;
string enginePath = FDMExec->GetEnginePath();
- string aircraftPath = FDMExec->GetAircraftPath();
+ string aircraftPath = FDMExec->GetFullAircraftPath();
FGXMLParse thruster_file_parser;
Element *document, *element;
ifstream thruster_file;
FGColumnVector3 location, orientation;
-
-# ifndef macintosh
string separator = "/";
-# else
- string separator = ";";
+
+# ifdef macintosh
+ separator = ";";
# endif
fullpath = enginePath + separator;
------------- 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 details.
+ 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
------------- 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.
mT(2,2) = 1;
mT(3,3) = 1;
vSense.InitMatrix(1);
+
Debug(0);
}
------------- 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.
SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
}
+ void SetPitch(double pitch) {vOrient(ePitch) = pitch;}
+ void SetYaw(double yaw) {vOrient(eYaw) = yaw;}
+
+ double GetPitch(void) const {return vOrient(ePitch);}
+ double GetYaw(void) const {return vOrient(eYaw);}
+
inline void SetSense(double x, double y, double z) { vSense(eX)=x, vSense(eY)=y, vSense(eZ)=z; }
inline void SetSense(FGColumnVector3 vv) { vSense=vv; }
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThruster(FDMExec)
+FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num)
+ : FGThruster(FDMExec, nozzle_element, num)
{
if (nozzle_element->FindElement("pe"))
}
Thrust = 0;
- ReverserAngle = 0.0;
Type = ttNozzle;
Area2 = (Diameter*Diameter/4.0)*M_PI;
AreaT = Area2/ExpR;
-// char property_name[80];
-// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-// PropertyManager->Tie( property_name, &ThrustCoeff );
-
Debug(0);
}
FGNozzle::~FGNozzle()
{
-// char property_name[80];
-// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-// PropertyManager->Untie( property_name );
-
Debug(1);
}
------------- 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
string GetThrusterValues(int id, string delimeter);
private:
- double ReverserAngle;
double PE;
double ExpR;
double nzlEff;
------------- 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
// These are internal program variables
crank_counter = 0;
- OilTemp_degK = 298;
+ OilTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
minMAP = 21950;
maxMAP = 96250;
MAP = Atmosphere->GetPressure() * psftopa;
- CylinderHeadTemp_degK = 0.0;
+ CylinderHeadTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
Magnetos = 0;
- ExhaustGasTemp_degK = 0.0;
- EGT_degC = 0.0;
+ ExhaustGasTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
+ EGT_degC = ExhaustGasTemp_degK - 273;
dt = State->Getdt();
}
minMAP = MinManifoldPressure_inHg * 3386.38; // inHg to Pa
maxMAP = MaxManifoldPressure_inHg * 3386.38;
+ StarterHP = sqrt(MaxHP) * 0.2;
// Set up and sanity-check the turbo/supercharging configuration based on the input values.
if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
p_amb = Atmosphere->GetPressure() * psftopa;
p_amb_sea_level = Atmosphere->GetPressureSL() * psftopa;
- T_amb = Atmosphere->GetTemperature() * (5.0 / 9.0); // convert from Rankine to Kelvin
+ T_amb = RankineToKelvin(Atmosphere->GetTemperature());
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
} else {
ManXRPM = ManifoldPressure_inHg * RPM; // Note that inHg must be used for the following correlation.
Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0;
- Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
+// Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
+ Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 * dt);
if (Percentage_Power < 0.0) Percentage_Power = 0.0;
else if (Percentage_Power > 100.0) Percentage_Power = 100.0;
}
// Power output when the engine is not running
if (Cranking) {
if (RPM < 10) {
- HP = 3.0; // This is a hack to prevent overshooting the idle rpm in
- // the first time step. It may possibly need to be changed
- // if the prop model is changed.
+ HP = StarterHP;
} else if (RPM < 480) {
- HP = 3.0 + ((480 - RPM) / 10.0);
+ HP = StarterHP + ((480 - RPM) / 10.0);
// This is a guess - would be nice to find a proper starter moter torque curve
} else {
- HP = 3.0;
+ HP = StarterHP;
}
} else {
// Quick hack until we port the FMEP stuff
ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0);
} else { // Drop towards ambient - guess an appropriate time constant for now
- dEGTdt = (298.0 - ExhaustGasTemp_degK) / 100.0;
+ combustion_efficiency = 0;
+ dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0;
delta_T_exhaust = dEGTdt * dt;
ExhaustGasTemp_degK += delta_T_exhaust;
}
time_constant /= ((Percentage_Power / idle_percentage_power) / 10.0); // adjust for power
}
} else {
- target_oil_temp = 298;
+ target_oil_temp = RankineToKelvin(Atmosphere->GetTemperature());
time_constant = 1000; // Time constant for engine-off; reflects the fact
// that oil is no longer getting circulated
}
------------- 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
double MaxHP; // horsepower
double Cycles; // cycles/power stroke
double IdleRPM; // revolutions per minute
+ double StarterHP; // initial horsepower of starter motor
int BoostSpeeds; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
int BoostSpeed; // The current boost-speed (zero-based).
bool Boosted; // Set true for boosted engine.
------------- 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
FGPropeller::~FGPropeller()
{
- if (cThrust) delete cThrust;
- if (cPower) delete cPower;
+ delete cThrust;
+ delete cPower;
char property_name[80];
snprintf(property_name, 80, "propulsion/engine[%d]/advance-ratio", EngineNum);
------------- 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
bool GetReverse (void) { return Reversed; }
void SetFeather (bool f) { Feathered = f; }
bool GetFeather (void) { return Feathered; }
- double GetThrustCoefficient(void) const {return ThrustCoeff;}
+ double GetThrustCoefficient(void) const {return ThrustCoeff;}
private:
int numBlades;
------------- 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
------------- 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
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGRotor::FGRotor(FGFDMExec *FDMExec) : FGThruster(FDMExec)
+FGRotor::FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num)
+ : FGThruster(FDMExec, rotor_element, num)
{
Debug(0);
}
------------- 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
class FGRotor : public FGThruster {
public:
- FGRotor(FGFDMExec *FDMExec);
+ /// Constructor
+ FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num);
+ /// Destructor
~FGRotor();
double Calculate(double);
------------- 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
------------- 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
------------- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec)
-{
- Type = ttDirect;
- SetTransformType(FGForce::tCustom);
-
- EngineNum = 0;
- PropertyManager = FDMExec->GetPropertyManager();
-
- Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMExec)
{
Element* thruster_element = el->GetParent();
Name = el->GetName();
GearRatio = 1.0;
-
+ ReverserAngle = 0.0;
EngineNum = num;
- ThrustCoeff = 0.0;
PropertyManager = FDMExec->GetPropertyManager();
// Determine the initial location and orientation of this thruster and load the
SetLocation(location);
SetAnglesToBody(orientation);
-// char property_name[80];
-// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-// PropertyManager->Tie( property_name, &ThrustCoeff );
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
+ PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
+ snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
+ PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
+
+ if (el->GetName() == "direct") // this is a direct thruster. At this time
+ // only a direct thruster can be reversed.
+ {
+ snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
+ PropertyManager->Tie( property_name, (FGThruster *)this, &FGThruster::GetReverserAngle,
+ &FGThruster::SetReverserAngle);
+ }
Debug(0);
}
FGThruster::~FGThruster()
{
-// char property_name[80];
-// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-// PropertyManager->Untie( property_name );
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
+ PropertyManager->Untie( property_name);
+ snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
+ PropertyManager->Untie( property_name);
+
+ if (Type == ttDirect) // this is a direct thruster. At this time
+ // only a direct thruster can be reversed.
+ {
+ snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
+ PropertyManager->Untie( property_name);
+ }
Debug(1);
}
------------- 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
public:
/// Constructor
- FGThruster(FGFDMExec *FDMExec);
FGThruster(FGFDMExec *FDMExec, Element *el, int num );
/// Destructor
virtual ~FGThruster();
enum eType {ttNozzle, ttRotor, ttPropeller, ttDirect};
virtual double Calculate(double tt) {
- Thrust = tt; vFn(1) = Thrust;
+ Thrust = cos(ReverserAngle)*tt;
+ vFn(1) = Thrust;
return Thrust;
}
void SetName(string name) {Name = name;}
double GetThrust(void) {return Thrust;}
eType GetType(void) {return Type;}
string GetName(void) {return Name;}
+ void SetReverserAngle(double angle) {ReverserAngle = angle;}
+ double GetReverserAngle(void) const {return ReverserAngle;}
virtual double GetRPM(void) { return 0.0; };
double GetGearRatio(void) {return GearRatio; }
virtual string GetThrusterLabels(int id, string delimeter);
double deltaT;
double GearRatio;
double ThrustCoeff;
+ double ReverserAngle;
int EngineNum;
FGPropertyManager* PropertyManager;
virtual void Debug(int from);
------------- Copyright (C) 2003 David 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
FGTurbine::~FGTurbine()
{
- if (IdleThrustLookup) delete IdleThrustLookup;
- if (MilThrustLookup) delete MilThrustLookup;
- if (MaxThrustLookup) delete MaxThrustLookup;
- if (InjectionLookup) delete InjectionLookup;
+ delete IdleThrustLookup;
+ delete MilThrustLookup;
+ delete MaxThrustLookup;
+ delete InjectionLookup;
unbind();
Debug(1);
}
------------- Copyright (C) 2003 David 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
------------- Copyright (C) 2004 (javky@email.cz) ---------
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
------------- Copyright (C) 2004 (javky@email.cz)----------
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