| | |
| | | import dikuai.addzhangaiwu; |
| | | import gecaoji.Device; |
| | | import set.Sets; |
| | | import set.debug; |
| | | import udpdell.UDPServer; |
| | | import zhangaiwu.AddDikuai; |
| | | import yaokong.Control04; |
| | |
| | | private JLabel mowerSpeedValueLabel; |
| | | private JLabel mowerSpeedUnitLabel; |
| | | private JLabel mowingProgressLabel; |
| | | private FixQualityIndicator fixQualityIndicator; |
| | | private gpszhuangtai fixQualityIndicator; |
| | | |
| | | // 导航按钮 |
| | | private JButton homeNavBtn; |
| | |
| | | } |
| | | |
| | | private void showInitialMowerSelfCheckDialogIfNeeded() { |
| | | zijian.showInitialPromptIfNeeded(this, this::showRemoteControlDialog); |
| | | // 已移除进入主页时的自检提示(按用户要求删除) |
| | | // 以前这里会调用 zijian.showInitialPromptIfNeeded(...) 展示自检对话框,现已禁用。 |
| | | } |
| | | |
| | | private void applyIdleTrailDurationFromSettings() { |
| | |
| | | return; |
| | | } |
| | | if (startButtonShowingPause) { |
| | | if (!zijian.ensureBeforeMowing(this, this::showRemoteControlDialog)) { |
| | | return; |
| | | } |
| | | // 点击开始按钮时不再弹出自检提示(按用户要求删除) |
| | | // 旧逻辑:调用 zijian.ensureBeforeMowing(...) 并在未确认自检时阻止开始 |
| | | // 新逻辑:直接允许开始作业 |
| | | } |
| | | startButtonShowingPause = !startButtonShowingPause; |
| | | if (!startButtonShowingPause) { |
| | |
| | | stopButtonActive = false; |
| | | updateStopButtonIcon(); |
| | | } |
| | | if (!beginMowingSession()) { |
| | | startButtonShowingPause = true; |
| | | statusLabel.setText("待机"); |
| | | updateStartButtonAppearance(); |
| | | return; |
| | | } |
| | | Control04.sendStartCommandIfDebugSerialOpen(); |
| | | if (!beginMowingSession()) { |
| | | startButtonShowingPause = true; |
| | | statusLabel.setText("待机"); |
| | | updateStartButtonAppearance(); |
| | | return; |
| | | } |
| | | } else { |
| | | statusLabel.setText("暂停中"); |
| | | pauseMowingSession(); |
| | | Control04.sendPauseCommandIfDebugSerialOpen(); |
| | | } |
| | | updateStartButtonAppearance(); |
| | | } |
| | |
| | | statusLabel.setText("已结束"); |
| | | startButtonShowingPause = false; |
| | | stopMowingSession(); |
| | | Control04.sendStopCommandIfDebugSerialOpen(); |
| | | } else { |
| | | statusLabel.setText("待机"); |
| | | startButtonShowingPause = true; |
| | |
| | | if (bluetoothBtn == null) { |
| | | return; |
| | | } |
| | | if (Bluelink.isConnected()) { |
| | | Bluelink.disconnect(); |
| | | bluetoothConnected = false; |
| | | } else { |
| | | boolean success = Bluelink.connect(); |
| | | if (success) { |
| | | bluetoothConnected = true; |
| | | } else { |
| | | bluetoothConnected = false; |
| | | JOptionPane.showMessageDialog(this, "蓝牙连接失败,请重试", "提示", JOptionPane.WARNING_MESSAGE); |
| | | } |
| | | } |
| | | updateBluetoothButtonIcon(); |
| | | // 弹出系统调试页面 |
| | | showDebugDialog(); |
| | | } |
| | | |
| | | private void showDebugDialog() { |
| | | Window parentWindow = SwingUtilities.getWindowAncestor(this); |
| | | debug debugDialog = new debug(parentWindow, THEME_COLOR); |
| | | debugDialog.setLocationRelativeTo(this); // 居中显示在首页 |
| | | debugDialog.setVisible(true); |
| | | } |
| | | |
| | | private void updateBluetoothButtonIcon() { |
| | |
| | | JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); |
| | | rightPanel.setOpaque(false); |
| | | |
| | | fixQualityIndicator = new FixQualityIndicator(); |
| | | fixQualityIndicator = new gpszhuangtai(THEME_COLOR); |
| | | fixQualityIndicator.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
| | | fixQualityIndicator.addMouseListener(new MouseAdapter() { |
| | | @Override |
| | |
| | | return !"未选择地块".equals(trimmed); |
| | | } |
| | | |
| | | private final class FixQualityIndicator extends JComponent { |
| | | private static final long serialVersionUID = 1L; |
| | | private static final int DIAMETER = 16; |
| | | private String currentCode; |
| | | private Color currentColor = new Color(160, 160, 160); |
| | | |
| | | private FixQualityIndicator() { |
| | | setPreferredSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setMinimumSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setMaximumSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setToolTipText("未知"); |
| | | } |
| | | |
| | | private void setQuality(String code) { |
| | | if (Objects.equals(currentCode, code)) { |
| | | return; |
| | | } |
| | | currentCode = code; |
| | | currentColor = resolveFixQualityColor(code); |
| | | setToolTipText(resolveFixQualityDescription(code)); |
| | | repaint(); |
| | | } |
| | | |
| | | @Override |
| | | protected void paintComponent(Graphics g) { |
| | | super.paintComponent(g); |
| | | Graphics2D g2 = (Graphics2D) g.create(); |
| | | try { |
| | | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | int diameter = Math.min(getWidth(), getHeight()) - 2; |
| | | int x = (getWidth() - diameter) / 2; |
| | | int y = (getHeight() - diameter) / 2; |
| | | g2.setColor(currentColor); |
| | | g2.fillOval(x, y, diameter, diameter); |
| | | g2.setColor(new Color(255, 255, 255, 128)); |
| | | g2.drawOval(x, y, diameter, diameter); |
| | | } finally { |
| | | g2.dispose(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 测试方法 |
| | | public static void main(String[] args) { |