package PublicPannel;
|
import javax.swing.*;
|
|
import home.MainFrame;
|
import jiexi.DellTag55AA03;
|
|
import java.awt.*;
|
|
public class AntiCollisionPanel extends JPanel {
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
private MainFrame mainFrame;
|
private JLabel[] labels;
|
private JTextField[] textFields;
|
|
public AntiCollisionPanel(MainFrame mainFrame) {
|
this.mainFrame = mainFrame;
|
initializeUI();
|
}
|
|
private void initializeUI() {
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
|
// ßÇçнyf³X
|
String[][] parameters = {
|
{"14.", "relay1.alarm.distance1"},
|
{"16.", "relay1.alarm.distance2"},
|
{"18.", "relay1.alarm.distance3"},
|
{"20.", "modbus.address"},
|
{"4A.", "whitelist.start"},
|
{"4C.", "whitelist.end"},
|
{"50.", "relay.duration"},
|
{"52.", "ranging.output.format"},
|
{"54.", "antenna.cable.length"},
|
{"58.", "feedline.length"},
|
{"F0.", "relay1.control"},
|
{"F2.", "relay2.control"},
|
{"F4.", "relay2.alarm.distance1"},
|
{"F6.", "relay2.alarm.distance2"},
|
{"F8.", "relay2.alarm.distance3"},
|
};
|
|
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.", "relay1.alarm.distance1"},
|
{"16.", "relay1.alarm.distance2"},
|
{"18.", "relay1.alarm.distance3"},
|
{"20.", "modbus.address"},
|
{"4A.", "whitelist.start"},
|
{"4C.", "whitelist.end"},
|
{"50.", "relay.duration"},
|
{"52.", "ranging.output.format"},
|
{"54.", "antenna.cable.length"},
|
{"58.", "feedline.length"},
|
{"F0.", "relay1.control"},
|
{"F2.", "relay2.control"},
|
{"F4.", "relay2.alarm.distance1"},
|
{"F6.", "relay2.alarm.distance2"},
|
{"F8.", "relay2.alarm.distance3"},
|
};
|
|
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)); // ¼ÌµçÆ÷1±¨¾¯¾àÀë1
|
}
|
|
if (textFields.length > 1 && result.dizhi0x16 != null) {
|
textFields[1].setText(String.valueOf(result.dizhi0x16)); // ¼ÌµçÆ÷1±¨¾¯¾àÀë2
|
}
|
|
if (textFields.length > 2 && result.dizhi0x18 != null) {// ¼ÌµçÆ÷1±¨¾¯¾àÀë3
|
textFields[2].setText(String.valueOf(result.dizhi0x18));
|
}
|
|
//20.ModbusµØÖ·
|
if (textFields.length > 3 && result.dizhi0x20 != null) {
|
textFields[3].setText(String.valueOf(result.dizhi0x20));
|
}
|
//4A.°×Ãûµ¥Æðʼ
|
if (textFields.length > 4 && result.dizhi0x4A != null) {
|
textFields[4].setText(String.valueOf(result.dizhi0x4A));
|
}
|
//4C.°×Ãûµ¥½áÊø
|
if (textFields.length > 5 && result.dizhi0x4C != null) {
|
textFields[5].setText(String.valueOf(result.dizhi0x4C));
|
}
|
//50.¼ÌµçÆ÷³ÖÐøÊ±¼ä
|
if (textFields.length > 6 ) {
|
textFields[6].setText(String.valueOf(result.dizhi0x50));
|
}
|
//52.²â¾àÊä³ö¸ñʽ
|
if (textFields.length > 7 && result.dizhi0x52 != null) {
|
textFields[7].setText(String.valueOf(result.dizhi0x52));
|
}
|
//54.ÌìÏßµçÀ³¤¶È
|
if (textFields.length > 8 && result.dizhi0x54 != null) {
|
textFields[8].setText(String.valueOf(result.dizhi0x54));
|
}
|
//58.À¡Ïß³¤¶È
|
if (textFields.length > 9 ) {
|
textFields[9].setText(String.valueOf(result.dizhi0x58));
|
}
|
//F0.¼ÌµçÆ÷1¿ØÖÆ
|
if (textFields.length > 10 && result.dizhi0xF0 != null) {
|
textFields[10].setText(String.valueOf(result.dizhi0xF0));
|
}
|
//F2.¼ÌµçÆ÷2¿ØÖÆ
|
if (textFields.length > 11 && result.dizhi0xF2 != null) {
|
textFields[11].setText(String.valueOf(result.dizhi0xF2));
|
}
|
//F4.¼ÌµçÆ÷2±¨¾¯¾àÀë1
|
if (textFields.length > 12 && result.dizhi0xF4 != null) {
|
textFields[12].setText(String.valueOf(result.dizhi0xF4));
|
}
|
//F6.¼ÌµçÆ÷2±¨¾¯¾àÀë2
|
if (textFields.length > 13 && result.dizhi0xF6 != null) {
|
textFields[13].setText(String.valueOf(result.dizhi0xF6));
|
}
|
//F8.¼ÌµçÆ÷2±¨¾¯¾àÀë3
|
if (textFields.length > 14 && result.dizhi0xF8 != null) {
|
textFields[14].setText(String.valueOf(result.dizhi0xF8));
|
}
|
|
} catch (Exception e) {
|
System.err.println("Error updating AntiCollisionPanel fields: " + e.getMessage());
|
e.printStackTrace();
|
}
|
|
// ÖØÐÂÑéÖ¤ºÍÖØ»æÃæ°å
|
revalidate();
|
repaint();
|
}
|
public String getdizhi0x14() {
|
return textFields.length > 0 ? textFields[0].getText() : "";
|
}//¼ÌµçÆ÷1±¨¾¯¾àÀë1
|
|
public String getdizhi0x16() {
|
return textFields.length > 1 ? textFields[1].getText() : "";
|
}//¼ÌµçÆ÷1±¨¾¯¾àÀë2
|
|
public String getdizhi0x18() {
|
return textFields.length > 2 ? textFields[2].getText() : "";
|
}//¼ÌµçÆ÷1±¨¾¯¾àÀë3
|
|
public String getdizhi0x20() {
|
return textFields.length > 3 ? textFields[3].getText() : "";
|
}//ModbusµØÖ·
|
|
public String getdizhi0x4A() {
|
return textFields.length > 4 ? textFields[4].getText() : "";
|
}//°×Ãûµ¥Æðʼ
|
|
public String getdizhi0x4C() {
|
return textFields.length > 5 ? textFields[5].getText() : "";
|
}//°×Ãûµ¥½áÊø
|
|
public String getdizhi0x50() {
|
return textFields.length > 6 ? textFields[6].getText() : "";
|
}//¼ÌµçÆ÷³ÖÐøÊ±¼ä
|
|
public String getdizhi0x52() {
|
return textFields.length > 7 ? textFields[7].getText() : "";
|
}//²â¾àÊä³ö¸ñʽ
|
|
public String getdizhi0x54() {
|
return textFields.length > 8 ? textFields[8].getText() : "";
|
}//ÌìÏßµçÀ³¤¶È
|
|
public String getdizhi0x58() {
|
return textFields.length > 9 ? textFields[9].getText() : "";
|
}//À¡Ïß³¤¶È
|
|
public String getdizhi0xF0() {
|
return textFields.length > 10 ? textFields[10].getText() : "";
|
}//¼ÌµçÆ÷1¿ØÖÆ
|
|
public String getdizhi0xF2() {
|
return textFields.length > 11 ? textFields[11].getText() : "";
|
}//¼ÌµçÆ÷2¿ØÖÆ
|
|
public String getdizhi0xF4() {
|
return textFields.length > 12 ? textFields[12].getText() : "";
|
}//¼ÌµçÆ÷2±¨¾¯¾àÀë1
|
|
public String getdizhi0xF6() {
|
return textFields.length > 13 ? textFields[13].getText() : "";
|
}//¼ÌµçÆ÷2±¨¾¯¾àÀë2
|
|
public String getdizhi0xF8() {
|
return textFields.length > 14 ? textFields[14].getText() : "";
|
}//¼ÌµçÆ÷2±¨¾¯¾àÀë3
|
}
|