1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Manage output of sim parameters to file or stdout
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
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.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This is the place where you create output routines to dump data for perusal
34 --------------------------------------------------------------------------------
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "FGFDMExec.h"
44 #include "FGAtmosphere.h"
46 #include "FGAerodynamics.h"
47 #include "FGGroundReactions.h"
48 #include "FGAircraft.h"
49 #include "FGMassBalance.h"
50 #include "FGPropagate.h"
51 #include "FGAuxiliary.h"
52 #include "FGInertial.h"
59 static const char *IdSrc = "$Id$";
60 static const char *IdHdr = ID_OUTPUT;
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
69 sFirstPass = dFirstPass = true;
81 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 OutputProperties.clear();
90 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 bool FGOutput::Run(void)
94 if (FGModel::Run()) return true;
96 if (enabled && !State->IntegrationSuspended()&& !FDMExec->Holding()) {
97 if (Type == otSocket) {
99 } else if (Type == otCSV || Type == otTab) {
100 DelimitedOutput(Filename);
101 } else if (Type == otTerminal) {
103 } else if (Type == otNone) {
106 // Not a valid type of output
112 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 void FGOutput::SetType(string type)
119 } else if (type == "TABULAR") {
122 } else if (type == "SOCKET") {
124 } else if (type == "TERMINAL") {
126 } else if (type != string("NONE")) {
128 cerr << "Unknown type of output specified in config file" << endl;
132 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 void FGOutput::DelimitedOutput(string fname)
139 if (fname == "COUT" || fname == "cout") {
140 buffer = cout.rdbuf();
142 datafile.open(fname.c_str());
143 buffer = datafile.rdbuf();
146 ostream outstream(buffer);
150 if (SubSystems & ssSimulation) {
153 if (SubSystems & ssAerosurfaces) {
154 outstream << delimeter;
155 outstream << "Aileron Command (norm)" + delimeter;
156 outstream << "Elevator Command (norm)" + delimeter;
157 outstream << "Rudder Command (norm)" + delimeter;
158 outstream << "Flap Command (norm)" + delimeter;
159 outstream << "Left Aileron Position (deg)" + delimeter;
160 outstream << "Right Aileron Position (deg)" + delimeter;
161 outstream << "Elevator Position (deg)" + delimeter;
162 outstream << "Rudder Position (deg)" + delimeter;
163 outstream << "Flap Position (deg)";
165 if (SubSystems & ssRates) {
166 outstream << delimeter;
167 outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter;
168 outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)";
170 if (SubSystems & ssVelocities) {
171 outstream << delimeter;
172 outstream << "q bar (psf)" + delimeter;
173 outstream << "V_{Total} (ft/s)" + delimeter;
174 outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
175 outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
176 outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
178 if (SubSystems & ssForces) {
179 outstream << delimeter;
180 outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter;
181 outstream << "L/D" + delimeter;
182 outstream << "F_X (lbs)" + delimeter + "F_Y (lbs)" + delimeter + "F_Z (lbs)";
184 if (SubSystems & ssMoments) {
185 outstream << delimeter;
186 outstream << "L (ft-lbs)" + delimeter + "M (ft-lbs)" + delimeter + "N (ft-lbs)";
188 if (SubSystems & ssAtmosphere) {
189 outstream << delimeter;
190 outstream << "Rho (slugs/ft^3)" + delimeter;
191 outstream << "P_{SL} (psf)" + delimeter;
192 outstream << "P_{Ambient} (psf)" + delimeter;
193 outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)";
195 if (SubSystems & ssMassProps) {
196 outstream << delimeter;
197 outstream << "I_xx" + delimeter;
198 outstream << "I_xy" + delimeter;
199 outstream << "I_xz" + delimeter;
200 outstream << "I_yx" + delimeter;
201 outstream << "I_yy" + delimeter;
202 outstream << "I_yz" + delimeter;
203 outstream << "I_zx" + delimeter;
204 outstream << "I_zy" + delimeter;
205 outstream << "I_zz" + delimeter;
206 outstream << "Mass" + delimeter;
207 outstream << "X_cg" + delimeter + "Y_cg" + delimeter + "Z_cg";
209 if (SubSystems & ssPropagate) {
210 outstream << delimeter;
211 outstream << "Altitude (ft)" + delimeter;
212 outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter;
213 outstream << "Alpha (deg)" + delimeter;
214 outstream << "Beta (deg)" + delimeter;
215 outstream << "Latitude (deg)" + delimeter;
216 outstream << "Longitude (deg)" + delimeter;
217 outstream << "Distance AGL (ft)" + delimeter;
218 outstream << "Runway Radius (ft)";
220 if (SubSystems & ssCoefficients) {
221 scratch = Aerodynamics->GetCoefficientStrings(delimeter);
222 if (scratch.length() != 0) outstream << delimeter << scratch;
224 if (SubSystems & ssFCS) {
225 scratch = FCS->GetComponentStrings(delimeter);
226 if (scratch.length() != 0) outstream << delimeter << scratch;
228 if (SubSystems & ssGroundReactions) {
229 outstream << delimeter;
230 outstream << GroundReactions->GetGroundReactionStrings(delimeter);
232 if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
233 outstream << delimeter;
234 outstream << Propulsion->GetPropulsionStrings(delimeter);
236 if (OutputProperties.size() > 0) {
237 for (unsigned int i=0;i<OutputProperties.size();i++) {
238 outstream << delimeter << OutputProperties[i]->GetName();
246 outstream << State->Getsim_time();
247 if (SubSystems & ssSimulation) {
249 if (SubSystems & ssAerosurfaces) {
250 outstream << delimeter;
251 outstream << FCS->GetDaCmd() << delimeter;
252 outstream << FCS->GetDeCmd() << delimeter;
253 outstream << FCS->GetDrCmd() << delimeter;
254 outstream << FCS->GetDfCmd() << delimeter;
255 outstream << FCS->GetDaLPos(ofDeg) << delimeter;
256 outstream << FCS->GetDaRPos(ofDeg) << delimeter;
257 outstream << FCS->GetDePos(ofDeg) << delimeter;
258 outstream << FCS->GetDrPos(ofDeg) << delimeter;
259 outstream << FCS->GetDfPos(ofDeg);
261 if (SubSystems & ssRates) {
262 outstream << delimeter;
263 outstream << Propagate->GetPQR().Dump(delimeter) << delimeter;
264 outstream << Propagate->GetPQRdot().Dump(delimeter);
266 if (SubSystems & ssVelocities) {
267 outstream << delimeter;
268 outstream << Auxiliary->Getqbar() << delimeter;
269 outstream << setprecision(12) << Auxiliary->GetVt() << delimeter;
270 outstream << setprecision(12) << Propagate->GetUVW().Dump(delimeter) << delimeter;
271 outstream << Auxiliary->GetAeroUVW().Dump(delimeter) << delimeter;
272 outstream << Propagate->GetVel().Dump(delimeter);
274 if (SubSystems & ssForces) {
275 outstream << delimeter;
276 outstream << Aerodynamics->GetvFs() << delimeter;
277 outstream << Aerodynamics->GetLoD() << delimeter;
278 outstream << Aircraft->GetForces().Dump(delimeter);
280 if (SubSystems & ssMoments) {
281 outstream << delimeter;
282 outstream << Aircraft->GetMoments().Dump(delimeter);
284 if (SubSystems & ssAtmosphere) {
285 outstream << delimeter;
286 outstream << Atmosphere->GetDensity() << delimeter;
287 outstream << Atmosphere->GetPressureSL() << delimeter;
288 outstream << Atmosphere->GetPressure() << delimeter;
289 outstream << Atmosphere->GetWindNED().Dump(delimeter);
291 if (SubSystems & ssMassProps) {
292 outstream << delimeter;
293 outstream << MassBalance->GetJ() << delimeter;
294 outstream << MassBalance->GetMass() << delimeter;
295 outstream << MassBalance->GetXYZcg();
297 if (SubSystems & ssPropagate) {
298 outstream << delimeter;
299 outstream << Propagate->Geth() << delimeter;
300 outstream << Propagate->GetEuler().Dump(delimeter) << delimeter;
301 outstream << Auxiliary->Getalpha(inDegrees) << delimeter;
302 outstream << Auxiliary->Getbeta(inDegrees) << delimeter;
303 outstream << Propagate->GetLocation().GetLatitudeDeg() << delimeter;
304 outstream << Propagate->GetLocation().GetLongitudeDeg() << delimeter;
305 outstream << Propagate->GetDistanceAGL() << delimeter;
306 outstream << Propagate->GetRunwayRadius();
308 if (SubSystems & ssCoefficients) {
309 scratch = Aerodynamics->GetCoefficientValues(delimeter);
310 if (scratch.length() != 0) outstream << delimeter << scratch;
312 if (SubSystems & ssFCS) {
313 scratch = FCS->GetComponentValues(delimeter);
314 if (scratch.length() != 0) outstream << delimeter << scratch;
316 if (SubSystems & ssGroundReactions) {
317 outstream << delimeter;
318 outstream << GroundReactions->GetGroundReactionValues(delimeter);
320 if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
321 outstream << delimeter;
322 outstream << Propulsion->GetPropulsionValues(delimeter);
325 for (unsigned int i=0;i<OutputProperties.size();i++) {
326 outstream << delimeter << OutputProperties[i]->getDoubleValue();
333 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335 void FGOutput::SocketOutput(void)
337 string asciiData, scratch;
339 if (socket == NULL) return;
340 if (!socket->GetConnectStatus()) return;
344 socket->Clear("<LABELS>");
345 socket->Append("Time");
347 if (SubSystems & ssAerosurfaces) {
348 socket->Append("Aileron Command");
349 socket->Append("Elevator Command");
350 socket->Append("Rudder Command");
351 socket->Append("Flap Command");
352 socket->Append("Left Aileron Position");
353 socket->Append("Right Aileron Position");
354 socket->Append("Elevator Position");
355 socket->Append("Rudder Position");
356 socket->Append("Flap Position");
359 if (SubSystems & ssRates) {
363 socket->Append("PDot");
364 socket->Append("QDot");
365 socket->Append("RDot");
368 if (SubSystems & ssVelocities) {
369 socket->Append("QBar");
370 socket->Append("Vtotal");
371 socket->Append("UBody");
372 socket->Append("VBody");
373 socket->Append("WBody");
374 socket->Append("UAero");
375 socket->Append("VAero");
376 socket->Append("WAero");
377 socket->Append("Vn");
378 socket->Append("Ve");
379 socket->Append("Vd");
381 if (SubSystems & ssForces) {
382 socket->Append("F_Drag");
383 socket->Append("F_Side");
384 socket->Append("F_Lift");
385 socket->Append("LoD");
386 socket->Append("Fx");
387 socket->Append("Fy");
388 socket->Append("Fz");
390 if (SubSystems & ssMoments) {
395 if (SubSystems & ssAtmosphere) {
396 socket->Append("Rho");
397 socket->Append("SL pressure");
398 socket->Append("Ambient pressure");
399 socket->Append("NWind");
400 socket->Append("EWind");
401 socket->Append("DWind");
403 if (SubSystems & ssMassProps) {
404 socket->Append("Ixx");
405 socket->Append("Ixy");
406 socket->Append("Ixz");
407 socket->Append("Iyx");
408 socket->Append("Iyy");
409 socket->Append("Iyz");
410 socket->Append("Izx");
411 socket->Append("Izy");
412 socket->Append("Izz");
413 socket->Append("Mass");
414 socket->Append("Xcg");
415 socket->Append("Ycg");
416 socket->Append("Zcg");
418 if (SubSystems & ssPropagate) {
419 socket->Append("Altitude");
420 socket->Append("Phi");
421 socket->Append("Tht");
422 socket->Append("Psi");
423 socket->Append("Alpha");
424 socket->Append("Beta");
425 socket->Append("Latitude (Deg)");
426 socket->Append("Longitude (Deg)");
428 if (SubSystems & ssCoefficients) {
429 scratch = Aerodynamics->GetCoefficientStrings(",");
430 if (scratch.length() != 0) socket->Append(scratch);
432 if (SubSystems & ssFCS) {
433 scratch = FCS->GetComponentStrings(",");
434 if (scratch.length() != 0) socket->Append(scratch);
436 if (SubSystems & ssGroundReactions) {
437 socket->Append(GroundReactions->GetGroundReactionStrings(","));
439 if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
440 socket->Append(Propulsion->GetPropulsionStrings(","));
442 if (OutputProperties.size() > 0) {
443 for (unsigned int i=0;i<OutputProperties.size();i++) {
444 socket->Append(OutputProperties[i]->GetName());
453 socket->Append(State->Getsim_time());
455 if (SubSystems & ssAerosurfaces) {
456 socket->Append(FCS->GetDaCmd());
457 socket->Append(FCS->GetDeCmd());
458 socket->Append(FCS->GetDrCmd());
459 socket->Append(FCS->GetDfCmd());
460 socket->Append(FCS->GetDaLPos());
461 socket->Append(FCS->GetDaRPos());
462 socket->Append(FCS->GetDePos());
463 socket->Append(FCS->GetDrPos());
464 socket->Append(FCS->GetDfPos());
466 if (SubSystems & ssRates) {
467 socket->Append(Propagate->GetPQR(eP));
468 socket->Append(Propagate->GetPQR(eQ));
469 socket->Append(Propagate->GetPQR(eR));
470 socket->Append(Propagate->GetPQRdot(eP));
471 socket->Append(Propagate->GetPQRdot(eQ));
472 socket->Append(Propagate->GetPQRdot(eR));
474 if (SubSystems & ssVelocities) {
475 socket->Append(Auxiliary->Getqbar());
476 socket->Append(Auxiliary->GetVt());
477 socket->Append(Propagate->GetUVW(eU));
478 socket->Append(Propagate->GetUVW(eV));
479 socket->Append(Propagate->GetUVW(eW));
480 socket->Append(Auxiliary->GetAeroUVW(eU));
481 socket->Append(Auxiliary->GetAeroUVW(eV));
482 socket->Append(Auxiliary->GetAeroUVW(eW));
483 socket->Append(Propagate->GetVel(eNorth));
484 socket->Append(Propagate->GetVel(eEast));
485 socket->Append(Propagate->GetVel(eDown));
487 if (SubSystems & ssForces) {
488 socket->Append(Aerodynamics->GetvFs()(eDrag));
489 socket->Append(Aerodynamics->GetvFs()(eSide));
490 socket->Append(Aerodynamics->GetvFs()(eLift));
491 socket->Append(Aerodynamics->GetLoD());
492 socket->Append(Aircraft->GetForces(eX));
493 socket->Append(Aircraft->GetForces(eY));
494 socket->Append(Aircraft->GetForces(eZ));
496 if (SubSystems & ssMoments) {
497 socket->Append(Aircraft->GetMoments(eL));
498 socket->Append(Aircraft->GetMoments(eM));
499 socket->Append(Aircraft->GetMoments(eN));
501 if (SubSystems & ssAtmosphere) {
502 socket->Append(Atmosphere->GetDensity());
503 socket->Append(Atmosphere->GetPressureSL());
504 socket->Append(Atmosphere->GetPressure());
505 socket->Append(Atmosphere->GetWindNED().Dump(","));
507 if (SubSystems & ssMassProps) {
508 socket->Append(MassBalance->GetJ()(1,1));
509 socket->Append(MassBalance->GetJ()(1,2));
510 socket->Append(MassBalance->GetJ()(1,3));
511 socket->Append(MassBalance->GetJ()(2,1));
512 socket->Append(MassBalance->GetJ()(2,2));
513 socket->Append(MassBalance->GetJ()(2,3));
514 socket->Append(MassBalance->GetJ()(3,1));
515 socket->Append(MassBalance->GetJ()(3,2));
516 socket->Append(MassBalance->GetJ()(3,3));
517 socket->Append(MassBalance->GetMass());
518 socket->Append(MassBalance->GetXYZcg()(eX));
519 socket->Append(MassBalance->GetXYZcg()(eY));
520 socket->Append(MassBalance->GetXYZcg()(eZ));
522 if (SubSystems & ssPropagate) {
523 socket->Append(Propagate->Geth());
524 socket->Append(Propagate->GetEuler(ePhi));
525 socket->Append(Propagate->GetEuler(eTht));
526 socket->Append(Propagate->GetEuler(ePsi));
527 socket->Append(Auxiliary->Getalpha(inDegrees));
528 socket->Append(Auxiliary->Getbeta(inDegrees));
529 socket->Append(Propagate->GetLocation().GetLatitudeDeg());
530 socket->Append(Propagate->GetLocation().GetLongitudeDeg());
532 if (SubSystems & ssCoefficients) {
533 scratch = Aerodynamics->GetCoefficientValues(",");
534 if (scratch.length() != 0) socket->Append(scratch);
536 if (SubSystems & ssFCS) {
537 scratch = FCS->GetComponentValues(",");
538 if (scratch.length() != 0) socket->Append(scratch);
540 if (SubSystems & ssGroundReactions) {
541 socket->Append(GroundReactions->GetGroundReactionValues(","));
543 if (SubSystems & ssPropulsion && Propulsion->GetNumEngines() > 0) {
544 socket->Append(Propulsion->GetPropulsionValues(","));
547 for (unsigned int i=0;i<OutputProperties.size();i++) {
548 socket->Append(OutputProperties[i]->getDoubleValue());
554 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 void FGOutput::SocketStatusOutput(string out_str)
560 if (socket == NULL) return;
563 asciiData = string("<STATUS>") + out_str;
564 socket->Append(asciiData.c_str());
568 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 bool FGOutput::Load(Element* element)
572 string type="", parameter="";
573 string name="", fname="";
577 FGXMLParse output_file_parser;
578 Element *document, *property_element;
579 ifstream* output_file = new ifstream();
581 string separator = "/";
586 if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
587 fname = DirectivesFile; // one found in the config file.
589 fname = element->GetAttributeValue("file");
592 if (!fname.empty()) {
593 int len = fname.size();
594 if (fname.find(".xml") != string::npos) {
595 output_file_name = fname; // Use supplied name if last four letters are ".xml"
597 output_file_name = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
599 output_file->open(output_file_name.c_str());
600 if (output_file->is_open()) {
601 readXML(*output_file, output_file_parser);
605 cerr << "Could not open directives file: " << output_file_name << endl;
608 document = output_file_parser.GetDocument();
613 name = document->GetAttributeValue("name");
614 type = document->GetAttributeValue("type");
616 if (!document->GetAttributeValue("port").empty() && type == string("SOCKET")) {
617 port = atoi(document->GetAttributeValue("port").c_str());
618 socket = new FGfdmSocket(name, port);
622 if (!document->GetAttributeValue("rate").empty()) {
623 OutRate = (int)document->GetAttributeValueAsNumber("rate");
628 if (document->FindElementValue("simulation") == string("ON"))
629 SubSystems += ssSimulation;
630 if (document->FindElementValue("aerosurfaces") == string("ON"))
631 SubSystems += ssAerosurfaces;
632 if (document->FindElementValue("rates") == string("ON"))
633 SubSystems += ssRates;
634 if (document->FindElementValue("velocities") == string("ON"))
635 SubSystems += ssVelocities;
636 if (document->FindElementValue("forces") == string("ON"))
637 SubSystems += ssForces;
638 if (document->FindElementValue("moments") == string("ON"))
639 SubSystems += ssMoments;
640 if (document->FindElementValue("atmosphere") == string("ON"))
641 SubSystems += ssAtmosphere;
642 if (document->FindElementValue("massprops") == string("ON"))
643 SubSystems += ssMassProps;
644 if (document->FindElementValue("position") == string("ON"))
645 SubSystems += ssPropagate;
646 if (document->FindElementValue("coefficients") == string("ON"))
647 SubSystems += ssCoefficients;
648 if (document->FindElementValue("ground_reactions") == string("ON"))
649 SubSystems += ssGroundReactions;
650 if (document->FindElementValue("fcs") == string("ON"))
652 if (document->FindElementValue("propulsion") == string("ON"))
653 SubSystems += ssPropulsion;
654 property_element = document->FindElement("property");
655 while (property_element) {
656 string property = property_element->GetDataLine();
657 OutputProperties.push_back(PropertyManager->GetNode(property));
658 property_element = document->FindNextElement("property");
661 OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate);
662 rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
669 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
670 // The bitmasked value choices are as follows:
671 // unset: In this case (the default) JSBSim would only print
672 // out the normally expected messages, essentially echoing
673 // the config files as they are read. If the environment
674 // variable is not set, debug_lvl is set to 1 internally
675 // 0: This requests JSBSim not to output any messages
677 // 1: This value explicity requests the normal JSBSim
679 // 2: This value asks for a message to be printed out when
680 // a class is instantiated
681 // 4: When this value is set, a message is displayed when a
682 // FGModel object executes its Run() method
683 // 8: When this value is set, various runtime state variables
684 // are printed out periodically
685 // 16: When set various parameters are sanity checked and
686 // a message is printed out when they go out of bounds
688 void FGOutput::Debug(int from)
692 if (debug_lvl <= 0) return;
694 if (debug_lvl & 1) { // Standard console startup message output
695 if (from == 0) { // Constructor
699 if (output_file_name.empty())
700 cout << " " << "Output parameters read inline" << endl;
702 cout << " Output parameters read from file: " << output_file_name << endl;
704 if (Filename == "cout" || Filename == "COUT") {
705 scratch = " Log output goes to screen console";
706 } else if (!Filename.empty()) {
707 scratch = " Log output goes to file: " + Filename;
711 cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl;
714 cout << " No log output" << endl;
718 if (SubSystems & ssSimulation) cout << " Simulation parameters logged" << endl;
719 if (SubSystems & ssAerosurfaces) cout << " Aerosurface parameters logged" << endl;
720 if (SubSystems & ssRates) cout << " Rate parameters logged" << endl;
721 if (SubSystems & ssVelocities) cout << " Velocity parameters logged" << endl;
722 if (SubSystems & ssForces) cout << " Force parameters logged" << endl;
723 if (SubSystems & ssMoments) cout << " Moments parameters logged" << endl;
724 if (SubSystems & ssAtmosphere) cout << " Atmosphere parameters logged" << endl;
725 if (SubSystems & ssMassProps) cout << " Mass parameters logged" << endl;
726 if (SubSystems & ssCoefficients) cout << " Coefficient parameters logged" << endl;
727 if (SubSystems & ssPropagate) cout << " Propagate parameters logged" << endl;
728 if (SubSystems & ssGroundReactions) cout << " Ground parameters logged" << endl;
729 if (SubSystems & ssFCS) cout << " FCS parameters logged" << endl;
730 if (SubSystems & ssPropulsion) cout << " Propulsion parameters logged" << endl;
731 if (OutputProperties.size() > 0) cout << " Properties logged:" << endl;
732 for (unsigned int i=0;i<OutputProperties.size();i++) {
733 cout << " - " << OutputProperties[i]->GetName() << endl;
737 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
738 if (from == 0) cout << "Instantiated: FGOutput" << endl;
739 if (from == 1) cout << "Destroyed: FGOutput" << endl;
741 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
743 if (debug_lvl & 8 ) { // Runtime state variables
745 if (debug_lvl & 16) { // Sanity checking
747 if (debug_lvl & 64) {
748 if (from == 0) { // Constructor
749 cout << IdSrc << endl;
750 cout << IdHdr << endl;