|
|
@@ -18,8 +18,8 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
private final JTextField hostField = new JTextField(16);
|
|
|
private final JLabel dbLabel = new JLabel("-");
|
|
|
|
|
|
- private final GunView a1View = new GunView("TJ / OP220", true);
|
|
|
- private final GunView b1View = new GunView("TJB / OP240B", false);
|
|
|
+ private final GunView leftView = new GunView("TJB / OP240", false);
|
|
|
+ private final GunView rightView = new GunView("TJ / OP220", true);
|
|
|
|
|
|
private TjPlcConfig config;
|
|
|
private TjS7Client s7Client;
|
|
|
@@ -57,9 +57,10 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
top.add(statusLabel);
|
|
|
add(top, BorderLayout.NORTH);
|
|
|
|
|
|
+ // 左 OP240 / 右 OP220
|
|
|
JPanel center = new JPanel(new GridLayout(1, 2, 12, 0));
|
|
|
- center.add(a1View);
|
|
|
- center.add(b1View);
|
|
|
+ center.add(leftView);
|
|
|
+ center.add(rightView);
|
|
|
add(center, BorderLayout.CENTER);
|
|
|
|
|
|
loadUiFromConfig(true);
|
|
|
@@ -73,9 +74,10 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
} else {
|
|
|
config.host = keepHost;
|
|
|
}
|
|
|
- dbLabel.setText("DB" + config.db + " 只读监控(作业在服务端)");
|
|
|
- a1View.bindAddr(config.a1, config.db);
|
|
|
- b1View.bindAddr(config.b1, config.db);
|
|
|
+ dbLabel.setText("DB" + config.db + " 本地直连(无服务器)");
|
|
|
+ // 左 OP240 = b1,右 OP220 = a1
|
|
|
+ leftView.bindAddr(config.b1, config.db);
|
|
|
+ rightView.bindAddr(config.a1, config.db);
|
|
|
}
|
|
|
|
|
|
private void saveIp() {
|
|
|
@@ -157,30 +159,31 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
s7Client.updateHost(config.host);
|
|
|
}
|
|
|
|
|
|
- final GunSnapshot a1 = readGun(config.a1);
|
|
|
- final GunSnapshot b1 = readGun(config.b1);
|
|
|
- final boolean a1Ok = a1.allOk();
|
|
|
- final boolean b1Ok = b1.allOk();
|
|
|
- final boolean connDead = a1.okCount() == 0 && b1.okCount() == 0;
|
|
|
+ final GunSnapshot op220 = readGun(config.a1);
|
|
|
+ final GunSnapshot op240 = readGun(config.b1);
|
|
|
+ final boolean op220Ok = op220.allOk();
|
|
|
+ final boolean op240Ok = op240.allOk();
|
|
|
+ final boolean connDead = op220.okCount() == 0 && op240.okCount() == 0;
|
|
|
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
- a1View.apply(a1);
|
|
|
- b1View.apply(b1);
|
|
|
- if (a1Ok && b1Ok) {
|
|
|
+ // 左 OP240 / 右 OP220
|
|
|
+ leftView.apply(op240);
|
|
|
+ rightView.apply(op220);
|
|
|
+ if (op220Ok && op240Ok) {
|
|
|
statusLabel.setForeground(new Color(0, 128, 0));
|
|
|
statusLabel.setText("已连接 · 实时刷新中");
|
|
|
} else if (connDead) {
|
|
|
statusLabel.setForeground(Color.RED);
|
|
|
- statusLabel.setText("TJ/TJB均失败: " + shorten(a1.firstError()));
|
|
|
- } else if (!a1Ok && !b1Ok) {
|
|
|
+ statusLabel.setText("OP240/OP220均失败: " + shorten(op240.firstError()));
|
|
|
+ } else if (!op240Ok && !op220Ok) {
|
|
|
statusLabel.setForeground(Color.RED);
|
|
|
- statusLabel.setText("TJ失败[" + a1.firstFailAddr + "] TJB失败[" + b1.firstFailAddr + "]");
|
|
|
- } else if (!a1Ok) {
|
|
|
+ statusLabel.setText("OP240失败[" + op240.firstFailAddr + "] OP220失败[" + op220.firstFailAddr + "]");
|
|
|
+ } else if (!op240Ok) {
|
|
|
statusLabel.setForeground(Color.RED);
|
|
|
- statusLabel.setText("TJ失败[" + a1.firstFailAddr + "]: " + shorten(a1.firstError()));
|
|
|
+ statusLabel.setText("OP240失败[" + op240.firstFailAddr + "]: " + shorten(op240.firstError()));
|
|
|
} else {
|
|
|
statusLabel.setForeground(Color.RED);
|
|
|
- statusLabel.setText("TJB失败[" + b1.firstFailAddr + "]: " + shorten(b1.firstError()));
|
|
|
+ statusLabel.setText("OP220失败[" + op220.firstFailAddr + "]: " + shorten(op220.firstError()));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -207,7 +210,7 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
if (!resetting.compareAndSet(false, true)) {
|
|
|
return;
|
|
|
}
|
|
|
- final String side = isA ? "TJ/OP220" : "TJB/OP240B";
|
|
|
+ final String side = isA ? "TJ/OP220" : "TJB/OP240";
|
|
|
final String addrHint = isA ? "DB1300.DBX64.2" : "DB1300.DBX64.3";
|
|
|
int confirm = JOptionPane.showConfirmDialog(this,
|
|
|
"确认将 " + side + " 质量校验通过(允许进站)置为 0?\n地址: " + addrHint,
|
|
|
@@ -230,6 +233,7 @@ public class TjPlcMonitorPanel extends JPanel {
|
|
|
} else {
|
|
|
s7Client.updateHost(config.host);
|
|
|
}
|
|
|
+ // isA=true → OP220(a1/64.2);isA=false → OP240B(b1/64.3)
|
|
|
TjPlcConfig.GunAddr gun = isA ? config.a1 : config.b1;
|
|
|
s7Client.writeBit(gun.allowEntryByte, gun.allowEntryBit, false);
|
|
|
SwingUtilities.invokeLater(() -> {
|