Package de.hpi.eworld.visualizer.simulation.traci.common

Examples of de.hpi.eworld.visualizer.simulation.traci.common.Message


  public abstract Command toCommand() throws IOException;
 
  public Command performSingleResponseSynchronousRequest(DataInputStream inputStream, DataOutputStream outputStream) throws IOException, TraciException {
   
    Message message = new Message(this);
    List<Command> commands = message.performSynchronousRequest(inputStream, outputStream);
    if(0 == commands.size()) {
      throw new IOException("TraCI request returned no command");
    }
    return commands.get(0);
  }
View Full Code Here


   * @throws Exception if the subscription returned an error
   */
  public void subscribeToSimulationValues() throws Exception {
    SubscribeSimulationValueRetrivalCommandGenerator simulationValue = new SubscribeSimulationValueRetrivalCommandGenerator(
        ModelManager.getInstance().getSimulationStartTime() * 1000, ModelManager.getInstance().getSimulationEndTime() * 1000);
    Message message = new Message(simulationValue);
    message.writeToStream(this.outputStream);
    Message response = Message.readFromStream(this.inputStream);
    for (Command command:response.getCommands()) {
      switch(command.getId()) {
        case SubscribeSimulationValueRetrivalCommandGenerator.ID:
          ResponseCommandReader responseCommand = ResponseCommandReader.fromCommand(command);
          if(responseCommand.getResult() != 0) {
            throw new IOException("TraCI reported an error.");
View Full Code Here

   * @throws TraciException
   */
  private float[] subscribeToVehicleValues(String id, int startTime) throws IOException, TraciException {
    SubscribeVehicleValueRetrivalCommandGenerator vehicleValue = new SubscribeVehicleValueRetrivalCommandGenerator(
        startTime, ModelManager.getInstance().getSimulationEndTime() * 1000, id);
    Message request = new Message(vehicleValue);
    request.writeToStream(this.outputStream);
    Message response = Message.readFromStream(this.inputStream);
    float[] position = null;
    for (Command command:response.getCommands()) {
      switch(command.getId()) {
        case SubscribeVehicleValueRetrivalCommandGenerator.ID:
          ResponseCommandReader responseCommand = ResponseCommandReader.fromCommand(command);
          if(responseCommand.getResult() != 0) {
            throw new IOException("TraCI reported an error.");
View Full Code Here

    // TraCI uses milliseconds as time unit
    // 1 time step = 1000 steps in sumo
    if(!readOnly) {
      this.time = time;
      SimulationStepCommandGenerator2 simulationStep = new SimulationStepCommandGenerator2(time * 1000);
      Message message = new Message(simulationStep);
      message.writeToStream(this.outputStream);
    }
   
    Map<String, double[]> added = new HashMap<String, double[]>();
    Map<String, double[]> updated = new HashMap<String, double[]>();
    List<String> removed = new ArrayList<String>();
View Full Code Here

   * @throws IOException
   *             Communication Error.
   */
  public void closeConnection() throws IOException {
   
    Message message = new Message(new CloseCommandGenerator());
    message.writeToStream(this.outputStream);
   
    while(true) {
      message = Message.readFromStream(this.inputStream);
      for(Command command : message.getCommands()) {
        if(command.getId() ==  CloseCommandGenerator.ID) {
          this.connected = false;
          return;
        }
      }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.visualizer.simulation.traci.common.Message

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.