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