Browse Source

fix:修复停止喷涂抽搐问题

master
白凤吉 3 weeks ago
parent
commit
b9f0837e94
  1. 24
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java
  2. 9
      src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

24
src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java

@ -83,14 +83,14 @@ public class SprayTaskExecutor {
//先移动到玻片位置 //先移动到玻片位置
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskStep.getIndex()][0], 20.0); DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskStep.getIndex()][0], 20.0);
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(75.5 - slideArr[sprayTaskStep.getIndex()][1], 20.0); DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(75.5 - slideArr[sprayTaskStep.getIndex()][1], 20.0);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXPositionSetCommand);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYPositionSetCommand);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXPositionSetCommand);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYPositionSetCommand);
SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper<SysSettings>().eq(SysSettings::getCode, "slide_height")); SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper<SysSettings>().eq(SysSettings::getCode, "slide_height"));
Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue());
Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight();//下降z轴高度 Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight();//下降z轴高度
DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height, 15.0); DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height, 15.0);
CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand);
CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand);
commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture);
} }
Thread.sleep(100); Thread.sleep(100);
@ -110,7 +110,7 @@ public class SprayTaskExecutor {
} }
if(i == 1){ if(i == 1){
DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵 DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵
CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand);
CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand);
commandWait(syringePumpForwardCommandFuture); commandWait(syringePumpForwardCommandFuture);
} }
sprayTask.setFirstImmobility(true); sprayTask.setFirstImmobility(true);
@ -127,12 +127,12 @@ public class SprayTaskExecutor {
ySprayStepCommands.getParam().put("position", Double.parseDouble(df.format(aYPoint))); ySprayStepCommands.getParam().put("position", Double.parseDouble(df.format(aYPoint)));
if (cacheXPoint != aXPoint) { if (cacheXPoint != aXPoint) {
CommandFuture commandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), xSprayStepCommands);
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), xSprayStepCommands);
commandFutureList.add(commandFuture); commandFutureList.add(commandFuture);
cacheXPoint = aXPoint; cacheXPoint = aXPoint;
} }
if (cacheYPoint != aYPoint) { if (cacheYPoint != aYPoint) {
CommandFuture commandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), ySprayStepCommands);
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), ySprayStepCommands);
commandFutureList.add(commandFuture); commandFutureList.add(commandFuture);
cacheYPoint = aYPoint; cacheYPoint = aYPoint;
} }
@ -160,7 +160,7 @@ public class SprayTaskExecutor {
deviceStatus.setSuspendable(false); deviceStatus.setSuspendable(false);
if (currentStep >= reCurrentStep) { if (currentStep >= reCurrentStep) {
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵 DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand);
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand);
commandWait(syringePumpStopCommandFuture); commandWait(syringePumpStopCommandFuture);
} }
sprayCount++; sprayCount++;
@ -168,20 +168,20 @@ public class SprayTaskExecutor {
} }
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压 DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
commandWait(highVoltageCloseCommandFuture); commandWait(highVoltageCloseCommandFuture);
Thread.sleep(500); Thread.sleep(500);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose();//关闭喷嘴阀 DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose();//关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
commandWait(nozzleValveCloseCommandFuture); commandWait(nozzleValveCloseCommandFuture);
//XYZ回原点 //XYZ回原点
DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin(); DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();
DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin(); DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin();
DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin(); DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin();
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXOriginCommand);
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYOriginCommand);
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand);
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXOriginCommand);
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYOriginCommand);
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand);
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture);

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

@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.qyft.ms.app.core.event.VirtualDeviceCmdResponseEvent; import com.qyft.ms.app.core.event.VirtualDeviceCmdResponseEvent;
import com.qyft.ms.app.device.status.DeviceStatus; import com.qyft.ms.app.device.status.DeviceStatus;
import com.qyft.ms.app.device.status.SprayTask;
import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.constant.CommandStatus;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.CyclicNumberGenerator; import com.qyft.ms.system.common.device.command.CyclicNumberGenerator;
@ -72,6 +73,14 @@ public class DeviceCommandService {
return commandFuture; return commandFuture;
} }
public CommandFuture sendCommandSprayTask(String cmdId, String cmdCode, DeviceCommand deviceCommand) throws Exception {
SprayTask sprayTask = SprayTask.getInstance();
if (sprayTask.isClosing() || Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
return sendCommand(cmdId, cmdCode, deviceCommand);
}
public void completeCommandResponse(JSONObject deviceResult) { public void completeCommandResponse(JSONObject deviceResult) {
Integer cmdId = deviceResult.getInt("cmdId"); Integer cmdId = deviceResult.getInt("cmdId");
if (cmdId != null) { if (cmdId != null) {

Loading…
Cancel
Save