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

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


    return new Command(ID, outputStream.toByteArray());
  }

  public static ScenarioCommandCodec fromCommand(Command command) throws IOException {
   
    TraciInputStream payload = command.getPayload();
   
    int flag = payload.readByte();
    int domain = payload.readByte();
    int domainID = payload.readInt();
    int variable = payload.readByte();
    int valueDataType = payload.readByte();
    Object value = payload.readTraciObject(valueDataType);
   
    return new ScenarioCommandCodec(
        flag,
        domain,
        domainID,
View Full Code Here


  public float[] getPosition() {
    return position;
  }
 
  public static ResponseVehicleValueCommandReader fromCommand(Command command) throws IOException, TraciException{
    TraciInputStream payload = command.getPayload();
   
    String objectId = new String(payload.readTraciString());
    // variable count == 1
    payload.readUnsignedByte();
    // variable id == POSITION (0x42)
    payload.readUnsignedByte();
    int status = payload.readUnsignedByte();
    if (status == 0xff){
      payload.readUnsignedByte(); // type: String
      String message = new String(payload.readTraciString());
      throw new TraciException(message);
    }
    float[] position = (float[]) payload.readTraciTypeAndObject();
   
    return new ResponseVehicleValueCommandReader(objectId, position);
  }
View Full Code Here

    }
  }

  public static ResponseSimulationValueCommandReader fromCommand(Command command) throws IOException, TraciException {
   
    TraciInputStream payload = command.getPayload();
   
    String objectId = new String(payload.readTraciString());
    int count = payload.readUnsignedByte();
    HashMap<Integer, Object> values = new HashMap<Integer, Object>();
    for (int i = 0; i < count; i++) {
      int id = payload.readUnsignedByte(); // value id
      int status = payload.readUnsignedByte();
      if (status == 0x00) {
        // value could be retrieved without an error
        int type = payload.readUnsignedByte();
        if (type == TraciConstants.DATATYPE_INT)
          values.put(id, payload.readInt());
        else if (type == TraciConstants.DATATYPE_STRING_LIST) {
          List<String> ids = new ArrayList<String>();
          int length = payload.readInt();
          for (int j = 0; j < length; j++) {
            ids.add(new String(payload.readTraciString()));
          }
          values.put(id, ids);
        }
      } else if (status == 0xff){
        payload.readUnsignedByte(); // type: String
        String message = new String(payload.readTraciString());
        throw new TraciException(message);
      }
       
    }
   
View Full Code Here

    this.description = description;
  }
 
  public static ResponseCommandReader fromCommand(Command command) throws IOException {
   
    TraciInputStream payload = command.getPayload();
   
    int result = payload.readUnsignedByte();
    byte[] description = payload.readTraciString();
   
    return new ResponseCommandReader(result, description);
  }
View Full Code Here

    this.yellowTime = yellowTime;
  }
 
  public static ResponseTrafficLightSwitchCommandReader fromCommand(Command command) throws IOException {
   
    TraciInputStream payload = command.getPayload();

    double switchTime = payload.readDouble();
    byte[] precedingEdge = payload.readTraciString();
    float positionOnPrecedingEdge = payload.readFloat();
    byte[] succeedingEdge = payload.readTraciString();
    int newPhase = payload.readInt();
    double yellowTime = payload.readDouble();
   
    return new ResponseTrafficLightSwitchCommandReader(
        switchTime,  precedingEdge, positionOnPrecedingEdge,
        succeedingEdge, newPhase, yellowTime);
  }
View Full Code Here

    this.position = position;
  }
 
  public static ResponseMoveNodeCommandReader fromCommand(Command command) throws IOException {
   
    TraciInputStream payload = command.getPayload();
   
    int nodeID = payload.readInt();
    double targetTime = payload.readDouble();
    float []position = (float[])payload.readTraciTypeAndObject();
   
    return new ResponseMoveNodeCommandReader(nodeID, targetTime, position);
  }
View Full Code Here

TOP

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

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.