]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGThruster.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGThruster.cpp
index 8cf4bf894c09951d798e2e49cd2ce89a6d42c7d0..5af8c1ddd50193ceb8b33b4f3a6542249bec4812 100644 (file)
@@ -5,7 +5,7 @@
  Date started: 08/23/00
  Purpose:      Encapsulates the thruster object
 
- ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -35,13 +35,17 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <iostream>
 #include <sstream>
 
 #include "FGThruster.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGThruster.cpp,v 1.13 2010/08/21 22:56:11 jberndt Exp $";
 static const char *IdHdr = ID_THRUSTER;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -58,7 +62,7 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
   Type = ttDirect;
   SetTransformType(FGForce::tCustom);
 
-  Name = el->GetName();
+  Name = el->GetAttributeValue("name");
 
   GearRatio = 1.0;
   ReverserAngle = 0.0;
@@ -70,26 +74,27 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
 
   element = thruster_element->FindElement("location");
   if (element)  location = element->FindElementTripletConvertTo("IN");
-  else          cerr << "No thruster location found." << endl;
+  else          cerr << fgred << "      No thruster location found." << reset << endl;
 
   element = thruster_element->FindElement("orient");
-  if (element)  orientation = element->FindElementTripletConvertTo("IN");
-  else          cerr << "No thruster orientation found." << endl;
+  if (element)  orientation = element->FindElementTripletConvertTo("RAD");
+  else          cerr << "      No thruster orientation found." << endl;
 
   SetLocation(location);
   SetAnglesToBody(orientation);
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
-  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
-  snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
-  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
+  property_name = base_property_name + "/pitch-angle-rad";
+  PropertyManager->Tie( property_name.c_str(), (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
+  property_name = base_property_name + "/yaw-angle-rad";
+  PropertyManager->Tie( property_name.c_str(), (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
 
   if (el->GetName() == "direct") // this is a direct thruster. At this time
-                                      // only a direct thruster can be reversed.
+                                 // only a direct thruster can be reversed.
   {
-    snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
-    PropertyManager->Tie( property_name, (FGThruster *)this, &FGThruster::GetReverserAngle,
+    property_name = base_property_name + "/reverser-angle-rad";
+    PropertyManager->Tie( property_name.c_str(), (FGThruster *)this, &FGThruster::GetReverserAngle,
                                                           &FGThruster::SetReverserAngle);
   }
 
@@ -100,19 +105,6 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
 
 FGThruster::~FGThruster()
 {
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
-  PropertyManager->Untie( property_name);
-  snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
-  PropertyManager->Untie( property_name);
-
-  if (Type == ttDirect) // this is a direct thruster. At this time
-                                      // only a direct thruster can be reversed.
-  {
-    snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
-    PropertyManager->Untie( property_name);
-  }
-
   Debug(1);
 }
 
@@ -122,7 +114,7 @@ string FGThruster::GetThrusterLabels(int id, string delimeter)
 {
   std::ostringstream buf;
 
-  buf << Name << "_Thrust[" << id << "]";
+  buf << Name << " Thrust (engine " << id << " in lbs)";
 
   return buf.str();
 }