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

import com.pwt.netty.common.chargerold.RequestData;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @author linyun
 * @version V1.0
 * @Title: BatteryStatusData
 * @Description: 电池状态数据包
 * @date 2022/11/14
 **/
@Data
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class BatteryStatusData extends RequestData {

    /**绝缘检测仪工作状态（0 "Selfcheck" 1"working" 2 "stopwork" 3 "equipmentfailure"）*/
    private short status1;

    /**绝缘故障等级"*/
    private short status2;

    /**正极绝缘值*/
    private short status3;

    /**负极绝缘值*/
    private short status4;

    /**备用1 (填充 0)*/
    private float reserved1;

    /**电池包额定容量*/
    private short status5;

    /**电池包额定电压*/
    private short status6;

    /**电池包额定总能量*/
    private short status7;

    /**电池类型*/
    private byte status8;

    /**电池冷却方式 */
    private byte status9;

    /**电池厂家 */
    private byte status10;

    /**协议版本高位*/
    private byte status11;

    /**协议版本低位*/
    private byte status12;

    /**电池系统中CSC总的数目*/
    private byte status13;

    /**PACK中单体电芯的总数目*/
    private short status14;

    /**电芯温度点(探针)的总数目*/
    private byte status15;

    /**高压支路数*/
    private byte status16;

    /**单支路电芯数*/
    private byte status17;

    /**可充电储能数目*/
    private byte status18;

    /**PACK可用电压上限*/
    private short status19;

    /**PACK可用电压下限*/
    private short status20;

    /**最高soc*/
    private byte status21;

    /**最低soc*/
    private byte status22;

    /**PACK可用温度上限*/
    private byte status23;

    /**PACK可用温度下限*/
    private byte status24;

    /**单体电压序号（从 1开始）*/
    private short status25;

    /**本帧第 1号电池电压（最后一帧发不满，则发送0xFFFF）*/
    private short status26;

    /**本帧第 2号电池电压（最后一帧发不满，则发送0xFFFF）*/
    private short status27;

    /**本帧第 3号电池电压（最后一帧发不满，则发送0xFFFF）*/
    private short status28;

    /**本帧第 起始单体温度序号（从1开始 填0）*/
    private short status29;

    /**本帧第 1号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status30;

    /**本帧第 2号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status31;

    /**本帧第 3号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status32;

    /**本帧第 4号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status33;

    /**本帧第 5号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status34;

    /**本帧第 6号电池温度（最后一帧发不满，则发送0xFF）*/
    private byte status35;

    /**备用2 */
    private int reserved2;

    /***
     * 子类编码
     * @param byteBuf
     */
    @Override
    protected void encodeInternal(ByteBuf byteBuf)
    {
        byteBuf.writeShort(getStatus1());
        byteBuf.writeShort(getStatus2());
        byteBuf.writeShort(getStatus3());
        byteBuf.writeShort(getStatus4());
        byteBuf.writeFloat(getReserved1());
        byteBuf.writeShort(getStatus5());
        byteBuf.writeShort(getStatus6());
        byteBuf.writeShort(getStatus7());
        byteBuf.writeByte(getStatus8());
        byteBuf.writeByte(getStatus9());
        byteBuf.writeByte(getStatus10());
        byteBuf.writeByte(getStatus11());
        byteBuf.writeByte(getStatus12());
        byteBuf.writeByte(getStatus13());
        byteBuf.writeShort(getStatus14());
        byteBuf.writeByte(getStatus15());
        byteBuf.writeByte(getStatus16());
        byteBuf.writeByte(getStatus17());
        byteBuf.writeByte(getStatus18());
        byteBuf.writeShort(getStatus19());
        byteBuf.writeShort(getStatus20());
        byteBuf.writeByte(getStatus21());
        byteBuf.writeByte(getStatus22());
        byteBuf.writeByte(getStatus23());
        byteBuf.writeByte(getStatus24());
        byteBuf.writeShort(getStatus25());
        byteBuf.writeShort(getStatus26());
        byteBuf.writeShort(getStatus27());
        byteBuf.writeShort(getStatus28());
        byteBuf.writeShort(getStatus29());
        byteBuf.writeByte(getStatus30());
        byteBuf.writeByte(getStatus31());
        byteBuf.writeByte(getStatus32());
        byteBuf.writeByte(getStatus33());
        byteBuf.writeByte(getStatus34());
        byteBuf.writeByte(getStatus35());
        byteBuf.writeInt(getReserved2());
    }

    /**
     * 子类解码
     *
     * @param byteBuf
     */
    @Override
    protected void decodeInternal(ByteBuf byteBuf)
    {
        setStatus1(byteBuf.readShort());
        setStatus2(byteBuf.readShort());
        setStatus3(byteBuf.readShort());
        setStatus4(byteBuf.readShort());
        setReserved1(byteBuf.readFloat());
        setStatus5(byteBuf.readShort());
        setStatus6(byteBuf.readShort());
        setStatus7(byteBuf.readShort());
        setStatus8(byteBuf.readByte());
        setStatus9(byteBuf.readByte());
        setStatus10(byteBuf.readByte());
        setStatus11(byteBuf.readByte());
        setStatus12(byteBuf.readByte());
        setStatus13(byteBuf.readByte());
        setStatus14(byteBuf.readShort());
        setStatus15(byteBuf.readByte());
        setStatus16(byteBuf.readByte());
        setStatus17(byteBuf.readByte());
        setStatus18(byteBuf.readByte());
        setStatus19(byteBuf.readShort());
        setStatus20(byteBuf.readShort());
        setStatus21(byteBuf.readByte());
        setStatus22(byteBuf.readByte());
        setStatus23(byteBuf.readByte());
        setStatus24(byteBuf.readByte());
        setStatus25(byteBuf.readShort());
        setStatus26(byteBuf.readShort());
        setStatus27(byteBuf.readShort());
        setStatus28(byteBuf.readShort());
        setStatus29(byteBuf.readShort());
        setStatus30(byteBuf.readByte());
        setStatus31(byteBuf.readByte());
        setStatus32(byteBuf.readByte());
        setStatus33(byteBuf.readByte());
        setStatus34(byteBuf.readByte());
        setStatus35(byteBuf.readByte());
        setReserved2(byteBuf.readInt());
    }
}
