]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/atlas.cxx
Update Mac configure script for new ALUT scheme; support --with-alut-framework.
[flightgear.git] / src / Network / atlas.cxx
index ea75d22b19e7225a04d63d519859c847b8841351..f0738a12f208e42ed3ab8009a8b11353c4b3861a 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started November 1999.
 //
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1999  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
 //
 // 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$
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/io/iochannel.hxx>
 
-#include <Cockpit/radiostack.hxx>
+
+
+
 #include <FDM/flight.hxx>
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
+#include <Main/fg_init.hxx>
 
 #include "atlas.hxx"
 
@@ -63,6 +70,17 @@ static char calc_atlas_cksum(char *sentence) {
 bool FGAtlas::gen_message() {
     // cout << "generating atlas message" << endl;
 
+    static SGPropertyNode *adf_freq
+        = fgGetNode("/instrumentation/adf/frequencies/selected-khz", true);
+    static SGPropertyNode *nav1_freq
+        = fgGetNode("/instrumentation/nav/frequencies/selected-mhz", true);
+    static SGPropertyNode *nav1_sel_radial
+        = fgGetNode("/instrumentation/nav/radials/selected-deg", true);
+    static SGPropertyNode *nav2_freq
+        = fgGetNode("/instrumentation/nav[1]/frequencies/selected-mhz", true);
+    static SGPropertyNode *nav2_sel_radial
+        = fgGetNode("/instrumentation/nav[1]/radials/selected-deg", true);
+
     char rmc[256], gga[256], patla[256];
     char rmc_sum[10], gga_sum[10], patla_sum[10];
     char dir;
@@ -126,11 +144,11 @@ bool FGAtlas::gen_message() {
     sprintf( gga_sum, "%02X", calc_atlas_cksum(gga) );
 
     sprintf( patla, "PATLA,%.2f,%.1f,%.2f,%.1f,%.0f",
-            current_radiostack->get_nav1_freq(),
-            current_radiostack->get_nav1_sel_radial(),
-            current_radiostack->get_nav2_freq(),
-            current_radiostack->get_nav2_sel_radial(),
-            current_radiostack->get_adf_freq() );
+            nav1_freq->getDoubleValue(),
+            nav1_sel_radial->getDoubleValue(),
+            nav2_freq->getDoubleValue(),
+            nav2_sel_radial->getDoubleValue(),
+            adf_freq->getDoubleValue() );
     sprintf( patla_sum, "%02X", calc_atlas_cksum(patla) );
 
     SG_LOG( SG_IO, SG_DEBUG, rmc );
@@ -160,7 +178,7 @@ bool FGAtlas::gen_message() {
     atlas_sentence += patla_sum;
     atlas_sentence += "\n";
 
-    cout << atlas_sentence;
+    //    cout << atlas_sentence;
 
     length = atlas_sentence.length();
     strncpy( buf, atlas_sentence.c_str(), length );
@@ -541,20 +559,20 @@ bool FGAtlas::process() {
     if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
-           SG_LOG( SG_IO, SG_ALERT, "Error writing data." );
+           SG_LOG( SG_IO, SG_WARN, "Error writing data." );
            return false;
        }
     } else if ( get_direction() == SG_IO_IN ) {
        if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
            parse_message();
        } else {
-           SG_LOG( SG_IO, SG_ALERT, "Error reading data." );
+           SG_LOG( SG_IO, SG_WARN, "Error reading data." );
            return false;
        }
        if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
            parse_message();
        } else {
-           SG_LOG( SG_IO, SG_ALERT, "Error reading data." );
+           SG_LOG( SG_IO, SG_WARN, "Error reading data." );
            return false;
        }
     }
@@ -565,6 +583,7 @@ bool FGAtlas::process() {
 
 // close the channel
 bool FGAtlas::close() {
+    SG_LOG( SG_IO, SG_INFO, "closing FGAtlas" );   
     SGIOChannel *io = get_io_channel();
 
     set_enabled( false );