Example usage for io.netty.buffer ByteBuf readFloat

List of usage examples for io.netty.buffer ByteBuf readFloat

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readFloat.

Prototype

public abstract float readFloat();

Source Link

Document

Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

From source file:org.eclipse.neoscada.protocol.iec60870.asdu.types.TypeHelper.java

License:Open Source License

/**
 * Parse Short floating point number with quality descriptor
 *//*from   ww w  .  j  ava  2s .  co  m*/
public static Value<Float> parseFloatValue(final ProtocolOptions options, final ByteBuf data,
        final boolean withTimestamp) {
    final float value = data.readFloat();

    final byte qds = data.readByte();

    final QualityInformation qualityInformation = QualityInformation.parse(qds);
    final boolean overflow = (qds & 0b00000001) > 0;

    final long timestamp = withTimestamp ? parseTimestamp(options, data) : System.currentTimeMillis();

    return new Value<Float>(value, timestamp, qualityInformation, overflow);
}

From source file:org.eclipse.scada.protocol.iec60870.asdu.message.SetPointCommandShortFloatingPointCP56Time2a.java

License:Open Source License

public static SetPointCommandShortFloatingPointCP56Time2a parse(final ProtocolOptions options,
        final byte length, final ASDUHeader header, final ByteBuf data) {
    final InformationObjectAddress address = InformationObjectAddress.parse(options, data);

    final float value = data.readFloat();

    final byte b = data.readByte();

    final byte type = (byte) (b & 0b011111111);
    final boolean execute = !((b & 0b100000000) > 0);

    final Value<Float> val = new Value<Float>(value, TypeHelper.parseTimestamp(options, data),
            QualityInformation.OK);/* w  w  w. j ava  2 s .co  m*/

    return new SetPointCommandShortFloatingPointCP56Time2a(header, address, val, type, execute);
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.PlayerAbilitiesPacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.flags = buffer.readByte();
    this.fly_speed = buffer.readFloat();
    this.walk_speed = buffer.readFloat();
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.PlayerBlockPlacementPacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.position = ByteBufUtil.readPosition(buffer);
    this.face = ByteBufUtil.readVarInt(buffer);
    this.hand = ByteBufUtil.readVarInt(buffer);
    this.cursorx = buffer.readFloat();
    this.cursory = buffer.readFloat();
    this.cursorz = buffer.readFloat();
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.PlayerLookPacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.yaw = buffer.readFloat();
    this.pitch = buffer.readFloat();
    this.onGround = buffer.readBoolean();
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.PlayerPositionAndLookPacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.x = buffer.readDouble();
    this.y = buffer.readDouble();
    this.z = buffer.readDouble();
    this.yaw = buffer.readFloat();
    this.pitch = buffer.readFloat();
    this.onGround = buffer.readBoolean();
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.SteerVehiclePacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.sideways = buffer.readFloat();
    this.forwards = buffer.readFloat();
    this.flags = buffer.readByte();
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.UseEntityPacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.target = ByteBufUtil.readVarInt(buffer);
    this.type = Type.values()[ByteBufUtil.readVarInt(buffer)];
    if (this.type == Type.INTERACT_AT) {
        this.x = buffer.readFloat();
        this.y = buffer.readFloat();
        this.z = buffer.readFloat();
    }//from  www .  ja v a2s . c  om
    if (this.type != Type.ATTACK) {
        this.hand = ByteBufUtil.readVarInt(buffer);
    }
}

From source file:org.spongepowered.clean.network.packet.play.serverbound.VehicleMovePacket.java

License:MIT License

@Override
public void read(ByteBuf buffer) {
    this.x = buffer.readDouble();
    this.y = buffer.readDouble();
    this.z = buffer.readDouble();
    this.yaw = buffer.readFloat();
    this.pitch = buffer.readFloat();
}

From source file:org.spout.api.util.ByteBufUtils.java

License:Open Source License

/**
 * Reads a list of parameters from the buffer.
 *
 * @param buf The buffer./*from w  w  w.  j  a v  a  2  s .c om*/
 * @return The parameters.
 */
public static List<Parameter<?>> readParameters(ByteBuf buf) throws IOException {
    List<Parameter<?>> parameters = new ArrayList<>();

    for (int b = buf.readUnsignedByte(); b != 127; b = buf.readUnsignedByte()) {
        int type = (b & 0xE0) >> 5;
        int index = b & 0x1F;

        switch (type) {
        case Parameter.TYPE_BYTE:
            parameters.add(new Parameter<>(type, index, buf.readByte()));
            break;
        case Parameter.TYPE_SHORT:
            parameters.add(new Parameter<>(type, index, buf.readShort()));
            break;
        case Parameter.TYPE_INT:
            parameters.add(new Parameter<>(type, index, buf.readInt()));
            break;
        case Parameter.TYPE_FLOAT:
            parameters.add(new Parameter<>(type, index, buf.readFloat()));
            break;
        case Parameter.TYPE_STRING:
            parameters.add(new Parameter<>(type, index, readString(buf)));
            break;
        case Parameter.TYPE_ITEM:
            short id = buf.readShort();
            int count = buf.readByte();
            short data = buf.readShort();
            ItemStack item = new ItemStack(Material.get(id), data, count);
            parameters.add(new Parameter<>(type, index, item));
            break;
        }
    }

    return parameters;
}