1
0
Fork 0

Mach number added to mode-S XPDR properties, exposed to MP (for ATC).

This commit is contained in:
Michael Filhol 2022-07-20 23:45:27 +02:00 committed by James Turner
parent dc5404a3c2
commit 6aff646cfa
3 changed files with 20 additions and 3 deletions

View file

@ -26,6 +26,7 @@
// <mode>2</mode> // Mode A = 0, Mode C = 1, Mode S = 2
// <auto-ground>...</auto-ground>
// <airspeed-path>...</airspeed-path>
// <mach-path>...</mach-path>
// </altimeter>
//
// 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 <config.h>
@ -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);
}
}

View file

@ -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;

View file

@ -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 },