RLPark 1.0.0
Reinforcement Learning Framework in Java

DropShortUnsigned.java

Go to the documentation of this file.
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 DropShortUnsigned extends DropData implements ScalarReader, GrayCodeConverter {
00011   private int value;
00012 
00013   public DropShortUnsigned(String label) {
00014     this(label, -1);
00015   }
00016 
00017   public DropShortUnsigned(String label, int index) {
00018     super(label, false, index);
00019   }
00020 
00021   @Override
00022   public DropData clone(String label, int index) {
00023     return new DropShortUnsigned(label, index);
00024   }
00025 
00026   @Override
00027   public int getInt(LiteByteBuffer buffer) {
00028     return buffer.getShort(index) & 0xffff;
00029   }
00030 
00031   @Override
00032   public void convert(LiteByteBuffer source, LiteByteBuffer target) {
00033     value = getInt(source);
00034     value = GrayCode.shortToGrayCode((short) value);
00035     putData(target);
00036   }
00037 
00038   @Override
00039   public void putData(LiteByteBuffer buffer) {
00040     buffer.putShort((short) value);
00041   }
00042 
00043   @Override
00044   public String toString() {
00045     return String.valueOf(value);
00046   }
00047 
00048   @Override
00049   public int size() {
00050     return 2;
00051   }
00052 
00053   @Override
00054   public Range range() {
00055     return new Range(0, 65535);
00056   }
00057 
00058   @Override
00059   public double getDouble(LiteByteBuffer buffer) {
00060     return getInt(buffer);
00061   }
00062 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark