Exemplo n.º 1
0
bool test_task_aat(TaskManager& task_manager,
                   const Waypoints &waypoints)
{
  const TaskProjection &projection =
    task_manager.get_ordered_task().get_task_projection();

  task_manager.set_factory(OrderedTask::FACTORY_AAT);
  AbstractTaskFactory &fact = task_manager.get_factory();
  const Waypoint *wp;

  task_report(task_manager, "# adding start\n");
  wp = waypoints.lookup_id(1);
  if (wp) {
    if (!fact.append(fact.createStart(*wp),false)) {
      return false;
    }
  }

  task_manager.setActiveTaskPoint(0);
  task_manager.resume();

  task_report(task_manager, "# adding intermediate\n");
  wp = waypoints.lookup_id(2);
  if (wp) {
    OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp);
    if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) {
      CylinderZone *cz = (CylinderZone *)tp->get_oz();
      cz->setRadius(fixed(30000.0));
      tp->update_oz(projection);
    }
    if (!fact.append(tp,false)) {
      return false;
    }
  }

  task_report(task_manager, "# adding intermediate\n");
  wp = waypoints.lookup_id(3);
  if (wp) {
    OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp);
    if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) {
      CylinderZone *cz = (CylinderZone *)tp->get_oz();
      cz->setRadius(fixed(40000.0));
      tp->update_oz(projection);
    }
    if (!fact.append(tp,false)) {
      return false;
    }
  }

  task_report(task_manager, "# adding finish\n");
  wp = waypoints.lookup_id(1);
  if (wp) {
    if (!fact.append(fact.createFinish(*wp),false)) {
      return false;
    }
  }

  task_report(task_manager, "# checking task..\n");
  if (!fact.validate()) {
    return false;
  }

  if (!task_manager.check_ordered_task()) {
    return false;
  }
  return true;
}
bool test_task_mixed(TaskManager& task_manager,
                     const Waypoints &waypoints)
{
  const TaskProjection &projection =
    task_manager.get_ordered_task().get_task_projection();

  OrderedTaskPoint *tp;
  const Waypoint *wp;

  task_manager.set_factory(TaskBehaviour::FACTORY_MIXED);
  AbstractTaskFactory &fact = task_manager.get_factory();

  task_report(task_manager, "# adding start\n");
  wp = waypoints.lookup_id(1);
  if (wp) {
    tp = fact.createStart(AbstractTaskFactory::START_LINE,*wp);
    if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) {
      CylinderZone *cz = (CylinderZone *)tp->get_oz();
      cz->setRadius(fixed(5000.0));
      tp->update_oz(projection);
    }
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_manager.setActiveTaskPoint(0);
  task_manager.resume();

  task_report(task_manager, "# adding intermdiate\n");
  wp = waypoints.lookup_id(2);
  if (wp) {
    tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp);
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_report(task_manager, "# adding intermdiate\n");
  wp = waypoints.lookup_id(3);
  if (wp) {
    tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp);
    if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) {
      CylinderZone *cz = (CylinderZone *)tp->get_oz();
      cz->setRadius(fixed(30000.0));
      tp->update_oz(projection);
    }
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_report(task_manager, "# adding intermediate\n");
  wp = waypoints.lookup_id(4);
  if (wp) {
    tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp);
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_report(task_manager, "# adding intermediate\n");
  wp = waypoints.lookup_id(5);
  if (wp) {
    tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp);
    if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) {
      CylinderZone *cz = (CylinderZone *)tp->get_oz();
      cz->setRadius(fixed(30000.0));
      tp->update_oz(projection);
    }
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_report(task_manager, "# adding finish\n");
  wp = waypoints.lookup_id(1);
  if (wp) {
    tp = fact.createFinish(AbstractTaskFactory::FINISH_LINE,*wp);
    if (!fact.append(*tp,false)) return false;
    delete tp;
  } else {
    return false;
  }

  task_report(task_manager, "# checking task\n");
  if (!fact.validate()) {
    return false;
  }

  if (!task_manager.check_ordered_task()) {
    return false;
  }
  return true;
}