]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/tacan.cxx
Fix unused private vars.
[flightgear.git] / src / Instrumentation / tacan.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 94c4caa..01319ec
@@ -17,8 +17,8 @@
 
 #include "tacan.hxx"
 
-SG_USING_STD(vector);
-
+using std::vector;
+using std::string;
 
 /**
  * Adjust the range.
@@ -45,50 +45,20 @@ adjust_range (double transmitter_elevation_ft, double aircraft_altitude_ft,
 }
 
 
-TACAN::TACAN ( SGPropertyNode *node )
-    : _last_distance_nm(0),
-      _last_frequency_mhz(-1),
-      _time_before_search_sec(0),
-      _mobile_valid(false),
-      _transmitter_valid(false),
-      _transmitter_pos(SGGeod::fromDeg(0, 0)),
-      _transmitter_range_nm(0),
-      _transmitter_bias(0.0),
-      _name("tacan"),
-      _num(0)
-{
-
-    int i;
-    for ( i = 0; i < node->nChildren(); ++i ) {
-        SGPropertyNode *child = node->getChild(i);
-        string cname = child->getName();
-        string cval = child->getStringValue();
-        if ( cname == "name" ) {
-            _name = cval;
-        } else if ( cname == "number" ) {
-            _num = child->getIntValue();
-        } else {
-            SG_LOG( SG_INSTR, SG_DEBUG, "Error in TACAN config logic" );
-            if ( _name.length() ) {
-                SG_LOG( SG_INSTR, SG_DEBUG, "Section = " << _name );
-            }
-        }
-    }
-}
-
-TACAN::TACAN ()
-    : _last_distance_nm(0),
-      _last_frequency_mhz(-1),
-      _time_before_search_sec(0),
-      _mobile_valid(false),
-      _transmitter_valid(false),
-      _transmitter_pos(SGGeod::fromDeg(0, 0)),
-      _transmitter_range_nm(0),
-      _transmitter_bearing_deg(0),
-      _transmitter_bias(0.0),
-      _transmitter_name(""),
-      _name("tacan"),
-      _num(0)
+TACAN::TACAN ( SGPropertyNode *node ) :
+    _name(node->getStringValue("name", "tacan")),
+    _num(node->getIntValue("number", 0)),
+    _new_frequency(false),
+    _channel("0000"),
+    _last_distance_nm(0),
+    _frequency_mhz(-1),
+    _time_before_search_sec(0),
+    _mobile_valid(false),
+    _transmitter_valid(false),
+    _transmitter_pos(SGGeod::fromDeg(0, 0)),
+    _transmitter_range_nm(0),
+    _transmitter_bias(0.0),
+    _listener_active(0)
 {
 }
 
@@ -104,28 +74,31 @@ TACAN::init ()
 
     SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
 
-    _longitude_node = fgGetNode("/position/longitude-deg", true);
-    _latitude_node = fgGetNode("/position/latitude-deg", true);
-    _altitude_node = fgGetNode("/position/altitude-ft", true);
-    _heading_node = fgGetNode("/orientation/heading-deg", true);
-    _yaw_node = fgGetNode("/orientation/side-slip-deg", true);
     _serviceable_node = node->getChild("serviceable", 0, true);
-    _electrical_node = fgGetNode("/systems/electrical/outputs/tacan", true);
     _ident_node = node->getChild("ident", 0, true);
+
     SGPropertyNode *fnode = node->getChild("frequencies", 0, true);
-    _source_node = fnode->getChild("source", 0, true);
     _frequency_node = fnode->getChild("selected-mhz", 0, true);
-    _channel_node = fnode->getChild("selected-channel", 0, true);
-    fnode->getChild("selected-channel", 1, true);
-    fnode->getChild("selected-channel", 2, true);
-    fnode->getChild("selected-channel", 3, true);
-    fnode->getChild("selected-channel", 4, true);
+
+    _channel_in0_node = fnode->getChild("selected-channel", 0, true);
+    _channel_in1_node = fnode->getChild("selected-channel", 1, true);
+    _channel_in2_node = fnode->getChild("selected-channel", 2, true);
+    _channel_in3_node = fnode->getChild("selected-channel", 3, true);
+    _channel_in4_node = fnode->getChild("selected-channel", 4, true);
+
+    _channel_in0_node->addChangeListener(this);
+    _channel_in1_node->addChangeListener(this);
+    _channel_in2_node->addChangeListener(this);
+    _channel_in3_node->addChangeListener(this);
+    _channel_in4_node->addChangeListener(this, true);
+
     _in_range_node = node->getChild("in-range", 0, true);
     _distance_node = node->getChild("indicated-distance-nm", 0, true);
     _speed_node = node->getChild("indicated-ground-speed-kt", 0, true);
     _time_node = node->getChild("indicated-time-min", 0, true);
     _name_node = node->getChild("name", 0, true);
     _bearing_node = node->getChild("indicated-bearing-true-deg", 0, true);
+
     SGPropertyNode *dnode = node->getChild("display", 0, true);
     _x_shift_node = dnode->getChild("x-shift", 0, true);
     _y_shift_node = dnode->getChild("y-shift", 0, true);
@@ -140,20 +113,24 @@ TACAN::init ()
 
     SGPropertyNode *mnode = fgGetNode("/ai/models/multiplayer", _num, false);
     _mp_callsign_node = mnode ? mnode->getChild("callsign", 0, false) : 0;
+
+    _heading_node = fgGetNode("/orientation/heading-deg", true);
+    _yaw_node = fgGetNode("/orientation/side-slip-deg", true);
+    _electrical_node = fgGetNode("/systems/electrical/outputs/tacan", true);
+}
+
+void
+TACAN::reinit ()
+{
+    _time_before_search_sec = 0;
 }
 
 void
 TACAN::update (double delta_time_sec)
 {
-    double az2 = 0;
-    double bearing = 0;
-    double distance = 0;
-    double mobile_az2 = 0;
-    double mobile_bearing = 0;
-    double mobile_distance = 0;
-    double frequency_mhz = 0;
+    // don't do anything when paused
+    if (delta_time_sec == 0) return;
 
-                                // If it's off, don't waste any time.
     if (!_serviceable_node->getBoolValue() || !_electrical_node->getBoolValue()) {
         _last_distance_nm = 0;
         _in_range_node->setBoolValue(false);
@@ -164,68 +141,30 @@ TACAN::update (double delta_time_sec)
         return;
     }
 
-                                // Figure out the source
-    const char * source = _source_node->getStringValue();
-
-    if (source[0] == '\0') {
-        string branch;
-        branch = "/instrumentation/" + _name + "/frequencies/selected-channel";
-        _source_node->setStringValue(branch.c_str());
-        source = _source_node->getStringValue();
-        SG_LOG( SG_INSTR, SG_DEBUG, "source " << source );
-    }
-                                // Get the channel   FIXME always from instrument #1 ??
-    string channel_1 = fgGetString("/instrumentation/tacan/frequencies/selected-channel[1]");
-    string channel_2 = fgGetString("/instrumentation/tacan/frequencies/selected-channel[2]");
-    string channel_3 = fgGetString("/instrumentation/tacan/frequencies/selected-channel[3]");
-    string channel_4 = fgGetString("/instrumentation/tacan/frequencies/selected-channel[4]");
-
-    SG_LOG( SG_INSTR, SG_DEBUG, "channels " << channel_1 << channel_2 << channel_3 << channel_4);
-
-    string channel = channel_1 + channel_2 + channel_3 + channel_4;
-
-                                    // Get the frequency
-    frequency_mhz = _last_frequency_mhz;
-    if (channel != _last_channel) {
-        _time_before_search_sec = 0;
-        _last_channel = channel;
-        frequency_mhz = searchChannel(channel);
-        SG_LOG( SG_INSTR, SG_DEBUG, "frequency " << frequency_mhz );
-        _frequency_node->setDoubleValue(frequency_mhz);
-    }
-
-    SG_LOG( SG_INSTR, SG_DEBUG, "channel " << channel );
-                                // Get the aircraft position
-    double longitude_deg = _longitude_node->getDoubleValue();
-    double latitude_deg  = _latitude_node->getDoubleValue();
-    double altitude_m    = _altitude_node->getDoubleValue() * SG_FEET_TO_METER;
-    double longitude_rad = longitude_deg * SGD_DEGREES_TO_RADIANS;
-    double latitude_rad  = latitude_deg * SGD_DEGREES_TO_RADIANS;
-
+  SGGeod pos(globals->get_aircraft_position());
                                 // On timeout, scan again
     _time_before_search_sec -= delta_time_sec;
-    if (_time_before_search_sec < 0 && frequency_mhz >= 0
-            || frequency_mhz != _last_frequency_mhz) {
-        search(frequency_mhz, longitude_rad, latitude_rad, altitude_m);
-        _last_frequency_mhz = frequency_mhz;
-    }
+    if ((_time_before_search_sec < 0 || _new_frequency) && _frequency_mhz >= 0)
+        search(_frequency_mhz, pos);
 
                                  // Calculate the distance to the transmitter
 
     //calculate the bearing and range of the mobile from the aircraft
-    SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lat " << _mobile_lat);
-    SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lon " << _mobile_lon);
-    SG_LOG( SG_INSTR, SG_DEBUG, "carrier_name " << _mobile_name);
-    SG_LOG( SG_INSTR, SG_DEBUG, "carrier_valid " << _mobile_valid);
-    geo_inverse_wgs_84(altitude_m,
-                       latitude_deg,
-                       longitude_deg,
-                       _mobile_lat,
-                       _mobile_lon,
+    double mobile_az2 = 0;
+    double mobile_bearing = 0;
+    double mobile_distance = 0;
+
+    SG_LOG( SG_INSTR, SG_DEBUG, "mobile_name " << _mobile_name);
+    SG_LOG( SG_INSTR, SG_DEBUG, "mobile_valid " << _mobile_valid);
+    geo_inverse_wgs_84(pos, _mobilePos,
                        &mobile_bearing, &mobile_az2, &mobile_distance);
 
+
     //calculate the bearing and range of the station from the aircraft
-    SGGeod pos = SGGeod::fromDegM(longitude_deg, latitude_deg, altitude_m);
+    double az2 = 0;
+    double bearing = 0;
+    double distance = 0;
+
     geo_inverse_wgs_84(pos, _transmitter_pos,
                        &bearing, &az2, &distance);
 
@@ -236,14 +175,14 @@ TACAN::update (double delta_time_sec)
         SG_LOG( SG_INSTR, SG_DEBUG, "distance_m " << distance);
         bearing = mobile_bearing;
         distance = mobile_distance;
-        _transmitter_pos.setElevationFt(_mobile_elevation_ft);
+        _transmitter_pos.setElevationFt(_mobilePos.getElevationFt());
         _transmitter_range_nm = _mobile_range_nm;
         _transmitter_bias = _mobile_bias;
         _transmitter_name = _mobile_name;
         _name_node->setStringValue(_transmitter_name.c_str());
         _transmitter_ident = _mobile_ident;
         _ident_node->setStringValue(_transmitter_ident.c_str());
-        _channel_node->setStringValue(channel.c_str());
+        _channel_node->setStringValue(_channel.c_str());
     }
 
     //// calculate some values for boresight display
@@ -274,7 +213,7 @@ TACAN::update (double delta_time_sec)
     double rotation = 0;
 
     double range_nm = adjust_range(_transmitter_pos.getElevationFt(),
-                                   altitude_m * SG_METER_TO_FEET,
+                                  pos.getElevationFt(),
                                    _transmitter_range_nm);
 
     if (distance_nm <= range_nm) {
@@ -289,7 +228,7 @@ TACAN::update (double delta_time_sec)
         }
         _distance_node->setDoubleValue( tmp_dist );
         _speed_node->setDoubleValue(speed_kt);
-        _time_node->setDoubleValue(distance_nm/speed_kt*60.0);
+        _time_node->setDoubleValue(speed_kt > 0 ? (distance_nm/speed_kt*60.0) : 0);
         _bearing_node->setDoubleValue(bearing);
         _x_shift_node->setDoubleValue(x_shift);
         _y_shift_node->setDoubleValue(y_shift);
@@ -320,16 +259,16 @@ TACAN::update (double delta_time_sec)
         _name_node->setStringValue(_transmitter_name.c_str());
         _transmitter_ident = "";
         _ident_node->setStringValue(_transmitter_ident.c_str());
-        _channel_node->setStringValue(channel.c_str());
+        _channel_node->setStringValue(_channel.c_str());
         return;
     }
 } // end function update
 
 void
-TACAN::search (double frequency_mhz, double longitude_rad,
-               double latitude_rad, double altitude_m)
+TACAN::search (double frequency_mhz,const SGGeod& pos)
 {
     int number, i;
+    _mobile_valid = false;
 
     SG_LOG( SG_INSTR, SG_DEBUG, "tacan freq " << frequency_mhz );
 
@@ -337,15 +276,13 @@ TACAN::search (double frequency_mhz, double longitude_rad,
     _time_before_search_sec = 1.0;
 
     //try any carriers first
-    FGNavRecord *mobile_tacan
-          = globals->get_carrierlist()->findStationByFreq( frequency_mhz );
+    FGNavRecord *mobile_tacan = FGNavList::findByFreq( frequency_mhz, FGNavList::carrierFilter() );
     bool freq_valid = (mobile_tacan != NULL);
     SG_LOG( SG_INSTR, SG_DEBUG, "mobile freqency valid " << freq_valid );
-    _mobile_valid = false;
 
     if ( freq_valid ) {
 
-        string str1( mobile_tacan->get_name() );
+        string str1( mobile_tacan->name() );
 
         SGPropertyNode * branch = fgGetNode("ai/models", true);
         vector<SGPropertyNode_ptr> carrier = branch->getChildren("carrier");
@@ -353,78 +290,69 @@ TACAN::search (double frequency_mhz, double longitude_rad,
         number = carrier.size();
 
         SG_LOG( SG_INSTR, SG_DEBUG, "carrier " << number );
-        if ( number > 0 ) {      // don't do this if there are no carriers
-            for ( i = 0; i < number; ++i ) {
-                string str2 ( carrier[i]->getStringValue("name", ""));
-                SG_LOG( SG_INSTR, SG_DEBUG, "carrier name " << str2 );
-
-                SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 2 " << str2 );
-                unsigned int loc1= str1.find( str2, 0 );
-                if ( loc1 != string::npos && str2 != "" ) {
-                    SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
-                    _mobile_lat = carrier[i]->getDoubleValue("position/latitude-deg");
-                    _mobile_lon = carrier[i]->getDoubleValue("position/longitude-deg");
-                    _mobile_elevation_ft = mobile_tacan->get_elev_ft();
-                    _mobile_range_nm = mobile_tacan->get_range();
-                    _mobile_bias = mobile_tacan->get_multiuse();
-                    _mobile_name = mobile_tacan->get_name();
-                    _mobile_ident = mobile_tacan->get_trans_ident();
-                    _mobile_valid = true;
-                    SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter valid " << _mobile_valid );
-                    break;
-                } else {
-                    _mobile_valid = false;
-                    SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _mobile_valid );
-                }
+        for ( i = 0; i < number; ++i ) {
+            string str2 ( carrier[i]->getStringValue("name", ""));
+            SG_LOG( SG_INSTR, SG_DEBUG, "carrier name " << str2 );
+
+            SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 2 " << str2 );
+            string::size_type loc1= str1.find( str2, 0 );
+            if ( loc1 != string::npos && str2 != "" ) {
+                SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
+                _mobilePos = SGGeod::fromDegFt(
+                             carrier[i]->getDoubleValue("position/longitude-deg"),
+                             carrier[i]->getDoubleValue("position/latitude-deg"),
+                             mobile_tacan->get_elev_ft());
+                _mobile_range_nm = mobile_tacan->get_range();
+                _mobile_bias = mobile_tacan->get_multiuse();
+                _mobile_name = mobile_tacan->name();
+                _mobile_ident = mobile_tacan->get_trans_ident();
+                _mobile_valid = true;
+                SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter valid " << _mobile_valid );
+                break;
+            } else {
+                _mobile_valid = false;
+                SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _mobile_valid );
             }
         }
 
-        SG_LOG( SG_INSTR, SG_DEBUG, "name " << _mobile_name);
-        SG_LOG( SG_INSTR, SG_DEBUG, "lat " << _mobile_lat << "lon " << _mobile_lon);
-        SG_LOG( SG_INSTR, SG_DEBUG, "elev " << _mobile_elevation_ft);
-
         //try any AI tankers second
 
         if ( !_mobile_valid) {
             SG_LOG( SG_INSTR, SG_DEBUG, "tanker transmitter valid start " << _mobile_valid );
 
         SGPropertyNode * branch = fgGetNode("ai/models", true);
-        vector<SGPropertyNode_ptr> tanker = branch->getChildren("aircraft");
+        vector<SGPropertyNode_ptr> tanker = branch->getChildren("tanker");
 
         number = tanker.size();
 
         SG_LOG( SG_INSTR, SG_DEBUG, "tanker number " << number );
 
-        if ( number > 0 ) {      // don't do this if there are no AI aircraft
-            for ( i = 0; i < number; ++i ) {
-                string str4 ( tanker[i]->getStringValue("callsign", ""));
-                SG_LOG( SG_INSTR, SG_DEBUG, "tanker callsign " << str4 );
-
-                SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 4 " << str4 );
-                unsigned int loc1= str1.find( str4, 0 );
-                if ( loc1 != string::npos && str4 != "" ) {
-                    SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
-                    _mobile_lat = tanker[i]->getDoubleValue("position/latitude-deg");
-                    _mobile_lon = tanker[i]->getDoubleValue("position/longitude-deg");
-                    _mobile_elevation_ft = tanker[i]->getDoubleValue("position/altitude-ft");
-                    _mobile_range_nm = mobile_tacan->get_range();
-                    _mobile_bias = mobile_tacan->get_multiuse();
-                    _mobile_name = mobile_tacan->get_name();
-                    _mobile_ident = mobile_tacan->get_trans_ident();
-                    _mobile_valid = true;
-                    SG_LOG( SG_INSTR, SG_DEBUG, " tanker transmitter valid " << _mobile_valid );
-                    break;
-                } else {
-                    _mobile_valid = false;
-                    SG_LOG( SG_INSTR, SG_DEBUG, " tanker transmitter invalid " << _mobile_valid );
-                }
+        for ( i = 0; i < number; ++i ) {
+            string str4 ( tanker[i]->getStringValue("callsign", ""));
+            SG_LOG( SG_INSTR, SG_DEBUG, "tanker callsign " << str4 );
+
+            SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 4 " << str4 );
+            string::size_type loc1= str1.find( str4, 0 );
+            if ( loc1 != string::npos && str4 != "" ) {
+                SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
+                _mobilePos = SGGeod::fromDegFt(
+                                             tanker[i]->getDoubleValue("position/longitude-deg"),
+                                             tanker[i]->getDoubleValue("position/latitude-deg"),
+                                             tanker[i]->getDoubleValue("position/altitude-ft"));
+
+              
+                _mobile_range_nm = mobile_tacan->get_range();
+                _mobile_bias = mobile_tacan->get_multiuse();
+                _mobile_name = mobile_tacan->name();
+                _mobile_ident = mobile_tacan->get_trans_ident();
+                _mobile_valid = true;
+                SG_LOG( SG_INSTR, SG_DEBUG, " tanker transmitter valid " << _mobile_valid );
+                break;
+            } else {
+                _mobile_valid = false;
+                SG_LOG( SG_INSTR, SG_DEBUG, " tanker transmitter invalid " << _mobile_valid );
             }
         }
-
-        SG_LOG( SG_INSTR, SG_DEBUG, "tanker name " << _mobile_name);
-        SG_LOG( SG_INSTR, SG_DEBUG, "lat " << _mobile_lat << "lon " << _mobile_lon);
-        SG_LOG( SG_INSTR, SG_DEBUG, "elev " << _mobile_elevation_ft);
-        SG_LOG( SG_INSTR, SG_DEBUG, "range " << _mobile_range_nm);
     }
 
     //try any mp tankers third, if we haven't found the tanker in the ai aircraft
@@ -445,22 +373,23 @@ TACAN::search (double frequency_mhz, double longitude_rad,
                 SG_LOG( SG_INSTR, SG_DEBUG, "mp tanker callsign " << str6 );
 
                 SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 5 " << str6 );
-                unsigned int loc1= str1.find( str6, 0 );
+                string::size_type loc1= str1.find( str6, 0 );
                 if ( loc1 != string::npos && str6 != "" ) {
                     SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
-                    _mobile_lat = mp_tanker[i]->getDoubleValue("position/latitude-deg");
-                    _mobile_lon = mp_tanker[i]->getDoubleValue("position/longitude-deg");
-                    _mobile_elevation_ft = mp_tanker[i]->getDoubleValue("position/altitude-ft");
+                  _mobilePos = SGGeod::fromDegFt(
+                                                 mp_tanker[i]->getDoubleValue("position/longitude-deg"),
+                                                 mp_tanker[i]->getDoubleValue("position/latitude-deg"),
+                                                 mp_tanker[i]->getDoubleValue("position/altitude-ft"));
+
+                  
                     _mobile_range_nm = mobile_tacan->get_range();
                     _mobile_bias = mobile_tacan->get_multiuse();
-                    _mobile_name = mobile_tacan->get_name();
+                    _mobile_name = mobile_tacan->name();
                     _mobile_ident = mobile_tacan->get_trans_ident();
                     _mobile_valid = true;
 
                     SG_LOG( SG_INSTR, SG_DEBUG, " mp tanker transmitter valid " << _mobile_valid );
                     SG_LOG( SG_INSTR, SG_DEBUG, " mp tanker name " << _mobile_name);
-                    SG_LOG( SG_INSTR, SG_DEBUG, " mp lat " << _mobile_lat << "lon " << _mobile_lon);
-                    SG_LOG( SG_INSTR, SG_DEBUG, " mp elev " << _mobile_elevation_ft);
                     SG_LOG( SG_INSTR, SG_DEBUG, " mp range " << _mobile_range_nm);
                     break;
                 } else {
@@ -476,19 +405,17 @@ TACAN::search (double frequency_mhz, double longitude_rad,
     }
 
     // try the TACAN/VORTAC list next
-    FGNavRecord *tacan
-        = globals->get_tacanlist()->findByFreq( frequency_mhz, longitude_rad,
-                                                latitude_rad, altitude_m);
+    FGNavRecord *tacan = FGNavList::findByFreq( frequency_mhz, pos, FGNavList::tacanFilter() );
 
     _transmitter_valid = (tacan != NULL);
 
     if ( _transmitter_valid ) {
         SG_LOG( SG_INSTR, SG_DEBUG, "transmitter valid " << _transmitter_valid );
 
-        _transmitter_pos = tacan->get_pos();
+        _transmitter_pos = tacan->geod();
         _transmitter_range_nm = tacan->get_range();
         _transmitter_bias = tacan->get_multiuse();
-        _transmitter_name = tacan->get_name();
+        _transmitter_name = tacan->name();
         _name_node->setStringValue(_transmitter_name.c_str());
         _transmitter_ident = tacan->get_trans_ident();
         _ident_node->setStringValue(_transmitter_ident.c_str());
@@ -520,4 +447,68 @@ TACAN::searchChannel (const string& channel)
     return frequency_khz = 0;
 } // end TACAN::searchChannel
 
+/*
+ * Listener callback. Maintains channel input properties,
+ * searches new channel frequency, updates _channel and
+ * _frequency and sets boolean _new_frequency appropriately.
+ */
+void
+TACAN::valueChanged(SGPropertyNode *prop)
+{
+    if (_listener_active)
+        return;
+    _listener_active++;
+
+    int index = prop->getIndex();
+    string channel = _channel;
+
+    if (index) {  // channel digit or X/Y input
+        int c;
+        if (isdigit(c = _channel_in1_node->getStringValue()[0]))
+            channel[0] = c;
+        if (isdigit(c = _channel_in2_node->getStringValue()[0]))
+            channel[1] = c;
+        if (isdigit(c = _channel_in3_node->getStringValue()[0]))
+            channel[2] = c;
+        c = _channel_in4_node->getStringValue()[0];
+        if (c == 'X' || c == 'Y')
+            channel[3] = c;
+
+    } else {      // channel number input
+        unsigned int f = prop->getIntValue();
+        if (f >= 1 && f <= 126) {
+            channel[0] = '0' + (f / 100) % 10;
+            channel[1] = '0' + (f / 10) % 10;
+            channel[2] = '0' + f % 10;
+        }
+    }
+
+    if (channel != _channel) {
+        SG_LOG(SG_INSTR, SG_DEBUG, "new channel " << channel);
+
+        // write back result
+        _channel_in0_node->setIntValue((channel[0] - '0') * 100
+                + (channel[1] - '0') * 10 + (channel[2] - '0'));
+        char s[2] = "0";
+        s[0] = channel[0], _channel_in1_node->setStringValue(s);
+        s[0] = channel[1], _channel_in2_node->setStringValue(s);
+        s[0] = channel[2], _channel_in3_node->setStringValue(s);
+        s[0] = channel[3], _channel_in4_node->setStringValue(s);
+
+        // search channel frequency
+        double freq = searchChannel(channel);
+        if (freq != _frequency_mhz) {
+            SG_LOG(SG_INSTR, SG_DEBUG, "new frequency " << freq);
+            _frequency_node->setDoubleValue(freq);
+            _frequency_mhz = freq;
+            _new_frequency = true;
+        }
+
+        _channel = channel;
+        _time_before_search_sec = 0;
+    }
+
+    _listener_active--;
+}
+
 // end of TACAN.cxx