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