Beispiel #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();
}
Speed* Speed::create(ActionInterval* action, float speed)
{
    Speed *ret = new (std::nothrow) Speed();
    if (ret && ret->initWithAction(action, speed))
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}
Beispiel #3
0
int main(int argc, char** argv) try
{
  Speed speed;
  speed.parseOptions (argc, argv);
  speed.runTest ();
  return 0;
}
 catch (Error& error)
   {
     cerr << error << endl;
     return -1;
   }
Beispiel #4
0
void PreFlightMiscPage::save()
{
  GeneralConfig *conf = GeneralConfig::instance();
  IgcLogger     *log  = IgcLogger::instance();

  if( m_chkLogAutoStart->isChecked() )
    {
      if ( ! log->getIsLogging() )
        {
          // Change logger mode to standby only, if logger is not on.
          log->Standby();
        }
    }
  else
    {
      if (log->getIsStandby())
        {
          log->Stop();
        }
    }

  conf->setLoggerAutostartMode( m_chkLogAutoStart->isChecked() );

  // @AP: Store altitude always as meter.
  if (m_altUnit == Altitude::meters)
    {
      conf->setSafetyAltitude(Altitude(m_edtMinimalArrival->value()));
    }
  else
    {
      Altitude currentAlt; // Altitude will be converted to feet

      currentAlt.setFeet((double) m_edtMinimalArrival->value());
      conf->setSafetyAltitude(currentAlt);
    }

  conf->setArrivalAltitudeDisplay( (GeneralConfig::ArrivalAltitudeDisplay) m_edtArrivalAltitude->itemData(m_edtArrivalAltitude->currentIndex()).toInt() );
  conf->setQNH(m_edtQNH->value());
  conf->setLDCalculationTime(m_edtLDTime->value());
  conf->setBRecordInterval(m_bRecordInterval->value());
  conf->setKRecordInterval(m_kRecordInterval->value());

  if( m_loadedSpeed != m_logAutoStartSpeed->value() )
    {
      Speed speed;
      speed.setValueInUnit( m_logAutoStartSpeed->value(), m_speedUnit );

      // store speed in Km/h
      GeneralConfig::instance()->setAutoLoggerStartSpeed( speed.getKph() );
    }
}
Beispiel #5
0
IEntity<T>				*Speed<T>::clone(double x, double y)
{
  Speed<T> *speed = new Speed<T>(*this);
  speed->setPosX(x);
  speed->setPosY(y);
  speed->setScale(T(10, 10, 10));
  speed->setPosition(T(x, 0, y));
  speed->setRotation(T(0, 0, 0));
  speed->setIsBreakable(true);
  speed->setHitboxSize(1);
  speed->setIsCrossable(true);
  return (speed);
}
Beispiel #6
0
Vector::Vector(double angle, Speed R){
  setAngleRad((float)angle);
  // qDebug("angle:  %f", angle*180/PI);
  _speed=R.getMps();
  // qDebug("_speed:  %f", _speed);
  dirtyDR=false;
  dirtyXY=true;
}
Beispiel #7
0
Speed<T>::Speed(Speed const &other)
{
  this->setPosX(other.getPosX());
  this->setPosY(other.getPosY());
  this->setHitboxSize(other.getHitboxSize());
  this->setIsBreakable(other.isBreakable());
  this->setPosition(other.getPosition());
  this->setRotation(other.getRotation());
  this->setScale(other.getScale());
  this->setIsCrossable(other.isCrossable());
}
Beispiel #8
0
/**
 * This function formats the variometer speed value in meters with sign +/-,
 * 3 numbers with 3 decimal numbers.
 */
