]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGOutput.cpp
Upgrade to JSBSim 1.0-prerelease
[flightgear.git] / src / FDM / JSBSim / models / FGOutput.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGOutput.cpp
4  Author:       Jon Berndt
5  Date started: 12/02/98
6  Purpose:      Manage output of sim parameters to file or stdout
7  Called by:    FGSimExec
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU Lesser General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
19  details.
20
21  You should have received a copy of the GNU Lesser General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU Lesser General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This is the place where you create output routines to dump data for perusal
31 later.
32
33 HISTORY
34 --------------------------------------------------------------------------------
35 12/02/98   JSB   Created
36 11/09/07   HDW   Added FlightGear Socket Interface
37
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include "FGOutput.h"
43 #include "FGState.h"
44 #include "FGFDMExec.h"
45 #include "FGAtmosphere.h"
46 #include "FGFCS.h"
47 #include "FGAerodynamics.h"
48 #include "FGGroundReactions.h"
49 #include "FGExternalReactions.h"
50 #include "FGBuoyantForces.h"
51 #include "FGAircraft.h"
52 #include "FGMassBalance.h"
53 #include "FGPropagate.h"
54 #include "FGAuxiliary.h"
55 #include "FGInertial.h"
56 #include "FGPropulsion.h"   //access to FGEngine, FGTank
57 #include "models/propulsion/FGPiston.h"
58 #include <fstream>
59 #include <iomanip>
60 #include <cstring>
61
62 #include "input_output/net_fdm.hxx"
63
64 #if defined(WIN32) && !defined(__CYGWIN__)
65 #  include <windows.h>
66 #else
67 #  include <netinet/in.h>       // htonl() ntohl()
68 #endif
69
70 static const int endianTest = 1;
71 #define isLittleEndian (*((char *) &endianTest ) != 0)
72
73 namespace JSBSim {
74
75 static const char *IdSrc = "$Id$";
76 static const char *IdHdr = ID_OUTPUT;
77
78 // (stolen from FGFS native_fdm.cxx)
79 // The function htond is defined this way due to the way some
80 // processors and OSes treat floating point values.  Some will raise
81 // an exception whenever a "bad" floating point value is loaded into a
82 // floating point register.  Solaris is notorious for this, but then
83 // so is LynxOS on the PowerPC.  By translating the data in place,
84 // there is no need to load a FP register with the "corruped" floating
85 // point value.  By doing the BIG_ENDIAN test, I can optimize the
86 // routine for big-endian processors so it can be as efficient as
87 // possible
88 static void htond (double &x)
89 {
90     if ( isLittleEndian ) {
91         int    *Double_Overlay;
92         int     Holding_Buffer;
93
94         Double_Overlay = (int *) &x;
95         Holding_Buffer = Double_Overlay [0];
96
97         Double_Overlay [0] = htonl (Double_Overlay [1]);
98         Double_Overlay [1] = htonl (Holding_Buffer);
99     } else {
100         return;
101     }
102 }
103
104 // Float version
105 static void htonf (float &x)
106 {
107     if ( isLittleEndian ) {
108         int    *Float_Overlay;
109         int     Holding_Buffer;
110
111         Float_Overlay = (int *) &x;
112         Holding_Buffer = Float_Overlay [0];
113
114         Float_Overlay [0] = htonl (Holding_Buffer);
115     } else {
116         return;
117     }
118 }
119
120
121 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 CLASS IMPLEMENTATION
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
124
125 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
126 {
127   Name = "FGOutput";
128   sFirstPass = dFirstPass = true;
129   socket = 0;
130   flightGearSocket = 0;
131   runID_postfix = 0;
132   Type = otNone;
133   SubSystems = 0;
134   enabled = true;
135   StartNewFile = false;
136   delimeter = ", ";
137   BaseFilename = Filename = "";
138   DirectivesFile = "";
139   output_file_name = "";
140
141   memset(&fgSockBuf, 0x00, sizeof(fgSockBuf));
142
143   Debug(0);
144 }
145
146 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148 FGOutput::~FGOutput()
149 {
150   delete socket;
151   delete flightGearSocket;
152   OutputProperties.clear();
153   Debug(1);
154 }
155
156 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
158 bool FGOutput::InitModel(void)
159 {
160   char fname[1000] = "";
161
162   if (!FGModel::InitModel()) return false;
163
164   if (Filename.size() > 0 && StartNewFile) {
165     int idx = BaseFilename.find_last_of(".");
166     int len = BaseFilename.length();
167     string extension = "";
168     if (idx != string::npos) {
169       extension = BaseFilename.substr(idx, len-idx);
170       len -= extension.length();
171     }
172     sprintf(fname, "%s_%d%s", BaseFilename.substr(0,len).c_str(), runID_postfix++, extension.c_str());
173     Filename = string(fname);
174     datafile.close();
175     StartNewFile = false;
176     dFirstPass = true;
177   }
178
179   return true;
180 }
181
182 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183
184 bool FGOutput::Run(void)
185 {
186   if (FGModel::Run()) return true;
187
188   if (enabled && !State->IntegrationSuspended()&& !FDMExec->Holding()) {
189     if (Type == otSocket) {
190       SocketOutput();
191     } else if (Type == otFlightGear) {
192       FlightGearSocketOutput();
193     } else if (Type == otCSV || Type == otTab) {
194       DelimitedOutput(Filename);
195     } else if (Type == otTerminal) {
196       // Not done yet
197     } else if (Type == otNone) {
198       // Do nothing
199     } else {
200       // Not a valid type of output
201     }
202   }
203   return false;
204 }
205
206 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207
208 void FGOutput::SetType(string type)
209 {
210   if (type == "CSV") {
211     Type = otCSV;
212     delimeter = ", ";
213   } else if (type == "TABULAR") {
214     Type = otTab;
215     delimeter = "\t";
216   } else if (type == "SOCKET") {
217     Type = otSocket;
218   } else if (type == "FLIGHTGEAR") {
219     Type = otFlightGear;
220   } else if (type == "TERMINAL") {
221     Type = otTerminal;
222   } else if (type != string("NONE")) {
223     Type = otUnknown;
224     cerr << "Unknown type of output specified in config file" << endl;
225   }
226 }
227
228 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229
230 void FGOutput::DelimitedOutput(string fname)
231 {
232   streambuf* buffer;
233   string scratch = "";
234
235   if (fname == "COUT" || fname == "cout") {
236     buffer = cout.rdbuf();
237   } else {
238     if (!datafile.is_open()) datafile.open(fname.c_str());
239     buffer = datafile.rdbuf();
240   }
241
242   ostream outstream(buffer);
243
244   outstream.precision(10);
245
246   if (dFirstPass) {
247     outstream << "Time";
248     if (SubSystems & ssSimulation) {
249       // Nothing here, yet
250     }
251     if (SubSystems & ssAerosurfaces) {
252       outstream << delimeter;
253       outstream << "Aileron Command (norm)" + delimeter;
254       outstream << "Elevator Command (norm)" + delimeter;
255       outstream << "Rudder Command (norm)" + delimeter;
256       outstream << "Flap Command (norm)" + delimeter;
257       outstream << "Left Aileron Position (deg)" + delimeter;
258       outstream << "Right Aileron Position (deg)" + delimeter;
259       outstream << "Elevator Position (deg)" + delimeter;
260       outstream << "Rudder Position (deg)" + delimeter;
261       outstream << "Flap Position (deg)";
262     }
263     if (SubSystems & ssRates) {
264       outstream << delimeter;
265       outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter;
266       outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)";
267     }
268     if (SubSystems & ssVelocities) {
269       outstream << delimeter;
270       outstream << "q bar (psf)" + delimeter;
271       outstream << "Reynolds Number" + delimeter;
272       outstream << "V_{Total} (ft/s)" + delimeter;
273       outstream << "V_{Inertial} (ft/s)" + delimeter;
274       outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
275       outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
276       outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
277     }
278     if (SubSystems & ssForces) {
279       outstream << delimeter;
280       outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter;
281       outstream << "L/D" + delimeter;
282       outstream << "F_{Aero x} (lbs)" + delimeter + "F_{Aero y} (lbs)" + delimeter + "F_{Aero z} (lbs)" + delimeter;
283       outstream << "F_{Prop x} (lbs)" + delimeter + "F_{Prop y} (lbs)" + delimeter + "F_{Prop z} (lbs)" + delimeter;
284       outstream << "F_{Gear x} (lbs)" + delimeter + "F_{Gear y} (lbs)" + delimeter + "F_{Gear z} (lbs)" + delimeter;
285       outstream << "F_{Ext x} (lbs)" + delimeter + "F_{Ext y} (lbs)" + delimeter + "F_{Ext z} (lbs)" + delimeter;
286       outstream << "F_{Buoyant x} (lbs)" + delimeter + "F_{Buoyant y} (lbs)" + delimeter + "F_{Buoyant z} (lbs)" + delimeter;
287       outstream << "F_{Total x} (lbs)" + delimeter + "F_{Total y} (lbs)" + delimeter + "F_{Total z} (lbs)";
288     }
289     if (SubSystems & ssMoments) {
290       outstream << delimeter;
291       outstream << "L_{Aero} (ft-lbs)" + delimeter + "M_{Aero} ( ft-lbs)" + delimeter + "N_{Aero} (ft-lbs)" + delimeter;
292       outstream << "L_{Prop} (ft-lbs)" + delimeter + "M_{Prop} (ft-lbs)" + delimeter + "N_{Prop} (ft-lbs)" + delimeter;
293       outstream << "L_{Gear} (ft-lbs)" + delimeter + "M_{Gear} (ft-lbs)" + delimeter + "N_{Gear} (ft-lbs)" + delimeter;
294       outstream << "L_{ext} (ft-lbs)" + delimeter + "M_{ext} (ft-lbs)" + delimeter + "N_{ext} (ft-lbs)" + delimeter;
295       outstream << "L_{Buoyant} (ft-lbs)" + delimeter + "M_{Buoyant} (ft-lbs)" + delimeter + "N_{Buoyant} (ft-lbs)" + delimeter;
296       outstream << "L_{Total} (ft-lbs)" + delimeter + "M_{Total} (ft-lbs)" + delimeter + "N_{Total} (ft-lbs)";
297     }
298     if (SubSystems & ssAtmosphere) {
299       outstream << delimeter;
300       outstream << "Rho (slugs/ft^3)" + delimeter;
301       outstream << "Absolute Viscosity" + delimeter;
302       outstream << "Kinematic Viscosity" + delimeter;
303       outstream << "Temperature (R)" + delimeter;
304       outstream << "P_{SL} (psf)" + delimeter;
305       outstream << "P_{Ambient} (psf)" + delimeter;
306       outstream << "Turbulence Magnitude (ft/sec)" + delimeter;
307       outstream << "Turbulence X Direction (rad)" + delimeter + "Turbulence Y Direction (rad)" + delimeter + "Turbulence Z Direction (rad)" + delimeter;
308       outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)";
309     }
310     if (SubSystems & ssMassProps) {
311       outstream << delimeter;
312       outstream << "I_{xx}" + delimeter;
313       outstream << "I_{xy}" + delimeter;
314       outstream << "I_{xz}" + delimeter;
315       outstream << "I_{yx}" + delimeter;
316       outstream << "I_{yy}" + delimeter;
317       outstream << "I_{yz}" + delimeter;
318       outstream << "I_{zx}" + delimeter;
319       outstream << "I_{zy}" + delimeter;
320       outstream << "I_{zz}" + delimeter;
321       outstream << "Mass" + delimeter;
322       outstream << "X_{cg}" + delimeter + "Y_{cg}" + delimeter + "Z_{cg}";
323     }
324     if (SubSystems & ssPropagate) {
325       outstream << delimeter;
326       outstream << "Altitude ASL (ft)" + delimeter;
327       outstream << "Altitude AGL (ft)" + delimeter;
328       outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter;
329       outstream << "Alpha (deg)" + delimeter;
330       outstream << "Beta (deg)" + delimeter;
331       outstream << "Latitude (deg)" + delimeter;
332       outstream << "Longitude (deg)" + delimeter;
333       outstream << "ECEF X (ft)" + delimeter + "ECEF Y (ft)" + delimeter + "ECEF Z (ft)" + delimeter;
334       outstream << "EPA (deg)" + delimeter;
335       outstream << "Distance AGL (ft)" + delimeter;
336       outstream << "Terrain Radius (ft)";
337     }
338     if (SubSystems & ssCoefficients) {
339       scratch = Aerodynamics->GetCoefficientStrings(delimeter);
340       if (scratch.length() != 0) outstream << delimeter << scratch;
341     }
342     if (SubSystems & ssFCS) {
343       scratch = FCS->GetComponentStrings(delimeter);
344       if (scratch.length() != 0) outstream << delimeter << scratch;
345     }
346     if (SubSystems & ssGroundReactions) {
347       outstream << delimeter;
348       outstream << GroundReactions->GetGroundReactionStrings(delimeter);
349     }
350     if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
351       outstream << delimeter;
352       outstream << Propulsion->GetPropulsionStrings(delimeter);
353     }
354     if (OutputProperties.size() > 0) {
355       for (unsigned int i=0;i<OutputProperties.size();i++) {
356         outstream << delimeter << OutputProperties[i]->GetPrintableName();
357       }
358     }
359
360     outstream << endl;
361     dFirstPass = false;
362   }
363
364   outstream << State->Getsim_time();
365   if (SubSystems & ssSimulation) {
366   }
367   if (SubSystems & ssAerosurfaces) {
368     outstream << delimeter;
369     outstream << FCS->GetDaCmd() << delimeter;
370     outstream << FCS->GetDeCmd() << delimeter;
371     outstream << FCS->GetDrCmd() << delimeter;
372     outstream << FCS->GetDfCmd() << delimeter;
373     outstream << FCS->GetDaLPos(ofDeg) << delimeter;
374     outstream << FCS->GetDaRPos(ofDeg) << delimeter;
375     outstream << FCS->GetDePos(ofDeg) << delimeter;
376     outstream << FCS->GetDrPos(ofDeg) << delimeter;
377     outstream << FCS->GetDfPos(ofDeg);
378   }
379   if (SubSystems & ssRates) {
380     outstream << delimeter;
381     outstream << (radtodeg*Propagate->GetPQR()).Dump(delimeter) << delimeter;
382     outstream << (radtodeg*Propagate->GetPQRdot()).Dump(delimeter);
383   }
384   if (SubSystems & ssVelocities) {
385     outstream << delimeter;
386     outstream << Auxiliary->Getqbar() << delimeter;
387     outstream << Auxiliary->GetReynoldsNumber() << delimeter;
388     outstream << setprecision(12) << Auxiliary->GetVt() << delimeter;
389     outstream << Propagate->GetInertialVelocityMagnitude() << delimeter;
390     outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter;
391     outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter;
392     outstream << Propagate->GetVel().Dump(delimeter);
393     outstream.precision(10);
394   }
395   if (SubSystems & ssForces) {
396     outstream << delimeter;
397     outstream << Aerodynamics->GetvFw() << delimeter;
398     outstream << Aerodynamics->GetLoD() << delimeter;
399     outstream << Aerodynamics->GetForces() << delimeter;
400     outstream << Propulsion->GetForces() << delimeter;
401     outstream << GroundReactions->GetForces() << delimeter;
402     outstream << ExternalReactions->GetForces() << delimeter;
403     outstream << BuoyantForces->GetForces() << delimeter;
404     outstream << Aircraft->GetForces().Dump(delimeter);
405   }
406   if (SubSystems & ssMoments) {
407     outstream << delimeter;
408     outstream << Aerodynamics->GetMoments() << delimeter;
409     outstream << Propulsion->GetMoments() << delimeter;
410     outstream << GroundReactions->GetMoments() << delimeter;
411     outstream << ExternalReactions->GetMoments() << delimeter;
412     outstream << BuoyantForces->GetMoments() << delimeter;
413     outstream << Aircraft->GetMoments().Dump(delimeter);
414   }
415   if (SubSystems & ssAtmosphere) {
416     outstream << delimeter;
417     outstream << Atmosphere->GetDensity() << delimeter;
418     outstream << Atmosphere->GetAbsoluteViscosity() << delimeter;
419     outstream << Atmosphere->GetKinematicViscosity() << delimeter;
420     outstream << Atmosphere->GetTemperature() << delimeter;
421     outstream << Atmosphere->GetPressureSL() << delimeter;
422     outstream << Atmosphere->GetPressure() << delimeter;
423     outstream << Atmosphere->GetTurbMagnitude() << delimeter;
424     outstream << Atmosphere->GetTurbDirection().Dump(delimeter) << delimeter;
425     outstream << Atmosphere->GetTotalWindNED().Dump(delimeter);
426   }
427   if (SubSystems & ssMassProps) {
428     outstream << delimeter;
429     outstream << MassBalance->GetJ() << delimeter;
430     outstream << MassBalance->GetMass() << delimeter;
431     outstream << MassBalance->GetXYZcg();
432   }
433   if (SubSystems & ssPropagate) {
434     outstream.precision(14);
435     outstream << delimeter;
436     outstream << Propagate->GetAltitudeASL() << delimeter;
437     outstream << Propagate->GetDistanceAGL() << delimeter;
438     outstream << (radtodeg*Propagate->GetEuler()).Dump(delimeter) << delimeter;
439     outstream << Auxiliary->Getalpha(inDegrees) << delimeter;
440     outstream << Auxiliary->Getbeta(inDegrees) << delimeter;
441     outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter;
442     outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter;
443     outstream.precision(18);
444     outstream << ((FGColumnVector3)Propagate->GetLocation()).Dump(delimeter) << delimeter;
445     outstream.precision(14);
446     outstream << Inertial->GetEarthPositionAngleDeg() << delimeter;
447     outstream << Propagate->GetDistanceAGL() << delimeter;
448     outstream << Propagate->GetLocalTerrainRadius();
449     outstream.precision(10);
450   }
451   if (SubSystems & ssCoefficients) {
452     scratch = Aerodynamics->GetCoefficientValues(delimeter);
453     if (scratch.length() != 0) outstream << delimeter << scratch;
454   }
455   if (SubSystems & ssFCS) {
456     scratch = FCS->GetComponentValues(delimeter);
457     if (scratch.length() != 0) outstream << delimeter << scratch;
458   }
459   if (SubSystems & ssGroundReactions) {
460     outstream << delimeter;
461     outstream << GroundReactions->GetGroundReactionValues(delimeter);
462   }
463   if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
464     outstream << delimeter;
465     outstream << Propulsion->GetPropulsionValues(delimeter);
466   }
467
468   for (unsigned int i=0;i<OutputProperties.size();i++) {
469     outstream << delimeter << OutputProperties[i]->getDoubleValue();
470   }
471
472   outstream << endl;
473   outstream.flush();
474 }
475
476 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478 void FGOutput::SocketDataFill(FGNetFDM* net)
479 {
480     unsigned int i;
481
482     // Version
483     net->version = FG_NET_FDM_VERSION;
484
485     // Positions
486     net->longitude = Propagate->GetLocation().GetLongitude(); // geodetic (radians)
487     net->latitude  = Propagate->GetLocation().GetLatitude(); // geodetic (radians)
488     net->altitude  = Propagate->GetAltitudeASL()*0.3048; // altitude, above sea level (meters)
489     net->agl       = (float)(Propagate->GetDistanceAGL()*0.3048); // altitude, above ground level (meters)
490
491     net->phi       = (float)(Propagate->GetEuler(ePhi)); // roll (radians)
492     net->theta     = (float)(Propagate->GetEuler(eTht)); // pitch (radians)
493     net->psi       = (float)(Propagate->GetEuler(ePsi)); // yaw or true heading (radians)
494
495     net->alpha     = (float)(Auxiliary->Getalpha()); // angle of attack (radians)
496     net->beta      = (float)(Auxiliary->Getbeta()); // side slip angle (radians)
497
498     // Velocities
499     net->phidot     = (float)(Auxiliary->GetEulerRates(ePhi)); // roll rate (radians/sec)
500     net->thetadot   = (float)(Auxiliary->GetEulerRates(eTht)); // pitch rate (radians/sec)
501     net->psidot     = (float)(Auxiliary->GetEulerRates(ePsi)); // yaw rate (radians/sec)
502     net->vcas       = (float)(Auxiliary->GetVcalibratedFPS()); // VCAS, ft/sec
503     net->climb_rate = (float)(Propagate->Gethdot());           // altitude rate, ft/sec
504     net->v_north    = (float)(Propagate->GetVel(eNorth));      // north vel in NED frame, fps
505     net->v_east     = (float)(Propagate->GetVel(eEast));       // east vel in NED frame, fps
506     net->v_down     = (float)(Propagate->GetVel(eDown));       // down vel in NED frame, fps
507 //---ADD METHOD TO CALCULATE THESE TERMS---
508     net->v_wind_body_north = (float)(Propagate->GetVel(eNorth)); // north vel in NED relative to airmass, fps
509     net->v_wind_body_east = (float)(Propagate->GetVel(eEast)); // east vel in NED relative to airmass, fps
510     net->v_wind_body_down = (float)(Propagate->GetVel(eDown)); // down vel in NED relative to airmass, fps
511
512     // Accelerations
513     net->A_X_pilot   = (float)(Auxiliary->GetPilotAccel(1));    // X body accel, ft/s/s
514     net->A_Y_pilot   = (float)(Auxiliary->GetPilotAccel(2));    // Y body accel, ft/s/s
515     net->A_Z_pilot   = (float)(Auxiliary->GetPilotAccel(3));    // Z body accel, ft/s/s
516
517     // Stall
518     net->stall_warning = 0.0;  // 0.0 - 1.0 indicating the amount of stall
519     net->slip_deg    = (float)(Auxiliary->Getbeta(inDegrees));  // slip ball deflection, deg
520
521     // Engine status
522     net->num_engines = Propulsion->GetNumEngines(); // Number of valid engines
523
524     for (i=0; i<net->num_engines; i++) {
525        if (Propulsion->GetEngine(i)->GetRunning())
526           net->eng_state[i] = 2;       // Engine state running
527        else if (Propulsion->GetEngine(i)->GetCranking())
528           net->eng_state[i] = 1;       // Engine state cranking
529        else
530           net->eng_state[i] = 0;       // Engine state off
531
532        switch (Propulsion->GetEngine(i)->GetType()) {
533        case (FGEngine::etRocket):
534        break;
535        case (FGEngine::etPiston):
536           net->rpm[i]       = (float)(((FGPiston *)Propulsion->GetEngine(i))->getRPM());
537           net->fuel_flow[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getFuelFlow_gph());
538           net->fuel_px[i]   = 0; // Fuel pressure, psi  (N/A in current model)
539           net->egt[i]       = (float)(((FGPiston *)Propulsion->GetEngine(i))->GetEGT());
540           net->cht[i]       = (float)(((FGPiston *)Propulsion->GetEngine(i))->getCylinderHeadTemp_degF());
541           net->mp_osi[i]    = (float)(((FGPiston *)Propulsion->GetEngine(i))->getManifoldPressure_inHg());
542           net->oil_temp[i]  = (float)(((FGPiston *)Propulsion->GetEngine(i))->getOilTemp_degF());
543           net->oil_px[i]    = (float)(((FGPiston *)Propulsion->GetEngine(i))->getOilPressure_psi());
544           net->tit[i]       = 0; // Turbine Inlet Temperature  (N/A for piston)
545        break;
546        case (FGEngine::etTurbine):
547        break;
548        case (FGEngine::etTurboprop):
549        break;
550        case (FGEngine::etElectric):
551        break;
552        case (FGEngine::etUnknown):
553        break;
554        }
555     }
556
557
558     // Consumables
559     net->num_tanks = Propulsion->GetNumTanks();   // Max number of fuel tanks
560
561     for (i=0; i<net->num_tanks; i++) {
562        net->fuel_quantity[i] = (float)(((FGTank *)Propulsion->GetTank(i))->GetContents());
563     }
564
565
566     // Gear status
567     net->num_wheels  = GroundReactions->GetNumGearUnits();
568
569     for (i=0; i<net->num_wheels; i++) {
570        net->wow[i]              = GroundReactions->GetGearUnit(i)->GetWOW();
571        if (GroundReactions->GetGearUnit(i)->GetGearUnitDown())
572           net->gear_pos[i]      = 1;  //gear down, using FCS convention
573        else
574           net->gear_pos[i]      = 0;  //gear up, using FCS convention
575        net->gear_steer[i]       = (float)(GroundReactions->GetGearUnit(i)->GetSteerNorm());
576        net->gear_compression[i] = (float)(GroundReactions->GetGearUnit(i)->GetCompLen());
577     }
578
579
580     // Environment
581     net->cur_time    = (long int)1234567890;    // Friday, Feb 13, 2009, 23:31:30 UTC (not processed by FGFS anyway)
582     net->warp        = 0;                       // offset in seconds to unix time
583     net->visibility  = 25000.0;                 // visibility in meters (for env. effects)
584
585
586     // Control surface positions (normalized values)
587     net->elevator          = (float)(FCS->GetDePos(ofNorm));    // Norm Elevator Pos, --
588     net->elevator_trim_tab = (float)(FCS->GetPitchTrimCmd());   // Norm Elev Trim Tab Pos, --
589     net->left_flap         = (float)(FCS->GetDfPos(ofNorm));    // Norm Flap Pos, --
590     net->right_flap        = (float)(FCS->GetDfPos(ofNorm));    // Norm Flap Pos, --
591     net->left_aileron      = (float)(FCS->GetDaLPos(ofNorm));   // Norm L Aileron Pos, --
592     net->right_aileron     = (float)(FCS->GetDaRPos(ofNorm));   // Norm R Aileron Pos, --
593     net->rudder            = (float)(FCS->GetDrPos(ofNorm));    // Norm Rudder Pos, --
594     net->nose_wheel        = (float)(FCS->GetDrPos(ofNorm));    // *** FIX ***  Using Rudder Pos for NWS, --
595     net->speedbrake        = (float)(FCS->GetDsbPos(ofNorm));   // Norm Speedbrake Pos, --
596     net->spoilers          = (float)(FCS->GetDspPos(ofNorm));   // Norm Spoiler Pos, --
597
598
599     // Convert the net buffer to network format
600     if ( isLittleEndian ) {
601         net->version = htonl(net->version);
602
603         htond(net->longitude);
604         htond(net->latitude);
605         htond(net->altitude);
606         htonf(net->agl);
607         htonf(net->phi);
608         htonf(net->theta);
609         htonf(net->psi);
610         htonf(net->alpha);
611         htonf(net->beta);
612
613         htonf(net->phidot);
614         htonf(net->thetadot);
615         htonf(net->psidot);
616         htonf(net->vcas);
617         htonf(net->climb_rate);
618         htonf(net->v_north);
619         htonf(net->v_east);
620         htonf(net->v_down);
621         htonf(net->v_wind_body_north);
622         htonf(net->v_wind_body_east);
623         htonf(net->v_wind_body_down);
624
625         htonf(net->A_X_pilot);
626         htonf(net->A_Y_pilot);
627         htonf(net->A_Z_pilot);
628
629         htonf(net->stall_warning);
630         htonf(net->slip_deg);
631
632         for (i=0; i<net->num_engines; ++i ) {
633             net->eng_state[i] = htonl(net->eng_state[i]);
634             htonf(net->rpm[i]);
635             htonf(net->fuel_flow[i]);
636             htonf(net->fuel_px[i]);
637             htonf(net->egt[i]);
638             htonf(net->cht[i]);
639             htonf(net->mp_osi[i]);
640             htonf(net->tit[i]);
641             htonf(net->oil_temp[i]);
642             htonf(net->oil_px[i]);
643         }
644         net->num_engines = htonl(net->num_engines);
645
646         for (i=0; i<net->num_tanks; ++i ) {
647             htonf(net->fuel_quantity[i]);
648         }
649         net->num_tanks = htonl(net->num_tanks);
650
651         for (i=0; i<net->num_wheels; ++i ) {
652             net->wow[i] = htonl(net->wow[i]);
653             htonf(net->gear_pos[i]);
654             htonf(net->gear_steer[i]);
655             htonf(net->gear_compression[i]);
656         }
657         net->num_wheels = htonl(net->num_wheels);
658
659         net->cur_time = htonl( net->cur_time );
660         net->warp = htonl( net->warp );
661         htonf(net->visibility);
662
663         htonf(net->elevator);
664         htonf(net->elevator_trim_tab);
665         htonf(net->left_flap);
666         htonf(net->right_flap);
667         htonf(net->left_aileron);
668         htonf(net->right_aileron);
669         htonf(net->rudder);
670         htonf(net->nose_wheel);
671         htonf(net->speedbrake);
672         htonf(net->spoilers);
673     }
674 }
675
676 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
677
678 void FGOutput::FlightGearSocketOutput(void)
679 {
680   int length = sizeof(fgSockBuf);
681
682
683   if (flightGearSocket == NULL) return;
684   if (!flightGearSocket->GetConnectStatus()) return;
685
686   SocketDataFill(&fgSockBuf);
687   flightGearSocket->Send((char *)&fgSockBuf, length);
688 }
689
690 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
691
692 void FGOutput::SocketOutput(void)
693 {
694   string asciiData, scratch;
695
696   if (socket == NULL) return;
697   if (!socket->GetConnectStatus()) return;
698
699   socket->Clear();
700   if (sFirstPass) {
701     socket->Clear("<LABELS>");
702     socket->Append("Time");
703
704     if (SubSystems & ssAerosurfaces) {
705       socket->Append("Aileron Command");
706       socket->Append("Elevator Command");
707       socket->Append("Rudder Command");
708       socket->Append("Flap Command");
709       socket->Append("Left Aileron Position");
710       socket->Append("Right Aileron Position");
711       socket->Append("Elevator Position");
712       socket->Append("Rudder Position");
713       socket->Append("Flap Position");
714     }
715
716     if (SubSystems & ssRates) {
717       socket->Append("P");
718       socket->Append("Q");
719       socket->Append("R");
720       socket->Append("PDot");
721       socket->Append("QDot");
722       socket->Append("RDot");
723     }
724
725     if (SubSystems & ssVelocities) {
726       socket->Append("QBar");
727       socket->Append("Vtotal");
728       socket->Append("UBody");
729       socket->Append("VBody");
730       socket->Append("WBody");
731       socket->Append("UAero");
732       socket->Append("VAero");
733       socket->Append("WAero");
734       socket->Append("Vn");
735       socket->Append("Ve");
736       socket->Append("Vd");
737     }
738     if (SubSystems & ssForces) {
739       socket->Append("F_Drag");
740       socket->Append("F_Side");
741       socket->Append("F_Lift");
742       socket->Append("LoD");
743       socket->Append("Fx");
744       socket->Append("Fy");
745       socket->Append("Fz");
746     }
747     if (SubSystems & ssMoments) {
748       socket->Append("L");
749       socket->Append("M");
750       socket->Append("N");
751     }
752     if (SubSystems & ssAtmosphere) {
753       socket->Append("Rho");
754       socket->Append("SL pressure");
755       socket->Append("Ambient pressure");
756       socket->Append("Turbulence Magnitude");
757       socket->Append("Turbulence Direction X");
758       socket->Append("Turbulence Direction Y");
759       socket->Append("Turbulence Direction Z");
760       socket->Append("NWind");
761       socket->Append("EWind");
762       socket->Append("DWind");
763     }
764     if (SubSystems & ssMassProps) {
765       socket->Append("Ixx");
766       socket->Append("Ixy");
767       socket->Append("Ixz");
768       socket->Append("Iyx");
769       socket->Append("Iyy");
770       socket->Append("Iyz");
771       socket->Append("Izx");
772       socket->Append("Izy");
773       socket->Append("Izz");
774       socket->Append("Mass");
775       socket->Append("Xcg");
776       socket->Append("Ycg");
777       socket->Append("Zcg");
778     }
779     if (SubSystems & ssPropagate) {
780         socket->Append("Altitude");
781         socket->Append("Phi (deg)");
782         socket->Append("Tht (deg)");
783         socket->Append("Psi (deg)");
784         socket->Append("Alpha (deg)");
785         socket->Append("Beta (deg)");
786         socket->Append("Latitude (deg)");
787         socket->Append("Longitude (deg)");
788     }
789     if (SubSystems & ssCoefficients) {
790       scratch = Aerodynamics->GetCoefficientStrings(",");
791       if (scratch.length() != 0) socket->Append(scratch);
792     }
793     if (SubSystems & ssFCS) {
794       scratch = FCS->GetComponentStrings(",");
795       if (scratch.length() != 0) socket->Append(scratch);
796     }
797     if (SubSystems & ssGroundReactions) {
798       socket->Append(GroundReactions->GetGroundReactionStrings(","));
799     }
800     if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
801       socket->Append(Propulsion->GetPropulsionStrings(","));
802     }
803     if (OutputProperties.size() > 0) {
804       for (unsigned int i=0;i<OutputProperties.size();i++) {
805         socket->Append(OutputProperties[i]->GetPrintableName());
806       }
807     }
808
809     sFirstPass = false;
810     socket->Send();
811   }
812
813   socket->Clear();
814   socket->Append(State->Getsim_time());
815
816   if (SubSystems & ssAerosurfaces) {
817     socket->Append(FCS->GetDaCmd());
818     socket->Append(FCS->GetDeCmd());
819     socket->Append(FCS->GetDrCmd());
820     socket->Append(FCS->GetDfCmd());
821     socket->Append(FCS->GetDaLPos());
822     socket->Append(FCS->GetDaRPos());
823     socket->Append(FCS->GetDePos());
824     socket->Append(FCS->GetDrPos());
825     socket->Append(FCS->GetDfPos());
826   }
827   if (SubSystems & ssRates) {
828     socket->Append(radtodeg*Propagate->GetPQR(eP));
829     socket->Append(radtodeg*Propagate->GetPQR(eQ));
830     socket->Append(radtodeg*Propagate->GetPQR(eR));
831     socket->Append(radtodeg*Propagate->GetPQRdot(eP));
832     socket->Append(radtodeg*Propagate->GetPQRdot(eQ));
833     socket->Append(radtodeg*Propagate->GetPQRdot(eR));
834   }
835   if (SubSystems & ssVelocities) {
836     socket->Append(Auxiliary->Getqbar());
837     socket->Append(Auxiliary->GetVt());
838     socket->Append(Propagate->GetUVW(eU));
839     socket->Append(Propagate->GetUVW(eV));
840     socket->Append(Propagate->GetUVW(eW));
841     socket->Append(Auxiliary->GetAeroUVW(eU));
842     socket->Append(Auxiliary->GetAeroUVW(eV));
843     socket->Append(Auxiliary->GetAeroUVW(eW));
844     socket->Append(Propagate->GetVel(eNorth));
845     socket->Append(Propagate->GetVel(eEast));
846     socket->Append(Propagate->GetVel(eDown));
847   }
848   if (SubSystems & ssForces) {
849     socket->Append(Aerodynamics->GetvFw()(eDrag));
850     socket->Append(Aerodynamics->GetvFw()(eSide));
851     socket->Append(Aerodynamics->GetvFw()(eLift));
852     socket->Append(Aerodynamics->GetLoD());
853     socket->Append(Aircraft->GetForces(eX));
854     socket->Append(Aircraft->GetForces(eY));
855     socket->Append(Aircraft->GetForces(eZ));
856   }
857   if (SubSystems & ssMoments) {
858     socket->Append(Aircraft->GetMoments(eL));
859     socket->Append(Aircraft->GetMoments(eM));
860     socket->Append(Aircraft->GetMoments(eN));
861   }
862   if (SubSystems & ssAtmosphere) {
863     socket->Append(Atmosphere->GetDensity());
864     socket->Append(Atmosphere->GetPressureSL());
865     socket->Append(Atmosphere->GetPressure());
866     socket->Append(Atmosphere->GetTurbMagnitude());
867     socket->Append(Atmosphere->GetTurbDirection().Dump(","));
868     socket->Append(Atmosphere->GetTotalWindNED().Dump(","));
869   }
870   if (SubSystems & ssMassProps) {
871     socket->Append(MassBalance->GetJ()(1,1));
872     socket->Append(MassBalance->GetJ()(1,2));
873     socket->Append(MassBalance->GetJ()(1,3));
874     socket->Append(MassBalance->GetJ()(2,1));
875     socket->Append(MassBalance->GetJ()(2,2));
876     socket->Append(MassBalance->GetJ()(2,3));
877     socket->Append(MassBalance->GetJ()(3,1));
878     socket->Append(MassBalance->GetJ()(3,2));
879     socket->Append(MassBalance->GetJ()(3,3));
880     socket->Append(MassBalance->GetMass());
881     socket->Append(MassBalance->GetXYZcg()(eX));
882     socket->Append(MassBalance->GetXYZcg()(eY));
883     socket->Append(MassBalance->GetXYZcg()(eZ));
884   }
885   if (SubSystems & ssPropagate) {
886     socket->Append(Propagate->GetAltitudeASL());
887     socket->Append(radtodeg*Propagate->GetEuler(ePhi));
888     socket->Append(radtodeg*Propagate->GetEuler(eTht));
889     socket->Append(radtodeg*Propagate->GetEuler(ePsi));
890     socket->Append(Auxiliary->Getalpha(inDegrees));
891     socket->Append(Auxiliary->Getbeta(inDegrees));
892     socket->Append(Propagate->GetLocation().GetLatitudeDeg());
893     socket->Append(Propagate->GetLocation().GetLongitudeDeg());
894   }
895   if (SubSystems & ssCoefficients) {
896     scratch = Aerodynamics->GetCoefficientValues(",");
897     if (scratch.length() != 0) socket->Append(scratch);
898   }
899   if (SubSystems & ssFCS) {
900     scratch = FCS->GetComponentValues(",");
901     if (scratch.length() != 0) socket->Append(scratch);
902   }
903   if (SubSystems & ssGroundReactions) {
904     socket->Append(GroundReactions->GetGroundReactionValues(","));
905   }
906   if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
907     socket->Append(Propulsion->GetPropulsionValues(","));
908   }
909
910   for (unsigned int i=0;i<OutputProperties.size();i++) {
911     socket->Append(OutputProperties[i]->getDoubleValue());
912   }
913
914   socket->Send();
915 }
916
917 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918
919 void FGOutput::SocketStatusOutput(string out_str)
920 {
921   string asciiData;
922
923   if (socket == NULL) return;
924
925   socket->Clear();
926   asciiData = string("<STATUS>") + out_str;
927   socket->Append(asciiData.c_str());
928   socket->Send();
929 }
930
931 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
932
933 bool FGOutput::Load(Element* element)
934 {
935   string type="", parameter="";
936   string name="";
937   string protocol="tcp";
938   int OutRate = 0;
939   string property;
940   unsigned int port;
941   Element *property_element;
942
943   string separator = "/";
944
945   if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
946     output_file_name = DirectivesFile;      // one found in the config file.
947     document = LoadXMLDocument(output_file_name);
948   } else if (!element->GetAttributeValue("file").empty()) {
949     output_file_name = element->GetAttributeValue("file");
950     document = LoadXMLDocument(output_file_name);
951   } else {
952     document = element;
953   }
954
955   name = document->GetAttributeValue("name");
956   type = document->GetAttributeValue("type");
957   SetType(type);
958   if (!document->GetAttributeValue("port").empty() && type == string("SOCKET")) {
959     port = atoi(document->GetAttributeValue("port").c_str());
960     socket = new FGfdmSocket(name, port);
961   } else if (!document->GetAttributeValue("port").empty() && type == string("FLIGHTGEAR")) {
962     port = atoi(document->GetAttributeValue("port").c_str());
963     if (!document->GetAttributeValue("protocol").empty())
964        protocol = document->GetAttributeValue("protocol");
965     if (protocol == "udp")
966        flightGearSocket = new FGfdmSocket(name, port, FGfdmSocket::ptUDP);  // create udp socket
967     else
968        flightGearSocket = new FGfdmSocket(name, port, FGfdmSocket::ptTCP);  // create tcp socket (default)
969   } else {
970     BaseFilename = Filename = name;
971   }
972   if (!document->GetAttributeValue("rate").empty()) {
973     OutRate = (int)document->GetAttributeValueAsNumber("rate");
974   } else {
975     OutRate = 1;
976   }
977
978   if (document->FindElementValue("simulation") == string("ON"))
979     SubSystems += ssSimulation;
980   if (document->FindElementValue("aerosurfaces") == string("ON"))
981     SubSystems += ssAerosurfaces;
982   if (document->FindElementValue("rates") == string("ON"))
983     SubSystems += ssRates;
984   if (document->FindElementValue("velocities") == string("ON"))
985     SubSystems += ssVelocities;
986   if (document->FindElementValue("forces") == string("ON"))
987     SubSystems += ssForces;
988   if (document->FindElementValue("moments") == string("ON"))
989     SubSystems += ssMoments;
990   if (document->FindElementValue("atmosphere") == string("ON"))
991     SubSystems += ssAtmosphere;
992   if (document->FindElementValue("massprops") == string("ON"))
993     SubSystems += ssMassProps;
994   if (document->FindElementValue("position") == string("ON"))
995     SubSystems += ssPropagate;
996   if (document->FindElementValue("coefficients") == string("ON"))
997     SubSystems += ssCoefficients;
998   if (document->FindElementValue("ground_reactions") == string("ON"))
999     SubSystems += ssGroundReactions;
1000   if (document->FindElementValue("fcs") == string("ON"))
1001     SubSystems += ssFCS;
1002   if (document->FindElementValue("propulsion") == string("ON"))
1003     SubSystems += ssPropulsion;
1004   property_element = document->FindElement("property");
1005   while (property_element) {
1006     string property_str = property_element->GetDataLine();
1007     FGPropertyManager* node = PropertyManager->GetNode(property_str);
1008     if (!node) {
1009       cerr << fgred << highint << endl << "  No property by the name "
1010            << property_str << " has been defined. This property will " << endl
1011            << "  not be logged. You should check your configuration file."
1012            << reset << endl;
1013     } else {
1014       OutputProperties.push_back(node);
1015     }
1016     property_element = document->FindNextElement("property");
1017   }
1018
1019   OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate);
1020   rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
1021
1022   Debug(2);
1023
1024   return true;
1025 }
1026
1027 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1028 //    The bitmasked value choices are as follows:
1029 //    unset: In this case (the default) JSBSim would only print
1030 //       out the normally expected messages, essentially echoing
1031 //       the config files as they are read. If the environment
1032 //       variable is not set, debug_lvl is set to 1 internally
1033 //    0: This requests JSBSim not to output any messages
1034 //       whatsoever.
1035 //    1: This value explicity requests the normal JSBSim
1036 //       startup messages
1037 //    2: This value asks for a message to be printed out when
1038 //       a class is instantiated
1039 //    4: When this value is set, a message is displayed when a
1040 //       FGModel object executes its Run() method
1041 //    8: When this value is set, various runtime state variables
1042 //       are printed out periodically
1043 //    16: When set various parameters are sanity checked and
1044 //       a message is printed out when they go out of bounds
1045
1046 void FGOutput::Debug(int from)
1047 {
1048   string scratch="";
1049
1050   if (debug_lvl <= 0) return;
1051
1052   if (debug_lvl & 1) { // Standard console startup message output
1053     if (from == 0) { // Constructor
1054
1055     }
1056     if (from == 2) {
1057       if (output_file_name.empty())
1058         cout << "  " << "Output parameters read inline" << endl;
1059       else
1060         cout << "    Output parameters read from file: " << output_file_name << endl;
1061
1062       if (Filename == "cout" || Filename == "COUT") {
1063         scratch = "    Log output goes to screen console";
1064       } else if (!Filename.empty()) {
1065         scratch = "    Log output goes to file: " + Filename;
1066       }
1067       switch (Type) {
1068       case otCSV:
1069         cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl;
1070         break;
1071       case otNone:
1072         cout << "  No log output" << endl;
1073         break;
1074       }
1075
1076       if (SubSystems & ssSimulation)      cout << "    Simulation parameters logged" << endl;
1077       if (SubSystems & ssAerosurfaces)    cout << "    Aerosurface parameters logged" << endl;
1078       if (SubSystems & ssRates)           cout << "    Rate parameters logged" << endl;
1079       if (SubSystems & ssVelocities)      cout << "    Velocity parameters logged" << endl;
1080       if (SubSystems & ssForces)          cout << "    Force parameters logged" << endl;
1081       if (SubSystems & ssMoments)         cout << "    Moments parameters logged" << endl;
1082       if (SubSystems & ssAtmosphere)      cout << "    Atmosphere parameters logged" << endl;
1083       if (SubSystems & ssMassProps)       cout << "    Mass parameters logged" << endl;
1084       if (SubSystems & ssCoefficients)    cout << "    Coefficient parameters logged" << endl;
1085       if (SubSystems & ssPropagate)       cout << "    Propagate parameters logged" << endl;
1086       if (SubSystems & ssGroundReactions) cout << "    Ground parameters logged" << endl;
1087       if (SubSystems & ssFCS)             cout << "    FCS parameters logged" << endl;
1088       if (SubSystems & ssPropulsion)      cout << "    Propulsion parameters logged" << endl;
1089       if (OutputProperties.size() > 0)    cout << "    Properties logged:" << endl;
1090       for (unsigned int i=0;i<OutputProperties.size();i++) {
1091         cout << "      - " << OutputProperties[i]->GetName() << endl;
1092       }
1093     }
1094   }
1095   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1096     if (from == 0) cout << "Instantiated: FGOutput" << endl;
1097     if (from == 1) cout << "Destroyed:    FGOutput" << endl;
1098   }
1099   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1100   }
1101   if (debug_lvl & 8 ) { // Runtime state variables
1102   }
1103   if (debug_lvl & 16) { // Sanity checking
1104   }
1105   if (debug_lvl & 64) {
1106     if (from == 0) { // Constructor
1107       cout << IdSrc << endl;
1108       cout << IdHdr << endl;
1109     }
1110   }
1111 }
1112 }