Browse Source

feat:ws推送急停

tags/1.0
白凤吉 5 months ago
parent
commit
4c41f45e4e
  1. 11
      src/main/java/com/qyft/ms/app/common/constant/WebSocketMessageType.java
  2. 9
      src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

11
src/main/java/com/qyft/ms/app/common/constant/WebSocketMessageType.java

@ -12,5 +12,16 @@ public class WebSocketMessageType {
*/
public static final String SPRAY_POINT = "spray-point";
/**
* 系统急停按钮被按下
*/
public static final String SYSTEM_E_STOP_PRESSED = "system_e_stop_pressed";
/**
* 系统急停按钮被释放
*/
public static final String SYSTEM_E_STOP_RELEASED = "system_e_stop_released";
}

9
src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

@ -1,11 +1,13 @@
package com.qyft.ms.system.service.device;
import cn.hutool.json.JSONObject;
import com.qyft.ms.app.common.constant.WebSocketMessageType;
import com.qyft.ms.system.common.constant.CommandStatus;
import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.core.client.DeviceTcpClient;
import com.qyft.ms.system.model.bo.DeviceCommand;
import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.WebSocketService;
import com.qyft.ms.system.service.front.FrontCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -25,6 +27,7 @@ public class DeviceCommandService {
private final DeviceTcpClient deviceTcpClient;
private final FrontCommandService frontCommandService;
private final WebSocketService webSocketService;
public CommandFuture executeCommand(DeviceCommand cmdToDevice) {
@ -87,6 +90,12 @@ public class DeviceCommandService {
} else if ("response".equals(tag)) {
completeCommandResponse(deviceResult);
} else if ("event".equals(tag)) {
String eventType = deviceResult.getStr("event_type");
if("system_e_stop_pressed".equals(eventType)) {//系统急停按钮被按下
webSocketService.pushMsg(WebSocketMessageType.SYSTEM_E_STOP_PRESSED, "系统急停按钮被按下");
}else if("system_e_stop_released".equals(eventType)) {//系统急停按钮被释放
webSocketService.pushMsg(WebSocketMessageType.SYSTEM_E_STOP_RELEASED, "系统急停按钮被释放");
}
} else if ("status".equals(tag)) {
}

Loading…
Cancel
Save