Exemple #1
0
//-------------------------------------------------------------------------
//  Change Selection
//-------------------------------------------------------------------------
void CFuiWind::Select()
{ int No  = windBOX.GetRealSelectedNo();
  sel     = (CWndLine*) windBOX.GetSelectedSlot();
  val     = sel->GetSlot();
  altd    = 0;
  altu    = 50000;
  windMAP.GetPrevX(No,altd);
  windMAP.GetNextX(No,altu);
  return;
}
Exemple #2
0
//=========================================================================
//  Update Temperature, pressure and density from altitude
//  NOTE:  Temperature is adjusted with the local conditions
//         if local condition say 20°C, then temperature is adusted 
//         by the delta (20 - 15) because 15°C is the standard temperature
//         at sea level;  We just make a (certainly) wrong supposition by 
//         saying that temperature is 5° higgher at all altitude
//=========================================================================
void CAtmosphereModelJSBSim::TimeSlice(float dt,double altitude)
{  //---Compute temperature and pressure -----------------------
  //  slot.U = slope
  //  slot.V = Temperature in Rankine
  //  slot.W = pressure (psf)
  C3valSlot *slot = stdATMOS.Getfloor(altitude);
  float slp  = slot->GetU();
  float rfT  = slot->GetV();
  float rfP  = slot->GetW();
  float da   = altitude - slot->GetX();
  float tp   = 0;
  float pr   = 0;
  float dn   = 0;
  //---Compute new targets ---------------------
  if (0 == slp)
  { tp = rfT;
    pr = rfP * exp(-pInertial->SLgravity()/(rfT*Reng)* da);
    dn = pr/ (Reng*tp);
  }
  else 
  { tp = rfT + (slp * da);
    pr = rfP * pow(float(tp/rfT),float(-pInertial->SLgravity()/(slp*Reng)));
    dn = pr/(Reng*tp);
  }
  //--- Get final values -----------------------------------------------
  tempR = tVAL.TimeSlice(dt);
  presS = pVAL.TimeSlice(dt);
  densD = dVAL.TimeSlice(dt);
  //--- Set Target value -----------------------------------------------
  tVAL.Set(tp);
  pVAL.Set(pr);
  dVAL.Set(dn);
  //---Update temperature to various units -----------------------------
  tempC   = RankineToCelsius(tempR) + dtaTC;
  tempF   = CelsiusToFahrenheit(tempC);
  //---Update pressure to various units --------------------------------
  presS  += dtaPS;                    // Add local deviation
  presH   = presS * PSF_TO_INHG;
  presB   = presS * PFS_TO_HPA;
  //--- Update sound speed ---------------------------------------------
  soundspeed = sqrt(SHRatio*Reng*(tempR));
  //--------------------------------------------------------------------
  // test others density
  //densD *= 10.0;
  //cout << "Atmosphere:  h=" << altitude << " rho= " << densD << endl;
//  #ifdef _DEBUG	
//	  FILE *fp_debug;
//	  if(!(fp_debug = fopen("__DDEBUG_atmosphere.txt", "a")) == NULL)
//	  {
//		  int test = 0;
//		  fprintf(fp_debug, "TPD = %f %f %f\n", tempR, presS, densD);
//		  fprintf(fp_debug, "TPD = %f %f %f\n",
//                              RankineToCelsius (tempR),
//                              presS * PSF_TO_INHG,
//                              densD);
//		  fclose(fp_debug); 
//	  }
//  #endif
}
Exemple #3
0
//-------------------------------------------------------------------------
//  Modify Direction
//  Error message
//-------------------------------------------------------------------------
void  CFuiWind::ModifyDirection(float m)
{  float dir = val->GetU() + m;
   dir       = Wrap360(dir);
   int No    = sel->GetSlotNo();
   windMAP.ChangeU(No,dir);
   windBOX.LineRefresh();
   errW->SetText("");
   return;
}
Exemple #4
0
//-------------------------------------------------------------------------
//  Modify speed
//-------------------------------------------------------------------------
void  CFuiWind::ModifySpeed(float m)
{  float spd = val->GetV() + m;
   if (spd <  0)    return;
   if (spd > 80)    return;
   int No    = sel->GetSlotNo();
   windMAP.ChangeV(No,spd);
   windBOX.LineRefresh();
   errW->SetText("");
   return;
}
Exemple #5
0
//-------------------------------------------------------------------------
//  Modify altitude
//  TODO: Error message
//-------------------------------------------------------------------------
void  CFuiWind::ModifyAltitude(float m)
{ float alt = val->GetX() + m;
  if (alt <= altd)   return Error("CANNOT OVERLAY LOWER LAYER");
  if (alt >= altu)   return Error("CANNOT OVERLAY UPPER LAYER");
  //----Must change value and refresh ---------------
  int No = sel->GetSlotNo();
  windMAP.ChangeX(No,alt);
  windBOX.LineRefresh();
  errW->SetText("");
  return;
}
Exemple #6
0
//==============================================================================
//  JSBSIM revisited by JS to unify temperature, presure and all between
//  the aircraft and the weather manager
//==============================================================================
CAtmosphereModelJSBSim::CAtmosphereModelJSBSim (void)
{ //MEMORY_LEAK_MARKER ("pInertial");
  pInertial = new CInertial;
  //MEMORY_LEAK_MARKER ("pInertial");
//  Name = "FGAtmosphere";
  psiw = 0.0;

  MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
  turbType = ttStandard;
  TurbGain = 0.0;
  TurbRate = 1.0;

  //---Load table lookup for standard atmosphere --------
  stdATMOS.Load(stdATPM);
  //---Init base parameters ----------------------------
  InitModel();
  globals->atm  = this;
}
Exemple #7
0
//=========================================================================
//  Update Temperature, pressure and density from altitude
//  NOTE:  Temperature is adjusted with the local conditions
//         if local condition say 20°C, then temperature is adusted 
//         by the delta (20 - 15) because 15°C is the standard temperature
//         at sea level;  We just make a (certainly) wrong supposition by 
//         saying that temperature is 5° higgher at all altitude
//=========================================================================
int CAtmosphereModelJSBSim::TimeSlice(float dt,U_INT frame)
{ double altitude = globals->geop.alt;
	//---Compute temperature and pressure -----------------------
  C3valSlot *slot = stdATMOS.Getfloor(altitude);
  float slp  = slot->GetU();
  float rfT  = slot->GetV();
  float rfP  = slot->GetW();
  float da   = altitude - slot->GetX();
  float tp   = 0;
  float pr   = 0;
  float dn   = 0;
  //---Compute new targets ---------------------
  if (0 == slp)
  { tp = rfT;
    pr = rfP * exp(-pInertial->SLgravity()/(rfT*Reng)* da);
    dn = pr/ (Reng*tp);
  }
  else 
  { tp = rfT + (slp * da);
    pr = rfP * pow(float(tp/rfT),float(-pInertial->SLgravity()/(slp*Reng)));
    dn = pr/(Reng*tp);
  }
  //--- Get final values -----------------------------------------------
  tempR = tVAL.TimeSlice(dt);
  presS = pVAL.TimeSlice(dt);
  densD = dVAL.TimeSlice(dt);
  //--- Set Target value -----------------------------------------------
  tVAL.Set(tp);
  pVAL.Set(pr);
  dVAL.Set(dn);
  //---Update temperature to various units -----------------------------
  tempC   = RankineToCelsius(tempR) + dtaTC;
  tempF   = CelsiusToFahrenheit(tempC);
  //---Update pressure to various units --------------------------------
  presS  += dtaPS;                    // Add local deviation
  presH   = presS * PSF_TO_INHG;
  presB   = presS * PFS_TO_HPA;
  //--- Update sound speed ---------------------------------------------
  soundspeed = sqrt(SHRatio*Reng*(tempR));
	return 1;
}