예제 #1
0
  /** {@inheritDoc} */
  public State convertToState(byte[] data, DavisValueType valueType) {

    ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
    DecimalType res = null;

    switch (valueType.getDataSize()) {
      case 1:
        res = new DecimalType(bb.get(valueType.getDataOffset()));
        break;
      case 2:
        res = new DecimalType(bb.getShort(valueType.getDataOffset()));
        break;
      case 4:
        res = new DecimalType(bb.getInt(valueType.getDataOffset()));
        break;
      default:
        res = null;
        break;
    }

    return res;
  }
예제 #2
0
 /** {@inheritDoc} */
 public State convertToState(byte[] data, DavisValueType valueType) {
   short value =
       ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN).getShort(valueType.getDataOffset());
   return new DecimalType(((double) value * 0.1 - 32) * 5 / 9.0);
 }