From eb30974d6de096bc767adbe4a7e5198efb9c122f Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Wed, 17 Aug 2022 09:46:50 +0800 Subject: [PATCH] mark --- .../dc/s7/my/s7connector/enmuc/S7Client.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/qgs/dc/s7/my/s7connector/enmuc/S7Client.java b/src/main/java/com/qgs/dc/s7/my/s7connector/enmuc/S7Client.java index 731caa8..b8a1748 100644 --- a/src/main/java/com/qgs/dc/s7/my/s7connector/enmuc/S7Client.java +++ b/src/main/java/com/qgs/dc/s7/my/s7connector/enmuc/S7Client.java @@ -4,7 +4,9 @@ import com.qgs.dc.s7.my.s7connector.api.DaveArea; import com.qgs.dc.s7.my.s7connector.api.S7Connector; import com.qgs.dc.s7.my.s7connector.api.factory.S7ConnectorFactory; import com.qgs.dc.s7.my.s7connector.api.utils.ByteUtils; +import com.qgs.dc.s7.my.s7connector.exception.S7Exception; import com.qgs.dc.s7.my.s7connector.type.PlcVar; +import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; @@ -27,9 +29,9 @@ import java.util.concurrent.TimeUnit; public enum S7Client { //TODO 步骤1 这里是配置多PLC 的,,,有多个plc 就在这里配置一个枚举类 //1500 西门子200smart、1200、1500默认的 机架号=0 槽位号=1; 300/400 默认的 机架-0 插槽-2 - S7_1500("192.168.0.51",0,1,2,PlcVarActual.HeartBeat), + S7_1500("192.168.0.51",0,1,1,PlcVarActual.HeartBeat), //1500 机架-0 插槽-1 - S7_1200("192.168.0.52",0,1,2,PlcVarActual.HeartBeatFor1200) + S7_1200("192.168.0.52",0,1,1,PlcVarActual.HeartBeatFor1200) //后续 在这里扩展 多PLC应用。 @@ -70,7 +72,7 @@ public enum S7Client { connectionPool(); ping(); - +// check_ping(); } @@ -268,8 +270,8 @@ public enum S7Client { .withSlot(slot) //optional slot 是插槽号 .build(); return connector; - }catch (Exception e){ - logger.info("创建S7Connector 连接失败"); + }catch (S7Exception e){ + logger.info("创建S7Connector 连接失败,原因:"+e.getMessage()); return null; } @@ -277,7 +279,10 @@ public enum S7Client { private void connectionPool(){ for(int i=0;i