More property node optimizations.
This commit is contained in:
parent
64254d7410
commit
c64e284c51
8 changed files with 72 additions and 54 deletions
|
@ -84,9 +84,9 @@ FGRadioStack::FGRadioStack() {
|
||||||
nav2_radial = 0.0;
|
nav2_radial = 0.0;
|
||||||
nav2_dme_dist = 0.0;
|
nav2_dme_dist = 0.0;
|
||||||
need_update = true;
|
need_update = true;
|
||||||
longitudeVal = fgGetValue("/position/longitude");
|
lon_node = fgGetNode("/position/longitude");
|
||||||
latitudeVal = fgGetValue("/position/latitude");
|
lat_node = fgGetNode("/position/latitude");
|
||||||
altitudeVal = fgGetValue("/position/altitude");
|
alt_node = fgGetNode("/position/altitude");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,9 +308,9 @@ double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
|
||||||
void
|
void
|
||||||
FGRadioStack::update()
|
FGRadioStack::update()
|
||||||
{
|
{
|
||||||
double lon = longitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double lat = latitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double elev = altitudeVal->getDoubleValue() * SG_FEET_TO_METER;
|
double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
|
||||||
|
|
||||||
need_update = false;
|
need_update = false;
|
||||||
|
|
||||||
|
@ -603,9 +603,9 @@ void FGRadioStack::search()
|
||||||
{
|
{
|
||||||
static FGMkrBeacon::fgMkrBeacType last_beacon = FGMkrBeacon::NOBEACON;
|
static FGMkrBeacon::fgMkrBeacType last_beacon = FGMkrBeacon::NOBEACON;
|
||||||
|
|
||||||
double lon = longitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double lat = latitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double elev = altitudeVal->getDoubleValue() * SG_FEET_TO_METER;
|
double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
|
||||||
|
|
||||||
// nav1
|
// nav1
|
||||||
FGILS ils;
|
FGILS ils;
|
||||||
|
|
|
@ -48,9 +48,9 @@ class FGRadioStack : public FGSubsystem
|
||||||
SGInterpTable *low_tbl;
|
SGInterpTable *low_tbl;
|
||||||
SGInterpTable *high_tbl;
|
SGInterpTable *high_tbl;
|
||||||
|
|
||||||
SGValue * latitudeVal;
|
SGPropertyNode *lat_node;
|
||||||
SGValue * longitudeVal;
|
SGPropertyNode *lon_node;
|
||||||
SGValue * altitudeVal;
|
SGPropertyNode *alt_node;
|
||||||
|
|
||||||
bool need_update;
|
bool need_update;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ FGControls::init ()
|
||||||
brake[wheel] = 0.0;
|
brake[wheel] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_coordination = fgGetValue("/sim/auto-coordination", true);
|
auto_coordination = fgGetNode("/sim/auto-coordination", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ private:
|
||||||
double brake[MAX_WHEELS];
|
double brake[MAX_WHEELS];
|
||||||
bool throttle_idle;
|
bool throttle_idle;
|
||||||
|
|
||||||
SGValue * auto_coordination;
|
SGPropertyNode * auto_coordination;
|
||||||
|
|
||||||
inline void CLAMP(double *x, double min, double max ) {
|
inline void CLAMP(double *x, double min, double max ) {
|
||||||
if ( *x < min ) { *x = min; }
|
if ( *x < min ) { *x = min; }
|
||||||
|
|
|
@ -105,9 +105,15 @@ FGJSBsim::FGJSBsim( double dt )
|
||||||
fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
|
fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
|
||||||
fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
|
fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
|
||||||
|
|
||||||
trimmed = fgGetValue("/fdm/trim/trimmed",true);
|
startup_trim = fgGetNode("/sim/startup/trim", true);
|
||||||
|
|
||||||
|
trimmed = fgGetNode("/fdm/trim/trimmed", true);
|
||||||
trimmed->setBoolValue(false);
|
trimmed->setBoolValue(false);
|
||||||
|
|
||||||
|
pitch_trim = fgGetNode("/fdm/trim/pitch-trim", true );
|
||||||
|
throttle_trim = fgGetNode("/fdm/trim/throttle", true );
|
||||||
|
aileron_trim = fgGetNode("/fdm/trim/aileron", true );
|
||||||
|
rudder_trim = fgGetNode("/fdm/trim/rudder", true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -192,44 +198,44 @@ bool FGJSBsim::update( int multiloop ) {
|
||||||
|
|
||||||
trimmed->setBoolValue(false);
|
trimmed->setBoolValue(false);
|
||||||
|
|
||||||
if (needTrim && fgGetBool("/sim/startup/trim")) {
|
if ( needTrim && startup_trim->getBoolValue() ) {
|
||||||
|
|
||||||
//fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
|
//fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
|
||||||
//fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
|
//fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
|
||||||
|
|
||||||
FGTrim *fgtrim;
|
FGTrim *fgtrim;
|
||||||
if(fgic->GetVcalibratedKtsIC() < 10 ) {
|
if(fgic->GetVcalibratedKtsIC() < 10 ) {
|
||||||
fgic->SetVcalibratedKtsIC(0.0);
|
fgic->SetVcalibratedKtsIC(0.0);
|
||||||
fgtrim=new FGTrim(fdmex,fgic,tGround);
|
fgtrim=new FGTrim(fdmex,fgic,tGround);
|
||||||
} else {
|
} else {
|
||||||
fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
|
fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
|
||||||
}
|
}
|
||||||
if(!fgtrim->DoTrim()) {
|
if(!fgtrim->DoTrim()) {
|
||||||
fgtrim->Report();
|
fgtrim->Report();
|
||||||
fgtrim->TrimStats();
|
fgtrim->TrimStats();
|
||||||
} else {
|
} else {
|
||||||
trimmed->setBoolValue(true);
|
trimmed->setBoolValue(true);
|
||||||
}
|
}
|
||||||
fgtrim->ReportState();
|
fgtrim->ReportState();
|
||||||
delete fgtrim;
|
delete fgtrim;
|
||||||
|
|
||||||
needTrim=false;
|
needTrim=false;
|
||||||
|
|
||||||
fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
|
pitch_trim->setDoubleValue( FCS->GetPitchTrimCmd() );
|
||||||
fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0));
|
throttle_trim->setDoubleValue( FCS->GetThrottleCmd(0) );
|
||||||
fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
|
aileron_trim->setDoubleValue( FCS->GetDaCmd() );
|
||||||
fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
|
rudder_trim->setDoubleValue( FCS->GetDrCmd() );
|
||||||
|
|
||||||
controls.set_elevator_trim(FCS->GetPitchTrimCmd());
|
controls.set_elevator_trim(FCS->GetPitchTrimCmd());
|
||||||
controls.set_elevator(FCS->GetDeCmd());
|
controls.set_elevator(FCS->GetDeCmd());
|
||||||
controls.set_throttle(FGControls::ALL_ENGINES,
|
controls.set_throttle(FGControls::ALL_ENGINES,
|
||||||
FCS->GetThrottleCmd(0));
|
FCS->GetThrottleCmd(0));
|
||||||
|
|
||||||
controls.set_aileron(FCS->GetDaCmd());
|
controls.set_aileron(FCS->GetDaCmd());
|
||||||
controls.set_rudder( FCS->GetDrCmd());
|
controls.set_rudder( FCS->GetDrCmd());
|
||||||
|
|
||||||
SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" );
|
SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<get_num_engines(); i++ ) {
|
for( i=0; i<get_num_engines(); i++ ) {
|
||||||
get_engine(i)->set_RPM( Propulsion->GetThruster(i)->GetRPM() );
|
get_engine(i)->set_RPM( Propulsion->GetThruster(i)->GetRPM() );
|
||||||
|
|
|
@ -50,6 +50,8 @@ DEFINITIONS
|
||||||
FORWARD DECLARATIONS
|
FORWARD DECLARATIONS
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
|
#include <simgear/misc/props.hxx>
|
||||||
|
|
||||||
#include <FDM/JSBSim/FGFDMExec.h>
|
#include <FDM/JSBSim/FGFDMExec.h>
|
||||||
|
|
||||||
class FGState;
|
class FGState;
|
||||||
|
@ -233,7 +235,12 @@ private:
|
||||||
float trim_elev;
|
float trim_elev;
|
||||||
float trim_throttle;
|
float trim_throttle;
|
||||||
|
|
||||||
SGValue *trimmed;
|
SGPropertyNode *startup_trim;
|
||||||
|
SGPropertyNode *trimmed;
|
||||||
|
SGPropertyNode *pitch_trim;
|
||||||
|
SGPropertyNode *throttle_trim;
|
||||||
|
SGPropertyNode *aileron_trim;
|
||||||
|
SGPropertyNode *rudder_trim;
|
||||||
|
|
||||||
void snap_shot(void);
|
void snap_shot(void);
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,8 +41,11 @@
|
||||||
FGLaRCsim::FGLaRCsim( double dt ) {
|
FGLaRCsim::FGLaRCsim( double dt ) {
|
||||||
set_delta_t( dt );
|
set_delta_t( dt );
|
||||||
|
|
||||||
ls_toplevel_init( 0.0,
|
speed_up = fgGetNode("/sim/speed-up", true);
|
||||||
(char *)fgGetString("/sim/aircraft").c_str() );
|
aircraft = fgGetNode("/sim/aircraft", true);
|
||||||
|
|
||||||
|
ls_toplevel_init( 0.0, (char *)(aircraft->getStringValue().c_str()) );
|
||||||
|
|
||||||
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
|
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
|
||||||
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
|
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
|
||||||
//this should go away someday -- formerly done in fg_init.cxx
|
//this should go away someday -- formerly done in fg_init.cxx
|
||||||
|
@ -71,8 +74,6 @@ void FGLaRCsim::init() {
|
||||||
// init method first.
|
// init method first.
|
||||||
FGInterface::init();
|
FGInterface::init();
|
||||||
|
|
||||||
speed_up = fgGetValue("/sim/speed-up", true);
|
|
||||||
|
|
||||||
ls_set_model_dt( get_delta_t() );
|
ls_set_model_dt( get_delta_t() );
|
||||||
// Initialize our little engine that hopefully might
|
// Initialize our little engine that hopefully might
|
||||||
eng.init( get_delta_t() );
|
eng.init( get_delta_t() );
|
||||||
|
@ -121,7 +122,7 @@ void FGLaRCsim::init() {
|
||||||
// Run an iteration of the EOM (equations of motion)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
bool FGLaRCsim::update( int multiloop ) {
|
bool FGLaRCsim::update( int multiloop ) {
|
||||||
|
|
||||||
if ( fgGetString("/sim/aircraft") == "c172" ) {
|
if ( aircraft->getStringValue() == "c172" ) {
|
||||||
// set control inputs
|
// set control inputs
|
||||||
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
|
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
|
||||||
eng.set_IAS( V_calibrated_kts );
|
eng.set_IAS( V_calibrated_kts );
|
||||||
|
@ -188,7 +189,7 @@ bool FGLaRCsim::update( int multiloop ) {
|
||||||
speed_up->getIntValue();
|
speed_up->getIntValue();
|
||||||
Flap_handle = 30.0 * controls.get_flaps();
|
Flap_handle = 30.0 * controls.get_flaps();
|
||||||
|
|
||||||
if ( fgGetString("/sim/aircraft") == "c172" ) {
|
if ( aircraft->getStringValue() == "c172" ) {
|
||||||
Use_External_Engine = 1;
|
Use_External_Engine = 1;
|
||||||
} else {
|
} else {
|
||||||
Use_External_Engine = 0;
|
Use_External_Engine = 0;
|
||||||
|
|
|
@ -33,14 +33,18 @@
|
||||||
|
|
||||||
class FGLaRCsim: public FGInterface {
|
class FGLaRCsim: public FGInterface {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
FGNewEngine eng;
|
FGNewEngine eng;
|
||||||
LaRCsimIC* lsic;
|
LaRCsimIC* lsic;
|
||||||
void set_ls(void);
|
void set_ls(void);
|
||||||
void snap_shot(void);
|
void snap_shot(void);
|
||||||
double time_step;
|
double time_step;
|
||||||
SGValue * speed_up;
|
SGPropertyNode *speed_up;
|
||||||
|
SGPropertyNode *aircraft;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGLaRCsim( double dt );
|
FGLaRCsim( double dt );
|
||||||
~FGLaRCsim(void);
|
~FGLaRCsim(void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue