]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/ExternalNet/ExternalNet.cxx
Do not run the HoldDown code until after the aircraft is trimmed to prevent a devide...
[flightgear.git] / src / FDM / ExternalNet / ExternalNet.cxx
index 72578bd79e34271b455618194ce5df4d0e5b1f7a..aafa2c1041bfa58e2682aaa5b7d440c637b04b16 100644 (file)
@@ -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 <config.h>
 #endif
 
+#include <cstring>
+
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/lowlevel.hxx> // endian tests
+#include <simgear/io/sg_netBuffer.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Network/native_ctrls.hxx>
 #include "ExternalNet.hxx"
 
 
+class HTTPClient : public simgear::NetBufferChannel
+{
+
+    bool done;
+    SGTimeStamp start;
+    simgear::NetChannelPoller poller;
+public:
+
+    HTTPClient ( const char* host, int port, const char* path ) :
+        done( false )
+    {
+       open ();
+       connect (host, port);
+
+  char buffer[256];
+  ::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
+       bufferSend(buffer, strlen(buffer) ) ;
+
+        poller.addChannel(this);
+        start.stamp();
+    }
+
+    virtual void handleBufferRead (simgear::NetBuffer& buffer)
+    {
+       const char* s = buffer.getData();
+       while (*s)
+           fputc(*s++,stdout);
+
+       printf("done\n");
+       buffer.remove();
+       printf("after buffer.remove()\n");
+        done = true;
+    }
+
+    bool isDone() const { return done; }
+    bool isDone( long usec ) const { 
+        if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
+            return true;
+        } else {
+            return done;
+        }
+    }
+    
+    void poll(int timeout)
+    {
+        poller.poll(timeout);
+    }
+};
+
 FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
 {
 //     set_delta_t( dt );
@@ -102,7 +154,7 @@ void FGExternalNet::init() {
     double lon = fgGetDouble( "/sim/presets/longitude-deg" );
     double lat = fgGetDouble( "/sim/presets/latitude-deg" );
     double alt = fgGetDouble( "/sim/presets/altitude-ft" );
-    double ground = fgGetDouble( "/environment/ground-elevation-m" );
+    double ground = get_Runway_altitude_m();
     double heading = fgGetDouble("/sim/presets/heading-deg");
     double speed = fgGetDouble( "/sim/presets/airspeed-kt" );