Beispiel #1
0
bool 
AbortTask::UpdateSample(const AircraftState &state,
                        const GlidePolar &glide_polar,
                        bool full_update)
{
  Clear();

  unsigned active_waypoint_on_entry;
  if (is_active)
    active_waypoint_on_entry = active_waypoint;
  else {
    active_waypoint = 0;
    active_waypoint_on_entry = (unsigned) -1 ;
  }

  active_task_point = 0; // default to best result if can't find user-set one 

  AlternateVector approx_waypoints; 
  approx_waypoints.reserve(128);

  WaypointVisitorVector wvv(approx_waypoints);
  waypoints.VisitWithinRange(state.location,
                             GetAbortRange(state, glide_polar), wvv);
  if (approx_waypoints.empty()) {
    /** @todo increase range */
    return false;
  }

  // sort by arrival time

  // first try with final glide only
  reachable_landable |=  FillReachable(state, approx_waypoints, glide_polar,
                                       true, true, true);
  reachable_landable |=  FillReachable(state, approx_waypoints, glide_polar,
                                       false, true, true);

  // inform clients that the landable reachable scan has been performed 
  ClientUpdate(state, true);

  // now try without final glide constraint and not preferring airports
  FillReachable(state, approx_waypoints, glide_polar, false, false, false);

  // inform clients that the landable unreachable scan has been performed 
  ClientUpdate(state, false);

  if (task_points.size()) {
    const TaskWaypoint &task_point = task_points[active_task_point];
    active_waypoint = task_point.GetWaypoint().id;
    if (is_active && (active_waypoint_on_entry != active_waypoint)) {
      if (task_events != NULL)
        task_events->ActiveChanged(task_point);
      return true;
    }
  }

  return false; // nothing to do
}
Beispiel #2
0
bool 
AbortTask::UpdateSample(const AircraftState &state, bool full_update)
{
  UpdatePolar(state.wind);
  Clear();

  const unsigned active_waypoint_on_entry =
      is_active ? active_waypoint : (unsigned)-1;

  active_task_point = 0; // default to best result if can't find user-set one 

  AlternateVector approx_waypoints; 
  approx_waypoints.reserve(128);

  WaypointVisitorVector wvv(approx_waypoints);
  waypoints.VisitWithinRange(state.location, GetAbortRange(state), wvv);
  if (approx_waypoints.empty()) {
    /** @todo increase range */
    return false;
  }

  // lookup the appropriate polar to use
  const GlidePolar* mode_polar;
  switch (task_behaviour.route_planner.reach_polar_mode) {
  case RoutePlannerConfig::rpmTask:
    mode_polar = &glide_polar;
    // make copy to avoid waste
    break;
  case RoutePlannerConfig::rpmSafety:
    mode_polar = &polar_safety;
    break;
  default:
    assert(false);
    return false;
  }
  assert(mode_polar);

  // sort by alt difference

  // first try with final glide only
  reachable_landable |=  FillReachable(state, approx_waypoints, *mode_polar,
                                       true, true, true);
  reachable_landable |=  FillReachable(state, approx_waypoints, *mode_polar,
                                       false, true, true);

  // inform clients that the landable reachable scan has been performed 
  ClientUpdate(state, true);

  // now try without final glide constraint and not preferring airports
  FillReachable(state, approx_waypoints, *mode_polar, false, false, false);

  // inform clients that the landable unreachable scan has been performed 
  ClientUpdate(state, false);

  if (task_points.size()) {
    const TaskWaypoint &task_point = task_points[active_task_point];
    active_waypoint = task_point.GetWaypoint().id;
    if (is_active && (active_waypoint_on_entry != active_waypoint)) {
      task_events.ActiveChanged(task_point);
      return true;
    }
  }

  return false; // nothing to do
}