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

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


    dataOutputStream.writeByte(variable);
    dataOutputStream.writeByte(valueDataType);
    dataOutputStream.writeTraciObject(valueDataType, value);
    dataOutputStream.close();
   
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here


    traciOutputStream.writeByte(NUMBER_DEPARTED_VEHICLES);
    traciOutputStream.writeByte(IDS_DEPARTED_VEHICLES);
    traciOutputStream.writeByte(NUMBER_ARRIVED_VEHICLES);
    traciOutputStream.writeByte(IDS_ARRIVED_VEHICLES);
    traciOutputStream.close();
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

    dataOutputStream.writeInt(targetTime);
   
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

    ScenarioCommandCodec reader = createReader(commandGenerator);
    return ((Integer) reader.getValue()).intValue();
  }

  private ScenarioCommandCodec createReader(ScenarioCommandCodec commandGenerator) throws IOException, TraciException {
    Command command = commandGenerator.performSingleResponseSynchronousRequest(inputStream, outputStream);
    ScenarioCommandCodec reader = ScenarioCommandCodec.fromCommand(command);
   
    return reader;
  }
View Full Code Here

    DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

    dataOutputStream.writeInt(trafficLightID);
    dataOutputStream.writeDouble(intervalStart);
    dataOutputStream.writeDouble(intervalEnd);
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

  public static final int ID = 0x7F;
 
  @Override
  public Command toCommand() throws IOException {
    return new Command(ID, new byte[0]);
  }
View Full Code Here

    traciOutputStream.writeInt(endTime);
    traciOutputStream.writeTraciObject(TraciConstants.DATATYPE_STRING, objectId.getBytes());
    traciOutputStream.writeByte(1); // count of following variables
    traciOutputStream.writeByte(POSITION);
    traciOutputStream.close();
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

    DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

    dataOutputStream.writeInt(targetTime);
    dataOutputStream.writeByte(positionType);
   
    return new Command(ID, outputStream.toByteArray());
  }
View Full Code Here

      int size = random.nextInt(1000);
     
      //Construct a random command
      byte []payload = new byte[size];
      random.nextBytes(payload);
      Command command = new Command(0, payload);
     
      //serialize this command
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      command.writeToStream(new DataOutputStream(outputStream));
      byte []commandBytes = outputStream.toByteArray();
     
      //read this command
      DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(commandBytes));
      Command decodedCommand = Command.readFromStream(inputStream);
     
      byte []receivedPayload = new byte[payload.length];
      decodedCommand.getPayload().read(receivedPayload);
     
      Assert.assertArrayEquals(payload, receivedPayload);
   
    }
View Full Code Here

  public static SimulationResponseReceiver readFromStream(DataInputStream input) throws IOException {
    int messageLength = input.readInt();
    int remaining = messageLength - 4;
    List<Command> commands = new ArrayList<Command>();
    // the first command is the response to the command step
    Command status = Command.readFromStream(input);
    commands.add(status);
    remaining -= status.size();
    int numberResponses = 0;
    // for an unknown reason the protocol was broken here
    // a raw integer value follows the the first command
    // indicating the following number of subscription responses
    if (remaining >= 4) {
      numberResponses = input.readInt()
      remaining -= 4;
    }
    // read the subscription response commands
    for (int i = 0; i < numberResponses; i++) {
      Command simResp = Command.readFromStream(input);
      commands.add(simResp);
      remaining -= simResp.size();
    }
    return new SimulationResponseReceiver(numberResponses, commands);
  }
View Full Code Here

TOP

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

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.