Package de.uniluebeck.itm.tcpip

Examples of de.uniluebeck.itm.tcpip.Storage


   
    dos.writeInt(totalLen);


    for (Command cmd : commands) {
      Storage s = new Storage();
      cmd.writeRawTo(s);
      writeStorage(s, dos, checksum);
    }

//    if (log.isDebugEnabled())
View Full Code Here


    int totalLen = dis.readInt() - Integer.SIZE/8;
   
    byte[] buffer = new byte[totalLen];
    dis.readFully(buffer);
   
    Storage s = new Storage(buffer);
   
    while (s.validPos()) {
      StatusResponse sr = new StatusResponse(s);
      ResponseContainer responseContainer;
     
      if (sr.result() != Constants.RTYPE_OK) {
        responseContainer = new ResponseContainer(sr, null);
      }
      else if (sr.id() == Constants.CMD_SIMSTEP2) {
        int nSubResponses = s.readInt();
        List<Command> subResponses = new ArrayList<Command>(
            nSubResponses);
        for (int i = 0; i < nSubResponses; i++) {
          subResponses.add(new Command(s));
        }
View Full Code Here

    short[] buf = new short[contentLen];
    for (int i=0; i<contentLen; i++) {
      buf[i] = (byte)rawStorage.readUnsignedByte();
    }
   
    content = new Storage(buf);
  }
View Full Code Here

   * @param id
   */
  public Command(int id) {
    if (id > 255)
      throw new IllegalArgumentException("id should fit in a byte");
    content = new Storage();
    this.id = id;
  }
View Full Code Here

  }

  @Override
  protected List<Link> readValue(Command resp) throws TraCIException {
    List<Link> out = new ArrayList<Link>();
    Storage content = resp.content();
    Utils.checkType(content, Constants.TYPE_COMPOUND);
    content.readInt(); // ignore link data length
    Utils.checkType(content, Constants.TYPE_INTEGER);
    int count = content.readInt();
    for (int i=0; i<count; i++) {
      try {
        out.add(new Link(content, laneRepo));
      } catch (IOException e) {
        throw new TraCIException(e.toString());
View Full Code Here

  }

  @Override
  protected ControlledLinks readValue(Command resp)
      throws TraCIException {
    final Storage content = resp.content();
    Utils.checkType(content, Constants.TYPE_COMPOUND);
    content.readInt(); // ignore data length
    try {
      return new ControlledLinks(content, laneRepo);
    } catch (IOException e) {
      throw new TraCIException(e.getMessage());
    }
View Full Code Here

  }
 
  @Override
  List<Command> getRequests() {
    Command cmd = new Command(commandID);
    Storage content = cmd.content();
    content.writeByte(varID);
    content.writeStringASCII(objectID);
    return Collections.singletonList(cmd);
  }
View Full Code Here

    }

    @Override
    protected Integer readValue(Command resp)
        throws TraCIException {
      Storage content = resp.content();
      Utils.checkType(content, Constants.TYPE_INTEGER);
      return content.readInt();
    }
View Full Code Here

      super(dis, dos, commandID, objectID, varID);
    }

    @Override
    protected Double readValue(Command resp) throws TraCIException {
      Storage content = resp.content();
      Utils.checkType(content, Constants.TYPE_DOUBLE);
      return content.readDouble();
    }
View Full Code Here

      super(dis, dos, commandID, objectID, varID);
    }

    @Override
    protected Color readValue(Command resp) throws TraCIException {
      Storage content = resp.content();
      Utils.checkType(content, Constants.TYPE_COLOR);
      int r = content.readUnsignedByte();
      int g = content.readUnsignedByte();
      int b = content.readUnsignedByte();
      int a = content.readUnsignedByte();
      return new Color(r, g, b, a);
    }
View Full Code Here

TOP

Related Classes of de.uniluebeck.itm.tcpip.Storage

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.