Esempio n. 1
0
 private void updateVelocity(long deltaTime) {
   if (turnRate > 0) {
     double deltaHeading = (deltaTime * turnRate) / MS_PER_SECOND;
     double newHeading = mCurrentVelocity.Direction() + deltaHeading;
     while (newHeading < 0.0f) newHeading += DEGREES_PER_CIRCLE;
     newHeading %= DEGREES_PER_CIRCLE;
     mCurrentVelocity.SetDirectionAndMagnitude(newHeading, mCurrentVelocity.Magnitude());
   }
 }
Esempio n. 2
0
  private void generateTestData() {

    long currentTime = new Date().getTime();
    if (timeOfLastUpdate == 0) timeOfLastUpdate = currentTime;
    long deltaTime = currentTime - timeOfLastUpdate;

    if (mCurrentAltitude > startAltitude + 200
        && turnRate != 0.0
        && Angle.delta(mCurrentVelocity.Direction(), mWindVelocity.Direction()) < 20) {
      turnRate = 0.0;
      mCurrentVelocity.SetDirectionAndMagnitude(mCurrentVelocity.Direction(), 50);
    } else if (mCurrentAltitude < startAltitude && turnRate == 0.0) {
      turnRate = 15.0;
      mCurrentVelocity.SetDirectionAndMagnitude(mCurrentVelocity.Direction(), 30);
    }

    updateClimbRate();
    updateVelocity(deltaTime);
    updateAltitude(deltaTime);
    updateLocation(deltaTime);

    Vector combinedVelocity = new Vector(mCurrentVelocity).Add(mWindVelocity);
    HashMap<UUID, Double> values = new HashMap<>();

    values.put(MessageChannels.GROUNDSPEED, combinedVelocity.Magnitude() / 3.6);
    values.put(MessageChannels.BEARING, combinedVelocity.Direction());
    values.put(MessageChannels.VARIO, mCurrentClimbRate);
    values.put(MessageChannels.LONGITUDE, mLongitude);
    values.put(MessageChannels.LATITUDE, mLatitude);
    values.put(MessageChannels.ALTITUDE, mCurrentAltitude);

    sendMsg(
        new Configuration(id(), new HashSet<>(values.keySet())),
        new Date().getTime(),
        new DataMessage(values));

    timeOfLastUpdate = currentTime;
  }