白凤吉 2 months ago
parent
commit
49725744e2
  1. 5
      src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java
  2. 9
      src/main/java/com/iflytop/gd/app/controller/TestController.java
  3. 14
      src/main/java/com/iflytop/gd/app/service/api/CraftsService.java
  4. 5
      src/main/java/com/iflytop/gd/app/service/api/TrayService.java
  5. 4
      src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java
  6. 128
      src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java
  7. 99
      src/main/java/com/iflytop/gd/app/service/device/module/SolutionModuleService.java
  8. 3
      src/main/java/com/iflytop/gd/app/ws/client/DeviceEmergencyStopConfig.java
  9. 1
      src/main/java/com/iflytop/gd/common/result/ResultCode.java

5
src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java

@ -47,6 +47,9 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
|| deviceStateService.getCommandMutexState().get().isShakeStartCommandExecuting()) {
throw new AppException(ResultCode.CMD_BUSY);
}
if (!deviceStateService.getDeviceState().getSolutionModule().isIdle()) {
throw new AppException(ResultCode.SOLUTION_MODULE_OCCUPIED);
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
double clawCapPick = devicePositionService.getPosition(DevicePositionCode.clawCapPick).getDistance(); //获取拍子夹取距离
@ -108,7 +111,7 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);//TODO 临时避让下降
gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea4TrayClawPoint3D);//将携带托盘的机械臂移动至4号加热模块上方
gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUp(cmdDTO.getCommandId(), cmdDTO.getCommand(), null);//TODO 临时避 恢复抬起状态
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUp(cmdDTO.getCommandId(), cmdDTO.getCommand(), null, heatModuleCode);//TODO 临时避 恢复抬起状态
gantryModuleService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块
// trayState.setInSolutionModule(true);//托盘是否在加液模块中
deviceStateService.getDeviceState().getSolutionModule().setTrayStatus(1);//加液模块是否存在托盘

9
src/main/java/com/iflytop/gd/app/controller/TestController.java

@ -2,10 +2,10 @@ package com.iflytop.gd.app.controller;
import com.iflytop.gd.app.model.bo.status.CommandMutexState;
import com.iflytop.gd.app.model.dto.AllSensorDTO;
import com.iflytop.gd.app.service.api.HeatService;
import com.iflytop.gd.app.service.api.TestService;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.CapModuleService;
import com.iflytop.gd.app.service.device.module.SolutionModuleService;
import com.iflytop.gd.common.result.Result;
import com.iflytop.gd.hardware.exception.HardwareException;
import io.swagger.v3.oas.annotations.Operation;
@ -31,6 +31,7 @@ public class TestController {
private final TestService testService;
private final CapModuleService capModuleService;
private final DeviceStateService deviceStateService;
private final SolutionModuleService solutionModuleService;
@Operation(summary = "获取所有传感器读数")
@GetMapping("/all-sensor")
@ -60,4 +61,10 @@ public class TestController {
return Result.success(deviceStateService.getCommandMutexState().get());
}
@Operation(summary = "获取加液区锁状态")
@GetMapping("/module-lock-try-lock")
public Result<Boolean> getModuleLockTryLock() {
return Result.success(solutionModuleService.getModuleLockTryLock());
}
}

14
src/main/java/com/iflytop/gd/app/service/api/CraftsService.java

