示例#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
}
示例#2
0
bool 
AbortTask::update_sample(const AIRCRAFT_STATE &state, 
                         const bool full_update)
{
  update_polar();
  clear();

  const unsigned active_waypoint_on_entry = active_waypoint;
  activeTaskPoint = 0; // default to best result if can't find user-set one 

  AlternateVector approx_waypoints; 

  WaypointVisitorVector wvv(approx_waypoints);
  waypoints.visit_within_radius(state.Location, abort_range(state), wvv);
  if (!approx_waypoints.size()) {
    /**
     * \todo
     * - increase range
     */
    return false;
  }

  // sort by alt difference

  // first try with safety polar, final glide only
  m_landable_reachable|=  fill_reachable(state, approx_waypoints, polar_safety, true, true);
  m_landable_reachable|=  fill_reachable(state, approx_waypoints, polar_safety, false, true);

  // now try with non-safety polar
  fill_reachable(state, approx_waypoints, glide_polar, true, false);
  fill_reachable(state, approx_waypoints, glide_polar, false, false);

  // now try with fake height added
  AIRCRAFT_STATE fake = state;
  fake.NavAltitude += fixed(10000.0);
  fill_reachable(fake, approx_waypoints, glide_polar, true, false);
  fill_reachable(fake, approx_waypoints, glide_polar, false, false);

  if (tps.size()) {
    active_waypoint = tps[activeTaskPoint].first->get_waypoint().id;
    if (active_waypoint_on_entry != active_waypoint) {
      task_events.active_changed(*(tps[activeTaskPoint].first));
    }
  }

  return false; // nothing to do
}
示例#3
0
void 
AbortTask::update_offline(const AIRCRAFT_STATE &state)
{
  update_polar();
  m_landable_reachable = false;

  AlternateVector approx_waypoints; 

  WaypointVisitorVector wvv(approx_waypoints);
  waypoints.visit_within_radius(state.Location, abort_range(state), wvv);

  for (AlternateVector::iterator v = approx_waypoints.begin();
       v!=approx_waypoints.end(); ++v) {

    UnorderedTaskPoint t(v->first, task_behaviour);
    const GlideResult result = TaskSolution::glide_solution_remaining(t, state, polar_safety);
    if (is_reachable(result, true)) {
      m_landable_reachable = true;
      return;
    }
  }
}
示例#4
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
}