%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGElectric.h"
-#include "FGState.h"
#include "models/FGPropulsion.h"
#include "models/propulsion/FGThruster.h"
+#include "FGPropeller.h"
#include <iostream>
#include <sstream>
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGElectric.cpp,v 1.11 2011/06/06 22:35:08 jentron Exp $";
static const char *IdHdr = ID_ELECTRIC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PowerWatts = 745.7;
hptowatts = 745.7;
- dt = State->Getdt();
+ dt = FDMExec->GetDeltaT();
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)
{
+ RunPreFunctions();
+
Throttle = FCS->GetThrottlePos(EngineNumber);
+ if (Thruster->GetType() == FGThruster::ttPropeller) {
+ ((FGPropeller*)Thruster)->SetAdvance(FCS->GetPropAdvance(EngineNumber));
+ ((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
+ }
+
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
HP = PowerWatts * Throttle / hptowatts;
+
+ Thruster->Calculate(HP * hptoftlbssec);
- PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired();
+ RunPostFunctions();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- return Thruster->Calculate(PowerAvailable);
+double FGElectric::CalcFuelNeed(void)
+{
+ return 0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
-double
-FGElectric::CalcFuelNeed(void)
-{
- return 0;
-}
-
} // namespace JSBSim