Exemplo n.º 1
0
void CuSonde::updateMeasurements(NMEA_INFO *Basic, DERIVED_INFO *Calculated) {
  if (!Calculated->Flying)
    return; // nothing to do..
  if (!Basic->TemperatureAvailable ||
      !Basic->HumidityAvailable) {
    return; // nothing to do..
  }

  // find appropriate level:
  unsigned short level = (unsigned short)(((int)(max(Basic->Altitude,0.0))) / CUSONDE_HEIGHTSTEP);
  if (level>=CUSONDE_NUMLEVELS) {
    return; // out of range
  }

  if (abs(level-last_level)>1) {
    // error, we skipped a step
    last_level = level;
    return;
  }
  if (abs(level-last_level)==0) {
    last_level = level;
    return; // nothing to do, wait until level transition
  }

  RasterTerrain::Lock();
  hGround =
    RasterTerrain::GetTerrainHeight(Basic->Latitude, Basic->Longitude);
  RasterTerrain::Unlock();
  if (hGround == TERRAIN_INVALID) hGround=0; //@ 101027 FIX

  if (level>last_level) {
    // going up
    cslevels[level].updateTemps(Basic->RelativeHumidity,
				Basic->OutsideAirTemperature);
    cslevels[level].updateThermalIndex(level);

    if (level>0) {
      findThermalHeight((unsigned short)(level-1));
      findCloudBase((unsigned short)(level-1));
    }
  } else {
    // going down
    cslevels[level+1].updateTemps(Basic->RelativeHumidity,
				Basic->OutsideAirTemperature);
    cslevels[level+1].updateThermalIndex((unsigned short)(level+1));

    if (level<CUSONDE_NUMLEVELS-1) {
      findThermalHeight(level);
      findCloudBase(level);
    }
  }

  last_level = level;

};
Exemplo n.º 2
0
/**
 * Sets the predicted maximum ground temperature to val
 * @param val New predicted maximum ground temperature in degrees C
 */
void CuSonde::setForecastTemperature(double val) {
  maxGroundTemperature= val;

  int level;
  int zlevel=0;

  // set these to invalid, so old values must be overwritten
  cloudBase = -1;
  thermalHeight = -1;

  // iterate through all levels
  for (level=0; level<CUSONDE_NUMLEVELS; level++) {
    // update the ThermalIndex for each level with
    // the new maxGroundTemperature
    cslevels[level].updateThermalIndex((unsigned short)level, false);

    // determine to which level measurements are available
    if (cslevels[level].nmeasurements) {
      zlevel = level;
    }
    if ((cslevels[level].nmeasurements==0)&&(zlevel)) break;
  }

  // iterate through all levels with measurements
  for (level=0; level<=zlevel; level++) {
    // calculate ThermalHeight
    findThermalHeight((unsigned short)level);
    // calculate CloudBase
    findCloudBase((unsigned short)level);
  }
}
Exemplo n.º 3
0
void CuSonde::setForecastTemperature(double val) {
  maxGroundTemperature= val;

  int level;
  int zlevel=0;

  // set these to invalid, so old values must be overwritten
  cloudBase = -1;
  thermalHeight = -1;

  for (level=0; level<CUSONDE_NUMLEVELS; level++) {
    cslevels[level].updateThermalIndex((unsigned short)level, false);
    if (cslevels[level].nmeasurements) {
      zlevel = level;
    }
    if ((cslevels[level].nmeasurements==0)&&(zlevel)) break;
  }
  for (level=0; level<=zlevel && level<CUSONDE_NUMLEVELS; level++) {
    findThermalHeight((unsigned short)level);
    findCloudBase((unsigned short)level);
  }

}
Exemplo n.º 4
0
/**
 * Update the measurements if new level reached
 * @param Basic NMEA_INFO for temperature and humidity
 * @param Calculated DERIVED_INFO for Flying status
 */
void
CuSonde::updateMeasurements(const NMEA_INFO *Basic,
                            const DERIVED_INFO *Calculated)
{
  // if (not flying) nothing to update...
  if (!Calculated->Flying)
    return;

  // if (no temperature or humidity available) nothing to update...
  if (!Basic->TemperatureAvailable ||
      !Basic->HumidityAvailable) {
    return;
  }

  // find appropriate level
  unsigned short level = (unsigned short)(((int)(max(Basic->Altitude,0))) / CUSONDE_HEIGHTSTEP);
  // if (level out of range) cancel update
  if (level>=CUSONDE_NUMLEVELS) {
    return;
  }

  // if (level skipped) cancel update
  if (abs(level-last_level)>1) {
    last_level = level;
    return;
  }

  // if (no level transition yet) wait for transition
  if (abs(level-last_level)==0) {
    // QUESTION TB: no need for next line?!
    last_level = level;
    return;
  }

  // calculate ground height
  terrain.Lock();
  if (terrain.GetMap()) {
    RasterRounding rounding(*terrain.GetMap(),0,0);
    hGround =
      terrain.GetTerrainHeight(Basic->Location, rounding);
  }
  terrain.Unlock();

  // if (going up)
  if (level>last_level) {
    cslevels[level].updateTemps(Basic->RelativeHumidity,
				Basic->OutsideAirTemperature);
    cslevels[level].updateThermalIndex(level);

    if (level>0) {
      findThermalHeight((unsigned short)(level-1));
      findCloudBase((unsigned short)(level-1));
    }

  // if (going down)
  } else {
    // QUESTION TB: why level+1 and not level?
    cslevels[level+1].updateTemps(Basic->RelativeHumidity,
				Basic->OutsideAirTemperature);
    cslevels[level+1].updateThermalIndex((unsigned short)(level+1));

    if (level<CUSONDE_NUMLEVELS-1) {
      findThermalHeight(level);
      findCloudBase(level);
    }
  }

  last_level = level;
}