diff --git a/src/FDM/YASim/Hitch.cpp b/src/FDM/YASim/Hitch.cpp index 5681625b8..c4bb871fa 100644 --- a/src/FDM/YASim/Hitch.cpp +++ b/src/FDM/YASim/Hitch.cpp @@ -64,46 +64,49 @@ Hitch::Hitch(const char *name) _mp_is_slave=false; _mp_open_last_state=false; _timeLagCorrectedDist=0; + if (_node) { - _node->tie("tow/length",SGRawValuePointer(&_towLength)); - _node->tie("tow/elastic-constant",SGRawValuePointer(&_towElasticConstant)); - _node->tie("tow/weight-per-m-kg-m",SGRawValuePointer(&_towWeightPerM)); - _node->tie("tow/brake-force",SGRawValuePointer(&_towBrakeForce)); - _node->tie("winch/max-speed-m-s",SGRawValuePointer(&_winchMaxSpeed)); - _node->tie("winch/rel-speed",SGRawValuePointer(&_winchRelSpeed)); - _node->tie("winch/initial-tow-length-m",SGRawValuePointer(&_winchInitialTowLength)); - _node->tie("winch/min-tow-length-m",SGRawValuePointer(&_winchMinTowLength)); - _node->tie("winch/max-tow-length-m",SGRawValuePointer(&_winchMaxTowLength)); - _node->tie("winch/global-pos-x",SGRawValuePointer(&_winchPos[0])); - _node->tie("winch/global-pos-y",SGRawValuePointer(&_winchPos[1])); - _node->tie("winch/global-pos-z",SGRawValuePointer(&_winchPos[2])); - _node->tie("winch/max-power",SGRawValuePointer(&_winchPower)); - _node->tie("winch/max-force",SGRawValuePointer(&_winchMaxForce)); - _node->tie("winch/actual-force",SGRawValuePointer(&_winchActualForce)); - _node->tie("tow/end-force-x",SGRawValuePointer(&_reportTowEndForce[0])); - _node->tie("tow/end-force-y",SGRawValuePointer(&_reportTowEndForce[1])); - _node->tie("tow/end-force-z",SGRawValuePointer(&_reportTowEndForce[2])); - _node->tie("force",SGRawValuePointer(&_forceMagnitude)); - _node->tie("open",SGRawValuePointer(&_open)); - _node->tie("force-is-calculated-by-other",SGRawValuePointer(&_forceIsCalculatedByMaster)); - _node->tie("local-pos-x",SGRawValuePointer(&_pos[0])); - _node->tie("local-pos-y",SGRawValuePointer(&_pos[1])); - _node->tie("local-pos-z",SGRawValuePointer(&_pos[2])); - _node->tie("tow/dist",SGRawValuePointer(&_dist)); - _node->tie("tow/dist-time-lag-corrected",SGRawValuePointer(&_timeLagCorrectedDist)); - _node->tie("tow/connected-to-property-node",SGRawValuePointer(&_towEndIsConnectedToProperty)); - _node->tie("tow/connected-to-mp-node",SGRawValuePointer(&_nodeIsMultiplayer)); - _node->tie("tow/connected-to-ai-node",SGRawValuePointer(&_nodeIsAiAircraft)); - _node->tie("tow/connected-to-ai-or-mp-id",SGRawValuePointer(&_nodeID)); - _node->tie("debug/hitch-height-above-ground",SGRawValuePointer(&_height_above_ground)); - _node->tie("debug/tow-end-height-above-ground",SGRawValuePointer(&_winch_height_above_ground)); - _node->tie("debug/tow-rel-lo-pos",SGRawValuePointer(&_loPosFrac)); - _node->tie("debug/tow-lowest-pos-height",SGRawValuePointer(&_lowest_tow_height)); - _node->tie("is-slave",SGRawValuePointer(&_isSlave)); - _node->tie("speed-in-tow-direction",SGRawValuePointer(&_speed_in_tow_direction)); - _node->tie("mp-auto-connect-period",SGRawValuePointer(&_mpAutoConnectPeriod)); - _node->tie("mp-time-lag",SGRawValuePointer(&_mp_time_lag)); +#define TIE(x,v) _tiedProperties.Tie(_node->getNode(x, true),v) + TIE("tow/length", SGRawValuePointer(&_towLength)); + TIE("tow/elastic-constant",SGRawValuePointer(&_towElasticConstant)); + TIE("tow/weight-per-m-kg-m",SGRawValuePointer(&_towWeightPerM)); + TIE("tow/brake-force",SGRawValuePointer(&_towBrakeForce)); + TIE("winch/max-speed-m-s",SGRawValuePointer(&_winchMaxSpeed)); + TIE("winch/rel-speed",SGRawValuePointer(&_winchRelSpeed)); + TIE("winch/initial-tow-length-m",SGRawValuePointer(&_winchInitialTowLength)); + TIE("winch/min-tow-length-m",SGRawValuePointer(&_winchMinTowLength)); + TIE("winch/max-tow-length-m",SGRawValuePointer(&_winchMaxTowLength)); + TIE("winch/global-pos-x",SGRawValuePointer(&_winchPos[0])); + TIE("winch/global-pos-y",SGRawValuePointer(&_winchPos[1])); + TIE("winch/global-pos-z",SGRawValuePointer(&_winchPos[2])); + TIE("winch/max-power",SGRawValuePointer(&_winchPower)); + TIE("winch/max-force",SGRawValuePointer(&_winchMaxForce)); + TIE("winch/actual-force",SGRawValuePointer(&_winchActualForce)); + TIE("tow/end-force-x",SGRawValuePointer(&_reportTowEndForce[0])); + TIE("tow/end-force-y",SGRawValuePointer(&_reportTowEndForce[1])); + TIE("tow/end-force-z",SGRawValuePointer(&_reportTowEndForce[2])); + TIE("force",SGRawValuePointer(&_forceMagnitude)); + TIE("open",SGRawValuePointer(&_open)); + TIE("force-is-calculated-by-other",SGRawValuePointer(&_forceIsCalculatedByMaster)); + TIE("local-pos-x",SGRawValuePointer(&_pos[0])); + TIE("local-pos-y",SGRawValuePointer(&_pos[1])); + TIE("local-pos-z",SGRawValuePointer(&_pos[2])); + TIE("tow/dist",SGRawValuePointer(&_dist)); + TIE("tow/dist-time-lag-corrected",SGRawValuePointer(&_timeLagCorrectedDist)); + TIE("tow/connected-to-property-node",SGRawValuePointer(&_towEndIsConnectedToProperty)); + TIE("tow/connected-to-mp-node",SGRawValuePointer(&_nodeIsMultiplayer)); + TIE("tow/connected-to-ai-node",SGRawValuePointer(&_nodeIsAiAircraft)); + TIE("tow/connected-to-ai-or-mp-id",SGRawValuePointer(&_nodeID)); + TIE("debug/hitch-height-above-ground",SGRawValuePointer(&_height_above_ground)); + TIE("debug/tow-end-height-above-ground",SGRawValuePointer(&_winch_height_above_ground)); + TIE("debug/tow-rel-lo-pos",SGRawValuePointer(&_loPosFrac)); + TIE("debug/tow-lowest-pos-height",SGRawValuePointer(&_lowest_tow_height)); + TIE("is-slave",SGRawValuePointer(&_isSlave)); + TIE("speed-in-tow-direction",SGRawValuePointer(&_speed_in_tow_direction)); + TIE("mp-auto-connect-period",SGRawValuePointer(&_mpAutoConnectPeriod)); + TIE("mp-time-lag",SGRawValuePointer(&_mp_time_lag)); +#undef TIE _node->setStringValue("tow/node",""); _node->setStringValue("tow/connected-to-ai-or-mp-callsign"); _node->setBoolValue("broken",false); @@ -112,47 +115,7 @@ Hitch::Hitch(const char *name) Hitch::~Hitch() { - if (_node) - { - _node->untie("tow/length"); - _node->untie("tow/elastic-constant"); - _node->untie("tow/weight-per-m-kg-m"); - _node->untie("tow/brake-force"); - _node->untie("winch/max-speed-m-s"); - _node->untie("winch/rel-speed"); - _node->untie("winch/initial-tow-length-m"); - _node->untie("winch/min-tow-length-m"); - _node->untie("winch/max-tow-length-m"); - _node->untie("winch/global-pos-x"); - _node->untie("winch/global-pos-y"); - _node->untie("winch/global-pos-z"); - _node->untie("winch/max-power"); - _node->untie("winch/max-force"); - _node->untie("winch/actual-force"); - _node->untie("tow/end-force-x"); - _node->untie("tow/end-force-y"); - _node->untie("tow/end-force-z"); - _node->untie("force"); - _node->untie("open"); - _node->untie("force-is-calculated-by-other"); - _node->untie("local-pos-x"); - _node->untie("local-pos-y"); - _node->untie("local-pos-z"); - _node->untie("tow/dist"); - _node->untie("tow/dist-time-lag-corrected"); - _node->untie("tow/connected-to-property-node"); - _node->untie("tow/connected-to-mp-node"); - _node->untie("tow/connected-to-ai-node"); - _node->untie("tow/connected-to-ai-or-mp-id"); - _node->untie("debug/hitch-height-above-ground"); - _node->untie("debug/tow-end-height-above-ground"); - _node->untie("debug/tow-rel-lo-pos"); - _node->untie("debug/tow-lowest-pos-height"); - _node->untie("is-slave"); - _node->untie("speed-in-tow-direction"); - _node->untie("mp-auto-connect-period"); - _node->untie("mp-time-lag"); - } + _tiedProperties.Untie(); delete _state; } diff --git a/src/FDM/YASim/Hitch.hpp b/src/FDM/YASim/Hitch.hpp index 45e9e7b84..f14cc85b5 100644 --- a/src/FDM/YASim/Hitch.hpp +++ b/src/FDM/YASim/Hitch.hpp @@ -4,6 +4,7 @@ #include #include
+#include namespace yasim { @@ -111,6 +112,7 @@ private: bool _last_wish; SGPropertyNode_ptr _node; + simgear::TiedPropertyList _tiedProperties; }; }; // namespace yasim