INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <sstream>
+#include <iomanip>
+#include <cstring>
+#include <cstdlib>
+
#include "FGOutput.h"
#include "FGFDMExec.h"
#include "FGAtmosphere.h"
+#include "FGAccelerations.h"
+#include "atmosphere/FGWinds.h"
#include "FGFCS.h"
#include "FGAerodynamics.h"
#include "FGGroundReactions.h"
#include "models/propulsion/FGEngine.h"
#include "models/propulsion/FGTank.h"
#include "models/propulsion/FGPiston.h"
-#include <sstream>
-#include <iomanip>
-#include <cstring>
-#include <cstdlib>
#if defined(WIN32) && !defined(__CYGWIN__)
# include <windows.h>
namespace JSBSim {
-static const char *IdSrc = "$Id: FGOutput.cpp,v 1.50 2010/11/18 12:38:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGOutput.cpp,v 1.67 2012/04/27 12:14:56 jberndt Exp $";
static const char *IdHdr = ID_OUTPUT;
// (stolen from FGFS native_fdm.cxx)
bool FGOutput::InitModel(void)
{
- if (!FGModel::InitModel()) return false;
-
if (Filename.size() > 0 && StartNewFile) {
ostringstream buf;
string::size_type dot = BaseFilename.find_last_of('.');
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGOutput::Run(void)
+bool FGOutput::Run(bool Holding)
{
- if (FGModel::Run()) return true;
+ if (FGModel::Run(Holding)) return true;
- if (enabled && !FDMExec->IntegrationSuspended()&& !FDMExec->Holding()) {
+ if (enabled && !FDMExec->IntegrationSuspended() && !Holding) {
RunPreFunctions();
- if (Type == otSocket) {
- SocketOutput();
- } else if (Type == otFlightGear) {
- FlightGearSocketOutput();
- } else if (Type == otCSV || Type == otTab) {
- DelimitedOutput(Filename);
- } else if (Type == otTerminal) {
- // Not done yet
- } else if (Type == otNone) {
- // Do nothing
- } else {
- // Not a valid type of output
- }
+ Print();
RunPostFunctions();
}
return false;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGOutput::Print(void)
+{
+ if (Type == otSocket) {
+ SocketOutput();
+ } else if (Type == otFlightGear) {
+ FlightGearSocketOutput();
+ } else if (Type == otCSV || Type == otTab) {
+ DelimitedOutput(Filename);
+ } else if (Type == otTerminal) {
+ // Not done yet
+ } else if (Type == otNone) {
+ // Do nothing
+ } else {
+ // Not a valid type of output
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
void FGOutput::SetType(const string& type)
{
if (type == "CSV") {
Type = otCSV;
- delimeter = ", ";
+ delimeter = ",";
} else if (type == "TABULAR") {
Type = otTab;
delimeter = "\t";
const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
const FGAircraft* Aircraft = FDMExec->GetAircraft();
const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere();
+ const FGWinds* Winds = FDMExec->GetWinds();
const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
const FGPropagate* Propagate = FDMExec->GetPropagate();
+ const FGAccelerations* Accelerations = FDMExec->GetAccelerations();
const FGFCS* FCS = FDMExec->GetFCS();
- const FGInertial* Inertial = FDMExec->GetInertial();
const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
const FGExternalReactions* ExternalReactions = FDMExec->GetExternalReactions();
const FGBuoyantForces* BuoyantForces = FDMExec->GetBuoyantForces();
outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
outstream << "V_{X_{inertial}} (ft/s)" + delimeter + "V_{Y_{inertial}} (ft/s)" + delimeter + "V_{Z_{inertial}} (ft/s)" + delimeter;
+ outstream << "V_{X_{ecef}} (ft/s)" + delimeter + "V_{Y_{ecef}} (ft/s)" + delimeter + "V_{Z_{ecef}} (ft/s)" + delimeter;
outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
}
if (SubSystems & ssForces) {
}
if (SubSystems & ssMoments) {
outstream << delimeter;
- outstream << "L_{Aero} (ft-lbs)" + delimeter + "M_{Aero} ( ft-lbs)" + delimeter + "N_{Aero} (ft-lbs)" + delimeter;
+ outstream << "L_{Aero} (ft-lbs)" + delimeter + "M_{Aero} (ft-lbs)" + delimeter + "N_{Aero} (ft-lbs)" + delimeter;
outstream << "L_{Prop} (ft-lbs)" + delimeter + "M_{Prop} (ft-lbs)" + delimeter + "N_{Prop} (ft-lbs)" + delimeter;
outstream << "L_{Gear} (ft-lbs)" + delimeter + "M_{Gear} (ft-lbs)" + delimeter + "N_{Gear} (ft-lbs)" + delimeter;
outstream << "L_{ext} (ft-lbs)" + delimeter + "M_{ext} (ft-lbs)" + delimeter + "N_{ext} (ft-lbs)" + delimeter;
outstream << "Distance AGL (ft)" + delimeter;
outstream << "Terrain Elevation (ft)";
}
- if (SubSystems & ssCoefficients) {
- scratch = Aerodynamics->GetCoefficientStrings(delimeter);
+ if (SubSystems & ssAeroFunctions) {
+ scratch = Aerodynamics->GetAeroFunctionStrings(delimeter);
if (scratch.length() != 0) outstream << delimeter << scratch;
}
if (SubSystems & ssFCS) {
if (SubSystems & ssRates) {
outstream << delimeter;
outstream << (radtodeg*Propagate->GetPQR()).Dump(delimeter) << delimeter;
- outstream << (radtodeg*Propagate->GetPQRdot()).Dump(delimeter) << delimeter;
+ outstream << (radtodeg*Accelerations->GetPQRdot()).Dump(delimeter) << delimeter;
outstream << (radtodeg*Propagate->GetPQRi()).Dump(delimeter);
}
if (SubSystems & ssVelocities) {
outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter;
outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter;
outstream << Propagate->GetInertialVelocity().Dump(delimeter) << delimeter;
+ outstream << Propagate->GetECEFVelocity().Dump(delimeter) << delimeter;
outstream << Propagate->GetVel().Dump(delimeter);
outstream.precision(10);
}
outstream << Atmosphere->GetTemperature() << delimeter;
outstream << Atmosphere->GetPressureSL() << delimeter;
outstream << Atmosphere->GetPressure() << delimeter;
- outstream << Atmosphere->GetTurbMagnitude() << delimeter;
- outstream << Atmosphere->GetTurbDirection().Dump(delimeter) << delimeter;
- outstream << Atmosphere->GetTotalWindNED().Dump(delimeter);
+ outstream << Winds->GetTurbMagnitude() << delimeter;
+ outstream << Winds->GetTurbDirection().Dump(delimeter) << delimeter;
+ outstream << Winds->GetTotalWindNED().Dump(delimeter);
}
if (SubSystems & ssMassProps) {
outstream << delimeter;
outstream << ((FGColumnVector3)Propagate->GetInertialPosition()).Dump(delimeter) << delimeter;
outstream << ((FGColumnVector3)Propagate->GetLocation()).Dump(delimeter) << delimeter;
outstream.precision(14);
- outstream << Inertial->GetEarthPositionAngleDeg() << delimeter;
+ outstream << Propagate->GetEarthPositionAngleDeg() << delimeter;
outstream << Propagate->GetDistanceAGL() << delimeter;
outstream << Propagate->GetTerrainElevation();
outstream.precision(10);
}
- if (SubSystems & ssCoefficients) {
- scratch = Aerodynamics->GetCoefficientValues(delimeter);
+ if (SubSystems & ssAeroFunctions) {
+ scratch = Aerodynamics->GetAeroFunctionValues(delimeter);
if (scratch.length() != 0) outstream << delimeter << scratch;
}
if (SubSystems & ssFCS) {
void FGOutput::SocketDataFill(FGNetFDM* net)
{
- const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics();
const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
- const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
const FGPropagate* Propagate = FDMExec->GetPropagate();
const FGFCS* FCS = FDMExec->GetFCS();
const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
const FGPropagate* Propagate = FDMExec->GetPropagate();
+ const FGAccelerations* Accelerations = FDMExec->GetAccelerations();
const FGFCS* FCS = FDMExec->GetFCS();
const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere();
+ const FGWinds* Winds = FDMExec->GetWinds();
const FGAircraft* Aircraft = FDMExec->GetAircraft();
const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
socket->Append("Latitude (deg)");
socket->Append("Longitude (deg)");
}
- if (SubSystems & ssCoefficients) {
- scratch = Aerodynamics->GetCoefficientStrings(",");
+ if (SubSystems & ssAeroFunctions) {
+ scratch = Aerodynamics->GetAeroFunctionStrings(",");
if (scratch.length() != 0) socket->Append(scratch);
}
if (SubSystems & ssFCS) {
socket->Append(radtodeg*Propagate->GetPQR(eP));
socket->Append(radtodeg*Propagate->GetPQR(eQ));
socket->Append(radtodeg*Propagate->GetPQR(eR));
- socket->Append(radtodeg*Propagate->GetPQRdot(eP));
- socket->Append(radtodeg*Propagate->GetPQRdot(eQ));
- socket->Append(radtodeg*Propagate->GetPQRdot(eR));
+ socket->Append(radtodeg*Accelerations->GetPQRdot(eP));
+ socket->Append(radtodeg*Accelerations->GetPQRdot(eQ));
+ socket->Append(radtodeg*Accelerations->GetPQRdot(eR));
}
if (SubSystems & ssVelocities) {
socket->Append(Auxiliary->Getqbar());
socket->Append(Atmosphere->GetDensity());
socket->Append(Atmosphere->GetPressureSL());
socket->Append(Atmosphere->GetPressure());
- socket->Append(Atmosphere->GetTurbMagnitude());
- socket->Append(Atmosphere->GetTurbDirection().Dump(","));
- socket->Append(Atmosphere->GetTotalWindNED().Dump(","));
+ socket->Append(Winds->GetTurbMagnitude());
+ socket->Append(Winds->GetTurbDirection().Dump(","));
+ socket->Append(Winds->GetTotalWindNED().Dump(","));
}
if (SubSystems & ssMassProps) {
socket->Append(MassBalance->GetJ()(1,1));
socket->Append(Propagate->GetLocation().GetLatitudeDeg());
socket->Append(Propagate->GetLocation().GetLongitudeDeg());
}
- if (SubSystems & ssCoefficients) {
- scratch = Aerodynamics->GetCoefficientValues(",");
+ if (SubSystems & ssAeroFunctions) {
+ scratch = Aerodynamics->GetAeroFunctionValues(",");
if (scratch.length() != 0) socket->Append(scratch);
}
if (SubSystems & ssFCS) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bool FGOutput::Load(int subSystems, std::string protocol, std::string type, std::string port, std::string name, double outRate, std::vector<FGPropertyManager *> & outputProperties)
+{
+ SetType(type);
+ SetRate(outRate);
+ SubSystems = subSystems;
+ OutputProperties = outputProperties;
+
+ if (((Type == otCSV) || (Type == otTab)) && (name != "cout") && (name !="COUT"))
+ name = FDMExec->GetRootDir() + name;
+
+ if (!port.empty() && (Type == otSocket || Type == otFlightGear)) {
+ SetProtocol(protocol);
+ socket = new FGfdmSocket(name, atoi(port.c_str()), Protocol);
+ } else {
+ BaseFilename = Filename = name;
+ }
+
+ Debug(2);
+ return true;
+}
+
bool FGOutput::Load(Element* element)
{
- string parameter="";
- string name="";
- int OutRate = 0;
- unsigned int port;
+ int subSystems = 0;
Element *property_element;
-
- string separator = "/";
+ std::vector<FGPropertyManager *> outputProperties;
if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
output_file_name = DirectivesFile; // one found in the config file.
if (!document) return false;
- name = FDMExec->GetRootDir() + document->GetAttributeValue("name");
- SetType(document->GetAttributeValue("type"));
- Port = document->GetAttributeValue("port");
- if (!Port.empty() && (Type == otSocket || Type == otFlightGear)) {
- port = atoi(Port.c_str());
- SetProtocol(document->GetAttributeValue("protocol"));
- socket = new FGfdmSocket(name, port, Protocol);
- } else {
- BaseFilename = Filename = name;
- }
+ string type = document->GetAttributeValue("type");
+ string name = document->GetAttributeValue("name");
+ string port = document->GetAttributeValue("port");
+ string protocol = document->GetAttributeValue("protocol");
if (!document->GetAttributeValue("rate").empty()) {
- OutRate = (int)document->GetAttributeValueAsNumber("rate");
+ rate = document->GetAttributeValueAsNumber("rate");
} else {
- OutRate = 1;
+ rate = 1;
}
if (document->FindElementValue("simulation") == string("ON"))
- SubSystems += ssSimulation;
+ subSystems += ssSimulation;
if (document->FindElementValue("aerosurfaces") == string("ON"))
- SubSystems += ssAerosurfaces;
+ subSystems += ssAerosurfaces;
if (document->FindElementValue("rates") == string("ON"))
- SubSystems += ssRates;
+ subSystems += ssRates;
if (document->FindElementValue("velocities") == string("ON"))
- SubSystems += ssVelocities;
+ subSystems += ssVelocities;
if (document->FindElementValue("forces") == string("ON"))
- SubSystems += ssForces;
+ subSystems += ssForces;
if (document->FindElementValue("moments") == string("ON"))
- SubSystems += ssMoments;
+ subSystems += ssMoments;
if (document->FindElementValue("atmosphere") == string("ON"))
- SubSystems += ssAtmosphere;
+ subSystems += ssAtmosphere;
if (document->FindElementValue("massprops") == string("ON"))
- SubSystems += ssMassProps;
+ subSystems += ssMassProps;
if (document->FindElementValue("position") == string("ON"))
- SubSystems += ssPropagate;
- if (document->FindElementValue("coefficients") == string("ON"))
- SubSystems += ssCoefficients;
+ subSystems += ssPropagate;
+ if (document->FindElementValue("coefficients") == string("ON") || document->FindElementValue("aerodynamics") == string("ON"))
+ subSystems += ssAeroFunctions;
if (document->FindElementValue("ground_reactions") == string("ON"))
- SubSystems += ssGroundReactions;
+ subSystems += ssGroundReactions;
if (document->FindElementValue("fcs") == string("ON"))
- SubSystems += ssFCS;
+ subSystems += ssFCS;
if (document->FindElementValue("propulsion") == string("ON"))
- SubSystems += ssPropulsion;
+ subSystems += ssPropulsion;
property_element = document->FindElement("property");
while (property_element) {
string property_str = property_element->GetDataLine();
<< " not be logged. You should check your configuration file."
<< reset << endl;
} else {
- OutputProperties.push_back(node);
+ outputProperties.push_back(node);
}
property_element = document->FindNextElement("property");
}
- SetRate(OutRate);
+ return Load(subSystems, protocol, type, port, name, rate, outputProperties);
+}
- Debug(2);
- return true;
-}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGOutput::SetRate(int rtHz)
+void FGOutput::SetRate(double rtHz)
{
rtHz = rtHz>1000?1000:(rtHz<0?0:rtHz);
if (rtHz > 0) {
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;
+ if (SubSystems & ssAeroFunctions) cout << " Coefficient parameters logged" << endl;
if (SubSystems & ssPropagate) cout << " Propagate parameters logged" << endl;
if (SubSystems & ssGroundReactions) cout << " Ground parameters logged" << endl;
if (SubSystems & ssFCS) cout << " FCS parameters logged" << endl;