|
|
@ -1,13 +1,24 @@ |
|
|
|
package com.qyft.ms.app.handler.impl; |
|
|
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import com.qyft.ms.app.common.annotation.CommandMapping; |
|
|
|
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.handler.CommandHandler; |
|
|
|
import com.qyft.ms.app.model.bo.CMDToDevice; |
|
|
|
import com.qyft.ms.app.model.form.CMDFormV2; |
|
|
|
import com.qyft.ms.device.client.TcpClient; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 注射器管路_清洗注射器管路 |
|
|
|
*/ |
|
|
@ -16,9 +27,229 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter |
|
|
|
@Async("asyncExecutor") |
|
|
|
@CommandMapping("syringe_pipeline_wash")//业务指令注解 |
|
|
|
public class SyringePipelineWash implements CommandHandler { |
|
|
|
/** |
|
|
|
* 设备通信client |
|
|
|
*/ |
|
|
|
private final TcpClient deviceClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handle(CMDFormV2 cmdForm, ResponseBodyEmitter emitter) throws Exception { |
|
|
|
String frontCmdId = cmdForm.getCmdId(); |
|
|
|
String frontCmdName = cmdForm.getCmdName(); |
|
|
|
Map<String, Object> param = cmdForm.getParam(); |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RECEIVE, "后台已收到指令"), MediaType.APPLICATION_JSON);//向前端发送接收到指令 |
|
|
|
// 1. 参数校验 |
|
|
|
Integer speed = (Integer) param.get("speed"); |
|
|
|
if (speed == null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "参数 speed 必填"), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
//2.判断z轴是否在安全距离,如果不在安全距离可以不抬升z轴 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "判断z轴是否在安全距离,如果不在安全距离可以不抬升z轴"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice motorXYZPositionGetCmdToDevice = DeviceCommandGenerator.motor_xyz_position_get();//生成指令 获取xyz当前位置 |
|
|
|
CommandFuture motorXYZPositionGetCmdToDeviceFuture = new CommandFuture(); |
|
|
|
motorXYZPositionGetCmdToDeviceFuture.setCmdToDevice(motorXYZPositionGetCmdToDevice); |
|
|
|
Integer motorXYZPositionGetCmdToDeviceCmdId = motorXYZPositionGetCmdToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(motorXYZPositionGetCmdToDeviceCmdId, motorXYZPositionGetCmdToDeviceFuture);//将指令放入map |
|
|
|
deviceClient.sendToJSON(motorXYZPositionGetCmdToDevice); //发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了获得电机XYZ相对原点坐标指令", motorXYZPositionGetCmdToDevice), MediaType.APPLICATION_JSON); |
|
|
|
motorXYZPositionGetCmdToDeviceFuture.waitForContinue();//等待设备的反馈 |
|
|
|
JSONObject motorXYZPositionGetCmdToDeviceResult = motorXYZPositionGetCmdToDeviceFuture.getCallbackResult();//拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(motorXYZPositionGetCmdToDeviceCmdId);//将指令从map中删除 |
|
|
|
if (!motorXYZPositionGetCmdToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "获得电机XYZ相对原点坐标指令响应超时", motorXYZPositionGetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (motorXYZPositionGetCmdToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "获得电机XYZ相对原点坐标指令返回错误", motorXYZPositionGetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
Double zAxisPosition = motorXYZPositionGetCmdToDeviceResult.getJSONObject("result").getDouble("zAxisPosition");//当前z轴相对于原点的位置 |
|
|
|
if (zAxisPosition == null || zAxisPosition < 0.0) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "获得电机XYZ相对原点坐标指令执行失败", motorXYZPositionGetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "电机XYZ相对原点坐标指令反馈", motorXYZPositionGetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
if (zAxisPosition > 80) { //z轴超出安全距离,抬升z轴 //TODO安全距离应该可配置 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "z轴超出安全距离,抬升z轴至安全距离"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice motorZPositionSetCmdToDevice = DeviceCommandGenerator.motor_z_position_set(80.0, 2);//生成指令 移动z轴到指定位置 (TODO)安全距离应该可配置 |
|
|
|
CommandFuture motorZPositionSetCmdToDeviceFuture = new CommandFuture(); |
|
|
|
motorZPositionSetCmdToDeviceFuture.setCmdToDevice(motorZPositionSetCmdToDevice); |
|
|
|
Integer motorZPositionSetCmdToDeviceCmdId = motorZPositionSetCmdToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(motorZPositionSetCmdToDeviceCmdId, motorZPositionSetCmdToDeviceFuture);//将指令放入map |
|
|
|
deviceClient.sendToJSON(motorZPositionSetCmdToDevice); //发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了移动z轴到指定位置指令", motorZPositionSetCmdToDevice), MediaType.APPLICATION_JSON); |
|
|
|
motorZPositionSetCmdToDeviceFuture.waitForContinue();//等待设备的反馈 |
|
|
|
JSONObject motorZPositionSetCmdToDeviceResult = motorZPositionSetCmdToDeviceFuture.getCallbackResult();//拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(motorZPositionSetCmdToDeviceCmdId);//将指令从map中删除 |
|
|
|
if (!motorZPositionSetCmdToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令置响应超时", motorZPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (motorZPositionSetCmdToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令返回错误", motorZPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Boolean motorZPositionSetCmdToDeviceResultStatus = motorZPositionSetCmdToDeviceResult.getBool("result"); |
|
|
|
if (!motorZPositionSetCmdToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令执行失败", motorZPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "移动z轴到指定位指令反馈", motorZPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
} |
|
|
|
//3.xy轴移动到废液位置 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "轴移动到废液位置"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice motorXPositionSetCmdToDevice = DeviceCommandGenerator.motor_x_position_set(173.08, 2);//生成指令 移动x轴到指定位置 (TODO) 废液桶X轴位置应当可以配置 |
|
|
|
CommandFuture motorXPositionSetCmdToDeviceFuture = new CommandFuture(); |
|
|
|
motorXPositionSetCmdToDeviceFuture.setCmdToDevice(motorXPositionSetCmdToDevice); |
|
|
|
Integer motorXPositionSetCmdToDeviceCmdId = motorXPositionSetCmdToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(motorXPositionSetCmdToDeviceCmdId, motorXPositionSetCmdToDeviceFuture);//将指令放入map |
|
|
|
deviceClient.sendToJSON(motorXPositionSetCmdToDevice); //发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了移动x轴到指定位置指令", motorXPositionSetCmdToDevice), MediaType.APPLICATION_JSON); |
|
|
|
motorXPositionSetCmdToDeviceFuture.waitForContinue();//等待设备的反馈 |
|
|
|
JSONObject motorXPositionSetCmdToDeviceResult = motorXPositionSetCmdToDeviceFuture.getCallbackResult();//拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(motorXPositionSetCmdToDeviceCmdId);//将指令从map中删除 |
|
|
|
if (!motorXPositionSetCmdToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动x轴到指定位置指令响应超时", motorXPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (motorXPositionSetCmdToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动x轴到指定位置指令返回错误", motorXPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
Boolean motorXYZPositionSetCmdToDeviceResultStatus = motorXPositionSetCmdToDeviceResult.getBool("result"); |
|
|
|
if (!motorXYZPositionSetCmdToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动x轴到指定位置指令执行失败", motorXPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "移动x轴到指定位置指令反馈", motorXPositionSetCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice motorYPositionSetCMDToDevice = DeviceCommandGenerator.motor_y_position_set(75.0, 0);//移动y轴到指定位置 (TODO) 废液桶Y轴位置应当可以配置 |
|
|
|
CommandFuture motorYPositionSetCMDToDeviceFuture = new CommandFuture(); |
|
|
|
motorYPositionSetCMDToDeviceFuture.setCmdToDevice(motorYPositionSetCMDToDevice); |
|
|
|
Integer motorYPositionSetCMDToDeviceCmdId = motorYPositionSetCMDToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(motorYPositionSetCMDToDeviceCmdId, motorYPositionSetCMDToDeviceFuture);//将指令放入map |
|
|
|
deviceClient.sendToJSON(motorYPositionSetCMDToDevice); //发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了移动y轴到指定位置指令", motorYPositionSetCMDToDevice), MediaType.APPLICATION_JSON); |
|
|
|
motorYPositionSetCMDToDeviceFuture.waitForContinue();//等待设备的反馈 |
|
|
|
JSONObject motorYPositionSetCMDToDeviceResult = motorYPositionSetCMDToDeviceFuture.getCallbackResult();//拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(motorYPositionSetCMDToDeviceCmdId);//将指令从map中删除 |
|
|
|
if (!motorYPositionSetCMDToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动y轴到指定位置指令响应超时", motorYPositionSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (motorYPositionSetCMDToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动y轴到指定位置指令返回错误", motorYPositionSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
Boolean motorYPositionSetCMDToDeviceResultStatus = motorYPositionSetCMDToDeviceResult.getBool("result"); |
|
|
|
if (!motorYPositionSetCMDToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动y轴到指定位置指令执行失败", motorYPositionSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "移动y轴到指定位置指令反馈", motorYPositionSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
//4.下降z轴高度,防止飞溅 |
|
|
|
Thread.sleep(10 * 1000);//TODO 等待10秒,x和y轴移动完毕 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "下降z轴高度,防止飞溅"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice motorZPositionSetDownCmdToDevice = DeviceCommandGenerator.motor_z_position_set(70.0, 2);//生成指令 移动z轴到指定位置 (TODO) 废液桶Y轴位置应当可以配置 |
|
|
|
CommandFuture motorZPositionSetDownCmdToDeviceFuture = new CommandFuture(); |
|
|
|
motorZPositionSetDownCmdToDeviceFuture.setCmdToDevice(motorZPositionSetDownCmdToDevice); |
|
|
|
Integer motorZPositionSetDownCmdToDeviceCmdId = motorZPositionSetDownCmdToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(motorZPositionSetDownCmdToDeviceCmdId, motorZPositionSetDownCmdToDeviceFuture);//将指令放入map |
|
|
|
deviceClient.sendToJSON(motorZPositionSetDownCmdToDevice); //发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了移动z轴到指定位置指令", motorZPositionSetDownCmdToDevice), MediaType.APPLICATION_JSON); |
|
|
|
motorZPositionSetDownCmdToDeviceFuture.waitForContinue();//等待设备的反馈 |
|
|
|
JSONObject motorZPositionSetDownCmdToDeviceResult = motorZPositionSetDownCmdToDeviceFuture.getCallbackResult();//拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(motorZPositionSetDownCmdToDeviceCmdId);//将指令从map中删除 |
|
|
|
if (!motorZPositionSetDownCmdToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令置响应超时", motorZPositionSetDownCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (motorZPositionSetDownCmdToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令返回错误", motorZPositionSetDownCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Boolean motorZPositionSetDownCmdToDeviceResultStatus = motorZPositionSetDownCmdToDeviceResult.getBool("result"); |
|
|
|
if (!motorZPositionSetDownCmdToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "移动z轴到指定位指令执行失败", motorZPositionSetDownCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "移动z轴到指定位指令反馈", motorZPositionSetDownCmdToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
//5.打开三通阀注射器管路 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "打开三通阀注射器管路"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice threeWayValveOpenSprayPipelineCMDToDevice = DeviceCommandGenerator.three_way_valve_open_spray_pipeline();//生成指令 打开三通阀注射器管路 |
|
|
|
CommandFuture threeWayValveOpenSprayPipelineCMDToDeviceFuture = new CommandFuture(); |
|
|
|
threeWayValveOpenSprayPipelineCMDToDeviceFuture.setCmdToDevice(threeWayValveOpenSprayPipelineCMDToDevice); |
|
|
|
Integer threeWayValveOpenSprayPipelineCMDToDeviceCmdId = threeWayValveOpenSprayPipelineCMDToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(threeWayValveOpenSprayPipelineCMDToDeviceCmdId, threeWayValveOpenSprayPipelineCMDToDeviceFuture); // 将指令放入map |
|
|
|
deviceClient.sendToJSON(threeWayValveOpenSprayPipelineCMDToDevice); // 发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了打开三通阀注射器管路指令", threeWayValveOpenSprayPipelineCMDToDevice), MediaType.APPLICATION_JSON); |
|
|
|
threeWayValveOpenSprayPipelineCMDToDeviceFuture.waitForContinue(); // 等待设备的反馈 |
|
|
|
JSONObject threeWayValveOpenSprayPipelineCMDToDeviceResult = threeWayValveOpenSprayPipelineCMDToDeviceFuture.getCallbackResult(); // 拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(threeWayValveOpenSprayPipelineCMDToDeviceCmdId); // 将指令从map中删除 |
|
|
|
if (!threeWayValveOpenSprayPipelineCMDToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "打开三通阀注射器管路指令响应超时", threeWayValveOpenSprayPipelineCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (threeWayValveOpenSprayPipelineCMDToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "打开三通阀注射器管路指令返回错误", threeWayValveOpenSprayPipelineCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
Boolean threeWayValveOpenSprayPipelineCMDToDeviceResultStatus = threeWayValveOpenSprayPipelineCMDToDeviceResult.getBool("result"); |
|
|
|
if (!threeWayValveOpenSprayPipelineCMDToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "打开三通阀注射器管路指令执行失败", threeWayValveOpenSprayPipelineCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "打开三通阀注射器管路指令反馈", threeWayValveOpenSprayPipelineCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
//6.设置注射泵速度,推注射泵 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "设置注射泵速度,推注射泵"), MediaType.APPLICATION_JSON); |
|
|
|
CMDToDevice syringePumpInjectionVolumeSetCMDToDevice = DeviceCommandGenerator.syringe_pump_injection_volume_set(1);//推动移动注射泵 |
|
|
|
CommandFuture syringePumpInjectionVolumeSetCMDToDeviceFuture = new CommandFuture(); |
|
|
|
syringePumpInjectionVolumeSetCMDToDeviceFuture.setCmdToDevice(syringePumpInjectionVolumeSetCMDToDevice); |
|
|
|
Integer syringePumpInjectionVolumeSetCMDToDeviceCmdId = syringePumpInjectionVolumeSetCMDToDevice.getCmdId(); |
|
|
|
CurrentSendCmdMapInstance.getInstance().putCommand(syringePumpInjectionVolumeSetCMDToDeviceCmdId, syringePumpInjectionVolumeSetCMDToDeviceFuture); // 将指令放入map |
|
|
|
deviceClient.sendToJSON(syringePumpInjectionVolumeSetCMDToDevice); // 发送指令给设备 |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.SEND, "已向设备发送了推动移动注射泵指令", syringePumpInjectionVolumeSetCMDToDevice), MediaType.APPLICATION_JSON); |
|
|
|
syringePumpInjectionVolumeSetCMDToDeviceFuture.waitForContinue(); // 等待设备的反馈 |
|
|
|
JSONObject syringePumpInjectionVolumeSetCMDToDeviceResult = syringePumpInjectionVolumeSetCMDToDeviceFuture.getCallbackResult(); // 拿到设备返回结果 |
|
|
|
CurrentSendCmdMapInstance.getInstance().removeCommand(syringePumpInjectionVolumeSetCMDToDeviceCmdId); // 将指令从map中删除 |
|
|
|
if (!syringePumpInjectionVolumeSetCMDToDeviceFuture.isReceived()) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "推动移动注射泵指令响应超时", syringePumpInjectionVolumeSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (syringePumpInjectionVolumeSetCMDToDeviceResult.getJSONObject("error") != null) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "推动移动注射泵指令返回错误", syringePumpInjectionVolumeSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
Boolean syringePumpInjectionVolumeSetCMDToDeviceResultStatus = syringePumpInjectionVolumeSetCMDToDeviceResult.getBool("result"); |
|
|
|
if (!syringePumpInjectionVolumeSetCMDToDeviceResultStatus) { |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.ERROR, "推动移动注射泵指令执行失败", syringePumpInjectionVolumeSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
return; |
|
|
|
} |
|
|
|
emitter.send(FrontCommandAck.backstageAck(frontCmdId, frontCmdName, CommandStatus.RESULT, "推动移动注射泵指令反馈", syringePumpInjectionVolumeSetCMDToDeviceResult), MediaType.APPLICATION_JSON); |
|
|
|
emitter.complete(); |
|
|
|
} |
|
|
|
} |