package com.mvc.netty.xmodem;

import io.netty.channel.ChannelHandlerContext;

import java.util.Date;
import java.util.HashMap;

/**
 * XModem传输过程对象
 */
public class XModemTransferModel {
    public static final InheritableThreadLocal<HashMap<Integer, XModemTransferModel>> inheritableThreadLocal = new InheritableThreadLocal<>() {
        @Override
        protected HashMap<Integer, XModemTransferModel> initialValue() {
            return new HashMap<>();
        }
    };

    private byte[] fileStream;//原始文件流
    private int packIndex;//包索引
    private int packCount;//总包数
    private Date createTime;//连接创建时间
    private Date lastRevTime;//最后一次接收时间
    private boolean sendEot;//是否发送了结束标记
    private ChannelHandlerContext channelHandlerContext;//TCP连接通道
    private int reissueNum;//重发次数(设备未应答无响应时的重发)
    private boolean sendOver;

    private String deviceSn;

    public byte[] getFileStream() {
        return fileStream;
    }

    public void setFileStream(byte[] fileStream) {
        this.fileStream = fileStream;
    }

    public int getPackIndex() {
        return packIndex;
    }

    public void setPackIndex(int packIndex) {
        this.packIndex = packIndex;
    }

    public int getPackCount() {
        return packCount;
    }

    public void setPackCount(int packCount) {
        this.packCount = packCount;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastRevTime() {
        return lastRevTime;
    }

    public void setLastRevTime(Date lastRevTime) {
        this.lastRevTime = lastRevTime;
    }

    public boolean isSendEot() {
        return sendEot;
    }

    public void setSendEot(boolean sendEot) {
        this.sendEot = sendEot;
    }

    public ChannelHandlerContext getChannelHandlerContext() {
        return channelHandlerContext;
    }

    public void setChannelHandlerContext(ChannelHandlerContext channelHandlerContext) {
        this.channelHandlerContext = channelHandlerContext;
    }

    public int getReissueNum() {
        return reissueNum;
    }

    public void setReissueNum(int reissueNum) {
        this.reissueNum = reissueNum;
    }

    public boolean isSendOver() {
        return sendOver;
    }

    public void setSendOver(boolean sendOver) {
        this.sendOver = sendOver;
    }

    public String getDeviceSn() {
        return deviceSn;
    }

    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}
