- datafile << State->Getsim_time() << ",";
- datafile << State->Geth() << ",";
- datafile << Rotation->Getphi() << ",";
- datafile << Rotation->Gettht() << ",";
- datafile << Rotation->Getpsi() << ",";
- datafile << Atmosphere->GetDensity() << ",";
- 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() << ",";
- datafile << Rotation->GetP() << ",";
- datafile << Rotation->GetQ() << ",";
- datafile << Rotation->GetR() << ",";
- datafile << Rotation->GetPdot() << ",";
- datafile << Rotation->GetQdot() << ",";
- datafile << Rotation->GetRdot() << ",";
- 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() << ",";
- datafile << Aircraft->GetN() << ",";
- datafile << FCS->GetThrottle(0) << ",";
- datafile << FCS->GetDa() << ",";
- datafile << FCS->GetDe() << ",";
- datafile << FCS->GetDr() << ",";
- datafile << Aircraft->GetIxx() << ",";
- datafile << Aircraft->GetIyy() << ",";
- datafile << Aircraft->GetIzz() << ",";
- datafile << Aircraft->GetIxz() << ",";
- datafile << Aircraft->GetMass() << ",";
- datafile << Aircraft->GetXcg() << "";
- datafile << endl;
- datafile.flush();
+ ostream outstream(buffer);
+
+ if (dFirstPass) {
+ outstream << "Time";
+ if (SubSystems & ssSimulation) {
+ // Nothing here, yet
+ }
+ if (SubSystems & ssAerosurfaces) {
+ outstream << ", ";
+ outstream << "Aileron Cmd, ";
+ outstream << "Elevator Cmd, ";
+ outstream << "Rudder Cmd, ";
+ outstream << "Flap Cmd, ";
+ outstream << "Left Aileron Pos, ";
+ outstream << "Right Aileron Pos, ";
+ outstream << "Elevator Pos, ";
+ outstream << "Rudder Pos, ";
+ outstream << "Flap Pos";
+ }
+ if (SubSystems & ssRates) {
+ outstream << ", ";
+ outstream << "P, Q, R, ";
+ outstream << "Pdot, Qdot, Rdot";
+ }
+ if (SubSystems & ssVelocities) {
+ outstream << ", ";
+ outstream << "QBar, ";
+ outstream << "Vtotal, ";
+ outstream << "UBody, VBody, WBody, ";
+ outstream << "UAero, VAero, WAero, ";
+ outstream << "Vn, Ve, Vd";
+ }
+ if (SubSystems & ssForces) {
+ outstream << ", ";
+ outstream << "Drag, Side, Lift, ";
+ outstream << "L/D, ";
+ outstream << "Xforce, Yforce, Zforce, ";
+ outstream << "xGravity, yGravity, zGravity, ";
+ outstream << "xCoriolis, yCoriolis, zCoriolis, ";
+ outstream << "xCentrifugal, yCentrifugal, zCentrifugal";
+ }
+ if (SubSystems & ssMoments) {
+ outstream << ", ";
+ outstream << "L, M, N";
+ }
+ if (SubSystems & ssAtmosphere) {
+ outstream << ", ";
+ outstream << "Rho, ";
+ outstream << "NWind, EWind, DWind";
+ }
+ if (SubSystems & ssMassProps) {
+ outstream << ", ";
+ outstream << "Ixx, ";
+ outstream << "Iyy, ";
+ outstream << "Izz, ";
+ outstream << "Ixz, ";
+ outstream << "Mass, ";
+ outstream << "Xcg, Ycg, Zcg";
+ }
+ if (SubSystems & ssPosition) {
+ outstream << ", ";
+ outstream << "Altitude, ";
+ outstream << "Phi, Tht, Psi, ";
+ outstream << "Alpha, ";
+ outstream << "Beta, ";
+ outstream << "Latitude, ";
+ outstream << "Longitude, ";
+ outstream << "Distance AGL, ";
+ outstream << "Runway Radius";
+ }
+ if (SubSystems & ssCoefficients) {
+ outstream << ", ";
+ outstream << Aerodynamics->GetCoefficientStrings();
+ }
+ if (SubSystems & ssFCS) {
+ outstream << ", ";
+ outstream << FCS->GetComponentStrings();
+ }
+ if (SubSystems & ssGroundReactions) {
+ outstream << ", ";
+ outstream << GroundReactions->GetGroundReactionStrings();
+ }
+ if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
+ outstream << ", ";
+ outstream << Propulsion->GetPropulsionStrings();
+ }
+
+ outstream << endl;
+ dFirstPass = false;
+ }
+
+ outstream << State->Getsim_time();
+ if (SubSystems & ssSimulation) {
+ }
+ if (SubSystems & ssAerosurfaces) {
+ outstream << ", ";
+ outstream << FCS->GetDaCmd() << ", ";
+ outstream << FCS->GetDeCmd() << ", ";
+ outstream << FCS->GetDrCmd() << ", ";
+ outstream << FCS->GetDfCmd() << ", ";
+ outstream << FCS->GetDaLPos() << ", ";
+ outstream << FCS->GetDaRPos() << ", ";
+ outstream << FCS->GetDePos() << ", ";
+ outstream << FCS->GetDrPos() << ", ";
+ outstream << FCS->GetDfPos();
+ }
+ if (SubSystems & ssRates) {
+ outstream << ", ";
+ outstream << Rotation->GetPQR() << ", ";
+ outstream << Rotation->GetPQRdot();
+ }
+ if (SubSystems & ssVelocities) {
+ outstream << ", ";
+ outstream << Translation->Getqbar() << ", ";
+ outstream << Translation->GetVt() << ", ";
+ outstream << Translation->GetUVW() << ", ";
+ outstream << Translation->GetAeroUVW() << ", ";
+ outstream << Position->GetVel();
+ }
+ if (SubSystems & ssForces) {
+ outstream << ", ";
+ outstream << Aerodynamics->GetvFs() << ", ";
+ outstream << Aerodynamics->GetLoD() << ", ";
+ outstream << Aircraft->GetForces() << ", ";
+ outstream << Inertial->GetGravity() << ", ";
+ outstream << Inertial->GetCoriolis() << ", ";
+ outstream << Inertial->GetCentrifugal();
+ }
+ if (SubSystems & ssMoments) {
+ outstream << ", ";
+ outstream << Aircraft->GetMoments();
+ }
+ if (SubSystems & ssAtmosphere) {
+ outstream << ", ";
+ outstream << Atmosphere->GetDensity() << ", ";
+ outstream << Atmosphere->GetWindNED();
+ }
+ if (SubSystems & ssMassProps) {
+ outstream << ", ";
+ outstream << MassBalance->GetIxx() << ", ";
+ outstream << MassBalance->GetIyy() << ", ";
+ outstream << MassBalance->GetIzz() << ", ";
+ outstream << MassBalance->GetIxz() << ", ";
+ outstream << MassBalance->GetMass() << ", ";
+ outstream << MassBalance->GetXYZcg();
+ }
+ if (SubSystems & ssPosition) {
+ outstream << ", ";
+ outstream << Position->Geth() << ", ";
+ outstream << Rotation->GetEuler() << ", ";
+ outstream << Translation->Getalpha() << ", ";
+ outstream << Translation->Getbeta() << ", ";
+ outstream << Position->GetLatitude() << ", ";
+ outstream << Position->GetLongitude() << ", ";
+ outstream << Position->GetDistanceAGL() << ", ";
+ outstream << Position->GetRunwayRadius();
+ }
+ if (SubSystems & ssCoefficients) {
+ outstream << ", ";
+ outstream << Aerodynamics->GetCoefficientValues();
+ }
+ if (SubSystems & ssFCS) {
+ outstream << ", ";
+ outstream << FCS->GetComponentValues();
+ }
+ if (SubSystems & ssGroundReactions) {
+ outstream << ", ";
+ outstream << GroundReactions->GetGroundReactionValues();
+ }
+ if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
+ outstream << ", ";
+ outstream << Propulsion->GetPropulsionValues();
+ }
+
+ outstream << endl;
+ outstream.flush();