コード例 #1
0
ファイル: ProcessTimer.cpp プロジェクト: Plantain/XCSoar
int
ProcessTimer::ConnectionProcessTimer(int itimeout)
{
  devConnectionMonitor();

  static bool connected_last = false;
  static bool wait_connect = false;
  static bool wait_lock = false;

  if (!Basic().gps.Connected) {
    // if gps is not connected, set navwarning to true so
    // calculations flight timers don't get updated
    device_blackboard.SetNAVWarning(true);
  }

  bool connected_now = device_blackboard.LowerConnection();
  if (connected_now && Basic().gps.NAVWarning) {
    if (!wait_lock) {
      // waiting for lock first time
      wait_lock = true;
      itimeout = 0;
      InputEvents::processGlideComputer(GCE_GPS_FIX_WAIT);
#ifndef DISABLEAUDIO
      MessageBeep(MB_ICONEXCLAMATION);
#endif
    }

    // If GPS connected but no lock, must be in hangar
    if (InterfaceTimeoutCheck()) {
      if (is_altair()) {
        // TODO feature: ask question about shutdown or give warning
        // then shutdown if no activity.
        // Shutdown();
      }
    }
  } else if (connected_now) {
    // !navwarning
    wait_connect = false;
    wait_lock = false;
    itimeout = 0;
  } else {
    // not connected
    wait_lock = false;
  }

  if (!connected_now && !connected_last) {
    AllDevicesLinkTimeout();

    if (!wait_connect) {
      // gps is waiting for connection first time
      wait_connect = true;
      InputEvents::processGlideComputer(GCE_GPS_CONNECTION_WAIT);
#ifndef DISABLEAUDIO
      MessageBeep(MB_ICONEXCLAMATION);
#endif
    } else if (itimeout % 60 == 0) {
      itimeout = 0;
      // we've been waiting for connection a long time
      // no activity for 30 seconds, so assume PDA has been
      // switched off and on again
      //
#ifdef _WIN32_WCE
      if (!is_altair()) {
        InputEvents::processGlideComputer(GCE_COMMPORT_RESTART);
        devRestart();
      }
#endif
    }
  }

  connected_last = connected_now;
  return itimeout;
}
コード例 #2
0
ファイル: UtilsSettings.cpp プロジェクト: hnpilot/XCSoar
static void
SettingsLeave()
{
  if (!globalRunningEvent.test())
    return;

  XCSoarInterface::main_window.map.set_focus();

  SuspendAllThreads();

  if (MapFileChanged) {
    AirspaceFileChanged = true;
    AirfieldFileChanged = true;
    WaypointFileChanged = true;
    TerrainFileChanged = true;
    TopologyFileChanged = true;
  }

  if ((WaypointFileChanged) || (TerrainFileChanged) || (AirfieldFileChanged)) {
    ProgressGlue::Create(_("Loading Terrain File..."));

    XCSoarInterface::main_window.map.set_terrain(NULL);

    // re-load terrain
    delete terrain;
    terrain = RasterTerrain::OpenTerrain(file_cache);

    // re-load waypoints
    WayPointGlue::ReadWaypoints(way_points, terrain);
    ReadAirfieldFile(way_points);

    // re-set home
    if (WaypointFileChanged || TerrainFileChanged) {
      WayPointGlue::SetHome(way_points, terrain,
                            XCSoarInterface::SetSettingsComputer(),
                            WaypointFileChanged, false);
    }

    if (terrain != NULL) {
      RasterTerrain::UnprotectedLease lease(*terrain);
      lease->SetViewCenter(XCSoarInterface::Basic().Location);
    }

    XCSoarInterface::main_window.map.set_terrain(terrain);
  }

  if (TopologyFileChanged)
    LoadConfiguredTopology(*topology);

  if (AirspaceFileChanged) {
    airspace_warnings.clear();
    airspace_database.clear();
    ReadAirspace(airspace_database, terrain,
                 XCSoarInterface::Basic().pressure);
  }

  if (PolarFileChanged) {
    GlidePolar gp = protected_task_manager.get_glide_polar();
    if (LoadPolarById(XCSoarInterface::SettingsComputer(), gp)) {
      protected_task_manager.set_glide_polar(gp);
    }
  }

  {
    ProtectedTaskManager::ExclusiveLease lease(protected_task_manager);
    lease->set_olc_rules(XCSoarInterface::SettingsComputer().olc_rules);
  }

  if (AirfieldFileChanged
      || AirspaceFileChanged
      || WaypointFileChanged
      || TerrainFileChanged
      || TopologyFileChanged) {
    ProgressGlue::Close();
    XCSoarInterface::main_window.map.set_focus();
    draw_thread->trigger_redraw();
  }

  if (DevicePortChanged)
    devRestart();

  ResumeAllThreads();
  // allow map and calculations threads to continue
}
コード例 #3
0
static void
SettingsLeave(const UISettings &old_ui_settings)
{
  if (!globalRunningEvent.Test())
    return;

  SuspendAllThreads();

  VerboseOperationEnvironment operation;

  MainWindow &main_window = XCSoarInterface::main_window;

  if (LanguageChanged)
    ReadLanguageFile();

  if (MapFileChanged) {
    /* set these flags, because they may be loaded from the map
       file */
    AirspaceFileChanged = true;
    AirfieldFileChanged = true;
    WaypointFileChanged = true;
    TerrainFileChanged = true;
    TopographyFileChanged = true;
  }

  if (TerrainFileChanged) {
    operation.SetText(_("Loading Terrain File..."));

    main_window.SetTerrain(NULL);
    glide_computer->SetTerrain(NULL);

    // re-load terrain
    delete terrain;
    terrain = RasterTerrain::OpenTerrain(file_cache, operation);

    main_window.SetTerrain(terrain);
    glide_computer->SetTerrain(terrain);
  }

  if (WaypointFileChanged || AirfieldFileChanged) {
    // re-load waypoints
    WaypointGlue::LoadWaypoints(way_points, terrain, operation);
    WaypointDetails::ReadFileFromProfile(way_points, operation);
  }

  if (WaypointFileChanged && protected_task_manager != NULL) {
    ProtectedTaskManager::ExclusiveLease lease(*protected_task_manager);
    OrderedTask *task = lease->Clone(XCSoarInterface::GetComputerSettings().task);
    if (task) {
      // this must be done in thread lock because it potentially changes the
      // waypoints database
      task->CheckDuplicateWaypoints(way_points);

      /* XXX shall this task be committed if it has been modified? */
      delete task;

      way_points.Optimise();
    }
  }

  if (WaypointFileChanged || TerrainFileChanged) {
    // re-set home
    WaypointGlue::SetHome(way_points, terrain,
                          XCSoarInterface::SetComputerSettings(),
                          device_blackboard, WaypointFileChanged);
    WaypointGlue::SaveHome(CommonInterface::GetComputerSettings());
  }

  if (TopographyFileChanged) {
    main_window.SetTopography(NULL);
    topography->Reset();
    LoadConfiguredTopography(*topography, operation);
    main_window.SetTopography(topography);
  }

  if (AirspaceFileChanged) {
    if (glide_computer != NULL)
      glide_computer->GetAirspaceWarnings().clear();

    if (glide_computer != NULL)
      glide_computer->ClearAirspaces();

    airspace_database.clear();
    ReadAirspace(airspace_database, terrain,
                 CommonInterface::GetComputerSettings().pressure,
                 operation);
  }

  if (DevicePortChanged)
    devRestart();

  const UISettings &ui_settings = CommonInterface::GetUISettings();

  Units::SetConfig(ui_settings.units);

  const MapSettings &old_settings_map = old_ui_settings.map;
  const MapSettings &settings_map = ui_settings.map;

  if (settings_map.snail_type != old_settings_map.snail_type ||
      settings_map.snail_scaling_enabled != old_settings_map.snail_scaling_enabled)
    main_window.SetLook().map.trail.Initialise(settings_map);

  if (settings_map.waypoint.landable_style != old_settings_map.waypoint.landable_style)
    main_window.SetLook().map.waypoint.Initialise(settings_map.waypoint);

  ResumeAllThreads();
  CommonInterface::main_window.ResumeThreads();
  // allow map and calculations threads to continue

  ActionInterface::SendMapSettings(true);

  operation.Hide();
  InfoBoxManager::SetDirty();
  main_window.full_redraw();
  main_window.SetDefaultFocus();
}
コード例 #4
0
ファイル: UtilsSettings.cpp プロジェクト: CnZoom/XcSoarPull
static void
SettingsLeave(const UISettings &old_ui_settings)
{
  if (!global_running)
    return;

  SuspendAllThreads();

  VerboseOperationEnvironment operation;

  MainWindow &main_window = *CommonInterface::main_window;

  if (LanguageChanged)
    ReadLanguageFile();

  bool TerrainFileChanged = false, TopographyFileChanged = false;
  if (MapFileChanged) {
    /* set these flags, because they may be loaded from the map
       file */
    AirspaceFileChanged = true;
    AirfieldFileChanged = true;
    WaypointFileChanged = true;
    TerrainFileChanged = true;
    TopographyFileChanged = true;
  }

  if (TerrainFileChanged) {
    operation.SetText(_("Loading Terrain File..."));

    /* just in case the bottom widget uses the old terrain object
       (e.g. the cross section) */
    main_window.SetBottomWidget(nullptr);

    main_window.SetTerrain(NULL);
    glide_computer->SetTerrain(NULL);

    // re-load terrain
    delete terrain;
    terrain = RasterTerrain::OpenTerrain(file_cache, operation);

    main_window.SetTerrain(terrain);
    glide_computer->SetTerrain(terrain);

    /* re-create the bottom widget if it was deleted here */
    PageActions::Update();
  }

  if (WaypointFileChanged || AirfieldFileChanged) {
    // re-load waypoints
    WaypointGlue::LoadWaypoints(way_points, terrain, operation);
    WaypointDetails::ReadFileFromProfile(way_points, operation);
  }

  if (WaypointFileChanged && protected_task_manager != NULL) {
    ProtectedTaskManager::ExclusiveLease lease(*protected_task_manager);
    OrderedTask *task = lease->Clone(CommonInterface::GetComputerSettings().task);
    if (task) {
      // this must be done in thread lock because it potentially changes the
      // waypoints database
      task->CheckDuplicateWaypoints(way_points);

      /* XXX shall this task be committed if it has been modified? */
      delete task;

      way_points.Optimise();
    }
  }

  if (WaypointFileChanged || TerrainFileChanged) {
    // re-set home
    WaypointGlue::SetHome(way_points, terrain,
                          CommonInterface::SetComputerSettings().poi,
                          CommonInterface::SetComputerSettings().team_code,
                          device_blackboard, WaypointFileChanged);
    WaypointGlue::SaveHome(Profile::map,
                           CommonInterface::GetComputerSettings().poi,
                           CommonInterface::GetComputerSettings().team_code);
  }

  if (TopographyFileChanged) {
    main_window.SetTopography(NULL);
    topography->Reset();
    LoadConfiguredTopography(*topography, operation);
    main_window.SetTopography(topography);
  }

  if (AirspaceFileChanged) {
    if (glide_computer != NULL)
      glide_computer->GetAirspaceWarnings().Clear();

    if (glide_computer != NULL)
      glide_computer->ClearAirspaces();

    airspace_database.Clear();
    ReadAirspace(airspace_database, terrain,
                 CommonInterface::GetComputerSettings().pressure,
                 operation);
  }

  if (DevicePortChanged)
    devRestart();

  const UISettings &ui_settings = CommonInterface::GetUISettings();

  Units::SetConfig(ui_settings.format.units);
  SetUserCoordinateFormat(ui_settings.format.coordinate_format);

  const MapSettings &old_settings_map = old_ui_settings.map;
  const MapSettings &settings_map = ui_settings.map;

  if (settings_map.trail.type != old_settings_map.trail.type ||
      settings_map.trail.scaling_enabled != old_settings_map.trail.scaling_enabled)
    main_window.SetLook().map.trail.Initialise(settings_map.trail);

  if (settings_map.waypoint.landable_style != old_settings_map.waypoint.landable_style)
    main_window.SetLook().map.waypoint.Reinitialise(settings_map.waypoint);

  ResumeAllThreads();
  main_window.ResumeThreads();
  // allow map and calculations threads to continue

  ActionInterface::SendMapSettings(true);

  AudioVarioGlue::Configure(CommonInterface::GetUISettings().sound.vario);

  operation.Hide();
  InfoBoxManager::SetDirty();
  main_window.FlushRendererCaches();
  main_window.FullRedraw();
  main_window.SetDefaultFocus();
}