/**
   * Packs a Pdu into the ByteBuffer.
   *
   * @throws java.nio.BufferOverflowException if buff is too small
   * @throws java.nio.ReadOnlyBufferException if buff is read only
   * @see java.nio.ByteBuffer
   * @param buff The ByteBuffer at the position to begin writing
   * @since ??
   */
  public void marshal(java.nio.ByteBuffer buff) {
    super.marshal(buff);
    entityId.marshal(buff);
    buff.putShort((short) communicationsDeviceID);
    buff.putShort((short) encodingScheme);
    buff.putShort((short) tdlType);
    buff.putInt((int) sampleRate);
    buff.putShort((short) data.size());
    buff.putShort((short) samples);

    for (int idx = 0; idx < data.size(); idx++) {
      OneByteChunk aOneByteChunk = (OneByteChunk) data.get(idx);
      aOneByteChunk.marshal(buff);
    } // end of list marshalling
  } // end of marshal method
  /**
   * Unpacks a Pdu from the underlying data.
   *
   * @throws java.nio.BufferUnderflowException if buff is too small
   * @see java.nio.ByteBuffer
   * @param buff The ByteBuffer at the position to begin reading
   * @since ??
   */
  public void unmarshal(java.nio.ByteBuffer buff) {
    super.unmarshal(buff);

    entityId.unmarshal(buff);
    communicationsDeviceID = (int) (buff.getShort() & 0xFFFF);
    encodingScheme = (int) (buff.getShort() & 0xFFFF);
    tdlType = (int) (buff.getShort() & 0xFFFF);
    sampleRate = buff.getInt();
    dataLength = (int) (buff.getShort() & 0xFFFF);
    samples = (int) (buff.getShort() & 0xFFFF);
    for (int idx = 0; idx < dataLength; idx++) {
      OneByteChunk anX = new OneByteChunk();
      anX.unmarshal(buff);
      data.add(anX);
    }
  } // end of unmarshal method
  public void marshal(DataOutputStream dos) {
    super.marshal(dos);
    try {
      entityId.marshal(dos);
      dos.writeShort((short) communicationsDeviceID);
      dos.writeShort((short) encodingScheme);
      dos.writeShort((short) tdlType);
      dos.writeInt((int) sampleRate);
      dos.writeShort((short) data.size());
      dos.writeShort((short) samples);

      for (int idx = 0; idx < data.size(); idx++) {
        OneByteChunk aOneByteChunk = data.get(idx);
        aOneByteChunk.marshal(dos);
      } // end of list marshalling

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of marshal method
  public void unmarshal(DataInputStream dis) {
    super.unmarshal(dis);

    try {
      entityId.unmarshal(dis);
      communicationsDeviceID = (int) dis.readUnsignedShort();
      encodingScheme = (int) dis.readUnsignedShort();
      tdlType = (int) dis.readUnsignedShort();
      sampleRate = dis.readInt();
      dataLength = (int) dis.readUnsignedShort();
      samples = (int) dis.readUnsignedShort();
      for (int idx = 0; idx < dataLength; idx++) {
        OneByteChunk anX = new OneByteChunk();
        anX.unmarshal(dis);
        data.add(anX);
      }

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of unmarshal method