RLPark 1.0.0
Reinforcement Learning Framework in Java

DiscoPacket.java

Go to the documentation of this file.
00001 package rlpark.plugin.robot.internal.disco.io;
00002 
00003 import java.io.Serializable;
00004 import java.nio.ByteOrder;
00005 
00006 import rlpark.plugin.robot.internal.sync.LiteByteBuffer;
00007 
00008 public class DiscoPacket implements Serializable {
00009   private static final long serialVersionUID = -4603810414251911563L;
00010 
00011   public enum Direction {
00012     Send,
00013     Recv
00014   }
00015 
00016   public final String order;
00017   public final byte[] buffer;
00018   public final String name;
00019   public final long time;
00020   public final Direction direction;
00021   private transient LiteByteBuffer byteBuffer = null;
00022 
00023   DiscoPacket(Direction direction, String name, LiteByteBuffer buffer) {
00024     this(direction, name, buffer.order(), buffer.array());
00025     this.byteBuffer = buffer;
00026   }
00027 
00028   DiscoPacket(Direction direction, String name, ByteOrder order, byte[] byteArray) {
00029     this.name = name;
00030     this.direction = direction;
00031     this.order = order.toString();
00032     this.buffer = byteArray;
00033     time = System.currentTimeMillis();
00034   }
00035 
00036   public ByteOrder order() {
00037     return "BIG_ENDIAN".equals(order) ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
00038   }
00039 
00040   public LiteByteBuffer byteBuffer() {
00041     if (byteBuffer != null)
00042       return byteBuffer;
00043     byteBuffer = new LiteByteBuffer(buffer, order());
00044     return byteBuffer;
00045   }
00046 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark