Latest JSBSim changes.
This commit is contained in:
parent
f0e6716953
commit
5d8a04291c
59 changed files with 779 additions and 667 deletions
|
@ -61,7 +61,7 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
|
|||
|
||||
Coeff = new CoeffArray[6];
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGAerodynamics" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -76,7 +76,7 @@ FGAerodynamics::~FGAerodynamics()
|
|||
}
|
||||
delete[] Coeff;
|
||||
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGAerodynamics" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -202,11 +202,49 @@ double FGAerodynamics::GetLoD(void)
|
|||
if (vFs(1) != 0.00) return vFs(3)/vFs(1);
|
||||
else return 0.00;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// 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 FGAerodynamics::Debug(int from)
|
||||
{
|
||||
//TODO: Add your source code here
|
||||
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: FGAerodynamics" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGAerodynamics" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,40 +119,6 @@ FGAircraft::~FGAircraft()
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::Load(FGConfigFile* AC_cfg)
|
||||
{
|
||||
string token;
|
||||
|
||||
if (!ReadPrologue(AC_cfg)) return false;
|
||||
|
||||
while ((AC_cfg->GetNextConfigLine() != string("EOF")) &&
|
||||
(token = AC_cfg->GetValue()) != string("/FDM_CONFIG")) {
|
||||
if (token == "METRICS") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
|
||||
if (!ReadMetrics(AC_cfg)) return false;
|
||||
} else if (token == "AERODYNAMICS") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
|
||||
if (!ReadAerodynamics(AC_cfg)) return false;
|
||||
} else if (token == "UNDERCARRIAGE") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
|
||||
if (!ReadUndercarriage(AC_cfg)) return false;
|
||||
} else if (token == "PROPULSION") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
|
||||
if (!ReadPropulsion(AC_cfg)) return false;
|
||||
} else if (token == "FLIGHT_CONTROL") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
|
||||
if (!ReadFlightControls(AC_cfg)) return false;
|
||||
} else if (token == "OUTPUT") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
|
||||
if (!ReadOutput(AC_cfg)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::Run(void)
|
||||
{
|
||||
if (!FGModel::Run()) { // if false then execute this Run()
|
||||
|
@ -197,33 +163,7 @@ float FGAircraft::GetNlf(void)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
|
||||
{
|
||||
string token = AC_cfg->GetValue();
|
||||
string scratch;
|
||||
AircraftName = AC_cfg->GetValue("NAME");
|
||||
if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
|
||||
<< underoff << ": " << highint << AircraftName << normint << endl;
|
||||
scratch = AC_cfg->GetValue("VERSION").c_str();
|
||||
|
||||
CFGVersion = AC_cfg->GetValue("VERSION");
|
||||
|
||||
if (debug_lvl > 0)
|
||||
cout << " Version: " << highint << CFGVersion
|
||||
<< normint << endl;
|
||||
if (CFGVersion != needed_cfg_version) {
|
||||
cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
|
||||
" RESULTS WILL BE UNPREDICTABLE !!" << endl;
|
||||
cerr << "Current version needed is: " << needed_cfg_version << endl;
|
||||
cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
||||
bool FGAircraft::Load(FGConfigFile* AC_cfg)
|
||||
{
|
||||
string token = "";
|
||||
string parameter;
|
||||
|
@ -318,61 +258,6 @@ bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
|||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Propulsion->Load(AC_cfg)) {
|
||||
cerr << " Propulsion not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!FCS->Load(AC_cfg)) {
|
||||
cerr << " Flight Controls not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Aerodynamics->Load(AC_cfg)) {
|
||||
cerr << " Aerodynamics not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!GroundReactions->Load(AC_cfg)) {
|
||||
cerr << " Ground Reactions not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Output->Load(AC_cfg)) {
|
||||
cerr << " Output not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// The bitmasked value choices are as follows:
|
||||
// unset: In this case (the default) JSBSim would only print
|
||||
|
@ -410,7 +295,11 @@ void FGAircraft::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 32) { // Turbulence
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,45 +74,6 @@ FORWARD DECLARATIONS
|
|||
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
Longitudinal
|
||||
CL0 - Reference lift at zero alpha
|
||||
CD0 - Reference drag at zero alpha
|
||||
CDM - Drag due to Mach
|
||||
CLa - Lift curve slope (w.r.t. alpha)
|
||||
CDa - Drag curve slope (w.r.t. alpha)
|
||||
CLq - Lift due to pitch rate
|
||||
CLM - Lift due to Mach
|
||||
CLadt - Lift due to alpha rate
|
||||
|
||||
Cmadt - Pitching Moment due to alpha rate
|
||||
Cm0 - Reference Pitching moment at zero alpha
|
||||
Cma - Pitching moment slope (w.r.t. alpha)
|
||||
Cmq - Pitch damping (pitch moment due to pitch rate)
|
||||
CmM - Pitch Moment due to Mach
|
||||
|
||||
Lateral
|
||||
Cyb - Side force due to sideslip
|
||||
Cyr - Side force due to yaw rate
|
||||
|
||||
Clb - Dihedral effect (roll moment due to sideslip)
|
||||
Clp - Roll damping (roll moment due to roll rate)
|
||||
Clr - Roll moment due to yaw rate
|
||||
Cnb - Weathercocking stability (yaw moment due to sideslip)
|
||||
Cnp - Rudder adverse yaw (yaw moment due to roll rate)
|
||||
Cnr - Yaw damping (yaw moment due to yaw rate)
|
||||
|
||||
Control
|
||||
CLDe - Lift due to elevator
|
||||
CDDe - Drag due to elevator
|
||||
CyDr - Side force due to rudder
|
||||
CyDa - Side force due to aileron
|
||||
|
||||
CmDe - Pitch moment due to elevator
|
||||
ClDa - Roll moment due to aileron
|
||||
ClDr - Roll moment due to rudder
|
||||
CnDr - Yaw moment due to rudder
|
||||
CnDa - Yaw moment due to aileron
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CLASS DOCUMENTATION
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
@ -123,10 +84,7 @@ CLASS DOCUMENTATION
|
|||
landing gear, etc. These constituent parts may actually run as separate
|
||||
JSBSim models themselves, but the responsibility for initializing them and
|
||||
for retrieving their force and moment contributions falls to FGAircraft.<br>
|
||||
When an aircraft model is loaded the config file is parsed and for each of the
|
||||
sections of the config file (propulsion, flight control, etc.) the
|
||||
corresponding "ReadXXX()" method is called. From within this method the
|
||||
"Load()" method of that system is called (e.g. LoadFCS).
|
||||
|
||||
@author Jon S. Berndt
|
||||
@version $Id$
|
||||
@see
|
||||
|
@ -199,6 +157,7 @@ public:
|
|||
|
||||
inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
|
||||
inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
|
||||
inline void SetAircraftName(string name) {AircraftName = name;}
|
||||
|
||||
inline double GetStallWarn(void) { return impending_stall; }
|
||||
|
||||
|
@ -222,16 +181,8 @@ private:
|
|||
double lbarh,lbarv,vbarh,vbarv;
|
||||
double alphaclmax,alphaclmin;
|
||||
double impending_stall;
|
||||
string CFGVersion;
|
||||
string AircraftName;
|
||||
|
||||
bool ReadMetrics(FGConfigFile*);
|
||||
bool ReadPropulsion(FGConfigFile*);
|
||||
bool ReadFlightControls(FGConfigFile*);
|
||||
bool ReadAerodynamics(FGConfigFile*);
|
||||
bool ReadUndercarriage(FGConfigFile*);
|
||||
bool ReadPrologue(FGConfigFile*);
|
||||
bool ReadOutput(FGConfigFile*);
|
||||
void Debug(int from);
|
||||
};
|
||||
|
||||
|
|
|
@ -338,5 +338,11 @@ void FGAtmosphere::Debug(int from)
|
|||
cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
|
||||
}
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
|
|||
psl = rhosl = 1;
|
||||
earthPosAngle = 0.0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
FGAuxiliary::~FGAuxiliary()
|
||||
{
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGAuxiliary" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -212,9 +212,48 @@ void FGAuxiliary::GetState(void)
|
|||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// 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 FGAuxiliary::Debug(int from)
|
||||
{
|
||||
//TODO: Add your source code here
|
||||
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: FGAuxiliary" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGAuxiliary" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -324,5 +324,11 @@ void FGCoefficient::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ FGColumnVector3::FGColumnVector3(void)
|
|||
rowCtr = 1;
|
||||
data[0]=0; data[1]=0; data[2]=0; data[3]=0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -42,14 +42,14 @@ FGColumnVector3::FGColumnVector3(double X, double Y, double Z)
|
|||
rowCtr = 1;
|
||||
data[0] = 0; data[eX] = X; data[eY] = Y; data[eZ] = Z;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
FGColumnVector3::~FGColumnVector3(void)
|
||||
{
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector3" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ FGColumnVector3::FGColumnVector3(const FGColumnVector3& b)
|
|||
data[3] = b.data[3];
|
||||
rowCtr = 1;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -74,8 +74,6 @@ FGColumnVector3 FGColumnVector3::operator=(const FGColumnVector3& b)
|
|||
data[3] = b.data[3];
|
||||
rowCtr = 1;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -283,10 +281,46 @@ FGColumnVector3& FGColumnVector3::operator<<(const double ff)
|
|||
return *this;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
// 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 FGColumnVector3::Debug(int from)
|
||||
{
|
||||
//TODO: Add your source code here
|
||||
if (debug_lvl <= 0) return;
|
||||
|
||||
if (debug_lvl & 1) { // Standard console startup message output
|
||||
}
|
||||
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
||||
if (from == 0) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGColumnVector3" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ FGColumnVector4::FGColumnVector4(void)
|
|||
rowCtr = 1;
|
||||
data[1]=0;data[2]=0;data[3]=0;data[4]=0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -42,14 +42,14 @@ FGColumnVector4::FGColumnVector4(double A, double B, double C, double D)
|
|||
rowCtr = 1;
|
||||
data[1]=0;data[2]=0;data[3]=0;data[4]=0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
FGColumnVector4::~FGColumnVector4(void)
|
||||
{
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector4" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ FGColumnVector4::FGColumnVector4(const FGColumnVector4& b)
|
|||
|
||||
rowCtr = 1;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -76,9 +76,6 @@ FGColumnVector4 FGColumnVector4::operator=(const FGColumnVector4& b)
|
|||
data[3] = b.data[3];
|
||||
data[4] = b.data[4];
|
||||
rowCtr = 1;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -270,11 +267,47 @@ FGColumnVector4& FGColumnVector4::operator<<(const double ff)
|
|||
if (++rowCtr > 4) rowCtr = 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
// 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 FGColumnVector4::Debug(int from)
|
||||
{
|
||||
//TODO: Add your source code here
|
||||
if (debug_lvl <= 0) return;
|
||||
|
||||
if (debug_lvl & 1) { // Standard console startup message output
|
||||
}
|
||||
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
||||
if (from == 0) cout << "Instantiated: FGColumnVector4" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGColumnVector4" << 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) { // Sanity checking
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -350,5 +350,11 @@ void FGConfigFile::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,4 +191,11 @@ void FGEngine::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -408,4 +408,11 @@ void FGFCS::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
Author: Jon S. Berndt
|
||||
Date started: 11/17/98
|
||||
Purpose: Schedules and runs the model routines.
|
||||
Called by: The GUI.
|
||||
|
||||
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
||||
|
||||
|
@ -80,26 +79,6 @@ static const char *IdHdr = ID_FDMEXEC;
|
|||
GLOBAL DECLARATIONS
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
short debug_lvl; // This describes to any interested entity the debug level
|
||||
// requested by setting the JSBSIM_DEBUG environment variable.
|
||||
// The bitmasked value choices are as follows:
|
||||
// a) 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
|
||||
// b) 0: This requests JSBSim not to output any messages
|
||||
// whatsoever.
|
||||
// c) 1: This value explicity requests the normal JSBSim
|
||||
// startup messages
|
||||
// d) 2: This value asks for a message to be printed out when
|
||||
// a class is instantiated
|
||||
// e) 4: When this value is set, a message is displayed when a
|
||||
// FGModel object executes its Run() method
|
||||
// f) 8: When this value is set, various runtime state variables
|
||||
// are printed out periodically
|
||||
// g) 16: When set various parameters are sanity checked and
|
||||
// a message is printed out when they go out of bounds.
|
||||
|
||||
unsigned int FGFDMExec::FDMctr = 0;
|
||||
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -131,7 +110,6 @@ FGFDMExec::FGFDMExec(void)
|
|||
terminate = false;
|
||||
frozen = false;
|
||||
modelLoaded = false;
|
||||
Scripted = false;
|
||||
|
||||
IdFDM = FDMctr;
|
||||
FDMctr++;
|
||||
|
@ -328,11 +306,6 @@ bool FGFDMExec::Run(void)
|
|||
model_iterator = FirstModel;
|
||||
if (model_iterator == 0L) return false;
|
||||
|
||||
if (Scripted) {
|
||||
RunScript();
|
||||
if (State->Getsim_time() >= EndTime) return false;
|
||||
}
|
||||
|
||||
Debug(2);
|
||||
|
||||
while (!model_iterator->Run()) {
|
||||
|
@ -361,8 +334,8 @@ bool FGFDMExec::RunIC(FGInitialCondition *fgic)
|
|||
|
||||
bool FGFDMExec::LoadModel(string APath, string EPath, string model)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
bool result = true;
|
||||
string token;
|
||||
string aircraftCfgFileName;
|
||||
|
||||
AircraftPath = APath;
|
||||
|
@ -382,7 +355,30 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
|
|||
Allocate();
|
||||
}
|
||||
|
||||
result = Aircraft->Load(&AC_cfg);
|
||||
if (!ReadPrologue(&AC_cfg)) return false;
|
||||
|
||||
while ((AC_cfg.GetNextConfigLine() != string("EOF")) &&
|
||||
(token = AC_cfg.GetValue()) != string("/FDM_CONFIG")) {
|
||||
if (token == "METRICS") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
|
||||
if (!ReadMetrics(&AC_cfg)) result = false;
|
||||
} else if (token == "AERODYNAMICS") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
|
||||
if (!ReadAerodynamics(&AC_cfg)) result = false;
|
||||
} else if (token == "UNDERCARRIAGE") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
|
||||
if (!ReadUndercarriage(&AC_cfg)) result = false;
|
||||
} else if (token == "PROPULSION") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
|
||||
if (!ReadPropulsion(&AC_cfg)) result = false;
|
||||
} else if (token == "FLIGHT_CONTROL") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
|
||||
if (!ReadFlightControls(&AC_cfg)) result = false;
|
||||
} else if (token == "OUTPUT") {
|
||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
|
||||
if (!ReadOutput(&AC_cfg)) result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
modelLoaded = true;
|
||||
|
@ -398,208 +394,98 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::LoadScript(string script)
|
||||
bool FGFDMExec::ReadPrologue(FGConfigFile* AC_cfg)
|
||||
{
|
||||
FGConfigFile Script(script);
|
||||
string token="";
|
||||
string aircraft="";
|
||||
string initialize="";
|
||||
bool result = false;
|
||||
double dt = 0.0;
|
||||
unsigned i;
|
||||
struct condition *newCondition;
|
||||
string token = AC_cfg->GetValue();
|
||||
string scratch;
|
||||
string AircraftName;
|
||||
|
||||
AircraftName = AC_cfg->GetValue("NAME");
|
||||
Aircraft->SetAircraftName(AircraftName);
|
||||
|
||||
if (!Script.IsOpen()) return false;
|
||||
if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
|
||||
<< underoff << ": " << highint << AircraftName << normint << endl;
|
||||
scratch = AC_cfg->GetValue("VERSION").c_str();
|
||||
|
||||
Script.GetNextConfigLine();
|
||||
ScriptName = Script.GetValue("name");
|
||||
Scripted = true;
|
||||
if (debug_lvl > 0) cout << "Reading Script File " << ScriptName << endl;
|
||||
CFGVersion = AC_cfg->GetValue("VERSION");
|
||||
|
||||
while (Script.GetNextConfigLine() != string("EOF") && Script.GetValue() != string("/runscript")) {
|
||||
token = Script.GetValue();
|
||||
if (token == "use") {
|
||||
if ((token = Script.GetValue("aircraft")) != string("")) {
|
||||
aircraft = token;
|
||||
if (debug_lvl > 0) cout << " Use aircraft: " << token << endl;
|
||||
} else if ((token = Script.GetValue("initialize")) != string("")) {
|
||||
initialize = token;
|
||||
if (debug_lvl > 0) cout << " Use reset file: " << token << endl;
|
||||
} else {
|
||||
cerr << "Unknown 'use' keyword: \"" << token << "\"" << endl;
|
||||
}
|
||||
} else if (token == "run") {
|
||||
StartTime = strtod(Script.GetValue("start").c_str(), NULL);
|
||||
State->Setsim_time(StartTime);
|
||||
EndTime = strtod(Script.GetValue("end").c_str(), NULL);
|
||||
dt = strtod(Script.GetValue("dt").c_str(), NULL);
|
||||
State->Setdt(dt);
|
||||
Script.GetNextConfigLine();
|
||||
token = Script.GetValue();
|
||||
while (token != string("/run")) {
|
||||
|
||||
if (token == "when") {
|
||||
Script.GetNextConfigLine();
|
||||
token = Script.GetValue();
|
||||
newCondition = new struct condition();
|
||||
while (token != string("/when")) {
|
||||
if (token == "parameter") {
|
||||
newCondition->TestParam.push_back(State->GetParameterIndex(Script.GetValue("name")));
|
||||
newCondition->TestValue.push_back(strtod(Script.GetValue("value").c_str(), NULL));
|
||||
newCondition->Comparison.push_back(Script.GetValue("comparison"));
|
||||
} else if (token == "set") {
|
||||
newCondition->SetParam.push_back(State->GetParameterIndex(Script.GetValue("name")));
|
||||
newCondition->SetValue.push_back(strtod(Script.GetValue("value").c_str(), NULL));
|
||||
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);
|
||||
string tempCompare = Script.GetValue("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((eType)0);
|
||||
tempCompare = Script.GetValue("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((eAction)0);
|
||||
|
||||
if (Script.GetValue("persistent") == "true")
|
||||
newCondition->Persistent.push_back(true);
|
||||
else
|
||||
newCondition->Persistent.push_back(false);
|
||||
|
||||
newCondition->TC.push_back(strtod(Script.GetValue("tc").c_str(), NULL));
|
||||
|
||||
} else {
|
||||
cerr << "Unrecognized keyword in script file: \" [when] " << token << "\"" << endl;
|
||||
}
|
||||
Script.GetNextConfigLine();
|
||||
token = Script.GetValue();
|
||||
}
|
||||
Conditions.push_back(*newCondition);
|
||||
Script.GetNextConfigLine();
|
||||
token = Script.GetValue();
|
||||
|
||||
} else {
|
||||
cerr << "Error reading script file: expected \"when\", got \"" << token << "\"" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (token.empty()) {
|
||||
// do nothing
|
||||
} else {
|
||||
cerr << "Unrecognized keyword in script file: \"" << token << "\" [runscript] " << endl;
|
||||
}
|
||||
if (debug_lvl > 0)
|
||||
cout << " Version: " << highint << CFGVersion
|
||||
<< normint << endl;
|
||||
if (CFGVersion != needed_cfg_version) {
|
||||
cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
|
||||
" RESULTS WILL BE UNPREDICTABLE !!" << endl;
|
||||
cerr << "Current version needed is: " << needed_cfg_version << endl;
|
||||
cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aircraft == "") {
|
||||
cerr << "Aircraft file not loaded in script" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Debug(4);
|
||||
|
||||
result = LoadModel("aircraft", "engine", aircraft);
|
||||
if (!result) {
|
||||
cerr << "Aircraft file " << aircraft << " was not found" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
FGInitialCondition IC(this);
|
||||
if ( ! IC.Load("aircraft", aircraft, initialize)) {
|
||||
cerr << "Initialization unsuccessful" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGFDMExec::RunScript(void)
|
||||
bool FGFDMExec::ReadPropulsion(FGConfigFile* AC_cfg)
|
||||
{
|
||||
vector <struct condition>::iterator iC = Conditions.begin();
|
||||
bool truth = false;
|
||||
bool WholeTruth = false;
|
||||
unsigned i;
|
||||
|
||||
double currentTime = State->Getsim_time();
|
||||
double newSetValue = 0;
|
||||
|
||||
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 = State->GetParameter(iC->TestParam[i]) < iC->TestValue[i];
|
||||
else if (iC->Comparison[i] == "le")
|
||||
truth = State->GetParameter(iC->TestParam[i]) <= iC->TestValue[i];
|
||||
else if (iC->Comparison[i] == "eq")
|
||||
truth = State->GetParameter(iC->TestParam[i]) == iC->TestValue[i];
|
||||
else if (iC->Comparison[i] == "ge")
|
||||
truth = State->GetParameter(iC->TestParam[i]) >= iC->TestValue[i];
|
||||
else if (iC->Comparison[i] == "gt")
|
||||
truth = State->GetParameter(iC->TestParam[i]) > iC->TestValue[i];
|
||||
else if (iC->Comparison[i] == "ne")
|
||||
truth = State->GetParameter(iC->TestParam[i]) != 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 the conditions are true, do the setting of the desired parameters
|
||||
|
||||
if (WholeTruth) {
|
||||
for (i=0; i<iC->SetValue.size(); i++) {
|
||||
if ( ! iC->Triggered[i]) {
|
||||
iC->OriginalValue[i] = State->GetParameter(iC->SetParam[i]);
|
||||
switch (iC->Type[i]) {
|
||||
case FG_VALUE:
|
||||
iC->newValue[i] = iC->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];
|
||||
break;
|
||||
default:
|
||||
cerr << "Invalid Type specified" << endl;
|
||||
break;
|
||||
}
|
||||
iC->Triggered[i] = true;
|
||||
iC->StartTime[i] = currentTime;
|
||||
}
|
||||
|
||||
switch (iC->Action[i]) {
|
||||
case FG_RAMP:
|
||||
newSetValue = (currentTime - iC->StartTime[i])/(iC->TC[i])
|
||||
* (iC->newValue[i] - iC->OriginalValue[i]) + iC->OriginalValue[i];
|
||||
if (newSetValue > iC->newValue[i]) newSetValue = iC->newValue[i];
|
||||
break;
|
||||
case FG_STEP:
|
||||
newSetValue = iC->newValue[i];
|
||||
break;
|
||||
case FG_EXP:
|
||||
newSetValue = (1 - exp(-(currentTime - iC->StartTime[i])/(iC->TC[i])))
|
||||
* (iC->newValue[i] - iC->OriginalValue[i]) + iC->OriginalValue[i];
|
||||
break;
|
||||
default:
|
||||
cerr << "Invalid Action specified" << endl;
|
||||
break;
|
||||
}
|
||||
State->SetParameter(iC->SetParam[i], newSetValue);
|
||||
}
|
||||
}
|
||||
iC++;
|
||||
if (!Propulsion->Load(AC_cfg)) {
|
||||
cerr << " Propulsion not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::ReadFlightControls(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!FCS->Load(AC_cfg)) {
|
||||
cerr << " Flight Controls not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::ReadAerodynamics(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Aerodynamics->Load(AC_cfg)) {
|
||||
cerr << " Aerodynamics not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::ReadUndercarriage(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!GroundReactions->Load(AC_cfg)) {
|
||||
cerr << " Ground Reactions not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::ReadMetrics(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Aircraft->Load(AC_cfg)) {
|
||||
cerr << " Aircraft metrics not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
bool FGFDMExec::ReadOutput(FGConfigFile* AC_cfg)
|
||||
{
|
||||
if (!Output->Load(AC_cfg)) {
|
||||
cerr << " Output not successfully loaded" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -623,8 +509,6 @@ void FGFDMExec::RunScript(void)
|
|||
|
||||
void FGFDMExec::Debug(int from)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (debug_lvl <= 0) return;
|
||||
|
||||
if (debug_lvl & 1) { // Standard console startup message output
|
||||
|
@ -635,73 +519,6 @@ void FGFDMExec::Debug(int from)
|
|||
cout << normint << "JSBSim startup beginning ...\n\n";
|
||||
} else if (from == 3) {
|
||||
cout << "\n\nJSBSim startup complete\n\n";
|
||||
} else if (from == 4) { // print out script data
|
||||
vector <struct condition>::iterator iterConditions = Conditions.begin();
|
||||
int count=0;
|
||||
|
||||
cout << "\n Script goes from " << StartTime << " to " << EndTime
|
||||
<< " with dt = " << State->Getdt() << endl << endl;
|
||||
|
||||
while (iterConditions < Conditions.end()) {
|
||||
cout << " Condition: " << count++ << endl;
|
||||
cout << " if (";
|
||||
|
||||
for (i=0; i<iterConditions->TestValue.size(); i++) {
|
||||
if (i>0) cout << " and" << endl << " ";
|
||||
cout << "(" << State->paramdef[iterConditions->TestParam[i]]
|
||||
<< iterConditions->Comparison[i] << " "
|
||||
<< iterConditions->TestValue[i] << ")";
|
||||
}
|
||||
cout << ") then {";
|
||||
|
||||
for (i=0; i<iterConditions->SetValue.size(); i++) {
|
||||
cout << endl << " set" << State->paramdef[iterConditions->SetParam[i]]
|
||||
<< "to " << iterConditions->SetValue[i];
|
||||
|
||||
switch (iterConditions->Type[i]) {
|
||||
case FG_VALUE:
|
||||
cout << " (constant";
|
||||
break;
|
||||
case FG_DELTA:
|
||||
cout << " (delta";
|
||||
break;
|
||||
case FG_BOOL:
|
||||
cout << " (boolean";
|
||||
break;
|
||||
default:
|
||||
cout << " (unspecified type";
|
||||
}
|
||||
|
||||
switch (iterConditions->Action[i]) {
|
||||
case FG_RAMP:
|
||||
cout << " via ramp";
|
||||
break;
|
||||
case FG_STEP:
|
||||
cout << " via step";
|
||||
break;
|
||||
case FG_EXP:
|
||||
cout << " via exponential approach";
|
||||
break;
|
||||
default:
|
||||
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];
|
||||
}
|
||||
cout << ")" << endl << " }" << endl << endl;
|
||||
|
||||
iterConditions++;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
||||
|
@ -718,4 +535,11 @@ void FGFDMExec::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,20 +55,6 @@ DEFINITIONS
|
|||
FORWARD DECLARATIONS
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
||||
class FGState;
|
||||
class FGAtmosphere;
|
||||
class FGFCS;
|
||||
class FGPropulsion;
|
||||
class FGMassBalance;
|
||||
class FGAerodynamics;
|
||||
class FGInertial;
|
||||
class FGGroundReactions;
|
||||
class FGAircraft;
|
||||
class FGTranslation;
|
||||
class FGRotation;
|
||||
class FGPosition;
|
||||
class FGAuxiliary;
|
||||
class FGOutput;
|
||||
class FGInitialCondition;
|
||||
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -88,64 +74,10 @@ CLASS DOCUMENTATION
|
|||
other flight simulator) this class is typically instantiated by an interface
|
||||
class on the simulator side.
|
||||
|
||||
<h4>Scripting support provided in the Executive</h4>
|
||||
|
||||
<p>There is simple scripting support provided in the FGFDMExec
|
||||
class. Commands are specified using the <u>Simple Scripting
|
||||
Directives for JSBSim</u> (SSDJ). The script file is in XML
|
||||
format. A test condition (or conditions) can be set up in the
|
||||
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
|
||||
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
|
||||
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>
|
||||
When an aircraft model is loaded the config file is parsed and for each of the
|
||||
sections of the config file (propulsion, flight control, etc.) the
|
||||
corresponding "ReadXXX()" method is called. From within this method the
|
||||
"Load()" method of that system is called (e.g. LoadFCS).
|
||||
|
||||
<h4>JSBSim Debugging Directives</h4>
|
||||
|
||||
|
@ -196,8 +128,7 @@ public:
|
|||
@return Currently returns 0 always. */
|
||||
int Schedule(FGModel* model, int rate);
|
||||
|
||||
/** This executes each scheduled model in succession, as well as running any
|
||||
scripts which are loaded.
|
||||
/** This executes each scheduled model in succession.
|
||||
@return true if successful, false if sim should be ended */
|
||||
bool Run(void);
|
||||
|
||||
|
@ -227,19 +158,8 @@ public:
|
|||
@return true if successful*/
|
||||
bool LoadModel(string AircraftPath, string EnginePath, string model);
|
||||
|
||||
/** Loads a script to drive JSBSim (usually in standalone mode).
|
||||
The language is the Simple Script Directives for JSBSim (SSDJ).
|
||||
@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. */
|
||||
void RunScript(void);
|
||||
|
||||
bool SetEnginePath(string path) {EnginePath = path; return true;}
|
||||
bool SetAircraftPath(string path) {AircraftPath = path; return true;}
|
||||
bool SetScriptPath(string path) {ScriptPath = path; return true;}
|
||||
|
||||
/// @name Top-level executive State and Model retrieval mechanism
|
||||
//@{
|
||||
|
@ -279,38 +199,6 @@ public:
|
|||
inline string GetAircraftPath(void) {return AircraftPath;}
|
||||
|
||||
private:
|
||||
enum eAction {
|
||||
FG_RAMP = 1,
|
||||
FG_STEP = 2,
|
||||
FG_EXP = 3
|
||||
};
|
||||
|
||||
enum eType {
|
||||
FG_VALUE = 1,
|
||||
FG_DELTA = 2,
|
||||
FG_BOOL = 3
|
||||
};
|
||||
|
||||
struct condition {
|
||||
vector <eParam> TestParam;
|
||||
vector <eParam> SetParam;
|
||||
vector <double> TestValue;
|
||||
vector <double> SetValue;
|
||||
vector <string> Comparison;
|
||||
vector <double> TC;
|
||||
vector <bool> Persistent;
|
||||
vector <eAction> Action;
|
||||
vector <eType> Type;
|
||||
vector <bool> Triggered;
|
||||
vector <double> newValue;
|
||||
vector <double> OriginalValue;
|
||||
vector <double> StartTime;
|
||||
vector <double> EndTime;
|
||||
|
||||
condition() {
|
||||
}
|
||||
};
|
||||
|
||||
FGModel* FirstModel;
|
||||
|
||||
bool frozen;
|
||||
|
@ -320,15 +208,10 @@ private:
|
|||
unsigned int IdFDM;
|
||||
static unsigned int FDMctr;
|
||||
bool modelLoaded;
|
||||
bool Scripted;
|
||||
|
||||
string AircraftPath;
|
||||
string EnginePath;
|
||||
string ScriptPath;
|
||||
string ScriptName;
|
||||
double StartTime;
|
||||
double EndTime;
|
||||
vector <struct condition> Conditions;
|
||||
string CFGVersion;
|
||||
|
||||
FGState* State;
|
||||
FGAtmosphere* Atmosphere;
|
||||
|
@ -345,6 +228,14 @@ private:
|
|||
FGAuxiliary* Auxiliary;
|
||||
FGOutput* Output;
|
||||
|
||||
bool ReadMetrics(FGConfigFile*);
|
||||
bool ReadPropulsion(FGConfigFile*);
|
||||
bool ReadFlightControls(FGConfigFile*);
|
||||
bool ReadAerodynamics(FGConfigFile*);
|
||||
bool ReadUndercarriage(FGConfigFile*);
|
||||
bool ReadPrologue(FGConfigFile*);
|
||||
bool ReadOutput(FGConfigFile*);
|
||||
|
||||
bool Allocate(void);
|
||||
bool DeAllocate(void);
|
||||
void Debug(int from);
|
||||
|
|
|
@ -166,4 +166,11 @@ void FGFactorGroup::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,5 +172,11 @@ void FGForce::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ FGGroundReactions::~FGGroundReactions(void)
|
|||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
bool FGGroundReactions::Run(void)
|
||||
{
|
||||
double steerAngle = 0.0;
|
||||
double xForces = 0.0, yForces = 0.0;
|
||||
// double steerAngle = 0.0;
|
||||
// double xForces = 0.0, yForces = 0.0;
|
||||
|
||||
if (!FGModel::Run()) {
|
||||
vForces.InitMatrix();
|
||||
|
@ -237,5 +237,11 @@ void FGGroundReactions::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,5 +160,11 @@ void FGInertial::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,14 +91,14 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec)
|
|||
cout << "FGInitialCondition: This class requires a pointer to a valid FGFDMExec object" << endl;
|
||||
}
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGInitialCondition" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
FGInitialCondition::~FGInitialCondition()
|
||||
{
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGInitialCondition" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
@ -764,4 +764,48 @@ bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
|
|||
fdmex->RunIC(this);
|
||||
|
||||
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 FGInitialCondition::Debug(int from)
|
||||
{
|
||||
if (debug_lvl <= 0) return;
|
||||
|
||||
if (debug_lvl & 1) { // Standard console startup message output
|
||||
}
|
||||
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
||||
if (from == 0) cout << "Instantiated: FGInitialCondition" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGInitialCondition" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,6 +290,7 @@ private:
|
|||
|
||||
bool findInterval(double x,double guess);
|
||||
bool solve(double *y, double x);
|
||||
void Debug(int from);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -497,5 +497,11 @@ void FGLGear::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,5 +231,11 @@ void FGMassBalance::Debug(int from)
|
|||
cout << "MassBalance::Mass out of bounds: " << Mass << endl;
|
||||
}
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -433,5 +433,11 @@ void FGMatrix33::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,4 +150,48 @@ bool FGModel::Run()
|
|||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// 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 FGModel::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: FGModel" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGModel" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,8 @@ public:
|
|||
protected:
|
||||
int exe_ctr;
|
||||
int rate;
|
||||
|
||||
virtual void Debug(int from);
|
||||
|
||||
FGFDMExec* FDMExec;
|
||||
FGState* State;
|
||||
|
|
|
@ -142,5 +142,11 @@ void FGNozzle::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -522,5 +522,11 @@ void FGOutput::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -570,5 +570,11 @@ void FGPiston::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,5 +263,11 @@ void FGPosition::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -272,5 +272,11 @@ void FGPropeller::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -580,5 +580,11 @@ void FGPropulsion::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,5 +153,11 @@ void FGRocket::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,4 +195,11 @@ void FGRotation::Debug(int from)
|
|||
cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl;
|
||||
}
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,9 @@ public:
|
|||
inline FGColumnVector3& GetEulerRates(void) { return vEulerRates; }
|
||||
inline double GetEulerRates(int axis) { return vEulerRates(axis); }
|
||||
inline void SetPQR(FGColumnVector3 tt) {vPQR = tt;}
|
||||
inline void SetPQR(double p, double q, double r) {vPQR(eP)=p;
|
||||
vPQR(eQ)=q;
|
||||
vPQR(eR)=r;}
|
||||
inline void SetEuler(FGColumnVector3 tt) {vEuler = tt;}
|
||||
|
||||
inline double Getphi(void) {return vEuler(1);}
|
||||
|
|
|
@ -102,5 +102,11 @@ void FGRotor::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ bool FGScript::LoadScript(string script)
|
|||
string initialize="";
|
||||
bool result = false;
|
||||
double dt = 0.0;
|
||||
unsigned i;
|
||||
struct condition *newCondition;
|
||||
|
||||
if (!Script.IsOpen()) return false;
|
||||
|
@ -405,5 +404,11 @@ void FGScript::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ eParam FGState::GetParameterIndex(string val_string)
|
|||
|
||||
void FGState::SetParameter(eParam val_idx, double val)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
switch(val_idx) {
|
||||
case FG_ELEVATOR_POS:
|
||||
|
@ -888,5 +888,12 @@ void FGState::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -266,6 +266,13 @@ void FGTable::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -151,5 +151,11 @@ void FGTank::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,5 +98,11 @@ void FGThruster::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -212,4 +212,11 @@ void FGTranslation::Debug(int from)
|
|||
if (qbar > 1e6 || qbar < 0.00)
|
||||
cout << "FGTranslation::qbar is out of bounds: " << qbar << endl;
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,11 +88,11 @@ public:
|
|||
~FGTranslation();
|
||||
|
||||
inline FGColumnVector3& GetUVW (void) { return vUVW; }
|
||||
inline double GetUVW (int idx) { return vUVW(idx); }
|
||||
inline double GetUVW (int idx) { return vUVW(idx); }
|
||||
inline FGColumnVector3& GetUVWdot(void) { return vUVWdot; }
|
||||
inline double GetUVWdot(int idx) { return vUVWdot(idx); }
|
||||
inline double GetUVWdot(int idx) { return vUVWdot(idx); }
|
||||
inline FGColumnVector3& GetvAeroUVW (void) { return vAeroUVW; }
|
||||
inline double GetvAeroUVW (int idx) { return vAeroUVW(idx); }
|
||||
inline double GetvAeroUVW (int idx) { return vAeroUVW(idx); }
|
||||
|
||||
inline double Getalpha(void) { return alpha; }
|
||||
inline double Getbeta (void) { return beta; }
|
||||
|
|
|
@ -115,15 +115,17 @@ FGTrim::FGTrim(FGFDMExec *FDMExec,FGInitialCondition *FGIC, TrimMode tt ) {
|
|||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tRdot,tRudder ));
|
||||
break;
|
||||
case tTurn:
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tNlf,tAlpha ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tWdot,tAlpha ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tUdot,tThrottle ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tQdot,tPitchTrim ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tVdot,tBeta ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tAileron ));
|
||||
TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tRdot,tRudder ));
|
||||
//TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tVdot,tBeta ));
|
||||
//TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tAileron ));
|
||||
//TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tRdot,tRudder ));
|
||||
break;
|
||||
|
||||
}
|
||||
case tCustom:
|
||||
case tNone:
|
||||
break;
|
||||
}
|
||||
//cout << "TrimAxes.size(): " << TrimAxes.size() << endl;
|
||||
sub_iterations=new double[TrimAxes.size()];
|
||||
successful=new double[TrimAxes.size()];
|
||||
|
@ -312,14 +314,14 @@ bool FGTrim::DoTrim(void) {
|
|||
cout << "nlf done" << endl;
|
||||
} else if (mode == tTurn) {
|
||||
setupTurn();
|
||||
TrimAxes[0]->SetStateTarget(targetNlf);
|
||||
//TrimAxes[0]->SetStateTarget(targetNlf);
|
||||
}
|
||||
|
||||
do {
|
||||
axis_count=0;
|
||||
for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
|
||||
setDebug();
|
||||
|
||||
updateRates();
|
||||
Nsub=0;
|
||||
if(!solution[current_axis]) {
|
||||
if(checkLimits()) {
|
||||
|
@ -595,30 +597,33 @@ void FGTrim::setupPullup() {
|
|||
<< fgic->GetVtrueFpsIC() << endl;
|
||||
q=g*(targetNlf-cgamma)/fgic->GetVtrueFpsIC();
|
||||
cout << targetNlf << ", " << q << endl;
|
||||
vPQR.InitMatrix();
|
||||
vPQR(2)=q;
|
||||
cout << vPQR << endl;
|
||||
fdmex->GetRotation()->SetPQR(vPQR);
|
||||
fdmex->GetRotation()->SetPQR(0,q,0);
|
||||
cout << "setPitchRateInPullup() complete" << endl;
|
||||
|
||||
}
|
||||
|
||||
void FGTrim::setupTurn(void){
|
||||
FGColumnVector3 vPQR;
|
||||
float g,q,r,phi, psidot;
|
||||
double g,phi;
|
||||
phi = fgic->GetRollAngleRadIC();
|
||||
if( fabs(phi) > 0.01 && fabs(phi) < 1.56 ) {
|
||||
targetNlf = 1 / cos(phi);
|
||||
g = fdmex->GetInertial()->gravity();
|
||||
psidot = g*tan(phi) / fgic->GetVtrueFpsIC();
|
||||
q = psidot*sin(phi);
|
||||
r = psidot*cos(phi);
|
||||
vPQR(1)=0;vPQR(2)=q;vPQR(3)=r;
|
||||
fdmex->GetRotation()->SetPQR(vPQR);
|
||||
cout << targetNlf << ", " << vPQR*57.29577 << endl;
|
||||
cout << targetNlf << ", " << psidot << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void FGTrim::updateRates(void){
|
||||
if(mode == tTurn) {
|
||||
double p,q,r,theta,phi;
|
||||
theta=fgic->GetPitchAngleRadIC();
|
||||
phi=fgic->GetRollAngleRadIC();
|
||||
p=-psidot*sin(theta);
|
||||
q=psidot*cos(theta)*sin(phi);
|
||||
r=psidot*cos(theta)*cos(phi);
|
||||
fdmex->GetRotation()->SetPQR(p,q,r);
|
||||
}
|
||||
}
|
||||
|
||||
void FGTrim::setDebug(void) {
|
||||
if(debug_axis == tAll ||
|
||||
|
|
|
@ -168,6 +168,8 @@ private:
|
|||
double xlo,xhi,alo,ahi;
|
||||
double targetNlf;
|
||||
int debug_axis;
|
||||
|
||||
double psidot,thetadot;
|
||||
|
||||
FGFDMExec* fdmex;
|
||||
FGInitialCondition* fgic;
|
||||
|
@ -188,6 +190,8 @@ private:
|
|||
void setupPullup(void);
|
||||
void setupTurn(void);
|
||||
|
||||
void updateRates(void);
|
||||
|
||||
void setDebug(void);
|
||||
|
||||
public:
|
||||
|
|
|
@ -72,6 +72,7 @@ FGTrimAxis::FGTrimAxis(FGFDMExec* fdex, FGInitialCondition* ic, State st,
|
|||
case tRdot: tolerance = DEFAULT_TOLERANCE / 10; break;
|
||||
case tHmgt: tolerance = 0.01; break;
|
||||
case tNlf: state_target=1.0; tolerance = 1E-5; break;
|
||||
case tAll: break;
|
||||
}
|
||||
|
||||
solver_eps=tolerance;
|
||||
|
@ -153,14 +154,15 @@ FGTrimAxis::~FGTrimAxis(void)
|
|||
|
||||
void FGTrimAxis::getState(void) {
|
||||
switch(state) {
|
||||
case tUdot: state_value=fdmex->GetTranslation()->GetUVWdot()(1)-state_target; break;
|
||||
case tVdot: state_value=fdmex->GetTranslation()->GetUVWdot()(2)-state_target; break;
|
||||
case tWdot: state_value=fdmex->GetTranslation()->GetUVWdot()(3)-state_target; break;
|
||||
case tUdot: state_value=fdmex->GetTranslation()->GetUVWdot(1)-state_target; break;
|
||||
case tVdot: state_value=fdmex->GetTranslation()->GetUVWdot(2)-state_target; break;
|
||||
case tWdot: state_value=fdmex->GetTranslation()->GetUVWdot(3)-state_target; break;
|
||||
case tQdot: state_value=fdmex->GetRotation()->GetPQRdot(2)-state_target;break;
|
||||
case tPdot: state_value=fdmex->GetRotation()->GetPQRdot(1)-state_target; break;
|
||||
case tRdot: state_value=fdmex->GetRotation()->GetPQRdot(3)-state_target; break;
|
||||
case tHmgt: state_value=computeHmgt()-state_target; break;
|
||||
case tNlf: state_value=fdmex->GetAircraft()->GetNlf()-state_target; break;
|
||||
case tAll: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,9 +452,9 @@ double FGTrimAxis::GetAvgStability( void ) {
|
|||
|
||||
void FGTrimAxis::Debug(int from)
|
||||
{
|
||||
if (debug_lvl <= 0) return;
|
||||
|
||||
if (debug_lvl & 1) { // Standard console startup message output
|
||||
if (debug_lvl <= 0) return;
|
||||
if (debug_lvl & 1 ) { // Standard console startup message output
|
||||
if (from == 0) { // Constructor
|
||||
|
||||
}
|
||||
|
@ -467,5 +469,12 @@ void FGTrimAxis::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,11 @@ void FGTurboJet::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,5 +105,11 @@ void FGTurboProp::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,5 +104,11 @@ void FGTurboShaft::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,5 +118,11 @@ void FGUtility::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,10 +87,11 @@ FGfdmSocket::FGfdmSocket(string address, int port)
|
|||
cout << "Could not create socket for FDM, error = " << errno << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGfdmSocket" << endl;
|
||||
Debug(0);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
FGfdmSocket::~FGfdmSocket()
|
||||
{
|
||||
#ifndef macintosh
|
||||
|
@ -100,14 +101,19 @@ FGfdmSocket::~FGfdmSocket()
|
|||
#ifdef __BORLANDC__
|
||||
WSACleanup();
|
||||
#endif
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGfdmSocket::Clear(void)
|
||||
{
|
||||
buffer = "";
|
||||
size = 0;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGfdmSocket::Append(const char* item)
|
||||
{
|
||||
if (size == 0) buffer += string(item);
|
||||
|
@ -115,28 +121,34 @@ void FGfdmSocket::Append(const char* item)
|
|||
size++;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGfdmSocket::Append(double item)
|
||||
{
|
||||
char s[25];
|
||||
|
||||
sprintf(s,"%12.7f\0",item);
|
||||
sprintf(s,"%12.7f",item);
|
||||
|
||||
if (size == 0) buffer += string(s);
|
||||
else buffer += string(",") + string(s);
|
||||
size++;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGfdmSocket::Append(long item)
|
||||
{
|
||||
char s[25];
|
||||
|
||||
sprintf(s,"%12d\0",item);
|
||||
sprintf(s,"%12d",item);
|
||||
|
||||
if (size == 0) buffer += string(s);
|
||||
else buffer += string(",") + string(s);
|
||||
size++;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGfdmSocket::Send(void)
|
||||
{
|
||||
buffer += string("\n");
|
||||
|
@ -146,3 +158,48 @@ void FGfdmSocket::Send(void)
|
|||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// 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 FGfdmSocket::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: FGfdmSocket" << endl;
|
||||
if (from == 1) cout << "Destroyed: FGfdmSocket" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ private:
|
|||
struct sockaddr_in scktName;
|
||||
struct hostent *host;
|
||||
string buffer;
|
||||
void Debug(int from) {}
|
||||
void Debug(int from);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,7 @@ INCLUDES
|
|||
#include "FGAuxiliary.h"
|
||||
#include "FGOutput.h"
|
||||
#include "FGConfigFile.h"
|
||||
#include "FGScript.h"
|
||||
|
||||
#ifdef FGFS
|
||||
#include <simgear/compiler.h>
|
||||
|
@ -97,42 +98,35 @@ IMPLEMENTATION
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
FGFDMExec* FDMExec;
|
||||
float cmd = 0.0;
|
||||
bool result = false;
|
||||
bool scripted = false;
|
||||
bool Scripted = false;
|
||||
FGScript* Script;
|
||||
|
||||
if (argc == 2) {
|
||||
FGConfigFile testFile(argv[1]);
|
||||
|
||||
if (!testFile.IsOpen()) {
|
||||
cout << "Script file not opened" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
testFile.GetNextConfigLine();
|
||||
if (testFile.GetValue("runscript").length() <= 0) {
|
||||
cout << "File: " << argv[1] << " is not a script file" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
scripted = true;
|
||||
} else if (argc != 3) {
|
||||
cout << endl
|
||||
if (argc != 3 && argc != 2) {
|
||||
cerr << endl
|
||||
<< " You must enter the name of a registered aircraft and reset point:"
|
||||
<< endl << endl << " FDM <aircraft name> <reset file>" << endl;
|
||||
cout << endl << " Alternatively, you may specify only the name of a script file:"
|
||||
cerr << endl << " Alternatively, you may specify only the name of a script file:"
|
||||
<< endl << endl << " FDM <script file>" << endl << endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
FDMExec = new FGFDMExec();
|
||||
|
||||
if (scripted) { // form jsbsim <scriptfile>
|
||||
result = FDMExec->LoadScript(argv[1]);
|
||||
if (argc == 2) { // SCRIPTED CASE
|
||||
|
||||
Script = new FGScript(FDMExec);
|
||||
result = Script->LoadScript(argv[1]);
|
||||
|
||||
if (!result) {
|
||||
cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Scripted = true;
|
||||
|
||||
} else { // form jsbsim <acname> <resetfile>
|
||||
|
||||
if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
|
||||
cerr << " JSBSim could not be started" << endl << endl;
|
||||
exit(-1);
|
||||
|
@ -150,7 +144,8 @@ int main(int argc, char** argv)
|
|||
//
|
||||
|
||||
FGJSBBase::Message* msg;
|
||||
while (FDMExec->Run()) {
|
||||
result = FDMExec->Run();
|
||||
while (result) {
|
||||
while (FDMExec->ReadMessage()) {
|
||||
msg = FDMExec->ProcessMessage();
|
||||
switch (msg->type) {
|
||||
|
@ -171,6 +166,12 @@ int main(int argc, char** argv)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Scripted) {
|
||||
if (!Script->RunScript()) break;
|
||||
}
|
||||
|
||||
result = FDMExec->Run();
|
||||
}
|
||||
|
||||
delete FDMExec;
|
||||
|
|
|
@ -124,5 +124,11 @@ void FGDeadBand::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,4 +128,11 @@ void FGFCSComponent::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,8 @@ bool FGFilter::Run(void)
|
|||
case eIntegrator:
|
||||
Output = Input * ca + PreviousInput1 * ca + PreviousOutput1;
|
||||
break;
|
||||
case eUnknown:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -231,5 +233,11 @@ void FGFilter::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,5 +187,11 @@ void FGGain::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,5 +110,11 @@ void FGGradient::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
|
|||
|
||||
FGKinemat::~FGKinemat()
|
||||
{
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGKinemat" << endl;
|
||||
Debug(1);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -207,5 +207,11 @@ void FGKinemat::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -177,5 +177,11 @@ void FGSummer::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,5 +110,11 @@ void FGSwitch::Debug(int from)
|
|||
}
|
||||
if (debug_lvl & 16) { // Sanity checking
|
||||
}
|
||||
if (debug_lvl & 64) {
|
||||
if (from == 0) { // Constructor
|
||||
cout << IdSrc << endl;
|
||||
cout << IdHdr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue