package com.pwt.netty.common.charger.client;

import com.pwt.netty.common.charger.RequestData;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 电池故障包
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode(callSuper = true)
public class BatteryFaultData extends RequestData {

    private final int  dataLength = 80;
    private byte[] faultArr = new byte[dataLength - 1];


    @Override
    public void encode(ByteBuf byteBuf)
    {
        byteBuf.writeBytes(faultArr);
        byteBuf.writeByte(getEnd());
    }


    @Override
    public void decode(ByteBuf byteBuf)
    {
        byteBuf.readBytes(faultArr);
        byteBuf.skipBytes(1);
    }

    @Override
    public int getProtocolLength() {
        return dataLength;
    }

    @Override
    public byte getEnd() {
        return 0x16;
    }
}
