| | |
| | | } |
| | | |
| | | private void initializeUI() { |
| | | setTitle("智能人脸发卡机管理系统"); |
| | | setTitle("发卡机控制软件V1.0"); |
| | | setSize(SCREEN_WIDTH, SCREEN_HEIGHT); |
| | | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| | | setLocationRelativeTo(null); |
| | |
| | | final int slotId = i; |
| | | SlotStatus status = getSlotStatusFromManager(slotId); |
| | | |
| | | // 添加调试信息 |
| | | // 获取卡槽信息 |
| | | Fkj slotInfo = slotManager.getSlotInfo(slotId); |
| | | if (slotInfo != null) { |
| | | } else { |
| | | System.err.println("卡槽 " + slotId + " - 获取信息失败"); |
| | | String cardNumber = "无卡"; |
| | | if (slotInfo != null && slotInfo.getCardNumber() != null) { |
| | | String cardNum = slotInfo.getCardNumber(); |
| | | // 判断卡号是否有效(不是"-1"或"0000") |
| | | if (!"-1".equals(cardNum) && !"0000".equals(cardNum)) { |
| | | cardNumber = cardNum; |
| | | } |
| | | } |
| | | |
| | | JButton slotButton = new JButton(String.valueOf(slotId)); |
| | | // 创建包含卡槽编号和卡号的HTML文本 |
| | | String buttonText = String.format("<html><div style='text-align: center;'>%d<br/><span style='font-size: 10px;'>%s</span></div></html>", |
| | | slotId, cardNumber); |
| | | |
| | | JButton slotButton = new JButton(buttonText); |
| | | slotButton.setBackground(status.getColor()); |
| | | slotButton.setForeground(Color.WHITE); |
| | | slotButton.setFont(new Font("Microsoft YaHei", Font.BOLD, 14)); |
| | |
| | | public boolean performCardPickup(int slotId) { |
| | | try { |
| | | // 调用OpenDoor生成开门指令 |
| | | String command = OpenDoor.openOneDoor(slotId, OpenDoor.TYPE_ISSUE_CARD); |
| | | // String command = OpenDoor.openOneDoor(slotId, OpenDoor.TYPE_ISSUE_CARD); |
| | | |
| | | // 使用Sendmsg发送指令到串口 |
| | | boolean sendResult = Sendmsg.sendMessage(command); |
| | | boolean sendResult = Sendmsg.opendoorzhiling(slotId, 2); |
| | | |
| | | if (sendResult) { |
| | | return true; |
| | |
| | | ensureSerialParserRunning(); // 确保串口解析器运行 |
| | | updateCardSlotsDisplay(); |
| | | updateStatistics(); |
| | | SlotManager.pollAndResendOpenCommand(1);//增加发卡不成功再次发卡 |
| | | }); |
| | | uiUpdateTimer.start(); |
| | | } |