%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGAuxiliary.h"
+#include "FGAerodynamics.h"
#include "FGTranslation.h"
#include "FGRotation.h"
#include "FGAtmosphere.h"
#include "FGMatrix33.h"
#include "FGColumnVector3.h"
#include "FGColumnVector4.h"
+#include "FGPropertyManager.h"
+
+namespace JSBSim {
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_AUXILIARY;
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAuxiliary";
- vcas = veas = mach = qbar = pt = 0;
+ vcas = veas = mach = qbar = pt = tat = 0;
psl = rhosl = 1;
earthPosAngle = 0.0;
- if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
+ vPilotAccelN.InitMatrix();
+
+ bind();
+
+ Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGAuxiliary::~FGAuxiliary()
{
- if (debug_lvl & 2) cout << "Destroyed: FGAuxiliary" << endl;
+ unbind();
+ Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (!FGModel::Run()) {
GetState();
+
+ //calculate total temperature assuming isentropic flow
+ tat=sat*(1 + 0.2*mach*mach);
+ tatc=RankineToCelsius(tat);
+
if (mach < 1) { //calculate total pressure assuming isentropic flow
- pt=p*pow((1 + 0.2*mach*mach),3.5);
+ pt = p*pow((1 + 0.2*machU*machU),3.5);
} else {
// shock in front of pitot tube, we'll assume its normal and use
// the Rayleigh Pitot Tube Formula, i.e. the ratio of total
// pressure behind the shock to the static pressure in front
- B = 5.76*mach*mach/(5.6*mach*mach - 0.8);
+ B = 5.76*machU*machU/(5.6*machU*machU - 0.8);
// The denominator above is zero for Mach ~ 0.38, for which
// we'll never be here, so we're safe
- D = (2.8*mach*mach-0.4)*0.4167;
+ D = (2.8*machU*machU-0.4)*0.4167;
pt = p*pow(B,3.5)*D;
}
A = pow(((pt-p)/psl+1),0.28571);
- vcas = sqrt(7*psl/rhosl*(A-1));
- veas = sqrt(2*qbar/rhosl);
+ if (machU > 0.0) {
+ vcas = sqrt(7*psl/rhosl*(A-1));
+ veas = sqrt(2*qbar/rhosl);
+ } else {
+ vcas = veas = 0.0;
+ }
// Pilot sensed accelerations are calculated here. This is used
// for the coordinated turn ball instrument. Motion base platforms sometimes
// mass, the acceleration vector is calculated. The term wdot is equivalent
// to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
// The radius R is calculated below in the vector vToEyePt.
-
- vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
+
+ vPilotAccel.InitMatrix();
+ if ( Translation->GetVt() > 1 ) {
+ vPilotAccel = Aerodynamics->GetForces()
+ + Propulsion->GetForces()
+ + GroundReactions->GetForces();
+ vPilotAccel /= MassBalance->GetMass();
+ vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep());
+ vPilotAccel += Rotation->GetPQRdot() * vToEyePt;
+ vPilotAccel += Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt);
+ } else {
+ vPilotAccel = -1*( State->GetTl2b() * Inertial->GetGravity() );
+ }
- vPilotAccel = Aircraft->GetBodyAccel()
- + Rotation->GetPQRdot() * vToEyePt
- + Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt)
- + Inertial->GetGravity();
+ vPilotAccelN = vPilotAccel/Inertial->gravity();
earthPosAngle += State->Getdt()*Inertial->omega();
return false;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3 FGAuxiliary::GetNpilot(void)
+void FGAuxiliary::bind(void)
{
- return vPilotAccel/Inertial->gravity();
+ typedef double (FGAuxiliary::*PMF)(int) const;
+ PropertyManager->Tie("velocities/vc-fps", this,
+ &FGAuxiliary::GetVcalibratedFPS);
+ PropertyManager->Tie("velocities/vc-kts", this,
+ &FGAuxiliary::GetVcalibratedKTS);
+ PropertyManager->Tie("velocities/ve-fps", this,
+ &FGAuxiliary::GetVequivalentFPS);
+ PropertyManager->Tie("velocities/ve-kts", this,
+ &FGAuxiliary::GetVequivalentKTS);
+ PropertyManager->Tie("velocities/machU", this,
+ &FGAuxiliary::GetMachU);
+ PropertyManager->Tie("velocities/tat-r", this,
+ &FGAuxiliary::GetTotalTemperature);
+ PropertyManager->Tie("velocities/tat-c", this,
+ &FGAuxiliary::GetTAT_C);
+ PropertyManager->Tie("velocities/pt-lbs_sqft", this,
+ &FGAuxiliary::GetTotalPressure);
+
+ PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this,1,
+ (PMF)&FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this,2,
+ (PMF)&FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this,3,
+ (PMF)&FGAuxiliary::GetPilotAccel);
+ PropertyManager->Tie("accelerations/n-pilot-x-norm", this,1,
+ (PMF)&FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("accelerations/n-pilot-y-norm", this,2,
+ (PMF)&FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("accelerations/n-pilot-z-norm", this,3,
+ (PMF)&FGAuxiliary::GetNpilot);
+ PropertyManager->Tie("position/epa-rad", this,
+ &FGAuxiliary::GetEarthPositionAngle);
+ /* PropertyManager->Tie("atmosphere/headwind-fps", this,
+ &FGAuxiliary::GetHeadWind,
+ true);
+ PropertyManager->Tie("atmosphere/crosswind-fps", this,
+ &FGAuxiliary::GetCrossWind,
+ true); */
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGAuxiliary::GetNpilot(int idx)
+void FGAuxiliary::unbind(void)
{
- return (vPilotAccel/Inertial->gravity())(idx);
+ PropertyManager->Untie("velocities/vc-fps");
+ PropertyManager->Untie("velocities/vc-kts");
+ PropertyManager->Untie("velocities/ve-fps");
+ PropertyManager->Untie("velocities/ve-kts");
+ PropertyManager->Untie("velocities/machU");
+ PropertyManager->Untie("velocities/tat-r");
+ PropertyManager->Untie("velocities/tat-c");
+ PropertyManager->Untie("accelerations/a-pilot-x-ft_sec2");
+ PropertyManager->Untie("accelerations/a-pilot-y-ft_sec2");
+ PropertyManager->Untie("accelerations/a-pilot-z-ft_sec2");
+ PropertyManager->Untie("accelerations/n-pilot-x-norm");
+ PropertyManager->Untie("accelerations/n-pilot-y-norm");
+ PropertyManager->Untie("accelerations/n-pilot-z-norm");
+ PropertyManager->Untie("position/epa-rad");
+ /* PropertyManager->Untie("atmosphere/headwind-fps");
+ PropertyManager->Untie("atmosphere/crosswind-fps"); */
+
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
qbar = Translation->Getqbar();
mach = Translation->GetMach();
+ machU= Translation->GetMachU();
p = Atmosphere->GetPressure();
rhosl = Atmosphere->GetDensitySL();
psl = Atmosphere->GetPressureSL();
+ sat = Atmosphere->GetTemperature();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to output any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
void FGAuxiliary::Debug(int from)
{
- //TODO: Add your source code here
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGAuxiliary" << endl;
+ if (from == 1) cout << "Destroyed: FGAuxiliary" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
}
+} // namespace JSBSim