| | |
| | | package gecaoji; |
| | | |
| | | import javax.swing.*; |
| | | |
| | | import publicway.buttonset; |
| | | |
| | | import java.awt.*; |
| | | import java.awt.event.WindowAdapter; |
| | | import java.awt.event.WindowEvent; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import zhuye.buttonset; |
| | | |
| | | // Manages the mower info dialog to keep MapRenderer focused on rendering. |
| | | public class GecaojiMeg { |
| | |
| | | private JLabel satelliteCountLabel; |
| | | private JLabel realtimeSpeedLabel; |
| | | private JLabel headingLabel; |
| | | |
| | | // 新增属性标签 |
| | | private JLabel pathIdLabel; |
| | | private JLabel batteryLevelLabel; |
| | | private JLabel batteryVoltageLabel; |
| | | private JLabel operationModeLabel; |
| | | private JLabel motorStatusLabel; |
| | | private JLabel bladeStatusLabel; |
| | | private JLabel bladeHeightLabel; |
| | | private JLabel selfCheckStatusLabel; |
| | | private JLabel errorCodeLabel; |
| | | private JLabel errorMessageLabel; |
| | | private JLabel rollLabel; |
| | | private JLabel pitchLabel; |
| | | private JLabel yawLabel; |
| | | |
| | | private JLabel updateTimeLabel; |
| | | |
| | | public GecaojiMeg(JPanel anchorPanel, Gecaoji mower) { |
| | |
| | | headingLabel.setFont(valueFont); |
| | | grid.add(headingLabel, gbc); |
| | | |
| | | // 第八行 |
| | | gbc.gridx = 0; gbc.gridy = 7; |
| | | // 新增属性显示 |
| | | int currentRow = 7; |
| | | |
| | | // 存储的路径ID |
| | | addLabelRow(grid, gbc, currentRow++, "路径ID:", pathIdLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 电池电量 |
| | | addLabelRow(grid, gbc, currentRow++, "电池电量:", batteryLevelLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 电池电压 |
| | | addLabelRow(grid, gbc, currentRow++, "电池电压:", batteryVoltageLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 操作模式 |
| | | addLabelRow(grid, gbc, currentRow++, "操作模式:", operationModeLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 电机状态 |
| | | addLabelRow(grid, gbc, currentRow++, "电机状态:", motorStatusLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 刀片状态 |
| | | addLabelRow(grid, gbc, currentRow++, "刀片状态:", bladeStatusLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 刀盘高度 |
| | | addLabelRow(grid, gbc, currentRow++, "刀盘高度:", bladeHeightLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 自检状态 |
| | | addLabelRow(grid, gbc, currentRow++, "自检状态:", selfCheckStatusLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 错误代码 |
| | | addLabelRow(grid, gbc, currentRow++, "错误代码:", errorCodeLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 错误信息 |
| | | addLabelRow(grid, gbc, currentRow++, "错误信息:", errorMessageLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 横滚角 |
| | | addLabelRow(grid, gbc, currentRow++, "横滚角:", rollLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 俯仰角 |
| | | addLabelRow(grid, gbc, currentRow++, "俯仰角:", pitchLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 偏航角 |
| | | addLabelRow(grid, gbc, currentRow++, "偏航角:", yawLabel = createValueLabel(), titleFont, valueFont); |
| | | |
| | | // 更新时间 |
| | | gbc.gridx = 0; gbc.gridy = currentRow; |
| | | gbc.weightx = 0.3; |
| | | JLabel label8 = new JLabel("更新时间:"); |
| | | label8.setFont(titleFont); |
| | | label8.setForeground(new Color(102, 102, 102)); |
| | | grid.add(label8, gbc); |
| | | |
| | | gbc.gridx = 1; gbc.gridy = 7; |
| | | gbc.gridx = 1; gbc.gridy = currentRow; |
| | | gbc.weightx = 0.7; |
| | | updateTimeLabel = createValueLabel(); |
| | | updateTimeLabel.setFont(valueFont); |
| | |
| | | satelliteCountLabel = null; |
| | | realtimeSpeedLabel = null; |
| | | headingLabel = null; |
| | | |
| | | pathIdLabel = null; |
| | | batteryLevelLabel = null; |
| | | batteryVoltageLabel = null; |
| | | operationModeLabel = null; |
| | | motorStatusLabel = null; |
| | | bladeStatusLabel = null; |
| | | bladeHeightLabel = null; |
| | | selfCheckStatusLabel = null; |
| | | errorCodeLabel = null; |
| | | errorMessageLabel = null; |
| | | rollLabel = null; |
| | | pitchLabel = null; |
| | | yawLabel = null; |
| | | |
| | | updateTimeLabel = null; |
| | | } |
| | | |
| | |
| | | satelliteCountLabel.setText(formatDeviceValue(device.getSatelliteCount())); |
| | | realtimeSpeedLabel.setText(formatDeviceValue(device.getRealtimeSpeed())); |
| | | headingLabel.setText(formatDeviceValue(device.getHeading())); |
| | | |
| | | // 更新新增属性 |
| | | pathIdLabel.setText(formatDeviceValue(device.getPath_id_saved())); |
| | | batteryLevelLabel.setText(formatDeviceValue(device.getBattery_level())); |
| | | batteryVoltageLabel.setText(formatDeviceValue(device.getBattery_voltage())); |
| | | operationModeLabel.setText(formatDeviceValue(device.getOperation_mode())); |
| | | motorStatusLabel.setText(formatDeviceValue(device.getMotor_status())); |
| | | bladeStatusLabel.setText(formatDeviceValue(device.getBlade_status())); |
| | | bladeHeightLabel.setText(formatDeviceValue(device.getBlade_height())); |
| | | selfCheckStatusLabel.setText(formatDeviceValue(device.getSelf_check_status())); |
| | | errorCodeLabel.setText(formatDeviceValue(device.getError_code())); |
| | | errorMessageLabel.setText(formatDeviceValue(device.getError_message())); |
| | | rollLabel.setText(formatDeviceValue(device.getRoll())); |
| | | pitchLabel.setText(formatDeviceValue(device.getPitch())); |
| | | yawLabel.setText(formatDeviceValue(device.getYaw())); |
| | | |
| | | updateTimeLabel.setText(formatTimestamp(device.getGupdateTime())); |
| | | } |
| | | |
| | |
| | | if (satelliteCountLabel != null) satelliteCountLabel.setText(value); |
| | | if (realtimeSpeedLabel != null) realtimeSpeedLabel.setText(value); |
| | | if (headingLabel != null) headingLabel.setText(value); |
| | | |
| | | if (pathIdLabel != null) pathIdLabel.setText(value); |
| | | if (batteryLevelLabel != null) batteryLevelLabel.setText(value); |
| | | if (batteryVoltageLabel != null) batteryVoltageLabel.setText(value); |
| | | if (operationModeLabel != null) operationModeLabel.setText(value); |
| | | if (motorStatusLabel != null) motorStatusLabel.setText(value); |
| | | if (bladeStatusLabel != null) bladeStatusLabel.setText(value); |
| | | if (bladeHeightLabel != null) bladeHeightLabel.setText(value); |
| | | if (selfCheckStatusLabel != null) selfCheckStatusLabel.setText(value); |
| | | if (errorCodeLabel != null) errorCodeLabel.setText(value); |
| | | if (errorMessageLabel != null) errorMessageLabel.setText(value); |
| | | if (rollLabel != null) rollLabel.setText(value); |
| | | if (pitchLabel != null) pitchLabel.setText(value); |
| | | if (yawLabel != null) yawLabel.setText(value); |
| | | |
| | | if (updateTimeLabel != null) updateTimeLabel.setText(value); |
| | | } |
| | | |
| | |
| | | return sanitized; |
| | | } |
| | | } |
| | | |
| | | private void addLabelRow(JPanel grid, GridBagConstraints gbc, int row, String title, JLabel valueLabel, Font titleFont, Font valueFont) { |
| | | gbc.gridx = 0; gbc.gridy = row; |
| | | gbc.weightx = 0.3; |
| | | JLabel label = new JLabel(title); |
| | | label.setFont(titleFont); |
| | | label.setForeground(new Color(102, 102, 102)); |
| | | grid.add(label, gbc); |
| | | |
| | | gbc.gridx = 1; gbc.gridy = row; |
| | | gbc.weightx = 0.7; |
| | | valueLabel.setFont(valueFont); |
| | | grid.add(valueLabel, gbc); |
| | | } |
| | | } |