| | |
| | | import java.awt.*; |
| | | import com.fazecast.jSerialComm.SerialPort; |
| | | import chushihua.Chushihua; |
| | | import home.CardMachineUI; |
| | | |
| | | /** |
| | | * 串口连接对话框 |
| | | * 软件启动时显示,用于选择串口和波特率并连接 |
| | | */ |
| | | @SuppressWarnings("serial") |
| | | public class SerialPortConnectionDialog extends JDialog { |
| | | |
| | | // 颜色常量 |
| | | private static final Color PRIMARY_COLOR = new Color(52, 152, 219); |
| | | private static final Color PRIMARY_DARK_COLOR = new Color(41, 128, 185); |
| | | private static final Color SECONDARY_COLOR = new Color(46, 204, 113); |
| | | private static final Color DANGER_COLOR = new Color(231, 76, 60); |
| | | private static final Color DARK_COLOR = new Color(255, 69, 0); // 改为橘黄色 |
| | |
| | | // 启动协议解析器 |
| | | if (serialService.getProtocolParser() != null) { |
| | | serialService.getProtocolParser().start(); |
| | | System.out.println("串口协议解析器已启动"); |
| | | //System.out.println("串口协议解析器已启动"); |
| | | } |
| | | |
| | | // 启动数据捕获并启用调试输出 |
| | | serialService.enableDebugOutput(); |
| | | serialService.startCapture(data -> { |
| | | // 这里会触发SerialPortService中的System.out.println打印 |
| | | // 这里会触发SerialPortService中的//System.out.println打印 |
| | | }); |
| | | |
| | | // 重要修改:移除自动创建主界面的代码 |
| | |
| | | |
| | | // 重要修改:移除自动打开主界面的代码 |
| | | // 由Homein统一管理主界面的创建和显示 |
| | | System.out.println("串口连接成功,准备返回控制权给主程序"); |
| | | //System.out.println("串口连接成功,准备返回控制权给主程序"); |
| | | |
| | | // 只需要关闭对话框,不创建主界面 |
| | | // 主界面将在Homein.showMainInterface()中创建 |