QString IgcLogger::formatVario(const Speed vSpeed)
{
  QString result;

  double mps = vSpeed.getMps();

  if( mps == 0.0 )
    {
      result += " ";
    }
  else if( mps > 0.0 )
    {
      result += "+";
    }

  // We need a number with 6 digits and without a decimal point. Therefore
  // the value meter per second is multiplied with 1000.
  result += QString("%1").arg( (int) rint(mps*1000.0), 6, 10, QChar('0') );

  return result;
}
Beispiel #9
0
void make_power()
{
    if(power_available == 0 || power_taken)
        return;
    glPushMatrix();

    if(power_choosen == MAGNET)
    {
        magnet.design(8,power_position.x,power_position.y,power_position.z);
    }

    else if(power_choosen == SPEED)
    {
        speed.design(5,power_position.x,power_position.y,power_position.z);
    }

    else if(power_choosen == INVISIBLE)
    {
        invisible.design(5,power_position.x,power_position.y,power_position.z);
    }

    glPopMatrix();
}
Beispiel #10
0
MetersPerSecond::MetersPerSecond(const Speed& speed) {
    m_metersPerSecond = speed.getMetersPerSecond();
}
 /// Here we use E=1/2m.v²
 Mass::Mass(const Energy& energy,const Speed& speed)
 : m_value(2*energy.Joule()/(speed.MeterPerSecond().length()*speed.MeterPerSecond().length())), 
   m_unit(_Kilogram)
 {}
Beispiel #12
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;
}
Beispiel #13
0
/** * operator for speed. */
Speed
operator *(double left, const Speed& right)
{
  return Speed(left * right.getMps());
}
Beispiel #14
0
void MetersPerSecond::operator+=(const Speed& speed) {
    m_metersPerSecond += speed.getMetersPerSecond();
}
Beispiel #15
0
double MetersPerSecond::operator/(const Speed& speed) const {
    return getMetersPerSecond() / speed.getMetersPerSecond();
}
Beispiel #16
0
MetersPerSecond MetersPerSecond::operator-(const Speed& speed) const {
    return MetersPerSecond(getMetersPerSecond() - speed.getMetersPerSecond());
}
Beispiel #17
0
/** Sets the X (longitudinal) speed in meters per second. */
void Vector::setX(Speed x){
    if (dirtyXY) recalcXY();
    _x=x.getMps();
    dirtyDR=true;
}
Beispiel #18
0
/** Sets the Y (latitudinal) speed in meters per second. */
void Vector::setY(Speed y){
    if (dirtyXY) recalcXY();
    _y=y.getMps();
    dirtyDR=true;
}
Beispiel #19
0
void Animal::Bounce(Speed &speed)
{
	/// Sytuacja, gdy zwierzątko dojdzie do lewego rogu.
	if(position.GetX()<25)
	{
		if(this->Decision(1)) speed.SetDirection(1); //n
		else
		if(this->Decision(8)) speed.SetDirection(8); //ne
		else
		if(this->Decision(6)) speed.SetDirection(6); //se
		else
		if(this->Decision(5)) speed.SetDirection(5); //s
		else
			speed.SetDirection(7); //e	
	} else
	/// Sytuacja, gdy zwierzątko dojdzie do prawego rogu.
	if(position.GetX()>A-50)
	{
		if(this->Decision(1)) speed.SetDirection(1); //n
		else
		if(this->Decision(2)) speed.SetDirection(2); //nw
		else
		if(this->Decision(4)) speed.SetDirection(4); //sw
		else
		if(this->Decision(5)) speed.SetDirection(5); //s
		else
			speed.SetDirection(3); //w	
	} else
	/// Sytuacja, gdy zwierzątko dojdzie do górnego rogu.
	if(position.GetY()<25)
	{
		if(this->Decision(3)) speed.SetDirection(3); //w
		else
		if(this->Decision(4)) speed.SetDirection(4); //sw
		else
		if(this->Decision(5)) speed.SetDirection(5); //s
		else
		if(this->Decision(6)) speed.SetDirection(6); //se
		else
			speed.SetDirection(7); //e
	} else
	/// Sytuacja, gdy zwierzątko dojdzie do dolnego rogu.
	if(position.GetY()>B-50)
	{
		if(this->Decision(3)) speed.SetDirection(3); //w
		else
		if(this->Decision(2)) speed.SetDirection(2); //nw
		else
		if(this->Decision(1)) speed.SetDirection(1); //n
		else
		if(this->Decision(8)) speed.SetDirection(8); //ne
		else
			speed.SetDirection(7); //e
	} 
}
/**
 * @track:      A Track
 * @iter:       Iterator to given Track
 * @is_route:   Is the track of the trackpoint actually a route?
 *
 * Sets the Trackpoint Edit Window to the values of the current trackpoint given in @tpl.
 */
