]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGOutput.cpp
abf5bdcac32f70fa22355702a288d03f96790f15
[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 #ifdef FGFS
43 #  include <Include/compiler.h>
44 #  ifdef FG_HAVE_STD_INCLUDES
45 #    include <iostream>
46 #  else
47 #    include <iostream.h>
48 #  endif
49 #else
50 #  include <iostream>
51 #endif
52
53 #ifdef HAVE_CURSES
54   #include <ncurses.h>
55 #endif
56
57 #include "FGOutput.h"
58 #include "FGState.h"
59 #include "FGFDMExec.h"
60 #include "FGAtmosphere.h"
61 #include "FGFCS.h"
62 #include "FGAircraft.h"
63 #include "FGTranslation.h"
64 #include "FGRotation.h"
65 #include "FGPosition.h"
66 #include "FGAuxiliary.h"
67
68 /*******************************************************************************
69 ************************************ CODE **************************************
70 *******************************************************************************/
71
72 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
73 {
74   Name = "FGOutput";
75   FirstPass = true;
76 #ifdef HAVE_CURSES
77   initscr();
78   cbreak();
79   noecho();
80 #endif
81 }
82
83
84 FGOutput::~FGOutput(void)
85 {
86 }
87
88
89 bool FGOutput::Run(void)
90 {
91   if (!FGModel::Run()) {
92     DelimitedOutput();
93 //    ConsoleOutput();
94   } else {
95   }
96   return false;
97 }
98
99
100 void FGOutput::ConsoleOutput(void)
101 {
102 #ifdef HAVE_CURSES
103   string buffer;
104
105   clear();
106   move(1,1);  insstr("Quaternions");
107   move(2,5);  insstr("Q0");
108   move(2,16); insstr("Q1");
109   move(2,27); insstr("Q2");
110   move(2,38); insstr("Q3");
111
112   move(3,1);  buffer = Rotation->GetQ0(); insstr(buffer.c_str());
113   move(3,12); buffer = Rotation->GetQ1(); insstr(buffer.c_str());
114   move(3,23); buffer = Rotation->GetQ2(); insstr(buffer.c_str());
115   move(3,34); buffer = Rotation->GetQ3(); insstr(buffer.c_str());
116
117   move(0,0); insstr("Time: ");
118   move(0,6); insstr(gcvt(State->Getsim_time(),6,buffer));
119
120   move(2,46); insstr("Phi");
121   move(2,55); insstr("Tht");
122   move(2,64); insstr("Psi");
123
124   move(3,45); buffer = Rotation->Getphi(); insstr(buffer.c_str());
125   move(3,54); buffer = Rotation->Gettht(); insstr(buffer.c_str());
126   move(3,63); buffer = Rotation->Getpsi(); insstr(buffer.c_str());
127
128   move(5,47); insstr("U");
129   move(5,56); insstr("V");
130   move(5,65); insstr("W");
131
132   move(6,45); buffer = Translation->GetU(); insstr(buffer.c_str());
133   move(6,54); buffer = Translation->GetV(); insstr(buffer.c_str());
134   move(6,63); buffer = Translation->GetW(); insstr(buffer.c_str());
135
136   move(8,47); insstr("Fx");
137   move(8,56); insstr("Fy");
138   move(8,65); insstr("Fz");
139
140   move(9,45); buffer = Aircraft->GetFx(); insstr(buffer.c_str());
141   move(9,54); buffer = Aircraft->GetFy(); insstr(buffer.c_str());
142   move(9,63); buffer = Aircraft->GetFz(); insstr(buffer.c_str());
143
144   move(11,47); insstr("Fn");
145   move(11,56); insstr("Fe");
146   move(11,65); insstr("Fd");
147
148   move(12,45); buffer = Position->GetFn(); insstr(buffer.c_str());
149   move(12,54); buffer = Position->GetFe(); insstr(buffer.c_str());
150   move(12,63); buffer = Position->GetFd(); insstr(buffer.c_str());
151
152   move(14,47); insstr("Latitude");
153   move(14,57); insstr("Longitude");
154   move(14,67); insstr("Altitude");
155
156   move(15,47); buffer = State->Getlatitude(); insstr(buffer.c_str());
157   move(15,57); buffer = State->Getlongitude(); insstr(buffer.c_str());
158   move(15,67); buffer = State->Geth(); insstr(buffer.c_str());
159
160   refresh();
161
162   move(LINES-1,1);
163   refresh();
164 #endif
165 }
166
167
168 void FGOutput::DelimitedOutput(void)
169 {
170   if (FirstPass) {
171     cout << "Time,";
172     cout << "Altitude,";
173     cout << "Phi,";
174     cout << "Tht,";
175     cout << "Psi,";
176     cout << "Rho,";
177     cout << "Vtotal,";
178     cout << "U,";
179     cout << "V,";
180     cout << "W,";
181     cout << "Vn,";
182     cout << "Ve,";
183     cout << "Vd,";
184     cout << "Udot,";
185     cout << "Vdot,";
186     cout << "Wdot,";
187     cout << "Fx,";
188     cout << "Fy,";
189     cout << "Fz,";
190     cout << "Latitude,";
191     cout << "Longitude,";
192     cout << "QBar,";
193     cout << "Alpha,";
194     cout << "L,";
195     cout << "M,";
196     cout << "N";
197     cout << endl;
198     FirstPass = false;
199   } else {
200     cout << State->Getsim_time() << ",";
201     cout << State->Geth() << ",";
202     cout << Rotation->Getphi() << ",";
203     cout << Rotation->Gettht() << ",";
204     cout << Rotation->Getpsi() << ",";
205     cout << Atmosphere->Getrho() << ",";
206     cout << State->GetVt() << ",";
207     cout << Translation->GetU() << ",";
208     cout << Translation->GetV() << ",";
209     cout << Translation->GetW() << ",";
210     cout << Position->GetVn() << ",";
211     cout << Position->GetVe() << ",";
212     cout << Position->GetVd() << ",";
213     cout << Translation->GetUdot() << ",";
214     cout << Translation->GetVdot() << ",";
215     cout << Translation->GetWdot() << ",";
216     cout << Aircraft->GetFx() << ",";
217     cout << Aircraft->GetFy() << ",";
218     cout << Aircraft->GetFz() << ",";
219     cout << State->Getlatitude() << ",";
220     cout << State->Getlongitude() << ",";
221     cout << State->Getqbar() << ",";
222     cout << Translation->Getalpha() << ",";
223                 cout << Aircraft->GetL() << ",";
224                 cout << Aircraft->GetM() << ",";
225                 cout << Aircraft->GetN() << "";
226     cout << endl;
227   }
228 }