From 0abf252ec8bc933b9b7c045f8782cfc7f16c0465 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 4 Mar 2012 15:30:08 +0100 Subject: [PATCH] Use tiedPropertyLists instead of manually matched tie/untie calls. Ensures we don't forget to untie some individual properties. --- src/AIModel/AIAircraft.cxx | 21 +- src/AIModel/AIAircraft.hxx | 1 - src/AIModel/AIBallistic.cxx | 84 ++----- src/AIModel/AIBallistic.hxx | 1 - src/AIModel/AIBase.cxx | 89 +++---- src/AIModel/AIBase.hxx | 30 ++- src/AIModel/AICarrier.cxx | 129 ++++------ src/AIModel/AICarrier.hxx | 1 - src/AIModel/AIEscort.cxx | 38 +-- src/AIModel/AIEscort.hxx | 1 - src/AIModel/AIGroundVehicle.cxx | 53 ++-- src/AIModel/AIGroundVehicle.hxx | 1 - src/AIModel/AIMultiplayer.cxx | 28 +-- src/AIModel/AIMultiplayer.hxx | 3 +- src/AIModel/AIShip.cxx | 106 +++----- src/AIModel/AIShip.hxx | 1 - src/AIModel/AITanker.cxx | 12 +- src/AIModel/AITanker.hxx | 1 - src/AIModel/AIThermal.cxx | 31 +-- src/AIModel/AIThermal.hxx | 38 ++- src/AIModel/AIWingman.cxx | 104 +++----- src/AIModel/AIWingman.hxx | 1 - src/FDM/flight.cxx | 373 +++++++++++++--------------- src/FDM/flight.hxx | 5 +- src/Input/FGKeyboardInput.cxx | 53 ++-- src/Input/FGKeyboardInput.hxx | 4 +- src/Instrumentation/dclgps.cxx | 22 +- src/Instrumentation/dclgps.hxx | 11 +- src/Instrumentation/gps.cxx | 10 +- src/Instrumentation/gps.hxx | 413 +++++++++++++++----------------- src/Instrumentation/kr_87.cxx | 167 +++++-------- src/Instrumentation/kr_87.hxx | 4 +- src/Instrumentation/kt_70.cxx | 92 +++---- src/Instrumentation/kt_70.hxx | 3 + src/Main/fg_props.cxx | 62 ++--- src/Main/fg_props.hxx | 4 + src/Main/viewmgr.cxx | 147 +++++------- src/Main/viewmgr.hxx | 6 +- 38 files changed, 861 insertions(+), 1289 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 5cd3d6277..eea17d927 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -119,23 +119,14 @@ void FGAIAircraft::readFromScenario(SGPropertyNode* scFileNode) { void FGAIAircraft::bind() { FGAIBase::bind(); - props->tie("controls/gear/gear-down", - SGRawValueMethods(*this, - &FGAIAircraft::_getGearDown)); - props->tie("transponder-id", - SGRawValueMethods(*this, - &FGAIAircraft::_getTransponderCode)); + tie("controls/gear/gear-down", + SGRawValueMethods(*this, + &FGAIAircraft::_getGearDown)); + tie("transponder-id", + SGRawValueMethods(*this, + &FGAIAircraft::_getTransponderCode)); } - -void FGAIAircraft::unbind() { - FGAIBase::unbind(); - - props->untie("controls/gear/gear-down"); - props->untie("transponder-id"); -} - - void FGAIAircraft::update(double dt) { FGAIBase::update(dt); Run(dt); diff --git a/src/AIModel/AIAircraft.hxx b/src/AIModel/AIAircraft.hxx index cfadfaf51..ea2d08e7c 100644 --- a/src/AIModel/AIAircraft.hxx +++ b/src/AIModel/AIAircraft.hxx @@ -42,7 +42,6 @@ public: // virtual bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void update(double dt); void setPerformance(const std::string& perfString); diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 68d72f92b..f7a2fc7d6 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -189,104 +189,72 @@ void FGAIBallistic::reinit() { void FGAIBallistic::bind() { // FGAIBase::bind(); - props->tie("sim/time/elapsed-sec", + _tiedProperties.setRoot(props); + tie("sim/time/elapsed-sec", SGRawValueMethods(*this, &FGAIBallistic::_getTime, &FGAIBallistic::setTime)); - //props->tie("mass-slug", + //tie("mass-slug", // SGRawValueMethods(*this, // &FGAIBallistic::getMass)); - props->tie("material/solid", + tie("material/solid", SGRawValuePointer(&_solid)); - props->tie("altitude-agl-ft", + tie("altitude-agl-ft", SGRawValuePointer(&_ht_agl_ft)); - props->tie("controls/slave-to-ac", + tie("controls/slave-to-ac", SGRawValueMethods (*this, &FGAIBallistic::getSlaved, &FGAIBallistic::setSlaved)); - props->tie("controls/invisible", + tie("controls/invisible", SGRawValuePointer(&invisible)); if(_external_force || _slave_to_ac){ - props->tie("controls/force_stabilized", + tie("controls/force_stabilized", SGRawValuePointer(&_force_stabilised)); - props->tie("position/global-x", + tie("position/global-x", SGRawValueMethods(*this, &FGAIBase::_getCartPosX, 0)); - props->tie("position/global-y", + tie("position/global-y", SGRawValueMethods(*this, &FGAIBase::_getCartPosY, 0)); - props->tie("position/global-z", + tie("position/global-z", SGRawValueMethods(*this, &FGAIBase::_getCartPosZ, 0)); - props->tie("velocities/vertical-speed-fps", + tie("velocities/vertical-speed-fps", SGRawValuePointer(&vs)); - props->tie("velocities/true-airspeed-kt", + tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); - props->tie("velocities/horizontal-speed-fps", + tie("velocities/horizontal-speed-fps", SGRawValuePointer(&hs)); - props->tie("position/altitude-ft", + tie("position/altitude-ft", SGRawValueMethods(*this, &FGAIBase::_getElevationFt, &FGAIBase::_setAltitude)); - props->tie("position/latitude-deg", + tie("position/latitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLatitude, &FGAIBase::_setLatitude)); - props->tie("position/longitude-deg", + tie("position/longitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLongitude, &FGAIBase::_setLongitude)); - props->tie("orientation/hdg-deg", + tie("orientation/hdg-deg", SGRawValuePointer(&hdg)); - props->tie("orientation/pitch-deg", + tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); - props->tie("orientation/roll-deg", + tie("orientation/roll-deg", SGRawValuePointer(&roll)); - props->tie("controls/slave-load-to-ac", + tie("controls/slave-load-to-ac", SGRawValueMethods (*this, &FGAIBallistic::getSlavedLoad, &FGAIBallistic::setSlavedLoad)); - props->tie("position/load-offset", + tie("position/load-offset", SGRawValueMethods (*this, &FGAIBallistic::getLoadOffset, &FGAIBallistic::setLoadOffset)); - props->tie("load/distance-to-hitch-ft", + tie("load/distance-to-hitch-ft", SGRawValueMethods (*this, &FGAIBallistic::getDistanceToHitch)); - props->tie("load/elevation-to-hitch-deg", + tie("load/elevation-to-hitch-deg", SGRawValueMethods (*this, &FGAIBallistic::getElevToHitch)); - props->tie("load/bearing-to-hitch-deg", + tie("load/bearing-to-hitch-deg", SGRawValueMethods (*this, &FGAIBallistic::getBearingToHitch)); - props->tie("material/load-resistance", + tie("material/load-resistance", SGRawValuePointer(&_load_resistance)); } } -void FGAIBallistic::unbind() { -// FGAIBase::unbind(); - - props->untie("sim/time/elapsed-sec"); - props->untie("mass-slug"); - props->untie("material/solid"); - props->untie("altitude-agl-ft"); - props->untie("controls/slave-to-ac"); - props->untie("controls/invisible"); - - if(_external_force || _slave_to_ac){ - props->untie("position/global-y"); - props->untie("position/global-x"); - props->untie("position/global-z"); - props->untie("velocities/vertical-speed-fps"); - props->untie("velocities/true-airspeed-kt"); - props->untie("velocities/horizontal-speed-fps"); - props->untie("position/altitude-ft"); - props->untie("position/latitude-deg"); - props->untie("position/longitude-deg"); - props->untie("position/ht-agl-ft"); - props->untie("orientation/hdg-deg"); - props->untie("orientation/pitch-deg"); - props->untie("orientation/roll-deg"); - props->untie("controls/force_stabilized"); - props->untie("position/load-offset"); - props->untie("load/distance-to-hitch-ft"); - props->untie("load/elevation-to-hitch-deg"); - props->untie("load/bearing-to-hitch-deg"); - props->untie("material/load-resistance"); - } -} - void FGAIBallistic::update(double dt) { FGAIBase::update(dt); _setUserPos(); diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index 70ea502cf..63d55bd95 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -45,7 +45,6 @@ public: bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void reinit(); virtual void update(double dt); diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 1431cc411..44494dc54 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -394,61 +394,62 @@ bool FGAIBase::isa( object_type otype ) { void FGAIBase::bind() { - props->tie("id", SGRawValueMethods(*this, + _tiedProperties.setRoot(props); + tie("id", SGRawValueMethods(*this, &FGAIBase::getID)); - props->tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); - props->tie("velocities/vertical-speed-fps", + tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); + tie("velocities/vertical-speed-fps", SGRawValueMethods(*this, &FGAIBase::_getVS_fps, &FGAIBase::_setVS_fps)); - props->tie("position/altitude-ft", + tie("position/altitude-ft", SGRawValueMethods(*this, &FGAIBase::_getAltitude, &FGAIBase::_setAltitude)); - props->tie("position/latitude-deg", + tie("position/latitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLatitude, &FGAIBase::_setLatitude)); - props->tie("position/longitude-deg", + tie("position/longitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLongitude, &FGAIBase::_setLongitude)); - props->tie("position/global-x", + tie("position/global-x", SGRawValueMethods(*this, &FGAIBase::_getCartPosX, 0)); - props->tie("position/global-y", + tie("position/global-y", SGRawValueMethods(*this, &FGAIBase::_getCartPosY, 0)); - props->tie("position/global-z", + tie("position/global-z", SGRawValueMethods(*this, &FGAIBase::_getCartPosZ, 0)); - props->tie("callsign", + tie("callsign", SGRawValueMethods(*this, &FGAIBase::_getCallsign, 0)); - props->tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); - props->tie("orientation/roll-deg", SGRawValuePointer(&roll)); - props->tie("orientation/true-heading-deg", SGRawValuePointer(&hdg)); - - props->tie("radar/in-range", SGRawValuePointer(&in_range)); - props->tie("radar/bearing-deg", SGRawValuePointer(&bearing)); - props->tie("radar/elevation-deg", SGRawValuePointer(&elevation)); - props->tie("radar/range-nm", SGRawValuePointer(&range)); - props->tie("radar/h-offset", SGRawValuePointer(&horiz_offset)); - props->tie("radar/v-offset", SGRawValuePointer(&vert_offset)); - props->tie("radar/x-shift", SGRawValuePointer(&x_shift)); - props->tie("radar/y-shift", SGRawValuePointer(&y_shift)); - props->tie("radar/rotation", SGRawValuePointer(&rotation)); - props->tie("radar/ht-diff-ft", SGRawValuePointer(&ht_diff)); - props->tie("subID", SGRawValuePointer(&_subID)); - props->tie("controls/lighting/nav-lights", - SGRawValueFunctions(_isNight)); + tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); + tie("orientation/roll-deg", SGRawValuePointer(&roll)); + tie("orientation/true-heading-deg", SGRawValuePointer(&hdg)); + + tie("radar/in-range", SGRawValuePointer(&in_range)); + tie("radar/bearing-deg", SGRawValuePointer(&bearing)); + tie("radar/elevation-deg", SGRawValuePointer(&elevation)); + tie("radar/range-nm", SGRawValuePointer(&range)); + tie("radar/h-offset", SGRawValuePointer(&horiz_offset)); + tie("radar/v-offset", SGRawValuePointer(&vert_offset)); + tie("radar/x-shift", SGRawValuePointer(&x_shift)); + tie("radar/y-shift", SGRawValuePointer(&y_shift)); + tie("radar/rotation", SGRawValuePointer(&rotation)); + tie("radar/ht-diff-ft", SGRawValuePointer(&ht_diff)); + tie("subID", SGRawValuePointer(&_subID)); + tie("controls/lighting/nav-lights", SGRawValueFunctions(_isNight)); + props->setBoolValue("controls/lighting/beacon", true); props->setBoolValue("controls/lighting/strobe", true); props->setBoolValue("controls/glide-path", true); @@ -467,40 +468,12 @@ void FGAIBase::bind() { props->setDoubleValue("sim/sound/avionics/volume", 0.0); props->setBoolValue("sim/sound/avionics/external-view", false); props->setBoolValue("sim/current-view/internal", false); - } void FGAIBase::unbind() { - props->untie("id"); - props->untie("velocities/true-airspeed-kt"); - props->untie("velocities/vertical-speed-fps"); - - props->untie("position/altitude-ft"); - props->untie("position/latitude-deg"); - props->untie("position/longitude-deg"); - props->untie("position/global-x"); - props->untie("position/global-y"); - props->untie("position/global-z"); - props->untie("callsign"); - - props->untie("orientation/pitch-deg"); - props->untie("orientation/roll-deg"); - props->untie("orientation/true-heading-deg"); - - props->untie("radar/in-range"); - props->untie("radar/bearing-deg"); - props->untie("radar/elevation-deg"); - props->untie("radar/range-nm"); - props->untie("radar/h-offset"); - props->untie("radar/v-offset"); - props->untie("radar/x-shift"); - props->untie("radar/y-shift"); - props->untie("radar/rotation"); - props->untie("radar/ht-diff-ft"); - - props->untie("controls/lighting/nav-lights"); - - props->setBoolValue("/sim/controls/radar/", true); + _tiedProperties.Untie(); + + props->setBoolValue("/sim/controls/radar", true); // drop reference to sound effects now _fx = 0; diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index eaf2c3ea1..d9844df10 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -43,7 +44,7 @@ class FGAIManager; class FGAIFlightPlan; class FGFX; class FGNasalModelDataProxy; -class FGAIModelData; // defined below +class FGAIModelData; // defined below class FGAIBase : public SGReferenced { @@ -52,7 +53,7 @@ public: enum object_type { otNull = 0, otAircraft, otShip, otCarrier, otBallistic, otRocket, otStorm, otThermal, otStatic, otWingman, otGroundVehicle, otEscort, otMultiplayer, - MAX_OBJECTS }; // Needs to be last!!! + MAX_OBJECTS }; // Needs to be last!!! FGAIBase(object_type ot, bool enableHot); virtual ~FGAIBase(); @@ -143,7 +144,16 @@ public: protected: - + /** + * Tied-properties helper, record nodes which are tied for easy un-tie-ing + */ + template + void tie(const char* aRelPath, const SGRawValue& aRawValue) + { + _tiedProperties.Tie(props->getNode(aRelPath, true), aRawValue); + } + + simgear::TiedPropertyList _tiedProperties; SGPropertyNode_ptr _selected_ac; SGPropertyNode_ptr props; SGPropertyNode_ptr trigger_node; @@ -151,10 +161,10 @@ protected: FGAIManager* manager; // these describe the model's actual state - SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters - double hdg; // True heading in degrees - double roll; // degrees, left is negative - double pitch; // degrees, nose-down is negative + SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters + double hdg; // True heading in degrees + double roll; // degrees, left is negative + double pitch; // degrees, nose-down is negative double speed; // knots true airspeed double altitude_ft; // feet above sea level double vs; // vertical speed, feet per minute @@ -186,9 +196,9 @@ protected: double x_shift; // value used by radar display instrument double y_shift; // value used by radar display instrument double rotation; // value used by radar display instrument - double ht_diff; // value used by radar display instrument + double ht_diff; // value used by radar display instrument - string model_path; //Path to the 3D model + string model_path; //Path to the 3D model SGModelPlacement aip; bool delete_me; @@ -469,4 +479,4 @@ private: bool _initialized; }; -#endif // _FG_AIBASE_HXX +#endif // _FG_AIBASE_HXX diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 2f109690c..dc8cde561 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -247,64 +247,63 @@ void FGAICarrier::bind() { props->untie("velocities/true-airspeed-kt"); - props->tie("controls/flols/source-lights", - SGRawValuePointer(&source)); - props->tie("controls/flols/distance-m", - SGRawValuePointer(&dist)); - props->tie("controls/flols/angle-degs", - SGRawValuePointer(&angle)); - props->tie("controls/turn-to-launch-hdg", - SGRawValuePointer(&turn_to_launch_hdg)); - props->tie("controls/in-to-wind", - SGRawValuePointer(&turn_to_launch_hdg)); - props->tie("controls/base-course-deg", - SGRawValuePointer(&base_course)); - props->tie("controls/base-speed-kts", - SGRawValuePointer(&base_speed)); - props->tie("controls/start-pos-lat-deg", - SGRawValueMethods(pos, &SGGeod::getLatitudeDeg)); - props->tie("controls/start-pos-long-deg", - SGRawValueMethods(pos, &SGGeod::getLongitudeDeg)); - props->tie("controls/mp-control", - SGRawValuePointer(&MPControl)); - props->tie("controls/ai-control", - SGRawValuePointer(&AIControl)); - props->tie("environment/surface-wind-speed-true-kts", - SGRawValuePointer(&wind_speed_kts)); - props->tie("environment/surface-wind-from-true-degs", - SGRawValuePointer(&wind_from_deg)); - props->tie("environment/rel-wind-from-degs", - SGRawValuePointer(&rel_wind_from_deg)); - props->tie("environment/rel-wind-from-carrier-hdg-degs", - SGRawValuePointer(&rel_wind)); - props->tie("environment/rel-wind-speed-kts", - SGRawValuePointer(&rel_wind_speed_kts)); - props->tie("environment/in-to-wind", + tie("controls/flols/source-lights", + SGRawValuePointer(&source)); + tie("controls/flols/distance-m", + SGRawValuePointer(&dist)); + tie("controls/flols/angle-degs", + SGRawValuePointer(&angle)); + tie("controls/turn-to-launch-hdg", + SGRawValuePointer(&turn_to_launch_hdg)); + tie("controls/in-to-wind", + SGRawValuePointer(&turn_to_launch_hdg)); + tie("controls/base-course-deg", + SGRawValuePointer(&base_course)); + tie("controls/base-speed-kts", + SGRawValuePointer(&base_speed)); + tie("controls/start-pos-lat-deg", + SGRawValueMethods(pos, &SGGeod::getLatitudeDeg)); + tie("controls/start-pos-long-deg", + SGRawValueMethods(pos, &SGGeod::getLongitudeDeg)); + tie("controls/mp-control", + SGRawValuePointer(&MPControl)); + tie("controls/ai-control", + SGRawValuePointer(&AIControl)); + tie("environment/surface-wind-speed-true-kts", + SGRawValuePointer(&wind_speed_kts)); + tie("environment/surface-wind-from-true-degs", + SGRawValuePointer(&wind_from_deg)); + tie("environment/rel-wind-from-degs", + SGRawValuePointer(&rel_wind_from_deg)); + tie("environment/rel-wind-from-carrier-hdg-degs", + SGRawValuePointer(&rel_wind)); + tie("environment/rel-wind-speed-kts", + SGRawValuePointer(&rel_wind_speed_kts)); + tie("environment/in-to-wind", SGRawValuePointer(&in_to_wind)); - //props->tie("controls/flols/wave-off-lights", - // SGRawValuePointer(&wave_off_lights)); - props->tie("controls/elevators", - SGRawValuePointer(&elevators)); - props->tie("surface-positions/elevators-pos-norm", - SGRawValuePointer(&pos_norm)); - props->tie("controls/constants/elevators/trans-time-s", - SGRawValuePointer(&transition_time)); - props->tie("controls/constants/elevators/time-constant", - SGRawValuePointer(&time_constant)); - props->tie("controls/jbd", + //tie("controls/flols/wave-off-lights", + // SGRawValuePointer(&wave_off_lights)); + tie("controls/elevators", + SGRawValuePointer(&elevators)); + tie("surface-positions/elevators-pos-norm", + SGRawValuePointer(&pos_norm)); + tie("controls/constants/elevators/trans-time-s", + SGRawValuePointer(&transition_time)); + tie("controls/constants/elevators/time-constant", + SGRawValuePointer(&time_constant)); + tie("controls/jbd", SGRawValuePointer(&jbd)); - props->tie("surface-positions/jbd-pos-norm", + tie("surface-positions/jbd-pos-norm", SGRawValuePointer(&jbd_pos_norm)); - props->tie("controls/constants/jbd/trans-time-s", + tie("controls/constants/jbd/trans-time-s", SGRawValuePointer(&jbd_transition_time)); - props->tie("controls/constants/jbd/time-constant", + tie("controls/constants/jbd/time-constant", SGRawValuePointer(&jbd_time_constant)); - props->tie("controls/turn-to-recovery-hdg", + tie("controls/turn-to-recovery-hdg", SGRawValuePointer(&turn_to_recovery_hdg)); - props->tie("controls/turn-to-base-course", + tie("controls/turn-to-base-course", SGRawValuePointer(&turn_to_base_course)); - props->setBoolValue("controls/flols/cut-lights", false); props->setBoolValue("controls/flols/wave-off-lights", false); props->setBoolValue("controls/flols/cond-datum-lights", true); @@ -315,36 +314,6 @@ void FGAICarrier::bind() { props->setDoubleValue("controls/lighting/flood-lights-red-norm", 0); } - -void FGAICarrier::unbind() { - FGAIShip::unbind(); - - props->untie("velocities/true-airspeed-kt"); - props->untie("controls/flols/source-lights"); - props->untie("controls/flols/distance-m"); - props->untie("controls/flols/angle-degs"); - props->untie("controls/turn-to-launch-hdg"); - props->untie("environment/wind-speed-true-kts"); - props->untie("environment/wind-from-true-degs"); - props->untie("environment/rel-wind-from-degs"); - props->untie("environment/rel-wind-speed-kts"); - props->untie("environment/in-to-wind"); - //props->untie("controls/flols/wave-off-lights"); - props->untie("controls/elevators"); - props->untie("surface-positions/elevators-pos-norm"); - props->untie("controls/constants/elevators/trans-time-secs"); - props->untie("controls/constants/elevators/time-constant"); - props->untie("controls/jbd"); - props->untie("surface-positions/jbd/pos-norm"); - props->untie("controls/constants/jbd/trans-time-s"); - props->untie("controls/jbd-time-constant"); - props->untie("controls/mp-control"); - props->untie("controls/ai-control"); - props->untie("controls/turn-to-recovery-hdg"); - props->untie("controls/turn-to-base-course"); -} - - bool FGAICarrier::getParkPosition(const string& id, SGGeod& geodPos, double& hdng, SGVec3d& uvw) { diff --git a/src/AIModel/AICarrier.hxx b/src/AIModel/AICarrier.hxx index da3380502..a34279b8f 100644 --- a/src/AIModel/AICarrier.hxx +++ b/src/AIModel/AICarrier.hxx @@ -49,7 +49,6 @@ public: void setTACANChannelID(const string &); virtual void bind(); - virtual void unbind(); void UpdateWind ( double dt ); void setWind_from_east( double fps ); void setWind_from_north( double fps ); diff --git a/src/AIModel/AIEscort.cxx b/src/AIModel/AIEscort.cxx index c88e9af33..9d19ce4b4 100644 --- a/src/AIModel/AIEscort.cxx +++ b/src/AIModel/AIEscort.cxx @@ -91,46 +91,32 @@ void FGAIEscort::readFromScenario(SGPropertyNode* scFileNode) { void FGAIEscort::bind() { FGAIShip::bind(); - props->tie("station/rel-bearing-deg", + tie("station/rel-bearing-deg", SGRawValuePointer(&_stn_relbrg)); - props->tie("station/true-bearing-deg", + tie("station/true-bearing-deg", SGRawValuePointer(&_stn_truebrg)); - props->tie("station/range-nm", + tie("station/range-nm", SGRawValuePointer(&_stn_range)); - props->tie("station/range-limit-nm", + tie("station/range-limit-nm", SGRawValuePointer(&_stn_limit)); - props->tie("station/angle-limit-deg", + tie("station/angle-limit-deg", SGRawValuePointer(&_stn_angle_limit)); - props->tie("station/speed-kts", + tie("station/speed-kts", SGRawValuePointer(&_stn_speed)); - props->tie("station/height-ft", + tie("station/height-ft", SGRawValuePointer(&_stn_height)); - props->tie("controls/update-interval-sec", + tie("controls/update-interval-sec", SGRawValuePointer(&_interval)); - props->tie("controls/parent-mp-control", + tie("controls/parent-mp-control", SGRawValuePointer(&_MPControl)); - props->tie("station/target-range-nm", + tie("station/target-range-nm", SGRawValuePointer(&_tgtrange)); - props->tie("station/target-brg-deg-t", + tie("station/target-brg-deg-t", SGRawValuePointer(&_tgtbrg)); - props->tie("station/patrol", + tie("station/patrol", SGRawValuePointer(&_patrol)); } -void FGAIEscort::unbind() { - FGAIShip::unbind(); - - props->untie("station/rel-bearing-deg"); - props->untie("station/true-bearing-deg"); - props->untie("station/range-nm"); - props->untie("station/range-limit-nm"); - props->untie("station/angle-limit-deg"); - props->untie("station/speed-kts"); - props->untie("station/height-ft"); - props->untie("controls/update-interval-sec"); - -} - bool FGAIEscort::init(bool search_in_AI_path) { if (!FGAIShip::init(search_in_AI_path)) return false; diff --git a/src/AIModel/AIEscort.hxx b/src/AIModel/AIEscort.hxx index a300f645e..380a92f28 100644 --- a/src/AIModel/AIEscort.hxx +++ b/src/AIModel/AIEscort.hxx @@ -42,7 +42,6 @@ public: bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void reinit(); virtual void update (double dt); diff --git a/src/AIModel/AIGroundVehicle.cxx b/src/AIModel/AIGroundVehicle.cxx index b39a1e19b..e6df8d302 100644 --- a/src/AIModel/AIGroundVehicle.cxx +++ b/src/AIModel/AIGroundVehicle.cxx @@ -84,61 +84,40 @@ void FGAIGroundVehicle::readFromScenario(SGPropertyNode* scFileNode) { void FGAIGroundVehicle::bind() { FGAIShip::bind(); - props->tie("controls/constants/elevation-coeff", + tie("controls/constants/elevation-coeff", SGRawValuePointer(&_elevation_coeff)); - props->tie("controls/constants/pitch-coeff", + tie("controls/constants/pitch-coeff", SGRawValuePointer(&_pitch_coeff)); - props->tie("position/ht-AGL-ft", + tie("position/ht-AGL-ft", SGRawValuePointer(&_ht_agl_ft)); - props->tie("hitch/rel-bearing-deg", + tie("hitch/rel-bearing-deg", SGRawValuePointer(&_relbrg)); - props->tie("hitch/tow-angle-deg", + tie("hitch/tow-angle-deg", SGRawValuePointer(&_tow_angle)); - props->tie("hitch/range-ft", + tie("hitch/range-ft", SGRawValuePointer(&_range_ft)); - props->tie("hitch/x-offset-ft", + tie("hitch/x-offset-ft", SGRawValuePointer(&_x_offset)); - props->tie("hitch/y-offset-ft", + tie("hitch/y-offset-ft", SGRawValuePointer(&_y_offset)); - props->tie("hitch/z-offset-ft", + tie("hitch/z-offset-ft", SGRawValuePointer(&_z_offset)); - props->tie("hitch/parent-x-offset-ft", + tie("hitch/parent-x-offset-ft", SGRawValuePointer(&_parent_x_offset)); - props->tie("hitch/parent-y-offset-ft", + tie("hitch/parent-y-offset-ft", SGRawValuePointer(&_parent_y_offset)); - props->tie("hitch/parent-z-offset-ft", + tie("hitch/parent-z-offset-ft", SGRawValuePointer(&_parent_z_offset)); - props->tie("controls/constants/tow-angle/gain", + tie("controls/constants/tow-angle/gain", SGRawValuePointer(&_tow_angle_gain)); - props->tie("controls/constants/tow-angle/limit-deg", + tie("controls/constants/tow-angle/limit-deg", SGRawValuePointer(&_tow_angle_limit)); - props->tie("controls/contact-x1-offset-ft", + tie("controls/contact-x1-offset-ft", SGRawValuePointer(&_contact_x1_offset)); - props->tie("controls/contact-x2-offset-ft", + tie("controls/contact-x2-offset-ft", SGRawValuePointer(&_contact_x2_offset)); } -void FGAIGroundVehicle::unbind() { - FGAIShip::unbind(); - - props->untie("controls/constants/elevation-coeff"); - props->untie("controls/constants/pitch-coeff"); - props->untie("position/ht-AGL-ft"); - props->untie("hitch/rel-bearing-deg"); - props->untie("hitch/tow-angle-deg"); - props->untie("hitch/range-ft"); - props->untie("hitch/x-offset-ft"); - props->untie("hitch/y-offset-ft"); - props->untie("hitch/z-offset-ft"); - props->untie("hitch/parent-x-offset-ft"); - props->untie("hitch/parent-y-offset-ft"); - props->untie("hitch/parent-y-offset-ft"); - props->untie("controls/constants/tow-angle/gain"); - props->untie("controls/constants/tow-angle/limit-deg"); - props->untie("controls/contact-x1-offset-ft"); - props->untie("controls/contact-x2-offset-ft"); -} - bool FGAIGroundVehicle::init(bool search_in_AI_path) { if (!FGAIShip::init(search_in_AI_path)) return false; diff --git a/src/AIModel/AIGroundVehicle.hxx b/src/AIModel/AIGroundVehicle.hxx index 08491bad6..2e4a2349f 100644 --- a/src/AIModel/AIGroundVehicle.hxx +++ b/src/AIModel/AIGroundVehicle.hxx @@ -40,7 +40,6 @@ public: bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void reinit(); virtual void update (double dt); diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index caa45ce9f..0b73c9ba4 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -74,10 +74,10 @@ bool FGAIMultiplayer::init(bool search_in_AI_path) { void FGAIMultiplayer::bind() { FGAIBase::bind(); - props->tie("refuel/contact", SGRawValuePointer(&contact)); - props->tie("tanker", SGRawValuePointer(&isTanker)); + tie("refuel/contact", SGRawValuePointer(&contact)); + tie("tanker", SGRawValuePointer(&isTanker)); - props->tie("controls/invisible", + tie("controls/invisible", SGRawValuePointer(&invisible)); #define AIMPROProp(type, name) \ @@ -87,30 +87,18 @@ SGRawValueMethods(*this, &FGAIMultiplayer::get##name) SGRawValueMethods(*this, \ &FGAIMultiplayer::get##name, &FGAIMultiplayer::set##name) - //props->tie("callsign", AIMPROProp(const char *, CallSign)); + //tie("callsign", AIMPROProp(const char *, CallSign)); - props->tie("controls/allow-extrapolation", - AIMPRWProp(bool, AllowExtrapolation)); - props->tie("controls/lag-adjust-system-speed", - AIMPRWProp(double, LagAdjustSystemSpeed)); + tie("controls/allow-extrapolation", + AIMPRWProp(bool, AllowExtrapolation)); + tie("controls/lag-adjust-system-speed", + AIMPRWProp(double, LagAdjustSystemSpeed)); #undef AIMPROProp #undef AIMPRWProp } -void FGAIMultiplayer::unbind() { - FGAIBase::unbind(); - - //props->untie("callsign"); - props->untie("controls/allow-extrapolation"); - props->untie("controls/lag-adjust-system-speed"); - props->untie("controls/invisible"); - props->untie("refuel/contact"); - props->untie("tanker"); - -} - void FGAIMultiplayer::update(double dt) { using namespace simgear; diff --git a/src/AIModel/AIMultiplayer.hxx b/src/AIModel/AIMultiplayer.hxx index 4c8d50a00..748784995 100644 --- a/src/AIModel/AIMultiplayer.hxx +++ b/src/AIModel/AIMultiplayer.hxx @@ -34,7 +34,6 @@ public: virtual bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void update(double dt); void addMotionInfo(FGExternalMotionData& motionInfo, long stamp); @@ -86,7 +85,7 @@ private: long mLastTimestamp; - // Propertiies for tankers + // Properties for tankers SGPropertyNode_ptr refuel_node; bool isTanker; bool contact; // set if this tanker is within fuelling range diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 5cf94f19d..9ecc89175 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -146,110 +146,72 @@ void FGAIShip::reinit() void FGAIShip::bind() { FGAIBase::bind(); - props->tie("surface-positions/rudder-pos-deg", + tie("surface-positions/rudder-pos-deg", SGRawValuePointer(&_rudder)); - props->tie("controls/heading-lock", + tie("controls/heading-lock", SGRawValuePointer(&_hdg_lock)); - props->tie("controls/tgt-speed-kts", + tie("controls/tgt-speed-kts", SGRawValuePointer(&tgt_speed)); - props->tie("controls/tgt-heading-degs", + tie("controls/tgt-heading-degs", SGRawValuePointer(&tgt_heading)); - props->tie("controls/constants/rudder", + tie("controls/constants/rudder", SGRawValuePointer(&_rudder_constant)); - props->tie("controls/constants/roll-factor", + tie("controls/constants/roll-factor", SGRawValuePointer(&_roll_factor)); - props->tie("controls/constants/roll", + tie("controls/constants/roll", SGRawValuePointer(&_roll_constant)); - props->tie("controls/constants/rudder", + tie("controls/constants/rudder", SGRawValuePointer(&_rudder_constant)); - props->tie("controls/constants/speed", + tie("controls/constants/speed", SGRawValuePointer(&_speed_constant)); - props->tie("waypoint/range-nm", + tie("waypoint/range-nm", SGRawValuePointer(&_wp_range)); - props->tie("waypoint/brg-deg", + tie("waypoint/brg-deg", SGRawValuePointer(&_course)); - props->tie("waypoint/rangerate-nm-sec", + tie("waypoint/rangerate-nm-sec", SGRawValuePointer(&_range_rate)); - props->tie("waypoint/new", + tie("waypoint/new", SGRawValuePointer(&_new_waypoint)); - props->tie("waypoint/missed", + tie("waypoint/missed", SGRawValuePointer(&_missed)); - props->tie("waypoint/missed-count-sec", + tie("waypoint/missed-count-sec", SGRawValuePointer(&_missed_count)); - props->tie("waypoint/missed-range-nm", + tie("waypoint/missed-range-nm", SGRawValuePointer(&_missed_range)); - props->tie("waypoint/missed-time-sec", + tie("waypoint/missed-time-sec", SGRawValuePointer(&_missed_time_sec)); - props->tie("waypoint/wait-count-sec", + tie("waypoint/wait-count-sec", SGRawValuePointer(&_wait_count)); - props->tie("waypoint/xtrack-error-ft", + tie("waypoint/xtrack-error-ft", SGRawValuePointer(&_xtrack_error)); - props->tie("waypoint/waiting", + tie("waypoint/waiting", SGRawValuePointer(&_waiting)); - props->tie("waypoint/lead-angle-deg", + tie("waypoint/lead-angle-deg", SGRawValuePointer(&_lead_angle)); - props->tie("waypoint/tunnel", + tie("waypoint/tunnel", SGRawValuePointer(&_tunnel)); - props->tie("waypoint/alt-curr-m", + tie("waypoint/alt-curr-m", SGRawValuePointer(&_curr_alt)); - props->tie("waypoint/alt-prev-m", + tie("waypoint/alt-prev-m", SGRawValuePointer(&_prev_alt)); - props->tie("submodels/serviceable", + tie("submodels/serviceable", SGRawValuePointer(&_serviceable)); - props->tie("controls/turn-radius-ft", + tie("controls/turn-radius-ft", SGRawValuePointer(&turn_radius_ft)); - props->tie("controls/turn-radius-corrected-ft", + tie("controls/turn-radius-corrected-ft", SGRawValuePointer(&_rd_turn_radius_ft)); - props->tie("controls/constants/lead-angle/gain", + tie("controls/constants/lead-angle/gain", SGRawValuePointer(&_lead_angle_gain)); - props->tie("controls/constants/lead-angle/limit-deg", + tie("controls/constants/lead-angle/limit-deg", SGRawValuePointer(&_lead_angle_limit)); - props->tie("controls/constants/lead-angle/proportion", + tie("controls/constants/lead-angle/proportion", SGRawValuePointer(&_proportion)); - props->tie("controls/fixed-turn-radius-ft", + tie("controls/fixed-turn-radius-ft", SGRawValuePointer(&_fixed_turn_radius)); - props->tie("controls/restart", + tie("controls/restart", SGRawValuePointer(&_restart)); - props->tie("velocities/speed-kts", - SGRawValuePointer(&speed)); -} - -void FGAIShip::unbind() { - FGAIBase::unbind(); - props->untie("surface-positions/rudder-pos-deg"); - props->untie("controls/heading-lock"); - props->untie("controls/tgt-speed-kts"); - props->untie("controls/tgt-heading-degs"); - props->untie("controls/constants/roll"); - props->untie("controls/constants/rudder"); - props->untie("controls/constants/roll-factor"); - props->untie("controls/constants/speed"); - props->untie("waypoint/range-nm"); - props->untie("waypoint/range-brg-deg"); - props->untie("waypoint/rangerate-nm-sec"); - props->untie("waypoint/new"); - props->untie("waypoint/missed"); - props->untie("waypoint/missed-count-sec"); - props->untie("waypoint/missed-time-sec"); - props->untie("waypoint/missed-range"); - props->untie("waypoint/wait-count-sec"); - props->untie("waypoint/lead-angle-deg"); - props->untie("waypoint/xtrack-error-ft"); - props->untie("waypoint/waiting"); - props->untie("waypoint/tunnel"); - props->untie("waypoint/alt-curr-m"); - props->untie("waypoint/alt-prev-m"); - props->untie("submodels/serviceable"); - props->untie("controls/turn-radius-ft"); - props->untie("controls/turn-radius-corrected-ft"); - props->untie("controls/constants/lead-angle/gain"); - props->untie("controls/constants/lead-angle/limit-deg"); - props->untie("controls/constants/lead-angle/proportion"); - props->untie("controls/fixed-turn-radius-ft"); - props->untie("controls/constants/speed"); - props->untie("controls/restart"); - props->untie("velocities/speed-kts"); - + tie("velocities/speed-kts", + SGRawValuePointer(&speed)); } void FGAIShip::update(double dt) { diff --git a/src/AIModel/AIShip.hxx b/src/AIModel/AIShip.hxx index 5c3c3b7f2..74a5ca2e7 100644 --- a/src/AIModel/AIShip.hxx +++ b/src/AIModel/AIShip.hxx @@ -39,7 +39,6 @@ public: virtual bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void update(double dt); virtual void reinit(); diff --git a/src/AIModel/AITanker.cxx b/src/AIModel/AITanker.cxx index ab7c8ed6d..6ab43e034 100644 --- a/src/AIModel/AITanker.cxx +++ b/src/AIModel/AITanker.cxx @@ -43,20 +43,14 @@ void FGAITanker::readFromScenario(SGPropertyNode* scFileNode) { void FGAITanker::bind() { FGAIAircraft::bind(); - props->tie("refuel/contact", SGRawValuePointer(&contact)); - props->tie("position/altitude-agl-ft",SGRawValuePointer(&altitude_agl_ft)); + tie("refuel/contact", SGRawValuePointer(&contact)); + tie("position/altitude-agl-ft",SGRawValuePointer(&altitude_agl_ft)); + props->setStringValue("navaids/tacan/channel-ID", TACAN_channel_id.c_str()); props->setStringValue("name", _name.c_str()); props->setBoolValue("tanker", true); } -void FGAITanker::unbind() { - FGAIAircraft::unbind(); - props->untie("refuel/contact"); - props->untie("position/altitude-agl-ft"); - -} - void FGAITanker::setTACANChannelID(const string& id) { TACAN_channel_id = id; } diff --git a/src/AIModel/AITanker.hxx b/src/AIModel/AITanker.hxx index ce4329a2c..8dcfe11ad 100644 --- a/src/AIModel/AITanker.hxx +++ b/src/AIModel/AITanker.hxx @@ -41,7 +41,6 @@ public: virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void bind(); - virtual void unbind(); virtual const char* getTypeString(void) const { return "tanker"; } diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index f47ba2356..4b1d653f8 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -77,38 +77,25 @@ bool FGAIThermal::init(bool search_in_AI_path) { } void FGAIThermal::bind() { - props->tie("position/altitude-agl-ft", // for debug and tweak + FGAIBase::bind(); + tie("position/altitude-agl-ft", // for debug and tweak SGRawValuePointer(&altitude_agl_ft)); - props->tie("alt-rel", // for debug and tweak + tie("alt-rel", // for debug and tweak SGRawValuePointer(&alt_rel)); - props->tie("time", // for debug and tweak + tie("time", // for debug and tweak SGRawValuePointer(&time)); - props->tie("xx", // for debug and tweak + tie("xx", // for debug and tweak SGRawValuePointer(&xx)); - props->tie("is-forming", // for debug abd tweak + tie("is-forming", // for debug abd tweak SGRawValuePointer(&is_forming)); - props->tie("is-formed", // for debug abd tweak + tie("is-formed", // for debug abd tweak SGRawValuePointer(&is_formed)); - props->tie("is-dying", // for debug abd tweak + tie("is-dying", // for debug abd tweak SGRawValuePointer(&is_dying)); - props->tie("is-dead", // for debug abd tweak + tie("is-dead", // for debug abd tweak SGRawValuePointer(&is_dead)); - FGAIBase::bind(); } -void FGAIThermal::unbind() { - props->untie("position/altitude-agl-ft"); - props->untie("alt-rel"); - props->untie("time"); - props->untie("is-forming"); - props->untie("is-formed"); - props->untie("is-dying"); - props->untie("is-dead"); - props->untie("xx"); - FGAIBase::unbind(); -} - - void FGAIThermal::update(double dt) { FGAIBase::update(dt); Run(dt); diff --git a/src/AIModel/AIThermal.hxx b/src/AIModel/AIThermal.hxx index 675a8aec7..1f37acdf0 100644 --- a/src/AIModel/AIThermal.hxx +++ b/src/AIModel/AIThermal.hxx @@ -33,49 +33,45 @@ using std::string; class FGAIThermal : public FGAIBase { public: - FGAIThermal(); ~FGAIThermal(); - - void readFromScenario(SGPropertyNode* scFileNode); + + void readFromScenario(SGPropertyNode* scFileNode); virtual bool init(bool search_in_AI_path=false); - virtual void bind(); - virtual void unbind(); + virtual void bind(); virtual void update(double dt); inline void setMaxStrength( double s ) { max_strength = s; }; - inline void setDiameter( double d ) { diameter = d; }; - inline void setHeight( double h ) { height = h; }; - inline void setMaxUpdraft( double lift ) { v_up_max = lift; }; + inline void setDiameter( double d ) { diameter = d; }; + inline void setHeight( double h ) { height = h; }; + inline void setMaxUpdraft( double lift ) { v_up_max = lift; }; inline void setMinUpdraft( double sink ) { v_up_min = sink; }; inline void setR_up_frac( double r ) { r_up_frac = r; }; - + inline double getStrength() const { return strength; }; - inline double getDiameter() const { return diameter; }; - inline double getHeight() const { return height; }; - inline double getV_up_max() const { return v_up_max; }; + inline double getDiameter() const { return diameter; }; + inline double getHeight() const { return height; }; + inline double getV_up_max() const { return v_up_max; }; inline double getV_up_min() const { return v_up_min; }; inline double getR_up_frac() const { return r_up_frac; }; - virtual const char* getTypeString(void) const { return "thermal"; } + virtual const char* getTypeString(void) const { return "thermal"; } void getGroundElev(double dt); - private: - void Run(double dt); double get_strength_fac(double alt_frac); double max_strength; - double strength; - double diameter; - double height; - double factor; + double strength; + double diameter; + double height; + double factor; double alt_rel; double alt; double v_up_max; double v_up_min; - double r_up_frac; + double r_up_frac; double cycle_timer; double dt_count; double time; @@ -94,6 +90,4 @@ private: }; - - #endif // _FG_AIThermal_HXX diff --git a/src/AIModel/AIWingman.cxx b/src/AIModel/AIWingman.cxx index 9ba01042a..6842c0916 100644 --- a/src/AIModel/AIWingman.cxx +++ b/src/AIModel/AIWingman.cxx @@ -81,125 +81,83 @@ void FGAIWingman::bind() { props->untie("controls/slave-to-ac"); - props->tie("id", SGRawValueMethods(*this, + tie("id", SGRawValueMethods(*this, &FGAIBase::getID)); - props->tie("subID", SGRawValueMethods(*this, + tie("subID", SGRawValueMethods(*this, &FGAIBase::_getSubID)); - props->tie("position/altitude-ft", + tie("position/altitude-ft", SGRawValueMethods(*this, &FGAIBase::_getElevationFt, &FGAIBase::_setAltitude)); - props->tie("position/latitude-deg", + tie("position/latitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLatitude, &FGAIBase::_setLatitude)); - props->tie("position/longitude-deg", + tie("position/longitude-deg", SGRawValueMethods(*this, &FGAIBase::_getLongitude, &FGAIBase::_setLongitude)); - props->tie("controls/break", SGRawValuePointer(&_break)); - props->tie("controls/join", SGRawValuePointer(&_join)); + tie("controls/break", SGRawValuePointer(&_break)); + tie("controls/join", SGRawValuePointer(&_join)); - props->tie("controls/formate-to-ac", + tie("controls/formate-to-ac", SGRawValueMethods (*this, &FGAIWingman::getFormate, &FGAIWingman::setFormate)); - props->tie("controls/tgt-heading-deg", + tie("controls/tgt-heading-deg", SGRawValueMethods (*this, &FGAIWingman::getTgtHdg, &FGAIWingman::setTgtHdg)); - props->tie("controls/tgt-speed-kt", + tie("controls/tgt-speed-kt", SGRawValueMethods (*this, &FGAIWingman::getTgtSpd, &FGAIWingman::setTgtSpd)); - props->tie("controls/break-deg-rel", + tie("controls/break-deg-rel", SGRawValueMethods (*this, &FGAIWingman::getBrkAng, &FGAIWingman::setBrkAng)); - props->tie("controls/coefficients/heading", + tie("controls/coefficients/heading", SGRawValuePointer(&_coeff_hdg)); - props->tie("controls/coefficients/pitch", + tie("controls/coefficients/pitch", SGRawValuePointer(&_coeff_pch)); - props->tie("controls/coefficients/bank", + tie("controls/coefficients/bank", SGRawValuePointer(&_coeff_bnk)); - props->tie("controls/coefficients/speed", + tie("controls/coefficients/speed", SGRawValuePointer(&_coeff_spd)); - props->tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); - props->tie("orientation/roll-deg", SGRawValuePointer(&roll)); - props->tie("orientation/true-heading-deg", SGRawValuePointer(&hdg)); + tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); + tie("orientation/roll-deg", SGRawValuePointer(&roll)); + tie("orientation/true-heading-deg", SGRawValuePointer(&hdg)); - props->tie("submodels/serviceable", SGRawValuePointer(&serviceable)); + tie("submodels/serviceable", SGRawValuePointer(&serviceable)); - props->tie("load/rel-brg-to-user-deg", + tie("load/rel-brg-to-user-deg", SGRawValueMethods (*this, &FGAIBallistic::getRelBrgHitchToUser)); - props->tie("load/elev-to-user-deg", + tie("load/elev-to-user-deg", SGRawValueMethods (*this, &FGAIBallistic::getElevHitchToUser)); - props->tie("velocities/vertical-speed-fps", + tie("velocities/vertical-speed-fps", SGRawValuePointer(&vs)); - props->tie("velocities/true-airspeed-kt", + tie("velocities/true-airspeed-kt", SGRawValuePointer(&speed)); - props->tie("velocities/speed-east-fps", + tie("velocities/speed-east-fps", SGRawValuePointer(&_speed_east_fps)); - props->tie("velocities/speed-north-fps", + tie("velocities/speed-north-fps", SGRawValuePointer(&_speed_north_fps)); - props->tie("position/x-offset", + tie("position/x-offset", SGRawValueMethods(*this, &FGAIBase::_getXOffset, &FGAIBase::setXoffset)); - props->tie("position/y-offset", + tie("position/y-offset", SGRawValueMethods(*this, &FGAIBase::_getYOffset, &FGAIBase::setYoffset)); - props->tie("position/z-offset", + tie("position/z-offset", SGRawValueMethods(*this, &FGAIBase::_getZOffset, &FGAIBase::setZoffset)); - props->tie("position/tgt-x-offset", + tie("position/tgt-x-offset", SGRawValueMethods(*this, &FGAIBallistic::getTgtXOffset, &FGAIBallistic::setTgtXOffset)); - props->tie("position/tgt-y-offset", + tie("position/tgt-y-offset", SGRawValueMethods(*this, &FGAIBallistic::getTgtYOffset, &FGAIBallistic::setTgtYOffset)); - props->tie("position/tgt-z-offset", + tie("position/tgt-z-offset", SGRawValueMethods(*this, &FGAIBallistic::getTgtZOffset, &FGAIBallistic::setTgtZOffset)); } -void FGAIWingman::unbind() { - FGAIBallistic::unbind(); - - props->untie("id"); - props->untie("SubID"); - - props->untie("orientation/pitch-deg"); - props->untie("orientation/roll-deg"); - props->untie("orientation/true-heading-deg"); - - props->untie("controls/formate-to-ac"); - props->untie("controls/break"); - props->untie("controls/join"); - props->untie("controls/tgt-heading-deg"); - props->untie("controls/tgt-speed-kt"); - props->untie("controls/break-deg-rel"); - props->untie("controls/coefficients/heading"); - props->untie("controls/coefficients/pitch"); - props->untie("controls/coefficients/bank"); - props->untie("controls/coefficients/speed"); - - props->untie("submodels/serviceable"); - - props->untie("velocities/true-airspeed-kt"); - props->untie("velocities/vertical-speed-fps"); - props->untie("velocities/speed_east_fps"); - props->untie("velocities/speed_north_fps"); - - props->untie("load/rel-brg-to-user-deg"); - props->untie("load/elev-to-user-deg"); - - props->untie("position/altitude-ft"); - props->untie("position/latitude-deg"); - props->untie("position/longitude-deg"); - props->untie("position/x-offset"); - props->untie("position/y-offset"); - props->untie("position/z-offset"); - props->untie("position/tgt-x-offset"); - props->untie("position/tgt-y-offset"); - props->untie("position/tgt-z-offset"); -} - bool FGAIWingman::init(bool search_in_AI_path) { if (!FGAIBallistic::init(search_in_AI_path)) return false; diff --git a/src/AIModel/AIWingman.hxx b/src/AIModel/AIWingman.hxx index c291069ba..fac079a23 100644 --- a/src/AIModel/AIWingman.hxx +++ b/src/AIModel/AIWingman.hxx @@ -38,7 +38,6 @@ public: bool init(bool search_in_AI_path=false); virtual void bind(); - virtual void unbind(); virtual void reinit(); virtual void update (double dt); diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index f3d55075a..458320257 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -240,175 +240,174 @@ FGInterface::bind () { bound = true; - // Aircraft position - fgTie("/position/latitude-deg", this, - &FGInterface::get_Latitude_deg, - &FGInterface::set_Latitude_deg, - false); + _tiedProperties.setRoot(globals->get_props()); + // Aircraft position + _tiedProperties.Tie("/position/latitude-deg", this, + &FGInterface::get_Latitude_deg, + &FGInterface::set_Latitude_deg, + false); fgSetArchivable("/position/latitude-deg"); - fgTie("/position/longitude-deg", this, - &FGInterface::get_Longitude_deg, - &FGInterface::set_Longitude_deg, - false); + _tiedProperties.Tie("/position/longitude-deg", this, + &FGInterface::get_Longitude_deg, + &FGInterface::set_Longitude_deg, + false); fgSetArchivable("/position/longitude-deg"); - fgTie("/position/altitude-ft", this, - &FGInterface::get_Altitude, - &FGInterface::set_Altitude, - false); + _tiedProperties.Tie("/position/altitude-ft", this, + &FGInterface::get_Altitude, + &FGInterface::set_Altitude, + false); fgSetArchivable("/position/altitude-ft"); - fgTie("/position/altitude-agl-ft", this, - &FGInterface::get_Altitude_AGL, &FGInterface::set_AltitudeAGL, false); + _tiedProperties.Tie("/position/altitude-agl-ft", this, + &FGInterface::get_Altitude_AGL, &FGInterface::set_AltitudeAGL, false); fgSetArchivable("/position/ground-elev-ft"); - fgTie("/position/ground-elev-ft", this, - &FGInterface::get_Runway_altitude); // read-only + _tiedProperties.Tie("/position/ground-elev-ft", this, + &FGInterface::get_Runway_altitude); // read-only fgSetArchivable("/position/ground-elev-m"); - fgTie("/position/ground-elev-m", this, - &FGInterface::get_Runway_altitude_m); // read-only - fgTie("/environment/ground-elevation-m", this, - &FGInterface::get_Runway_altitude_m); // read-only + _tiedProperties.Tie("/position/ground-elev-m", this, + &FGInterface::get_Runway_altitude_m); // read-only + _tiedProperties.Tie("/environment/ground-elevation-m", this, + &FGInterface::get_Runway_altitude_m); // read-only fgSetArchivable("/position/sea-level-radius-ft"); - fgTie("/position/sea-level-radius-ft", this, - &FGInterface::get_Sea_level_radius, - &FGInterface::_set_Sea_level_radius, false); - - // Orientation - fgTie("/orientation/roll-deg", this, - &FGInterface::get_Phi_deg, - &FGInterface::set_Phi_deg, false); + _tiedProperties.Tie("/position/sea-level-radius-ft", this, + &FGInterface::get_Sea_level_radius, + &FGInterface::_set_Sea_level_radius, false); + + // Orientation + _tiedProperties.Tie("/orientation/roll-deg", this, + &FGInterface::get_Phi_deg, + &FGInterface::set_Phi_deg, false); fgSetArchivable("/orientation/roll-deg"); - fgTie("/orientation/pitch-deg", this, - &FGInterface::get_Theta_deg, - &FGInterface::set_Theta_deg, false); + _tiedProperties.Tie("/orientation/pitch-deg", this, + &FGInterface::get_Theta_deg, + &FGInterface::set_Theta_deg, false); fgSetArchivable("/orientation/pitch-deg"); - fgTie("/orientation/heading-deg", this, - &FGInterface::get_Psi_deg, - &FGInterface::set_Psi_deg, false); + _tiedProperties.Tie("/orientation/heading-deg", this, + &FGInterface::get_Psi_deg, + &FGInterface::set_Psi_deg, false); fgSetArchivable("/orientation/heading-deg"); - fgTie("/orientation/track-deg", this, - &FGInterface::get_Track); // read-only + _tiedProperties.Tie("/orientation/track-deg", this, + &FGInterface::get_Track); // read-only // Body-axis "euler rates" (rotation speed, but in a funny // representation). - fgTie("/orientation/roll-rate-degps", this, - &FGInterface::get_Phi_dot_degps, - &FGInterface::set_Phi_dot_degps, false); - fgTie("/orientation/pitch-rate-degps", this, - &FGInterface::get_Theta_dot_degps, - &FGInterface::set_Theta_dot_degps, false); - fgTie("/orientation/yaw-rate-degps", this, - &FGInterface::get_Psi_dot_degps, - &FGInterface::set_Psi_dot_degps, false); - - fgTie("/orientation/p-body", this, &FGInterface::get_P_body); // read-only - fgTie("/orientation/q-body", this, &FGInterface::get_Q_body); // read-only - fgTie("/orientation/r-body", this, &FGInterface::get_R_body); // read-only - - // Ground speed knots - fgTie("/velocities/groundspeed-kt", this, - &FGInterface::get_V_ground_speed_kt, - &FGInterface::set_V_ground_speed_kt); // read-only - - // Calibrated airspeed - fgTie("/velocities/airspeed-kt", this, - &FGInterface::get_V_calibrated_kts, - &FGInterface::set_V_calibrated_kts, - false); - - fgTie("/velocities/equivalent-kt", this, - &FGInterface::get_V_equiv_kts); // read-only - - // Mach number - fgTie("/velocities/mach", this, - &FGInterface::get_Mach_number, - &FGInterface::set_Mach_number, - false); - - // Local velocities -// fgTie("/velocities/speed-north-fps", this, -// &FGInterface::get_V_north, -// &FGInterface::set_V_north); + _tiedProperties.Tie("/orientation/roll-rate-degps", this, + &FGInterface::get_Phi_dot_degps, + &FGInterface::set_Phi_dot_degps, false); + _tiedProperties.Tie("/orientation/pitch-rate-degps", this, + &FGInterface::get_Theta_dot_degps, + &FGInterface::set_Theta_dot_degps, false); + _tiedProperties.Tie("/orientation/yaw-rate-degps", this, + &FGInterface::get_Psi_dot_degps, + &FGInterface::set_Psi_dot_degps, false); + + _tiedProperties.Tie("/orientation/p-body", this, &FGInterface::get_P_body); // read-only + _tiedProperties.Tie("/orientation/q-body", this, &FGInterface::get_Q_body); // read-only + _tiedProperties.Tie("/orientation/r-body", this, &FGInterface::get_R_body); // read-only + + // Ground speed knots + _tiedProperties.Tie("/velocities/groundspeed-kt", this, + &FGInterface::get_V_ground_speed_kt, + &FGInterface::set_V_ground_speed_kt); // read-only + + // Calibrated airspeed + _tiedProperties.Tie("/velocities/airspeed-kt", this, + &FGInterface::get_V_calibrated_kts, + &FGInterface::set_V_calibrated_kts, + false); + + _tiedProperties.Tie("/velocities/equivalent-kt", this, + &FGInterface::get_V_equiv_kts); // read-only + + // Mach number + _tiedProperties.Tie("/velocities/mach", this, + &FGInterface::get_Mach_number, + &FGInterface::set_Mach_number, + false); + + // Local velocities +// _tiedProperties.Tie("/velocities/speed-north-fps", this, +// &FGInterface::get_V_north, +// &FGInterface::set_V_north); // fgSetArchivable("/velocities/speed-north-fps"); -// fgTie("/velocities/speed-east-fps", this, -// &FGInterface::get_V_east, -// &FGInterface::set_V_east); +// _tiedProperties.Tie("/velocities/speed-east-fps", this, +// &FGInterface::get_V_east, +// &FGInterface::set_V_east); // fgSetArchivable("/velocities/speed-east-fps"); -// fgTie("/velocities/speed-down-fps", this, -// &FGInterface::get_V_down, -// &FGInterface::set_V_down); +// _tiedProperties.Tie("/velocities/speed-down-fps", this, +// &FGInterface::get_V_down, +// &FGInterface::set_V_down); // fgSetArchivable("/velocities/speed-down-fps"); - // FIXME: Temporarily read-only, until the - // incompatibilities between JSBSim and - // LaRCSim are fixed (LaRCSim adds the - // earth's rotation to the east velocity). - fgTie("/velocities/speed-north-fps", this, - &FGInterface::get_V_north, &FGInterface::set_V_north, false); - fgTie("/velocities/speed-east-fps", this, - &FGInterface::get_V_east, &FGInterface::set_V_east, false); - fgTie("/velocities/speed-down-fps", this, - &FGInterface::get_V_down, &FGInterface::set_V_down, false); - - fgTie("/velocities/north-relground-fps", this, - &FGInterface::get_V_north_rel_ground); // read-only - fgTie("/velocities/east-relground-fps", this, - &FGInterface::get_V_east_rel_ground); // read-only - fgTie("/velocities/down-relground-fps", this, - &FGInterface::get_V_down_rel_ground); // read-only - - - // Relative wind - // FIXME: temporarily archivable, until - // the NED problem is fixed. - fgTie("/velocities/uBody-fps", this, - &FGInterface::get_uBody, - &FGInterface::set_uBody, - false); + + // FIXME: Temporarily read-only, until the + // incompatibilities between JSBSim and + // LaRCSim are fixed (LaRCSim adds the + // earth's rotation to the east velocity). + _tiedProperties.Tie("/velocities/speed-north-fps", this, + &FGInterface::get_V_north, &FGInterface::set_V_north, false); + _tiedProperties.Tie("/velocities/speed-east-fps", this, + &FGInterface::get_V_east, &FGInterface::set_V_east, false); + _tiedProperties.Tie("/velocities/speed-down-fps", this, + &FGInterface::get_V_down, &FGInterface::set_V_down, false); + + _tiedProperties.Tie("/velocities/north-relground-fps", this, + &FGInterface::get_V_north_rel_ground); // read-only + _tiedProperties.Tie("/velocities/east-relground-fps", this, + &FGInterface::get_V_east_rel_ground); // read-only + _tiedProperties.Tie("/velocities/down-relground-fps", this, + &FGInterface::get_V_down_rel_ground); // read-only + + // Relative wind + // FIXME: temporarily archivable, until the NED problem is fixed. + _tiedProperties.Tie("/velocities/uBody-fps", this, + &FGInterface::get_uBody, + &FGInterface::set_uBody, + false); fgSetArchivable("/velocities/uBody-fps"); - fgTie("/velocities/vBody-fps", this, - &FGInterface::get_vBody, - &FGInterface::set_vBody, - false); + _tiedProperties.Tie("/velocities/vBody-fps", this, + &FGInterface::get_vBody, + &FGInterface::set_vBody, + false); fgSetArchivable("/velocities/vBody-fps"); - fgTie("/velocities/wBody-fps", this, - &FGInterface::get_wBody, - &FGInterface::set_wBody, - false); + _tiedProperties.Tie("/velocities/wBody-fps", this, + &FGInterface::get_wBody, + &FGInterface::set_wBody, + false); fgSetArchivable("/velocities/wBody-fps"); - // Climb and slip (read-only) - fgTie("/velocities/vertical-speed-fps", this, - &FGInterface::get_Climb_Rate, - &FGInterface::set_Climb_Rate, false ); - fgTie("/velocities/glideslope", this, - &FGInterface::get_Gamma_vert_rad, - &FGInterface::set_Gamma_vert_rad, false ); - fgTie("/orientation/side-slip-rad", this, - &FGInterface::get_Beta, &FGInterface::_set_Beta, false); - fgTie("/orientation/side-slip-deg", this, - &FGInterface::get_Beta_deg); // read-only - fgTie("/orientation/alpha-deg", this, - &FGInterface::get_Alpha_deg, &FGInterface::set_Alpha_deg, false); - fgTie("/accelerations/nlf", this, - &FGInterface::get_Nlf); // read-only - - // NED accelerations - fgTie("/accelerations/ned/north-accel-fps_sec", - this, &FGInterface::get_V_dot_north); // read-only - fgTie("/accelerations/ned/east-accel-fps_sec", - this, &FGInterface::get_V_dot_east); // read-only - fgTie("/accelerations/ned/down-accel-fps_sec", - this, &FGInterface::get_V_dot_down); // read-only - - // Pilot accelerations - fgTie("/accelerations/pilot/x-accel-fps_sec", - this, &FGInterface::get_A_X_pilot, &FGInterface::set_A_X_pilot, false); - fgTie("/accelerations/pilot/y-accel-fps_sec", - this, &FGInterface::get_A_Y_pilot, &FGInterface::set_A_Y_pilot, false); - fgTie("/accelerations/pilot/z-accel-fps_sec", - this, &FGInterface::get_A_Z_pilot, &FGInterface::set_A_Z_pilot, false); - - fgTie("/accelerations/n-z-cg-fps_sec", - this, &FGInterface::get_N_Z_cg); // read-only - + // Climb and slip (read-only) + _tiedProperties.Tie("/velocities/vertical-speed-fps", this, + &FGInterface::get_Climb_Rate, + &FGInterface::set_Climb_Rate, false ); + _tiedProperties.Tie("/velocities/glideslope", this, + &FGInterface::get_Gamma_vert_rad, + &FGInterface::set_Gamma_vert_rad, false ); + _tiedProperties.Tie("/orientation/side-slip-rad", this, + &FGInterface::get_Beta, &FGInterface::_set_Beta, false); + _tiedProperties.Tie("/orientation/side-slip-deg", this, + &FGInterface::get_Beta_deg); // read-only + _tiedProperties.Tie("/orientation/alpha-deg", this, + &FGInterface::get_Alpha_deg, &FGInterface::set_Alpha_deg, false); + _tiedProperties.Tie("/accelerations/nlf", this, + &FGInterface::get_Nlf); // read-only + + // NED accelerations + _tiedProperties.Tie("/accelerations/ned/north-accel-fps_sec", + this, &FGInterface::get_V_dot_north); // read-only + _tiedProperties.Tie("/accelerations/ned/east-accel-fps_sec", + this, &FGInterface::get_V_dot_east); // read-only + _tiedProperties.Tie("/accelerations/ned/down-accel-fps_sec", + this, &FGInterface::get_V_dot_down); // read-only + + // Pilot accelerations + _tiedProperties.Tie("/accelerations/pilot/x-accel-fps_sec", + this, &FGInterface::get_A_X_pilot, &FGInterface::set_A_X_pilot, false); + _tiedProperties.Tie("/accelerations/pilot/y-accel-fps_sec", + this, &FGInterface::get_A_Y_pilot, &FGInterface::set_A_Y_pilot, false); + _tiedProperties.Tie("/accelerations/pilot/z-accel-fps_sec", + this, &FGInterface::get_A_Z_pilot, &FGInterface::set_A_Z_pilot, false); + + _tiedProperties.Tie("/accelerations/n-z-cg-fps_sec", + this, &FGInterface::get_N_Z_cg); // read-only } @@ -421,56 +420,8 @@ FGInterface::bind () void FGInterface::unbind () { - if (!bound) { - return; - } - + _tiedProperties.Untie(); bound = false; - - fgUntie("/position/latitude-deg"); - fgUntie("/position/longitude-deg"); - fgUntie("/position/altitude-ft"); - fgUntie("/position/altitude-agl-ft"); - fgUntie("/position/ground-elev-ft"); - fgUntie("/position/ground-elev-m"); - fgUntie("/environment/ground-elevation-m"); - fgUntie("/position/sea-level-radius-ft"); - fgUntie("/orientation/roll-deg"); - fgUntie("/orientation/pitch-deg"); - fgUntie("/orientation/heading-deg"); - fgUntie("/orientation/track-deg"); - fgUntie("/orientation/roll-rate-degps"); - fgUntie("/orientation/pitch-rate-degps"); - fgUntie("/orientation/yaw-rate-degps"); - fgUntie("/orientation/p-body"); - fgUntie("/orientation/q-body"); - fgUntie("/orientation/r-body"); - fgUntie("/orientation/side-slip-rad"); - fgUntie("/orientation/side-slip-deg"); - fgUntie("/orientation/alpha-deg"); - fgUntie("/velocities/airspeed-kt"); - fgUntie("/velocities/groundspeed-kt"); - fgUntie("/velocities/equivalent-kt"); - fgUntie("/velocities/mach"); - fgUntie("/velocities/speed-north-fps"); - fgUntie("/velocities/speed-east-fps"); - fgUntie("/velocities/speed-down-fps"); - fgUntie("/velocities/north-relground-fps"); - fgUntie("/velocities/east-relground-fps"); - fgUntie("/velocities/down-relground-fps"); - fgUntie("/velocities/uBody-fps"); - fgUntie("/velocities/vBody-fps"); - fgUntie("/velocities/wBody-fps"); - fgUntie("/velocities/vertical-speed-fps"); - fgUntie("/velocities/glideslope"); - fgUntie("/accelerations/nlf"); - fgUntie("/accelerations/pilot/x-accel-fps_sec"); - fgUntie("/accelerations/pilot/y-accel-fps_sec"); - fgUntie("/accelerations/pilot/z-accel-fps_sec"); - fgUntie("/accelerations/ned/north-accel-fps_sec"); - fgUntie("/accelerations/ned/east-accel-fps_sec"); - fgUntie("/accelerations/ned/down-accel-fps_sec"); - fgUntie("/accelerations/n-z-cg-fps_sec"); } /** @@ -525,7 +476,7 @@ void FGInterface::_updateGeodeticPosition( double lat, double lon, double alt ) void FGInterface::_updateGeocentricPosition( double lat, double lon, - double alt ) + double alt ) { _updatePosition(SGGeoc::fromRadFt(lon, lat, get_Sea_level_radius() + alt)); } @@ -562,16 +513,16 @@ void FGInterface::set_Mach_number(double mach) { } void FGInterface::set_Velocities_Local( double north, - double east, - double down ){ + double east, + double down ){ v_local_v[0] = north; v_local_v[1] = east; v_local_v[2] = down; } void FGInterface::set_Velocities_Wind_Body( double u, - double v, - double w){ + double v, + double w){ v_wind_body_v[0] = u; v_wind_body_v[1] = v; v_wind_body_v[2] = w; @@ -579,11 +530,11 @@ void FGInterface::set_Velocities_Wind_Body( double u, // Euler angles void FGInterface::set_Euler_Angles( double phi, - double theta, - double psi ) { + double theta, + double psi ) { euler_angles_v[0] = phi; euler_angles_v[1] = theta; - euler_angles_v[2] = psi; + euler_angles_v[2] = psi; } // Flight Path @@ -600,16 +551,16 @@ void FGInterface::set_Static_temperature(double T) { static_temperature = T; } void FGInterface::set_Density(double rho) { density = rho; } void FGInterface::set_Velocities_Local_Airmass (double wnorth, - double weast, - double wdown ) { + double weast, + double wdown ) { v_local_airmass_v[0] = wnorth; v_local_airmass_v[1] = weast; v_local_airmass_v[2] = wdown; } -void FGInterface::_busdump(void) { - +void FGInterface::_busdump(void) +{ SG_LOG(SG_FLIGHT,SG_INFO,"d_cg_rp_body_v: " << d_cg_rp_body_v); SG_LOG(SG_FLIGHT,SG_INFO,"v_dot_local_v: " << v_dot_local_v); SG_LOG(SG_FLIGHT,SG_INFO,"v_dot_body_v: " << v_dot_body_v); diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 35ae2550a..9c312f33d 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -82,6 +82,7 @@ #include #include #include +#include #include using std::list; @@ -127,7 +128,7 @@ private: bool inited; // Have we bound to the property system - bool bound; + bool bound; // periodic update management variable. This is a scheme to run // the fdm with a fixed delta-t. We control how many iteration of @@ -187,6 +188,8 @@ private: double altitude_agl; double track; + simgear::TiedPropertyList _tiedProperties; + // the ground cache object itself. FGGroundCache ground_cache; diff --git a/src/Input/FGKeyboardInput.cxx b/src/Input/FGKeyboardInput.cxx index f6fe803ce..49426d27a 100644 --- a/src/Input/FGKeyboardInput.cxx +++ b/src/Input/FGKeyboardInput.cxx @@ -124,44 +124,29 @@ void FGKeyboardInput::postinit() void FGKeyboardInput::bind() { - fgTie("/devices/status/keyboard", getModifiers); - fgTie("/devices/status/keyboard/shift", getModShift); - fgTie("/devices/status/keyboard/ctrl", getModCtrl); - fgTie("/devices/status/keyboard/alt", getModAlt); - fgTie("/devices/status/keyboard/meta", getModMeta); - fgTie("/devices/status/keyboard/super", getModSuper); - fgTie("/devices/status/keyboard/hyper", getModHyper); - - _key_event->tie("key", SGRawValuePointer(&_key_code)); - _key_event->tie("pressed", SGRawValuePointer(&_key_pressed)); - _key_event->tie("modifier", SGRawValuePointer(&_key_modifiers)); - _key_event->tie("modifier/shift", SGRawValuePointer(&_key_shift)); - _key_event->tie("modifier/ctrl", SGRawValuePointer(&_key_ctrl)); - _key_event->tie("modifier/alt", SGRawValuePointer(&_key_alt)); - _key_event->tie("modifier/meta", SGRawValuePointer(&_key_meta)); - _key_event->tie("modifier/super", SGRawValuePointer(&_key_super)); - _key_event->tie("modifier/hyper", SGRawValuePointer(&_key_hyper)); + _tiedProperties.setRoot(fgGetNode("/device/status", true)); + _tiedProperties.Tie("keyboard", getModifiers); + _tiedProperties.Tie("keyboard/shift", getModShift); + _tiedProperties.Tie("keyboard/ctrl", getModCtrl); + _tiedProperties.Tie("keyboard/alt", getModAlt); + _tiedProperties.Tie("keyboard/meta", getModMeta); + _tiedProperties.Tie("keyboard/super", getModSuper); + _tiedProperties.Tie("keyboard/hyper", getModHyper); + + _tiedProperties.Tie(_key_event->getNode("key", true), SGRawValuePointer(&_key_code)); + _tiedProperties.Tie(_key_event->getNode("pressed", true), SGRawValuePointer(&_key_pressed)); + _tiedProperties.Tie(_key_event->getNode("modifier", true), SGRawValuePointer(&_key_modifiers)); + _tiedProperties.Tie(_key_event->getNode("modifier/shift", true), SGRawValuePointer(&_key_shift)); + _tiedProperties.Tie(_key_event->getNode("modifier/ctrl", true), SGRawValuePointer(&_key_ctrl)); + _tiedProperties.Tie(_key_event->getNode("modifier/alt", true), SGRawValuePointer(&_key_alt)); + _tiedProperties.Tie(_key_event->getNode("modifier/meta", true), SGRawValuePointer(&_key_meta)); + _tiedProperties.Tie(_key_event->getNode("modifier/super", true), SGRawValuePointer(&_key_super)); + _tiedProperties.Tie(_key_event->getNode("modifier/hyper", true), SGRawValuePointer(&_key_hyper)); } void FGKeyboardInput::unbind() { - fgUntie("/devices/status/keyboard"); - fgUntie("/devices/status/keyboard/shift"); - fgUntie("/devices/status/keyboard/ctrl"); - fgUntie("/devices/status/keyboard/alt"); - fgUntie("/devices/status/keyboard/meta"); - fgUntie("/devices/status/keyboard/super"); - fgUntie("/devices/status/keyboard/hyper"); - - _key_event->untie("key"); - _key_event->untie("pressed"); - _key_event->untie("modifier"); - _key_event->untie("modifier/shift"); - _key_event->untie("modifier/ctrl"); - _key_event->untie("modifier/alt"); - _key_event->untie("modifier/meta"); - _key_event->untie("modifier/super"); - _key_event->untie("modifier/hyper"); + _tiedProperties.Untie(); } void FGKeyboardInput::update( double dt ) diff --git a/src/Input/FGKeyboardInput.hxx b/src/Input/FGKeyboardInput.hxx index 225d0f65e..886823269 100644 --- a/src/Input/FGKeyboardInput.hxx +++ b/src/Input/FGKeyboardInput.hxx @@ -25,13 +25,14 @@ #ifndef _FGKEYBOARDINPUT_HXX #define _FGKEYBOARDINPUT_HXX -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ #endif #include "FGCommonInput.hxx" #include "FGButton.hxx" #include +#include //////////////////////////////////////////////////////////////////////// // The Keyboard Input Class @@ -66,6 +67,7 @@ private: bool _key_meta; bool _key_super; bool _key_hyper; + simgear::TiedPropertyList _tiedProperties; }; #endif diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index f193c5624..42157d7a1 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -239,22 +239,18 @@ void DCLGPS::init() { } void DCLGPS::bind() { - fgTie("/instrumentation/gps/waypoint-alert", this, &DCLGPS::GetWaypointAlert); - fgTie("/instrumentation/gps/leg-mode", this, &DCLGPS::GetLegMode); - fgTie("/instrumentation/gps/obs-mode", this, &DCLGPS::GetOBSMode); - fgTie("/instrumentation/gps/approach-arm", this, &DCLGPS::GetApproachArm); - fgTie("/instrumentation/gps/approach-active", this, &DCLGPS::GetApproachActive); - fgTie("/instrumentation/gps/cdi-deflection", this, &DCLGPS::GetCDIDeflection); - fgTie("/instrumentation/gps/to-flag", this, &DCLGPS::GetToFlag); + _tiedProperties.setRoot(fgGetNode("/instrumentation/gps", true)); + _tiedProperties.Tie("waypoint-alert", this, &DCLGPS::GetWaypointAlert); + _tiedProperties.Tie("leg-mode", this, &DCLGPS::GetLegMode); + _tiedProperties.Tie("obs-mode", this, &DCLGPS::GetOBSMode); + _tiedProperties.Tie("approach-arm", this, &DCLGPS::GetApproachArm); + _tiedProperties.Tie("approach-active", this, &DCLGPS::GetApproachActive); + _tiedProperties.Tie("cdi-deflection", this, &DCLGPS::GetCDIDeflection); + _tiedProperties.Tie("to-flag", this, &DCLGPS::GetToFlag); } void DCLGPS::unbind() { - fgUntie("/instrumentation/gps/waypoint-alert"); - fgUntie("/instrumentation/gps/leg-mode"); - fgUntie("/instrumentation/gps/obs-mode"); - fgUntie("/instrumentation/gps/approach-arm"); - fgUntie("/instrumentation/gps/approach-active"); - fgUntie("/instrumentation/gps/cdi-deflection"); + _tiedProperties.Untie(); } void DCLGPS::update(double dt) { diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index be3469aaf..9037e97f1 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -34,6 +34,7 @@ #include #include +#include #include class SGTime; @@ -433,12 +434,12 @@ protected: // Configuration that affects flightplan operation bool _turnAnticipationEnabled; - + // Magvar stuff. Might get some of this stuff (such as time) from FG in future. SGTime* _time; - - std::list _messageStack; - + + std::list _messageStack; + virtual void CreateFlightPlan(GPSFlightPlan* fp, std::vector ids, std::vector wps); // Orientate the GPS unit to a flightplan - ie. figure out from current position @@ -464,6 +465,8 @@ protected: // More hackery since we aren't actually storing an approach class... Doh! std::string _approachAbbrev; std::string _approachRwyStr; +private: + simgear::TiedPropertyList _tiedProperties; }; #endif // _DCLGPS_HXX diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 5076b5380..a7cd4ab80 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -333,10 +333,11 @@ void GPS::bind() { _config.bind(this, _gpsNode->getChild("config", 0, true)); + // basic GPS outputs tie(_gpsNode, "selected-course-deg", SGRawValueMethods (*this, &GPS::getSelectedCourse, &GPS::setSelectedCourse)); - + tie(_gpsNode, "desired-course-deg", SGRawValueMethods (*this, &GPS::getDesiredCourse, NULL)); _desiredCourseNode = _gpsNode->getChild("desired-course-deg", 0, true); @@ -353,7 +354,7 @@ GPS::bind() tie(_gpsNode, "indicated-ground-speed-kt", SGRawValueMethods (*this, &GPS::getGroundspeedKts, NULL)); -// command system +// command system tie(_gpsNode, "mode", SGRawValueMethods(*this, &GPS::getMode, NULL)); tie(_gpsNode, "command", SGRawValueMethods(*this, &GPS::getCommand, &GPS::setCommand)); @@ -406,10 +407,7 @@ GPS::bind() void GPS::unbind() { - for (unsigned int t=0; t<_tiedNodes.size(); ++t) { - _tiedNodes[t]->untie(); - } - _tiedNodes.clear(); + _tiedProperties.Untie(); } void diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index f69a70a76..36cc81c01 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -29,12 +30,13 @@ public: SGGeodProperty() { } - - void init(SGPropertyNode* base, const char* lonStr, const char* latStr, const char* altStr = NULL); - void init(const char* lonStr, const char* latStr, const char* altStr = NULL); - void clear(); - void operator=(const SGGeod& geod); + + void init(SGPropertyNode* base, const char* lonStr, const char* latStr, const char* altStr = NULL); + void init(const char* lonStr, const char* latStr, const char* altStr = NULL); + void clear(); + void operator=(const SGGeod& geod); SGGeod get() const; + private: SGPropertyNode_ptr _lon, _lat, _alt; }; @@ -73,7 +75,6 @@ private: * /instrumentation/gps/trip-odometer * /instrumentation/gps/true-bug-error-deg * /instrumentation/gps/magnetic-bug-error-deg - */ class GPS : public SGSubsystem, public flightgear::RNAV { @@ -85,7 +86,7 @@ public: // SGSubsystem interface virtual void init (); virtual void update (double delta_time_sec); - + virtual void bind(); virtual void unbind(); @@ -97,11 +98,11 @@ public: virtual double magvarDeg(); virtual double selectedMagCourse(); virtual double overflightArmDistanceM(); - + private: friend class GPSListener; friend class SearchFilter; - + /** * Configuration manager, track data relating to aircraft installation */ @@ -109,93 +110,83 @@ private: { public: Config(); - + void bind(GPS* aOwner, SGPropertyNode* aCfg); - - bool turnAnticipationEnabled() const - { return _enableTurnAnticipation; } - + + bool turnAnticipationEnabled() const { return _enableTurnAnticipation; } + /** * Desired turn rate in degrees/second. From this we derive the turn * radius and hence how early we need to anticipate it. */ - double turnRateDegSec() const - { return _turnRate; } - + double turnRateDegSec() const { return _turnRate; } + /** * Distance at which we arm overflight sequencing. Once inside this * distance, a change of the wp1 'TO' flag to false will be considered * overlight of the wp. */ - double overflightArmDistanceNm() const - { return _overflightArmDistance; } - + double overflightArmDistanceNm() const { return _overflightArmDistance; } + /** * Time before the next WP to activate an external annunciator */ - double waypointAlertTime() const - { return _waypointAlertTime; } - - bool requireHardSurface() const - { return _requireHardSurface; } - - double minRunwayLengthFt() const - { return _minRunwayLengthFt; } - - bool cdiDeflectionIsAngular() const - { return (_cdiMaxDeflectionNm <= 0.0); } - + double waypointAlertTime() const { return _waypointAlertTime; } + + bool requireHardSurface() const { return _requireHardSurface; } + + double minRunwayLengthFt() const { return _minRunwayLengthFt; } + + bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); } + double cdiDeflectionLinearPeg() const { assert(_cdiMaxDeflectionNm > 0.0); return _cdiMaxDeflectionNm; } - - bool driveAutopilot() const - { return _driveAutopilot; } - - bool courseSelectable() const - { return _courseSelectable; } + + bool driveAutopilot() const { return _driveAutopilot; } + + bool courseSelectable() const { return _courseSelectable; } + private: bool _enableTurnAnticipation; - + // desired turn rate in degrees per second double _turnRate; - + // distance from waypoint to arm overflight sequencing (in nm) double _overflightArmDistance; - - // time before reaching a waypoint to trigger annunicator light/sound + + // time before reaching a waypoint to trigger annunciator light/sound // (in seconds) double _waypointAlertTime; - + // minimum runway length to require when filtering double _minRunwayLengthFt; - + // should we require a hard-surfaced runway when filtering? bool _requireHardSurface; - + double _cdiMaxDeflectionNm; - + // should we drive the autopilot directly or not? bool _driveAutopilot; - + // is selected-course-deg read to set desired-course or not? bool _courseSelectable; }; - + class SearchFilter : public FGPositioned::Filter { - public: + public: virtual bool pass(FGPositioned* aPos) const; - + virtual FGPositioned::Type minType() const; virtual FGPositioned::Type maxType() const; }; - - /** - * reset all output properties to default / non-service values - */ + + /** reset all output properties to default / non-service values */ void clearOutput(); void updateBasicData(double dt); @@ -210,162 +201,152 @@ private: void routeManagerSequenced(); void routeEdited(); void routeFinished(); - - void updateTurn(); - void updateOverflight(); + + void updateTurn(); + void updateOverflight(); void beginTurn(); void endTurn(); - + double computeTurnProgress(double aBearing) const; void computeTurnData(); void updateTurnData(); double computeTurnRadiusNm(double aGroundSpeedKts) const; + + /** Update one-shot things when WP1 / leg data change */ + void wp1Changed(); + +// scratch maintenance utilities + void setScratchFromPositioned(FGPositioned* aPos, int aIndex); + void setScratchFromCachedSearchResult(); + void setScratchFromRouteWaypoint(int aIndex); + + /** Add airport-specific information to a scratch result */ + void addAirportToScratch(FGAirport* aAirport); - /** - * Update one-shot things when WP1 / leg data change - */ - void wp1Changed(); - -// scratch maintenence utilities - void setScratchFromPositioned(FGPositioned* aPos, int aIndex); - void setScratchFromCachedSearchResult(); - void setScratchFromRouteWaypoint(int aIndex); - - /** - * Add airport-specific information to a scratch result - */ - void addAirportToScratch(FGAirport* aAirport); - - void clearScratch(); - - /** - * Predicate, determine if the lon/lat position in the scratch is - * valid or not. - */ - bool isScratchPositionValid() const; - - FGPositioned::Filter* createFilter(FGPositioned::Type aTy); - - /** - * Search kernel - called each time we step through a result - */ - void performSearch(); + void clearScratch(); + + /** Predicate, determine if the lon/lat position in the scratch is + * valid or not. */ + bool isScratchPositionValid() const; + + FGPositioned::Filter* createFilter(FGPositioned::Type aTy); + /** Search kernel - called each time we step through a result */ + void performSearch(); + // command handlers - void selectLegMode(); - void selectOBSMode(); - void directTo(); - void loadRouteWaypoint(); - void loadNearest(); - void search(); - void nextResult(); - void previousResult(); - void defineWaypoint(); - void insertWaypointAtIndex(int aIndex); - void removeWaypointAtIndex(int aIndex); - + void selectLegMode(); + void selectOBSMode(); + void directTo(); + void loadRouteWaypoint(); + void loadNearest(); + void search(); + void nextResult(); + void previousResult(); + void defineWaypoint(); + void insertWaypointAtIndex(int aIndex); + void removeWaypointAtIndex(int aIndex); + // tied-property getter/setters - void setCommand(const char* aCmd); - const char* getCommand() const { return ""; } - - const char* getMode() const { return _mode.c_str(); } - - bool getScratchValid() const { return _scratchValid; } - double getScratchDistance() const; - double getScratchMagBearing() const; - double getScratchTrueBearing() const; - bool getScratchHasNext() const; - - double getSelectedCourse() const { return _selectedCourse; } - void setSelectedCourse(double crs); - double getDesiredCourse() const { return _desiredCourse; } - - double getCDIDeflection() const; - - double getLegDistance() const; - double getLegCourse() const; - double getLegMagCourse() const; - - double getTrueTrack() const { return _last_true_track; } - double getMagTrack() const; - double getGroundspeedKts() const { return _last_speed_kts; } - double getVerticalSpeed() const { return _last_vertical_speed; } - - //bool getLegMode() const { return _mode == "leg"; } - //bool getObsMode() const { return _mode == "obs"; } - - const char* getWP0Ident() const; - const char* getWP0Name() const; - - const char* getWP1Ident() const; - const char* getWP1Name() const; - - double getWP1Distance() const; - double getWP1TTW() const; - const char* getWP1TTWString() const; - double getWP1Bearing() const; - double getWP1MagBearing() const; - double getWP1CourseDeviation() const; - double getWP1CourseErrorNm() const; - bool getWP1ToFlag() const; - bool getWP1FromFlag() const; - - // true-bearing-error and mag-bearing-error - + void setCommand(const char* aCmd); + const char* getCommand() const { return ""; } + + const char* getMode() const { return _mode.c_str(); } + + bool getScratchValid() const { return _scratchValid; } + double getScratchDistance() const; + double getScratchMagBearing() const; + double getScratchTrueBearing() const; + bool getScratchHasNext() const; + + double getSelectedCourse() const { return _selectedCourse; } + void setSelectedCourse(double crs); + double getDesiredCourse() const { return _desiredCourse; } + + double getCDIDeflection() const; + + double getLegDistance() const; + double getLegCourse() const; + double getLegMagCourse() const; + + double getTrueTrack() const { return _last_true_track; } + double getMagTrack() const; + double getGroundspeedKts() const { return _last_speed_kts; } + double getVerticalSpeed() const { return _last_vertical_speed; } + + //bool getLegMode() const { return _mode == "leg"; } + //bool getObsMode() const { return _mode == "obs"; } - /** - * Tied-properties helper, record nodes which are tied for easy un-tie-ing - */ - template - void tie(SGPropertyNode* aNode, const char* aRelPath, const SGRawValue& aRawValue) - { - SGPropertyNode* nd = aNode->getNode(aRelPath, true); - _tiedNodes.push_back(nd); - nd->tie(aRawValue); - } - - /// helper, tie the lat/lon/elev of a SGGeod to the named children of aNode - void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef, - const char* lonStr, const char* latStr, const char* altStr); + const char* getWP0Ident() const; + const char* getWP0Name() const; + + const char* getWP1Ident() const; + const char* getWP1Name() const; + + double getWP1Distance() const; + double getWP1TTW() const; + const char* getWP1TTWString() const; + double getWP1Bearing() const; + double getWP1MagBearing() const; + double getWP1CourseDeviation() const; + double getWP1CourseErrorNm() const; + bool getWP1ToFlag() const; + bool getWP1FromFlag() const; + + // true-bearing-error and mag-bearing-error + + + /** + * Tied-properties helper, record nodes which are tied for easy un-tie-ing + */ + template + void tie(SGPropertyNode* aNode, const char* aRelPath, const SGRawValue& aRawValue) + { + _tiedProperties.Tie(aNode->getNode(aRelPath, true), aRawValue); + } + + /** helper, tie the lat/lon/elev of a SGGeod to the named children of aNode */ + void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef, + const char* lonStr, const char* latStr, const char* altStr); - /// helper, tie a SGGeod to proeprties, but read-only - void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef, - const char* lonStr, const char* latStr, const char* altStr); + /** helper, tie a SGGeod to proeprties, but read-only */ + void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef, + const char* lonStr, const char* latStr, const char* altStr); // members - SGPropertyNode_ptr _gpsNode; - SGPropertyNode_ptr _currentWayptNode; - SGPropertyNode_ptr _magvar_node; - SGPropertyNode_ptr _serviceable_node; - SGPropertyNode_ptr _electrical_node; - SGPropertyNode_ptr _tracking_bug_node; - SGPropertyNode_ptr _raim_node; - - SGPropertyNode_ptr _odometer_node; + SGPropertyNode_ptr _gpsNode; + SGPropertyNode_ptr _currentWayptNode; + SGPropertyNode_ptr _magvar_node; + SGPropertyNode_ptr _serviceable_node; + SGPropertyNode_ptr _electrical_node; + SGPropertyNode_ptr _tracking_bug_node; + SGPropertyNode_ptr _raim_node; + + SGPropertyNode_ptr _odometer_node; SGPropertyNode_ptr _trip_odometer_node; SGPropertyNode_ptr _true_bug_error_node; SGPropertyNode_ptr _magnetic_bug_error_node; SGPropertyNode_ptr _eastWestVelocity; SGPropertyNode_ptr _northSouthVelocity; - + SGPropertyNode_ptr _ref_navaid_id_node; SGPropertyNode_ptr _ref_navaid_bearing_node; SGPropertyNode_ptr _ref_navaid_distance_node; SGPropertyNode_ptr _ref_navaid_mag_bearing_node; SGPropertyNode_ptr _ref_navaid_frequency_node; SGPropertyNode_ptr _ref_navaid_name_node; - + SGPropertyNode_ptr _route_active_node; SGPropertyNode_ptr _route_current_wp_node; SGPropertyNode_ptr _routeDistanceNm; SGPropertyNode_ptr _routeETE; - SGPropertyNode_ptr _routeEditedSignal; - SGPropertyNode_ptr _routeFinishedSignal; - SGPropertyNode_ptr _desiredCourseNode; - + SGPropertyNode_ptr _routeEditedSignal; + SGPropertyNode_ptr _routeFinishedSignal; + SGPropertyNode_ptr _desiredCourseNode; + double _selectedCourse; double _desiredCourse; - + bool _dataValid; SGGeod _last_pos; bool _lastPosValid; @@ -374,40 +355,40 @@ private: double _last_vertical_speed; double _lastEWVelocity; double _lastNSVelocity; - + std::string _mode; GPSListener* _listener; Config _config; FGRouteMgr* _routeMgr; - + bool _ref_navaid_set; double _ref_navaid_elapsed; FGPositionedRef _ref_navaid; - + std::string _name; int _num; - - SGGeodProperty _position; - SGGeod _wp0_position; - SGGeod _indicated_pos; - double _legDistanceNm; - + + SGGeodProperty _position; + SGGeod _wp0_position; + SGGeod _indicated_pos; + double _legDistanceNm; + // scratch data - SGGeod _scratchPos; - SGPropertyNode_ptr _scratchNode; - bool _scratchValid; - + SGGeod _scratchPos; + SGPropertyNode_ptr _scratchNode; + bool _scratchValid; + // search data - int _searchResultIndex; - std::string _searchQuery; - FGPositioned::Type _searchType; - bool _searchExact; - FGPositioned::List _searchResults; - bool _searchIsRoute; ///< set if 'search' is actually the current route - bool _searchHasNext; ///< is there a result after this one? - bool _searchNames; ///< set if we're searching names instead of idents - - // turn data + int _searchResultIndex; + std::string _searchQuery; + FGPositioned::Type _searchType; + bool _searchExact; + FGPositioned::List _searchResults; + bool _searchIsRoute; ///< set if 'search' is actually the current route + bool _searchHasNext; ///< is there a result after this one? + bool _searchNames; ///< set if we're searching names instead of idents + +// turn data bool _computeTurnData; ///< do we need to update the turn data? bool _anticipateTurn; ///< are we anticipating the next turn or not? bool _inTurn; // is a turn in progress? @@ -417,21 +398,21 @@ private: double _turnRadius; // radius of turn in nm SGGeod _turnPt; SGGeod _turnCentre; - - std::auto_ptr _wayptController; - - SGPropertyNode_ptr _realismSimpleGps; ///< should the GPS be simple or realistic? - flightgear::WayptRef _prevWaypt; - flightgear::WayptRef _currentWaypt; - + + std::auto_ptr _wayptController; + + SGPropertyNode_ptr _realismSimpleGps; ///< should the GPS be simple or realistic? + flightgear::WayptRef _prevWaypt; + flightgear::WayptRef _currentWaypt; + // autopilot drive properties - SGPropertyNode_ptr _apDrivingFlag; - SGPropertyNode_ptr _apTrueHeading; - SGPropertyNode_ptr _apTargetAltitudeFt; - SGPropertyNode_ptr _apAltitudeLock; - - std::vector _tiedNodes; -}; + SGPropertyNode_ptr _apDrivingFlag; + SGPropertyNode_ptr _apTrueHeading; + SGPropertyNode_ptr _apTargetAltitudeFt; + SGPropertyNode_ptr _apAltitudeLock; + + simgear::TiedPropertyList _tiedProperties; +}; #endif // __INSTRUMENTS_GPS_HXX diff --git a/src/Instrumentation/kr_87.cxx b/src/Instrumentation/kr_87.cxx index 8ea39569c..22694f7cf 100644 --- a/src/Instrumentation/kr_87.cxx +++ b/src/Instrumentation/kr_87.cxx @@ -120,126 +120,91 @@ void FGKR_87::init () { void FGKR_87::bind () { + _tiedProperties.setRoot(fgGetNode("/instrumentation/kr-87", true)); // internal values - fgTie("/instrumentation/kr-87/internal/valid", this, &FGKR_87::get_valid); - fgTie("/instrumentation/kr-87/internal/inrange", this, - &FGKR_87::get_inrange); - fgTie("/instrumentation/kr-87/internal/dist", this, - &FGKR_87::get_dist); - fgTie("/instrumentation/kr-87/internal/heading", this, - &FGKR_87::get_heading); + _tiedProperties.Tie("internal/valid", this, &FGKR_87::get_valid); + _tiedProperties.Tie("internal/inrange", this, + &FGKR_87::get_inrange); + _tiedProperties.Tie("internal/dist", this, + &FGKR_87::get_dist); + _tiedProperties.Tie("internal/heading", this, + &FGKR_87::get_heading); // modes - fgTie("/instrumentation/kr-87/modes/ant", this, - &FGKR_87::get_ant_mode); - fgTie("/instrumentation/kr-87/modes/stby", this, - &FGKR_87::get_stby_mode); - fgTie("/instrumentation/kr-87/modes/timer", this, - &FGKR_87::get_timer_mode); - fgTie("/instrumentation/kr-87/modes/count", this, - &FGKR_87::get_count_mode); + _tiedProperties.Tie("modes/ant", this, + &FGKR_87::get_ant_mode); + _tiedProperties.Tie("modes/stby", this, + &FGKR_87::get_stby_mode); + _tiedProperties.Tie("modes/timer", this, + &FGKR_87::get_timer_mode); + _tiedProperties.Tie("modes/count", this, + &FGKR_87::get_count_mode); // input and buttons - fgTie("/instrumentation/kr-87/inputs/rotation-deg", this, - &FGKR_87::get_rotation, &FGKR_87::set_rotation); + _tiedProperties.Tie("inputs/rotation-deg", this, + &FGKR_87::get_rotation, &FGKR_87::set_rotation); fgSetArchivable("/instrumentation/kr-87/inputs/rotation-deg"); - fgTie("/instrumentation/kr-87/inputs/power-btn", this, - &FGKR_87::get_power_btn, - &FGKR_87::set_power_btn); + _tiedProperties.Tie("inputs/power-btn", this, + &FGKR_87::get_power_btn, + &FGKR_87::set_power_btn); fgSetArchivable("/instrumentation/kr-87/inputs/power-btn"); - fgTie("/instrumentation/kr-87/inputs/audio-btn", this, - &FGKR_87::get_audio_btn, - &FGKR_87::set_audio_btn); + _tiedProperties.Tie("inputs/audio-btn", this, + &FGKR_87::get_audio_btn, + &FGKR_87::set_audio_btn); fgSetArchivable("/instrumentation/kr-87/inputs/audio-btn"); - fgTie("/instrumentation/kr-87/inputs/volume", this, - &FGKR_87::get_vol_btn, - &FGKR_87::set_vol_btn); + _tiedProperties.Tie("inputs/volume", this, + &FGKR_87::get_vol_btn, + &FGKR_87::set_vol_btn); fgSetArchivable("/instrumentation/kr-87/inputs/volume"); - fgTie("/instrumentation/kr-87/inputs/adf-btn", this, - &FGKR_87::get_adf_btn, - &FGKR_87::set_adf_btn); - fgTie("/instrumentation/kr-87/inputs/bfo-btn", this, - &FGKR_87::get_bfo_btn, - &FGKR_87::set_bfo_btn); - fgTie("/instrumentation/kr-87/inputs/frq-btn", this, - &FGKR_87::get_frq_btn, - &FGKR_87::set_frq_btn); - fgTie("/instrumentation/kr-87/inputs/flt-et-btn", this, - &FGKR_87::get_flt_et_btn, - &FGKR_87::set_flt_et_btn); - fgTie("/instrumentation/kr-87/inputs/set-rst-btn", this, - &FGKR_87::get_set_rst_btn, - &FGKR_87::set_set_rst_btn); + _tiedProperties.Tie("inputs/adf-btn", this, + &FGKR_87::get_adf_btn, + &FGKR_87::set_adf_btn); + _tiedProperties.Tie("inputs/bfo-btn", this, + &FGKR_87::get_bfo_btn, + &FGKR_87::set_bfo_btn); + _tiedProperties.Tie("inputs/frq-btn", this, + &FGKR_87::get_frq_btn, + &FGKR_87::set_frq_btn); + _tiedProperties.Tie("inputs/flt-et-btn", this, + &FGKR_87::get_flt_et_btn, + &FGKR_87::set_flt_et_btn); + _tiedProperties.Tie("inputs/set-rst-btn", this, + &FGKR_87::get_set_rst_btn, + &FGKR_87::set_set_rst_btn); // outputs - fgTie("/instrumentation/kr-87/outputs/selected-khz", this, - &FGKR_87::get_freq, &FGKR_87::set_freq); + _tiedProperties.Tie("outputs/selected-khz", this, + &FGKR_87::get_freq, &FGKR_87::set_freq); fgSetArchivable("/instrumentation/kr-87/outputs/selected-khz"); - fgTie("/instrumentation/kr-87/outputs/standby-khz", this, - &FGKR_87::get_stby_freq, &FGKR_87::set_stby_freq); + _tiedProperties.Tie("outputs/standby-khz", this, + &FGKR_87::get_stby_freq, &FGKR_87::set_stby_freq); fgSetArchivable("/instrumentation/kr-87/outputs/standby-khz"); - fgTie("/instrumentation/kr-87/outputs/needle-deg", this, - &FGKR_87::get_needle_deg); - fgTie("/instrumentation/kr-87/outputs/flight-timer", this, - &FGKR_87::get_flight_timer); - fgTie("/instrumentation/kr-87/outputs/elapsed-timer", this, - &FGKR_87::get_elapsed_timer, - &FGKR_87::set_elapsed_timer); + _tiedProperties.Tie("outputs/needle-deg", this, + &FGKR_87::get_needle_deg); + _tiedProperties.Tie("outputs/flight-timer", this, + &FGKR_87::get_flight_timer); + _tiedProperties.Tie("outputs/elapsed-timer", this, + &FGKR_87::get_elapsed_timer, + &FGKR_87::set_elapsed_timer); // annunciators - fgTie("/instrumentation/kr-87/annunciators/ant", this, - &FGKR_87::get_ant_ann ); - fgTie("/instrumentation/kr-87/annunciators/adf", this, - &FGKR_87::get_adf_ann ); - fgTie("/instrumentation/kr-87/annunciators/bfo", this, - &FGKR_87::get_bfo_ann ); - fgTie("/instrumentation/kr-87/annunciators/frq", this, - &FGKR_87::get_frq_ann ); - fgTie("/instrumentation/kr-87/annunciators/flt", this, - &FGKR_87::get_flt_ann ); - fgTie("/instrumentation/kr-87/annunciators/et", this, - &FGKR_87::get_et_ann ); + _tiedProperties.Tie("annunciators/ant", this, + &FGKR_87::get_ant_ann ); + _tiedProperties.Tie("annunciators/adf", this, + &FGKR_87::get_adf_ann ); + _tiedProperties.Tie("annunciators/bfo", this, + &FGKR_87::get_bfo_ann ); + _tiedProperties.Tie("annunciators/frq", this, + &FGKR_87::get_frq_ann ); + _tiedProperties.Tie("annunciators/flt", this, + &FGKR_87::get_flt_ann ); + _tiedProperties.Tie("annunciators/et", this, + &FGKR_87::get_et_ann ); } void FGKR_87::unbind () { - // internal values - fgUntie("/instrumentation/kr-87/internal/valid"); - fgUntie("/instrumentation/kr-87/internal/inrange"); - fgUntie("/instrumentation/kr-87/internal/dist"); - fgUntie("/instrumentation/kr-87/internal/heading"); - - // modes - fgUntie("/instrumentation/kr-87/modes/ant"); - fgUntie("/instrumentation/kr-87/modes/stby"); - fgUntie("/instrumentation/kr-87/modes/timer"); - fgUntie("/instrumentation/kr-87/modes/count"); - - // input and buttons - fgUntie("/instrumentation/kr-87/inputs/rotation-deg"); - fgUntie("/instrumentation/kr-87/inputs/power-btn"); - fgUntie("/instrumentation/kr-87/inputs/volume"); - fgUntie("/instrumentation/kr-87/inputs/adf-btn"); - fgUntie("/instrumentation/kr-87/inputs/bfo-btn"); - fgUntie("/instrumentation/kr-87/inputs/frq-btn"); - fgUntie("/instrumentation/kr-87/inputs/flt-et-btn"); - fgUntie("/instrumentation/kr-87/inputs/set-rst-btn"); - fgUntie("/instrumentation/kr-87/inputs/ident-btn"); - - // outputs - fgUntie("/instrumentation/kr-87/outputs/selected-khz"); - fgUntie("/instrumentation/kr-87/outputs/standby-khz"); - fgUntie("/instrumentation/kr-87/outputs/needle-deg"); - fgUntie("/instrumentation/kr-87/outputs/flight-timer"); - fgUntie("/instrumentation/kr-87/outputs/elapsed-timer"); - - // annunciators - fgUntie("/instrumentation/kr-87/annunciators/ant"); - fgUntie("/instrumentation/kr-87/annunciators/adf"); - fgUntie("/instrumentation/kr-87/annunciators/bfo"); - fgUntie("/instrumentation/kr-87/annunciators/frq"); - fgUntie("/instrumentation/kr-87/annunciators/flt"); - fgUntie("/instrumentation/kr-87/annunciators/et"); + _tiedProperties.Untie(); } diff --git a/src/Instrumentation/kr_87.hxx b/src/Instrumentation/kr_87.hxx index 5f32b1f5a..cd10cf445 100644 --- a/src/Instrumentation/kr_87.hxx +++ b/src/Instrumentation/kr_87.hxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ class SGSampleGroup; class FGKR_87 : public SGSubsystem { +private: SGPropertyNode_ptr bus_power; SGPropertyNode_ptr serviceable; @@ -100,9 +102,9 @@ class FGKR_87 : public SGSubsystem double _time_before_search_sec; SGSharedPtr _sgr; + simgear::TiedPropertyList _tiedProperties; public: - FGKR_87( SGPropertyNode *node ); ~FGKR_87(); diff --git a/src/Instrumentation/kt_70.cxx b/src/Instrumentation/kt_70.cxx index ec48bf84d..e32b917e3 100644 --- a/src/Instrumentation/kt_70.cxx +++ b/src/Instrumentation/kt_70.cxx @@ -91,91 +91,67 @@ void FGKT_70::init () alt_node = fgGetNode("/position/altitude-ft", true); bus_power = fgGetNode("/systems/electrical/outputs/transponder", true); serviceable_node = (node->getChild("inputs", 0, true)) - ->getChild("serviceable", 0, true); + ->getChild("serviceable", 0, true); serviceable_node->setBoolValue(true); } -void FGKT_70::bind () { +void FGKT_70::bind () +{ std::ostringstream temp; string branch; temp << num; branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + _tiedProperties.setRoot(fgGetNode(branch, true)); + // internal values // modes - // input and buttons - fgTie((branch + "/inputs/ident-btn").c_str(), this, - &FGKT_70::get_ident_btn, &FGKT_70::set_ident_btn); + _tiedProperties.Tie("inputs/ident-btn", this, + &FGKT_70::get_ident_btn, &FGKT_70::set_ident_btn); fgSetArchivable((branch + "/inputs/rotation-deg").c_str()); - fgTie((branch + "/inputs/digit1").c_str(), this, - &FGKT_70::get_digit1, &FGKT_70::set_digit1); + _tiedProperties.Tie("inputs/digit1", this, + &FGKT_70::get_digit1, &FGKT_70::set_digit1); fgSetArchivable((branch + "/inputs/digit1").c_str()); - fgTie((branch + "/inputs/digit2").c_str(), this, - &FGKT_70::get_digit2, &FGKT_70::set_digit2); + _tiedProperties.Tie("inputs/digit2", this, + &FGKT_70::get_digit2, &FGKT_70::set_digit2); fgSetArchivable((branch + "/inputs/digit2").c_str()); - fgTie((branch + "/inputs/digit3").c_str(), this, - &FGKT_70::get_digit3, &FGKT_70::set_digit3); + _tiedProperties.Tie("inputs/digit3", this, + &FGKT_70::get_digit3, &FGKT_70::set_digit3); fgSetArchivable((branch + "/inputs/digit3").c_str()); - fgTie((branch + "/inputs/digit4").c_str(), this, - &FGKT_70::get_digit4, &FGKT_70::set_digit4); + _tiedProperties.Tie("inputs/digit4", this, + &FGKT_70::get_digit4, &FGKT_70::set_digit4); fgSetArchivable((branch + "/inputs/digit4").c_str()); - fgTie((branch + "/inputs/func-knob").c_str(), this, - &FGKT_70::get_func_knob, &FGKT_70::set_func_knob); + _tiedProperties.Tie("inputs/func-knob", this, + &FGKT_70::get_func_knob, &FGKT_70::set_func_knob); fgSetArchivable((branch + "/inputs/func-knob").c_str()); // outputs - fgTie((branch + "/outputs/id-code").c_str(), this, - &FGKT_70::get_id_code, &FGKT_70::set_id_code); + _tiedProperties.Tie("outputs/id-code", this, + &FGKT_70::get_id_code, &FGKT_70::set_id_code); fgSetArchivable((branch + "/outputs/id-code").c_str()); - fgTie((branch + "/outputs/flight-level").c_str(), this, - &FGKT_70::get_flight_level); + _tiedProperties.Tie("outputs/flight-level", this, + &FGKT_70::get_flight_level); // annunciators - fgTie((branch + "/annunciators/fl").c_str(), this, - &FGKT_70::get_fl_ann ); - fgTie((branch + "/annunciators/alt").c_str(), this, - &FGKT_70::get_alt_ann ); - fgTie((branch + "/annunciators/gnd").c_str(), this, - &FGKT_70::get_gnd_ann ); - fgTie((branch + "/annunciators/on").c_str(), this, - &FGKT_70::get_on_ann ); - fgTie((branch + "/annunciators/sby").c_str(), this, - &FGKT_70::get_sby_ann ); - fgTie((branch + "/annunciators/reply").c_str(), this, - &FGKT_70::get_reply_ann ); + _tiedProperties.Tie("annunciators/fl", this, + &FGKT_70::get_fl_ann ); + _tiedProperties.Tie("annunciators/alt", this, + &FGKT_70::get_alt_ann ); + _tiedProperties.Tie("annunciators/gnd", this, + &FGKT_70::get_gnd_ann ); + _tiedProperties.Tie("annunciators/on", this, + &FGKT_70::get_on_ann ); + _tiedProperties.Tie("annunciators/sby", this, + &FGKT_70::get_sby_ann ); + _tiedProperties.Tie("annunciators/reply", this, + &FGKT_70::get_reply_ann ); } void FGKT_70::unbind () { - std::ostringstream temp; - string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; - // internal values - - // modes - - // input and buttons - fgUntie((branch + "/inputs/ident-btn").c_str()); - fgUntie((branch + "/inputs/digit1").c_str()); - fgUntie((branch + "/inputs/digit2").c_str()); - fgUntie((branch + "/inputs/digit3").c_str()); - fgUntie((branch + "/inputs/digit4").c_str()); - fgUntie((branch + "/inputs/func-knob").c_str()); - - // outputs - fgUntie((branch + "/outputs/id-code").c_str()); - fgUntie((branch + "/outputs/flight-level").c_str()); - - // annunciators - fgUntie((branch + "/annunciators/fl").c_str()); - fgUntie((branch + "/annunciators/alt").c_str()); - fgUntie((branch + "/annunciators/gnd").c_str()); - fgUntie((branch + "/annunciators/on").c_str()); - fgUntie((branch + "/annunciators/sby").c_str()); - fgUntie((branch + "/annunciators/reply").c_str()); + _tiedProperties.Untie(); } diff --git a/src/Instrumentation/kt_70.hxx b/src/Instrumentation/kt_70.hxx index 69d534831..1316e243a 100644 --- a/src/Instrumentation/kt_70.hxx +++ b/src/Instrumentation/kt_70.hxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -39,6 +40,7 @@ class FGKT_70 : public SGSubsystem { +private: SGPropertyNode_ptr lon_node; SGPropertyNode_ptr lat_node; SGPropertyNode_ptr alt_node; @@ -72,6 +74,7 @@ class FGKT_70 : public SGSubsystem string name; int num; + simgear::TiedPropertyList _tiedProperties; public: diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 63777e3bb..807c92118 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -482,58 +482,37 @@ FGProperties::init () void FGProperties::bind () { - // Simulation - fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority); - fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses); - fgTie("/sim/freeze/master", getFreeze, setFreeze); + _tiedProperties.setRoot(globals->get_props()); - fgTie("/sim/time/elapsed-sec", getElapsedTime_sec); - fgTie("/sim/time/gmt", getDateString, setDateString); + // Simulation + _tiedProperties.Tie("/sim/logging/priority", getLoggingPriority, setLoggingPriority); + _tiedProperties.Tie("/sim/logging/classes", getLoggingClasses, setLoggingClasses); + _tiedProperties.Tie("/sim/freeze/master", getFreeze, setFreeze); + + _tiedProperties.Tie("/sim/time/elapsed-sec", getElapsedTime_sec); + _tiedProperties.Tie("/sim/time/gmt", getDateString, setDateString); fgSetArchivable("/sim/time/gmt"); - fgTie("/sim/time/gmt-string", getGMTString); + _tiedProperties.Tie("/sim/time/gmt-string", getGMTString); - // Position - fgTie("/position/latitude-string", getLatitudeString); - fgTie("/position/longitude-string", getLongitudeString); + // Position + _tiedProperties.Tie("/position/latitude-string", getLatitudeString); + _tiedProperties.Tie("/position/longitude-string", getLongitudeString); - // Orientation - fgTie("/orientation/heading-magnetic-deg", getHeadingMag); - fgTie("/orientation/track-magnetic-deg", getTrackMag); + // Orientation + _tiedProperties.Tie("/orientation/heading-magnetic-deg", getHeadingMag); + _tiedProperties.Tie("/orientation/track-magnetic-deg", getTrackMag); - fgTie("/environment/magnetic-variation-deg", getMagVar); - fgTie("/environment/magnetic-dip-deg", getMagDip); + _tiedProperties.Tie("/environment/magnetic-variation-deg", getMagVar); + _tiedProperties.Tie("/environment/magnetic-dip-deg", getMagDip); - // Misc. Temporary junk. - fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false); + // Misc. Temporary junk. + _tiedProperties.Tie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false); } void FGProperties::unbind () { - // Simulation - fgUntie("/sim/logging/priority"); - fgUntie("/sim/logging/classes"); - fgUntie("/sim/freeze/master"); - - fgUntie("/sim/time/elapsed-sec"); - fgUntie("/sim/time/gmt"); - fgUntie("/sim/time/gmt-string"); - // Position - fgUntie("/position/latitude-string"); - fgUntie("/position/longitude-string"); - - // Orientation - fgUntie("/orientation/heading-magnetic-deg"); - fgUntie("/orientation/track-magnetic-deg"); - - // Environment - fgUntie("/environment/magnetic-variation-deg"); - fgUntie("/environment/magnetic-dip-deg"); - - // Misc. Temporary junk. - fgUntie("/sim/temp/winding-ccw"); -// fgUntie("/sim/temp/full-screen"); -// fgUntie("/sim/temp/fdm-data-logging"); + _tiedProperties.Untie(); } void @@ -542,7 +521,6 @@ FGProperties::update (double dt) static SGPropertyNode_ptr offset = fgGetNode("/sim/time/local-offset", true); offset->setIntValue(globals->get_time_params()->get_local_offset()); - // utc date/time static SGPropertyNode_ptr uyear = fgGetNode("/sim/time/utc/year", true); static SGPropertyNode_ptr umonth = fgGetNode("/sim/time/utc/month", true); diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 756ac763b..15bf286f2 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -9,6 +9,7 @@ #include #include +#include #include #include
@@ -27,6 +28,9 @@ public: void bind (); void unbind (); void update (double dt); + +private: + simgear::TiedPropertyList _tiedProperties; }; diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx index 4e4417d34..32e7390ea 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -182,123 +182,98 @@ void FGViewMgr::do_bind() { // these are bound to the current view properties - fgTie("/sim/current-view/heading-offset-deg", this, - &FGViewMgr::getViewHeadingOffset_deg, - &FGViewMgr::setViewHeadingOffset_deg); + _tiedProperties.setRoot(fgGetNode("/sim/current-view", true)); + _tiedProperties.Tie("heading-offset-deg", this, + &FGViewMgr::getViewHeadingOffset_deg, + &FGViewMgr::setViewHeadingOffset_deg); fgSetArchivable("/sim/current-view/heading-offset-deg"); - fgTie("/sim/current-view/goal-heading-offset-deg", this, - &FGViewMgr::getViewGoalHeadingOffset_deg, - &FGViewMgr::setViewGoalHeadingOffset_deg); + _tiedProperties.Tie("goal-heading-offset-deg", this, + &FGViewMgr::getViewGoalHeadingOffset_deg, + &FGViewMgr::setViewGoalHeadingOffset_deg); fgSetArchivable("/sim/current-view/goal-heading-offset-deg"); - fgTie("/sim/current-view/pitch-offset-deg", this, - &FGViewMgr::getViewPitchOffset_deg, - &FGViewMgr::setViewPitchOffset_deg); + _tiedProperties.Tie("pitch-offset-deg", this, + &FGViewMgr::getViewPitchOffset_deg, + &FGViewMgr::setViewPitchOffset_deg); fgSetArchivable("/sim/current-view/pitch-offset-deg"); - fgTie("/sim/current-view/goal-pitch-offset-deg", this, - &FGViewMgr::getGoalViewPitchOffset_deg, - &FGViewMgr::setGoalViewPitchOffset_deg); + _tiedProperties.Tie("goal-pitch-offset-deg", this, + &FGViewMgr::getGoalViewPitchOffset_deg, + &FGViewMgr::setGoalViewPitchOffset_deg); fgSetArchivable("/sim/current-view/goal-pitch-offset-deg"); - fgTie("/sim/current-view/roll-offset-deg", this, - &FGViewMgr::getViewRollOffset_deg, - &FGViewMgr::setViewRollOffset_deg); + _tiedProperties.Tie("roll-offset-deg", this, + &FGViewMgr::getViewRollOffset_deg, + &FGViewMgr::setViewRollOffset_deg); fgSetArchivable("/sim/current-view/roll-offset-deg"); - fgTie("/sim/current-view/goal-roll-offset-deg", this, - &FGViewMgr::getGoalViewRollOffset_deg, - &FGViewMgr::setGoalViewRollOffset_deg); + _tiedProperties.Tie("goal-roll-offset-deg", this, + &FGViewMgr::getGoalViewRollOffset_deg, + &FGViewMgr::setGoalViewRollOffset_deg); fgSetArchivable("/sim/current-view/goal-roll-offset-deg"); - fgTie("/sim/current-view/view-number", this, + _tiedProperties.Tie("view-number", this, &FGViewMgr::getView, &FGViewMgr::setView); fgSetArchivable("/sim/current-view/view-number", false); - fgTie("/sim/current-view/axes/long", this, - (double_getter)0, &FGViewMgr::setViewAxisLong); + _tiedProperties.Tie("axes/long", this, + (double_getter)0, &FGViewMgr::setViewAxisLong); fgSetArchivable("/sim/current-view/axes/long"); - fgTie("/sim/current-view/axes/lat", this, - (double_getter)0, &FGViewMgr::setViewAxisLat); + _tiedProperties.Tie("axes/lat", this, + (double_getter)0, &FGViewMgr::setViewAxisLat); fgSetArchivable("/sim/current-view/axes/lat"); - fgTie("/sim/current-view/field-of-view", this, - &FGViewMgr::getFOV_deg, &FGViewMgr::setFOV_deg); + _tiedProperties.Tie("field-of-view", this, + &FGViewMgr::getFOV_deg, &FGViewMgr::setFOV_deg); fgSetArchivable("/sim/current-view/field-of-view"); - fgTie("/sim/current-view/aspect-ratio-multiplier", this, - &FGViewMgr::getARM_deg, &FGViewMgr::setARM_deg); + _tiedProperties.Tie("aspect-ratio-multiplier", this, + &FGViewMgr::getARM_deg, &FGViewMgr::setARM_deg); fgSetArchivable("/sim/current-view/field-of-view"); - fgTie("/sim/current-view/ground-level-nearplane-m", this, - &FGViewMgr::getNear_m, &FGViewMgr::setNear_m); + _tiedProperties.Tie("ground-level-nearplane-m", this, + &FGViewMgr::getNear_m, &FGViewMgr::setNear_m); fgSetArchivable("/sim/current-view/ground-level-nearplane-m"); SGPropertyNode *n = fgGetNode("/sim/current-view", true); - n->tie("viewer-x-m", SGRawValuePointer(&abs_viewer_position[0])); - n->tie("viewer-y-m", SGRawValuePointer(&abs_viewer_position[1])); - n->tie("viewer-z-m", SGRawValuePointer(&abs_viewer_position[2])); - -// for automatic untying: -#define x(str) ((void)tied_props.push_back(str), str) - - fgTie(x("/sim/current-view/debug/orientation-w"), this, - &FGViewMgr::getCurrentViewOrientation_w); - fgTie(x("/sim/current-view/debug/orientation-x"), this, - &FGViewMgr::getCurrentViewOrientation_x); - fgTie(x("/sim/current-view/debug/orientation-y"), this, - &FGViewMgr::getCurrentViewOrientation_y); - fgTie(x("/sim/current-view/debug/orientation-z"), this, - &FGViewMgr::getCurrentViewOrientation_z); - - fgTie(x("/sim/current-view/debug/orientation_offset-w"), this, - &FGViewMgr::getCurrentViewOrOffset_w); - fgTie(x("/sim/current-view/debug/orientation_offset-x"), this, - &FGViewMgr::getCurrentViewOrOffset_x); - fgTie(x("/sim/current-view/debug/orientation_offset-y"), this, - &FGViewMgr::getCurrentViewOrOffset_y); - fgTie(x("/sim/current-view/debug/orientation_offset-z"), this, - &FGViewMgr::getCurrentViewOrOffset_z); - - fgTie(x("/sim/current-view/debug/frame-w"), this, - &FGViewMgr::getCurrentViewFrame_w); - fgTie(x("/sim/current-view/debug/frame-x"), this, - &FGViewMgr::getCurrentViewFrame_x); - fgTie(x("/sim/current-view/debug/frame-y"), this, - &FGViewMgr::getCurrentViewFrame_y); - fgTie(x("/sim/current-view/debug/frame-z"), this, - &FGViewMgr::getCurrentViewFrame_z); - -#undef x + _tiedProperties.Tie(n->getNode("viewer-x-m", true),SGRawValuePointer(&abs_viewer_position[0])); + _tiedProperties.Tie(n->getNode("viewer-y-m", true),SGRawValuePointer(&abs_viewer_position[1])); + _tiedProperties.Tie(n->getNode("viewer-z-m", true),SGRawValuePointer(&abs_viewer_position[2])); + + _tiedProperties.Tie("debug/orientation-w", this, + &FGViewMgr::getCurrentViewOrientation_w); + _tiedProperties.Tie("debug/orientation-x", this, + &FGViewMgr::getCurrentViewOrientation_x); + _tiedProperties.Tie("debug/orientation-y", this, + &FGViewMgr::getCurrentViewOrientation_y); + _tiedProperties.Tie("debug/orientation-z", this, + &FGViewMgr::getCurrentViewOrientation_z); + + _tiedProperties.Tie("debug/orientation_offset-w", this, + &FGViewMgr::getCurrentViewOrOffset_w); + _tiedProperties.Tie("debug/orientation_offset-x", this, + &FGViewMgr::getCurrentViewOrOffset_x); + _tiedProperties.Tie("debug/orientation_offset-y", this, + &FGViewMgr::getCurrentViewOrOffset_y); + _tiedProperties.Tie("debug/orientation_offset-z", this, + &FGViewMgr::getCurrentViewOrOffset_z); + + _tiedProperties.Tie("debug/frame-w", this, + &FGViewMgr::getCurrentViewFrame_w); + _tiedProperties.Tie("debug/frame-x", this, + &FGViewMgr::getCurrentViewFrame_x); + _tiedProperties.Tie("debug/frame-y", this, + &FGViewMgr::getCurrentViewFrame_y); + _tiedProperties.Tie("debug/frame-z", this, + &FGViewMgr::getCurrentViewFrame_z); } void FGViewMgr::unbind () { - // FIXME: - // need to redo these bindings to the new locations (move to viewer?) - fgUntie("/sim/current-view/heading-offset-deg"); - fgUntie("/sim/current-view/goal-heading-offset-deg"); - fgUntie("/sim/current-view/pitch-offset-deg"); - fgUntie("/sim/current-view/goal-pitch-offset-deg"); - fgUntie("/sim/current-view/field-of-view"); - fgUntie("/sim/current-view/aspect-ratio-multiplier"); - fgUntie("/sim/current-view/view-number"); - fgUntie("/sim/current-view/axes/long"); - fgUntie("/sim/current-view/axes/lat"); - fgUntie("/sim/current-view/ground-level-nearplane-m"); - fgUntie("/sim/current-view/viewer-x-m"); - fgUntie("/sim/current-view/viewer-y-m"); - fgUntie("/sim/current-view/viewer-z-m"); - - std::list::const_iterator it; - for (it = tied_props.begin(); it != tied_props.end(); it++){ - fgUntie(*it); - } - + _tiedProperties.Untie(); } void FGViewMgr::update (double dt) { - FGViewer *loop_view = (FGViewer *)get_current_view(); if (loop_view == 0) return; diff --git a/src/Main/viewmgr.hxx b/src/Main/viewmgr.hxx index 4906f87f6..d094a3d65 100644 --- a/src/Main/viewmgr.hxx +++ b/src/Main/viewmgr.hxx @@ -25,11 +25,11 @@ #define _VIEWMGR_HXX #include -#include #include #include #include +#include #include // forward decls @@ -75,8 +75,8 @@ public: private: void do_bind(); - - std::list tied_props; + + simgear::TiedPropertyList _tiedProperties; double axis_long; double axis_lat; -- 2.39.5