From 3aa3916d0574365548b2d12c225d3f5e0ec23887 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期六, 16 九月 2023 07:57:45 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
---
springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
index 7e9a4fa..00d1d4b 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -3,6 +3,7 @@
import cn.hutool.json.JSONObject;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import com.example.springboot.mapper.AlarmMapper;
@@ -14,15 +15,20 @@
public void run() {
while (this != null) {
try {
- Thread.sleep(10000);
+ Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
- List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.DBx0.0", 40);
- if (plclist == null) {
-
- } else {
+ List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 40);
+ // Boolean[] values = { true, false, true, false, true, false, true, false,
+ // true, false, true, false, true, false,
+ // true, false, true, false, true, false, true, false, true, false, true, false,
+ // true, false, true, false, true,
+ // false, true, false, true, false,
+ // true, false, true, false };
+ // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values));
+ if (plclist != null) {
JSONObject jsonObject = new JSONObject();
@@ -31,13 +37,15 @@
if (sendwServer != null) {
sendwServer.sendMessage(jsonObject.toString());
}
- // 灏嗚鍙杙lc鏁版嵁鐨刾lclist杞崲涓烘暟缁�
- Short[] shuzu1 = plclist.toArray(new Short[0]);
- // Short[] shuzu1 = {
- // 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
- // 1, 0, 1, 0, 0,
- // 1, 0, 1, 0, 1, 0, 1, 0, 1,
- // };
+
+ // 灏嗚幏鍙栫殑甯冨皵绫诲瀷杞崲涓烘暣鏁扮被鍨�
+ List<Integer> Intlist = new ArrayList<>();
+ for (Boolean value : plclist) {
+ Intlist.add(value == true ? 1 : 0);
+
+ }
+ // 灏咺ntlist杞崲涓烘暟缁�
+ Integer[] shuzu1 = Intlist.toArray(new Integer[0]);
String[] shuzu = {
"D01 VFD error",
@@ -82,7 +90,7 @@
"B02 OUT pos error",
};
alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class);
- for (short i = 0; i < shuzu1.length; i++) {
+ for (short i = 0; i < shuzu.length; i++) {
short result = alarmMapper.selectnullti(shuzu[i]);
if (shuzu1[i] == 1 && result == 0) {
alarmMapper.Insertalarm(shuzu[i]);
--
Gitblit v1.8.0