pl.grzeslowski.jsupla.protocol.api.decoders.cs.DeviceCalCfgRequestDecoder Maven / Gradle / Ivy
package pl.grzeslowski.jsupla.protocol.api.decoders.cs;
import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.decoders.PrimitiveDecoder;
import pl.grzeslowski.jsupla.protocol.api.structs.cs.DeviceCalCfgRequest;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
@javax.annotation.Generated(value="Struct original name: TCS_DeviceCalCfgRequest", date = "2024-08-03T11:49:41.873Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class DeviceCalCfgRequestDecoder implements pl.grzeslowski.jsupla.protocol.api.decoders.cs.ClientServerDecoder {
public static final DeviceCalCfgRequestDecoder INSTANCE = new DeviceCalCfgRequestDecoder();
@Override
public DeviceCalCfgRequest decode(byte[] bytes, int offset) {
val channelId = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val command = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val dataType = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val dataSize = PrimitiveDecoder.INSTANCE.parseUnsignedInt(bytes, offset);
offset += INT_SIZE;
val data = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) dataSize);
offset += dataSize * BYTE_SIZE;
return new DeviceCalCfgRequest(channelId, command, dataType, dataSize, data);
}
}