]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGInput.cpp
Merge branch 'next' of http://git.gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / FGInput.cpp
index 4715ad05a4f10660ee0d0ed6532473de3830182e..51b4a3984b028e688f375d1c382dda34a353beb1 100755 (executable)
@@ -39,15 +39,21 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGInput.h"
-#include "FGState.h"
+#include "FGAircraft.h"
 #include "FGFDMExec.h"
 
-#include <fstream>
+#include "input_output/FGfdmSocket.h"
+#include "input_output/FGXMLElement.h"
+
+#include <sstream>
 #include <iomanip>
+#include <cstdlib>
+
+using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGInput.cpp,v 1.20 2010/11/18 12:38:06 jberndt Exp $";
 static const char *IdHdr = ID_INPUT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -89,9 +95,8 @@ bool FGInput::InitModel(void)
 
 bool FGInput::Run(void)
 {
-  string line, token, info_string;
+  string line, token;
   size_t start=0, string_start=0, string_end=0;
-  char buf[100];
   double value=0;
   FGPropertyManager* node=0;
 
@@ -100,6 +105,8 @@ bool FGInput::Run(void)
                                     // return false if no error
   // This model DOES execute if "Exec->Holding"
 
+  RunPreFunctions();
+
   data = socket->Receive(); // get socket transmission if present
 
   if (data.size() > 0) {
@@ -157,8 +164,9 @@ bool FGInput::Run(void)
             socket->Reply("Must be in HOLD to search properties\n");
           }
         } else if (node > 0) {
-          sprintf(buf, "%s = %12.6f\n", argument.c_str(), node->getDoubleValue());
-          socket->Reply(buf);
+          ostringstream buf;
+          buf << argument << " = " << setw(12) << setprecision(6) << node->getDoubleValue() << endl;
+          socket->Reply(buf.str());
         }
 
       } else if (command == "hold") {                  // PAUSE
@@ -180,12 +188,12 @@ bool FGInput::Run(void)
       } else if (command == "info") {                   // INFO
 
         // get info about the sim run and/or aircraft, etc.
-        sprintf(buf, "%8.3f", State->Getsim_time());
-        info_string  = "JSBSim version: " + JSBSim_version + "\n";
-        info_string += "Config File version: " + needed_cfg_version + "\n";
-        info_string += "Aircraft simulated: " + Aircraft->GetAircraftName() + "\n";
-        info_string += "Simulation time: " + string(buf) + "\n";
-        socket->Reply(info_string);
+        ostringstream info;
+        info << "JSBSim version: " << JSBSim_version << endl;
+        info << "Config File version: " << needed_cfg_version << endl;
+        info << "Aircraft simulated: " << FDMExec->GetAircraft()->GetAircraftName() << endl;
+        info << "Simulation time: " << setw(8) << setprecision(3) << FDMExec->GetSimTime() << endl;
+        socket->Reply(info.str());
 
       } else if (command == "help") {                   // HELP
 
@@ -207,6 +215,8 @@ bool FGInput::Run(void)
     }
   }
 
+  RunPostFunctions();
+
   return false;
 }