package com.pwt.netty.common.vehicle1;

import com.pwt.netty.common.Codeable;
import lombok.Data;

/**
 * 协议A消息封装： 小端格式
 */

@Data
public abstract class Vehicle1Message implements Codeable {

    // 数据帧相关
    public static final short MAGIC = (short) 0xFDFE;
    public static final int MAGIC_LENGTH = 2;

    // header = frame header(2 bytes) + length(1 byte)
    public static final short HEADER_LENGTH = 3;

    public static final int VIN_LENGTH = 17;

    public static final int BATTERY_SN_LENGTH = 24;

    public static final int DATE_LENGTH = 8;

    // 公司编码
    public static final int COMPANY_CODE_LENGTH = 8;

    public final byte type;

    protected Vehicle1Message(byte type) {
        this.type = type;
    }

    /**
     * 返回当前data类型在协议中定义的长度. 1(功能码) + 实际数据长度
     * @return 数据长度
     */
    public abstract int getProtocolLength();

    public byte getType() {
        return type;
    }
}
