RLPark 1.0.0
Reinforcement Learning Framework in Java
|
00001 package rlpark.plugin.robot.internal.disco.drops; 00002 00003 00004 import rlpark.plugin.rltoys.math.GrayCode; 00005 import rlpark.plugin.rltoys.math.ranges.Range; 00006 import rlpark.plugin.robot.internal.disco.datatype.GrayCodeConverter; 00007 import rlpark.plugin.robot.internal.disco.datatype.ScalarReader; 00008 import rlpark.plugin.robot.internal.sync.LiteByteBuffer; 00009 00010 public class DropByteSigned extends DropData implements ScalarReader, GrayCodeConverter { 00011 private byte value; 00012 00013 public DropByteSigned(String label) { 00014 this(label, -1); 00015 } 00016 00017 public DropByteSigned(String label, int index) { 00018 super(label, false, index); 00019 } 00020 00021 @Override 00022 public DropData clone(String label, int index) { 00023 return new DropByteSigned(label, index); 00024 } 00025 00026 @Override 00027 public int getInt(LiteByteBuffer buffer) { 00028 return buffer.get(index); 00029 } 00030 00031 @Override 00032 public void convert(LiteByteBuffer source, LiteByteBuffer target) { 00033 value = (byte) getInt(source); 00034 value = GrayCode.byteToGrayCode(value); 00035 putData(target); 00036 } 00037 00038 @Override 00039 public void putData(LiteByteBuffer buffer) { 00040 buffer.put(value); 00041 } 00042 00043 @Override 00044 public int size() { 00045 return 1; 00046 } 00047 00048 @Override 00049 public Range range() { 00050 return new Range(Byte.MIN_VALUE, Byte.MAX_VALUE); 00051 } 00052 00053 @Override 00054 public double getDouble(LiteByteBuffer buffer) { 00055 return getInt(buffer); 00056 } 00057 }