Java Code Examples for org.apache.mina.core.buffer.IoBuffer#getFloat()

The following examples show how to use org.apache.mina.core.buffer.IoBuffer#getFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArduinoCodec.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private Object decodeData ( final IoBuffer data ) throws ProtocolCodecException
{
    data.order ( ByteOrder.LITTLE_ENDIAN );

    final byte dataType = data.get ();
    switch ( dataType )
    {
        case 0:
            return null;
        case 1:
            return data.get () != 0x00;
        case 2:
            return data.getInt ();
        case 3:
            return data.getLong ();
        case 4:
            return data.getFloat ();
        default:
            throw new ProtocolCodecException ( String.format ( "Data type %02x is unknown", dataType ) );
    }

}
 
Example 2
Source File: FloatAttribute.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void handleData ( final IoBuffer data, final Map<String, Variant> attributes, final Variant timestamp )
{
    final float f = data.getFloat ( toAddress ( this.index ) );
    attributes.put ( this.name, Variant.valueOf ( f ) );

    if ( !Float.valueOf ( f ).equals ( this.lastValue ) )
    {
        this.lastValue = f;
        this.lastTimestamp = timestamp;
    }

    if ( this.enableTimestamp )
    {
        attributes.put ( this.name + ".timestamp", this.lastTimestamp );
    }
}
 
Example 3
Source File: FloatFieldTypeHandler.java    From CXTouch with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Float decode(IoBuffer inBuffer) {
    if (inBuffer.remaining() < 4) {
        return null;
    } else {
        return inBuffer.getFloat();
    }
}