1999-02-05 21:26:01 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
Module: FGOutput.cpp
|
|
|
|
Author: Jon Berndt
|
|
|
|
Date started: 12/02/98
|
|
|
|
Purpose: Manage output of sim parameters to file or stdout
|
|
|
|
Called by: FGSimExec
|
|
|
|
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
This is the place where you create output routines to dump data for perusal
|
|
|
|
later. Some machines may not support the ncurses console output. Borland is one
|
|
|
|
of those environments which does not, so the ncurses stuff is commented out.
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
12/02/98 JSB Created
|
|
|
|
|
|
|
|
********************************************************************************
|
|
|
|
INCLUDES
|
|
|
|
*******************************************************************************/
|
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
#include "FGOutput.h"
|
|
|
|
#include "FGState.h"
|
|
|
|
#include "FGFDMExec.h"
|
|
|
|
#include "FGAtmosphere.h"
|
|
|
|
#include "FGFCS.h"
|
|
|
|
#include "FGAircraft.h"
|
|
|
|
#include "FGTranslation.h"
|
|
|
|
#include "FGRotation.h"
|
|
|
|
#include "FGPosition.h"
|
|
|
|
#include "FGAuxiliary.h"
|
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
************************************ CODE **************************************
|
|
|
|
*******************************************************************************/
|
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
|
1999-02-05 21:26:01 +00:00
|
|
|
{
|
1999-02-26 22:09:10 +00:00
|
|
|
Name = "FGOutput";
|
1999-12-20 20:24:49 +00:00
|
|
|
sFirstPass = dFirstPass = true;
|
2000-01-10 21:07:00 +00:00
|
|
|
socket = 0;
|
|
|
|
//#ifdef FG_WITH_JSBSIM_SOCKET
|
1999-12-20 20:24:49 +00:00
|
|
|
socket = new FGfdmSocket("localhost",1138);
|
2000-01-10 21:07:00 +00:00
|
|
|
//#endif
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FGOutput::~FGOutput(void)
|
|
|
|
{
|
1999-12-20 20:24:49 +00:00
|
|
|
if (socket) delete socket;
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FGOutput::Run(void)
|
|
|
|
{
|
|
|
|
if (!FGModel::Run()) {
|
1999-12-30 17:42:24 +00:00
|
|
|
// SocketOutput();
|
2000-01-10 21:07:00 +00:00
|
|
|
// DelimitedOutput("JSBSimData.csv");
|
|
|
|
// DelimitedOutput();
|
1999-02-05 21:26:01 +00:00
|
|
|
} else {
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FGOutput::DelimitedOutput(void)
|
|
|
|
{
|
1999-12-20 20:24:49 +00:00
|
|
|
if (dFirstPass) {
|
1999-02-05 21:26:01 +00:00
|
|
|
cout << "Time,";
|
|
|
|
cout << "Altitude,";
|
|
|
|
cout << "Phi,";
|
|
|
|
cout << "Tht,";
|
|
|
|
cout << "Psi,";
|
|
|
|
cout << "Rho,";
|
|
|
|
cout << "Vtotal,";
|
|
|
|
cout << "U,";
|
|
|
|
cout << "V,";
|
|
|
|
cout << "W,";
|
|
|
|
cout << "Vn,";
|
|
|
|
cout << "Ve,";
|
|
|
|
cout << "Vd,";
|
|
|
|
cout << "Udot,";
|
|
|
|
cout << "Vdot,";
|
|
|
|
cout << "Wdot,";
|
1999-09-28 14:19:34 +00:00
|
|
|
cout << "P,";
|
|
|
|
cout << "Q,";
|
|
|
|
cout << "R,";
|
|
|
|
cout << "PDot,";
|
|
|
|
cout << "QDot,";
|
|
|
|
cout << "RDot,";
|
1999-02-05 21:26:01 +00:00
|
|
|
cout << "Fx,";
|
|
|
|
cout << "Fy,";
|
|
|
|
cout << "Fz,";
|
|
|
|
cout << "Latitude,";
|
|
|
|
cout << "Longitude,";
|
|
|
|
cout << "QBar,";
|
1999-06-28 17:39:20 +00:00
|
|
|
cout << "Alpha,";
|
|
|
|
cout << "L,";
|
|
|
|
cout << "M,";
|
1999-12-30 17:42:24 +00:00
|
|
|
cout << "N,";
|
|
|
|
cout << "Throttle,";
|
|
|
|
cout << "Aileron,";
|
|
|
|
cout << "Elevator,";
|
2000-01-10 21:07:00 +00:00
|
|
|
cout << "Rudder,";
|
|
|
|
cout << "Ixx,";
|
|
|
|
cout << "Iyy,";
|
|
|
|
cout << "Izz,";
|
|
|
|
cout << "Ixz,";
|
|
|
|
cout << "Mass,";
|
|
|
|
cout << "X CG";
|
1999-02-05 21:26:01 +00:00
|
|
|
cout << endl;
|
1999-12-20 20:24:49 +00:00
|
|
|
dFirstPass = false;
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
1999-07-31 04:55:23 +00:00
|
|
|
|
|
|
|
cout << State->Getsim_time() << ",";
|
|
|
|
cout << State->Geth() << ",";
|
|
|
|
cout << Rotation->Getphi() << ",";
|
|
|
|
cout << Rotation->Gettht() << ",";
|
|
|
|
cout << Rotation->Getpsi() << ",";
|
1999-09-28 14:19:34 +00:00
|
|
|
cout << Atmosphere->GetDensity() << ",";
|
1999-07-31 04:55:23 +00:00
|
|
|
cout << State->GetVt() << ",";
|
|
|
|
cout << Translation->GetU() << ",";
|
|
|
|
cout << Translation->GetV() << ",";
|
|
|
|
cout << Translation->GetW() << ",";
|
|
|
|
cout << Position->GetVn() << ",";
|
|
|
|
cout << Position->GetVe() << ",";
|
|
|
|
cout << Position->GetVd() << ",";
|
|
|
|
cout << Translation->GetUdot() << ",";
|
|
|
|
cout << Translation->GetVdot() << ",";
|
|
|
|
cout << Translation->GetWdot() << ",";
|
1999-09-28 14:19:34 +00:00
|
|
|
cout << Rotation->GetP() << ",";
|
|
|
|
cout << Rotation->GetQ() << ",";
|
|
|
|
cout << Rotation->GetR() << ",";
|
|
|
|
cout << Rotation->GetPdot() << ",";
|
|
|
|
cout << Rotation->GetQdot() << ",";
|
|
|
|
cout << Rotation->GetRdot() << ",";
|
1999-07-31 04:55:23 +00:00
|
|
|
cout << Aircraft->GetFx() << ",";
|
|
|
|
cout << Aircraft->GetFy() << ",";
|
|
|
|
cout << Aircraft->GetFz() << ",";
|
|
|
|
cout << State->Getlatitude() << ",";
|
|
|
|
cout << State->Getlongitude() << ",";
|
|
|
|
cout << State->Getqbar() << ",";
|
|
|
|
cout << Translation->Getalpha() << ",";
|
|
|
|
cout << Aircraft->GetL() << ",";
|
|
|
|
cout << Aircraft->GetM() << ",";
|
1999-12-30 17:42:24 +00:00
|
|
|
cout << Aircraft->GetN() << ",";
|
|
|
|
cout << FCS->GetThrottle(0) << ",";
|
|
|
|
cout << FCS->GetDa() << ",";
|
|
|
|
cout << FCS->GetDe() << ",";
|
2000-01-10 21:07:00 +00:00
|
|
|
cout << FCS->GetDr() << ",";
|
|
|
|
cout << Aircraft->GetIxx() << ",";
|
|
|
|
cout << Aircraft->GetIyy() << ",";
|
|
|
|
cout << Aircraft->GetIzz() << ",";
|
|
|
|
cout << Aircraft->GetIxz() << ",";
|
|
|
|
cout << Aircraft->GetMass() << ",";
|
|
|
|
cout << Aircraft->GetXcg() << "";
|
1999-07-31 04:55:23 +00:00
|
|
|
cout << endl;
|
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
1999-09-07 23:15:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FGOutput::DelimitedOutput(string fname)
|
|
|
|
{
|
1999-12-20 20:24:49 +00:00
|
|
|
if (sFirstPass) {
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile.open(fname.c_str());
|
|
|
|
datafile << "Time,";
|
|
|
|
datafile << "Altitude,";
|
|
|
|
datafile << "Phi,";
|
|
|
|
datafile << "Tht,";
|
|
|
|
datafile << "Psi,";
|
|
|
|
datafile << "Rho,";
|
|
|
|
datafile << "Vtotal,";
|
|
|
|
datafile << "U,";
|
|
|
|
datafile << "V,";
|
|
|
|
datafile << "W,";
|
|
|
|
datafile << "Vn,";
|
|
|
|
datafile << "Ve,";
|
|
|
|
datafile << "Vd,";
|
|
|
|
datafile << "Udot,";
|
|
|
|
datafile << "Vdot,";
|
|
|
|
datafile << "Wdot,";
|
1999-09-28 14:19:34 +00:00
|
|
|
datafile << "P,";
|
|
|
|
datafile << "Q,";
|
|
|
|
datafile << "R,";
|
|
|
|
datafile << "PDot,";
|
|
|
|
datafile << "QDot,";
|
|
|
|
datafile << "RDot,";
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << "Fx,";
|
|
|
|
datafile << "Fy,";
|
|
|
|
datafile << "Fz,";
|
|
|
|
datafile << "Latitude,";
|
|
|
|
datafile << "Longitude,";
|
|
|
|
datafile << "QBar,";
|
|
|
|
datafile << "Alpha,";
|
|
|
|
datafile << "L,";
|
|
|
|
datafile << "M,";
|
1999-12-30 17:42:24 +00:00
|
|
|
datafile << "N,";
|
|
|
|
datafile << "Throttle,";
|
|
|
|
datafile << "Aileron,";
|
|
|
|
datafile << "Elevator,";
|
2000-01-10 21:07:00 +00:00
|
|
|
datafile << "Rudder,";
|
|
|
|
datafile << "Ixx,";
|
|
|
|
datafile << "Iyy,";
|
|
|
|
datafile << "Izz,";
|
|
|
|
datafile << "Ixz,";
|
|
|
|
datafile << "Mass,";
|
|
|
|
datafile << "X CG";
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << endl;
|
1999-12-20 20:24:49 +00:00
|
|
|
sFirstPass = false;
|
1999-09-07 23:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
datafile << State->Getsim_time() << ",";
|
|
|
|
datafile << State->Geth() << ",";
|
|
|
|
datafile << Rotation->Getphi() << ",";
|
|
|
|
datafile << Rotation->Gettht() << ",";
|
|
|
|
datafile << Rotation->Getpsi() << ",";
|
1999-09-28 14:19:34 +00:00
|
|
|
datafile << Atmosphere->GetDensity() << ",";
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << State->GetVt() << ",";
|
|
|
|
datafile << Translation->GetU() << ",";
|
|
|
|
datafile << Translation->GetV() << ",";
|
|
|
|
datafile << Translation->GetW() << ",";
|
|
|
|
datafile << Position->GetVn() << ",";
|
|
|
|
datafile << Position->GetVe() << ",";
|
|
|
|
datafile << Position->GetVd() << ",";
|
|
|
|
datafile << Translation->GetUdot() << ",";
|
|
|
|
datafile << Translation->GetVdot() << ",";
|
|
|
|
datafile << Translation->GetWdot() << ",";
|
1999-09-28 14:19:34 +00:00
|
|
|
datafile << Rotation->GetP() << ",";
|
|
|
|
datafile << Rotation->GetQ() << ",";
|
|
|
|
datafile << Rotation->GetR() << ",";
|
|
|
|
datafile << Rotation->GetPdot() << ",";
|
|
|
|
datafile << Rotation->GetQdot() << ",";
|
|
|
|
datafile << Rotation->GetRdot() << ",";
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << Aircraft->GetFx() << ",";
|
|
|
|
datafile << Aircraft->GetFy() << ",";
|
|
|
|
datafile << Aircraft->GetFz() << ",";
|
|
|
|
datafile << State->Getlatitude() << ",";
|
|
|
|
datafile << State->Getlongitude() << ",";
|
|
|
|
datafile << State->Getqbar() << ",";
|
|
|
|
datafile << Translation->Getalpha() << ",";
|
|
|
|
datafile << Aircraft->GetL() << ",";
|
|
|
|
datafile << Aircraft->GetM() << ",";
|
1999-12-30 17:42:24 +00:00
|
|
|
datafile << Aircraft->GetN() << ",";
|
|
|
|
datafile << FCS->GetThrottle(0) << ",";
|
|
|
|
datafile << FCS->GetDa() << ",";
|
|
|
|
datafile << FCS->GetDe() << ",";
|
2000-01-10 21:07:00 +00:00
|
|
|
datafile << FCS->GetDr() << ",";
|
|
|
|
datafile << Aircraft->GetIxx() << ",";
|
|
|
|
datafile << Aircraft->GetIyy() << ",";
|
|
|
|
datafile << Aircraft->GetIzz() << ",";
|
|
|
|
datafile << Aircraft->GetIxz() << ",";
|
|
|
|
datafile << Aircraft->GetMass() << ",";
|
|
|
|
datafile << Aircraft->GetXcg() << "";
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << endl;
|
|
|
|
datafile.flush();
|
|
|
|
}
|
|
|
|
|
1999-12-20 20:24:49 +00:00
|
|
|
void FGOutput::SocketOutput(void)
|
|
|
|
{
|
|
|
|
string asciiData;
|
|
|
|
|
|
|
|
if (socket <= 0) return;
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
if (sFirstPass) {
|
|
|
|
socket->Append("<LABELS>");
|
|
|
|
socket->Append("Time");
|
|
|
|
socket->Append("Altitude");
|
|
|
|
socket->Append("Phi");
|
|
|
|
socket->Append("Tht");
|
|
|
|
socket->Append("Psi");
|
|
|
|
socket->Append("Rho");
|
|
|
|
socket->Append("Vtotal");
|
|
|
|
socket->Append("U");
|
|
|
|
socket->Append("V");
|
|
|
|
socket->Append("W");
|
|
|
|
socket->Append("Vn");
|
|
|
|
socket->Append("Ve");
|
|
|
|
socket->Append("Vd");
|
|
|
|
socket->Append("Udot");
|
|
|
|
socket->Append("Vdot");
|
|
|
|
socket->Append("Wdot");
|
|
|
|
socket->Append("P");
|
|
|
|
socket->Append("Q");
|
|
|
|
socket->Append("R");
|
|
|
|
socket->Append("PDot");
|
|
|
|
socket->Append("QDot");
|
|
|
|
socket->Append("RDot");
|
|
|
|
socket->Append("Fx");
|
|
|
|
socket->Append("Fy");
|
|
|
|
socket->Append("Fz");
|
|
|
|
socket->Append("Latitude");
|
|
|
|
socket->Append("Longitude");
|
|
|
|
socket->Append("QBar");
|
|
|
|
socket->Append("Alpha");
|
|
|
|
socket->Append("L");
|
|
|
|
socket->Append("M");
|
|
|
|
socket->Append("N");
|
2000-01-10 21:07:00 +00:00
|
|
|
socket->Append("Throttle");
|
|
|
|
socket->Append("Aileron");
|
|
|
|
socket->Append("Elevator");
|
|
|
|
socket->Append("Rudder");
|
1999-12-20 20:24:49 +00:00
|
|
|
sFirstPass = false;
|
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
socket->Append(State->Getsim_time());
|
|
|
|
socket->Append(State->Geth());
|
|
|
|
socket->Append(Rotation->Getphi());
|
|
|
|
socket->Append(Rotation->Gettht());
|
|
|
|
socket->Append(Rotation->Getpsi());
|
|
|
|
socket->Append(Atmosphere->GetDensity());
|
|
|
|
socket->Append(State->GetVt());
|
|
|
|
socket->Append(Translation->GetU());
|
|
|
|
socket->Append(Translation->GetV());
|
|
|
|
socket->Append(Translation->GetW());
|
|
|
|
socket->Append(Position->GetVn());
|
|
|
|
socket->Append(Position->GetVe());
|
|
|
|
socket->Append(Position->GetVd());
|
|
|
|
socket->Append(Translation->GetUdot());
|
|
|
|
socket->Append(Translation->GetVdot());
|
|
|
|
socket->Append(Translation->GetWdot());
|
|
|
|
socket->Append(Rotation->GetP());
|
|
|
|
socket->Append(Rotation->GetQ());
|
|
|
|
socket->Append(Rotation->GetR());
|
|
|
|
socket->Append(Rotation->GetPdot());
|
|
|
|
socket->Append(Rotation->GetQdot());
|
|
|
|
socket->Append(Rotation->GetRdot());
|
|
|
|
socket->Append(Aircraft->GetFx());
|
|
|
|
socket->Append(Aircraft->GetFy());
|
|
|
|
socket->Append(Aircraft->GetFz());
|
|
|
|
socket->Append(State->Getlatitude());
|
|
|
|
socket->Append(State->Getlongitude());
|
|
|
|
socket->Append(State->Getqbar());
|
|
|
|
socket->Append(Translation->Getalpha());
|
|
|
|
socket->Append(Aircraft->GetL());
|
|
|
|
socket->Append(Aircraft->GetM());
|
|
|
|
socket->Append(Aircraft->GetN());
|
2000-01-10 21:07:00 +00:00
|
|
|
socket->Append(FCS->GetThrottle(0));
|
|
|
|
socket->Append(FCS->GetDa());
|
|
|
|
socket->Append(FCS->GetDe());
|
|
|
|
socket->Append(FCS->GetDr());
|
1999-12-20 20:24:49 +00:00
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FGOutput::SocketStatusOutput(string out_str)
|
|
|
|
{
|
|
|
|
string asciiData;
|
|
|
|
|
|
|
|
if (socket <= 0) return;
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
asciiData = string("<STATUS>") + out_str;
|
|
|
|
socket->Append(asciiData.c_str());
|
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|