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.
+later.
HISTORY
--------------------------------------------------------------------------------
#include "FGPosition.h"
#include "FGAuxiliary.h"
+static const char *IdSrc = "$Header$";
+static const char *IdHdr = ID_OUTPUT;
+
/*******************************************************************************
************************************ CODE **************************************
*******************************************************************************/
Name = "FGOutput";
sFirstPass = dFirstPass = true;
socket = 0;
+ Type = otNone;
+ Filename = "JSBSim.out";
+ SubSystems = 0;
+ enabled = true;
+
#ifdef FG_WITH_JSBSIM_SOCKET
socket = new FGfdmSocket("localhost",1138);
#endif
bool FGOutput::Run(void)
{
- if (!FGModel::Run()) {
-// SocketOutput();
-// DelimitedOutput("JSBSimData.csv");
-// DelimitedOutput();
- } else {
+ if (enabled) {
+ if (!FGModel::Run()) {
+
+ if (Type == otSocket) {
+ SocketOutput();
+ } else if (Type == otCSV) {
+ if (Filename != "COUT" && Filename != "cout" && Filename.size() > 0) {
+ DelimitedOutput(Filename);
+ } else {
+ DelimitedOutput();
+ }
+ } else if (Type == otTerminal) {
+ // Not done yet
+ } else if (Type == otNone) {
+ // Do nothing
+ } else {
+ // Not a valid type of output
+ }
+
+ } else {
+ }
}
return false;
}
/******************************************************************************/
+void FGOutput::SetType(string type)
+{
+ if (type == "CSV") {
+ Type = otCSV;
+ } else if (type == "TABULAR") {
+ Type = otTab;
+ } else if (type == "SOCKET") {
+ Type = otSocket;
+ } else if (type == "TERMINAL") {
+ Type = otTerminal;
+ } else if (type != "NONE"){
+ Type = otUnknown;
+ cerr << "Unknown type of output specified in config file" << endl;
+ }
+}
+
+/******************************************************************************/
+
void FGOutput::DelimitedOutput(void)
{
if (dFirstPass) {
- cout << "Time,";
- cout << "QBar,";
- cout << "Vtotal,";
- cout << "Throttle,";
- cout << "Aileron,";
- cout << "Elevator,";
- cout << "Rudder,";
- cout << "Rho,";
- cout << "Ixx,";
- cout << "Iyy,";
- cout << "Izz,";
- cout << "Ixz,";
- cout << "Mass,";
- 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";
+ cout << "Time";
+ if (SubSystems & FGAircraft::ssSimulation) {
+ // Nothing here, yet
+ }
+ if (SubSystems & FGAircraft::ssAerosurfaces) {
+ cout << ", ";
+ cout << "Throttle, ";
+ cout << "Aileron Cmd, ";
+ cout << "Elevator Cmd, ";
+ cout << "Rudder Cmd, ";
+ cout << "Aileron Pos, ";
+ cout << "Elevator Pos, ";
+ cout << "Rudder Pos";
+ }
+ if (SubSystems & FGAircraft::ssRates) {
+ cout << ", ";
+ cout << "P, Q, R";
+ }
+ if (SubSystems & FGAircraft::ssVelocities) {
+ cout << ", ";
+ cout << "QBar, ";
+ cout << "Vtotal, ";
+ cout << "U, V, W, ";
+ cout << "Vn, Ve, Vd";
+ }
+ if (SubSystems & FGAircraft::ssForces) {
+ cout << ", ";
+ cout << "XsForce, YsForce, ZsForce, ";
+ cout << "Xforce, Yforce, Zforce";
+ }
+ if (SubSystems & FGAircraft::ssMoments) {
+ cout << ", ";
+ cout << "L, M, N";
+ }
+ if (SubSystems & FGAircraft::ssAtmosphere) {
+ cout << ", ";
+ cout << "Rho";
+ }
+ if (SubSystems & FGAircraft::ssMassProps) {
+ cout << ", ";
+ cout << "Ixx, ";
+ cout << "Iyy, ";
+ cout << "Izz, ";
+ cout << "Ixz, ";
+ cout << "Mass, ";
+ cout << "Xcg, Ycg, Zcg";
+ }
+ if (SubSystems & FGAircraft::ssPosition) {
+ cout << ", ";
+ cout << "Altitude, ";
+ cout << "Phi, Tht, Psi, ";
+ cout << "Alpha, ";
+ cout << "Latitude, ";
+ cout << "Longitude, ";
+ cout << "Distance AGL, ";
+ cout << "Runway Radius";
+ }
+ if (SubSystems & FGAircraft::ssCoefficients) {
+ cout << ", ";
+ cout << Aircraft->GetCoefficientStrings();
+ }
+ if (SubSystems & FGAircraft::ssGroundReactions) {
+ cout << ", ";
+ cout << Aircraft->GetGroundReactionStrings();
+ }
+
cout << endl;
dFirstPass = false;
}
- cout << State->Getsim_time() << ",";
- cout << Translation->Getqbar() << ",";
- cout << Translation->GetVt() << ",";
- cout << FCS->GetThrottlePos(0) << ",";
- cout << FCS->GetDaPos() << ",";
- cout << FCS->GetDePos() << ",";
- cout << FCS->GetDrPos() << ",";
- cout << Atmosphere->GetDensity() << ",";
- cout << Aircraft->GetIxx() << ",";
- cout << Aircraft->GetIyy() << ",";
- cout << Aircraft->GetIzz() << ",";
- cout << Aircraft->GetIxz() << ",";
- cout << Aircraft->GetMass() << ",";
- cout << Aircraft->GetXYZcg() << ",";
- cout << Aircraft->GetForces() << ",";
- cout << Aircraft->GetMoments() << ",";
- cout << Position->Geth() << ",";
- cout << Rotation->GetEuler() << ",";
- cout << Rotation->GetPQR() << ",";
- cout << Translation->GetUVW() << ",";
- cout << Translation->Getalpha() << ",";
- cout << Position->GetVel() << ",";
- cout << Position->GetLatitude() << ",";
- cout << Position->GetLongitude();
+ cout << State->Getsim_time();
+ if (SubSystems & FGAircraft::ssSimulation) {
+ }
+ if (SubSystems & FGAircraft::ssAerosurfaces) {
+ cout << ", ";
+ cout << FCS->GetThrottlePos(0) << ", ";
+ cout << FCS->GetDaCmd() << ", ";
+ cout << FCS->GetDeCmd() << ", ";
+ cout << FCS->GetDrCmd() << ", ";
+ cout << FCS->GetDaPos() << ", ";
+ cout << FCS->GetDePos() << ", ";
+ cout << FCS->GetDrPos();
+ }
+ if (SubSystems & FGAircraft::ssRates) {
+ cout << ", ";
+ cout << Rotation->GetPQR();
+ }
+ if (SubSystems & FGAircraft::ssVelocities) {
+ cout << ", ";
+ cout << Translation->Getqbar() << ", ";
+ cout << Translation->GetVt() << ", ";
+ cout << Translation->GetUVW() << ", ";
+ cout << Position->GetVel();
+ }
+ if (SubSystems & FGAircraft::ssForces) {
+ cout << ", ";
+ cout << Aircraft->GetvFs() << ", ";
+ cout << Aircraft->GetForces();
+ }
+ if (SubSystems & FGAircraft::ssMoments) {
+ cout << ", ";
+ cout << Aircraft->GetMoments();
+ }
+ if (SubSystems & FGAircraft::ssAtmosphere) {
+ cout << ", ";
+ cout << Atmosphere->GetDensity();
+ }
+ if (SubSystems & FGAircraft::ssMassProps) {
+ cout << ", ";
+ cout << Aircraft->GetIxx() << ", ";
+ cout << Aircraft->GetIyy() << ", ";
+ cout << Aircraft->GetIzz() << ", ";
+ cout << Aircraft->GetIxz() << ", ";
+ cout << Aircraft->GetMass() << ", ";
+ cout << Aircraft->GetXYZcg();
+ }
+ if (SubSystems & FGAircraft::ssPosition) {
+ cout << ", ";
+ cout << Position->Geth() << ", ";
+ cout << Rotation->GetEuler() << ", ";
+ cout << Translation->Getalpha() << ", ";
+ cout << Position->GetLatitude() << ", ";
+ cout << Position->GetLongitude() << ", ";
+ cout << Position->GetDistanceAGL() << ", ";
+ cout << Position->GetRunwayRadius();
+ }
+ if (SubSystems & FGAircraft::ssCoefficients) {
+ cout << ", ";
+ cout << Aircraft->GetCoefficientValues();
+ }
+ if (SubSystems & FGAircraft::ssGroundReactions) {
+ cout << ", ";
+ cout << Aircraft->GetGroundReactionValues();
+ }
cout << endl;
}
{
if (sFirstPass) {
datafile.open(fname.c_str());
- datafile << "Time,";
- datafile << "QBar,";
- datafile << "Vtotal,";
- datafile << "Throttle,";
- datafile << "Aileron,";
- datafile << "Elevator,";
- datafile << "Rudder,";
- datafile << "Rho,";
- datafile << "Ixx,";
- datafile << "Iyy,";
- datafile << "Izz,";
- datafile << "Ixz,";
- datafile << "Mass,";
- 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";
+ datafile << "Time";
+ if (SubSystems & FGAircraft::ssSimulation) {
+ // Nothing here, yet
+ }
+ if (SubSystems & FGAircraft::ssAerosurfaces) {
+ datafile << ", ";
+ datafile << "Throttle, ";
+ datafile << "Aileron Cmd, ";
+ datafile << "Elevator Cmd, ";
+ datafile << "Rudder Cmd, ";
+ datafile << "Aileron Pos, ";
+ datafile << "Elevator Pos, ";
+ datafile << "Rudder Pos";
+ }
+ if (SubSystems & FGAircraft::ssRates) {
+ datafile << ", ";
+ datafile << "P, Q, R";
+ }
+ if (SubSystems & FGAircraft::ssVelocities) {
+ datafile << ", ";
+ datafile << "QBar, ";
+ datafile << "Vtotal, ";
+ datafile << "U, V, W, ";
+ datafile << "Vn, Ve, Vd";
+ }
+ if (SubSystems & FGAircraft::ssForces) {
+ datafile << ", ";
+ datafile << "XsForce, YsForce, ZsForce, ";
+ datafile << "Xforce, Yforce, Zforce";
+ }
+ if (SubSystems & FGAircraft::ssMoments) {
+ datafile << ", ";
+ datafile << "L, M, N";
+ }
+ if (SubSystems & FGAircraft::ssAtmosphere) {
+ datafile << ", ";
+ datafile << "Rho";
+ }
+ if (SubSystems & FGAircraft::ssMassProps) {
+ datafile << ", ";
+ datafile << "Ixx, ";
+ datafile << "Iyy, ";
+ datafile << "Izz, ";
+ datafile << "Ixz, ";
+ datafile << "Mass, ";
+ datafile << "Xcg, Ycg, Zcg";
+ }
+ if (SubSystems & FGAircraft::ssPosition) {
+ datafile << ", ";
+ datafile << "Altitude, ";
+ datafile << "Phi, Tht, Psi, ";
+ datafile << "Alpha, ";
+ datafile << "Latitude, ";
+ datafile << "Longitude, ";
+ datafile << "Distance AGL, ";
+ datafile << "Runway Radius";
+ }
+ if (SubSystems & FGAircraft::ssCoefficients) {
+ datafile << ", ";
+ datafile << Aircraft->GetCoefficientStrings();
+ }
+ if (SubSystems & FGAircraft::ssGroundReactions) {
+ datafile << ", ";
+ datafile << Aircraft->GetGroundReactionStrings();
+ }
datafile << endl;
sFirstPass = false;
}
- datafile << State->Getsim_time() << ",";
- datafile << Translation->Getqbar() << ",";
- datafile << Translation->GetVt() << ",";
- datafile << FCS->GetThrottlePos(0) << ",";
- datafile << FCS->GetDaPos() << ",";
- datafile << FCS->GetDePos() << ",";
- datafile << FCS->GetDrPos() << ",";
- datafile << Atmosphere->GetDensity() << ",";
- datafile << Aircraft->GetIxx() << ",";
- datafile << Aircraft->GetIyy() << ",";
- datafile << Aircraft->GetIzz() << ",";
- datafile << Aircraft->GetIxz() << ",";
- datafile << Aircraft->GetMass() << ",";
- datafile << Aircraft->GetXYZcg() << ",";
- datafile << Aircraft->GetForces() << ",";
- datafile << Aircraft->GetMoments() << ",";
- datafile << Position->Geth() << ",";
- datafile << Rotation->GetEuler() << ",";
- datafile << Rotation->GetPQR() << ",";
- datafile << Translation->GetUVW() << ",";
- datafile << Translation->Getalpha() << ",";
- datafile << Position->GetVel() << ",";
- datafile << Position->GetLatitude() << ",";
- datafile << Position->GetLongitude();
+ datafile << State->Getsim_time();
+ if (SubSystems & FGAircraft::ssSimulation) {
+ }
+ if (SubSystems & FGAircraft::ssAerosurfaces) {
+ datafile << ", ";
+ datafile << FCS->GetThrottlePos(0) << ", ";
+ datafile << FCS->GetDaCmd() << ", ";
+ datafile << FCS->GetDeCmd() << ", ";
+ datafile << FCS->GetDrCmd() << ", ";
+ datafile << FCS->GetDaPos() << ", ";
+ datafile << FCS->GetDePos() << ", ";
+ datafile << FCS->GetDrPos();
+ }
+ if (SubSystems & FGAircraft::ssRates) {
+ datafile << ", ";
+ datafile << Rotation->GetPQR();
+ }
+ if (SubSystems & FGAircraft::ssVelocities) {
+ datafile << ", ";
+ datafile << Translation->Getqbar() << ", ";
+ datafile << Translation->GetVt() << ", ";
+ datafile << Translation->GetUVW() << ", ";
+ datafile << Position->GetVel();
+ }
+ if (SubSystems & FGAircraft::ssForces) {
+ datafile << ", ";
+ datafile << Aircraft->GetvFs() << ", ";
+ datafile << Aircraft->GetForces();
+ }
+ if (SubSystems & FGAircraft::ssMoments) {
+ datafile << ", ";
+ datafile << Aircraft->GetMoments();
+ }
+ if (SubSystems & FGAircraft::ssAtmosphere) {
+ datafile << ", ";
+ datafile << Atmosphere->GetDensity();
+ }
+ if (SubSystems & FGAircraft::ssMassProps) {
+ datafile << ", ";
+ datafile << Aircraft->GetIxx() << ", ";
+ datafile << Aircraft->GetIyy() << ", ";
+ datafile << Aircraft->GetIzz() << ", ";
+ datafile << Aircraft->GetIxz() << ", ";
+ datafile << Aircraft->GetMass() << ", ";
+ datafile << Aircraft->GetXYZcg();
+ }
+ if (SubSystems & FGAircraft::ssPosition) {
+ datafile << ", ";
+ datafile << Position->Geth() << ", ";
+ datafile << Rotation->GetEuler() << ", ";
+ datafile << Translation->Getalpha() << ", ";
+ datafile << Position->GetLatitude() << ", ";
+ datafile << Position->GetLongitude() << ", ";
+ datafile << Position->GetDistanceAGL() << ", ";
+ datafile << Position->GetRunwayRadius();
+ }
+ if (SubSystems & FGAircraft::ssCoefficients) {
+ datafile << ", ";
+ datafile << Aircraft->GetCoefficientValues();
+ }
+ if (SubSystems & FGAircraft::ssGroundReactions) {
+ datafile << ", ";
+ datafile << Aircraft->GetGroundReactionValues();
+ }
datafile << endl;
datafile.flush();
}
{
string asciiData;
/*
- if (socket <= 0) return;
+ if (socket == NULL) return;
socket->Clear();
if (sFirstPass) {
{
string asciiData;
- if (socket <= 0) return;
+ if (socket == NULL) return;
socket->Clear();
asciiData = string("<STATUS>") + out_str;