2003-03-03 04:30:16 +00:00
|
|
|
// ExternalPipe.hxx -- a "pipe" interface to an external flight dynamics model
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started March 2003.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2003 Curtis L. Olson - http://www.flightgear.org/~curt
|
2003-03-03 04:30:16 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-03-03 04:30:16 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#ifndef _EXTERNAL_PIPE_HXX
|
|
|
|
#define _EXTERNAL_PIPE_HXX
|
|
|
|
|
2005-04-19 01:44:56 +00:00
|
|
|
#include <stdio.h> // FILE*, fopen(), fread(), fwrite(), et. al.
|
|
|
|
|
2003-03-03 04:30:16 +00:00
|
|
|
#include <simgear/timing/timestamp.hxx> // fine grained timing measurements
|
|
|
|
|
|
|
|
#include <Network/net_ctrls.hxx>
|
|
|
|
#include <Network/net_fdm.hxx>
|
2006-04-17 13:19:53 +00:00
|
|
|
#include <FDM/flight.hxx>
|
2003-03-03 04:30:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FGExternalPipe: public FGInterface {
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
string fifo_name_1;
|
|
|
|
string fifo_name_2;
|
2005-04-19 01:44:56 +00:00
|
|
|
FILE *pd1;
|
|
|
|
FILE *pd2;
|
|
|
|
string _protocol;
|
2003-03-03 04:30:16 +00:00
|
|
|
|
|
|
|
FGNetCtrls ctrls;
|
|
|
|
FGNetFDM fdm;
|
|
|
|
char *buf;
|
|
|
|
|
2004-04-01 15:27:53 +00:00
|
|
|
double last_weight;
|
|
|
|
double last_cg_offset;
|
|
|
|
|
2005-04-19 01:44:56 +00:00
|
|
|
vector <string> property_names;
|
2006-06-11 10:21:10 +00:00
|
|
|
vector <SGPropertyNode_ptr> nodes;
|
2005-04-19 01:44:56 +00:00
|
|
|
|
|
|
|
// Protocol specific init routines
|
|
|
|
void init_binary();
|
|
|
|
void init_property();
|
|
|
|
|
|
|
|
// Protocol specific update routines
|
|
|
|
void update_binary( double dt );
|
|
|
|
void update_property( double dt );
|
|
|
|
|
2003-03-03 04:30:16 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
2005-04-19 01:44:56 +00:00
|
|
|
FGExternalPipe( double dt, string fifo_name, string protocol );
|
2003-03-03 04:30:16 +00:00
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~FGExternalPipe();
|
|
|
|
|
|
|
|
// Reset flight params to a specific position
|
|
|
|
void init();
|
|
|
|
|
|
|
|
// update the fdm
|
|
|
|
void update( double dt );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _EXTERNAL_PIPE_HXX
|