Ejemplo n.º 1
0
void PreFlightMiscPage::load()
{
  GeneralConfig *conf = GeneralConfig::instance();

  // @AP: Arrival Altitude is always saved as meter.
  Altitude minArrival = conf->getSafetyAltitude();

  if (m_altUnit == Altitude::meters) // user wants meters
    {
      m_edtMinimalArrival->setValue((int) rint(minArrival.getMeters()));
    }
  else // user gets feet
    {
      m_edtMinimalArrival->setValue((int) rint(minArrival.getFeet()));
    }

  m_edtArrivalAltitude->setCurrentIndex( conf->getArrivalAltitudeDisplay() );

  m_edtQNH->setValue( conf->getQNH() );
  m_edtLDTime->setValue( conf->getLDCalculationTime() );
  m_bRecordInterval->setValue( conf->getBRecordInterval() );
  m_kRecordInterval->setValue( conf->getKRecordInterval() );
  m_chkLogAutoStart->setChecked( conf->getLoggerAutostartMode() );

  Speed speed;
  // speed is stored in Km/h
  speed.setKph( GeneralConfig::instance()->getAutoLoggerStartSpeed() );
  m_logAutoStartSpeed->setValue( speed.getValueInUnit( m_speedUnit ) );

  // save loaded value for change control
  m_loadedSpeed = m_logAutoStartSpeed->value();
}
Ejemplo n.º 2
0
/*
 * https://github.com/LK8000/LK8000/tree/master/Common/Distribution/LK8000/_Polars
 *
 * Format explanation: all lines starting with a * are comments and you can also have empty lines
 *
 * Field 1: Gross weight of the glider, excluded ballast, when the values were measured
 * Field 2: Max ballast you can load (water). It will add wing loading, separately
 * Field 3-4, 5-6, 7-8  are couples of  speed,sink rate  in km/h and m/s .
 * 	these values are used to create an interpolated curve of sink rates
 * Field 9: NEW! Normally winpilot does not have this value. Put here at all cost the glider
 *          surface area in squared meters (m2). If the polar curve you are using does not have
 *          this value, go on wikipedia to find the wing area for that glider and add it after a comma.
 *
 * Here is the REAL polar used internally, that you have to create or change, for a glider
 * that during test flight was weighting 330kg including pilots and everything, that can load
 * extra 90 liters of water ballast, that at 75km/h has a sink rate of 0.7 m/s , at 93 km/h of 0,74
 * at 185 km/h sinks at 3.1 m/s and finally that has a wing surface of 10.6 m2.
 * Thus, the polar was calculated with a default wing loading of 31.1 kg/m2

 * So this is an example
 *
 * 330,	90,	75.0,	-0.7,	93.0,	-0.74,	185.00,	-3.1, 10.6
 *
 * Speed Astir.plr file content
 *
 * LK8000 polar for: Speed Astir
 * MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3, WingArea[m2]
 * 351,  90,  90, -0.63, 105, -0.72, 157, -2.00, 11.5   // BestLD40@105
 *
 */
bool GliderEditorNumPad::readLK8000PolarFile( const QString& fileName, Polar& polar )
{
  QFile polarFile( fileName );

  if( polarFile.exists() == false )
    {
      qWarning() << "readLK8000PolarFile:" << fileName << "does not exists!";
      return false;
    }

  if( polarFile.open(QIODevice::ReadOnly) == false )
    {
      qWarning() << "readLK8000PolarFile:" << fileName << "is not readable!";
      return false;
    }

  // We take the polar file name as gilder type name. The type description
  // is sometimes missing in the file.
  QString name = QFileInfo(fileName).completeBaseName();
  polar.setName( name );

  if( name.contains( "PAS") )
    {
      // Polar of a double seater was selected
      polar.setSeats( 2 );
    }

  QTextStream stream( &polarFile );

  int lineNo = 0;

  while( !stream.atEnd() )
    {
      QString line = stream.readLine().trimmed();
      lineNo++;

      if( line.isEmpty() || line.startsWith("*") || line.startsWith("//") )
	{
	  continue;
	}

      // Lines can contain at their right end C++ comments. This part must be
      // removed first.
      QStringList items = line.split( "//" );
      items = items.at(0).split( ",", QString::SkipEmptyParts );

      if( items.size() < 9 )
	{
	  qWarning() << "Polar file"
	             << QFileInfo(fileName).fileName()
	             << "line"
	             << lineNo
	             << "contains to less items:"
	             << line;

	  polarFile.close();
	  return false;
	}

      // Extract data, Example is from Spped Astir.
      // MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3, WingArea[m2]
      // 351,  90,  90, -0.63, 105, -0.72, 157, -2.00, 11.5   // BestLD40@105
      for( int i = 0; i < 9; i++ )
	{
	  bool ok;
	  double dv = items.at(i).trimmed().toDouble(&ok);

	  Speed speed;

	  if( ! ok )
	    {
	      polarFile.close();
	      return false;
	    }

	  switch(i)
	  {
	    case 0:
	      polar.setGrossWeight( dv );
	      break;

	    case 1:
	      polar.setMaxWater( rint(dv) );
	      break;

	    case 2:
	      speed.setKph( dv );
	      polar.setV1( speed );
	      break;

	    case 3:
	      speed.setMps( dv );
	      polar.setW1( speed );
	      break;

	    case 4:
	      speed.setKph( dv );
	      polar.setV2( speed );
	      break;

	    case 5:
	      speed.setMps( dv );
	      polar.setW2( speed );
	      break;

	    case 6:
	      speed.setKph( dv );
	      polar.setV3( speed );
	      break;

	    case 7:
	      speed.setMps( dv );
	      polar.setW3( speed );
	      break;

	    case 8:
	      polar.setWingArea( dv );
	      break;

	    default:
	      break;
	  }
	}

      polar.recalculatePolarData();
      polarFile.close();
      return true;
    }

  polarFile.close();
  qWarning() << "readLK8000PolarFile:" << fileName << "contains no polar data!";
  return false;
}