From 03b0fb0ba2de86bcfff277778826547c0e37a93f Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期四, 20 十一月 2025 23:52:51 +0800
Subject: [PATCH] 优化修改

---
 src/chushihua/lunxun.java |   63 +++++++++++++++----------------
 1 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/src/chushihua/lunxun.java b/src/chushihua/lunxun.java
index 6ed53dd..8d08dff 100644
--- a/src/chushihua/lunxun.java
+++ b/src/chushihua/lunxun.java
@@ -56,7 +56,7 @@
             
             if (result) {
                 if (DEBUG_ENABLED) {
-                    System.out.println("涓插彛杩炴帴姝e父");
+                    //System.out.println("涓插彛杩炴帴姝e父");
                 }
                 serialConnected = true;
             } else {
@@ -95,7 +95,7 @@
      */
     public static boolean startPolling() {
         if (isRunning) {
-            System.out.println("杞鏌ヨ宸茬粡鍦ㄨ繍琛屼腑");
+            //System.out.println("杞鏌ヨ宸茬粡鍦ㄨ繍琛屼腑");
             return true;
         }
         
@@ -115,10 +115,7 @@
         try {
             pollingThread = new Thread(new PollingTask(), "CardSlot-Polling-Thread");
             pollingThread.setDaemon(true);
-            pollingThread.start();            
-            if (DEBUG_ENABLED) {
-                System.out.println("杞鏌ヨ宸插惎鍔紝闂撮殧: " + pollingInterval + "ms");
-            }
+            pollingThread.start(); 
             return true;
         } catch (Exception e) {
             System.err.println("鍚姩杞鏌ヨ绾跨▼鏃跺彂鐢熷紓甯�: " + e.getMessage());
@@ -134,7 +131,7 @@
      */
     public static boolean stopPolling() {
         if (!isRunning) {
-            System.out.println("杞鏌ヨ鏈湪杩愯");
+            //System.out.println("杞鏌ヨ鏈湪杩愯");
             return false;
         }
         
@@ -163,7 +160,7 @@
         }
         
         shouldStop.set(false);
-        System.out.println("杞鏌ヨ宸插仠姝�");
+        //System.out.println("杞鏌ヨ宸插仠姝�");
         return true;
     }
     
@@ -174,20 +171,20 @@
     public static boolean pausePolling() {
         if (!isRunning) {
             if (DEBUG_ENABLED) {
-                System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曟殏鍋�");
+                //System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曟殏鍋�");
             }
             return false;
         }
         
         if (isPaused) {
             if (DEBUG_ENABLED) {
-                System.out.println("杞鏌ヨ宸茬粡澶勪簬鏆傚仠鐘舵��");
+                //System.out.println("杞鏌ヨ宸茬粡澶勪簬鏆傚仠鐘舵��");
             }
             return false;
         }
         
         isPaused = true;
-        System.out.println("杞鏌ヨ宸叉殏鍋�");
+        //System.out.println("杞鏌ヨ宸叉殏鍋�");
         return true;
     }
     
@@ -197,12 +194,12 @@
      */
     public static boolean resumePolling() {
         if (!isRunning) {
-            System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曟仮澶�");
+            //System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曟仮澶�");
             return false;
         }
         
         if (!isPaused) {
-            System.out.println("杞鏌ヨ鏈浜庢殏鍋滅姸鎬�");
+            //System.out.println("杞鏌ヨ鏈浜庢殏鍋滅姸鎬�");
             return false;
         }
         
@@ -216,7 +213,7 @@
         synchronized (lunxun.class) {
             lunxun.class.notifyAll(); // 鍞ら啋绛夊緟鐨勭嚎绋�
         }
-        System.out.println("杞鏌ヨ宸叉仮澶�");
+        //System.out.println("杞鏌ヨ宸叉仮澶�");
         return true;
     }
     
@@ -255,7 +252,7 @@
         }
         
         pollingInterval = interval;
-        System.out.println("杞闂撮殧宸茶缃负: " + interval + "ms");
+        //System.out.println("杞闂撮殧宸茶缃负: " + interval + "ms");
         
         // 濡傛灉姝e湪杩愯锛岄噸鏂板惎鍔ㄤ互搴旂敤鏂扮殑闂撮殧
         if (isRunning) {
@@ -297,13 +294,13 @@
             if (configSystem.isInitialized()) {
                 MachineConfig machineConfig = configSystem.getMachineConfig();
                 pollingInterval = machineConfig.getPollingInterval();
-                System.out.println("浠庨厤缃姞杞借疆璇㈤棿闅�: " + pollingInterval + "ms");
+                //System.out.println("浠庨厤缃姞杞借疆璇㈤棿闅�: " + pollingInterval + "ms");
             } else {
-                System.out.println("閰嶇疆绯荤粺鏈垵濮嬪寲锛屼娇鐢ㄩ粯璁よ疆璇㈤棿闅�: " + pollingInterval + "ms");
+                //System.out.println("閰嶇疆绯荤粺鏈垵濮嬪寲锛屼娇鐢ㄩ粯璁よ疆璇㈤棿闅�: " + pollingInterval + "ms");
             }
         } catch (Exception e) {
             System.err.println("鍔犺浇杞闂撮殧閰嶇疆澶辫触: " + e.getMessage());
-            System.out.println("浣跨敤榛樿杞闂撮殧: " + pollingInterval + "ms");
+            //System.out.println("浣跨敤榛樿杞闂撮殧: " + pollingInterval + "ms");
         }
     }
     
