------------- Copyright (C) 2004 (javky@email.cz) ---------
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 <vector>
+#include <iostream>
#include <sstream>
#include "FGTurboProp.h"
-
#include "FGPropeller.h"
+#include "models/FGPropulsion.h"
+#include "models/FGAuxiliary.h"
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.17 2010/08/21 17:13:48 jberndt Exp $";
static const char *IdHdr = ID_TURBOPROP;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number)
- : FGEngine(exec, el, engine_number)
+ : FGEngine(exec, el, engine_number),
+ ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL)
{
SetDefaults();
FGTurboProp::~FGTurboProp()
{
+ delete ITT_N1;
+ delete EnginePowerRPM_N1;
+ delete EnginePowerVC;
Debug(1);
}
bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
{
- char property_prefix[80];
- snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber);
-
IdleFF=-1;
MaxStartingTime = 999999; //very big timeout -> infinite
Ielu_max_torque=-1;
if (el->FindElement("idlen1"))
IdleN1 = el->FindElementValueAsNumber("idlen1");
if (el->FindElement("idlen2"))
- IdleN2 = el->FindElementValueAsNumber("idlen1");
+ IdleN2 = el->FindElementValueAsNumber("idlen2");
if (el->FindElement("maxn1"))
MaxN1 = el->FindElementValueAsNumber("maxn1");
if (el->FindElement("maxn2"))
// The main purpose of Calculate() is to determine what phase the engine should
// be in, then call the corresponding function.
-double FGTurboProp::Calculate(void)
+void FGTurboProp::Calculate(void)
{
+ RunPreFunctions();
+
TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
- dt = State->Getdt() * Propulsion->GetRate();
+ dt = FDMExec->GetDeltaT() * Propulsion->GetRate();
ThrottleCmd = FCS->GetThrottleCmd(EngineNumber);
}
//printf ("EngHP: %lf / Requi: %lf\n",Eng_HP,Prop_Required_Power);
- return Thruster->Calculate((Eng_HP * hptoftlbssec)-Thruster->GetPowerRequired());
+ PowerAvailable = (Eng_HP * hptoftlbssec) - Thruster->GetPowerRequired();
+
+ Thruster->Calculate(PowerAvailable);
+
+ RunPostFunctions();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGTurboProp::Run(void)
{
- double idlethrust, milthrust, thrust = 0.0, EngPower_HP, eff_coef;
+ double thrust = 0.0, EngPower_HP, eff_coef;
Running = true; Starter = false; EngStarting = false;
//---
double FGTurboProp::CalcFuelNeed(void)
{
- return FuelFlow_pph /3600 * State->Getdt() * Propulsion->GetRate();
+ double dT = FDMExec->GetDeltaT() * Propulsion->GetRate();
+ FuelFlowRate = FuelFlow_pph / 3600.0;
+ FuelExpended = FuelFlowRate * dT;
+ return FuelExpended;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTurboProp::SetDefaults(void)
{
- Name = "Not defined";
+// Name = "Not defined";
N1 = N2 = 0.0;
Type = etTurboprop;
MilThrust = 10000.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGTurboProp::GetEngineLabels(string delimeter)
+string FGTurboProp::GetEngineLabels(const string& delimiter)
{
std::ostringstream buf;
- buf << Name << "_N1[" << EngineNumber << "]" << delimeter
- << Name << "_N2[" << EngineNumber << "]" << delimeter
- << Name << "__PwrAvailJVK[" << EngineNumber << "]" << delimeter
- << Thruster->GetThrusterLabels(EngineNumber, delimeter);
+ buf << Name << "_N1[" << EngineNumber << "]" << delimiter
+ << Name << "_N2[" << EngineNumber << "]" << delimiter
+ << Name << "_PwrAvail[" << EngineNumber << "]" << delimiter
+ << Thruster->GetThrusterLabels(EngineNumber, delimiter);
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGTurboProp::GetEngineValues(string delimeter)
+string FGTurboProp::GetEngineValues(const string& delimiter)
{
std::ostringstream buf;
- buf << N1 << delimeter
- << N2 << delimeter
- << Thruster->GetThrusterValues(EngineNumber,delimeter);
+ buf << PowerAvailable << delimiter
+ << N1 << delimiter
+ << N2 << delimiter
+ << Thruster->GetThrusterValues(EngineNumber,delimiter);
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGTurboProp::bindmodel()
+int FGTurboProp::InitRunning(void)
{
- char property_name[80];
-
-// ToDo: Do a proper Tie here, this should be read only.
-
- snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
- PropertyManager->Tie( property_name, &N1);
- snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
- PropertyManager->Tie( property_name, &N2);
- snprintf(property_name, 80, "propulsion/engine[%u]/reverser", EngineNumber);
- PropertyManager->Tie( property_name, &Reversed);
-
+ FDMExec->SuspendIntegration();
+ Cutoff=false;
+ Running=true;
+ N2=16.0;
+ Calculate();
+ FDMExec->ResumeIntegration();
+ return phase==tpRun;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGTurboProp::unbind()
+void FGTurboProp::bindmodel()
{
- char property_name[80];
-
- snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
- PropertyManager->Untie(property_name);
- snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
- PropertyManager->Untie(property_name);
- snprintf(property_name, 80, "propulsion/engine[%u]/reverser", EngineNumber);
- PropertyManager->Untie(property_name);
+ string property_name, base_property_name;
+ base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+ property_name = base_property_name + "/n1";
+ PropertyManager->Tie( property_name.c_str(), &N1);
+ property_name = base_property_name + "/n2";
+ PropertyManager->Tie( property_name.c_str(), &N2);
+ property_name = base_property_name + "/reverser";
+ PropertyManager->Tie( property_name.c_str(), &Reversed);
}
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print