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协议tcp采集通道
 *
 * @author 修唯xiuwei
 * @version 3.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Proxy(lazy = false)
public class GatherModbusTcpTunnelInfo extends BaseTunnelInfo<ProtocolGatherDataPoint> {

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

    /**
     * 远端ip
     */
    @Column(length = 15)
    private String remoteIp;

    /**
     * 远端端口
     */
    @Column(length = 6)
    private Integer remotePort = 502;

    /**
     * 远端备用ip
     */
    @Column(length = 15)
    private String remoteSpareIp;

    /**
     * 远端备用端口
     */
    @Column(length = 6)
    private Integer remoteSparePort;

    /**
     * 自身的ip
     */
    @Column(length = 15)
    private String selfIp;

    /**
     * 自身的端口
     */
    @Column(length = 6)
    private Integer selfPort;

    /**
     * 功能码
     */
    @Column(length = 2)
    private Integer functionCode = 3;

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

    /**
     * 设备地址
     */
    @Column(length = 4)
    private Integer slaveId = 1;


}
