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 General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
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.16 2012/03/18 15:48:36 jentron Exp $";
static const char *IdHdr = ID_THRUSTER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec)
-{
- Type = ttDirect;
- SetTransformType(FGForce::tCustom);
-
- EngineNum = 0;
- PropertyManager = FDMExec->GetPropertyManager();
-
- Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMExec)
{
Element* thruster_element = el->GetParent();
Type = ttDirect;
SetTransformType(FGForce::tCustom);
- Name = el->GetName();
+ Name = el->GetAttributeValue("name");
GearRatio = 1.0;
-
+ ReverserAngle = 0.0;
EngineNum = num;
- ThrustCoeff = 0.0;
PropertyManager = FDMExec->GetPropertyManager();
// Determine the initial location and orientation of this thruster and load the
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/c-thrust[%u]", EngineNum);
-// PropertyManager->Tie( property_name, &ThrustCoeff );
+ 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.
+ {
+ property_name = base_property_name + "/reverser-angle-rad";
+ PropertyManager->Tie( property_name.c_str(), (FGThruster *)this, &FGThruster::GetReverserAngle,
+ &FGThruster::SetReverserAngle);
+ }
Debug(0);
}
FGThruster::~FGThruster()
{
-// char property_name[80];
-// snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-// PropertyManager->Untie( property_name );
-
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGThruster::GetThrusterLabels(int id, string delimeter)
+string FGThruster::GetThrusterLabels(int id, const string& delimeter)
{
std::ostringstream buf;
- buf << Name << "_Thrust[" << id << "]";
+ buf << Name << " Thrust (engine " << id << " in lbs)";
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGThruster::GetThrusterValues(int id, string delimeter)
+string FGThruster::GetThrusterValues(int id, const string& delimeter)
{
std::ostringstream buf;