|
@@ -80,6 +80,9 @@ public class StationPanel extends JPanel {
|
|
|
/** 设备状态心跳间隔:2 分钟 */
|
|
/** 设备状态心跳间隔:2 分钟 */
|
|
|
private static final long DEVICE_HEARTBEAT_MS = 2L * 60L * 1000L;
|
|
private static final long DEVICE_HEARTBEAT_MS = 2L * 60L * 1000L;
|
|
|
private volatile long lastDeviceHeartbeatAtMs;
|
|
private volatile long lastDeviceHeartbeatAtMs;
|
|
|
|
|
+ /** PLC 未连时重试间隔,避免 tick 被 connect 超时卡住导致服务端灯不刷新 */
|
|
|
|
|
+ private static final long PLC_RECONNECT_MS = 8_000L;
|
|
|
|
|
+ private volatile long lastPlcConnectAtMs;
|
|
|
|
|
|
|
|
/** 生产过程参数回显(对齐 RealHuHan:只展示采参量,不展示握手点位) */
|
|
/** 生产过程参数回显(对齐 RealHuHan:只展示采参量,不展示握手点位) */
|
|
|
private final JTextField txtWeld1Current;
|
|
private final JTextField txtWeld1Current;
|
|
@@ -365,10 +368,11 @@ public class StationPanel extends JPanel {
|
|
|
* 有码 HOLD/RUN:等运行开始 → 运行结束按件上传。
|
|
* 有码 HOLD/RUN:等运行开始 → 运行结束按件上传。
|
|
|
*/
|
|
*/
|
|
|
public void tick() {
|
|
public void tick() {
|
|
|
|
|
+ // 先刷服务端灯:PLC 连超时会卡住后面逻辑,不能让灯跟着假红
|
|
|
|
|
+ uiServerHeartbeat();
|
|
|
if (busy.get()) {
|
|
if (busy.get()) {
|
|
|
uiPlcLabel();
|
|
uiPlcLabel();
|
|
|
uiDeviceStatusLight();
|
|
uiDeviceStatusLight();
|
|
|
- uiServerHeartbeat();
|
|
|
|
|
maybePushDeviceHeartbeat();
|
|
maybePushDeviceHeartbeat();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -380,7 +384,11 @@ public class StationPanel extends JPanel {
|
|
|
if (phase == Phase.IDLE) {
|
|
if (phase == Phase.IDLE) {
|
|
|
if (!sessionActive) {
|
|
if (!sessionActive) {
|
|
|
if (!device.isConnected()) {
|
|
if (!device.isConnected()) {
|
|
|
- device.connect();
|
|
|
|
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
|
|
+ if (now - lastPlcConnectAtMs >= PLC_RECONNECT_MS) {
|
|
|
|
|
+ lastPlcConnectAtMs = now;
|
|
|
|
|
+ device.connect();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (device.isConnected()) {
|
|
if (device.isConnected()) {
|
|
|
requestOpenSessionIfCheckOk();
|
|
requestOpenSessionIfCheckOk();
|
|
@@ -430,7 +438,6 @@ public class StationPanel extends JPanel {
|
|
|
}
|
|
}
|
|
|
uiPlcLabel();
|
|
uiPlcLabel();
|
|
|
uiDeviceStatusLight();
|
|
uiDeviceStatusLight();
|
|
|
- uiServerHeartbeat();
|
|
|
|
|
maybePushDeviceHeartbeat();
|
|
maybePushDeviceHeartbeat();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());
|
|
log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());
|