package com.jiayue.ipfcst.common.data.entity.gathertunnelinfo;

import com.jiayue.ipfcst.common.data.constant.enums.TunnelType;
import com.jiayue.ipfcst.common.data.entity.BaseTunnelInfo;
import com.jiayue.ipfcst.common.data.entity.ProtocolDataType;
import com.jiayue.ipfcst.common.data.entity.ProtocolGatherDataPoint;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Proxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

/**
 * modbus协议rtu采集通道
 *
 * @author 修唯xiuwei
 * @version 3.0
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@Proxy(lazy = false)
public class GatherModbusRtuTunnelInfo extends BaseTunnelInfo<ProtocolGatherDataPoint> {


    /**
     * 串口名称
     */
    @Column(length = 50)
    private String serialName;
    /**
     * 波特率
     */
    @Column(length = 7)
    private Integer baudRate;
    /**
     * 功能码
     */
    @Column(length = 2)
    private Integer functionCode = 3;
    /**
     * 设备地址
     */
    @Column(length = 4)
    private Integer slaveId = 1;

    @Column(length = 2)
    @Enumerated(EnumType.STRING)
    private ProtocolDataType protocolDataType;


    /**
     * 数据位 5,6,7,8
     */
    private Integer dataBits = 8;

    /**
     * 停止位  1 2  3(1.5)
     */
    private Integer stopBits = 1;

    /**
     * 奇偶校验
     * PARITY_NONE = 0  无校验;
     * PARITY_ODD = 1  奇校验;
     * PARITY_EVEN = 2  偶校验;
     * PARITY_MARK = 3  0校验;
     * PARITY_SPACE = 4  1校验;
     */
    private Integer parity = 0;

    /**
     * 初始化时确定通道类型
     */
    public GatherModbusRtuTunnelInfo() {
        this.setTunnelType(TunnelType.MODBUSRTUMASTER);
    }


}
