From 100f4dcea20a32663a07e91525de111f7515eb79 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 21 十一月 2025 17:25:53 +0800
Subject: [PATCH] 可发布版本202517.25
---
src/chuankou/Sendmsg.java | 99 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 90 insertions(+), 9 deletions(-)
diff --git a/src/chuankou/Sendmsg.java b/src/chuankou/Sendmsg.java
index 6479155..0b51605 100644
--- a/src/chuankou/Sendmsg.java
+++ b/src/chuankou/Sendmsg.java
@@ -2,6 +2,15 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+import javax.swing.SwingWorker;
+
+import chushihua.lunxun;
+import dialog.Charulog;
+import dialog.Dingshidialog;
+import dialog.Errlog;
+import publicway.OpenDoor;
+import xitongshezhi.SystemDebugDialog;
+
/**
* 涓插彛娑堟伅鍙戦�佸伐鍏风被
* 鎻愪緵楂樻�ц兘鐨勪覆鍙f秷鎭彂閫佸姛鑳斤紝閫傚悎楂橀璋冪敤
@@ -16,6 +25,78 @@
// 鏃ユ湡鏍煎紡鍖�
private static final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss.SSS");
+
+
+ /**鍙戝崱鏈嶅姟鍣ㄦ帶鍒舵墦寮�鏌愪釜鏌滈棬璋冪敤鎸囦护
+ * @param int slotId鏌滈棬缂栧彿1-60
+ * @param int type 1鏄湇鍔″櫒鍙戝崱锛�2鏄鐞嗗憳鍙戝崱*/
+ public static boolean opendoorzhiling(int slotId,int type) {
+ lunxun.setSendChaxunzhiling(false);//鏆傚仠鏌ヨ鎸囦护
+ // 璋冪敤OpenDoor鐢熸垚寮�闂ㄦ寚浠�
+ String command = OpenDoor.openOneDoor(slotId, type);
+ boolean sendResult = Sendmsg.sendMessage(command);
+ String mes=command+";type"+type+"鎺у埗鎵撳紑"+slotId+"鏌滈棬";
+ Charulog.logOperation(mes);
+ if (lunxun.DEBUG_ENABLED) {
+ SystemDebugDialog.appendAsciiData(mes);
+ }
+
+ lunxun.setSendChaxunzhiling(true);//寮�濮嬫煡璇㈡寚浠�
+ return sendResult;
+ }
+
+ /**
+ * 鎵撳紑鍏ㄩ儴鍗℃Ы鐨勫叕鐢ㄩ潤鎬佹柟娉�
+ * @param type 鎿嶄綔绫诲瀷锛�1-鏈嶅姟鍣ㄥ彂鍗★紝2-绠$悊鍛樺彂鍗�
+ */
+ public static void openAllSlots(int type) {
+ lunxun.setSendChaxunzhiling(false);//鏆傚仠鏌ヨ鎸囦护
+ // 浣跨敤SwingWorker鍦ㄥ悗鍙版墽琛岋紝閬垮厤闃诲UI
+ SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
+ @Override
+ protected Void doInBackground() throws Exception {
+ // 閬嶅巻鎵�鏈夊崱妲斤紙1-60锛�
+ for (int slotId = 1; slotId <= 60; slotId++) {
+ try {
+ // 鐢熸垚寮�闂ㄦ寚浠�
+ String command = OpenDoor.openOneDoor(slotId, type);
+
+ // 鍙戦�佷覆鍙f寚浠�
+ boolean sent = Sendmsg.sendMessage(command);
+
+ if (!sent) {
+ Errlog.logOperation("鍙戦�佹寚浠ゅ埌鍗℃Ы " + slotId + " 澶辫触");
+ }
+
+ // 闂撮殧100ms
+ Thread.sleep(100);
+
+ } catch (Exception e) {
+ Errlog.logOperation("澶勭悊鍗℃Ы " + slotId + " 鏃跺彂鐢熼敊璇�: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void done() {
+ // 鍙�夛細瀹屾垚鍚庡彲浠ユ坊鍔犲洖璋冨鐞�
+ System.out.println("鍏ㄩ儴鍗℃Ы寮�闂ㄦ寚浠ゅ彂閫佸畬鎴�");
+ String types="绠$悊鍛�";
+ if(type==1) {
+ types="鏈嶅姟鍣ㄦ寚浠�";
+ }
+ String message=types+"宸插皢鍏ㄩ儴鍗℃Ы宸茬粡鎵撳紑璇峰彇鍗�";
+ Dingshidialog.showTimedDialog(null,5,message);
+ Charulog.logOperation(message);
+ }
+ };
+
+ worker.execute();
+ lunxun.setSendChaxunzhiling(true);//寮�濮嬫煡璇㈡寚浠�
+ }
+
/**
* 璁剧疆涓插彛鏈嶅姟瀹炰緥
@@ -39,12 +120,12 @@
*/
public static boolean sendMessage(String message) {
if (!isPortOpen || serialService == null) {
- System.err.println("[" + getCurrentTime() + "] 涓插彛鏈墦寮�锛屾棤娉曞彂閫佹暟鎹�");
+ Errlog.logOperation("[" + getCurrentTime() + "] 涓插彛鏈墦寮�锛屾棤娉曞彂閫佹暟鎹�");
return false;
}
if (message == null || message.trim().isEmpty()) {
- System.err.println("[" + getCurrentTime() + "] 鍙戦�佹暟鎹负绌�");
+ Errlog.logOperation("[" + getCurrentTime() + "] 鍙戦�佹暟鎹负绌�");
return false;
}
@@ -56,7 +137,7 @@
try {
byte[] data = hexStringToByteArray(text);
if (data == null) {
- System.err.println("[" + getCurrentTime() + "] HEX杞崲澶辫触锛屾暟鎹�: " + text);
+ Errlog.logOperation("[" + getCurrentTime() + "] HEX杞崲澶辫触锛屾暟鎹�: " + text);
return false;
}
@@ -70,7 +151,7 @@
} else {
retryCount++;
if (retryCount <= MAX_RETRY) {
- System.err.println("[" + getCurrentTime() + "] 鍙戦�佸け璐ワ紝姝e湪閲嶈瘯 (" + retryCount + "/" + MAX_RETRY + ")");
+ Errlog.logOperation("[" + getCurrentTime() + "] 鍙戦�佸け璐ワ紝姝e湪閲嶈瘯 (" + retryCount + "/" + MAX_RETRY + ")");
try {
Thread.sleep(50); // 閲嶈瘯鍓嶇瓑寰�
} catch (InterruptedException e) {
@@ -78,16 +159,16 @@
break;
}
} else {
- System.err.println("[" + getCurrentTime() + "] 涓插彛鍙戦�佸け璐ワ紝鎸囦护: " + text.toUpperCase());
- System.err.println("[" + getCurrentTime() + "] 涓插彛鐘舵�� - 鎵撳紑: " + isPortOpen + ", 鏈嶅姟: " + (serialService != null));
+ Errlog.logOperation("[" + getCurrentTime() + "] 涓插彛鍙戦�佸け璐ワ紝鎸囦护: " + text.toUpperCase());
+ Errlog.logOperation("[" + getCurrentTime() + "] 涓插彛鐘舵�� - 鎵撳紑: " + isPortOpen + ", 鏈嶅姟: " + (serialService != null));
if (serialService != null) {
- System.err.println("[" + getCurrentTime() + "] 涓插彛鏈嶅姟鐘舵�� - 鏄惁鎵撳紑: " + serialService.isOpen());
+ Errlog.logOperation("[" + getCurrentTime() + "] 涓插彛鏈嶅姟鐘舵�� - 鏄惁鎵撳紑: " + serialService.isOpen());
}
return false;
}
}
} catch (Exception e) {
- System.err.println("[" + getCurrentTime() + "] 鍙戦�佸紓甯革紝鎸囦护: " + text.toUpperCase());
+ Errlog.logOperation("[" + getCurrentTime() + "] 鍙戦�佸紓甯革紝鎸囦护: " + text.toUpperCase());
e.printStackTrace();
return false;
}
@@ -103,7 +184,7 @@
public static boolean isPortOpen() {
boolean open = isPortOpen && serialService != null;
if (!open && DEBUG_MODE) {
- System.err.println("[" + getCurrentTime() + "] 涓插彛鐘舵�佹鏌�: 鏈墦寮�");
+ Errlog.logOperation("[" + getCurrentTime() + "] 涓插彛鐘舵�佹鏌�: 鏈墦寮�");
}
return open;
}
--
Gitblit v1.9.3