@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -178,6 +179,19 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> {
}
/**
* 停止执行所有工艺不清除上下文
*/
public synchronized void stopAllCrafts() {
contextMap.forEach((key, ctx) -> {
Future<?> future = futureMap.remove(key);
if (ctx != null && future != null) {
ctx.stop();
future.cancel(true);
}
});
}
/**
* 清理指定 heatId 的执行上下文和 Future
*/
public synchronized void clearCraftContext(HeatModuleCode heatModuleCode) {

5
src/main/java/com/iflytop/gd/app/service/api/TrayService.java

@ -1,12 +1,10 @@
package com.iflytop.gd.app.service.api;
import com.iflytop.gd.app.model.bo.status.device.HeatModuleState;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.vo.SetTrayTubeVO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.SolutionModuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import java.util.List;
@ -19,13 +17,12 @@ import java.util.List;
public class TrayService {
private final DeviceStateService deviceStateService;
private final SolutionModuleService solutionModuleService;
private final ObjectProvider<TrayState> trayStateObjectProvider;
/**
* 放入了新托盘
*/
public synchronized TrayState trayIn() {
TrayState trayState = trayStateObjectProvider.getObject();
TrayState trayState = new TrayState();
trayState.setInSolutionModule(true);
deviceStateService.getDeviceState().getTray().add(trayState);
deviceStateService.getDeviceState().getSolutionModule().setTrayStatus(1);

4
src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java

@ -45,7 +45,7 @@ public class CraftsStepService {
* 执行单个工艺步骤
*
* @param heatModuleCode 加热区 ID
* @param step 工艺步骤包括 method params
* @param step 工艺步骤包括 method params
* @return true 表示执行成功false 表示失败
*/
public boolean executeStep(HeatModuleCode heatModuleCode, CraftsStep step) throws Exception {
@ -259,7 +259,7 @@ public class CraftsStepService {
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(heatModuleCode);//TODO 临时避让下降
gantryModuleService.gantryMove(heatArea4TrayClawPoint3D);//将携带托盘的机械臂移动至4号加热模块上方
gantryModuleService.gantryMove(liquidAreaTrayPoint3D); //将携带托盘的机械臂移动至加液模块上方
deviceCommandTempUtilService.moveTrayHeatModuleAvoidDown(null);//TODO 临时避 恢复抬起状态
deviceCommandTempUtilService.moveTrayHeatModuleAvoidUp(null, heatModuleCode);//TODO 临时避 恢复抬起状态
gantryModuleService.gantryZMove(solutionModuleTrayMoveHeight);//下降z轴,使托盘落入加液模块
// trayState.setInSolutionModule(true);//托盘是否在加液模块中
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayStatus(1);//加液模块是否存在托盘

128
src/main/java/com/iflytop/gd/app/service/device/DeviceCommandTempUtilService.java

@ -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);
}
});
}
}

99
src/main/java/com/iflytop/gd/app/service/device/module/SolutionModuleService.java

