Browse Source

fix:调整指令执行顺序

master
白凤吉 1 day ago
parent
commit
6ed250190b
  1. 17
      src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

17
src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

@ -101,9 +101,6 @@ public class ChannelCtrlService {
handleCalculateActualDispensedVolume(channelState, formulation.getVolume(), formulation.getRevolutions()); handleCalculateActualDispensedVolume(channelState, formulation.getVolume(), formulation.getRevolutions());
} }
} }
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
for (ChannelState channelState : channelStateList) { for (ChannelState channelState : channelStateList) {
channelState.setStateCode(ChannelStateCode.IDLE); channelState.setStateCode(ChannelStateCode.IDLE);
//关闭阀门 //关闭阀门
@ -111,6 +108,8 @@ public class ChannelCtrlService {
deviceCommandService.sendCommand(valveCloseDeviceCommand); deviceCommandService.sendCommand(valveCloseDeviceCommand);
} }
deviceState.setSolutionAddStop(false); deviceState.setSolutionAddStop(false);
} catch (Exception e) {
throw new RuntimeException(e);
} }
}); });
} }
@ -119,8 +118,8 @@ public class ChannelCtrlService {
* 停止加液 * 停止加液
*/ */
public void solutionAddStop() { public void solutionAddStop() {
List<ChannelState> channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.ADD);
deviceState.setSolutionAddStop(true); deviceState.setSolutionAddStop(true);
List<ChannelState> channelCodeList = deviceState.filterChannelStatesByState(ChannelStateCode.ADD);
try { try {
List<CommandFuture> commandFutureList = new ArrayList<>(); List<CommandFuture> commandFutureList = new ArrayList<>();
for (ChannelState channelState : channelCodeList) { for (ChannelState channelState : channelCodeList) {
@ -128,12 +127,11 @@ public class ChannelCtrlService {
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand));
} }
CommandUtil.wait(commandFutureList); CommandUtil.wait(commandFutureList);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
for (ChannelState channelCode : channelCodeList) { for (ChannelState channelCode : channelCodeList) {
channelCode.setStateCode(ChannelStateCode.IDLE); channelCode.setStateCode(ChannelStateCode.IDLE);
} }
} catch (Exception e) {
throw new RuntimeException(e);
} }
} }
@ -202,9 +200,6 @@ public class ChannelCtrlService {
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand));
} }
CommandUtil.wait(commandFutureList); CommandUtil.wait(commandFutureList);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
for (ChannelState channelCode : channelCodeList) { for (ChannelState channelCode : channelCodeList) {
channelCode.setPre(true); channelCode.setPre(true);
channelCode.setStateCode(ChannelStateCode.IDLE); channelCode.setStateCode(ChannelStateCode.IDLE);
@ -212,6 +207,8 @@ public class ChannelCtrlService {
DeviceCommand valveCloseDeviceCommand = getValveCloseCommandByChannel(channelCode.getChannelCode()); DeviceCommand valveCloseDeviceCommand = getValveCloseCommandByChannel(channelCode.getChannelCode());
deviceCommandService.sendCommand(valveCloseDeviceCommand); deviceCommandService.sendCommand(valveCloseDeviceCommand);
} }
} catch (Exception e) {
throw new RuntimeException(e);
} }
}); });
} }

Loading…
Cancel
Save