| | |
| | | startUIUpdates(); // UI刷新定时器 |
| | | startSerialStatusMonitoring(); // 串口状态监控 |
| | | |
| | | System.out.println("主界面初始化完成"); |
| | | //System.out.println("主界面初始化完成"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | JOptionPane.showMessageDialog(null, |
| | |
| | | try { |
| | | // 初始化卡槽管理器 - 必须首先执行 |
| | | slotManager = new SlotManager(); |
| | | System.out.println("卡槽管理器初始化完成"); |
| | | //System.out.println("卡槽管理器初始化完成"); |
| | | |
| | | // 直接使用已经初始化的配置系统 |
| | | Chushihua configSystem = Chushihua.getInstance(); |
| | |
| | | PICKUP_PASSWORD = configSystem.getMachineConfig().getFetchCardPassword(); |
| | | } |
| | | |
| | | System.out.println("系统配置初始化完成"); |
| | | System.out.println("管理员密码长度: " + (ADMIN_PASSWORD != null ? ADMIN_PASSWORD.length() : "null")); |
| | | System.out.println("取卡密码长度: " + (PICKUP_PASSWORD != null ? PICKUP_PASSWORD.length() : "null")); |
| | | //System.out.println("系统配置初始化完成"); |
| | | //System.out.println("管理员密码长度: " + (ADMIN_PASSWORD != null ? ADMIN_PASSWORD.length() : "null")); |
| | | //System.out.println("取卡密码长度: " + (PICKUP_PASSWORD != null ? PICKUP_PASSWORD.length() : "null")); |
| | | |
| | | } catch (Exception e) { |
| | | System.err.println("系统初始化异常: " + e.getMessage()); |
| | |
| | | cardSlotsPanel.removeAll(); |
| | | slotButtons.clear(); |
| | | |
| | | int updatedSlots = 0; |
| | | int errorSlots = 0; |
| | | |
| | | for (int i = 1; i <= TOTAL_SLOTS; i++) { |
| | | final int slotId = i; |
| | | SlotStatus status = getSlotStatusFromManager(slotId); |
| | |
| | | // 添加调试信息 |
| | | Fkj slotInfo = slotManager.getSlotInfo(slotId); |
| | | if (slotInfo != null) { |
| | | updatedSlots++; |
| | | } else { |
| | | System.err.println("卡槽 " + slotId + " - 获取信息失败"); |
| | | errorSlots++; |
| | | } |
| | | |
| | | JButton slotButton = new JButton(String.valueOf(slotId)); |
| | |
| | | cardSlotsPanel.revalidate(); |
| | | cardSlotsPanel.repaint(); |
| | | |
| | | System.out.println("卡槽显示更新完成: " + updatedSlots + " 个成功, " + errorSlots + " 个失败"); |
| | | // //System.out.println("卡槽显示更新完成: " + updatedSlots + " 个成功, " + errorSlots + " 个失败"); |
| | | } |
| | | |
| | | private Color brighterColor(Color color) { |
| | |
| | | if (panel.getComponentCount() >= 2) { |
| | | JLabel textLabel = (JLabel) panel.getComponent(1); |
| | | if (textLabel.getText().startsWith("串口:")) { |
| | | String statusText = lunxun.isSerialConnected() ? "正常" : "断开"; |
| | | Color statusColor = lunxun.isSerialConnected() ? |
| | | new Color(52, 152, 219) : new Color(231, 76, 60); |
| | | |
| | |
| | | boolean pickupSuccess = CardPickupDialog.showCardPickup(this, slotId, status); |
| | | |
| | | if (pickupSuccess) { |
| | | // 取卡成功,界面已经在对话框中更新,这里不需要额外操作 |
| | | System.out.println("卡槽 " + slotId + " 取卡成功"); |
| | | // 取卡成功,调用changgehaska方法改变卡槽属性 |
| | | SlotManager.changgehaska(slotId, "1"); // "1"表示管理员操作 |
| | | //System.out.println("卡槽 " + slotId + " 取卡成功,已更新卡槽状态"); |
| | | } |
| | | } |
| | | |
| | |
| | | // 停止轮询查询 |
| | | if (lunxun.isPolling()) { |
| | | lunxun.stopPolling(); |
| | | System.out.println("应用程序关闭,轮询查询已停止"); |
| | | //System.out.println("应用程序关闭,轮询查询已停止"); |
| | | } |
| | | |
| | | // 停止串口协议解析器(新增) |
| | |
| | | return "串口解析器未初始化"; |
| | | } |
| | | |
| | | /** |
| | | * 创建美化按钮 |
| | | */ |
| | | private JButton createStyledButton(String text, Color color) { |
| | | JButton button = new JButton(text); |
| | | button.setFont(new Font("Microsoft YaHei", Font.BOLD, 14)); |
| | | button.setBackground(color); |
| | | button.setForeground(Color.WHITE); |
| | | button.setFocusPainted(false); |
| | | button.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); |
| | | button.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
| | | |
| | | // 鼠标悬停效果 |
| | | button.addMouseListener(new java.awt.event.MouseAdapter() { |
| | | public void mouseEntered(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(brighterColor(color)); |
| | | } |
| | | |
| | | public void mouseExited(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(color); |
| | | } |
| | | }); |
| | | |
| | | return button; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 验证取卡密码 |
| | | */ |
| | |
| | | if (lunxun.checkSerialConnection()) { |
| | | boolean resumed = lunxun.setPollingPaused(false); |
| | | if (resumed) { |
| | | System.out.println("切换到主页面,轮询查询已恢复"); |
| | | //System.out.println("切换到主页面,轮询查询已恢复"); |
| | | } |
| | | } else { |
| | | System.err.println("切换到主页面,串口未连接,保持轮询暂停"); |