#ifdef FGFS
#include <simgear/compiler.h>
#include STL_IOSTREAM
-# ifdef SG_HAVE_STD_INCLUDES
-# include <ctime>
-# else
-# include <time.h>
-# endif
#else
# if defined(sgi) && !defined(__GNUC__)
# include <iostream.h>
-# include <time.h>
# else
# include <iostream>
-# include <ctime>
# endif
#endif
FDMExec = new FGFDMExec();
- if (scripted) {
+ if (scripted) { // form jsbsim <scriptfile>
result = FDMExec->LoadScript(argv[1]);
if (!result) {
cerr << "Script file " << argv[1] << " was not successfully loaded" << endl;
exit(-1);
}
- } else {
- // result = FDMExec->LoadModel("aircraft", "engine", string(argv[1]));
- FGInitialCondition IC(FDMExec);
- result = IC.Load("aircraft","engine",string(argv[1]));
+ } else { // form jsbsim <acname> <resetfile>
+ if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
+ cerr << " JSBSim could not be started" << endl << endl;
+ exit(-1);
+ }
- if (!result) {
- cerr << "Aircraft file " << argv[1] << " was not found" << endl;
- exit(-1);
+ FGInitialCondition IC(FDMExec);
+ if ( ! IC.Load("aircraft",string(argv[1]),string(argv[2]))) {
+ cerr << "Initialization unsuccessful" << endl;
+ exit(-1);
}
- if ( ! FDMExec->GetState()->Reset("aircraft", string(argv[1]), string(argv[2])))
- FDMExec->GetState()->Initialize(2000,0,0,0,0,0,0.5,0.5,40000, 0, 0, 0);
}
- while (FDMExec->Run()) {}
+//
+// RUN loop. MESSAGES are read inside the Run() loop and output as necessary.
+//
+
+ FGJSBBase::Message* msg;
+ while (FDMExec->Run()) {
+ while (FDMExec->ReadMessage()) {
+ msg = FDMExec->ProcessMessage();
+ switch (msg->type) {
+ case FGJSBBase::Message::eText:
+ cout << msg->messageId << ": " << msg->text << endl;
+ break;
+ case FGJSBBase::Message::eBool:
+ cout << msg->messageId << ": " << msg->text << " " << msg->bVal << endl;
+ break;
+ case FGJSBBase::Message::eInteger:
+ cout << msg->messageId << ": " << msg->text << " " << msg->iVal << endl;
+ break;
+ case FGJSBBase::Message::eDouble:
+ cout << msg->messageId << ": " << msg->text << " " << msg->dVal << endl;
+ break;
+ default:
+ cerr << "Unrecognized message type." << endl;
+ break;
+ }
+ }
+ }
delete FDMExec;