27 changed files with 1024 additions and 278 deletions
-
7src/main/java/com/qyft/ms/app/common/command/CommandFuture.java
-
31src/main/java/com/qyft/ms/app/common/command/CommandWaitControl.java
-
10src/main/java/com/qyft/ms/app/common/command/DeviceCommandGenerator.java
-
2src/main/java/com/qyft/ms/app/common/command/FrontCommandAck.java
-
8src/main/java/com/qyft/ms/app/common/constant/CommandStatus.java
-
136src/main/java/com/qyft/ms/app/controller/FrontCmdController.java
-
143src/main/java/com/qyft/ms/app/controller/frontcommandhandle/DehumidifierStart.java
-
46src/main/java/com/qyft/ms/app/controller/frontcommandhandle/MatrixSprayChangeParam.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/MatrixSprayContinue.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/MatrixSprayPause.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/MatrixSprayStart.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/MatrixSprayStop.java
-
49src/main/java/com/qyft/ms/app/controller/frontcommandhandle/NozzlePipelinePreFill.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/SlideTrayIn.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/SlideTrayOut.java
-
52src/main/java/com/qyft/ms/app/controller/frontcommandhandle/SprayPipelineWash.java
-
47src/main/java/com/qyft/ms/app/controller/frontcommandhandle/SyringePipelineWash.java
-
66src/main/java/com/qyft/ms/device/device/DeviceInstance.java
-
34src/main/java/com/qyft/ms/device/device/DeviceLifeEnum.java
-
32src/main/java/com/qyft/ms/device/device/MatrixSprayStatusEnum.java
-
32src/main/java/com/qyft/ms/device/device/MotorNameEnum.java
-
10src/main/java/com/qyft/ms/device/device/MotorX.java
-
10src/main/java/com/qyft/ms/device/device/MotorY.java
-
10src/main/java/com/qyft/ms/device/device/MotorZ.java
-
48src/main/java/com/qyft/ms/device/handler/DeviceMessageHandler.java
-
39src/main/java/com/qyft/ms/device/model/DeviceStatusEnum.java
@ -0,0 +1,143 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import cn.hutool.json.JSONObject; |
|||
import cn.hutool.json.JSONUtil; |
|||
import com.qyft.ms.app.common.command.CommandFuture; |
|||
import com.qyft.ms.app.common.command.CurrentSendCmdMapInstance; |
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.command.DeviceCommandGenerator; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.bo.CMDToDevice; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
public class DehumidifierStart { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
/** |
|||
* 1:判断参数是否合法 |
|||
*/ |
|||
Integer frontHumidity = (Integer) param.get("humidity"); |
|||
if (frontHumidity == null) { |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "参数 humidity 必填"), MediaType.APPLICATION_JSON); |
|||
emitter.complete(); |
|||
return; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 2:获取设备湿度 |
|||
*/ |
|||
|
|||
CMDToDevice humidityCmdToDevice = DeviceCommandGenerator.humidity_get();//生成指令 获取当前湿度 |
|||
CommandFuture humidityGetFuture = new CommandFuture(); |
|||
humidityGetFuture.setCmdToDevice(humidityCmdToDevice); |
|||
Integer toDeviceCmdId = humidityCmdToDevice.getCmdId(); |
|||
CurrentSendCmdMapInstance.getInstance().putCommand(toDeviceCmdId, humidityGetFuture);//将指令放入map |
|||
deviceTcpCMDServiceV2.send(humidityCmdToDevice); //发送指令给设备 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了获取湿度指令:" + JSONUtil.toJsonStr(humidityCmdToDevice)), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
humidityGetFuture.waitForContinue();//等待设备的反馈 |
|||
|
|||
|
|||
|
|||
/** |
|||
* 3:处理返回结果或者没有响应 |
|||
*/ |
|||
JSONObject deviceResult = humidityGetFuture.getCallbackResult();//拿到设备返回结果 |
|||
CurrentSendCmdMapInstance.getInstance().removeCommand(toDeviceCmdId);//将指令从map中删除 |
|||
|
|||
if (humidityGetFuture.isReceived() || humidityGetFuture.isGetResult()) { |
|||
//设备已经收到指令并且执行成功 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "设备指令反馈:" + JSONUtil.toJsonStr(deviceResult)), MediaType.APPLICATION_JSON); |
|||
|
|||
Double deviceHumidity = deviceResult.getDouble("humidity");//拿到设备返回的湿度数值 |
|||
if (frontHumidity > deviceHumidity) { |
|||
|
|||
//如果小于设置值,提醒用户不用除湿 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "设定湿度大于当前湿度,无需除湿。"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
} |
|||
else{ |
|||
|
|||
/** |
|||
* 4:如果大于设置值,开始除湿;打开除湿阀门 |
|||
*/ |
|||
|
|||
CMDToDevice dehumidifier_valve_control = DeviceCommandGenerator.dehumidifier_valve_control("open");//生成指令 开启除湿阀 |
|||
CommandFuture dehumidifier_valve_control_Future = new CommandFuture(); |
|||
humidityGetFuture.setCmdToDevice(dehumidifier_valve_control); |
|||
Integer dehumidifier_valve_control_cmdId = dehumidifier_valve_control.getCmdId(); |
|||
CurrentSendCmdMapInstance.getInstance().putCommand(dehumidifier_valve_control_cmdId, dehumidifier_valve_control_Future);//将指令放入map |
|||
deviceTcpCMDServiceV2.send(dehumidifier_valve_control); //发送指令给设备 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了开启除湿阀指令:" + JSONUtil.toJsonStr(dehumidifier_valve_control)), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
dehumidifier_valve_control_Future.waitForContinue();//等待设备的反馈 |
|||
|
|||
/** |
|||
* 5:处理打开除湿阀门返回结果 |
|||
*/ |
|||
JSONObject dehumidifier_valve_control_result = dehumidifier_valve_control_Future.getCallbackResult();//拿到设备返回结果 |
|||
CurrentSendCmdMapInstance.getInstance().removeCommand(dehumidifier_valve_control_cmdId);//将指令从map中删除 |
|||
|
|||
if (dehumidifier_valve_control_Future.isReceived() || dehumidifier_valve_control_Future.isGetResult()) { |
|||
//设备已经收到指令并且执行成功 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "开启除湿阀指令指令设备反馈:" + JSONUtil.toJsonStr(dehumidifier_valve_control_result)), MediaType.APPLICATION_JSON); |
|||
|
|||
} |
|||
else{ |
|||
//设备未收到指令或者执行失败 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "开启除湿阀指令没有响应:" + JSONUtil.toJsonStr(deviceResult)), MediaType.APPLICATION_JSON); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
}else{ |
|||
//设备未收到指令或者执行失败 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "设备没有响应:" + JSONUtil.toJsonStr(deviceResult)), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.device.DeviceInstance; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 实时修改参数 |
|||
*/ |
|||
public class MatrixSprayChangeParam { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 前端继续基质喷涂 |
|||
*/ |
|||
public class MatrixSprayContinue { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 前端暂停基质喷涂 |
|||
*/ |
|||
public class MatrixSprayPause { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 前端开始基质喷涂 |
|||
*/ |
|||
public class MatrixSprayStart { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 前端主动结束基质喷涂 |
|||
*/ |
|||
public class MatrixSprayStop { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 处理前端喷嘴管路预充指令 |
|||
*/ |
|||
public class NozzlePipelinePreFill { |
|||
|
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
spackage com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 处理前端推入托盘 |
|||
*/ |
|||
public class SlideTrayIn { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 处理前端推出托盘 |
|||
*/ |
|||
public class SlideTrayOut { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import cn.hutool.json.JSONObject; |
|||
import cn.hutool.json.JSONUtil; |
|||
import com.qyft.ms.app.common.command.CommandFuture; |
|||
import com.qyft.ms.app.common.command.CurrentSendCmdMapInstance; |
|||
import com.qyft.ms.app.common.command.DeviceCommandGenerator; |
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.bo.CMDToDevice; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
/** |
|||
* 处理前端清洗喷嘴管路 |
|||
*/ |
|||
public class SprayPipelineWash { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.qyft.ms.app.controller.frontcommandhandle; |
|||
|
|||
import com.qyft.ms.app.common.command.FrontCommandAck; |
|||
import com.qyft.ms.app.common.constant.CommandStatus; |
|||
import com.qyft.ms.app.model.form.CMDFormV2; |
|||
import com.qyft.ms.device.service.DeviceTcpCMDServiceV2; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 处理前端清洗注射器管路 |
|||
*/ |
|||
public class SyringePipelineWash { |
|||
public static void handle(DeviceTcpCMDServiceV2 deviceTcpCMDServiceV2, ResponseBodyEmitter emitter, CMDFormV2 cmdForm) { |
|||
|
|||
String frontCmdId = cmdForm.getCmdId(); |
|||
String frontCmdName = cmdForm.getCmdName(); |
|||
Map<String, Object> param = cmdForm.getParam(); |
|||
|
|||
new Thread(() -> { |
|||
try { |
|||
|
|||
//向前端发送接收到指令 |
|||
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} catch (IOException e) { |
|||
emitter.completeWithError(e); |
|||
} |
|||
}).start(); |
|||
|
|||
|
|||
//对返回结果处理 |
|||
emitter.complete(); |
|||
} |
|||
} |
@ -0,0 +1,66 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
import com.qyft.ms.device.model.DeviceStatusEnum; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class DeviceInstance { |
|||
private static DeviceInstance instance; |
|||
|
|||
private DeviceInstance() { |
|||
// private constructor to prevent instantiation |
|||
} |
|||
|
|||
public static synchronized DeviceInstance getInstance() { |
|||
if (instance == null) { |
|||
instance = new DeviceInstance(); |
|||
} |
|||
return instance; |
|||
} |
|||
|
|||
//设备名称 |
|||
private String deviceName; |
|||
//序列号 |
|||
private String deviceNumber; |
|||
//前端版本 |
|||
private String frontVersion; |
|||
//后端版本 |
|||
private String javaVersion; |
|||
//嵌入式版本 |
|||
private String linuxVersion; |
|||
//嵌入式版本 |
|||
private String microVersion; |
|||
//设备状态 |
|||
private DeviceStatusEnum deviceStatus; |
|||
|
|||
//喷涂状态 |
|||
private MatrixSprayStatusEnum matrixSprayStatusEnum; |
|||
//当前任务 |
|||
private String currentTaskCommandName; |
|||
//上一个任务 |
|||
private String previousTaskCommandName; |
|||
|
|||
private MotorX motorX; |
|||
private MotorY motorY; |
|||
private MotorZ motorZ; |
|||
|
|||
private void updateMotorPosition(MotorNameEnum motorName, Double position) { |
|||
if (motorName == MotorNameEnum.X) { |
|||
motorX.setPosition(position); |
|||
} else if (motorName == MotorNameEnum.Y) { |
|||
motorY.setPosition(position); |
|||
} else if (motorName == MotorNameEnum.Z) { |
|||
motorZ.setPosition(position); |
|||
} |
|||
|
|||
}; |
|||
private void updateMotorOrigin(MotorNameEnum motorName, Boolean isOrigin) { |
|||
if (motorName == MotorNameEnum.X) { |
|||
motorX.setIsOrigin(isOrigin); |
|||
} else if (motorName == MotorNameEnum.Y) { |
|||
motorY.setIsOrigin(isOrigin); |
|||
} else if (motorName == MotorNameEnum.Z) { |
|||
motorZ.setIsOrigin(isOrigin); |
|||
} |
|||
}; |
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
public enum DeviceLifeEnum { |
|||
|
|||
SYNCED("sync", "已经同步信息"), |
|||
NOSYNC("nosync", "未同步信息"), |
|||
NEWSTART("newStart", "刚从从新启动"), |
|||
SLEFCHECKED("slefchecked", "已经自检"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
DeviceLifeEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public static DeviceLifeEnum getByCode(String code) { |
|||
for (DeviceLifeEnum value : values()) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
public enum MatrixSprayStatusEnum { |
|||
YES("yes", "是"), |
|||
NO("no", "否"); |
|||
|
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
MatrixSprayStatusEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public static MatrixSprayStatusEnum getByCode(String code) { |
|||
for (MatrixSprayStatusEnum value : values()) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
public enum MotorNameEnum { |
|||
X("x", "X轴"), |
|||
Y("y", "Y轴"), |
|||
Z("z", "Z轴"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
MotorNameEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public static MotorNameEnum getByCode(String code) { |
|||
for (MotorNameEnum value : values()) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class MotorX { |
|||
private Boolean isOrigin; |
|||
private Double position; |
|||
private String name = MotorNameEnum.X.getCode(); |
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class MotorY { |
|||
private Boolean isOrigin; |
|||
private Double position; |
|||
private String name = MotorNameEnum.Y.getCode(); |
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.qyft.ms.device.device; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class MotorZ { |
|||
private Boolean isOrigin; |
|||
private Double position; |
|||
private String name = MotorNameEnum.Z.getCode(); |
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.qyft.ms.device.model; |
|||
|
|||
/** |
|||
* 设备状态枚举 |
|||
*/ |
|||
public enum DeviceStatusEnum { |
|||
FREE("free", "闲"), |
|||
BUSY("busy", "忙"), |
|||
ONLINE("online", "在线"), |
|||
OFFLINE("offline", "离线"), |
|||
FAULT("fault", "故障"), |
|||
MAINTENANCE("maintenance", "维护"), |
|||
UNKNOWN("unknown", "未知"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
DeviceStatusEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public static DeviceStatusEnum getByCode(String code) { |
|||
for (DeviceStatusEnum value : values()) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue