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 | 40 ++++++++++++++++++++++------------------
1 files changed, 22 insertions(+), 18 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 3edf6e7..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());
}
- // 灏嗚鍙栧埌鐨刾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,15 +90,11 @@
"B02 OUT pos error",
};
alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class);
- for (short i = 0; i < shuzu1.length; i++) {
- // 鏌ヨ缁撴潫鏃堕棿涓簄ull鐨勪釜鏁�
+ for (short i = 0; i < shuzu.length; i++) {
short result = alarmMapper.selectnullti(shuzu[i]);
- // 璇诲彇PLC瀵瑰簲鍦板潃鐨勫�间负1骞朵笖璇ュ湴鍧�娌℃湁缁撴潫鏃堕棿涓簄ull鐨勬暟鎹紝娣诲姞涓�鏉℃柊鐨勬姤璀︿俊鎭�
if (shuzu1[i] == 1 && result == 0) {
alarmMapper.Insertalarm(shuzu[i]);
- }
- // 璇诲彇PLC瀵瑰簲鍦板潃鐨勫�间负0骞朵笖璇ュ湴鍧�鏈夌粨鏉熸椂闂翠负null鐨勬暟鎹紝淇敼璇ユ潯鏁版嵁鐨勭粨鏉熸椂闂�
- else if (shuzu1[i] == 0 && result > 0) {
+ } else if (shuzu1[i] == 0 && result > 0) {
alarmMapper.updatealarm(shuzu[i]);
}
}
--
Gitblit v1.8.0