]> git.mxchange.org Git - flightgear.git/blob - src/FDM/ExternalPipe/ExternalPipe.hxx
Make FGAircraftModel behave like a standarrd subsystem.
[flightgear.git] / src / FDM / ExternalPipe / ExternalPipe.hxx
1 // ExternalPipe.hxx -- a "pipe" interface to an external flight dynamics model
2 //
3 // Written by Curtis Olson, started March 2003.
4 //
5 // Copyright (C) 2003  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifndef _EXTERNAL_PIPE_HXX
24 #define _EXTERNAL_PIPE_HXX
25
26 #include <stdio.h>              // FILE*, fopen(), fread(), fwrite(), et. al.
27
28 #include <simgear/timing/timestamp.hxx> // fine grained timing measurements
29
30 #include <Network/net_ctrls.hxx>
31 #include <Network/net_fdm.hxx>
32 #include <FDM/flight.hxx>
33
34
35 class FGExternalPipe: public FGInterface {
36
37 private:
38
39     bool valid;
40
41     string fifo_name_1;
42     string fifo_name_2;
43     FILE *pd1;
44     FILE *pd2;
45     string _protocol;
46
47     FGNetCtrls ctrls;
48     FGNetFDM fdm;
49     char *buf;
50
51     double last_weight;
52     double last_cg_offset;
53
54     vector <string> property_names;
55     vector <SGPropertyNode_ptr> nodes;
56
57     // Protocol specific init routines
58     void init_binary();
59     void init_property();
60
61     // Protocol specific update routines
62     void update_binary( double dt );
63     void update_property( double dt );
64
65     void process_set_command( const string_list &tokens );
66 public:
67
68     // Constructor
69     FGExternalPipe( double dt, string fifo_name, string protocol );
70
71     // Destructor
72     ~FGExternalPipe();
73
74     // Reset flight params to a specific position
75     void init();
76
77     // update the fdm
78     void update( double dt );
79
80 };
81
82
83 #endif // _EXTERNAL_PIPE_HXX