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

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

/**
 * @author linyun
 * @version V1.0
 * @Title: StartStopData
 * @Description: 启停命令
 * @date 2022/11/15
 **/
@Data
public class StartStopData extends RequestData {

    /*启停性质*/
    private byte startStopNature;

    /*启动条件*/
    private byte startCondition;

    /*预约小时*/
    private byte appointmentHour;

    /*预约分钟*/
    private byte appointmentMinute;

    /*充电方式*/
    private byte chargeMode;

    /*充电数据*/
    private byte chargeData;

    /*充电电流*/
    private byte chargeCurrent;

    /** 充电模式 1：室内充电 2：应急充电*/
    private byte chargeType;

    /***
     * 子类编码
     * @param byteBuf
     */
    @Override
    protected void encodeInternal(ByteBuf byteBuf)
    {
        byteBuf.writeByte(getStartStopNature());
        byteBuf.writeByte(getStartCondition());
        byteBuf.writeByte(getAppointmentHour());
        byteBuf.writeByte(getAppointmentMinute());
        byteBuf.writeByte(getChargeMode());
        byteBuf.writeByte(getChargeData());
        byteBuf.writeByte(getChargeCurrent());
        byteBuf.writeByte(getChargeType());
    }

    /**
     * 子类解码
     *
     * @param byteBuf
     */
    @Override
    protected void decodeInternal(ByteBuf byteBuf)
    {
        setStartStopNature(byteBuf.readByte());
        setStartCondition(byteBuf.readByte());
        setAppointmentHour(byteBuf.readByte());
        setAppointmentMinute(byteBuf.readByte());
        setChargeMode(byteBuf.readByte());
        setChargeData(byteBuf.readByte());
        setChargeCurrent(byteBuf.readByte());
        setChargeType(byteBuf.readByte());
    }
}
