From 7687eb6cc76ab8ca20b39e7567255939abc4ff66 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期一, 29 四月 2024 09:16:24 +0800
Subject: [PATCH] 修改进片逻辑判断,添加异常捕获
---
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java | 55 ++++++++++++++++++++++++++++++++-----------------------
1 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
index 6e6ef8a..6181031 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
@@ -15,11 +15,37 @@
// 鐢ㄤ簬瀛樺偍搴旂敤绋嬪簭鐨勯厤缃俊鎭�
private Configuration config;
private static InitUtil initUtil;
+ // public static PlcParameterObject PlcMesObject;
+ // public static PlcParameterObject PlcReadObject;
+ // public static PlcParameterObject PlcframeObject;
+
// 鍒涘缓涓�涓嚜瀹氫箟鐨� S7 鎺у埗鍣ㄦ秷鎭鐞嗗櫒瀵硅薄
MessageHandler customS7Control = new MessageHandler();
// 鍗曚緥瀹炰緥
private static PLCAutoMes instance;
+ private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath();
+ private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
+ private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
+ private static String PlcParameter = PLCAutomaticParameterSettingReview2.class
+ .getResource("/JsonFile/PlcParameter.json").getPath();
+ private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json")
+ .getPath();
+ private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json")
+ .getPath();
+ private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath();
+ private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath();
+
+ // 璋冪敤initword鏂规硶
+
+ public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter);
+ public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest);
+ public static PlcBitObject plcBitObject = initUtil.initbit(PlcSign);
+ public static PlcParameterObject plcStateObject= initUtil.initword(PlcState);
+ public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm);
+ public static PlcParameterObject PlcMesObject = initUtil.initword(PlcMes);
+ public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead);
+ public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe);
// 绉佹湁鏋勯�犲嚱鏁�
public PLCAutoMes() throws IOException {
@@ -39,51 +65,34 @@
public void run() {
while (this != null) {
try {
- Thread.sleep(1000);
+ Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
-
-
- String jsonFilePath = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath();
-
- String jsonFilePath2 = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
- // String jsonFilePath3 = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
// System.out.println(jsonFilePath);
- // 璋冪敤initword鏂规硶
- PlcParameterObject PlcMesObject= initUtil.initword(jsonFilePath);
- // 璋冪敤initbit鏂规硶
- PlcParameterObject PlcReadObject= initUtil.initword(jsonFilePath2);
- // // 璋冪敤initbit鏂规硶
- // PlcParameterObject PlcframeObject= initUtil.initword(jsonFilePath3);
readAndUpdateWordValues(PlcReadObject);
readAndUpdateWordValues(PlcMesObject);
+ readAndUpdateWordValues(PlcframeObject);
// readAndUpdateWordValues(PlcframeObject);
-
-
-
// readAndUpdateWordValues(plcStateObject);
int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex();
- //System.out.println(index);
+ // System.out.println(index);
PlcMesObject.getPlcParameter("AddStart").getAddress(index);
- //System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index));
+ // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index));
List<String> addresses = new ArrayList<>();
addresses.add("FeedID");
addresses.add("AddStart");
- //System.out.println(addresses);
- //System.out.println(PlcMesObject.getPlcParameterValues(addresses));
+ // System.out.println(addresses);
+ // System.out.println(PlcMesObject.getPlcParameterValues(addresses));
List<String> addresses2 = new ArrayList<>();
addresses2.add("FeedID");
addresses2.add("FeedCarStatus");
System.out.println(PlcReadObject.getPlcParameterValues(addresses2));
-
-
-
}
}
--
Gitblit v1.8.0