@@ -319,7 +316,7 @@
      */
     public static void clearQueryCache() {
         queryCommandCache.clear();
-        System.out.println("鏌ヨ鎸囦护缂撳瓨宸叉竻绌�");
+        //System.out.println("鏌ヨ鎸囦护缂撳瓨宸叉竻绌�");
     }
     
     /**
@@ -334,7 +331,7 @@
         
         @Override
         public void run() {
-            System.out.println("杞鏌ヨ绾跨▼寮�濮嬭繍琛�");
+            //System.out.println("杞鏌ヨ绾跨▼寮�濮嬭繍琛�");
             
             while (isRunning && !Thread.currentThread().isInterrupted() && !shouldStop.get()) {
                 try {
@@ -387,7 +384,7 @@
                                 } else {
                                     consecutiveFailures++;
                                     if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
-                                        System.err.println("杩炵画澶辫触娆℃暟杩囧锛屾殏鍋滆疆璇�");
+                                        System.err.println("lunxun杩炵画澶辫触娆℃暟杩囧锛屾殏鍋滆疆璇�");
                                         pausePolling();
                                         break;
                                     }
@@ -406,7 +403,7 @@
                     }
                     
                 } catch (InterruptedException e) {
-                    System.out.println("杞鏌ヨ绾跨▼琚腑鏂�");
+                    //System.out.println("杞鏌ヨ绾跨▼琚腑鏂�");
                     Thread.currentThread().interrupt();
                     break;
                 } catch (Exception e) {
@@ -423,7 +420,7 @@
                 }
             }
             
-            System.out.println("杞鏌ヨ绾跨▼缁撴潫杩愯");
+            //System.out.println("杞鏌ヨ绾跨▼缁撴潫杩愯");
         }
         
         /**
@@ -442,7 +439,7 @@
                     if (sendResult) {
                         // 鍙湪璋冭瘯鏃惰緭鍑猴紝閬垮厤棰戠箒鎵撳嵃
                         if (DEBUG_ENABLED) {
-                            SystemDebugDialog.appendAsciiData(String.format("Slot %d Send query (hasCard !=1)", slotNumber));
+                            SystemDebugDialog.appendAsciiData(String.format("Slot %d Send query (hasCard !=1)\n", slotNumber));
                         }
                         return true;
                     } else {
@@ -494,7 +491,7 @@
                 
                 if (sendResult) {
                     if (DEBUG_ENABLED) {
-                        System.out.println("绔嬪嵆鏌ヨ鎴愬姛 - 鍗℃Ы " + slotNumber);
+                        //System.out.println("绔嬪嵆鏌ヨ鎴愬姛 - 鍗℃Ы " + slotNumber);
                     }
                     return true;
                 } else {
@@ -527,7 +524,7 @@
         int batchSize = 5; // 姣忔壒娆″彂閫�5涓煡璇�
         int totalSlots = MAX_SLOT - MIN_SLOT + 1;
         
-        System.out.println("寮�濮嬫壒閲忔煡璇㈡墍鏈夊崱妲�...");
+        //System.out.println("寮�濮嬫壒閲忔煡璇㈡墍鏈夊崱妲�...");
         
         for (int batchStart = MIN_SLOT; batchStart <= MAX_SLOT; batchStart += batchSize) {
             if (shouldStop.get()) {
@@ -554,7 +551,7 @@
             }
         }
         
-        System.out.println("鎵归噺鏌ヨ瀹屾垚锛屾垚鍔熷彂閫�: " + successCount + "/" + totalSlots);
+        //System.out.println("鎵归噺鏌ヨ瀹屾垚锛屾垚鍔熷彂閫�: " + successCount + "/" + totalSlots);
         return successCount;
     }
     
@@ -567,7 +564,7 @@
         lastSerialCheckTime = System.currentTimeMillis();
         
         if (connected) {
-            System.out.println("涓插彛杩炴帴鐘舵�佸凡璁剧疆涓�: 宸茶繛鎺�");
+//            //System.out.println("涓插彛杩炴帴鐘舵�佸凡璁剧疆涓�: 宸茶繛鎺�");
         } else {
             System.err.println("涓插彛杩炴帴鐘舵�佸凡璁剧疆涓�: 鏈繛鎺�");
             // 濡傛灉涓插彛鏂紑涓旇疆璇㈡鍦ㄨ繍琛岋紝鑷姩鏆傚仠杞
@@ -605,7 +602,7 @@
      */
     public static boolean setPollingPaused(boolean paused) {
         if (!isRunning) {
-            System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曡缃殏鍋滅姸鎬�");
+            //System.out.println("杞鏌ヨ鏈湪杩愯锛屾棤娉曡缃殏鍋滅姸鎬�");
             return false;
         }
         
@@ -613,10 +610,10 @@
             // 璇锋眰鏆傚仠
             if (!isPaused) {
                 isPaused = true;
-                System.out.println("杞鏌ヨ宸查�氳繃澶栭儴璋冪敤鏆傚仠");
+                //System.out.println("杞鏌ヨ宸查�氳繃澶栭儴璋冪敤鏆傚仠");
                 return true;
             } else {
-                System.out.println("杞鏌ヨ宸茬粡澶勪簬鏆傚仠鐘舵��");
+                //System.out.println("杞鏌ヨ宸茬粡澶勪簬鏆傚仠鐘舵��");
                 return false;
             }
         } else {
@@ -632,10 +629,10 @@
                 synchronized (lunxun.class) {
                     lunxun.class.notifyAll(); // 鍞ら啋绛夊緟鐨勭嚎绋�
                 }
-                System.out.println("杞鏌ヨ宸查�氳繃澶栭儴璋冪敤鎭㈠");
+                //System.out.println("杞鏌ヨ宸查�氳繃澶栭儴璋冪敤鎭㈠");
                 return true;
             } else {
-                System.out.println("杞鏌ヨ鏈浜庢殏鍋滅姸鎬�");
+                //System.out.println("杞鏌ヨ鏈浜庢殏鍋滅姸鎬�");
                 return false;
             }
         }

--
Gitblit v1.9.3