|
|
@ -1,424 +0,0 @@ |
|
|
|
package com.iflytop.sgs.app.service.device; |
|
|
|
|
|
|
|
import com.iflytop.sgs.app.model.bo.Point2D; |
|
|
|
import com.iflytop.sgs.app.model.bo.Point3D; |
|
|
|
import com.iflytop.sgs.app.model.entity.DevicePosition; |
|
|
|
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|
|
|
import com.iflytop.sgs.common.cmd.CommandFuture; |
|
|
|
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; |
|
|
|
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; |
|
|
|
import com.iflytop.sgs.common.enums.HeatModuleCode; |
|
|
|
import com.iflytop.sgs.common.enums.data.DevicePositionCode; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceCommandUtilService { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private final DevicePositionService devicePositionService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 门电机回原点 |
|
|
|
*/ |
|
|
|
public void doorOrigin() throws Exception { |
|
|
|
doorOrigin(null, null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 门电机回原点 |
|
|
|
*/ |
|
|
|
public void doorOrigin(String cmdId, String cmdCode) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorOrigin(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 门电机移动 |
|
|
|
*/ |
|
|
|
public void doorMove(double position) throws Exception { |
|
|
|
doorMove(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 门电机移动 |
|
|
|
*/ |
|
|
|
public void doorMove(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂移动到0点 |
|
|
|
*/ |
|
|
|
public void gantryMoveZero() throws Exception { |
|
|
|
gantryMove(null, null, new Point3D(0.0, 0.0, 0.0)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryMove(Point3D point) throws Exception { |
|
|
|
gantryMove(null, null, point); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryMove(String cmdId, String cmdCode, Point3D point) throws Exception { |
|
|
|
DeviceCommandBundle gantryXMoveDeviceCommand = DeviceCommandGenerator.gantryXMove(point.getX()); |
|
|
|
CommandFuture gantryXMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, gantryXMoveDeviceCommand); |
|
|
|
DeviceCommandBundle gantryZMoveDeviceCommand = DeviceCommandGenerator.gantryZMove(point.getZ()); |
|
|
|
CommandFuture gantryZMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, gantryZMoveDeviceCommand); |
|
|
|
commandWait(gantryXMoveDeviceCommandFuture,gantryZMoveDeviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryMoveQueue(Point3D point) throws Exception { |
|
|
|
gantryMoveQueue(null, null, point); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryMoveQueue(String cmdId, String cmdCode, Point3D point) throws Exception { |
|
|
|
DeviceCommandBundle gantryXMoveDeviceCommand = DeviceCommandGenerator.gantryXMove(point.getX()); |
|
|
|
DeviceCommandBundle gantryZMoveDeviceCommand = DeviceCommandGenerator.gantryZMove(point.getZ()); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, gantryXMoveDeviceCommand, gantryZMoveDeviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveOrigin() throws Exception { |
|
|
|
gantryXMoveOrigin(null, null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveOrigin(String cmdId, String cmdCode) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveOriginQueue() throws Exception { |
|
|
|
gantryXMoveOriginQueue(null, null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveOriginQueue(String cmdId, String cmdCode) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin(); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveOrigin() throws Exception { |
|
|
|
gantryZMoveOrigin(null, null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveOrigin(String cmdId, String cmdCode) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveOriginQueue() throws Exception { |
|
|
|
gantryZMoveOriginQueue(null, null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴回原点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveOriginQueue(String cmdId, String cmdCode) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin(); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMove(double position) throws Exception { |
|
|
|
gantryXMove(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMove(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMove(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveQueue(double position) throws Exception { |
|
|
|
gantryXMoveQueue(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveQueue(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMove(position); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMove(double position) throws Exception { |
|
|
|
gantryZMove(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 加液机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void motorLiquidMove(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMove(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 加液机械臂移动到指定点 |
|
|
|
*/ |
|
|
|
public void motorLiquidMove(double position) throws Exception { |
|
|
|
motorLiquidMove(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMove(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMove(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveQueue(double position) throws Exception { |
|
|
|
gantryZMoveQueue(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveQueue(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMove(position); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveBy(double position) throws Exception { |
|
|
|
gantryXMoveBy(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveBy(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveByQueue(double position) throws Exception { |
|
|
|
gantryXMoveByQueue(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂X轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryXMoveByQueue(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(position); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveBy(double position) throws Exception { |
|
|
|
gantryZMoveBy(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveBy(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(position); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveByQueue(double position) throws Exception { |
|
|
|
gantryZMoveByQueue(null, null, position); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 龙门架机械臂Z轴相对移动到指定点 |
|
|
|
*/ |
|
|
|
public void gantryZMoveByQueue(String cmdId, String cmdCode, double position) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(position); |
|
|
|
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFutureArr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指定加热模块开始加热 |
|
|
|
*/ |
|
|
|
public void heatRodOpen(HeatModuleCode heatModuleId, double temperature) throws Exception { |
|
|
|
heatRodOpen(null, null, heatModuleId, temperature); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指定加热模块开始加热 |
|
|
|
*/ |
|
|
|
public void heatRodOpen(String cmdId, String cmdCode, HeatModuleCode heatModuleId, double temperature) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = switch (heatModuleId) { |
|
|
|
case heat_module_01 -> DeviceCommandGenerator.heatRod1Open(temperature); |
|
|
|
case heat_module_02 -> DeviceCommandGenerator.heatRod2Open(temperature); |
|
|
|
case heat_module_03 -> DeviceCommandGenerator.heatRod3Open(temperature); |
|
|
|
case heat_module_04 -> DeviceCommandGenerator.heatRod4Open(temperature); |
|
|
|
}; |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指定加热模块停止加热 |
|
|
|
*/ |
|
|
|
public void heatRodClose(HeatModuleCode heatModuleId) throws Exception { |
|
|
|
heatRodClose(null, null, heatModuleId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指定加热模块停止加热 |
|
|
|
*/ |
|
|
|
public void heatRodClose(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand = switch (heatModuleId) { |
|
|
|
case heat_module_01 -> DeviceCommandGenerator.heatRod1Close(); |
|
|
|
case heat_module_02 -> DeviceCommandGenerator.heatRod2Close(); |
|
|
|
case heat_module_03 -> DeviceCommandGenerator.heatRod3Close(); |
|
|
|
case heat_module_04 -> DeviceCommandGenerator.heatRod4Close(); |
|
|
|
}; |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
public void commandWait(CommandFuture... futures) throws Exception { |
|
|
|
CompletableFuture<?>[] responseFutures = Arrays.stream(futures) |
|
|
|
.map(CommandFuture::getResponseFuture) |
|
|
|
.toArray(CompletableFuture[]::new); |
|
|
|
CompletableFuture.allOf(responseFutures) |
|
|
|
.get(120, TimeUnit.SECONDS); |
|
|
|
} |
|
|
|
|
|
|
|
/////////////////////////////////////////////////获取位置 |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取指定加热区托盘夹爪点位 |
|
|
|
*/ |
|
|
|
public Point3D getHeatAreaTrayClawPoint3D(HeatModuleCode heatModuleId) { |
|
|
|
DevicePosition devicePosition = switch (heatModuleId) { |
|
|
|
case heat_module_01 -> devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint); |
|
|
|
case heat_module_02 -> devicePositionService.getPosition(DevicePositionCode.heatArea2TrayClawPoint); |
|
|
|
case heat_module_03 -> devicePositionService.getPosition(DevicePositionCode.heatArea3TrayClawPoint); |
|
|
|
case heat_module_04 -> devicePositionService.getPosition(DevicePositionCode.heatArea4TrayClawPoint); |
|
|
|
}; |
|
|
|
return devicePosition.getPoint3D(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取指定加热区拍子夹爪点位 |
|
|
|
*/ |
|
|
|
public Point3D getHeatAreaCapClawPointPoint3D(HeatModuleCode heatModuleId) { |
|
|
|
DevicePosition devicePosition = switch (heatModuleId) { |
|
|
|
case heat_module_01 -> devicePositionService.getPosition(DevicePositionCode.heatArea1CapClawPoint); |
|
|
|
case heat_module_02 -> devicePositionService.getPosition(DevicePositionCode.heatArea2CapClawPoint); |
|
|
|
case heat_module_03 -> devicePositionService.getPosition(DevicePositionCode.heatArea3CapClawPoint); |
|
|
|
case heat_module_04 -> devicePositionService.getPosition(DevicePositionCode.heatArea4CapClawPoint); |
|
|
|
}; |
|
|
|
return devicePosition.getPoint3D(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据试管需要获取点位 |
|
|
|
*/ |
|
|
|
public Point2D getPointByTubeNum(int tubeNum) { |
|
|
|
return new Point2D(tubeNum * 60.0, tubeNum * 60.0);// |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void fanStart(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand; |
|
|
|
switch (heatModuleId) { |
|
|
|
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open(); |
|
|
|
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Open(); |
|
|
|
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Open(); |
|
|
|
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Open(); |
|
|
|
default -> throw new RuntimeException("heatId 未找到"); |
|
|
|
} |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void fanClose(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception { |
|
|
|
DeviceCommandBundle deviceCommand; |
|
|
|
switch (heatModuleId) { |
|
|
|
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close(); |
|
|
|
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Close(); |
|
|
|
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Close(); |
|
|
|
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Close(); |
|
|
|
default -> throw new RuntimeException("heatId 未找到"); |
|
|
|
} |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
} |