@ -20,6 +20,8 @@ import org.springframework.stereotype.Service;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* 加液模块
@ -33,6 +35,7 @@ public class SolutionModuleService {
private final LiquidDistributionArmDriver liquidDistributionArmDriver;
private final WebSocketSender webSocketService;
private final Lock moduleLock = new ReentrantLock();
private final BlockingQueue<Thread> waitingQueue = new ArrayBlockingQueue<>(1);
/**
@ -45,9 +48,8 @@ public class SolutionModuleService {
/**
* 申请使用加液模块
*/
public synchronized void requestSolutionModule(String commandId, String command) {
public void requestSolutionModule(String commandId, String command) {
try {
log.info("申请使用加液模块");
// 如果加液模块繁忙加入队列等待
while (!deviceStateService.getDeviceState().getSolutionModule().isIdle()) {
if (commandId != null && command != null) {
@ -57,8 +59,7 @@ public class SolutionModuleService {
// 把当前线程放到队列中等待
waitingQueue.put(Thread.currentThread()); // 阻塞当前线程直到被唤醒
}
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);
log.info("加液模块申请成功");
occupySolutionModule();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("等待加液区空闲错误", e);
@ -66,79 +67,64 @@ public class SolutionModuleService {
}
/**
* 占用加液模块
*/
private void occupySolutionModule() {
moduleLock.lock();
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);
}
/**
* 释放加液区
*/
public synchronized void releaseSolutionModule() throws InterruptedException {
log.info("释放加液模块占用");
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);
// 唤醒队列中的第一个线程
if (!waitingQueue.isEmpty()) {
Thread waitingThread = waitingQueue.take();
synchronized (waitingThread) {
waitingThread.notify(); // 唤醒队列中的第一个等待线程
public void releaseSolutionModule() throws InterruptedException {
try {
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);
// 唤醒队列中的第一个线程
if (!waitingQueue.isEmpty()) {
Thread waitingThread = waitingQueue.take();
synchronized (waitingThread) {
waitingThread.notify(); // 唤醒队列中的第一个等待线程
}
}
} finally {
if (moduleLock.tryLock()) {
moduleLock.unlock();
}
}
}
public boolean getModuleLockTryLock(){
return moduleLock.tryLock();
}
/**
* 双轴械臂 移动至指定试管
*/
public void dualRobotMovePoint(int index) throws Exception {
if (!deviceStateService.getDeviceState().isVirtual()) {
liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, index);
} else {
new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}).start();
}
liquidDistributionArmDriver.liquidDistributionArmMoveTo(LiquidArmMId.LiquidDistributionArm, index);
}
/**
* 加液机械臂回原点
*/
public void dualRobotOrigin() throws Exception {
if (!deviceStateService.getDeviceState().isVirtual()) {
liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, 0);
} else {
new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}).start();
}
liquidDistributionArmDriver.liquidDistributionArmMoveTo(LiquidArmMId.LiquidDistributionArm, 0);
}
/**
* 加液机械臂回原点
*/
public void dualRobotOrigin(String commandId, String command, CmdAxis cmdAxis) throws Exception {
if (!deviceStateService.getDeviceState().isVirtual()) {
if (cmdAxis == CmdAxis.joint1) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
} else {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
if (cmdAxis == CmdAxis.joint1) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
} else {
new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}).start();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
}
@ -217,14 +203,14 @@ public class SolutionModuleService {
/**
* 添加溶液
*/
public CommandFuture acidPumpMoveBy(AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
return acidPumpMoveBy(null, null, acidPumpDevice, position);
public void acidPumpMoveBy(AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
acidPumpMoveBy(null, null, acidPumpDevice, position);
}
/**
* 添加溶液
*/
public CommandFuture acidPumpMoveBy(String commandId, String command, AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
public void acidPumpMoveBy(String commandId, String command, AcidPumpDeviceCode acidPumpDevice, double position) throws Exception {
DeviceCommandBundle deviceCommand;
switch (acidPumpDevice) {
case acid_pump_01 -> {
@ -253,7 +239,8 @@ public class SolutionModuleService {
}
default -> throw new RuntimeException("index 未找到");
}
return deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandId, command, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
/**

3
src/main/java/com/iflytop/gd/app/ws/client/DeviceEmergencyStopConfig.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.ws.client;
import com.iflytop.gd.app.core.CommandPoolManager;
import com.iflytop.gd.app.service.api.CraftsService;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.DeviceStepCommandService;
import lombok.RequiredArgsConstructor;
@ -18,6 +19,7 @@ public class DeviceEmergencyStopConfig {
private final DeviceStepCommandService stepCommandService;
private final DeviceStateService deviceStateService;
private final CommandPoolManager commandPoolManager;
private final CraftsService craftsService;
@Value("${iflytophald.ip}")
String ip;
@ -33,6 +35,7 @@ public class DeviceEmergencyStopConfig {
log.info("触发急停{}", s);
try {
commandPoolManager.forceShutdownAll();//强制终止现在运行的所有指令
craftsService.stopAllCrafts();//停止所有工艺
stepCommandService.stopAll();
deviceStateService.getDeviceState().setEmergencyStop(true);
} catch (Exception e) {

1
src/main/java/com/iflytop/gd/common/result/ResultCode.java

@ -58,6 +58,7 @@ public enum ResultCode implements IResultCode, Serializable {
CMD_BUSY("6025", "设备忙,请稍后"),
HEAT_MODULE_NO_IDLE("6026", "加热模块无空闲"),
CAP_MODULE_NO_CAP("6027", "拍子存放区未检测到拍子"),
SOLUTION_MODULE_OCCUPIED("6028", "加液模块被占用"),
;
/** 状态码 */
private final String code;

Loading…
Cancel
Save