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;
|
2000-01-11 17:26:43 +00:00
|
|
|
#ifdef FG_WITH_JSBSIM_SOCKET
|
1999-12-20 20:24:49 +00:00
|
|
|
socket = new FGfdmSocket("localhost",1138);
|
2000-01-11 17:26:43 +00:00
|
|
|
#endif
|
1999-02-05 21:26:01 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
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
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
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;
|
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
|
|
|
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 << "QBar,";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << "Vtotal,";
|
1999-12-30 17:42:24 +00:00
|
|
|
cout << "Throttle,";
|
|
|
|
cout << "Aileron,";
|
|
|
|
cout << "Elevator,";
|
2000-01-10 21:07:00 +00:00
|
|
|
cout << "Rudder,";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << "Rho,";
|
2000-01-10 21:07:00 +00:00
|
|
|
cout << "Ixx,";
|
|
|
|
cout << "Iyy,";
|
|
|
|
cout << "Izz,";
|
|
|
|
cout << "Ixz,";
|
|
|
|
cout << "Mass,";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << "Xcg, Ycg, Zcg, ";
|
|
|
|
cout << "Xforce, Yforce, Zforce,";
|
|
|
|
cout << "L, M, N, ";
|
|
|
|
cout << "Altitude,";
|
|
|
|
cout << "Phi, Tht, Psi,";
|
|
|
|
cout << "P, Q, R, ";
|
|
|
|
cout << "U, V, W, ";
|
|
|
|
cout << "Alpha,";
|
|
|
|
cout << "Vn, Ve, Vd, ";
|
|
|
|
cout << "Latitude,";
|
|
|
|
cout << "Longitude";
|
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() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
cout << Translation->Getqbar() << ",";
|
|
|
|
cout << Translation->GetVt() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << FCS->GetThrottlePos(0) << ",";
|
|
|
|
cout << FCS->GetDaPos() << ",";
|
|
|
|
cout << FCS->GetDePos() << ",";
|
|
|
|
cout << FCS->GetDrPos() << ",";
|
|
|
|
cout << Atmosphere->GetDensity() << ",";
|
2000-01-10 21:07:00 +00:00
|
|
|
cout << Aircraft->GetIxx() << ",";
|
|
|
|
cout << Aircraft->GetIyy() << ",";
|
|
|
|
cout << Aircraft->GetIzz() << ",";
|
|
|
|
cout << Aircraft->GetIxz() << ",";
|
|
|
|
cout << Aircraft->GetMass() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << Aircraft->GetXYZcg() << ",";
|
|
|
|
cout << Aircraft->GetForces() << ",";
|
|
|
|
cout << Aircraft->GetMoments() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
cout << Position->Geth() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
cout << Rotation->GetEuler() << ",";
|
|
|
|
cout << Rotation->GetPQR() << ",";
|
|
|
|
cout << Translation->GetUVW() << ",";
|
|
|
|
cout << Translation->Getalpha() << ",";
|
|
|
|
cout << Position->GetVel() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
cout << Position->GetLatitude() << ",";
|
|
|
|
cout << Position->GetLongitude();
|
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
|
|
|
|
2000-04-24 23:49:06 +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 << "QBar,";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << "Vtotal,";
|
1999-12-30 17:42:24 +00:00
|
|
|
datafile << "Throttle,";
|
|
|
|
datafile << "Aileron,";
|
|
|
|
datafile << "Elevator,";
|
2000-01-10 21:07:00 +00:00
|
|
|
datafile << "Rudder,";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << "Rho,";
|
2000-01-10 21:07:00 +00:00
|
|
|
datafile << "Ixx,";
|
|
|
|
datafile << "Iyy,";
|
|
|
|
datafile << "Izz,";
|
|
|
|
datafile << "Ixz,";
|
|
|
|
datafile << "Mass,";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << "Xcg, Ycg, Zcg, ";
|
|
|
|
datafile << "Xforce, Yforce, Zforce, ";
|
|
|
|
datafile << "L, M, N, ";
|
|
|
|
datafile << "Altitude,";
|
|
|
|
datafile << "Phi, Tht, Psi,";
|
|
|
|
datafile << "P, Q, R, ";
|
|
|
|
datafile << "U, V, W, ";
|
|
|
|
datafile << "Alpha,";
|
|
|
|
datafile << "Vn, Ve, Vd, ";
|
|
|
|
datafile << "Latitude,";
|
|
|
|
datafile << "Longitude";
|
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() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
datafile << Translation->Getqbar() << ",";
|
|
|
|
datafile << Translation->GetVt() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << FCS->GetThrottlePos(0) << ",";
|
|
|
|
datafile << FCS->GetDaPos() << ",";
|
|
|
|
datafile << FCS->GetDePos() << ",";
|
|
|
|
datafile << FCS->GetDrPos() << ",";
|
|
|
|
datafile << Atmosphere->GetDensity() << ",";
|
2000-01-10 21:07:00 +00:00
|
|
|
datafile << Aircraft->GetIxx() << ",";
|
|
|
|
datafile << Aircraft->GetIyy() << ",";
|
|
|
|
datafile << Aircraft->GetIzz() << ",";
|
|
|
|
datafile << Aircraft->GetIxz() << ",";
|
|
|
|
datafile << Aircraft->GetMass() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << Aircraft->GetXYZcg() << ",";
|
|
|
|
datafile << Aircraft->GetForces() << ",";
|
|
|
|
datafile << Aircraft->GetMoments() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
datafile << Position->Geth() << ",";
|
2000-04-24 23:49:06 +00:00
|
|
|
datafile << Rotation->GetEuler() << ",";
|
|
|
|
datafile << Rotation->GetPQR() << ",";
|
|
|
|
datafile << Translation->GetUVW() << ",";
|
|
|
|
datafile << Translation->Getalpha() << ",";
|
|
|
|
datafile << Position->GetVel() << ",";
|
2000-04-28 19:59:46 +00:00
|
|
|
datafile << Position->GetLatitude() << ",";
|
|
|
|
datafile << Position->GetLongitude();
|
1999-09-07 23:15:45 +00:00
|
|
|
datafile << endl;
|
|
|
|
datafile.flush();
|
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
|
1999-12-20 20:24:49 +00:00
|
|
|
void FGOutput::SocketOutput(void)
|
|
|
|
{
|
|
|
|
string asciiData;
|
2000-04-24 23:49:06 +00:00
|
|
|
/*
|
1999-12-20 20:24:49 +00:00
|
|
|
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());
|
2000-04-28 19:59:46 +00:00
|
|
|
socket->Append(Position->Geth());
|
1999-12-20 20:24:49 +00:00
|
|
|
socket->Append(Rotation->Getphi());
|
|
|
|
socket->Append(Rotation->Gettht());
|
|
|
|
socket->Append(Rotation->Getpsi());
|
|
|
|
socket->Append(Atmosphere->GetDensity());
|
2000-04-28 19:59:46 +00:00
|
|
|
socket->Append(Translation->GetVt());
|
1999-12-20 20:24:49 +00:00
|
|
|
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());
|
2000-04-28 19:59:46 +00:00
|
|
|
socket->Append(Position->GetLatitude());
|
|
|
|
socket->Append(Position->GetLongitude());
|
|
|
|
socket->Append(Translation->Getqbar());
|
1999-12-20 20:24:49 +00:00
|
|
|
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());
|
2000-04-24 23:49:06 +00:00
|
|
|
socket->Send(); */
|
1999-12-20 20:24:49 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
1999-12-20 20:24:49 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
|