Package it.polito.appeal.traci

Examples of it.polito.appeal.traci.Vehicle


      conn.nextSimStep();
      conn.nextSimStep();
     
      Collection<Vehicle> vehicles = conn.getVehicleRepository().getAll().values();

      Vehicle aVehicle = vehicles.iterator().next();
     
      System.out.println("Vehicle " + aVehicle
          + " will traverse these edges: "
          + aVehicle.queryReadCurrentRoute().get());
     
      conn.close();
    }
    catch(Exception e) {
      e.printStackTrace();
View Full Code Here


  }
 
  @Test
  public void testRefreshedValues() throws IllegalStateException, IOException {
    conn.nextSimStep();
    Vehicle v = conn.getVehicleRepository().getAll().values().iterator().next();
    ValueReadQuery<Double> readSpeedQuery = v.queryReadSpeed();
    Double speedFirst = readSpeedQuery.get();
   
    for (int i=0; i<10; i++) {
      conn.nextSimStep();
      Double speedNow = readSpeedQuery.get();
View Full Code Here

 
  @Test
  public void testVehiclePositionAtStepOne() throws IOException {
    conn.nextSimStep();
    final Repository<Vehicle> repo = conn.getVehicleRepository();
    Vehicle v0 = repo.getByID("0.0");
    assertEquals(0, v0.queryReadLanePosition().get(), DELTA);
  }
View Full Code Here

  @Test
  public void testVehiclePositionAtStepTwo() throws IOException {
    conn.nextSimStep();
    conn.nextSimStep();
    final Repository<Vehicle> repo = conn.getVehicleRepository();
    Vehicle v0 = repo.getByID("0.0");
    assertEquals(1.886542, v0.queryReadLanePosition().get(), DELTA);
  }
View Full Code Here

  }

  @Test
  public void testChangeTarget() throws IOException {
    getFirstVehicle();
    Vehicle v = firstVehicle;

    ChangeTargetQuery ctq = v.queryChangeTarget();
    ctq.setValue(conn.getEdgeRepository().getByID("end"));
    ctq.run();
   
    Edge lastEdge = null;
    while (conn.getVehicleRepository().getByID(v.getID()) != null) {
      lastEdge = v.queryReadCurrentEdge().get();
      assertFalse(lastEdge.getID().equals("end"));

      conn.nextSimStep();
    }
  }
View Full Code Here

  }
 
  @Test
  public void testChangeTargetAlsoAffectsRouteList() throws IOException {
    getFirstVehicle();
    Vehicle v = firstVehicle;
    ChangeTargetQuery ctq = v.queryChangeTarget();
    ctq.setValue(conn.getEdgeRepository().getByID("end"));
    ctq.run();
    List<Edge> route = v.queryReadCurrentRoute().get();
    assertEquals("end", route.get(route.size()-1).getID());
  }
View Full Code Here

  }
 
  @Test
  public void testChangeRoute() throws IOException {
    getFirstVehicle();
    Vehicle v = firstVehicle;
    List<Edge> newRoute = new ArrayList<Edge>();
    newRoute.add(conn.getEdgeRepository().getByID("beg"));
    newRoute.add(conn.getEdgeRepository().getByID("beg2left"));
    newRoute.add(conn.getEdgeRepository().getByID("left"));
    newRoute.add(conn.getEdgeRepository().getByID("left2end"));
    ChangeRouteQuery crq = v.queryChangeRoute();
    crq.setValue(newRoute);
    crq.run();
    assertEquals(newRoute, v.queryReadCurrentRoute().get());
  }
View Full Code Here

   * @throws IOException
   */
  @Test
  public void testRefreshedValues() throws IllegalStateException, IOException {
    conn.nextSimStep();
    Vehicle v = conn.getVehicleRepository().getAll().values().iterator().next();
    Double speedFirst = v.getSpeed();
   
    for (int i=0; i<10; i++) {
      conn.nextSimStep();
      Double speedNow = v.getSpeed();
      log.info(speedNow.toString());
      assertTrue(Math.abs(speedFirst - speedNow) > DELTA);
    }
  }
View Full Code Here

   */
  @Test
  public void testVehiclePositionAtStepOne() throws IOException {
    conn.nextSimStep();
    final Repository<Vehicle> repo = conn.getVehicleRepository();
    Vehicle v0 = repo.getByID("0.0");
    assertEquals(0, v0.getLanePosition(), DELTA);
  }
View Full Code Here

  @Test
  public void testVehiclePositionAtStepTwo() throws IOException {
    conn.nextSimStep();
    conn.nextSimStep();
    final Repository<Vehicle> repo = conn.getVehicleRepository();
    Vehicle v0 = repo.getByID("0.0");
    assertEquals(1.886542, v0.getLanePosition(), DELTA);
  }
View Full Code Here

TOP

Related Classes of it.polito.appeal.traci.Vehicle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.