张世豪
5 小时以前 a6077217e25f5804027194a5c2848e773eda1abd
src/chushihua/Chushihua.java
@@ -2,6 +2,9 @@
import java.io.File;
import java.util.List;
import dialog.Dingshidialog;
import dialog.Errlog;
import home.MachineConfig;
/**
@@ -62,11 +65,11 @@
            initialize(DEFAULT_CONFIG_PATH);
            
            // 移除自动启动轮询的逻辑,由Homein统一管理
            System.out.println("系统配置初始化完成,轮询将由主启动类统一管理");
            ////System.out.println("系统配置初始化完成,轮询将由主启动类统一管理");
            
            return true;
        } catch (Exception e) {
            System.err.println("系统初始化异常: " + e.getMessage());
            Errlog.logOperation("系统初始化异常: " + e.getMessage());
            e.printStackTrace();
            return false;
        }
@@ -80,10 +83,10 @@
            // 停止轮询查询
            if (lunxun.isPolling()) {
                lunxun.stopPolling();
                System.out.println("系统关闭:轮询查询已停止");
                ////System.out.println("系统关闭:轮询查询已停止");
            }
        } catch (Exception e) {
            System.err.println("系统关闭异常: " + e.getMessage());
           Errlog.logOperation("系统关闭异常: " + e.getMessage());
        }
    }
    
@@ -96,7 +99,7 @@
            // 检查配置文件是否存在
            File configFile = new File(configFilePath);
            if (!configFile.exists()) {
                System.err.println("配置文件不存在: " + configFilePath);
                Errlog.logOperation("配置文件不存在: " + configFilePath);
                return false;
            }
            
@@ -109,17 +112,17 @@
            // 标记初始化完成
            initialized = true;
            
            System.out.println("系统初始化完成,配置已加载");
            System.out.println("设备编号: " + machineConfig.getMachineId());
            System.out.println("服务器地址: " + machineConfig.getServerAddress() + ":" + machineConfig.getServerPort());
            System.out.println("卡槽总数: " + machineConfig.getTotalSlots());
            System.out.println("轮询间隔: " + machineConfig.getPollingInterval() + "ms");
            System.out.println("波特率: " + machineConfig.getBaudrate());
            ////System.out.println("系统初始化完成,配置已加载");
            ////System.out.println("设备编号: " + machineConfig.getMachineId());
            ////System.out.println("服务器地址: " + machineConfig.getServerAddress() + ":" + machineConfig.getServerPort());
            ////System.out.println("卡槽总数: " + machineConfig.getTotalSlots());
            ////System.out.println("轮询间隔: " + machineConfig.getPollingInterval() + "ms");
            ////System.out.println("波特率: " + machineConfig.getBaudrate());
            
            return true;
            
        } catch (Exception e) {
            System.err.println("系统初始化失败: " + e.getMessage());
            Errlog.logOperation("系统初始化失败: " + e.getMessage());
            e.printStackTrace();
            return false;
        }
@@ -176,16 +179,16 @@
     */
    public boolean saveConfig(String configFilePath) {
        if (machineConfig == null) {
            System.err.println("配置未加载,无法保存");
            Errlog.logOperation("配置未加载,无法保存");
            return false;
        }
        
        try {
            machineConfig.saveToFile(configFilePath);
            System.out.println("配置已保存到: " + configFilePath);
            ////System.out.println("配置已保存到: " + configFilePath);
            return true;
        } catch (Exception e) {
            System.err.println("保存配置失败: " + e.getMessage());
            Errlog.logOperation("保存配置失败: " + e.getMessage());
            return false;
        }
    }
@@ -195,7 +198,7 @@
     */
    public MachineConfig getMachineConfig() {
        if (!initialized) {
            throw new IllegalStateException("系统未初始化,请先调用initialize()方法");
           Dingshidialog.showTimedDialog(null,10,"系统未初始化成功");
        }
        return machineConfig;
    }