diff --git a/src/Instrumentation/transponder.cxx b/src/Instrumentation/transponder.cxx index 7276cefa9..599a032de 100644 --- a/src/Instrumentation/transponder.cxx +++ b/src/Instrumentation/transponder.cxx @@ -26,6 +26,7 @@ // 2 // Mode A = 0, Mode C = 1, Mode S = 2 // ... // ... +// ... // // // Mode-S transponders (configured with mode = 2) can transmit a ground bit to @@ -41,9 +42,10 @@ // Note that Mode-A and Mode-C transponders do not transmit a ground bit, even // if the transponder knob is set to the GND position. // -// Mode-S transponders also transmit indicated airspeed. The default source of -// this is /instrumentation/airspeed-indicator/indicated-speed-kt but this can be -// changed by setting the airspeed-path property as shown above. +// Mode-S transponders also transmit indicated airspeed and Mach number. The +// default sources are "/instrumentation/airspeed-indicator/indicated-speed-kt" +// and ".../indicated-mach", but this can be changed by setting "airspeed-path" +// and "mach-path" properties respectively as shown above. #include @@ -62,6 +64,7 @@ using std::string; const double IDENT_TIMEOUT = 18.0; // 18 seconds const int INVALID_ALTITUDE = -9999; const int INVALID_AIRSPEED = -9999; +const float INVALID_MACH_NUM = -1.0; const int INVALID_ID = -9999; Transponder::Transponder(SGPropertyNode *node) : @@ -78,6 +81,7 @@ Transponder::Transponder(SGPropertyNode *node) : _altitudeSourcePath = node->getStringValue("encoder-path", "/instrumentation/altimeter"); _autoGroundPath = node->getStringValue("auto-ground"); _airspeedSourcePath = node->getStringValue("airspeed-path", "/instrumentation/airspeed-indicator/indicated-speed-kt"); + _machSourcePath = node->getStringValue("mach-path", "/instrumentation/airspeed-indicator/indicated-mach"); _kt70Compat = node->getBoolValue("kt70-compatibility", false); } @@ -96,6 +100,7 @@ void Transponder::init() _pressureAltitude_node = fgGetNode(_altitudeSourcePath, true); _autoGround_node = fgGetNode(_autoGroundPath, true); _airspeedIndicator_node = fgGetNode(_airspeedSourcePath, true); + _machSource_node = fgGetNode(_machSourcePath, true); SGPropertyNode *in_node = node->getChild("inputs", 0, true); for (int i=0; i<4;++i) { @@ -137,6 +142,7 @@ void Transponder::init() _transmittedId_node = node->getChild("transmitted-id", 0, true); _ground_node = node->getChild("ground-bit", 0, true); _airspeed_node = node->getChild("airspeed-kt", 0, true); + _mach_node = node->getChild("mach-number", 0, true); if (_kt70Compat) { // alias the properties through @@ -238,6 +244,12 @@ void Transponder::update(double dt) } else { _airspeed_node->setIntValue(INVALID_AIRSPEED); } + + if (_mode == MODE_S && _machSource_node->hasValue()) { + _mach_node->setDoubleValue(_machSource_node->getDoubleValue()); + } else { + _mach_node->setDoubleValue(INVALID_MACH_NUM); + } } else { // un-powered or u/s @@ -246,6 +258,7 @@ void Transponder::update(double dt) _ident_node->setBoolValue(false); _ground_node->setBoolValue(false); _airspeed_node->setIntValue(INVALID_AIRSPEED); + _mach_node->setDoubleValue(INVALID_MACH_NUM); _transmittedId_node->setIntValue(INVALID_ID); } } diff --git a/src/Instrumentation/transponder.hxx b/src/Instrumentation/transponder.hxx index b14330c56..953771dc9 100644 --- a/src/Instrumentation/transponder.hxx +++ b/src/Instrumentation/transponder.hxx @@ -75,6 +75,7 @@ private: SGPropertyNode_ptr _pressureAltitude_node; SGPropertyNode_ptr _autoGround_node; SGPropertyNode_ptr _airspeedIndicator_node; + SGPropertyNode_ptr _machSource_node; SGPropertyNode_ptr _mode_node; SGPropertyNode_ptr _knob_node; @@ -94,6 +95,7 @@ private: SGPropertyNode_ptr _ident_node; SGPropertyNode_ptr _ground_node; SGPropertyNode_ptr _airspeed_node; + SGPropertyNode_ptr _mach_node; // Internal Mode _mode; @@ -104,6 +106,7 @@ private: std::string _altitudeSourcePath; std::string _autoGroundPath; std::string _airspeedSourcePath; + std::string _machSourcePath; void valueChanged (SGPropertyNode *) override; diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index e4018f1bd..b9f9bd7d5 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -337,6 +337,7 @@ static const IdPropertyList sIdPropertyList[] = { { 1503, "instrumentation/transponder/inputs/mode", simgear::props::INT, TT_SHORTINT, V1_1_PROP_ID, NULL, NULL }, { 1504, "instrumentation/transponder/ground-bit", simgear::props::BOOL, TT_SHORTINT, V1_1_2_PROP_ID, NULL, NULL }, { 1505, "instrumentation/transponder/airspeed-kt", simgear::props::INT, TT_SHORTINT, V1_1_2_PROP_ID, NULL, NULL }, + { 1506, "instrumentation/transponder/mach-number", simgear::props::FLOAT, TT_SHORT_FLOAT_4, V1_1_2_PROP_ID, NULL, NULL }, { 10001, "sim/multiplay/transmission-freq-hz", simgear::props::STRING, TT_NOSEND, V1_1_2_PROP_ID, NULL, NULL }, { 10002, "sim/multiplay/chat", simgear::props::STRING, TT_ASIS, V1_1_2_PROP_ID, NULL, NULL },