]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_gui.cxx
Logging: less verbose panel loading.
[flightgear.git] / src / Network / native_gui.cxx
index 91618430f2675b75e567165131176cdd409da639..9171822521f119071b6f9588642dc4a1f6d93bac 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started January 2002.
 //
-// Copyright (C) 2002  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2002  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 #include <simgear/io/iochannel.hxx>
 #include <simgear/timing/sg_time.hxx>
 
-#include <Cockpit/radiostack.hxx>
 #include <FDM/flight.hxx>
 #include <Time/tmp.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "native_gui.hxx"
 
@@ -120,7 +120,23 @@ bool FGNativeGUI::open() {
 
 
 void FGProps2NetGUI( FGNetGUI *net ) {
-    int i;
+    static SGPropertyNode *nav_freq
+       = fgGetNode("/instrumentation/nav/frequencies/selected-mhz", true);
+    static SGPropertyNode *nav_target_radial
+       = fgGetNode("/instrumentation/nav/radials/target-radial-deg", true);
+    static SGPropertyNode *nav_inrange
+       = fgGetNode("/instrumentation/nav/in-range", true);
+    static SGPropertyNode *nav_loc
+       = fgGetNode("/instrumentation/nav/nav-loc", true);
+    static SGPropertyNode *nav_gs_dist_signed
+       = fgGetNode("/instrumentation/nav/gs-distance", true);
+    static SGPropertyNode *nav_loc_dist
+       = fgGetNode("/instrumentation/nav/nav-distance", true);
+    static SGPropertyNode *nav_reciprocal_radial
+       = fgGetNode("/instrumentation/nav/radials/reciprocal-radial-deg", true);
+    static SGPropertyNode *nav_gs_deflection
+       = fgGetNode("/instrumentation/nav/gs-needle-deflection", true);
+    unsigned int i;
 
     // Version sanity checking
     net->version = FG_NET_GUI_VERSION;
@@ -144,15 +160,37 @@ void FGProps2NetGUI( FGNetGUI *net ) {
         net->fuel_quantity[i] = node->getDoubleValue("level-gal_us");
     }
 
-    // the following really aren't used in this context
+    // Environment
     net->cur_time = globals->get_time_params()->get_cur_time();
     net->warp = globals->get_warp();
+    net->ground_elev = cur_fdm_state->get_Runway_altitude_m();
 
     // Approach
-    net->dist_nm = current_radiostack->get_navcom1()->get_nav_gs_dist();
+    net->tuned_freq = nav_freq->getDoubleValue();
+    net->nav_radial = nav_target_radial->getDoubleValue();
+    net->in_range = nav_inrange->getBoolValue();
+
+    if ( nav_loc->getBoolValue() ) {
+        // is an ILS
+        net->dist_nm
+            = nav_gs_dist_signed->getDoubleValue()
+              * SG_METER_TO_NM;
+    } else {
+        // is a VOR
+        net->dist_nm = nav_loc_dist->getDoubleValue()
+            * SG_METER_TO_NM;
+    }
+
     net->course_deviation_deg
-        = current_radiostack->get_navcom1()->get_nav_heading()
-        - current_radiostack->get_navcom1()->get_nav_radial();
+        = nav_reciprocal_radial->getDoubleValue()
+        - nav_target_radial->getDoubleValue();
+
+    if ( net->course_deviation_deg < -1000.0 
+         || net->course_deviation_deg > 1000.0 )
+    {
+        // Sanity check ...
+        net->course_deviation_deg = 0.0;
+    }
     while ( net->course_deviation_deg >  180.0 ) {
         net->course_deviation_deg -= 360.0;
     }
@@ -164,9 +202,16 @@ void FGProps2NetGUI( FGNetGUI *net ) {
             = ( net->course_deviation_deg<0.0
                 ? -net->course_deviation_deg - 180.0
                 : -net->course_deviation_deg + 180.0 );
-    net->gs_deviation_deg
-        = current_radiostack->get_navcom1()->get_nav_gs_needle_deflection()
-        / 5.0;
+
+    if ( nav_loc->getBoolValue() ) {
+        // is an ILS
+        net->gs_deviation_deg
+            = nav_gs_deflection->getDoubleValue()
+            / 5.0;
+    } else {
+        // is an ILS
+        net->gs_deviation_deg = -9999.0;
+    }
 
 #if defined( FG_USE_NETWORK_BYTE_ORDER )
     // Convert the net buffer to network format
@@ -188,7 +233,11 @@ void FGProps2NetGUI( FGNetGUI *net ) {
 
     net->cur_time = htonl( net->cur_time );
     net->warp = htonl( net->warp );
+    net->ground_elev = htonl( net->ground_elev );
 
+    htonf(net->tuned_freq);
+    htonf(net->nav_radial);
+    net->in_range = htonl( net->in_range );
     htonf(net->dist_nm);
     htonf(net->course_deviation_deg);
     htonf(net->gs_deviation_deg);
@@ -197,7 +246,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
 
 
 void FGNetGUI2Props( FGNetGUI *net ) {
-    int i;
+    unsigned int i;
 
 #if defined( FG_USE_NETWORK_BYTE_ORDER )
     // Convert to the net buffer from network format
@@ -219,7 +268,11 @@ void FGNetGUI2Props( FGNetGUI *net ) {
 
     net->cur_time = ntohl(net->cur_time);
     net->warp = ntohl(net->warp);
+    net->ground_elev = htonl( net->ground_elev );
 
+    htonf(net->tuned_freq);
+    htonf(net->nav_radial);
+    net->in_range = htonl( net->in_range );
     htonf(net->dist_nm);
     htonf(net->course_deviation_deg);
     htonf(net->gs_deviation_deg);
@@ -253,10 +306,13 @@ void FGNetGUI2Props( FGNetGUI *net ) {
         globals->set_warp( net->warp );
 
         // Approach
-        fgSetDouble( "/radios/dme/distance-nm", net->dist_nm );
-        fgSetDouble( "/radios/nav[0]/heading-needle-deflection",
+        fgSetDouble( "/instrumentation/nav[0]/frequencies/selected-mhz",
+                     net->tuned_freq );
+        fgSetBool( "/instrumentation/nav[0]/in-range", net->in_range );
+        fgSetDouble( "/instrumentation/dme/indicated-distance-nm", net->dist_nm );
+        fgSetDouble( "/instrumentation/nav[0]/heading-needle-deflection",
                      net->course_deviation_deg );
-        fgSetDouble( "/radios/nav[0]/gs-needle-deflection",
+        fgSetDouble( "/instrumentation/nav[0]/gs-needle-deflection",
                      net->gs_deviation_deg );
     } else {
        SG_LOG( SG_IO, SG_ALERT,