diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 714e5d184..05d5074da 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -72,7 +72,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.191 2016/05/16 18:19:57 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.193 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -650,24 +650,26 @@ vector FGFDMExec::EnumerateFDMs(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadScript(const string& script, double deltaT, const string& initfile)
+bool FGFDMExec::LoadScript(const SGPath& script, double deltaT,
+ const SGPath& initfile)
{
bool result;
Script = new FGScript(this);
- result = Script->LoadScript(RootDir + script, deltaT, initfile);
+ result = Script->LoadScript(GetFullPath(script), deltaT, initfile);
return result;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
- const string& model, bool addModelToPath)
+bool FGFDMExec::LoadModel(const SGPath& AircraftPath, const SGPath& EnginePath,
+ const SGPath& SystemsPath, const string& model,
+ bool addModelToPath)
{
- FGFDMExec::AircraftPath = RootDir + AircraftPath;
- FGFDMExec::EnginePath = RootDir + EnginePath;
- FGFDMExec::SystemsPath = RootDir + SystemsPath;
+ FGFDMExec::AircraftPath = GetFullPath(AircraftPath);
+ FGFDMExec::EnginePath = GetFullPath(EnginePath);
+ FGFDMExec::SystemsPath = GetFullPath(SystemsPath);
return LoadModel(model, addModelToPath);
}
@@ -676,20 +678,20 @@ bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath,
bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
{
- string aircraftCfgFileName;
+ SGPath aircraftCfgFileName;
bool result = false; // initialize result to false, indicating input file not yet read
modelName = model; // Set the class modelName attribute
- if( AircraftPath.empty() || EnginePath.empty() || SystemsPath.empty()) {
+ if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) {
cerr << "Error: attempted to load aircraft with undefined ";
cerr << "aircraft, engine, and system paths" << endl;
return false;
}
FullAircraftPath = AircraftPath;
- if (addModelToPath) FullAircraftPath += "/" + model;
- aircraftCfgFileName = FullAircraftPath + "/" + model + ".xml";
+ if (addModelToPath) FullAircraftPath.append(model);
+ aircraftCfgFileName = FullAircraftPath/(model + ".xml");
if (modelLoaded) {
DeAllocate();
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index 03e3ae799..f59810d40 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -49,12 +49,13 @@ INCLUDES
#include "models/FGPropagate.h"
#include "math/FGColumnVector3.h"
#include "models/FGOutput.h"
+#include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.105 2016/04/16 12:24:39 bcoconni Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.106 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -178,7 +179,7 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
- @version $Revision: 1.105 $
+ @version $Revision: 1.106 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -284,8 +285,8 @@ public:
@param addModelToPath set to true to add the model name to the
AircraftPath, defaults to true
@return true if successful */
- bool LoadModel(const std::string& AircraftPath, const std::string& EnginePath,
- const std::string& SystemsPath, const std::string& model,
+ bool LoadModel(const SGPath& AircraftPath, const SGPath& EnginePath,
+ const SGPath& SystemsPath, const std::string& model,
bool addModelToPath = true);
/** Loads an aircraft model. The paths to the aircraft and engine
@@ -310,24 +311,33 @@ public:
the file specified in the script will be used. If an initialization file
is not given in either place, an error will result.
@return true if successfully loads; false otherwise. */
- bool LoadScript(const std::string& Script, double deltaT=0.0,
- const std::string& initfile="");
+ bool LoadScript(const SGPath& Script, double deltaT=0.0,
+ const SGPath& initfile=SGPath());
/** 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" */
- bool SetEnginePath(const std::string& path) { EnginePath = RootDir + path; return true; }
+ bool SetEnginePath(const SGPath& path) {
+ EnginePath = GetFullPath(path);
+ return true;
+ }
/** Sets the path to the aircraft config file directories.
@param path path to the aircraft directory. For instance:
"aircraft". Under aircraft, then, would be directories for various
modeled aircraft such as C172/, x15/, etc. */
- bool SetAircraftPath(const std::string& path) { AircraftPath = RootDir + path; return true; }
+ bool SetAircraftPath(const SGPath& path) {
+ AircraftPath = GetFullPath(path);
+ return true;
+ }
/** Sets the path to the systems config file directories.
@param path path to the directory under which systems config
files are kept, for instance "systems" */
- bool SetSystemsPath(const std::string& path) { SystemsPath = RootDir + path; return true; }
+ bool SetSystemsPath(const SGPath& path) {
+ SystemsPath = GetFullPath(path);
+ return true;
+ }
/// @name Top-level executive State and Model retrieval mechanism
///@{
@@ -378,13 +388,13 @@ public:
///@}
/// Retrieves the engine path.
- const std::string& GetEnginePath(void) {return EnginePath;}
+ const SGPath& GetEnginePath(void) {return EnginePath;}
/// Retrieves the aircraft path.
- const std::string& GetAircraftPath(void) {return AircraftPath;}
+ const SGPath& GetAircraftPath(void) {return AircraftPath;}
/// Retrieves the systems path.
- const std::string& GetSystemsPath(void) {return SystemsPath;}
+ const SGPath& GetSystemsPath(void) {return SystemsPath;}
/// Retrieves the full aircraft path name.
- const std::string& GetFullAircraftPath(void) {return FullAircraftPath;}
+ const SGPath& GetFullAircraftPath(void) {return FullAircraftPath;}
/** Retrieves the value of a property.
@param property the name of the property
@@ -428,8 +438,8 @@ public:
be logged.
@param fname the filename of an output directives file.
*/
- bool SetOutputDirectives(const std::string& fname)
- {return Output->SetDirectivesFile(RootDir + fname);}
+ bool SetOutputDirectives(const SGPath& fname)
+ { return Output->SetDirectivesFile(GetFullPath(fname)); }
/** Forces the specified output object to print its items once */
void ForceOutput(int idx=0) { Output->ForceOutput(idx); }
@@ -550,11 +560,11 @@ public:
/** Sets the root directory where JSBSim starts looking for its system directories.
@param rootDir the string containing the root directory. */
- void SetRootDir(const std::string& rootDir) {RootDir = rootDir;}
+ void SetRootDir(const SGPath& rootDir) {RootDir = rootDir;}
/** Retrieves the Root Directory.
@return the string representing the root (base) JSBSim directory. */
- const std::string& GetRootDir(void) const {return RootDir;}
+ const SGPath& GetRootDir(void) const {return RootDir;}
/** Increments the simulation time if not in Holding mode. The Frame counter
is also incremented.
@@ -606,13 +616,13 @@ private:
bool modelLoaded;
bool IsChild;
std::string modelName;
- std::string AircraftPath;
- std::string FullAircraftPath;
- std::string EnginePath;
- std::string SystemsPath;
+ SGPath AircraftPath;
+ SGPath FullAircraftPath;
+ SGPath EnginePath;
+ SGPath SystemsPath;
std::string CFGVersion;
std::string Release;
- std::string RootDir;
+ SGPath RootDir;
// Standard Model pointers - shortcuts for internal executive use only.
FGPropagate* Propagate;
@@ -664,6 +674,12 @@ private:
bool Allocate(void);
bool DeAllocate(void);
int GetDisperse(void) const {return disperse;}
+ SGPath GetFullPath(const SGPath& name) {
+ if (name.isRelative())
+ return RootDir/name.utf8Str();
+ else
+ return name;
+ }
void Debug(int from);
};
diff --git a/src/FDM/JSBSim/JSBSim.cpp b/src/FDM/JSBSim/JSBSim.cpp
index 87b5e6ec9..3561bff71 100644
--- a/src/FDM/JSBSim/JSBSim.cpp
+++ b/src/FDM/JSBSim/JSBSim.cpp
@@ -77,18 +77,18 @@ using JSBSim::Element;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-IDENT(IdSrc,"$Id: JSBSim.cpp,v 1.89 2016/05/20 14:14:05 ehofman Exp $");
+IDENT(IdSrc,"$Id: JSBSim.cpp,v 1.90 2017/02/25 14:23:18 bcoconni Exp $");
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-string RootDir = "";
-string ScriptName;
+SGPath RootDir;
+SGPath ScriptName;
string AircraftName;
-string ResetName;
+SGPath ResetName;
vector LogOutputName;
-vector LogDirectiveName;
+vector LogDirectiveName;
vector CommandLineProperties;
vector CommandLinePropertyValues;
JSBSim::FGFDMExec* FDMExec;
@@ -151,28 +151,28 @@ void PrintHelp(void);
of file is given on the command line */
class XMLFile : public FGXMLFileRead {
public:
- bool IsScriptFile(std::string filename) {
+ bool IsScriptFile(const SGPath& filename) {
bool result=false;
Element *document = LoadXMLDocument(filename, false);
if (document && document->GetName() == "runscript") result = true;
ResetParser();
return result;
}
- bool IsLogDirectiveFile(std::string filename) {
+ bool IsLogDirectiveFile(const SGPath& filename) {
bool result=false;
Element *document = LoadXMLDocument(filename, false);
if (document && document->GetName() == "output") result = true;
ResetParser();
return result;
}
- bool IsAircraftFile(std::string filename) {
+ bool IsAircraftFile(const SGPath& filename) {
bool result=false;
Element* document = LoadXMLDocument(filename, false);
if (document && document->GetName() == "fdm_config") result = true;
ResetParser();
return result;
}
- bool IsInitFile(std::string filename) {
+ bool IsInitFile(const SGPath& filename) {
bool result=false;
Element *document = LoadXMLDocument(filename, false);
if (document && document->GetName() == "initialize") result = true;
@@ -345,9 +345,9 @@ int real_main(int argc, char* argv[])
// *** SET UP JSBSIM *** //
FDMExec = new JSBSim::FGFDMExec();
FDMExec->SetRootDir(RootDir);
- FDMExec->SetAircraftPath("aircraft");
- FDMExec->SetEnginePath("engine");
- FDMExec->SetSystemsPath("systems");
+ FDMExec->SetAircraftPath(SGPath("aircraft"));
+ FDMExec->SetEnginePath(SGPath("engine"));
+ FDMExec->SetSystemsPath(SGPath("systems"));
FDMExec->GetPropertyManager()->Tie("simulation/frame_start_time", &actual_elapsed_time);
FDMExec->GetPropertyManager()->Tie("simulation/cycle_duration", &cycle_duration);
@@ -372,7 +372,7 @@ int real_main(int argc, char* argv[])
}
// *** OPTION A: LOAD A SCRIPT, WHICH LOADS EVERYTHING ELSE *** //
- if (!ScriptName.empty()) {
+ if (!ScriptName.isNull()) {
result = FDMExec->LoadScript(ScriptName, override_sim_rate_value, ResetName);
@@ -383,14 +383,14 @@ int real_main(int argc, char* argv[])
}
// *** OPTION B: LOAD AN AIRCRAFT AND A SET OF INITIAL CONDITIONS *** //
- } else if (!AircraftName.empty() || !ResetName.empty()) {
+ } else if (!AircraftName.empty() || !ResetName.isNull()) {
if (catalog) FDMExec->SetDebugLevel(0);
- if ( ! FDMExec->LoadModel( "aircraft",
- "engine",
- "systems",
- AircraftName)) {
+ if ( ! FDMExec->LoadModel(SGPath("aircraft"),
+ SGPath("engine"),
+ SGPath("systems"),
+ AircraftName)) {
cerr << " JSBSim could not be started" << endl << endl;
delete FDMExec;
exit(-1);
@@ -417,7 +417,7 @@ int real_main(int argc, char* argv[])
// Load output directives file[s], if given
for (unsigned int i=0; iSetOutputDirectives(LogDirectiveName[i])) {
cout << "Output directives not properly set in file " << LogDirectiveName[i] << endl;
delete FDMExec;
@@ -621,17 +621,14 @@ bool options(int count, char **arg)
}
} else if (keyword == "--logdirectivefile") {
if (n != string::npos) {
- LogDirectiveName.push_back(value);
+ LogDirectiveName.push_back(SGPath::fromLocal8Bit(value.c_str()));
} else {
gripe;
exit(1);
}
} else if (keyword == "--root") {
if (n != string::npos) {
- RootDir = value;
- if (RootDir[RootDir.length()-1] != '/') {
- RootDir += '/';
- }
+ RootDir = SGPath::fromLocal8Bit(value.c_str());
} else {
gripe;
exit(1);
@@ -645,14 +642,14 @@ bool options(int count, char **arg)
}
} else if (keyword == "--script") {
if (n != string::npos) {
- ScriptName = value;
+ ScriptName = SGPath::fromLocal8Bit(value.c_str());
} else {
gripe;
exit(1);
}
} else if (keyword == "--initfile") {
if (n != string::npos) {
- ResetName = value;
+ ResetName = SGPath::fromLocal8Bit(value.c_str());
} else {
gripe;
exit(1);
@@ -704,12 +701,13 @@ bool options(int count, char **arg)
// See what kind of files we are specifying on the command line
XMLFile xmlFile;
+ SGPath path = SGPath::fromLocal8Bit(keyword.c_str());
- if (xmlFile.IsScriptFile(keyword)) ScriptName = keyword;
- else if (xmlFile.IsLogDirectiveFile(keyword)) LogDirectiveName.push_back(keyword);
- else if (xmlFile.IsAircraftFile("aircraft/" + keyword + "/" + keyword)) AircraftName = keyword;
- else if (xmlFile.IsInitFile(keyword)) ResetName = keyword;
- else if (xmlFile.IsInitFile("aircraft/" + AircraftName + "/" + keyword)) ResetName = keyword;
+ if (xmlFile.IsScriptFile(path)) ScriptName = path;
+ else if (xmlFile.IsLogDirectiveFile(path)) LogDirectiveName.push_back(path);
+ else if (xmlFile.IsAircraftFile(SGPath("aircraft")/keyword/keyword)) AircraftName = keyword;
+ else if (xmlFile.IsInitFile(path)) ResetName = path;
+ else if (xmlFile.IsInitFile(SGPath("aircraft")/AircraftName/keyword)) ResetName = SGPath("aircraft")/AircraftName/keyword;
else {
cerr << "The argument \"" << keyword << "\" cannot be interpreted as a file name or option." << endl;
exit(1);
@@ -727,15 +725,15 @@ bool options(int count, char **arg)
// Post-processing for script options. check for incompatible options.
- if (catalog && !ScriptName.empty()) {
+ if (catalog && !ScriptName.isNull()) {
cerr << "Cannot specify catalog with script option" << endl << endl;
result = false;
}
- if (AircraftName.size() > 0 && ResetName.size() == 0 && !catalog) {
+ if (!AircraftName.empty() && ResetName.isNull() && !catalog) {
cerr << "You must specify an initialization file with the aircraft name." << endl << endl;
result = false;
}
- if (ScriptName.size() > 0 && AircraftName.size() > 0) {
+ if (!ScriptName.isNull() && !AircraftName.empty()) {
cerr << "You cannot specify an aircraft file with a script." << endl;
result = false;
}
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index 745f9ad97..0dac1d72f 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -234,9 +234,7 @@ FGJSBsim::FGJSBsim( double dt )
fdmex->Setdt( dt );
- result = fdmex->LoadModel( aircraft_path.local8BitStr(),
- engine_path.local8BitStr(),
- systems_path.local8BitStr(),
+ result = fdmex->LoadModel( aircraft_path, engine_path, systems_path,
fgGetString("/sim/aero"), false );
if (result) {
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
index d71317ce1..10ba4d960 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp
@@ -58,7 +58,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.111 2016/07/03 17:20:55 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.114 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_INITIALCONDITION);
//******************************************************************************
@@ -709,10 +709,10 @@ void FGInitialCondition::SetAltitudeASLFtIC(double alt)
altitudeASL=alt;
position.SetAltitudeASL(alt);
- if (lastLatitudeSet == setgeod) {
- double h = ComputeGeodAltitude(geodLatitude);
- position.SetPositionGeodetic(position.GetLongitude(), geodLatitude, h);
- }
+ // The call to SetAltitudeASL has most likely modified the geodetic latitude
+ // so we need to restore it to its initial value.
+ if (lastLatitudeSet == setgeod)
+ SetGeodLatitudeRadIC(geodLatitude);
soundSpeed = Atmosphere->GetSoundSpeed(altitudeASL);
rho = Atmosphere->GetDensity(altitudeASL);
@@ -880,11 +880,11 @@ double FGInitialCondition::GetBodyVelFpsIC(int idx) const
//******************************************************************************
-bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
+bool FGInitialCondition::Load(const SGPath& rstfile, bool useStoredPath)
{
- string init_file_name;
- if( useStoredPath ) {
- init_file_name = fdmex->GetFullAircraftPath() + "/" + rstfile + ".xml";
+ SGPath init_file_name;
+ if(useStoredPath && rstfile.isRelative()) {
+ init_file_name = fdmex->GetFullAircraftPath()/rstfile.utf8Str();
} else {
init_file_name = rstfile;
}
@@ -931,16 +931,11 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
}
//******************************************************************************
-// Given an altitude above the sea level (or a position radius which is the
-// same) and a geodetic latitude, compute the geodetic altitude. It is assumed
-// that the terrain is a sphere and that the elevation is uniform all over the
-// Earth. Would that assumption fail, the computation below would need to be
-// adapted since the position radius would depend on the terrain elevation which
-// depends itself on the latitude.
+// Given an altitude above the mean sea level (or a position radius which is the
+// same) and a geodetic latitude, compute the geodetic altitude.
//
-// This is an acceptable trade off because this routine is only used by
-// standalone JSBSim which uses FGDefaultGroundCallback which assumes that the
-// Earth is a sphere.
+// TODO: extend the routine to the case where lastAltitudeSet is equal to
+// setagl.
double FGInitialCondition::ComputeGeodAltitude(double geodLatitude)
{
@@ -978,11 +973,8 @@ bool FGInitialCondition::LoadLatitude(Element* position_el)
string lat_type = latitude_el->GetAttributeValue("type");
- if (lat_type == "geod" || lat_type == "geodetic") {
- double h = ComputeGeodAltitude(latitude);
- position.SetPositionGeodetic(position.GetLongitude(), latitude, h);
- lastLatitudeSet = setgeod;
- }
+ if (lat_type == "geod" || lat_type == "geodetic")
+ SetGeodLatitudeRadIC(latitude);
else {
position.SetLatitude(latitude);
lastLatitudeSet = setgeoc;
@@ -1491,10 +1483,14 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager)
&FGInitialCondition::GetRRadpsIC,
&FGInitialCondition::SetRRadpsIC,
true);
- PropertyManager->Tie("ic/lat-geod-rad", &position,
- &FGLocation::GetGeodLatitudeRad);
- PropertyManager->Tie("ic/lat-geod-deg", &position,
- &FGLocation::GetGeodLatitudeDeg);
+ PropertyManager->Tie("ic/lat-geod-rad", this,
+ &FGInitialCondition::GetGeodLatitudeRadIC,
+ &FGInitialCondition::SetGeodLatitudeRadIC,
+ true);
+ PropertyManager->Tie("ic/lat-geod-deg", this,
+ &FGInitialCondition::GetGeodLatitudeDegIC,
+ &FGInitialCondition::SetGeodLatitudeDegIC,
+ true);
PropertyManager->Tie("ic/geod-alt-ft", &position,
&FGLocation::GetGeodAltitude);
}
diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.h b/src/FDM/JSBSim/initialization/FGInitialCondition.h
index 02af89c06..e9d209cbf 100644
--- a/src/FDM/JSBSim/initialization/FGInitialCondition.h
+++ b/src/FDM/JSBSim/initialization/FGInitialCondition.h
@@ -49,12 +49,13 @@ INCLUDES
#include "math/FGLocation.h"
#include "math/FGQuaternion.h"
+#include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.46 2016/07/03 17:20:55 bcoconni Exp $"
+#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.48 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -220,7 +221,7 @@ CLASS DOCUMENTATION
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden
- @version "$Id: FGInitialCondition.h,v 1.46 2016/07/03 17:20:55 bcoconni Exp $"
+ @version "$Id: FGInitialCondition.h,v 1.48 2017/02/25 14:23:18 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -311,6 +312,13 @@ public:
@param lat Initial latitude in degrees */
void SetLatitudeDegIC(double lat) { SetLatitudeRadIC(lat*degtorad); }
+ /** Sets the initial geodetic latitude.
+ This method modifies the geodetic altitude in order to keep the altitude
+ above sea level unchanged.
+ @param glat Initial geodetic latitude in degrees */
+ void SetGeodLatitudeDegIC(double glat)
+ { SetGeodLatitudeRadIC(glat*degtorad); }
+
/** Sets the initial longitude.
@param lon Initial longitude in degrees */
void SetLongitudeDegIC(double lon) { SetLongitudeRadIC(lon*degtorad); }
@@ -369,6 +377,11 @@ public:
@return Initial geocentric latitude in degrees */
double GetLatitudeDegIC(void) const { return position.GetLatitudeDeg(); }
+ /** Gets the initial geodetic latitude.
+ @return Initial geodetic latitude in degrees */
+ double GetGeodLatitudeDegIC(void) const
+ { return position.GetGeodLatitudeDeg(); }
+
/** Gets the initial longitude.
@return Initial longitude in degrees */
double GetLongitudeDegIC(void) const { return position.GetLongitudeDeg(); }
@@ -628,6 +641,11 @@ public:
@return Initial latitude in radians */
double GetLatitudeRadIC(void) const { return position.GetLatitude(); }
+ /** Gets the initial geodetic latitude.
+ @return Initial geodetic latitude in radians */
+ double GetGeodLatitudeRadIC(void) const
+ { return position.GetGeodLatitudeRad(); }
+
/** Gets the initial longitude.
@return Initial longitude in radians */
double GetLongitudeRadIC(void) const { return position.GetLongitude(); }
@@ -660,7 +678,7 @@ public:
@param rstname The name of an initial conditions file
@param useStoredPath true if the stored path to the IC file should be used
@return true if successful */
- bool Load(std::string rstname, bool useStoredPath = true );
+ bool Load(const SGPath& rstname, bool useStoredPath = true );
/** Is an engine running ?
@param index of the engine to be checked
diff --git a/src/FDM/JSBSim/input_output/FGModelLoader.cpp b/src/FDM/JSBSim/input_output/FGModelLoader.cpp
index 45378efc4..919520b11 100644
--- a/src/FDM/JSBSim/input_output/FGModelLoader.cpp
+++ b/src/FDM/JSBSim/input_output/FGModelLoader.cpp
@@ -46,7 +46,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc, "$Id: FGModelLoader.cpp,v 1.3 2015/07/12 12:41:55 bcoconni Exp $");
+IDENT(IdSrc, "$Id: FGModelLoader.cpp,v 1.4 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr, ID_MODELLOADER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -60,28 +60,21 @@ Element_ptr FGModelLoader::Open(Element *el)
if (!fname.empty()) {
FGXMLFileRead XMLFileRead;
- string file;
+ SGPath path(SGPath::fromLocal8Bit(fname.c_str()));
- try {
- file = model->FindFullPathName(fname);
- if (file.empty()) throw string("File does not exist.");
- }
- catch(string& e) {
- cerr << endl << el->ReadFrom()
- << "Could not open file: " << fname << endl << e << endl;
- return NULL;
- }
+ if (path.isRelative())
+ path = model->FindFullPathName(path);
- if (CachedFiles.find(file) != CachedFiles.end())
- document = CachedFiles[file];
+ if (CachedFiles.find(path.utf8Str()) != CachedFiles.end())
+ document = CachedFiles[path.utf8Str()];
else {
- document = XMLFileRead.LoadXMLDocument(file);
+ document = XMLFileRead.LoadXMLDocument(path);
if (document == 0L) {
cerr << endl << el->ReadFrom()
- << "Could not open file: " << file << endl;
+ << "Could not open file: " << path << endl;
return NULL;
}
- CachedFiles[file] = document;
+ CachedFiles[path.utf8Str()] = document;
}
if (document->GetName() != el->GetName()) {
@@ -93,19 +86,12 @@ Element_ptr FGModelLoader::Open(Element *el)
return document;
}
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SGPath CheckPathName(const SGPath& path, const SGPath& filename) {
+ SGPath fullName = path/filename.utf8Str();
-string CheckFullPathName(const string& path, const string& fname)
-{
- string name = path + "/" + fname;
+ if (fullName.extension().empty())
+ fullName.concat(".xml");
- if (name.length() <=4 || name.substr(name.length()-4, 4) != ".xml")
- name.append(".xml");
-
- ifstream file(name.c_str());
- if (!file.is_open())
- return string();
-
- return name;
+ return fullName.exists() ? fullName : SGPath();
}
}
diff --git a/src/FDM/JSBSim/input_output/FGModelLoader.h b/src/FDM/JSBSim/input_output/FGModelLoader.h
index 4c2b937c9..6b18a0a8b 100644
--- a/src/FDM/JSBSim/input_output/FGModelLoader.h
+++ b/src/FDM/JSBSim/input_output/FGModelLoader.h
@@ -41,12 +41,13 @@ INCLUDES
#include
#include "FGXMLElement.h"
+#include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MODELLOADER "$Id: FGModelLoader.h,v 1.1 2014/06/09 11:52:06 bcoconni Exp $"
+#define ID_MODELLOADER "$Id: FGModelLoader.h,v 1.2 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -75,7 +76,7 @@ private:
std::map CachedFiles;
};
- std::string CheckFullPathName(const std::string& path, const std::string& fname);
+SGPath CheckPathName(const SGPath& path, const SGPath& filename);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
diff --git a/src/FDM/JSBSim/input_output/FGOutputFile.cpp b/src/FDM/JSBSim/input_output/FGOutputFile.cpp
index 6e1024037..f75b09d7e 100644
--- a/src/FDM/JSBSim/input_output/FGOutputFile.cpp
+++ b/src/FDM/JSBSim/input_output/FGOutputFile.cpp
@@ -47,7 +47,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutputFile.cpp,v 1.9 2014/05/04 17:00:27 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutputFile.cpp,v 1.10 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUTFILE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -65,8 +65,8 @@ FGOutputFile::FGOutputFile(FGFDMExec* fdmex) :
bool FGOutputFile::InitModel(void)
{
if (FGOutputType::InitModel()) {
- if (Filename.empty()) {
- Filename = Name;
+ if (Filename.isNull()) {
+ Filename = SGPath(Name);
runID_postfix = 0;
}
return OpenFile();
@@ -87,7 +87,7 @@ void FGOutputFile::SetStartNewOutput(void)
} else {
buf << Name << '_' << runID_postfix++;
}
- Filename = buf.str();
+ Filename = SGPath(buf.str());
}
CloseFile();
diff --git a/src/FDM/JSBSim/input_output/FGOutputFile.h b/src/FDM/JSBSim/input_output/FGOutputFile.h
index da74607da..cab11906a 100644
--- a/src/FDM/JSBSim/input_output/FGOutputFile.h
+++ b/src/FDM/JSBSim/input_output/FGOutputFile.h
@@ -45,7 +45,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUTFILE "$Id: FGOutputFile.h,v 1.6 2014/05/04 17:00:27 bcoconni Exp $"
+#define ID_OUTPUTFILE "$Id: FGOutputFile.h,v 1.8 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -106,9 +106,9 @@ public:
the next call to SetStartNewOutput().
@param name new name */
void SetOutputName(const std::string& fname) {
- Name = FDMExec->GetRootDir() + fname;
+ Name = (FDMExec->GetRootDir()/fname).utf8Str();
runID_postfix = -1;
- Filename = std::string();
+ Filename = SGPath();
}
/** Generate the output. This is a pure method so it must be implemented by
the classes that inherits from FGOutputFile.
@@ -116,7 +116,7 @@ public:
void Print(void) = 0;
protected:
- std::string Filename;
+ SGPath Filename;
/// Opens the file
virtual bool OpenFile(void) = 0;
diff --git a/src/FDM/JSBSim/input_output/FGOutputTextFile.cpp b/src/FDM/JSBSim/input_output/FGOutputTextFile.cpp
index 569408e46..40e81f716 100644
--- a/src/FDM/JSBSim/input_output/FGOutputTextFile.cpp
+++ b/src/FDM/JSBSim/input_output/FGOutputTextFile.cpp
@@ -64,7 +64,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutputTextFile.cpp,v 1.12 2016/05/22 10:28:23 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutputTextFile.cpp,v 1.13 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUTTEXTFILE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -96,7 +96,7 @@ bool FGOutputTextFile::Load(Element* el)
bool FGOutputTextFile::OpenFile(void)
{
datafile.clear();
- datafile.open(Filename.c_str());
+ datafile.open(Filename);
if (!datafile) {
cerr << endl << fgred << highint << "ERROR: unable to open the file "
<< reset << Filename.c_str() << endl
@@ -261,9 +261,9 @@ bool FGOutputTextFile::OpenFile(void)
void FGOutputTextFile::Print(void)
{
streambuf* buffer;
- string scratch = "";
+ string scratch = Filename.utf8Str();
- if (Filename == "COUT" || Filename == "cout") {
+ if (to_upper(scratch) == "COUT") {
buffer = cout.rdbuf();
} else {
buffer = datafile.rdbuf();
diff --git a/src/FDM/JSBSim/input_output/FGOutputTextFile.h b/src/FDM/JSBSim/input_output/FGOutputTextFile.h
index b3c9e1ec4..0dc31c160 100644
--- a/src/FDM/JSBSim/input_output/FGOutputTextFile.h
+++ b/src/FDM/JSBSim/input_output/FGOutputTextFile.h
@@ -41,12 +41,13 @@ INCLUDES
#include
#include "FGOutputFile.h"
+#include "simgear/io/iostreams/sgstream.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUTTEXTFILE "$Id: FGOutputTextFile.h,v 1.4 2012/12/15 16:13:58 bcoconni Exp $"
+#define ID_OUTPUTTEXTFILE "$Id: FGOutputTextFile.h,v 1.5 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -89,7 +90,7 @@ public:
protected:
std::string delimeter;
- std::ofstream datafile;
+ sg_ofstream datafile;
virtual bool OpenFile(void);
virtual void CloseFile(void) { if (datafile.is_open()) datafile.close(); }
diff --git a/src/FDM/JSBSim/input_output/FGScript.cpp b/src/FDM/JSBSim/input_output/FGScript.cpp
index a3a7e32aa..38639a465 100644
--- a/src/FDM/JSBSim/input_output/FGScript.cpp
+++ b/src/FDM/JSBSim/input_output/FGScript.cpp
@@ -58,7 +58,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGScript.cpp,v 1.64 2016/04/03 17:10:46 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGScript.cpp,v 1.65 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_FGSCRIPT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -96,10 +96,11 @@ FGScript::~FGScript()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGScript::LoadScript(const string& script, double default_dT,
- const string& initfile)
+bool FGScript::LoadScript(const SGPath& script, double default_dT,
+ const SGPath& initfile)
{
- string aircraft="", initialize="", prop_name="";
+ SGPath initialize;
+ string aircraft="", prop_name="";
string notifyPropertyName="";
Element *element=0, *run_element=0, *event_element=0;
Element *set_element=0;
@@ -171,9 +172,9 @@ bool FGScript::LoadScript(const string& script, double default_dT,
return false;
}
- if (initfile.empty()) {
- initialize = element->GetAttributeValue("initialize");
- if (initialize.empty()) {
+ initialize = SGPath::fromLocal8Bit(element->GetAttributeValue("initialize").c_str());
+ if (initfile.isNull()) {
+ if (initialize.isNull()) {
cerr << "Initialization file must be specified in use element." << endl;
return false;
}
diff --git a/src/FDM/JSBSim/input_output/FGScript.h b/src/FDM/JSBSim/input_output/FGScript.h
index c49200629..611648565 100644
--- a/src/FDM/JSBSim/input_output/FGScript.h
+++ b/src/FDM/JSBSim/input_output/FGScript.h
@@ -43,12 +43,13 @@ INCLUDES
#include "FGJSBBase.h"
#include "FGPropertyReader.h"
#include "input_output/FGPropertyManager.h"
+#include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FGSCRIPT "$Id: FGScript.h,v 1.30 2015/09/20 16:32:11 bcoconni Exp $"
+#define ID_FGSCRIPT "$Id: FGScript.h,v 1.31 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -161,7 +162,7 @@ CLASS DOCUMENTATION
comes the "run" section, where the conditions are
described in "event" clauses.
@author Jon S. Berndt
- @version "$Id: FGScript.h,v 1.30 2015/09/20 16:32:11 bcoconni Exp $"
+ @version "$Id: FGScript.h,v 1.31 2017/02/25 14:23:18 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -188,8 +189,8 @@ public:
default. If a file name is passed in, it will override the
one present in the script.
@return true if successful */
- bool LoadScript(const std::string& script, double default_dT,
- const std::string& initfile);
+ bool LoadScript(const SGPath& script, double default_dT,
+ const SGPath& initfile);
/** This function is called each pass through the executive Run() method IF
scripting is enabled.
diff --git a/src/FDM/JSBSim/input_output/FGXMLElement.cpp b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
index ac9fb7094..799445e04 100644
--- a/src/FDM/JSBSim/input_output/FGXMLElement.cpp
+++ b/src/FDM/JSBSim/input_output/FGXMLElement.cpp
@@ -45,7 +45,7 @@ FORWARD DECLARATIONS
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGXMLElement.cpp,v 1.55 2016/01/02 15:23:50 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGXMLElement.cpp,v 1.56 2016/09/11 11:26:04 bcoconni Exp $");
IDENT(IdHdr,ID_XMLELEMENT);
bool Element::converterIsInitialized = false;
@@ -467,12 +467,14 @@ double Element::FindElementValueAsNumberConvertTo(const string& el, const string
// Sanity check for angular values
if ((supplied_units == "RAD") && (fabs(value) > 2 * M_PI)) {
- cerr << element->ReadFrom() << "The value " << value
- << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
+ cerr << element->ReadFrom() << element->GetName() << " value "
+ << value << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]"
+ << endl;
}
if ((supplied_units == "DEG") && (fabs(value) > 360.0)) {
- cerr << element->ReadFrom() << "The value " << value
- << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
+ cerr << element->ReadFrom() << element->GetName() << " value "
+ << value << " DEG is outside the range [ -360 DEG ; +360 DEG ]"
+ << endl;
}
@@ -481,12 +483,14 @@ double Element::FindElementValueAsNumberConvertTo(const string& el, const string
}
if ((target_units == "RAD") && (fabs(value) > 2 * M_PI)) {
- cerr << element->ReadFrom() << "The value " << value
- << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]" << endl;
+ cerr << element->ReadFrom() << element->GetName() << " value "
+ << value << " RAD is outside the range [ -2*M_PI RAD ; +2*M_PI RAD ]"
+ << endl;
}
if ((target_units == "DEG") && (fabs(value) > 360.0)) {
- cerr << element->ReadFrom() << "The value " << value
- << " DEG is outside the range [ -360 DEG ; +360 DEG ]" << endl;
+ cerr << element->ReadFrom() << element->GetName() << " value "
+ << value << " DEG is outside the range [ -360 DEG ; +360 DEG ]"
+ << endl;
}
value = DisperseValue(element, value, supplied_units, target_units);
diff --git a/src/FDM/JSBSim/input_output/FGXMLFileRead.h b/src/FDM/JSBSim/input_output/FGXMLFileRead.h
index 1c912862a..62bc3421c 100644
--- a/src/FDM/JSBSim/input_output/FGXMLFileRead.h
+++ b/src/FDM/JSBSim/input_output/FGXMLFileRead.h
@@ -35,15 +35,18 @@ SENTRY
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "input_output/FGXMLParse.h"
#include
#include
+#include "input_output/FGXMLParse.h"
+#include "simgear/misc/sg_path.hxx"
+#include "simgear/io/iostreams/sgstream.hxx"
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.9 2013/12/01 14:33:51 bcoconni Exp $"
+#define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.10 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -56,20 +59,23 @@ public:
FGXMLFileRead(void) {}
~FGXMLFileRead(void) {}
- Element* LoadXMLDocument(std::string XML_filename, bool verbose=true)
+ Element* LoadXMLDocument(const SGPath& XML_filename, bool verbose=true)
{
return LoadXMLDocument(XML_filename, file_parser, verbose);
}
- Element* LoadXMLDocument(std::string XML_filename, FGXMLParse& fparse, bool verbose=true)
+ Element* LoadXMLDocument(const SGPath& XML_filename, FGXMLParse& fparse, bool verbose=true)
{
- std::ifstream infile;
+ sg_ifstream infile;
+ SGPath filename(XML_filename);
- if ( !XML_filename.empty() ) {
- if (XML_filename.find(".xml") == std::string::npos) XML_filename += ".xml";
- infile.open(XML_filename.c_str());
+ if (!filename.isNull()) {
+ if (filename.extension().empty())
+ filename.concat(".xml");
+
+ infile.open(filename);
if ( !infile.is_open()) {
- if (verbose) std::cerr << "Could not open file: " << XML_filename << std::endl;
+ if (verbose) std::cerr << "Could not open file: " << filename << std::endl;
return 0L;
}
} else {
@@ -77,7 +83,7 @@ public:
return 0L;
}
- readXML(infile, fparse, XML_filename);
+ readXML(infile, fparse, filename.utf8Str());
Element* document = fparse.GetDocument();
infile.close();
diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp
index 134a88f3d..cd8c28fe5 100644
--- a/src/FDM/JSBSim/models/FGFCS.cpp
+++ b/src/FDM/JSBSim/models/FGFCS.cpp
@@ -70,7 +70,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.95 2016/05/16 18:19:57 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFCS.cpp,v 1.98 2017/02/25 14:23:18 bcoconni Exp $");
IDENT(IdHdr,ID_FCS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -602,16 +602,15 @@ double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFCS::FindFullPathName(const string& sysfilename) const
+SGPath FGFCS::FindFullPathName(const SGPath& path) const
{
- string name = FGModel::FindFullPathName(sysfilename);
+ SGPath name = FGModel::FindFullPathName(path);
+ if (systype != stSystem || !name.isNull()) return name;
- if (systype != stSystem || !name.empty()) return name;
+ name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Systems"), path);
+ if (!name.isNull()) return name;
- name = CheckFullPathName(FDMExec->GetFullAircraftPath() + "/Systems", sysfilename);
- if (!name.empty()) return name;
-
- return CheckFullPathName(FDMExec->GetSystemsPath(), sysfilename);
+ return CheckPathName(FDMExec->GetSystemsPath(), path);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/FGFCS.h b/src/FDM/JSBSim/models/FGFCS.h
index fabb7dd1a..b843f34ed 100644
--- a/src/FDM/JSBSim/models/FGFCS.h
+++ b/src/FDM/JSBSim/models/FGFCS.h
@@ -50,7 +50,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Id: FGFCS.h,v 1.53 2016/05/18 08:06:57 ehofman Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.54 2017/02/25 14:23:18 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -168,7 +168,7 @@ CLASS DOCUMENTATION
@property gear/tailhook-pos-norm
@author Jon S. Berndt
- @version $Revision: 1.53 $
+ @version $Revision: 1.54 $
@see FGActuator
@see FGDeadBand
@see FGFCSFunction
@@ -544,7 +544,7 @@ public:
@return true if succesful */
bool Load(Element* el);
- std::string FindFullPathName(const std::string& system_filename) const;
+ SGPath FindFullPathName(const SGPath& path) const;
void AddThrottle(void);
double GetDt(void) const;
diff --git a/src/FDM/JSBSim/models/FGInput.cpp b/src/FDM/JSBSim/models/FGInput.cpp
index 5bf66a4f2..e1972aeef 100644
--- a/src/FDM/JSBSim/models/FGInput.cpp
+++ b/src/FDM/JSBSim/models/FGInput.cpp
@@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInput.cpp,v 1.34 2015/08/23 09:43:31 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGInput.cpp,v 1.35 2017/02/25 14:23:19 bcoconni Exp $");
IDENT(IdHdr,ID_INPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -153,7 +153,7 @@ bool FGInput::Run(bool Holding)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGInput::SetDirectivesFile(const std::string& fname)
+bool FGInput::SetDirectivesFile(const SGPath& fname)
{
FGXMLFileRead XMLFile;
Element* document = XMLFile.LoadXMLDocument(fname);
diff --git a/src/FDM/JSBSim/models/FGInput.h b/src/FDM/JSBSim/models/FGInput.h
index e2b606d7c..86eb592d3 100644
--- a/src/FDM/JSBSim/models/FGInput.h
+++ b/src/FDM/JSBSim/models/FGInput.h
@@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INPUT "$Id: FGInput.h,v 1.13 2015/08/23 09:43:31 bcoconni Exp $"
+#define ID_INPUT "$Id: FGInput.h,v 1.14 2017/02/25 14:23:19 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -81,7 +81,7 @@ CLASS DOCUMENTATION
The class FGInput is the manager of the inputs requested by the user. It
manages a list of instances derived from the abstract class FGInputType.
- @version $Id: FGInput.h,v 1.13 2015/08/23 09:43:31 bcoconni Exp $
+ @version $Id: FGInput.h,v 1.14 2017/02/25 14:23:19 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -122,7 +122,7 @@ public:
@param fname the name of the file from which the ouput directives should
be read.
@return true if the execution succeeded. */
- bool SetDirectivesFile(const std::string& fname);
+ bool SetDirectivesFile(const SGPath& fname);
/// Enables the input generation for all input instances.
void Enable(void) { enabled = true; }
diff --git a/src/FDM/JSBSim/models/FGModel.cpp b/src/FDM/JSBSim/models/FGModel.cpp
index 943444ac3..c73bf7011 100644
--- a/src/FDM/JSBSim/models/FGModel.cpp
+++ b/src/FDM/JSBSim/models/FGModel.cpp
@@ -46,7 +46,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGModel.cpp,v 1.26 2015/07/12 19:34:08 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGModel.cpp,v 1.27 2017/02/25 14:23:19 bcoconni Exp $");
IDENT(IdHdr,ID_MODEL);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -103,9 +103,9 @@ bool FGModel::Run(bool Holding)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGModel::FindFullPathName(const string& fname) const
+SGPath FGModel::FindFullPathName(const SGPath& path) const
{
- return CheckFullPathName(FDMExec->GetFullAircraftPath(), fname);
+ return CheckPathName(FDMExec->GetFullAircraftPath(), path);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/FGModel.h b/src/FDM/JSBSim/models/FGModel.h
index b7ad17bca..a436e41c3 100644
--- a/src/FDM/JSBSim/models/FGModel.h
+++ b/src/FDM/JSBSim/models/FGModel.h
@@ -41,12 +41,13 @@ INCLUDES
#include
#include "math/FGModelFunctions.h"
+#include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MODEL "$Id: FGModel.h,v 1.25 2015/08/16 13:19:52 bcoconni Exp $"
+#define ID_MODEL "$Id: FGModel.h,v 1.26 2017/02/25 14:23:19 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -100,7 +101,7 @@ public:
FGFDMExec* GetExec(void) {return FDMExec;}
void SetPropertyManager(FGPropertyManager *fgpm) { PropertyManager=fgpm;}
- virtual std::string FindFullPathName(const std::string& filename) const;
+ virtual SGPath FindFullPathName(const SGPath& path) const;
protected:
unsigned int exe_ctr;
@@ -119,4 +120,3 @@ protected:
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
-
diff --git a/src/FDM/JSBSim/models/FGOutput.cpp b/src/FDM/JSBSim/models/FGOutput.cpp
index 6d682bac9..d7e15e8b2 100644
--- a/src/FDM/JSBSim/models/FGOutput.cpp
+++ b/src/FDM/JSBSim/models/FGOutput.cpp
@@ -53,7 +53,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.86 2015/08/23 09:43:31 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.87 2017/02/25 14:23:19 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -182,7 +182,7 @@ string FGOutput::GetOutputName(unsigned int idx) const
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGOutput::SetDirectivesFile(const std::string& fname)
+bool FGOutput::SetDirectivesFile(const SGPath& fname)
{
FGXMLFileRead XMLFile;
Element* document = XMLFile.LoadXMLDocument(fname);
diff --git a/src/FDM/JSBSim/models/FGOutput.h b/src/FDM/JSBSim/models/FGOutput.h
index 7a68a8440..9c7062247 100644
--- a/src/FDM/JSBSim/models/FGOutput.h
+++ b/src/FDM/JSBSim/models/FGOutput.h
@@ -47,7 +47,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUT "$Id: FGOutput.h,v 1.33 2015/08/23 09:43:31 bcoconni Exp $"
+#define ID_OUTPUT "$Id: FGOutput.h,v 1.34 2017/02/25 14:23:19 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -121,7 +121,7 @@ CLASS DOCUMENTATION
The class FGOutput is the manager of the outputs requested by the user. It
manages a list of instances derived from the abstract class FGOutputType.
- @version $Id: FGOutput.h,v 1.33 2015/08/23 09:43:31 bcoconni Exp $
+ @version $Id: FGOutput.h,v 1.34 2017/02/25 14:23:19 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -181,7 +181,7 @@ public:
@param fname the name of the file from which the ouput directives should
be read.
@return true if the execution succeeded. */
- bool SetDirectivesFile(const std::string& fname);
+ bool SetDirectivesFile(const SGPath& fname);
/// Enables the output generation for all output instances.
void Enable(void) { enabled = true; }
/// Disables the output generation for all output instances.
diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp
index 57b839feb..632c224f1 100644
--- a/src/FDM/JSBSim/models/FGPropagate.cpp
+++ b/src/FDM/JSBSim/models/FGPropagate.cpp
@@ -67,19 +67,19 @@ INCLUDES
#include
#include
#include
-#include
#include "initialization/FGInitialCondition.h"
#include "FGPropagate.h"
#include "FGGroundReactions.h"
#include "FGFDMExec.h"
#include "input_output/FGPropertyManager.h"
+#include "simgear/io/iostreams/sgstream.hxx"
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.131 2016/05/01 18:25:57 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPropagate.cpp,v 1.132 2017/02/25 14:23:19 bcoconni Exp $");
IDENT(IdHdr,ID_PROPAGATE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -659,21 +659,21 @@ void FGPropagate::DumpState(void)
void FGPropagate::WriteStateFile(int num)
{
- ofstream outfile;
+ sg_ofstream outfile;
if (num == 0) return;
- string filename = FDMExec->GetFullAircraftPath();
+ SGPath path = FDMExec->GetFullAircraftPath();
- if (filename.empty()) filename = "initfile.";
- else filename.append("/initfile.");
+ if (path.isNull()) path = SGPath("initfile.");
+ else path.append("initfile.");
// Append sim time to the filename since there may be more than one created during a simulation run
- filename += to_string((double)FDMExec->GetSimTime())+".xml";
+ path.concat(to_string((double)FDMExec->GetSimTime())+".xml");
switch(num) {
case 1:
- outfile.open(filename.c_str());
+ outfile.open(path);
if (outfile.is_open()) {
outfile << "" << endl;
outfile << "" << endl;
@@ -689,11 +689,12 @@ void FGPropagate::WriteStateFile(int num)
outfile << "" << endl;
outfile.close();
} else {
- cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
+ cerr << "Could not open and/or write the state to the initial conditions file: "
+ << path << endl;
}
break;
case 2:
- outfile.open(filename.c_str());
+ outfile.open(path);
if (outfile.is_open()) {
outfile << "" << endl;
outfile << "" << endl;
@@ -725,7 +726,8 @@ void FGPropagate::WriteStateFile(int num)
outfile << "" << endl;
outfile.close();
} else {
- cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
+ cerr << "Could not open and/or write the state to the initial conditions file: "
+ << path << endl;
}
break;
default:
diff --git a/src/FDM/JSBSim/models/FGPropulsion.cpp b/src/FDM/JSBSim/models/FGPropulsion.cpp
index 7d61e22e6..561182ce3 100644
--- a/src/FDM/JSBSim/models/FGPropulsion.cpp
+++ b/src/FDM/JSBSim/models/FGPropulsion.cpp
@@ -65,7 +65,7 @@ using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.87 2016/05/05 15:38:09 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.88 2017/02/25 14:23:19 bcoconni Exp $");
IDENT(IdHdr,ID_PROPULSION);
extern short debug_lvl;
@@ -463,14 +463,15 @@ bool FGPropulsion::Load(Element* el)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGPropulsion::FindFullPathName(const string& filename) const
+SGPath FGPropulsion::FindFullPathName(const SGPath& path) const
{
- if (!ReadingEngine) return FGModel::FindFullPathName(filename);
+ if (!ReadingEngine) return FGModel::FindFullPathName(path);
- string name = CheckFullPathName(FDMExec->GetFullAircraftPath() + "/Engines", filename);
- if (!name.empty()) return name;
+ SGPath name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Engines"),
+ path);
+ if (!name.isNull()) return name;
- return CheckFullPathName(FDMExec->GetEnginePath(), filename);
+ return CheckPathName(FDMExec->GetEnginePath(), path);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/FGPropulsion.h b/src/FDM/JSBSim/models/FGPropulsion.h
index 0b95dc0b8..728b7c916 100644
--- a/src/FDM/JSBSim/models/FGPropulsion.h
+++ b/src/FDM/JSBSim/models/FGPropulsion.h
@@ -50,7 +50,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.36 2016/05/05 15:38:08 bcoconni Exp $"
+#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.37 2017/02/25 14:23:19 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -93,7 +93,7 @@ CLASS DOCUMENTATION
@endcode
@author Jon S. Berndt
- @version $Id: FGPropulsion.h,v 1.36 2016/05/05 15:38:08 bcoconni Exp $
+ @version $Id: FGPropulsion.h,v 1.37 2017/02/25 14:23:19 bcoconni Exp $
@see
FGEngine
FGTank
@@ -180,7 +180,7 @@ public:
const FGColumnVector3& GetTanksMoment(void);
double GetTanksWeight(void) const;
- std::string FindFullPathName(const std::string& filename) const;
+ SGPath FindFullPathName(const SGPath& path) const;
inline int GetActiveEngine(void) const {return ActiveEngine;}
inline bool GetFuelFreeze(void) const {return FuelFreeze;}
diff --git a/src/FDM/JSBSim/models/flight_control/FGAngles.cpp b/src/FDM/JSBSim/models/flight_control/FGAngles.cpp
old mode 100755
new mode 100644
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
old mode 100755
new mode 100644
diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.h b/src/FDM/JSBSim/models/propulsion/FGTurboProp.h
old mode 100755
new mode 100644