void PropertiesDialogTP::set_dialog_data(Track * track, const TrackPoints::iterator & current_tp_iter, bool is_route)
{
	const HeightUnit height_unit = Preferences::get_unit_height();
	const DistanceUnit distance_unit = Preferences::get_unit_distance();
	const SpeedUnit speed_unit = Preferences::get_unit_speed();

	Trackpoint * tp = *current_tp_iter;

	this->trkpt_name->setEnabled(true);
	this->trkpt_name->setText(tp->name); /* The name may be empty, but we have to do this anyway (e.g. to overwrite non-empty name of previous trackpoint). */

	/* User can insert only if not at the end of track (otherwise use extend track). */
	this->button_insert_tp_after->setEnabled(std::next(current_tp_iter) != track->end());
	this->button_delete_current_tp->setEnabled(true);

	/* We can only split up a track if it's not an endpoint. */
	this->button_split_track->setEnabled(std::next(current_tp_iter) != track->end() && current_tp_iter != track->begin());

	this->button_go_forward->setEnabled(std::next(current_tp_iter) != track->end());
	this->button_go_back->setEnabled(current_tp_iter != track->begin());


	this->lat_entry->setEnabled(true);
	this->lon_entry->setEnabled(true);
	this->alt->setEnabled(true);
	this->timestamp_widget->setEnabled(tp->timestamp.is_valid());

	this->set_dialog_title(track->name);

	this->timestamp_widget->setEnabled(!is_route);
	if (is_route) {
		/* Remove any data that may have been previously displayed. */
		this->timestamp_widget->clear();
	}

	this->sync_to_current_tp_block = true; /* Don't update while setting data. */

	const LatLon lat_lon = tp->coord.get_latlon();
	this->lat_entry->setValue(lat_lon.lat);
	this->lon_entry->setValue(lat_lon.lon);


	this->alt->set_value_iu(tp->altitude);


	this->update_timestamp_widget(tp);

	this->sync_to_current_tp_block = false; /* Can now update after setting data. */


	if (this->cur_tp) {
		const Distance diff = Coord::distance_2(tp->coord, this->cur_tp->coord);
		this->diff_dist->setText(diff.convert_to_unit(Preferences::get_unit_distance()).to_nice_string());

		if (tp->timestamp.is_valid() && this->cur_tp->timestamp.is_valid()) {
			this->diff_time->setText(tr("%1 s").arg((long) (tp->timestamp.get_value() - this->cur_tp->timestamp.get_value())));
			if (tp->timestamp == this->cur_tp->timestamp) {
				this->diff_speed->setText("--");
			} else {
				const double dist = Coord::distance(tp->coord, this->cur_tp->coord);
				const Time duration = Time::get_abs_diff(tp->timestamp, this->cur_tp->timestamp);
				const Speed tmp_speed(dist / duration.get_value(), SpeedUnit::MetresPerSecond);
				this->diff_speed->setText(tmp_speed.to_string());
			}
		} else {
			this->diff_time->setText("");
			this->diff_speed->setText("");
		}
	}


	this->course->setText(tp->course.to_string());
	this->speed->setText(Speed(tp->speed, SpeedUnit::MetresPerSecond).convert_to_unit(speed_unit).to_string());
	this->hdop->setText(Distance(tp->hdop, SupplementaryDistanceUnit::Meters).convert_to_unit(distance_unit).to_nice_string());
	this->pdop->setText(Distance(tp->pdop, SupplementaryDistanceUnit::Meters).convert_to_unit(distance_unit).to_nice_string());
	this->vdop->setText(Altitude(tp->vdop, HeightUnit::Metres).convert_to_unit(height_unit).to_nice_string());
	this->sat->setText(tr("%1 / %2").arg(tp->nsats).arg((int) tp->fix_mode));


	this->cur_tp = tp;
}