Beispiel #1
0
void
MergeThread::Tick()
{
  bool gps_updated, calculated_updated;

#ifdef HAVE_PCM_PLAYER
  bool vario_available;
  double vario;
#endif

  {
    ScopeLock protect(device_blackboard.mutex);

    Process();

    const MoreData &basic = device_blackboard.Basic();

    /* call Driver::OnSensorUpdate() on all devices */
    if (devices != nullptr)
      devices->NotifySensorUpdate(basic);

    /* trigger update if gps has become available or dropped out */
    gps_updated = last_any.location_available != basic.location_available;

    /* trigger a redraw when the connection was just lost, to show the
       new state; when no GPS is connected, no other entity triggers
       the redraw, so we have to do it */
    calculated_updated = (bool)last_any.alive != (bool)basic.alive ||
      (bool)last_any.location_available != (bool)basic.location_available;

#ifdef HAVE_PCM_PLAYER
    vario_available = basic.brutto_vario_available;
    vario = vario_available ? basic.brutto_vario : 0;
#endif

    /* update last_any in every iteration */
    last_any = basic;

    /* update last_fix only when a new GPS fix was received */
    if ((basic.time_available &&
         (!last_fix.time_available || basic.time != last_fix.time)) ||
        basic.location_available != last_fix.location_available)
      last_fix = basic;
  }

#ifdef HAVE_PCM_PLAYER
  if (vario_available)
    AudioVarioGlue::SetValue(vario);
  else
    AudioVarioGlue::NoValue();
#endif

  if (gps_updated)
    TriggerGPSUpdate();

  if (calculated_updated)
    TriggerCalculatedUpdate();

  TriggerVarioUpdate();
}
Beispiel #2
0
void
MergeThread::Tick()
{
  ScopeLock protect(device_blackboard.mutex);

  Process();

  const MoreData &basic = device_blackboard.Basic();
  if (last_any.location_available != basic.location_available)
    // trigger update if gps has become available or dropped out
    TriggerGPSUpdate();

  if ((bool)last_any.alive != (bool)basic.alive ||
      (bool)last_any.location_available != (bool)basic.location_available)
    /* trigger a redraw when the connection was just lost, to show the
       new state; when no GPS is connected, no other entity triggers
       the redraw, so we have to do it */
    TriggerCalculatedUpdate();

  TriggerVarioUpdate();

  /* update last_any in every iteration */
  last_any = basic;

  /* update last_fix only when a new GPS fix was received */
  if ((basic.time_available &&
       (!last_fix.time_available || basic.time != last_fix.time)) ||
      basic.location_available != last_fix.location_available)
    last_fix = basic;
}
/**
 * Main loop of the CalculationThread
 */
void
CalculationThread::Tick()
{
  bool gps_updated;

  // update and transfer master info to glide computer
  {
    ScopeLock protect(device_blackboard->mutex);

    gps_updated = device_blackboard->Basic().location_available.Modified(glide_computer.Basic().location_available);

    // Copy data from DeviceBlackboard to GlideComputerBlackboard
    glide_computer.ReadBlackboard(device_blackboard->Basic());
  }

  {
    ScopeLock protect(mutex);
    // Copy settings form ComputerSettingsBlackboard to GlideComputerBlackboard
    glide_computer.ReadComputerSettings(settings_computer);
    glide_computer.SetScreenDistanceMeters(screen_distance_meters);
  }

  glide_computer.Expire();

  bool do_idle = false;

  if (gps_updated) {
    // perform idle call if time advanced and slow calculations need to be updated
    do_idle |= glide_computer.ProcessGPS();
  }

  // values changed, so copy them back now: ONLY CALCULATED INFO
  // should be changed in DoCalculations, so we only need to write
  // that one back (otherwise we may write over new data)
  {
    ScopeLock protect(device_blackboard->mutex);
    device_blackboard->ReadBlackboard(glide_computer.Calculated());
  }

  // if (new GPS data)
  if (gps_updated) {
    // inform map new data is ready
    TriggerCalculatedUpdate();
  }

  if (do_idle) {
    // do slow calculations last, to minimise latency
    glide_computer.ProcessIdle();
  }
}
Beispiel #4
0
/**
 * Main loop of the CalculationThread
 */
void
CalculationThread::Tick()
{
  const Validity previous_warning =
    glide_computer.Calculated().airspace_warnings.latest;

  bool gps_updated;

  // update and transfer master info to glide computer
  {
    ScopeLock protect(device_blackboard->mutex);

    gps_updated = device_blackboard->Basic().location_available.Modified(glide_computer.Basic().location_available);

    // Copy data from DeviceBlackboard to GlideComputerBlackboard
    glide_computer.ReadBlackboard(device_blackboard->Basic());
  }

  bool force;
  {
    ScopeLock protect(mutex);
    // Copy settings form ComputerSettingsBlackboard to GlideComputerBlackboard
    glide_computer.ReadComputerSettings(settings_computer);

    force = this->force;
    if (force) {
      this->force = false;
      gps_updated = true;
    }
  }

  glide_computer.Expire();

  bool do_idle = false;

  if (gps_updated || force)
    // perform idle call if time advanced and slow calculations need to be updated
    do_idle |= glide_computer.ProcessGPS(force);

  // values changed, so copy them back now: ONLY CALCULATED INFO
  // should be changed in DoCalculations, so we only need to write
  // that one back (otherwise we may write over new data)
  {
    ScopeLock protect(device_blackboard->mutex);
    device_blackboard->ReadBlackboard(glide_computer.Calculated());
  }

  // if (new GPS data)
  if (gps_updated || force)
    // inform map new data is ready
    TriggerCalculatedUpdate();

  if (do_idle) {
    // do slow calculations last, to minimise latency
    glide_computer.ProcessIdle();

    if (glide_computer.Calculated().airspace_warnings.latest != previous_warning) {
      /* there's a new airspace warning */

      {
        ScopeLock protect(device_blackboard->mutex);
        device_blackboard->ReadBlackboard(glide_computer.Calculated());
      }

      TriggerAirspaceWarning();
    }
  }
}