From af1e6e2ccc7ecd165ac5f6ee619f0665a4919871 Mon Sep 17 00:00:00 2001 From: zwl <1051256694@qq.com> Date: 星期六, 21 六月 2025 16:02:23 +0800 Subject: [PATCH] # --- src/main/webapp/static/wcs/js/console3.map.js | 2 src/main/webapp/static/wcs/js/console2.map.js | 2 src/main/java/com/zy/core/thread/LedThread.java | 87 ++++++++++++++----------------------------- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 11 ++++- src/main/java/com/zy/core/cache/MessageQueue.java | 1 src/main/resources/application-prod.yml | 2 src/main/resources/license.lic | 0 src/main/webapp/static/wcs/js/console1.map.js | 2 src/main/resources/application.yml | 2 9 files changed, 42 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index a6f9389..593a28b 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -1916,14 +1916,21 @@ // 鑾峰彇led绾跨▼ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); // led鏄剧ず榛樿鍐呭 - if (reset && !ledThread.isLedMk()) { + if (reset) { ledThread.setLedMk(true); - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { log.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); } else { } } +// if (reset) { +// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { +// log.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); +// } else { +// +// } +// } } // log.info(""+mark+" - 0"+" - 鎵ц瀹屾垚锛氬叾浠� ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅"); } diff --git a/src/main/java/com/zy/core/cache/MessageQueue.java b/src/main/java/com/zy/core/cache/MessageQueue.java index 7c63158..5ffad0b 100644 --- a/src/main/java/com/zy/core/cache/MessageQueue.java +++ b/src/main/java/com/zy/core/cache/MessageQueue.java @@ -1,6 +1,5 @@ package com.zy.core.cache; -import com.zy.asrs.utils.CommandUtils; import com.zy.core.Slave; import com.zy.core.enums.SlaveType; import com.zy.core.model.Task; diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java index a0995f5..f3d001a 100644 --- a/src/main/java/com/zy/core/thread/LedThread.java +++ b/src/main/java/com/zy/core/thread/LedThread.java @@ -28,6 +28,8 @@ import onbon.bx05.utils.DisplayStyleFactory; import java.awt.*; +import java.io.IOException; +import java.net.InetAddress; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -52,20 +54,11 @@ public LedThread(Slave slave) { this.slave = slave; - try { - Bx5GEnv.initial(3000); - screen = new Bx5GScreenClient("my"); - } catch (Exception e) { - e.printStackTrace(); - log.info("led杩炴帴鏋勯�犲櫒閿欒 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); - } } @Override @SuppressWarnings({"InfiniteLoopStatement", "unchecked"}) public void run() { - connect(); - close(); while (true) { try { Task task = MessageQueue.poll(SlaveType.Led, slave.getId()); @@ -78,6 +71,7 @@ // 澶嶄綅 case 2: reset(); +// this.ledMk = false; break; case 5: error((String) task.getData()); @@ -149,63 +143,35 @@ } private void reset() throws Bx5GException { - if (!connect()) { - return; - } -// if (resetStatus) { -// return; -// } - pf = new ProgramBxFile( 0, screen.getProfile()); - pf.setFrameShow(false); - // 鍒嗗埆杈撳叆X锛孻锛寃idth锛宧eight - area = new TextCaptionBxArea( 0,0,96,48, screen.getProfile()); - // 鍒涘缓涓�涓暟鎹〉 - TextBxPage page = new TextBxPage(); - -// List<String> list = null; -// try { -// String ledDefaultMsg = Parameter.get().getLedDefaultMsg(); -// list = JSON.parseArray(ledDefaultMsg, String.class); -// } catch (Exception ignore) { -// } -// if (!Cools.isEmpty(list)) { -// for (String str : list) { -// page.newLine(str); -// } -// } else { -// page.newLine("鑷姩鍖栫珛浣撲粨搴�"); -// page.newLine("瑗挎牸杩堣偂浠芥湁闄愬叕鍙�"); -// } - page.newLine("鍔涙簮鏅鸿兘浠撳偍"); - - // 璁剧疆瀛椾綋 - page.setFont(new Font("瀹嬩綋",Font.PLAIN,13)); - // 璁剧疆鏂囨湰棰滆壊 - page.setForeground(Color.red); - // 璁剧疆鏄剧ず鐗规妧涓哄揩閫熸墦鍑� - page.setDisplayStyle(styles[6]); - area.clearPages(); - area.addPage(page); - pf.addArea(area); - // 鏇存柊鑺傜洰 - if (pf.validate() != null) { - log.info("pf out of range"); - } else { - // 鏇存柊鑺傜洰 - screen.writeProgram(pf); -// resetStatus = true; - } - close(); + errorMsg.delete(0, errorMsg.length()); } + @Override public boolean connect() { boolean connRes = false; + + // ======= 馃寪 娣诲姞缃戠粶鍙揪鎬ф娴� ======= try { - connRes = screen.connect(slave.getIp(),slave.getPort()); - screen.turnOn(); - } catch (Exception ignore) { + InetAddress address = InetAddress.getByName(slave.getIp()); + if (!address.isReachable(2000)) { + log.warn("璁惧涓嶅彲杈撅紝璺宠繃杩炴帴: {}", slave.getIp()); + return false; // 鎻愬墠杩斿洖锛岄伩鍏嶆棤鎰忎箟杩炴帴灏濊瘯 + } + } catch (IOException e) { + log.error("IP妫�娴嬪紓甯�: {}", e.getMessage()); + return false; // 鍙鎯呭喌鍐冲畾鏄惁 return } + + // ======= 灏濊瘯杩炴帴璁惧 ======= + try { + connRes = screen.connect(slave.getIp(), slave.getPort()); + screen.turnOn(); // 濡傛灉 connect 鎴愬姛鍐嶅紑灞� + } catch (Exception e) { + log.error("杩炴帴寮傚父: {}", e.getMessage(), e); // 閬垮厤鎹曡幏鍚庢棤鎻愮ず + } + + // ======= 璁惧閿欒鐘舵�佸鐞� ======= DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); if (connRes) { log.info("led杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); @@ -214,8 +180,10 @@ log.error("led杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); deviceErrorService.addDeviceError("led", slave.getId(), "led杩炴帴澶辫触"); } + return connRes; } + @Override public void close() { @@ -465,6 +433,7 @@ screen.disconnect(); } private void error(String msg) { + log.error("閿欒淇℃伅涓猴細{}",msg); errorMsg.delete(0, errorMsg.length()); errorMsg.append(msg); } diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index dcf1649..84dff2e 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -281,7 +281,7 @@ ip: 192.168.110.212 port: 5005 devpPlcId: ${wcs-slave.devp[0].id} - staArr: 1014 + staArr: 1014,1015 # LED4 鎴愬搧搴�2F led[3]: id: 4 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0b6fb5c..2b7bec6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8081 + port: 8080 servlet: context-path: /@pom.build.finalName@ diff --git a/src/main/resources/license.lic b/src/main/resources/license.lic index 77bf55a..a17b988 100644 --- a/src/main/resources/license.lic +++ b/src/main/resources/license.lic Binary files differ diff --git a/src/main/webapp/static/wcs/js/console1.map.js b/src/main/webapp/static/wcs/js/console1.map.js index 95756eb..e0698ac 100644 --- a/src/main/webapp/static/wcs/js/console1.map.js +++ b/src/main/webapp/static/wcs/js/console1.map.js @@ -136,7 +136,7 @@ ], "areas": [{ "type": "Control_floor", - "id": "tabControl_floor1", + "id": "tabControl_floor2", "text": "妤煎眰", "top": 66, "left": 580, diff --git a/src/main/webapp/static/wcs/js/console2.map.js b/src/main/webapp/static/wcs/js/console2.map.js index 6471bd3..f152fc3 100644 --- a/src/main/webapp/static/wcs/js/console2.map.js +++ b/src/main/webapp/static/wcs/js/console2.map.js @@ -131,7 +131,7 @@ }], "areas": [{ "type": "Control_floor", - "id": "tabControl_floor1", + "id": "tabControl_floor3", "text": "妤煎眰", "top": 66, "left": 580, diff --git a/src/main/webapp/static/wcs/js/console3.map.js b/src/main/webapp/static/wcs/js/console3.map.js index b409a8d..1ab1d2e 100644 --- a/src/main/webapp/static/wcs/js/console3.map.js +++ b/src/main/webapp/static/wcs/js/console3.map.js @@ -136,7 +136,7 @@ ], "areas": [{ "type": "Control_floor", - "id": "tabControl_floor1", + "id": "tabControl_floor4", "text": "妤煎眰", "top": 66, "left": 580, -- Gitblit v1.9.1