huang
2025-09-03 6c9369ab9b7da99687857004470e8d7824eb69ae
JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java
@@ -38,12 +38,19 @@
        }
    }
    //连接
    public void connect(){
    public boolean connect() {
        try {
            if (this.socket != null && !this.socket.isClosed()) {
                this.socket.close();
            }
            this.socket=new Socket(Ip,Port);
            this.socket.setSoTimeout(300);
            log.info("PLC连接成功");
            return true;
        }catch (Exception e) {
            log.info("The IP address of the host cannot be determined:{}",e.getMessage());
            log.error("PLC连接失败", e);
            this.socket = null;
            return false;
        }
    }
    //关闭连接