/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2022/11/11
 */
package org.ts.ddcs.datatemplate.swDataTemplate;

import lombok.EqualsAndHashCode;
import org.ts.ddcs.dataStream.DataStreamCache;


/***
 * Date:2022/11/11
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@EqualsAndHashCode(callSuper = false)
public class SwDataStreamCache extends DataStreamCache {

    /**
     * 包数据
     */
    private byte[] packet;
    /**
     * 包长度
     */
    private int len;

    /**
     * 命令(HEX_2)
     */
    private byte command;
    /**
     * 报文头7E7E
     */
    private byte[] packetHeader;
    /**
     * 中心站地址
     */
    private byte[] centerStation;
    /**
     * RTU地址
     */
    private byte[] rtuCodeByte;
    /**
     * RTU密码
     */
    private byte[] rtuPw;
    /**
     * 功能码
     */
    private byte[] funcCode;
    /**
     * 报文上下行标识及长度
     */
    private byte[] dataAreaLen;
    /**
     * 报文起始符
     */
    private byte[] dataAreaStartFlag;
    /**
     * 报文正文
     */
    private byte[] dataArea;
    /**
     * 报文起始符
     */
    private byte[] dataAreaEndFlag;
    /**
     * 校验码
     */
    private byte[] packetCrc16;

    public void setCommand(byte buff) {
        this.command = buff;
    }

    public void setPacketHeader(byte[] packetHeader) {
        this.packetHeader = packetHeader;
    }

    public void setCenterStation(byte[] centerStation) {
        this.centerStation = centerStation;
    }

    public void setRtuCodeByte(byte[] rtuCodeByte) {
        this.rtuCodeByte = rtuCodeByte;
    }

    public void setRtuPw(byte[] buff) {
        this.rtuPw = buff;
    }

    public void setFuncCode(byte[] buff) {
        this.funcCode = buff;
    }

    public void setDataAreaLen(byte[] buff) {
        this.dataAreaLen = buff;
    }

    public void setDataAreaStartFlag(byte[] buff) {
        this.dataAreaStartFlag = buff;
    }

    public void setDataAreaEndFlag(byte[] buff) {
        this.dataAreaEndFlag = buff;
    }

    public void setPacketCrc16(byte[] buff) {
        this.packetCrc16 = buff;
    }

    @Override
    public void setPacketBuff(byte[] buff) {
        this.packet = buff;
    }

    @Override
    public byte[] getPacketBuff() {
        return this.packet;
    }

    @Override
    public void setPacketLen(int len) {
        this.len = len;
    }

    @Override
    public int getPacketLen() {
        return this.len;
    }

    @Override
    public void setBodyBuff(byte[] buff) {
        this.dataArea = buff;
    }

    @Override
    public byte[] getBodyBuff() {
        return this.dataArea;
    }

    @Override
    public int getBodyLen() {
        if (null != this.dataArea){
            return this.dataArea.length;
        }
        return 0;
    }

    @Override
    public byte[] getDeviceCodeBuff() {
        return this.rtuCodeByte;
    }
}
