]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGOutput.cpp
Updates to get engine working.
[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 << "Fx,";
99     cout << "Fy,";
100     cout << "Fz,";
101     cout << "Latitude,";
102     cout << "Longitude,";
103     cout << "QBar,";
104     cout << "Alpha,";
105     cout << "L,";
106     cout << "M,";
107     cout << "N";
108     cout << endl;
109     FirstPass = false;
110   }
111
112   cout << State->Getsim_time() << ",";
113   cout << State->Geth() << ",";
114   cout << Rotation->Getphi() << ",";
115   cout << Rotation->Gettht() << ",";
116   cout << Rotation->Getpsi() << ",";
117   cout << Atmosphere->Getrho() << ",";
118   cout << State->GetVt() << ",";
119   cout << Translation->GetU() << ",";
120   cout << Translation->GetV() << ",";
121   cout << Translation->GetW() << ",";
122   cout << Position->GetVn() << ",";
123   cout << Position->GetVe() << ",";
124   cout << Position->GetVd() << ",";
125   cout << Translation->GetUdot() << ",";
126   cout << Translation->GetVdot() << ",";
127   cout << Translation->GetWdot() << ",";
128   cout << Aircraft->GetFx() << ",";
129   cout << Aircraft->GetFy() << ",";
130   cout << Aircraft->GetFz() << ",";
131   cout << State->Getlatitude() << ",";
132   cout << State->Getlongitude() << ",";
133   cout << State->Getqbar() << ",";
134   cout << Translation->Getalpha() << ",";
135   cout << Aircraft->GetL() << ",";
136   cout << Aircraft->GetM() << ",";
137   cout << Aircraft->GetN() << "";
138   cout << endl;
139
140 }
141
142
143 void FGOutput::DelimitedOutput(string fname)
144 {
145   if (FirstPass) {
146     datafile.open(fname.c_str());
147     datafile << "Time,";
148     datafile << "Altitude,";
149     datafile << "Phi,";
150     datafile << "Tht,";
151     datafile << "Psi,";
152     datafile << "Rho,";
153     datafile << "Vtotal,";
154     datafile << "U,";
155     datafile << "V,";
156     datafile << "W,";
157     datafile << "Vn,";
158     datafile << "Ve,";
159     datafile << "Vd,";
160     datafile << "Udot,";
161     datafile << "Vdot,";
162     datafile << "Wdot,";
163     datafile << "Fx,";
164     datafile << "Fy,";
165     datafile << "Fz,";
166     datafile << "Latitude,";
167     datafile << "Longitude,";
168     datafile << "QBar,";
169     datafile << "Alpha,";
170     datafile << "L,";
171     datafile << "M,";
172     datafile << "N";
173     datafile << endl;
174     FirstPass = false;
175   }
176
177   datafile << State->Getsim_time() << ",";
178   datafile << State->Geth() << ",";
179   datafile << Rotation->Getphi() << ",";
180   datafile << Rotation->Gettht() << ",";
181   datafile << Rotation->Getpsi() << ",";
182   datafile << Atmosphere->Getrho() << ",";
183   datafile << State->GetVt() << ",";
184   datafile << Translation->GetU() << ",";
185   datafile << Translation->GetV() << ",";
186   datafile << Translation->GetW() << ",";
187   datafile << Position->GetVn() << ",";
188   datafile << Position->GetVe() << ",";
189   datafile << Position->GetVd() << ",";
190   datafile << Translation->GetUdot() << ",";
191   datafile << Translation->GetVdot() << ",";
192   datafile << Translation->GetWdot() << ",";
193   datafile << Aircraft->GetFx() << ",";
194   datafile << Aircraft->GetFy() << ",";
195   datafile << Aircraft->GetFz() << ",";
196   datafile << State->Getlatitude() << ",";
197   datafile << State->Getlongitude() << ",";
198   datafile << State->Getqbar() << ",";
199   datafile << Translation->Getalpha() << ",";
200   datafile << Aircraft->GetL() << ",";
201   datafile << Aircraft->GetM() << ",";
202   datafile << Aircraft->GetN() << "";
203   datafile << endl;
204   datafile.flush();
205 }
206