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

    /*1#充电模块电压*/
    private int status1;

    /*1#充电模块电流*/
    private int status2;

    /*1#充电模块温度*/
    private int status3;

    /*2#充电模块电压*/
    private int status4;

    /*2#充电模块电流*/
    private int status5;

    /*2#充电模块温度*/
    private int status6;

    /*3#充电模块电压*/
    private int status7;

    /*3#充电模块电流*/
    private int status8;

    /*3#充电模块温度*/
    private int status9;

    /*4#充电模块电压*/
    private int status10;

    /*4#充电模块电流*/
    private int status11;

    /*4#充电模块温度*/
    private int status12;

    /*5#充电模块电压*/
    private int status13;

    /*5#充电模块电流*/
    private int status14;

    /*5#充电模块温度*/
    private int status15;

    /*6#充电模块电压*/
    private int status16;

    /*6#充电模块电流*/
    private int status17;

    /*6#充电模块温度*/
    private int status18;

    /*7#充电模块电压*/
    private int status19;

    /*7#充电模块电流*/
    private int status20;

    /*7#充电模块温度*/
    private int status21;

    /*8#充电模块电压*/
    private int status22;

    /*8#充电模块电流*/
    private int status23;

    /*8#充电模块温度*/
    private int status24;

    /*备用*/
    private int reserved1;

    /*备用*/
    private int reserved2;


    @Override
    public void encode(ByteBuf byteBuf)
    {
        byteBuf.writeShort(getStatus1());
        byteBuf.writeShort(getStatus2());
        byteBuf.writeShort(getStatus3());
        byteBuf.writeShort(getStatus4());
        byteBuf.writeShort(getStatus5());
        byteBuf.writeShort(getStatus6());
        byteBuf.writeShort(getStatus7());
        byteBuf.writeShort(getStatus8());
        byteBuf.writeShort(getStatus9());
        byteBuf.writeShort(getStatus10());
        byteBuf.writeShort(getStatus11());
        byteBuf.writeShort(getStatus12());
        byteBuf.writeShort(getStatus13());
        byteBuf.writeShort(getStatus14());
        byteBuf.writeShort(getStatus15());
        byteBuf.writeShort(getStatus16());
        byteBuf.writeShort(getStatus17());
        byteBuf.writeShort(getStatus18());
        byteBuf.writeShort(getStatus19());
        byteBuf.writeShort(getStatus20());
        byteBuf.writeShort(getStatus21());
        byteBuf.writeShort(getStatus22());
        byteBuf.writeShort(getStatus23());
        byteBuf.writeShort(getStatus24());
        byteBuf.writeInt(getReserved1());
        byteBuf.writeInt(getReserved2());

        byteBuf.writeByte(getEnd());
    }

    @Override
    public void decode(ByteBuf byteBuf)
    {
        setStatus1(byteBuf.readUnsignedShort());
        setStatus2(byteBuf.readUnsignedShort());
        setStatus3(byteBuf.readUnsignedShort());
        setStatus4(byteBuf.readUnsignedShort());
        setStatus5(byteBuf.readUnsignedShort());
        setStatus6(byteBuf.readUnsignedShort());
        setStatus7(byteBuf.readUnsignedShort());
        setStatus8(byteBuf.readUnsignedShort());
        setStatus9(byteBuf.readUnsignedShort());
        setStatus10(byteBuf.readUnsignedShort());
        setStatus11(byteBuf.readUnsignedShort());
        setStatus12(byteBuf.readUnsignedShort());
        setStatus13(byteBuf.readUnsignedShort());
        setStatus14(byteBuf.readUnsignedShort());
        setStatus15(byteBuf.readUnsignedShort());
        setStatus16(byteBuf.readUnsignedShort());
        setStatus17(byteBuf.readUnsignedShort());
        setStatus18(byteBuf.readUnsignedShort());
        setStatus19(byteBuf.readUnsignedShort());
        setStatus20(byteBuf.readUnsignedShort());
        setStatus21(byteBuf.readUnsignedShort());
        setStatus22(byteBuf.readUnsignedShort());
        setStatus23(byteBuf.readUnsignedShort());
        setStatus24(byteBuf.readUnsignedShort());
        setReserved1(byteBuf.readInt());
        setReserved2(byteBuf.readInt());

        byteBuf.skipBytes(1);
    }

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

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