refactor(plc): 修改PLC连接对象初始化方式
- 将ModbusTcpNet对象的局部变量声明移除 - 使用类成员变量modbusTcpNet进行初始化 - 确保连接对象在整个类中的统一访问
This commit is contained in:
@@ -168,7 +168,7 @@ public class PlcSrgvRead implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectServer() {
|
public void ConnectServer() {
|
||||||
ModbusTcpNet modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
|
modbusTcpNet = new ModbusTcpNet();//创建一个Modbus对象
|
||||||
try {
|
try {
|
||||||
modbusTcpNet.setIpAddress(this.ip);
|
modbusTcpNet.setIpAddress(this.ip);
|
||||||
modbusTcpNet.setPort(this.port);
|
modbusTcpNet.setPort(this.port);
|
||||||
|
|||||||
Reference in New Issue
Block a user