Package it.polito.appeal.traci

Examples of it.polito.appeal.traci.SumoTraciConnection


public class OpenStepsClose {

  public static void main(String[] args) {
    BasicConfigurator.configure();
   
    SumoTraciConnection conn = new SumoTraciConnection(
        "test/sumo_maps/box1l/test.sumo.cfg"// config file
        12345,                                 // random seed
        false                                  // look for geolocalization info in the map
        );
    try {
      conn.runServer();
     
      System.out.println("Map bounds are: " + conn.queryBounds());
     
      for (int i = 0; i < 10; i++) {
        int time = conn.getCurrentSimStep();
        Collection<Vehicle> vehicles = conn.getVehicleRepository().getAll().values();
       
        System.out.println("At time step " + time + ", there are "
            + vehicles.size() + " vehicles: " + vehicles);
       
        conn.nextSimStep();
      }
     
      conn.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


import java.util.Collection;

public class GetVehicleInfo {

  public static void main(String[] args) {
    SumoTraciConnection conn = new SumoTraciConnection(
        "test/sumo_maps/box1l/test.sumo.cfg"// config file
        12345,                                 // random seed
        false                                  // look for geolocalization info in the map
        );
    try {
      conn.runServer();
     
      // the first two steps of this simulation have no vehicles.
      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

    }
    catch (IllegalThreadStateException e) {
      // all OK, it's alive
    }
   
    conn = new SumoTraciConnection(InetAddress.getLocalHost(), PORT);
  }
View Full Code Here

            Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
        }    catch (IllegalThreadStateException e) {
      // all OK, it's alive
    }
        try {
            conn = new SumoTraciConnection(InetAddress.getLocalHost(), PORT);
        } catch (IOException ex) {
            Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

    conn = startSumoConn(SIM_CONFIG_LOCATION);
  }

  public static SumoTraciConnection startSumoConn(String simConfigLocation) throws Exception {
    try {
      SumoTraciConnection newConn = new SumoTraciConnection(simConfigLocation, 0, false);
      newConn.runServer();
      return newConn;
    }
    catch(Exception e) {
      e.printStackTrace();
      throw e;
View Full Code Here

  @Test
  public void testHttpDownload() throws IOException, InterruptedException {
    new NanoHTTPD(5432);

    SumoTraciConnection conn = new SumoTraciConnection("http://127.0.0.1:5432/test/sumo_maps/variable_speed_signs/test.sumo.cfg", 1, false);
    conn.runServer();
    conn.nextSimStep();
    conn.nextSimStep();
  }
View Full Code Here

  @Test
  public void testHttpDownload() throws IOException, InterruptedException {
    new NanoHTTPD(5432);

    SumoTraciConnection conn = new SumoTraciConnection("http://127.0.0.1:5432/test/sumo_maps/variable_speed_signs/test.sumo.cfg", 1);
    conn.runServer();
    conn.nextSimStep();
    conn.nextSimStep();
  }
View Full Code Here

   * @throws IOException
   * @throws Exception
   */
  @Before
  public void startSumoConnection() throws IOException, InterruptedException  {
    conn = new SumoTraciConnection(getSimConfigFileLocation(), 0);
    conn.runServer();
  }
View Full Code Here

    }
    catch (IllegalThreadStateException e) {
      // all OK, it's alive
    }
   
    conn = new SumoTraciConnection(InetAddress.getLocalHost(), PORT);
  }
View Full Code Here

  public static void main(String[] args) {
 
   
    try{
     
      SumoTraciConnection conn = new SumoTraciConnection(sumo_bin, config_file);
      conn.addOption("step-length", step_length+"");
      conn.addOption("start", ""); //start sumo immediately
   
      //start Traci Server
      conn.runServer();
     
      for(int i=0; i<3600; i++){
     
        conn.do_timestep();
        conn.do_job_set(Vehicle.add("v"+i, "car", "r1", 0, 0, 13.8, (byte) 1));
 
      }
     
      conn.close();
     
    }catch(Exception ex){ex.printStackTrace();}
   
  }
View Full Code Here

TOP

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

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.