package PublicPannel;
|
import javax.swing.*;
|
|
import home.MainFrame;
|
import jiexi.DellTag55AA03;
|
|
import java.awt.*;
|
|
public class TagPanel extends JPanel {
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
private MainFrame mainFrame;
|
private JLabel[] labels;
|
private JTextField[] textFields;
|
|
public TagPanel(MainFrame mainFrame) {
|
this.mainFrame = mainFrame;
|
initializeUI();
|
}
|
|
private void initializeUI() {
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
|
// ßÇè÷¥ï½yf³X
|
String[][] parameters = {
|
{"14.", "imu.idle.time"},
|
{"1C.", "uwb.switch.status"},
|
{"20.", "vibration.duration"},
|
{"38.", "accelerometer.threshold"},
|
{"3A.", "idle.sleep.time"},
|
{"3C.", "vibration.enable"},
|
{"3E.", "accelerometer.enable"},
|
{"40.", "tag.config.status"},
|
{"42.", "accelerometer.duration"},
|
{"44.", "device.activation.status"},
|
{"48.", "speed.filter.limit"},
|
{"50.", "pressure.calibration"},
|
|
};
|
|
labels = new JLabel[parameters.length];
|
textFields = new JTextField[parameters.length];
|
|
for (int i = 0; i < parameters.length; i++) {
|
addParameterField(this, parameters[i][0], parameters[i][1], i);
|
}
|
}
|
|
private void addParameterField(JPanel panel, String address, String paramKey, int index) {
|
JPanel paramPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); // µ³òÛÇÜR5í¹
\
|
|
labels[index] = new JLabel(address + " " + mainFrame.getString(paramKey));
|
labels[index].setPreferredSize(new Dimension(140, 25));
|
|
textFields[index] = new JTextField();
|
textFields[index].setPreferredSize(new Dimension(120, 25));
|
|
paramPanel.add(labels[index]);
|
paramPanel.add(textFields[index]);
|
|
// ßÇÇÜ
|
paramPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 35));
|
panel.add(paramPanel);
|
}
|
|
public void updateLanguage() {
|
// ÝdÚë~ô¬è÷¥ïÇ»`ì
|
String[][] parameters = {
|
{"14.", "imu.idle.time"},
|
{"1C.", "uwb.switch.status"},
|
{"20.", "vibration.duration"},
|
{"38.", "accelerometer.threshold"},
|
{"3A.", "idle.sleep.time"},
|
{"3C.", "vibration.enable"},
|
{"3E.", "accelerometer.enable"},
|
{"40.", "tag.config.status"},
|
{"42.", "accelerometer.duration"},
|
{"44.", "device.activation.status"},
|
{"48.", "speed.filter.limit"},
|
{"50.", "pressure.calibration"},
|
|
};
|
|
for (int i = 0; i < parameters.length && i < labels.length; i++) {
|
labels[i].setText(parameters[i][0] + " " + mainFrame.getString(parameters[i][1]));
|
}
|
|
revalidate();
|
repaint();
|
}
|
|
// ÐÂÔö£º»ñÈ¡Îı¾¿òÊý×éµÄ·½·¨
|
public JTextField[] getTextFields() {
|
return textFields;
|
}
|
/**
|
* ¸üбêÇ©Ãæ°å×Ö¶Î
|
*/
|
public void updateFields(DellTag55AA03.ParseResult result) {
|
if (result == null) {
|
|
return;
|
}
|
|
|
|
try {
|
// ¸ù¾Ý²ÎÊý˳Ðò¸üжÔÓ¦µÄÎı¾¿ò
|
if (textFields.length > 0 && result.dizhi0x14 != null) {
|
textFields[0].setText(String.valueOf(result.dizhi0x14)); // IMU¾²Ö¹Ê±¼ä
|
}
|
|
if (textFields.length > 1 && result.dizhi0x1C != null) {
|
textFields[1].setText(String.valueOf(result.dizhi0x1C)); // UWB¿ª¹Ø×´Ì¬
|
}
|
|
if (textFields.length > 2 && result.dizhi0x20 != null) {
|
textFields[2].setText(String.valueOf(result.dizhi0x20)); // Õñ¶¯Ê±³¤
|
}
|
|
if (textFields.length > 3 && result.dizhi0x38 != null) {
|
textFields[3].setText(String.valueOf(result.dizhi0x38)); // ¼ÓËٶȼÆãÐÖµ
|
}
|
|
if (textFields.length > 4 && result.dizhi0x3A != null) {
|
textFields[4].setText(String.valueOf(result.dizhi0x3A)); // ¿ÕÏÐÐÝÃßʱ¼ä
|
}
|
|
if (textFields.length > 5 && result.dizhi0x3C != null) {
|
textFields[5].setText(String.valueOf(result.dizhi0x3C)); // Õñ¶¯Ê¹ÄÜ
|
}
|
|
if (textFields.length > 6 && result.dizhi0x3E != null) {
|
textFields[6].setText(String.valueOf(result.dizhi0x3E)); // ¼ÓËٶȼÆÊ¹ÄÜ
|
}
|
|
if (textFields.length > 7 && result.dizhi0x40 != null) {
|
textFields[7].setText(String.valueOf(result.dizhi0x40)); // ±êÇ©ÅäÖÃ״̬
|
}
|
|
if (textFields.length > 8 && result.dizhi0x42 != null) {
|
textFields[8].setText(String.valueOf(result.dizhi0x42)); // ¼ÓËٶȼÆÊ±³¤
|
}
|
|
if (textFields.length > 9 && result.dizhi0x44 != null) {
|
textFields[9].setText(result.dizhi0x44); // É豸¼¤»î״̬
|
}
|
|
if (textFields.length > 10 && result.dizhi0x48 != null) {
|
textFields[10].setText(String.valueOf(result.dizhi0x48)); // ËÙ¶ÈÂ˲¨ÏÞÖµ
|
}
|
|
if (textFields.length > 11 ) {
|
textFields[11].setText(String.valueOf(result.dizhi0x50)); // ѹÁ¦Ð£×¼
|
}
|
|
} catch (Exception e) {
|
System.err.println("Error updating TagPanel fields: " + e.getMessage());
|
e.printStackTrace();
|
}
|
|
// ÖØÐÂÑéÖ¤ºÍÖØ»æÃæ°å
|
revalidate();
|
repaint();
|
}
|
public String getdizhi0x14() {
|
return textFields.length > 0 ? textFields[0].getText() : "";
|
}//IMU¾²Ö¹Ê±¼ä
|
|
public String getdizhi0x1C() {
|
return textFields.length > 1 ? textFields[1].getText() : "";
|
}//UWB¿ª¹Ø×´Ì¬
|
|
public String getdizhi0x20() {
|
return textFields.length > 2 ? textFields[2].getText() : "";
|
}//Õñ¶¯Ê±³¤
|
|
public String getdizhi0x38() {
|
return textFields.length > 3 ? textFields[3].getText() : "";
|
}//¼ÓËٶȼÆãÐÖµ
|
|
public String getdizhi0x3A() {
|
return textFields.length > 4 ? textFields[4].getText() : "";
|
}//¿ÕÏÐÐÝÃßʱ¼ä
|
|
public String getdizhi0x3C() {
|
return textFields.length > 5 ? textFields[5].getText() : "";
|
}//Õñ¶¯Ê¹ÄÜ
|
|
public String getdizhi0x3E() {
|
return textFields.length > 6 ? textFields[6].getText() : "";
|
}//¼ÓËٶȼÆÊ¹ÄÜ
|
|
public String getdizhi0x40() {
|
return textFields.length > 7 ? textFields[7].getText() : "";
|
}//±êÇ©ÅäÖÃ״̬
|
|
public String getdizhi0x42() {
|
return textFields.length > 8 ? textFields[8].getText() : "";
|
}//¼ÓËٶȼÆÊ±³¤
|
|
public String getdizhi0x44() {
|
return textFields.length > 9 ? textFields[9].getText() : "";
|
}//É豸¼¤»î״̬
|
|
public String getdizhi0x48() {
|
return textFields.length > 10 ? textFields[10].getText() : "";
|
}//ËÙ¶ÈÂ˲¨ÏÞÖµ
|
|
public String getdizhi0x50() {
|
return textFields.length > 11 ? textFields[11].getText() : "";
|
}//ѹÁ¦Ð£×¼
|
}
|