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 ChargerAlarmData extends RequestData {

    /*故障信息*/
    private int alarmCode;


    @Override
    public void encode(ByteBuf byteBuf) {
        byteBuf.writeShort(alarmCode);
        byteBuf.writeByte(getEnd());
    }

    @Override
    public void decode(ByteBuf byteBuf) {
        alarmCode = byteBuf.readUnsignedShort();
        byteBuf.skipBytes(1);

    }

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

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