--------- Copyright (C) 2004 David Culp (davidculp2@comcast.net) -------------
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 "FGElectric.h"
-#include <models/FGPropulsion.h>
+#include "FGPropeller.h"
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGElectric.cpp,v 1.13 2011/08/03 03:21:06 jberndt Exp $";
static const char *IdHdr = ID_ELECTRIC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-FGElectric::FGElectric(FGFDMExec* exec, Element *el, int engine_number)
- : FGEngine(exec, el, engine_number)
+FGElectric::FGElectric(FGFDMExec* exec, Element *el, int engine_number, struct FGEngine::Inputs& input)
+ : FGEngine(exec, el, engine_number, input)
{
string token;
PowerWatts = 745.7;
hptowatts = 745.7;
- dt = State->Getdt();
-
if (el->FindElement("power"))
PowerWatts = el->FindElementValueAsNumberConvertTo("power","WATTS");
+ string property_name, base_property_name;
+ base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+ property_name = base_property_name + "/power-hp";
+ PropertyManager->Tie(property_name, &HP);
+
Debug(0); // Call Debug() routine from constructor if needed
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGElectric::Calculate(void)
+void FGElectric::Calculate(void)
{
- Throttle = FCS->GetThrottlePos(EngineNumber);
+ RunPreFunctions();
+
+ if (Thruster->GetType() == FGThruster::ttPropeller) {
+ ((FGPropeller*)Thruster)->SetAdvance(in.PropAdvance[EngineNumber]);
+ ((FGPropeller*)Thruster)->SetFeather(in.PropFeather[EngineNumber]);
+ }
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
- HP = PowerWatts * Throttle / hptowatts;
+ HP = PowerWatts * in.ThrottlePos[EngineNumber] / hptowatts;
+
+ LoadThrusterInputs();
+ Thruster->Calculate(HP * hptoftlbssec);
- PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired();
+ RunPostFunctions();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- return Thruster->Calculate(PowerAvailable);
+double FGElectric::CalcFuelNeed(void)
+{
+ return 0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGElectric::GetEngineLabels(string delimeter)
+string FGElectric::GetEngineLabels(const string& delimiter)
{
- return ""; // currently no labels are returned for this engine
+ std::ostringstream buf;
+
+ buf << Name << " HP (engine " << EngineNumber << ")" << delimiter
+ << Thruster->GetThrusterLabels(EngineNumber, delimiter);
+
+ return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGElectric::GetEngineValues(string delimeter)
+string FGElectric::GetEngineValues(const string& delimiter)
{
- return ""; // currently no values are returned for this engine
+ std::ostringstream buf;
+
+ buf << HP << delimiter
+ << Thruster->GetThrusterValues(EngineNumber, delimiter);
+
+ return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
-double
-FGElectric::CalcFuelNeed(void)
-{
- return 0;
-}
-
} // namespace JSBSim