2004-03-15 09:24:57 +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
|
2007-01-15 12:48:54 +00:00
|
|
|
the terms of the GNU Lesser General Public License as published by the Free Software
|
2004-03-15 09:24:57 +00:00
|
|
|
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
|
2007-01-15 12:48:54 +00:00
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
2004-03-15 09:24:57 +00:00
|
|
|
details.
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along with
|
2004-03-15 09:24:57 +00:00
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
Further information about the GNU Lesser General Public License can also be found on
|
2004-03-15 09:24:57 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
12/02/98 JSB Created
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
INCLUDES
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#include "FGOutput.h"
|
|
|
|
#include "FGState.h"
|
|
|
|
#include "FGFDMExec.h"
|
|
|
|
#include "FGAtmosphere.h"
|
|
|
|
#include "FGFCS.h"
|
|
|
|
#include "FGAerodynamics.h"
|
|
|
|
#include "FGGroundReactions.h"
|
|
|
|
#include "FGAircraft.h"
|
|
|
|
#include "FGMassBalance.h"
|
2004-06-14 11:40:45 +00:00
|
|
|
#include "FGPropagate.h"
|
2004-03-15 09:24:57 +00:00
|
|
|
#include "FGAuxiliary.h"
|
|
|
|
#include "FGInertial.h"
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
#include <fstream>
|
2004-06-14 11:40:45 +00:00
|
|
|
#include <iomanip>
|
|
|
|
|
2004-03-15 09:24:57 +00:00
|
|
|
namespace JSBSim {
|
|
|
|
|
|
|
|
static const char *IdSrc = "$Id$";
|
|
|
|
static const char *IdHdr = ID_OUTPUT;
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS IMPLEMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
|
|
|
|
{
|
|
|
|
Name = "FGOutput";
|
|
|
|
sFirstPass = dFirstPass = true;
|
|
|
|
socket = 0;
|
|
|
|
Type = otNone;
|
|
|
|
SubSystems = 0;
|
|
|
|
enabled = true;
|
2004-12-16 12:47:20 +00:00
|
|
|
delimeter = ", ";
|
2006-01-12 15:04:22 +00:00
|
|
|
Filename = "";
|
2007-01-15 12:48:54 +00:00
|
|
|
DirectivesFile = "";
|
2004-03-15 09:24:57 +00:00
|
|
|
|
|
|
|
Debug(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
FGOutput::~FGOutput()
|
|
|
|
{
|
2007-01-15 12:48:54 +00:00
|
|
|
delete socket;
|
2006-01-12 15:04:22 +00:00
|
|
|
OutputProperties.clear();
|
2004-03-15 09:24:57 +00:00
|
|
|
Debug(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
bool FGOutput::Run(void)
|
|
|
|
{
|
2006-01-12 15:04:22 +00:00
|
|
|
if (FGModel::Run()) return true;
|
|
|
|
|
|
|
|
if (enabled && !State->IntegrationSuspended()&& !FDMExec->Holding()) {
|
2004-06-14 11:40:45 +00:00
|
|
|
if (Type == otSocket) {
|
|
|
|
SocketOutput();
|
2004-12-16 12:47:20 +00:00
|
|
|
} else if (Type == otCSV || Type == otTab) {
|
2004-06-14 11:40:45 +00:00
|
|
|
DelimitedOutput(Filename);
|
|
|
|
} else if (Type == otTerminal) {
|
|
|
|
// Not done yet
|
|
|
|
} else if (Type == otNone) {
|
|
|
|
// Do nothing
|
2004-03-15 09:24:57 +00:00
|
|
|
} else {
|
2004-06-14 11:40:45 +00:00
|
|
|
// Not a valid type of output
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGOutput::SetType(string type)
|
|
|
|
{
|
|
|
|
if (type == "CSV") {
|
|
|
|
Type = otCSV;
|
2004-12-16 12:47:20 +00:00
|
|
|
delimeter = ", ";
|
2004-03-15 09:24:57 +00:00
|
|
|
} else if (type == "TABULAR") {
|
|
|
|
Type = otTab;
|
2004-12-16 12:47:20 +00:00
|
|
|
delimeter = "\t";
|
2004-03-15 09:24:57 +00:00
|
|
|
} else if (type == "SOCKET") {
|
|
|
|
Type = otSocket;
|
|
|
|
} else if (type == "TERMINAL") {
|
|
|
|
Type = otTerminal;
|
|
|
|
} else if (type != string("NONE")) {
|
|
|
|
Type = otUnknown;
|
|
|
|
cerr << "Unknown type of output specified in config file" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGOutput::DelimitedOutput(string fname)
|
|
|
|
{
|
|
|
|
streambuf* buffer;
|
|
|
|
string scratch = "";
|
|
|
|
|
|
|
|
if (fname == "COUT" || fname == "cout") {
|
|
|
|
buffer = cout.rdbuf();
|
|
|
|
} else {
|
|
|
|
datafile.open(fname.c_str());
|
|
|
|
buffer = datafile.rdbuf();
|
|
|
|
}
|
|
|
|
|
|
|
|
ostream outstream(buffer);
|
|
|
|
|
|
|
|
if (dFirstPass) {
|
|
|
|
outstream << "Time";
|
|
|
|
if (SubSystems & ssSimulation) {
|
|
|
|
// Nothing here, yet
|
|
|
|
}
|
|
|
|
if (SubSystems & ssAerosurfaces) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "Aileron Command (norm)" + delimeter;
|
|
|
|
outstream << "Elevator Command (norm)" + delimeter;
|
|
|
|
outstream << "Rudder Command (norm)" + delimeter;
|
|
|
|
outstream << "Flap Command (norm)" + delimeter;
|
|
|
|
outstream << "Left Aileron Position (deg)" + delimeter;
|
|
|
|
outstream << "Right Aileron Position (deg)" + delimeter;
|
|
|
|
outstream << "Elevator Position (deg)" + delimeter;
|
|
|
|
outstream << "Rudder Position (deg)" + delimeter;
|
|
|
|
outstream << "Flap Position (deg)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssRates) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter;
|
|
|
|
outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssVelocities) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "q bar (psf)" + delimeter;
|
|
|
|
outstream << "V_{Total} (ft/s)" + delimeter;
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
|
|
|
|
outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssForces) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter;
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << "L/D" + delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "F_X (lbs)" + delimeter + "F_Y (lbs)" + delimeter + "F_Z (lbs)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssMoments) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "L (ft-lbs)" + delimeter + "M (ft-lbs)" + delimeter + "N (ft-lbs)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssAtmosphere) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "Rho (slugs/ft^3)" + delimeter;
|
|
|
|
outstream << "P_{SL} (psf)" + delimeter;
|
|
|
|
outstream << "P_{Ambient} (psf)" + delimeter;
|
|
|
|
outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssMassProps) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "I_xx" + delimeter;
|
|
|
|
outstream << "I_xy" + delimeter;
|
|
|
|
outstream << "I_xz" + delimeter;
|
|
|
|
outstream << "I_yx" + delimeter;
|
|
|
|
outstream << "I_yy" + delimeter;
|
|
|
|
outstream << "I_yz" + delimeter;
|
|
|
|
outstream << "I_zx" + delimeter;
|
|
|
|
outstream << "I_zy" + delimeter;
|
|
|
|
outstream << "I_zz" + delimeter;
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << "Mass" + delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "X_cg" + delimeter + "Y_cg" + delimeter + "Z_cg";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
2004-06-14 11:40:45 +00:00
|
|
|
if (SubSystems & ssPropagate) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << "Altitude (ft)" + delimeter;
|
|
|
|
outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter;
|
|
|
|
outstream << "Alpha (deg)" + delimeter;
|
|
|
|
outstream << "Beta (deg)" + delimeter;
|
|
|
|
outstream << "Latitude (deg)" + delimeter;
|
|
|
|
outstream << "Longitude (deg)" + delimeter;
|
|
|
|
outstream << "Distance AGL (ft)" + delimeter;
|
|
|
|
outstream << "Runway Radius (ft)";
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssCoefficients) {
|
2004-12-16 12:47:20 +00:00
|
|
|
scratch = Aerodynamics->GetCoefficientStrings(delimeter);
|
|
|
|
if (scratch.length() != 0) outstream << delimeter << scratch;
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssFCS) {
|
2004-12-16 12:47:20 +00:00
|
|
|
scratch = FCS->GetComponentStrings(delimeter);
|
|
|
|
if (scratch.length() != 0) outstream << delimeter << scratch;
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssGroundReactions) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << GroundReactions->GetGroundReactionStrings(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Propulsion->GetPropulsionStrings(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (OutputProperties.size() > 0) {
|
|
|
|
for (unsigned int i=0;i<OutputProperties.size();i++) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter << OutputProperties[i]->GetName();
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
outstream << endl;
|
|
|
|
dFirstPass = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
outstream << State->Getsim_time();
|
|
|
|
if (SubSystems & ssSimulation) {
|
|
|
|
}
|
|
|
|
if (SubSystems & ssAerosurfaces) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << FCS->GetDaCmd() << delimeter;
|
|
|
|
outstream << FCS->GetDeCmd() << delimeter;
|
|
|
|
outstream << FCS->GetDrCmd() << delimeter;
|
|
|
|
outstream << FCS->GetDfCmd() << delimeter;
|
2007-01-15 12:48:54 +00:00
|
|
|
outstream << FCS->GetDaLPos(ofDeg) << delimeter;
|
|
|
|
outstream << FCS->GetDaRPos(ofDeg) << delimeter;
|
|
|
|
outstream << FCS->GetDePos(ofDeg) << delimeter;
|
|
|
|
outstream << FCS->GetDrPos(ofDeg) << delimeter;
|
|
|
|
outstream << FCS->GetDfPos(ofDeg);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssRates) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Propagate->GetPQR().Dump(delimeter) << delimeter;
|
|
|
|
outstream << Propagate->GetPQRdot().Dump(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssVelocities) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Auxiliary->Getqbar() << delimeter;
|
|
|
|
outstream << setprecision(12) << Auxiliary->GetVt() << delimeter;
|
|
|
|
outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter;
|
|
|
|
outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter;
|
|
|
|
outstream << Propagate->GetVel().Dump(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssForces) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Aerodynamics->GetvFs() << delimeter;
|
|
|
|
outstream << Aerodynamics->GetLoD() << delimeter;
|
|
|
|
outstream << Aircraft->GetForces().Dump(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssMoments) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Aircraft->GetMoments().Dump(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssAtmosphere) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Atmosphere->GetDensity() << delimeter;
|
2006-01-12 15:04:22 +00:00
|
|
|
outstream << Atmosphere->GetPressureSL() << delimeter;
|
|
|
|
outstream << Atmosphere->GetPressure() << delimeter;
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << Atmosphere->GetWindNED().Dump(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssMassProps) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << MassBalance->GetJ() << delimeter;
|
|
|
|
outstream << MassBalance->GetMass() << delimeter;
|
2004-03-15 09:24:57 +00:00
|
|
|
outstream << MassBalance->GetXYZcg();
|
|
|
|
}
|
2004-06-14 11:40:45 +00:00
|
|
|
if (SubSystems & ssPropagate) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Propagate->Geth() << delimeter;
|
|
|
|
outstream << Propagate->GetEuler().Dump(delimeter) << delimeter;
|
|
|
|
outstream << Auxiliary->Getalpha(inDegrees) << delimeter;
|
|
|
|
outstream << Auxiliary->Getbeta(inDegrees) << delimeter;
|
|
|
|
outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter;
|
|
|
|
outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter;
|
|
|
|
outstream << Propagate->GetDistanceAGL() << delimeter;
|
2004-06-14 11:40:45 +00:00
|
|
|
outstream << Propagate->GetRunwayRadius();
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssCoefficients) {
|
2004-12-16 12:47:20 +00:00
|
|
|
scratch = Aerodynamics->GetCoefficientValues(delimeter);
|
|
|
|
if (scratch.length() != 0) outstream << delimeter << scratch;
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssFCS) {
|
2004-12-16 12:47:20 +00:00
|
|
|
scratch = FCS->GetComponentValues(delimeter);
|
|
|
|
if (scratch.length() != 0) outstream << delimeter << scratch;
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssGroundReactions) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << GroundReactions->GetGroundReactionValues(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter;
|
|
|
|
outstream << Propulsion->GetPropulsionValues(delimeter);
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i=0;i<OutputProperties.size();i++) {
|
2004-12-16 12:47:20 +00:00
|
|
|
outstream << delimeter << OutputProperties[i]->getDoubleValue();
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
outstream << endl;
|
|
|
|
outstream.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGOutput::SocketOutput(void)
|
|
|
|
{
|
2006-01-12 15:04:22 +00:00
|
|
|
string asciiData, scratch;
|
2004-03-15 09:24:57 +00:00
|
|
|
|
|
|
|
if (socket == NULL) return;
|
|
|
|
if (!socket->GetConnectStatus()) return;
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
if (sFirstPass) {
|
2006-01-12 15:04:22 +00:00
|
|
|
socket->Clear("<LABELS>");
|
2004-03-15 09:24:57 +00:00
|
|
|
socket->Append("Time");
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
if (SubSystems & ssAerosurfaces) {
|
|
|
|
socket->Append("Aileron Command");
|
|
|
|
socket->Append("Elevator Command");
|
|
|
|
socket->Append("Rudder Command");
|
|
|
|
socket->Append("Flap Command");
|
|
|
|
socket->Append("Left Aileron Position");
|
|
|
|
socket->Append("Right Aileron Position");
|
|
|
|
socket->Append("Elevator Position");
|
|
|
|
socket->Append("Rudder Position");
|
|
|
|
socket->Append("Flap Position");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubSystems & ssRates) {
|
|
|
|
socket->Append("P");
|
|
|
|
socket->Append("Q");
|
|
|
|
socket->Append("R");
|
|
|
|
socket->Append("PDot");
|
|
|
|
socket->Append("QDot");
|
|
|
|
socket->Append("RDot");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubSystems & ssVelocities) {
|
|
|
|
socket->Append("QBar");
|
|
|
|
socket->Append("Vtotal");
|
|
|
|
socket->Append("UBody");
|
|
|
|
socket->Append("VBody");
|
|
|
|
socket->Append("WBody");
|
|
|
|
socket->Append("UAero");
|
|
|
|
socket->Append("VAero");
|
|
|
|
socket->Append("WAero");
|
|
|
|
socket->Append("Vn");
|
|
|
|
socket->Append("Ve");
|
|
|
|
socket->Append("Vd");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssForces) {
|
|
|
|
socket->Append("F_Drag");
|
|
|
|
socket->Append("F_Side");
|
|
|
|
socket->Append("F_Lift");
|
|
|
|
socket->Append("LoD");
|
|
|
|
socket->Append("Fx");
|
|
|
|
socket->Append("Fy");
|
|
|
|
socket->Append("Fz");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssMoments) {
|
|
|
|
socket->Append("L");
|
|
|
|
socket->Append("M");
|
|
|
|
socket->Append("N");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssAtmosphere) {
|
|
|
|
socket->Append("Rho");
|
|
|
|
socket->Append("SL pressure");
|
|
|
|
socket->Append("Ambient pressure");
|
|
|
|
socket->Append("NWind");
|
|
|
|
socket->Append("EWind");
|
|
|
|
socket->Append("DWind");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssMassProps) {
|
|
|
|
socket->Append("Ixx");
|
|
|
|
socket->Append("Ixy");
|
|
|
|
socket->Append("Ixz");
|
|
|
|
socket->Append("Iyx");
|
|
|
|
socket->Append("Iyy");
|
|
|
|
socket->Append("Iyz");
|
|
|
|
socket->Append("Izx");
|
|
|
|
socket->Append("Izy");
|
|
|
|
socket->Append("Izz");
|
|
|
|
socket->Append("Mass");
|
|
|
|
socket->Append("Xcg");
|
|
|
|
socket->Append("Ycg");
|
|
|
|
socket->Append("Zcg");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssPropagate) {
|
|
|
|
socket->Append("Altitude");
|
|
|
|
socket->Append("Phi");
|
|
|
|
socket->Append("Tht");
|
|
|
|
socket->Append("Psi");
|
|
|
|
socket->Append("Alpha");
|
|
|
|
socket->Append("Beta");
|
|
|
|
socket->Append("Latitude (Deg)");
|
|
|
|
socket->Append("Longitude (Deg)");
|
|
|
|
}
|
|
|
|
if (SubSystems & ssCoefficients) {
|
|
|
|
scratch = Aerodynamics->GetCoefficientStrings(",");
|
|
|
|
if (scratch.length() != 0) socket->Append(scratch);
|
|
|
|
}
|
|
|
|
if (SubSystems & ssFCS) {
|
|
|
|
scratch = FCS->GetComponentStrings(",");
|
|
|
|
if (scratch.length() != 0) socket->Append(scratch);
|
|
|
|
}
|
|
|
|
if (SubSystems & ssGroundReactions) {
|
|
|
|
socket->Append(GroundReactions->GetGroundReactionStrings(","));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
|
|
|
|
socket->Append(Propulsion->GetPropulsionStrings(","));
|
|
|
|
}
|
|
|
|
if (OutputProperties.size() > 0) {
|
|
|
|
for (unsigned int i=0;i<OutputProperties.size();i++) {
|
|
|
|
socket->Append(OutputProperties[i]->GetName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-15 09:24:57 +00:00
|
|
|
sFirstPass = false;
|
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
socket->Append(State->Getsim_time());
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
if (SubSystems & ssAerosurfaces) {
|
|
|
|
socket->Append(FCS->GetDaCmd());
|
|
|
|
socket->Append(FCS->GetDeCmd());
|
|
|
|
socket->Append(FCS->GetDrCmd());
|
|
|
|
socket->Append(FCS->GetDfCmd());
|
|
|
|
socket->Append(FCS->GetDaLPos());
|
|
|
|
socket->Append(FCS->GetDaRPos());
|
|
|
|
socket->Append(FCS->GetDePos());
|
|
|
|
socket->Append(FCS->GetDrPos());
|
|
|
|
socket->Append(FCS->GetDfPos());
|
|
|
|
}
|
|
|
|
if (SubSystems & ssRates) {
|
|
|
|
socket->Append(Propagate->GetPQR(eP));
|
|
|
|
socket->Append(Propagate->GetPQR(eQ));
|
|
|
|
socket->Append(Propagate->GetPQR(eR));
|
|
|
|
socket->Append(Propagate->GetPQRdot(eP));
|
|
|
|
socket->Append(Propagate->GetPQRdot(eQ));
|
|
|
|
socket->Append(Propagate->GetPQRdot(eR));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssVelocities) {
|
|
|
|
socket->Append(Auxiliary->Getqbar());
|
|
|
|
socket->Append(Auxiliary->GetVt());
|
|
|
|
socket->Append(Propagate->GetUVW(eU));
|
|
|
|
socket->Append(Propagate->GetUVW(eV));
|
|
|
|
socket->Append(Propagate->GetUVW(eW));
|
|
|
|
socket->Append(Auxiliary->GetAeroUVW(eU));
|
|
|
|
socket->Append(Auxiliary->GetAeroUVW(eV));
|
|
|
|
socket->Append(Auxiliary->GetAeroUVW(eW));
|
|
|
|
socket->Append(Propagate->GetVel(eNorth));
|
|
|
|
socket->Append(Propagate->GetVel(eEast));
|
|
|
|
socket->Append(Propagate->GetVel(eDown));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssForces) {
|
|
|
|
socket->Append(Aerodynamics->GetvFs()(eDrag));
|
|
|
|
socket->Append(Aerodynamics->GetvFs()(eSide));
|
|
|
|
socket->Append(Aerodynamics->GetvFs()(eLift));
|
|
|
|
socket->Append(Aerodynamics->GetLoD());
|
|
|
|
socket->Append(Aircraft->GetForces(eX));
|
|
|
|
socket->Append(Aircraft->GetForces(eY));
|
|
|
|
socket->Append(Aircraft->GetForces(eZ));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssMoments) {
|
|
|
|
socket->Append(Aircraft->GetMoments(eL));
|
|
|
|
socket->Append(Aircraft->GetMoments(eM));
|
|
|
|
socket->Append(Aircraft->GetMoments(eN));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssAtmosphere) {
|
|
|
|
socket->Append(Atmosphere->GetDensity());
|
|
|
|
socket->Append(Atmosphere->GetPressureSL());
|
|
|
|
socket->Append(Atmosphere->GetPressure());
|
|
|
|
socket->Append(Atmosphere->GetWindNED().Dump(","));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssMassProps) {
|
|
|
|
socket->Append(MassBalance->GetJ()(1,1));
|
|
|
|
socket->Append(MassBalance->GetJ()(1,2));
|
|
|
|
socket->Append(MassBalance->GetJ()(1,3));
|
|
|
|
socket->Append(MassBalance->GetJ()(2,1));
|
|
|
|
socket->Append(MassBalance->GetJ()(2,2));
|
|
|
|
socket->Append(MassBalance->GetJ()(2,3));
|
|
|
|
socket->Append(MassBalance->GetJ()(3,1));
|
|
|
|
socket->Append(MassBalance->GetJ()(3,2));
|
|
|
|
socket->Append(MassBalance->GetJ()(3,3));
|
|
|
|
socket->Append(MassBalance->GetMass());
|
|
|
|
socket->Append(MassBalance->GetXYZcg()(eX));
|
|
|
|
socket->Append(MassBalance->GetXYZcg()(eY));
|
|
|
|
socket->Append(MassBalance->GetXYZcg()(eZ));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssPropagate) {
|
|
|
|
socket->Append(Propagate->Geth());
|
|
|
|
socket->Append(Propagate->GetEuler(ePhi));
|
|
|
|
socket->Append(Propagate->GetEuler(eTht));
|
|
|
|
socket->Append(Propagate->GetEuler(ePsi));
|
|
|
|
socket->Append(Auxiliary->Getalpha(inDegrees));
|
|
|
|
socket->Append(Auxiliary->Getbeta(inDegrees));
|
|
|
|
socket->Append(Propagate->GetLocation().GetLatitudeDeg());
|
|
|
|
socket->Append(Propagate->GetLocation().GetLongitudeDeg());
|
|
|
|
}
|
|
|
|
if (SubSystems & ssCoefficients) {
|
|
|
|
scratch = Aerodynamics->GetCoefficientValues(",");
|
|
|
|
if (scratch.length() != 0) socket->Append(scratch);
|
|
|
|
}
|
|
|
|
if (SubSystems & ssFCS) {
|
|
|
|
scratch = FCS->GetComponentValues(",");
|
|
|
|
if (scratch.length() != 0) socket->Append(scratch);
|
|
|
|
}
|
|
|
|
if (SubSystems & ssGroundReactions) {
|
|
|
|
socket->Append(GroundReactions->GetGroundReactionValues(","));
|
|
|
|
}
|
|
|
|
if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
|
|
|
|
socket->Append(Propulsion->GetPropulsionValues(","));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i=0;i<OutputProperties.size();i++) {
|
|
|
|
socket->Append(OutputProperties[i]->getDoubleValue());
|
|
|
|
}
|
|
|
|
|
2004-03-15 09:24:57 +00:00
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGOutput::SocketStatusOutput(string out_str)
|
|
|
|
{
|
|
|
|
string asciiData;
|
|
|
|
|
|
|
|
if (socket == NULL) return;
|
|
|
|
|
|
|
|
socket->Clear();
|
|
|
|
asciiData = string("<STATUS>") + out_str;
|
|
|
|
socket->Append(asciiData.c_str());
|
|
|
|
socket->Send();
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
bool FGOutput::Load(Element* element)
|
2004-03-15 09:24:57 +00:00
|
|
|
{
|
2006-01-12 15:04:22 +00:00
|
|
|
string type="", parameter="";
|
2004-03-15 09:24:57 +00:00
|
|
|
string name="", fname="";
|
|
|
|
int OutRate = 0;
|
|
|
|
string property;
|
2004-06-14 11:40:45 +00:00
|
|
|
unsigned int port;
|
2006-01-12 15:04:22 +00:00
|
|
|
FGXMLParse output_file_parser;
|
|
|
|
Element *document, *property_element;
|
|
|
|
ifstream* output_file = new ifstream();
|
2004-03-15 09:24:57 +00:00
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
string separator = "/";
|
|
|
|
# ifdef macintosh
|
|
|
|
separator = ";";
|
2004-03-15 09:24:57 +00:00
|
|
|
# endif
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
|
|
|
|
fname = DirectivesFile; // one found in the config file.
|
|
|
|
} else {
|
|
|
|
fname = element->GetAttributeValue("file");
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
if (!fname.empty()) {
|
|
|
|
int len = fname.size();
|
|
|
|
if (fname.find(".xml") != string::npos) {
|
|
|
|
output_file_name = fname; // Use supplied name if last four letters are ".xml"
|
|
|
|
} else {
|
|
|
|
output_file_name = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
output_file->open(output_file_name.c_str());
|
2007-01-15 12:48:54 +00:00
|
|
|
if (output_file->is_open()) {
|
|
|
|
readXML(*output_file, output_file_parser);
|
|
|
|
delete output_file;
|
|
|
|
} else {
|
|
|
|
delete output_file;
|
|
|
|
cerr << "Could not open directives file: " << output_file_name << endl;
|
|
|
|
return false;
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
document = output_file_parser.GetDocument();
|
2004-03-15 09:24:57 +00:00
|
|
|
} else {
|
2006-01-12 15:04:22 +00:00
|
|
|
document = element;
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
name = document->GetAttributeValue("name");
|
|
|
|
type = document->GetAttributeValue("type");
|
|
|
|
SetType(type);
|
|
|
|
if (!document->GetAttributeValue("port").empty() && type == string("SOCKET")) {
|
|
|
|
port = atoi(document->GetAttributeValue("port").c_str());
|
|
|
|
socket = new FGfdmSocket(name, port);
|
|
|
|
} else {
|
|
|
|
Filename = name;
|
|
|
|
}
|
|
|
|
if (!document->GetAttributeValue("rate").empty()) {
|
|
|
|
OutRate = (int)document->GetAttributeValueAsNumber("rate");
|
|
|
|
} else {
|
|
|
|
OutRate = 1;
|
|
|
|
}
|
2004-03-15 09:24:57 +00:00
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
if (document->FindElementValue("simulation") == string("ON"))
|
|
|
|
SubSystems += ssSimulation;
|
|
|
|
if (document->FindElementValue("aerosurfaces") == string("ON"))
|
|
|
|
SubSystems += ssAerosurfaces;
|
|
|
|
if (document->FindElementValue("rates") == string("ON"))
|
|
|
|
SubSystems += ssRates;
|
|
|
|
if (document->FindElementValue("velocities") == string("ON"))
|
|
|
|
SubSystems += ssVelocities;
|
|
|
|
if (document->FindElementValue("forces") == string("ON"))
|
|
|
|
SubSystems += ssForces;
|
|
|
|
if (document->FindElementValue("moments") == string("ON"))
|
|
|
|
SubSystems += ssMoments;
|
|
|
|
if (document->FindElementValue("atmosphere") == string("ON"))
|
|
|
|
SubSystems += ssAtmosphere;
|
|
|
|
if (document->FindElementValue("massprops") == string("ON"))
|
|
|
|
SubSystems += ssMassProps;
|
|
|
|
if (document->FindElementValue("position") == string("ON"))
|
|
|
|
SubSystems += ssPropagate;
|
|
|
|
if (document->FindElementValue("coefficients") == string("ON"))
|
|
|
|
SubSystems += ssCoefficients;
|
|
|
|
if (document->FindElementValue("ground_reactions") == string("ON"))
|
|
|
|
SubSystems += ssGroundReactions;
|
|
|
|
if (document->FindElementValue("fcs") == string("ON"))
|
|
|
|
SubSystems += ssFCS;
|
|
|
|
if (document->FindElementValue("propulsion") == string("ON"))
|
|
|
|
SubSystems += ssPropulsion;
|
|
|
|
property_element = document->FindElement("property");
|
|
|
|
while (property_element) {
|
|
|
|
string property = property_element->GetDataLine();
|
|
|
|
OutputProperties.push_back(PropertyManager->GetNode(property));
|
|
|
|
property_element = document->FindNextElement("property");
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate);
|
2004-03-15 09:24:57 +00:00
|
|
|
rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
|
|
|
|
|
|
|
|
Debug(2);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// The bitmasked value choices are as follows:
|
|
|
|
// unset: In this case (the default) JSBSim would only print
|
|
|
|
// out the normally expected messages, essentially echoing
|
|
|
|
// the config files as they are read. If the environment
|
|
|
|
// variable is not set, debug_lvl is set to 1 internally
|
|
|
|
// 0: This requests JSBSim not to output any messages
|
|
|
|
// whatsoever.
|
|
|
|
// 1: This value explicity requests the normal JSBSim
|
|
|
|
// startup messages
|
|
|
|
// 2: This value asks for a message to be printed out when
|
|
|
|
// a class is instantiated
|
|
|
|
// 4: When this value is set, a message is displayed when a
|
|
|
|
// FGModel object executes its Run() method
|
|
|
|
// 8: When this value is set, various runtime state variables
|
|
|
|
// are printed out periodically
|
|
|
|
// 16: When set various parameters are sanity checked and
|
|
|
|
// a message is printed out when they go out of bounds
|
|
|
|
|
|
|
|
void FGOutput::Debug(int from)
|
|
|
|
{
|
|
|
|
string scratch="";
|
|
|
|
|
|
|
|
if (debug_lvl <= 0) return;
|
|
|
|
|
|
|
|
if (debug_lvl & 1) { // Standard console startup message output
|
|
|
|
if (from == 0) { // Constructor
|
|
|
|
|
|
|
|
}
|
|
|
|
if (from == 2) {
|
2006-01-12 15:04:22 +00:00
|
|
|
if (output_file_name.empty())
|
2004-03-15 09:24:57 +00:00
|
|
|
cout << " " << "Output parameters read inline" << endl;
|
|
|
|
else
|
2006-01-12 15:04:22 +00:00
|
|
|
cout << " Output parameters read from file: " << output_file_name << endl;
|
2004-03-15 09:24:57 +00:00
|
|
|
|
|
|
|
if (Filename == "cout" || Filename == "COUT") {
|
|
|
|
scratch = " Log output goes to screen console";
|
|
|
|
} else if (!Filename.empty()) {
|
|
|
|
scratch = " Log output goes to file: " + Filename;
|
|
|
|
}
|
|
|
|
switch (Type) {
|
|
|
|
case otCSV:
|
2007-01-15 12:48:54 +00:00
|
|
|
cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl;
|
2004-03-15 09:24:57 +00:00
|
|
|
break;
|
|
|
|
case otNone:
|
|
|
|
cout << " No log output" << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubSystems & ssSimulation) cout << " Simulation parameters logged" << endl;
|
|
|
|
if (SubSystems & ssAerosurfaces) cout << " Aerosurface parameters logged" << endl;
|
|
|
|
if (SubSystems & ssRates) cout << " Rate parameters logged" << endl;
|
|
|
|
if (SubSystems & ssVelocities) cout << " Velocity parameters logged" << endl;
|
|
|
|
if (SubSystems & ssForces) cout << " Force parameters logged" << endl;
|
|
|
|
if (SubSystems & ssMoments) cout << " Moments parameters logged" << endl;
|
|
|
|
if (SubSystems & ssAtmosphere) cout << " Atmosphere parameters logged" << endl;
|
|
|
|
if (SubSystems & ssMassProps) cout << " Mass parameters logged" << endl;
|
|
|
|
if (SubSystems & ssCoefficients) cout << " Coefficient parameters logged" << endl;
|
2004-06-14 11:40:45 +00:00
|
|
|
if (SubSystems & ssPropagate) cout << " Propagate parameters logged" << endl;
|
2004-03-15 09:24:57 +00:00
|
|
|
if (SubSystems & ssGroundReactions) cout << " Ground parameters logged" << endl;
|
|
|
|
if (SubSystems & ssFCS) cout << " FCS parameters logged" << endl;
|
|
|
|
if (SubSystems & ssPropulsion) cout << " Propulsion parameters logged" << endl;
|
2004-06-14 11:40:45 +00:00
|
|
|
if (OutputProperties.size() > 0) cout << " Properties logged:" << endl;
|
|
|
|
for (unsigned int i=0;i<OutputProperties.size();i++) {
|
|
|
|
cout << " - " << OutputProperties[i]->GetName() << endl;
|
|
|
|
}
|
2004-03-15 09:24:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
|
|
|
if (from == 0) cout << "Instantiated: FGOutput" << endl;
|
|
|
|
if (from == 1) cout << "Destroyed: FGOutput" << endl;
|
|
|
|
}
|
|
|
|
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
|
|
|
|
}
|
|
|
|
if (debug_lvl & 8 ) { // Runtime state variables
|
|
|
|
}
|
|
|
|
if (debug_lvl & 16) { // Sanity checking
|
|
|
|
}
|
|
|
|
if (debug_lvl & 64) {
|
|
|
|
if (from == 0) { // Constructor
|
|
|
|
cout << IdSrc << endl;
|
|
|
|
cout << IdHdr << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|