Package it.polito.appeal.traci

Examples of it.polito.appeal.traci.SumoTraciConnection$StreamLogger


  }
 
  public void start(String sumo_bin, String configFile){
 
    //start SUMO
    conn = new SumoTraciConnection(sumo_bin, configFile);
     try{
       conn.runServer();
       this.running=true;
      
     }catch(Exception ex){
View Full Code Here


  }
 
  public void start(String sumo_bin, String net_file, String route_file){
   
    //start SUMO
    conn = new SumoTraciConnection(
          sumo_bin, //binary
          net_file,   // net file
          route_file // route file
      );
   
View Full Code Here

 
  @SuppressWarnings("static-access")
  public void start_ws(){

    //start SUMO
    conn = new SumoTraciConnection(conf.sumo_bin, conf.config_file);
   
      //Add Options
      this.add_options();
     
       try{
View Full Code Here

  /** main method */
  public static void main(String[] args) {
    BasicConfigurator.configure();
   
    SumoTraciConnection conn = new SumoTraciConnection(
        "test/sumo_maps/box1l/test.sumo.cfg"// config file
        12345                                  // random seed
        );
    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

*/
public class GetVehicleInfo {

  /** main method */
  public static void main(String[] args) {
    SumoTraciConnection conn = new SumoTraciConnection(
        "test/sumo_maps/box1l/test.sumo.cfg"// config file
        12345                                  // random seed
        );
    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.getCurrentRoute());
     
      conn.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      */
     ConsoleAppender ca = new ConsoleAppender();
    ca.setThreshold(Priority.WARN);
    BasicConfigurator.configure(ca);
   
    SumoTraciConnection conn = new SumoTraciConnection(
        "test/sumo_maps/box1l/test.sumo.cfg"// config file
        12345                                  // random seed
        );
   

    /*
     * Sets the TCP_NODELAY property on the socket connection to SUMO based
     * on the OS we are executing in.
     */
    String os = System.getProperty("os.name");
    if(os.matches("Linux"))
    {
       conn.enableTcpNoDelay();
    }
    else
    {
       conn.disableTcpNoDelay();
    }
   
   
    /*
     * Just some simple checking code.
     */
    boolean check = conn.isTcpNoDelayActive();
   
    System.out.println();
    System.out.printf("Setting TcpNoDelay to [%b] as we are in %s\n", check, os);
   
   
    /*
     * For calculating mean execution times.
     */
    ArrayList<Long> val = new ArrayList<Long>();
   
    try
    {
       /*
        * If we did not want to depend on the OS, we can simply override the
        * TCP_NODELAY setting by doing conn.setTcpNoDelay(false) here. 
        */
       // conn.setTcpNoDelay(false);
      conn.runServer();
     
      System.out.println();
      System.out.println("Map bounds are: " + conn.queryBounds());
      System.out.println();
     
      int i;
           
      for (i = 0; i < 20; i++)
      {
        int time = conn.getCurrentSimStep();
       
         long bgn;
         long end;
         long dif;
        
         bgn = System.currentTimeMillis();
        conn.nextSimStep();
        end = System.currentTimeMillis();
        dif = end - bgn;
       
        System.out.println();
        System.out.printf("Begin Time: %s ms\n", bgn);
        System.out.printf("End Time  : %s ms\n", end);
        System.out.printf("Tick %03d : %d ms\n", time, dif);
        val.add(dif);
      }
     
      double sum = 0;
     
      for(Long l : val)
      {
         sum += l;
      }
     
      double avg = sum / (double)val.size();
     
      System.out.println();
      System.out.printf("Average: %.2f ms for %d ticks, with tcpnodelay=%b\n", avg, i, conn.isTcpNoDelayActive());
     
      conn.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

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

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.