|
|
@ -26,7 +26,6 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceCommandTempUtilService { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private final HeatModuleService heatModuleService; |
|
|
|
private final DevicePositionService devicePositionService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
@ -38,63 +37,38 @@ public class DeviceCommandTempUtilService { |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会恢复之前升起的状态 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidUpNoWait(HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
moveTrayHeatModuleAvoidUpNoWait(null, null, targetHeatModuleCode, exceptionHeatModuleCodes); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 避让抬升 |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会恢复之前升起的状态 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidUp(HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
public void moveTrayHeatModuleAvoidUp(HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) { |
|
|
|
moveTrayHeatModuleAvoidUp(null, null, targetHeatModuleCode, exceptionHeatModuleCodes); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 避让抬升 |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会恢复之前升起的状态 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidUpNoWait(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //托盘升降抬升距离 |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleCode)) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLift); |
|
|
|
deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
} |
|
|
|
} |
|
|
|
if (targetHeatModuleCode != null) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLift); |
|
|
|
deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
} |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//加热模块托盘升降状态 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 避让抬升 |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会恢复之前升起的状态 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidUp(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
public void moveTrayHeatModuleAvoidUp(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) { |
|
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //托盘升降抬升距离 |
|
|
|
List<CommandFuture> futuresList = new ArrayList<>(); |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleCode)) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLift); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
heatModuleService.heaterMotorMove(cmdId, cmdCode, heatModuleCode, trayLift); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//加热模块托盘升降状态 |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("避让抬升错误:{}", heatModuleCode, e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (targetHeatModuleCode != null) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLift); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
CommandUtil.wait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1);//加热模块托盘升降状态 |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
heatModuleService.heaterMotorMove(cmdId, cmdCode, targetHeatModuleCode, trayLift); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayUp(1);//加热模块托盘升降状态 |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("避让抬升错误:{}", targetHeatModuleCode, e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -103,15 +77,6 @@ public class DeviceCommandTempUtilService { |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会下降所有升起的加热模块并且记录 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidDownNoWait(HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
moveTrayHeatModuleAvoidDownNoWait(null, null, targetHeatModuleCode, exceptionHeatModuleCodes); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 避让下降 |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会下降所有升起的加热模块并且记录 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidDown(HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
moveTrayHeatModuleAvoidDown(null, null, targetHeatModuleCode, exceptionHeatModuleCodes); |
|
|
|
} |
|
|
@ -121,35 +86,7 @@ public class DeviceCommandTempUtilService { |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会下降所有升起的加热模块并且记录 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidDownNoWait(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
moveTrayHeatModuleAvoidUpStateList.clear(); |
|
|
|
List<HeatModuleState> heatModuleStateList = deviceStateService.getDeviceState().getHeatModule(); |
|
|
|
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取加热位下降托盘位置 |
|
|
|
for (HeatModuleState heatModuleState : heatModuleStateList) { |
|
|
|
if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleState.getModuleCode())) { |
|
|
|
if (heatModuleState.getTrayUp() == 1) { |
|
|
|
HeatModuleCode heatModuleCode = heatModuleState.getModuleCode(); |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLower); |
|
|
|
deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
moveTrayHeatModuleAvoidUpStateList.add(heatModuleCode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (targetHeatModuleCode != null) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLower); |
|
|
|
deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
} |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 避让下降 |
|
|
|
* 临时移动托盘的时候,加热模块升降避让 |
|
|
|
* 该方法会下降所有升起的加热模块并且记录 |
|
|
|
*/ |
|
|
|
public void moveTrayHeatModuleAvoidDown(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) throws Exception { |
|
|
|
public void moveTrayHeatModuleAvoidDown(String cmdId, String cmdCode, HeatModuleCode targetHeatModuleCode, HeatModuleCode... exceptionHeatModuleCodes) { |
|
|
|
moveTrayHeatModuleAvoidUpStateList.clear(); |
|
|
|
List<HeatModuleState> heatModuleStateList = deviceStateService.getDeviceState().getHeatModule(); |
|
|
|
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取加热位下降托盘位置 |
|
|
@ -158,21 +95,26 @@ public class DeviceCommandTempUtilService { |
|
|
|
if (!Arrays.stream(exceptionHeatModuleCodes).toList().contains(heatModuleState.getModuleCode())) { |
|
|
|
if (heatModuleState.getTrayUp() == 1) { |
|
|
|
HeatModuleCode heatModuleCode = heatModuleState.getModuleCode(); |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(heatModuleCode, trayLower); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
moveTrayHeatModuleAvoidUpStateList.add(heatModuleCode); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
heatModuleService.heaterMotorMove(cmdId, cmdCode, heatModuleCode, trayLower); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("避让下降错误:{}", heatModuleCode, e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (targetHeatModuleCode != null) { |
|
|
|
DeviceCommandBundle deviceCommand = getHeaterMotorMoveDeviceCommand(targetHeatModuleCode, trayLower); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
CommandUtil.wait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
for (HeatModuleCode heatModuleCode : moveTrayHeatModuleAvoidUpStateList) { |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态 |
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
try { |
|
|
|
heatModuleService.heaterMotorMove(cmdId, cmdCode, targetHeatModuleCode, trayLower); |
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayUp(0);//加热模块托盘升降状态 |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("避让下降错误:{}", targetHeatModuleCode, e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|