コード例 #1
0
ファイル: TraCITest.java プロジェクト: p1tt1/TraCI4J
 /**
  * This test checks ensures that changing the destination road also changes the vehicle's current
  * route list such that the last road is the new destination road.
  *
  * @throws IOException
  */
 @Test
 public void testChangeTargetAlsoAffectsRouteList() throws IOException {
   getFirstVehicle();
   Vehicle v = firstVehicle;
   Edge endEdge = conn.getEdgeRepository().getByID("end");
   v.changeTarget(endEdge);
   List<Edge> route = v.getCurrentRoute();
   assertEquals("end", route.get(route.size() - 1).getID());
 }
コード例 #2
0
ファイル: TraCITest.java プロジェクト: p1tt1/TraCI4J
  /**
   * This test shows how to change a vehicle's destination road to "end", which is just before the
   * default "rend", then advances the simulation to check that "rend" is never traversed by the
   * vehicle until it exits.
   *
   * @throws IOException
   */
  @Test
  public void testChangeTarget() throws IOException {
    getFirstVehicle();
    Vehicle v = firstVehicle;

    Edge endEdge = conn.getEdgeRepository().getByID("end");
    v.changeTarget(endEdge);

    Edge lastEdge = null;
    while (conn.getVehicleRepository().getByID(v.getID()) != null) {
      lastEdge = v.getCurrentEdge();
      assertFalse(lastEdge.getID().equals("rend"));

      conn.nextSimStep();
    }
  }