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