Package it.polito.appeal.traci

Examples of it.polito.appeal.traci.TrafficLight


        Repository<TrafficLight> tlr =  this.connection.getTrafficLightRepository();
            try {
                Set<String> listaIDtl = tlr.getIDs();
                for(String s:listaIDtl){
                    System.out.println("Traffic light "+s);
                    TrafficLight tl = tlr.getByID(s);
                    List<Lane> list = tl.getReadControlledLanesQuery().get();
                   
                    LightState[] ls = new LightState[tl.getReadCurrentStateQuery().get().lightStates.length];
                    for(int i=0; i<tl.getReadCurrentStateQuery().get().lightStates.length; i++){
                     ls[i]=LightState.RED;
                    }
                    TLState tls = new TLState(ls);
                    ChangeLightsStateQuery q = tl.getChangeLightsStateQuery();
                    q.setValue(tls);
                    q.run();
                   

                }
View Full Code Here


  };

 
  @Test
  public void testStateAtFirstStep() throws IOException {
    TrafficLight tl = repo.getByID("0");
    TLState tlState = tl.getReadCurrentStateQuery().get();
    final LightState[] states = tlState.lightStates;
    assertEquals(16, states.length);
    assertArrayEquals(PHASES[0], states);
  }
View Full Code Here

    assertArrayEquals(PHASES[0], states);
  }
 
  @Test
  public void testStateUpdate() throws IOException {
    TrafficLight tl = repo.getByID("0");
    final ReadObjectVarQuery<TLState> query = tl.getReadCurrentStateQuery();
   
    // looks like SUMO shifts all TL timings ahead one second
    conn.nextSimStep();
   
    for (int p = 0; p < PHASES.length; p++) {
View Full Code Here

    }
  }
 
  @Test
  public void testCurrentDuration() throws IOException {
    TrafficLight tl = repo.getByID("0");
    final ReadObjectVarQuery<Integer> query = tl.getReadCurrentPhaseDurationQuery();

    // looks like SUMO shifts all TL timings ahead one second
    conn.nextSimStep();
   
    for (int p = 0; p < PHASES.length; p++) {
View Full Code Here

    new String[] { "1si_2", ":0_15_0", "1o_0" },
  };
 
  @Test
  public void testControlledLinks() throws IOException {
    TrafficLight tl = repo.getByID("0");
    ControlledLinks links = tl.getReadControlledLinksQuery().get();
   
    assertEquals(linksLaneIDs.length, links.getLinks().length);
    for (int i=0; i<linksLaneIDs.length; i++) {
      ControlledLink[] linksForSignal = links.getLinks()[i];
      assertEquals(1, linksForSignal.length);
View Full Code Here

    }
  }
 
  @Test
  public void testCompleteProgramDefinition() throws IOException {
    TrafficLight tl = repo.getByID("0");
    Program program = tl.getCompleteDefinitionQuery().get();
   
    assertEquals(1, program.getLogics().length);
    Logic logic = program.getLogics()[0];
   
    assertEquals("0", logic.getSubID());
View Full Code Here

 
  private static final TLState TEST_TL_STATE = new TLState("rrGGyyyyggrryryr");

  @Test
  public void testChangeState() throws IOException {
    TrafficLight tl = repo.getByID("0");
    ChangeLightsStateQuery q = tl.getChangeLightsStateQuery();
    q.setValue(TEST_TL_STATE);
    q.run();
   
    assertEquals(TEST_TL_STATE, tl.getReadCurrentStateQuery().get());
  }
View Full Code Here

    assertEquals(TEST_TL_STATE, tl.getReadCurrentStateQuery().get());
  }
 
  @Test
  public void testTrafficLightsPosition() throws IOException {
    TrafficLight tl = repo.getByID("0");
    List<Lane> lanes = tl.getReadControlledLanesQuery().get();
   
    assertEquals(16, lanes.size());
   
    for (Lane lane : lanes) {
   
View Full Code Here

    assertArrayEquals(PHASES[0], states);
  }
 
  @Test
  public void testStateUpdate() throws IOException {
    TrafficLight tl = repo.getByID("0");
    final ReadObjectVarQuery<TLState> query = tl.queryReadState();
   
    // looks like SUMO shifts all TL timings ahead one second
    conn.nextSimStep();
   
    for (int p = 0; p < PHASES.length; p++) {
View Full Code Here

    }
  }
 
  @Test
  public void testCurrentDuration() throws IOException {
    TrafficLight tl = repo.getByID("0");
    final ReadObjectVarQuery<Integer> query = tl.queryReadDefaultCurrentPhaseDuration();

    // looks like SUMO shifts all TL timings ahead one second
    conn.nextSimStep();
   
    for (int p = 0; p < PHASES.length; p++) {
View Full Code Here

TOP

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

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.