1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
19 You should have received a copy of the GNU Lesser General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
44 # include <simgear/compiler.h>
45 # include STL_IOSTREAM
48 # if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
49 # include <iostream.h>
57 #include <input_output/FGfdmSocket.h>
58 #include <input_output/FGXMLElement.h>
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 #define ID_OUTPUT "$Id$"
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76 /** Handles simulation output.
77 OUTPUT section definition
79 The following specifies the way that JSBSim writes out data.
81 NAME is the filename you want the output to go to
84 CSV Comma separated data. If a filename is supplied then the data
85 goes to that file. If COUT or cout is specified, the data goes
86 to stdout. If the filename is a null filename the data goes to
88 SOCKET Will eventually send data to a socket output, where NAME
89 would then be the IP address of the machine the data should be
90 sent to. DON'T USE THIS YET!
91 TABULAR Columnar data. NOT IMPLEMENTED YET!
92 TERMINAL Output to terminal. NOT IMPLEMENTED YET!
93 NONE Specifies to do nothing. THis setting makes it easy to turn on and
94 off the data output without having to mess with anything else.
96 The arguments that can be supplied, currently, are
98 RATE_IN_HZ An integer rate in times-per-second that the data is output. This
99 value may not be *exactly* what you want, due to the dependence
100 on dt, the cycle rate for the FDM.
102 The following parameters tell which subsystems of data to output:
114 GROUND_REACTIONS ON|OFF
118 NOTE that Time is always output with the data.
122 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
126 class FGOutput : public FGModel
129 FGOutput(FGFDMExec*);
134 void DelimitedOutput(string);
135 void SocketOutput(void);
136 void SocketStatusOutput(string);
137 void SetType(string);
138 void SetSubsystems(int tt) {SubSystems = tt;}
139 inline void Enable(void) { enabled = true; }
140 inline void Disable(void) { enabled = false; }
141 inline bool Toggle(void) {enabled = !enabled; return enabled;}
142 bool Load(Element* el);
143 void SetOutputFileName(string fname) {Filename = fname;}
144 void SetDirectivesFile(string fname) {DirectivesFile = fname;}
145 string GetOutputFileName(void) const {return Filename;}
147 /// Subsystem types for specifying which will be output in the FDM data logging
149 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
150 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
151 /** Subsystem: Body rates (= 4) */ ssRates = 4,
152 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
153 /** Subsystem: Forces (= 16) */ ssForces = 16,
154 /** Subsystem: Moments (= 32) */ ssMoments = 32,
155 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
156 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
157 /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
158 /** Subsystem: Propagate (= 512) */ ssPropagate = 512,
159 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
160 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
161 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
165 enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
166 bool sFirstPass, dFirstPass, enabled;
168 string output_file_name, delimeter, Filename, DirectivesFile;
171 vector <FGPropertyManager*> OutputProperties;
173 void Debug(int from);
176 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%