Make all FDMs selectable at runtime; default LARCsim/UIUC to off.
This commit is contained in:
parent
d1e5dc95ca
commit
e819a4aaa4
2 changed files with 86 additions and 66 deletions
|
@ -80,8 +80,8 @@ endif()
|
||||||
option(LOGGING "Set to OFF to build FlightGear without logging" ON)
|
option(LOGGING "Set to OFF to build FlightGear without logging" ON)
|
||||||
|
|
||||||
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
|
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
|
||||||
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" ON)
|
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
|
||||||
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" ON)
|
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
|
||||||
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
|
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
|
||||||
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
|
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
|
||||||
option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
|
option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
|
||||||
|
|
|
@ -43,12 +43,21 @@
|
||||||
#endif
|
#endif
|
||||||
#include <FDM/ExternalNet/ExternalNet.hxx>
|
#include <FDM/ExternalNet/ExternalNet.hxx>
|
||||||
#include <FDM/ExternalPipe/ExternalPipe.hxx>
|
#include <FDM/ExternalPipe/ExternalPipe.hxx>
|
||||||
|
|
||||||
|
#ifdef ENABLE_JSBSIM
|
||||||
#include <FDM/JSBSim/JSBSim.hxx>
|
#include <FDM/JSBSim/JSBSim.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_LARCSIM
|
||||||
#include <FDM/LaRCsim/LaRCsim.hxx>
|
#include <FDM/LaRCsim/LaRCsim.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <FDM/UFO.hxx>
|
#include <FDM/UFO.hxx>
|
||||||
#include <FDM/NullFDM.hxx>
|
#include <FDM/NullFDM.hxx>
|
||||||
#include <FDM/YASim/YASim.hxx>
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_YASIM
|
||||||
|
#include <FDM/YASim/YASim.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Evil global variable required by Network/FGNative,
|
* Evil global variable required by Network/FGNative,
|
||||||
|
@ -194,12 +203,77 @@ void FDMShell::createImplementation()
|
||||||
double dt = 1.0 / fgGetInt("/sim/model-hz");
|
double dt = 1.0 / fgGetInt("/sim/model-hz");
|
||||||
string model = fgGetString("/sim/flight-model");
|
string model = fgGetString("/sim/flight-model");
|
||||||
|
|
||||||
if ( model == "larcsim" ) {
|
if ( model == "ufo" ) {
|
||||||
|
_impl = new FGUFO( dt );
|
||||||
|
} else if ( model == "external" ) {
|
||||||
|
// external is a synonym for "--fdm=null" and is
|
||||||
|
// maintained here for backwards compatibility
|
||||||
|
_impl = new FGNullFDM( dt );
|
||||||
|
} else if ( model.find("network") == 0 ) {
|
||||||
|
string host = "localhost";
|
||||||
|
int port1 = 5501;
|
||||||
|
int port2 = 5502;
|
||||||
|
int port3 = 5503;
|
||||||
|
string net_options = model.substr(8);
|
||||||
|
string::size_type begin, end;
|
||||||
|
begin = 0;
|
||||||
|
// host
|
||||||
|
end = net_options.find( ",", begin );
|
||||||
|
if ( end != string::npos ) {
|
||||||
|
host = net_options.substr(begin, end - begin);
|
||||||
|
begin = end + 1;
|
||||||
|
}
|
||||||
|
// port1
|
||||||
|
end = net_options.find( ",", begin );
|
||||||
|
if ( end != string::npos ) {
|
||||||
|
port1 = atoi( net_options.substr(begin, end - begin).c_str() );
|
||||||
|
begin = end + 1;
|
||||||
|
}
|
||||||
|
// port2
|
||||||
|
end = net_options.find( ",", begin );
|
||||||
|
if ( end != string::npos ) {
|
||||||
|
port2 = atoi( net_options.substr(begin, end - begin).c_str() );
|
||||||
|
begin = end + 1;
|
||||||
|
}
|
||||||
|
// port3
|
||||||
|
end = net_options.find( ",", begin );
|
||||||
|
if ( end != string::npos ) {
|
||||||
|
port3 = atoi( net_options.substr(begin, end - begin).c_str() );
|
||||||
|
begin = end + 1;
|
||||||
|
}
|
||||||
|
_impl = new FGExternalNet( dt, host, port1, port2, port3 );
|
||||||
|
} else if ( model.find("pipe") == 0 ) {
|
||||||
|
// /* old */ string pipe_path = model.substr(5);
|
||||||
|
// /* old */ _impl = new FGExternalPipe( dt, pipe_path );
|
||||||
|
string pipe_path = "";
|
||||||
|
string pipe_protocol = "";
|
||||||
|
string pipe_options = model.substr(5);
|
||||||
|
string::size_type begin, end;
|
||||||
|
begin = 0;
|
||||||
|
// pipe file path
|
||||||
|
end = pipe_options.find( ",", begin );
|
||||||
|
if ( end != string::npos ) {
|
||||||
|
pipe_path = pipe_options.substr(begin, end - begin);
|
||||||
|
begin = end + 1;
|
||||||
|
}
|
||||||
|
// protocol (last option)
|
||||||
|
pipe_protocol = pipe_options.substr(begin);
|
||||||
|
_impl = new FGExternalPipe( dt, pipe_path, pipe_protocol );
|
||||||
|
} else if ( model == "null" ) {
|
||||||
|
_impl = new FGNullFDM( dt );
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_LARCSIM
|
||||||
|
else if ( model == "larcsim" ) {
|
||||||
_impl = new FGLaRCsim( dt );
|
_impl = new FGLaRCsim( dt );
|
||||||
} else if ( model == "jsb" ) {
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_JSBSIM
|
||||||
|
else if ( model == "jsb" ) {
|
||||||
_impl = new FGJSBsim( dt );
|
_impl = new FGJSBsim( dt );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_SP_FDM
|
#ifdef ENABLE_SP_FDM
|
||||||
} else if ( model == "ada" ) {
|
else if ( model == "ada" ) {
|
||||||
_impl = new FGADA( dt );
|
_impl = new FGADA( dt );
|
||||||
} else if ( model == "acms" ) {
|
} else if ( model == "acms" ) {
|
||||||
_impl = new FGACMS( dt );
|
_impl = new FGACMS( dt );
|
||||||
|
@ -207,68 +281,14 @@ void FDMShell::createImplementation()
|
||||||
_impl = new FGBalloonSim( dt );
|
_impl = new FGBalloonSim( dt );
|
||||||
} else if ( model == "magic" ) {
|
} else if ( model == "magic" ) {
|
||||||
_impl = new FGMagicCarpet( dt );
|
_impl = new FGMagicCarpet( dt );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if ( model == "ufo" ) {
|
#ifdef ENABLE_YASIM
|
||||||
_impl = new FGUFO( dt );
|
else if ( model == "yasim" ) {
|
||||||
} else if ( model == "external" ) {
|
|
||||||
// external is a synonym for "--fdm=null" and is
|
|
||||||
// maintained here for backwards compatibility
|
|
||||||
_impl = new FGNullFDM( dt );
|
|
||||||
} else if ( model.find("network") == 0 ) {
|
|
||||||
string host = "localhost";
|
|
||||||
int port1 = 5501;
|
|
||||||
int port2 = 5502;
|
|
||||||
int port3 = 5503;
|
|
||||||
string net_options = model.substr(8);
|
|
||||||
string::size_type begin, end;
|
|
||||||
begin = 0;
|
|
||||||
// host
|
|
||||||
end = net_options.find( ",", begin );
|
|
||||||
if ( end != string::npos ) {
|
|
||||||
host = net_options.substr(begin, end - begin);
|
|
||||||
begin = end + 1;
|
|
||||||
}
|
|
||||||
// port1
|
|
||||||
end = net_options.find( ",", begin );
|
|
||||||
if ( end != string::npos ) {
|
|
||||||
port1 = atoi( net_options.substr(begin, end - begin).c_str() );
|
|
||||||
begin = end + 1;
|
|
||||||
}
|
|
||||||
// port2
|
|
||||||
end = net_options.find( ",", begin );
|
|
||||||
if ( end != string::npos ) {
|
|
||||||
port2 = atoi( net_options.substr(begin, end - begin).c_str() );
|
|
||||||
begin = end + 1;
|
|
||||||
}
|
|
||||||
// port3
|
|
||||||
end = net_options.find( ",", begin );
|
|
||||||
if ( end != string::npos ) {
|
|
||||||
port3 = atoi( net_options.substr(begin, end - begin).c_str() );
|
|
||||||
begin = end + 1;
|
|
||||||
}
|
|
||||||
_impl = new FGExternalNet( dt, host, port1, port2, port3 );
|
|
||||||
} else if ( model.find("pipe") == 0 ) {
|
|
||||||
// /* old */ string pipe_path = model.substr(5);
|
|
||||||
// /* old */ _impl = new FGExternalPipe( dt, pipe_path );
|
|
||||||
string pipe_path = "";
|
|
||||||
string pipe_protocol = "";
|
|
||||||
string pipe_options = model.substr(5);
|
|
||||||
string::size_type begin, end;
|
|
||||||
begin = 0;
|
|
||||||
// pipe file path
|
|
||||||
end = pipe_options.find( ",", begin );
|
|
||||||
if ( end != string::npos ) {
|
|
||||||
pipe_path = pipe_options.substr(begin, end - begin);
|
|
||||||
begin = end + 1;
|
|
||||||
}
|
|
||||||
// protocol (last option)
|
|
||||||
pipe_protocol = pipe_options.substr(begin);
|
|
||||||
_impl = new FGExternalPipe( dt, pipe_path, pipe_protocol );
|
|
||||||
} else if ( model == "null" ) {
|
|
||||||
_impl = new FGNullFDM( dt );
|
|
||||||
} else if ( model == "yasim" ) {
|
|
||||||
_impl = new YASim( dt );
|
_impl = new YASim( dt );
|
||||||
} else {
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
throw sg_exception(string("Unrecognized flight model '") + model
|
throw sg_exception(string("Unrecognized flight model '") + model
|
||||||
+ "', cannot init flight dynamics model.");
|
+ "', cannot init flight dynamics model.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue