}
public Command toCommand() throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
TraciOutputStream traciOutputStream = new TraciOutputStream(dataOutputStream);
traciOutputStream.writeInt(startTime);
traciOutputStream.writeInt(endTime);
// the simulation ID is always unused and therefore an empty string
traciOutputStream.writeTraciObject(TraciConstants.DATATYPE_STRING, "".getBytes());
traciOutputStream.writeByte(7); // count of following variables
traciOutputStream.writeByte(CURRENT_SIMULATION_TIME);
traciOutputStream.writeByte(NUMBER_LOADED_VEHICLES);
traciOutputStream.writeByte(IDS_LOADED_VEHICLES);
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());
}