|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.iflytop.gd.app.ws.client; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.service.device.DeviceEmergencyStopService; |
|
|
|
import com.iflytop.gd.app.core.CommandPoolManager; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStateService; |
|
|
|
import com.iflytop.gd.app.service.device.DeviceStepCommandService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
@ -13,8 +15,9 @@ import java.net.URI; |
|
|
|
@Configuration |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceEmergencyStopConfig { |
|
|
|
private final DeviceEmergencyStopService deviceEmergencyStopService; |
|
|
|
|
|
|
|
private final DeviceStepCommandService stepCommandService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
private final CommandPoolManager commandPoolManager; |
|
|
|
|
|
|
|
@Value("${iflytophald.ip}") |
|
|
|
String ip; |
|
|
@ -29,13 +32,16 @@ public class DeviceEmergencyStopConfig { |
|
|
|
if (s.get("event").equals("press")) { |
|
|
|
log.info("触发急停{}", s); |
|
|
|
try { |
|
|
|
deviceEmergencyStopService.press(); |
|
|
|
commandPoolManager.forceShutdownAll();//强制终止现在运行的所有指令 |
|
|
|
stepCommandService.stopAll(); |
|
|
|
deviceStateService.getDeviceState().setEmergencyStop(true); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("设备急停失败:{}", e.getMessage()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} else if (s.get("event").equals("release")) { |
|
|
|
deviceEmergencyStopService.release(); |
|
|
|
commandPoolManager.restartExecutor(); |
|
|
|
deviceStateService.getDeviceState().setEmergencyStop(false); |
|
|
|
log.info("解除急停{}", s); |
|
|
|
} |
|
|
|
}); |
|
|
|