package com.inspect.patrol.linkage.frame;

import com.inspect.base.core.utils.ByteUtil;
import com.inspect.base.core.utils.HexUtils;
import com.inspect.patrol.linkage.util.Cp56Time2aUtil;

import java.nio.charset.Charset;
import java.util.Date;

public class LinkageSignEntity {
    private String type = "EB90EB9055";
    private short stationNo;
    private short monitorIndexNo;
    private byte linkageType;
    private byte linkageAttributeLen;
    private String linkageAttribute;
    private byte linkageValueLen;
    private String linkageValue;
    private Date linkageTime = new Date();
    private byte sumCheck;

    public String getType() {
        return this.type;
    }

    public void setType(byte[] type) {
        this.type = HexUtils.binary(type, 16);
    }

    public int getStationNo() {
        return this.stationNo;
    }

    public void setStationNo(byte[] stationNo) {
        this.stationNo = ByteUtil.getShort(stationNo);
    }

    public int getMonitorIndexNo() {
        return this.monitorIndexNo;
    }

    public void setMonitorIndexNo(byte[] monitorIndexNo) {
        this.monitorIndexNo = ByteUtil.getShort(monitorIndexNo);
    }

    public int getLinkageType() {
        return this.linkageType;
    }

    public void setLinkageType(byte[] linkageType) {
        this.linkageType = linkageType[0];
    }

    public int getLinkageAttributeLen() {
        return this.linkageAttributeLen;
    }

    public void setLinkageAttributeLen(byte[] linkageAttributeLen) {
        this.linkageAttributeLen = linkageAttributeLen[0];
    }

    public String getLinkageAttribute() {
        return this.linkageAttribute;
    }

    public void setLinkageAttribute(byte[] linkageAttribute) {
        this.linkageAttribute = new String(linkageAttribute, Charset.forName("GB2312"));
    }

    public int getLinkageValueLen() {
        return this.linkageValueLen;
    }

    public void setLinkageValueLen(byte[] linkageValueLen) {
        this.linkageValueLen = linkageValueLen[0];
    }

    public String getLinkageValue() {
        return this.linkageValue;
    }

    public void setLinkageValue(byte[] linkageValue) {
        this.linkageValue = new String(linkageValue, Charset.forName("GB2312"));
    }

    public Date getLinkageTime() {
        return this.linkageTime;
    }

    public void setLinkageTime(byte[] linkageTime) {
        this.linkageTime = Cp56Time2aUtil.toDate(linkageTime);
    }

    public int getSumCheck() {
        return this.sumCheck;
    }

    public void setSumCheck(byte[] sumCheck) {
        this.sumCheck = sumCheck[0];
    }
}
