]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGOutput.cpp
Dynamic calculation of CG and inertias.
[flightgear.git] / src / FDM / JSBSim / FGOutput.cpp
1 /*******************************************************************************
2
3  Module:       FGOutput.cpp
4  Author:       Jon Berndt
5  Date started: 12/02/98
6  Purpose:      Manage output of sim parameters to file or stdout
7  Called by:    FGSimExec
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This is the place where you create output routines to dump data for perusal
31 later. Some machines may not support the ncurses console output. Borland is one
32 of those environments which does not, so the ncurses stuff is commented out.
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 12/02/98   JSB   Created
37
38 ********************************************************************************
39 INCLUDES
40 *******************************************************************************/
41
42 #include "FGOutput.h"
43 #include "FGState.h"
44 #include "FGFDMExec.h"
45 #include "FGAtmosphere.h"
46 #include "FGFCS.h"
47 #include "FGAircraft.h"
48 #include "FGTranslation.h"
49 #include "FGRotation.h"
50 #include "FGPosition.h"
51 #include "FGAuxiliary.h"
52
53 /*******************************************************************************
54 ************************************ CODE **************************************
55 *******************************************************************************/
56
57 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
58 {
59   Name = "FGOutput";
60   FirstPass = true;
61 }
62
63
64 FGOutput::~FGOutput(void)
65 {
66 }
67
68
69 bool FGOutput::Run(void)
70 {
71   if (!FGModel::Run()) {
72     DelimitedOutput("JSBSimData.csv");
73   } else {
74   }
75   return false;
76 }
77
78
79 void FGOutput::DelimitedOutput(void)
80 {
81   if (FirstPass) {
82     cout << "Time,";
83     cout << "Altitude,";
84     cout << "Phi,";
85     cout << "Tht,";
86     cout << "Psi,";
87     cout << "Rho,";
88     cout << "Vtotal,";
89     cout << "U,";
90     cout << "V,";
91     cout << "W,";
92     cout << "Vn,";
93     cout << "Ve,";
94     cout << "Vd,";
95     cout << "Udot,";
96     cout << "Vdot,";
97     cout << "Wdot,";
98     cout << "P,";
99     cout << "Q,";
100     cout << "R,";
101     cout << "PDot,";
102     cout << "QDot,";
103     cout << "RDot,";
104     cout << "Fx,";
105     cout << "Fy,";
106     cout << "Fz,";
107     cout << "Latitude,";
108     cout << "Longitude,";
109     cout << "QBar,";
110     cout << "Alpha,";
111     cout << "L,";
112     cout << "M,";
113     cout << "N";
114     cout << endl;
115     FirstPass = false;
116   }
117
118   cout << State->Getsim_time() << ",";
119   cout << State->Geth() << ",";
120   cout << Rotation->Getphi() << ",";
121   cout << Rotation->Gettht() << ",";
122   cout << Rotation->Getpsi() << ",";
123   cout << Atmosphere->GetDensity() << ",";
124   cout << State->GetVt() << ",";
125   cout << Translation->GetU() << ",";
126   cout << Translation->GetV() << ",";
127   cout << Translation->GetW() << ",";
128   cout << Position->GetVn() << ",";
129   cout << Position->GetVe() << ",";
130   cout << Position->GetVd() << ",";
131   cout << Translation->GetUdot() << ",";
132   cout << Translation->GetVdot() << ",";
133   cout << Translation->GetWdot() << ",";
134   cout << Rotation->GetP() << ",";
135   cout << Rotation->GetQ() << ",";
136   cout << Rotation->GetR() << ",";
137   cout << Rotation->GetPdot() << ",";
138   cout << Rotation->GetQdot() << ",";
139   cout << Rotation->GetRdot() << ",";
140   cout << Aircraft->GetFx() << ",";
141   cout << Aircraft->GetFy() << ",";
142   cout << Aircraft->GetFz() << ",";
143   cout << State->Getlatitude() << ",";
144   cout << State->Getlongitude() << ",";
145   cout << State->Getqbar() << ",";
146   cout << Translation->Getalpha() << ",";
147   cout << Aircraft->GetL() << ",";
148   cout << Aircraft->GetM() << ",";
149   cout << Aircraft->GetN() << "";
150   cout << endl;
151
152 }
153
154
155 void FGOutput::DelimitedOutput(string fname)
156 {
157   if (FirstPass) {
158     datafile.open(fname.c_str());
159     datafile << "Time,";
160     datafile << "Altitude,";
161     datafile << "Phi,";
162     datafile << "Tht,";
163     datafile << "Psi,";
164     datafile << "Rho,";
165     datafile << "Vtotal,";
166     datafile << "U,";
167     datafile << "V,";
168     datafile << "W,";
169     datafile << "Vn,";
170     datafile << "Ve,";
171     datafile << "Vd,";
172     datafile << "Udot,";
173     datafile << "Vdot,";
174     datafile << "Wdot,";
175     datafile << "P,";
176     datafile << "Q,";
177     datafile << "R,";
178     datafile << "PDot,";
179     datafile << "QDot,";
180     datafile << "RDot,";
181     datafile << "Fx,";
182     datafile << "Fy,";
183     datafile << "Fz,";
184     datafile << "Latitude,";
185     datafile << "Longitude,";
186     datafile << "QBar,";
187     datafile << "Alpha,";
188     datafile << "L,";
189     datafile << "M,";
190     datafile << "N";
191     datafile << endl;
192     FirstPass = false;
193   }
194
195   datafile << State->Getsim_time() << ",";
196   datafile << State->Geth() << ",";
197   datafile << Rotation->Getphi() << ",";
198   datafile << Rotation->Gettht() << ",";
199   datafile << Rotation->Getpsi() << ",";
200   datafile << Atmosphere->GetDensity() << ",";
201   datafile << State->GetVt() << ",";
202   datafile << Translation->GetU() << ",";
203   datafile << Translation->GetV() << ",";
204   datafile << Translation->GetW() << ",";
205   datafile << Position->GetVn() << ",";
206   datafile << Position->GetVe() << ",";
207   datafile << Position->GetVd() << ",";
208   datafile << Translation->GetUdot() << ",";
209   datafile << Translation->GetVdot() << ",";
210   datafile << Translation->GetWdot() << ",";
211   datafile << Rotation->GetP() << ",";
212   datafile << Rotation->GetQ() << ",";
213   datafile << Rotation->GetR() << ",";
214   datafile << Rotation->GetPdot() << ",";
215   datafile << Rotation->GetQdot() << ",";
216   datafile << Rotation->GetRdot() << ",";
217   datafile << Aircraft->GetFx() << ",";
218   datafile << Aircraft->GetFy() << ",";
219   datafile << Aircraft->GetFz() << ",";
220   datafile << State->Getlatitude() << ",";
221   datafile << State->Getlongitude() << ",";
222   datafile << State->Getqbar() << ",";
223   datafile << Translation->Getalpha() << ",";
224   datafile << Aircraft->GetL() << ",";
225   datafile << Aircraft->GetM() << ",";
226   datafile << Aircraft->GetN() << "";
227   datafile << endl;
228   datafile.flush();
229 }
230