package com.jiayue.ipfcst.client.protocol2file;


import com.syjy.DataExchangeException;
import com.syjy.ReadConfigFile;
import com.syjy.tunnelinfo.BaseTunnelInfo;
import com.syjy.tunnelinfo.TunnelType;
import jxl.Cell;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * modbus协议tcp采集通道
 *
 * @author 修唯xiuwei
 * @version 3.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class GatherModbusRtuByTcpServerTunnelInfo extends BaseTunnelInfo {


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


	/**
	 * 自身的端口
	 */
	private Integer selfPort;

	/**
	 * 功能码
	 */
	private Integer functionCode = 3;


	/**
	 * 设备地址
	 */
	private Integer slaveId = 1;


	@Override
	public void setByRow(Cell[] cells) throws DataExchangeException {
		this.setSelfPort(Integer.parseInt(ReadConfigFile.getCellContext(cells[0])));
		this.setSlaveId(Integer.parseInt(ReadConfigFile.getCellContext(cells[1])));
		this.setFunctionCode(Integer.parseInt(ReadConfigFile.getCellContext(cells[2])));
	}
}
