张世豪
昨天 ef78717c5b956a26b360de44f774fc2b804296c2
src/chushihua/lunxun.java
@@ -56,7 +56,7 @@
            
            if (result) {
                if (DEBUG_ENABLED) {
                    System.out.println("串口连接正常");
                    //System.out.println("串口连接正常");
                }
                serialConnected = true;
            } else {
@@ -95,7 +95,7 @@
     */
    public static boolean startPolling() {
        if (isRunning) {
            System.out.println("轮询查询已经在运行中");
            //System.out.println("轮询查询已经在运行中");
            return true;
        }
        
@@ -117,7 +117,7 @@
            pollingThread.setDaemon(true);
            pollingThread.start();            
            if (DEBUG_ENABLED) {
                System.out.println("轮询查询已启动,间隔: " + pollingInterval + "ms");
                //System.out.println("轮询查询已启动,间隔: " + pollingInterval + "ms");
            }
            return true;
        } catch (Exception e) {
@@ -134,7 +134,7 @@
     */
    public static boolean stopPolling() {
        if (!isRunning) {
            System.out.println("轮询查询未在运行");
            //System.out.println("轮询查询未在运行");
            return false;
        }
        
@@ -163,7 +163,7 @@
        }
        
        shouldStop.set(false);
        System.out.println("轮询查询已停止");
        //System.out.println("轮询查询已停止");
        return true;
    }
    
@@ -174,20 +174,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 +197,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 +216,7 @@
        synchronized (lunxun.class) {
            lunxun.class.notifyAll(); // 唤醒等待的线程
        }
        System.out.println("轮询查询已恢复");
        //System.out.println("轮询查询已恢复");
        return true;
    }
    
@@ -255,7 +255,7 @@
        }
        
        pollingInterval = interval;
        System.out.println("轮询间隔已设置为: " + interval + "ms");
        //System.out.println("轮询间隔已设置为: " + interval + "ms");
        
        // 如果正在运行,重新启动以应用新的间隔
        if (isRunning) {
@@ -297,13 +297,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 +319,7 @@
     */
    public static void clearQueryCache() {
        queryCommandCache.clear();
        System.out.println("查询指令缓存已清空");
        //System.out.println("查询指令缓存已清空");
    }
    
    /**
@@ -334,7 +334,7 @@
        
        @Override
        public void run() {
            System.out.println("轮询查询线程开始运行");
            //System.out.println("轮询查询线程开始运行");
            
            while (isRunning && !Thread.currentThread().isInterrupted() && !shouldStop.get()) {
                try {
@@ -406,7 +406,7 @@
                    }
                    
                } catch (InterruptedException e) {
                    System.out.println("轮询查询线程被中断");
                    //System.out.println("轮询查询线程被中断");
                    Thread.currentThread().interrupt();
                    break;
                } catch (Exception e) {
@@ -423,7 +423,7 @@
                }
            }
            
            System.out.println("轮询查询线程结束运行");
            //System.out.println("轮询查询线程结束运行");
        }
        
        /**
@@ -494,7 +494,7 @@
                
                if (sendResult) {
                    if (DEBUG_ENABLED) {
                        System.out.println("立即查询成功 - 卡槽 " + slotNumber);
                        //System.out.println("立即查询成功 - 卡槽 " + slotNumber);
                    }
                    return true;
                } else {
@@ -527,7 +527,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 +554,7 @@
            }
        }
        
        System.out.println("批量查询完成,成功发送: " + successCount + "/" + totalSlots);
        //System.out.println("批量查询完成,成功发送: " + successCount + "/" + totalSlots);
        return successCount;
    }
    
@@ -567,7 +567,7 @@
        lastSerialCheckTime = System.currentTimeMillis();
        
        if (connected) {
            System.out.println("串口连接状态已设置为: 已连接");
//            //System.out.println("串口连接状态已设置为: 已连接");
        } else {
            System.err.println("串口连接状态已设置为: 未连接");
            // 如果串口断开且轮询正在运行,自动暂停轮询
@@ -605,7 +605,7 @@
     */
    public static boolean setPollingPaused(boolean paused) {
        if (!isRunning) {
            System.out.println("轮询查询未在运行,无法设置暂停状态");
            //System.out.println("轮询查询未在运行,无法设置暂停状态");
            return false;
        }
        
@@ -613,10 +613,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 +632,10 @@
                synchronized (lunxun.class) {
                    lunxun.class.notifyAll(); // 唤醒等待的线程
                }
                System.out.println("轮询查询已通过外部调用恢复");
                //System.out.println("轮询查询已通过外部调用恢复");
                return true;
            } else {
                System.out.println("轮询查询未处于暂停状态");
                //System.out.println("轮询查询未处于暂停状态");
                return false;
            }
        }