Browse Source

拆分DeviceCommandUtilService

master
白凤吉 2 months ago
parent
commit
f8f95016e2
  1. 6
      src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java
  2. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java
  3. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java
  4. 8
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java
  5. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java
  6. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java
  7. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java
  8. 8
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java
  9. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java
  10. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java
  11. 4
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java
  12. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java
  13. 2
      src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java
  14. 12
      src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java
  15. 6
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java
  16. 2
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java
  17. 4
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/TransferModuleState.java
  18. 32
      src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java
  19. 43
      src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java
  20. 8
      src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java
  21. 62
      src/main/java/com/iflytop/sgs/app/service/device/GantryArmService.java
  22. 5
      src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java
  23. 116
      src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java
  24. 2
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

6
src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java

@ -4,8 +4,8 @@ import cn.hutool.json.JSONArray;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandUtilService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
@ -22,7 +22,7 @@ import java.util.concurrent.CompletableFuture;
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
public class HeatStartCommand extends BaseCommandHandler {
private final DeviceCommandUtilService deviceCommandUtilService;
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@Override
@ -39,7 +39,7 @@ public class HeatStartCommand extends BaseCommandHandler {
//从系统状态中获取指定加热区设定的烘干温度数值
double temperature = deviceStateService.getHeatModuleState(heatModuleId).getHeatTemperature();
//开启加热
deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature);
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature);
//设置加热区状态 正在加热
deviceStateService.setHeatModuleStateHeating(heatModuleId, true);

2
src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java

@ -26,7 +26,7 @@ public class TransferXOriginCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
transferModuleService.transferXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());
selfTestService.getSelfTestState().setGantryXOrigin(true);//设置是否在原点状态
selfTestService.getSelfTestState().setTransferXOrigin(true);//设置是否在原点状态
});
}
}

2
src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java

@ -26,7 +26,7 @@ public class TransferZOriginCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
transferModuleService.transferZMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());
selfTestService.getSelfTestState().setGantryZOrigin(true);//设置是否在原点状态
selfTestService.getSelfTestState().setTransferZOrigin(true);//设置是否在原点状态
});
}
}

8
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java

@ -37,7 +37,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
Integer times = cmdDTO.getIntegerParam("times");
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(speed);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
@ -47,13 +47,13 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
return;
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
@ -61,7 +61,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
}
} else {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java

@ -28,7 +28,7 @@ public class DebugMotorXMoveToCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
double position = cmdDTO.getDoubleParam("position");
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMove(position);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java

@ -27,7 +27,7 @@ public class DebugMotorXOriginCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java

@ -27,7 +27,7 @@ public class DebugMotorXStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXStop();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

8
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java

@ -36,7 +36,7 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler {
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
@ -46,19 +46,19 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler {
return;
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java

@ -29,7 +29,7 @@ public class DebugMotorZMoveToCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
double position = cmdDTO.getDoubleParam("position");
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMove(position);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java

@ -27,7 +27,7 @@ public class DebugMotorZOriginCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

4
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("gantry_z_set")
@CommandMapping("z_set")
public class DebugMotorZSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@ -28,7 +28,7 @@ public class DebugMotorZSetCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java

@ -27,7 +27,7 @@ public class DebugMotorZStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZStop();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});

2
src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java

@ -1,7 +1,6 @@
package com.iflytop.sgs.app.controller;
import com.iflytop.sgs.app.model.bo.status.SelfTestState;
import com.iflytop.sgs.app.service.device.DeviceCommandUtilService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.SelfTestService;
import com.iflytop.sgs.common.result.Result;
@ -22,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController;
public class SelfTestController {
private final SelfTestService selfTestService;
private final DeviceStateService deviceStateService;
private final DeviceCommandUtilService deviceCommandUtilService;
@Operation(summary = "获取自检状态")
@GetMapping("/status")

12
src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java

@ -12,14 +12,14 @@ public class SelfTestState {
@Schema(description = "摇匀是否在原点")
private boolean shakeOrigin = false;
@Schema(description = "龙门架机械臂x轴是否在原点")
private boolean gantryXOrigin = false;
@Schema(description = "转运机械臂x轴是否在原点")
private boolean transferXOrigin = false;
@Schema(description = "龙门架机械臂y轴是否在原点")
private boolean gantryYOrigin = false;
@Schema(description = "转运机械臂y轴是否在原点")
private boolean transferYOrigin = false;
@Schema(description = "龙门架机械臂z轴是否在原点")
private boolean gantryZOrigin = false;
@Schema(description = "转运机械臂z轴是否在原点")
private boolean transferZOrigin = false;
@Schema(description = "加液机械臂是否在原点")
private boolean dualRobotOrigin = false;

6
src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java

@ -12,9 +12,9 @@ import java.util.List;
@Data
public class DeviceState {
@Schema(description = "门状态")
private final DoorState door = new DoorState();
@Schema(description = "龙门架机械臂状态")
private final GantryArmState gantryArm = new GantryArmState();
private final DoorModuleState doorModule = new DoorModuleState();
@Schema(description = "转运机械臂状态")
private final TransferModuleState transferModule = new TransferModuleState();
@Schema(description = "加液模块属性")
private final SolutionModuleState solutionModule = new SolutionModuleState();
@Schema(description = "加热模块属性")

2
src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorState.java → src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java

@ -5,7 +5,7 @@ import lombok.Data;
@Schema(description = "门")
@Data
public class DoorState {
public class DoorModuleState {
@Schema(description = "是否开门,true为开启状态,false为关闭状态")
private boolean open = false;
}

4
src/main/java/com/iflytop/sgs/app/model/bo/status/device/GantryArmState.java → src/main/java/com/iflytop/sgs/app/model/bo/status/device/TransferModuleState.java

@ -3,9 +3,9 @@ package com.iflytop.sgs.app.model.bo.status.device;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "龙门架机械臂")
@Schema(description = "转运机模块")
@Data
public class GantryArmState {
public class TransferModuleState {
@Schema(description = "是否空闲,true为空闲,false为占用")
private boolean idle = true;
}

32
src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java

@ -1,12 +1,9 @@
package com.iflytop.sgs.app.service.crafts;
import cn.hutool.json.JSONObject;
import com.iflytop.sgs.app.core.CraftsDebugGenerator;
import com.iflytop.sgs.app.model.bo.CraftsStep;
import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.device.DeviceCommandUtilService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.GantryArmService;
import com.iflytop.sgs.app.ws.server.WebSocketSender;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -17,10 +14,8 @@ import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class CraftsStepService {
private final DeviceCommandUtilService deviceCommandUtilService;
private final DevicePositionService devicePositionService;
private final WebSocketSender webSocketService;
private final GantryArmService gantryArmService;
private final DeviceStateService deviceStateService;
@ -35,37 +30,10 @@ public class CraftsStepService {
String method = step.getMethod();
JSONObject params = step.getParams();
return switch (method) {
case "addLiquid" -> addLiquid(heatId, params);
case "shaking" -> shaking(heatId, params);
case "startHeating" -> heating(heatId, params);
default -> true;
};
}
/**
* 将托盘从加热区移动至加液区并且添加溶液
*/
private boolean addLiquid(String heatId, JSONObject params) throws Exception {
return true;
}
/**
* 摇匀操作
*/
private boolean shaking(String heatId, JSONObject params) throws Exception {
Integer second = params.getInt("second");
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开始摇匀", params));
delay(second);
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "停止摇匀", null));
return true;
}
/**
* 将托盘从加液区移动至加热区并开启加热
*/
private boolean heating(String heatId, JSONObject params) throws Exception {
return true;
}
/**
* 延时等待

43
src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java

@ -27,50 +27,9 @@ public class DeviceCommandService {
private final WebSocketSender webSocketService;
private final DeviceStateService deviceStateService;
/**
* 需要等待加液区空闲的龙门架机械臂指令
* 需要等待加液区空闲的转运机械臂指令
*/
private final ConcurrentMap<Integer, CommandFuture> sendCommandFutureMap = new ConcurrentHashMap<>();
private final BlockingQueue<CommandFuture[]> gantryCommandQueue = new LinkedBlockingQueue<>();
@PostConstruct
private void initExecutorThread() {
new Thread(this::executeCommands).start();
}
private void executeCommands() {
while (true) {
try {
deviceStateService.setGantryArmStateIdle(true);
CommandFuture[] commandFutureArray = gantryCommandQueue.take();
for (CommandFuture commandFuture : commandFutureArray) {
executeCommand(commandFuture);
}
} catch (Exception e) {
Thread.currentThread().interrupt();
} finally {
deviceStateService.setGantryArmStateIdle(false);
}
}
}
public synchronized CommandFuture[] sendCommandGantryQueue(DeviceCommandBundle... deviceCommandBundles) {
return sendCommandGantryQueue(null, null, deviceCommandBundles);
}
public synchronized CommandFuture[] sendCommandGantryQueue(String cmdId, String cmdCode, DeviceCommandBundle... deviceCommandBundles) {
List<CommandFuture> commandFutureList = new ArrayList<>();
for (DeviceCommandBundle deviceCommandBundle : deviceCommandBundles) {
commandFutureList.add(createDeviceCommandFuture(cmdId, cmdCode, deviceCommandBundle));
}
CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]);
try {
gantryCommandQueue.put(commandFutureArray);
} catch (Exception e) {
log.error("设备指令入队列失败", e);
throw new RuntimeException(e);
}
return commandFutureArray;
}
/**
* 根据 DeviceCommand 创建 CommandFuture

8
src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java

@ -95,14 +95,14 @@ public class DeviceStateService {
}
public synchronized void setDoorStatus(boolean status) {
boolean oldValue = deviceState.getDoor().isOpen();
deviceState.getDoor().setOpen(status);
boolean oldValue = deviceState.getDoorModule().isOpen();
deviceState.getDoorModule().setOpen(status);
support.firePropertyChange("setDoorStatus", oldValue, status);
}
public synchronized void setGantryArmStateIdle(boolean idle) {
boolean oldValue = deviceState.getGantryArm().isIdle();
deviceState.getGantryArm().setIdle(idle);
boolean oldValue = deviceState.getTransferModule().isIdle();
deviceState.getTransferModule().setIdle(idle);
support.firePropertyChange("setGantryArmStateIdle", oldValue, idle);
}

62
src/main/java/com/iflytop/sgs/app/service/device/GantryArmService.java

@ -1,62 +0,0 @@
package com.iflytop.sgs.app.service.device;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Slf4j
@Service
@RequiredArgsConstructor
public class GantryArmService {
private final Lock liquidLock = new ReentrantLock();
private final Condition liquidIdleCondition = liquidLock.newCondition();
private final DeviceStateService deviceStateService;
/**
* 等待加液区空闲
*/
public void waitLiquidIdle() {
liquidLock.lock();
try {
while (!deviceStateService.getDeviceState().getSolutionModule().isIdle()) {
liquidIdleCondition.await();
}
} catch (InterruptedException e) {
throw new RuntimeException("等待加液区空闲错误", e);
} finally {
liquidLock.unlock();
}
}
/**
* 锁定加液区
*/
public void setLiquidIdleFalse() {
liquidLock.lock();
try {
deviceStateService.setSolutionModuleStateIdle(false);
liquidIdleCondition.signalAll(); // 唤醒所有等待的线程
} finally {
liquidLock.unlock();
}
}
/**
* 释放加液区
*/
public void setLiquidIdleTrue() {
liquidLock.lock();
try {
deviceStateService.setSolutionModuleStateIdle(true);
liquidIdleCondition.signalAll(); // 唤醒所有等待的线程
} finally {
liquidLock.unlock();
}
}
}

5
src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java

@ -1,6 +1,7 @@
package com.iflytop.sgs.app.service.device;
import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -10,9 +11,9 @@ import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class StepCommandService {
private final DeviceCommandUtilService deviceCommandUtilService;
private final TransferModuleService transferModuleService;
public void gantryToPoint3D(Point3D point3D) throws Exception {
deviceCommandUtilService.gantryMove(point3D);
transferModuleService.transferMove(point3D);
}
}

116
src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java

@ -19,7 +19,6 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class TransferModuleService {
private final DeviceCommandService deviceCommandService;
private final DevicePositionService devicePositionService;
/**
@ -47,23 +46,6 @@ public class TransferModuleService {
CommandUtil.wait(transferXMoveDeviceCommandFuture, transferZMoveDeviceCommandFuture);
}
/**
* 转运机械臂移动到指定点
*/
public void transferMoveQueue(Point3D point) throws Exception {
transferMoveQueue(null, null, point);
}
/**
* 转运机械臂移动到指定点
*/
public void transferMoveQueue(String cmdId, String cmdCode, Point3D point) throws Exception {
DeviceCommandBundle transferXMoveDeviceCommand = DeviceCommandGenerator.transferXMove(point.getX());
DeviceCommandBundle transferZMoveDeviceCommand = DeviceCommandGenerator.transferZMove(point.getZ());
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, transferXMoveDeviceCommand, transferZMoveDeviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂X轴回原点
@ -82,23 +64,6 @@ public class TransferModuleService {
}
/**
* 转运机械臂X轴回原点
*/
public void transferXMoveOriginQueue() throws Exception {
transferXMoveOriginQueue(null, null);
}
/**
* 转运机械臂X轴回原点
*/
public void transferXMoveOriginQueue(String cmdId, String cmdCode) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin();
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂Z轴回原点
*/
public void transferZMoveOrigin() throws Exception {
@ -114,23 +79,6 @@ public class TransferModuleService {
CommandUtil.wait(deviceCommandFuture);
}
/**
* 转运机械臂Z轴回原点
*/
public void transferZMoveOriginQueue() throws Exception {
transferZMoveOriginQueue(null, null);
}
/**
* 转运机械臂Z轴回原点
*/
public void transferZMoveOriginQueue(String cmdId, String cmdCode) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin();
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂X轴移动到指定点
*/
@ -148,22 +96,6 @@ public class TransferModuleService {
}
/**
* 转运机械臂X轴移动到指定点
*/
public void transferXMoveQueue(double position) throws Exception {
transferXMoveQueue(null, null, position);
}
/**
* 转运机械臂X轴移动到指定点
*/
public void transferXMoveQueue(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMove(position);
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂Z轴移动到指定点
*/
public void transferZMove(double position) throws Exception {
@ -181,22 +113,6 @@ public class TransferModuleService {
}
/**
* 转运机械臂Z轴移动到指定点
*/
public void transferZMoveQueue(double position) throws Exception {
transferZMoveQueue(null, null, position);
}
/**
* 转运机械臂Z轴移动到指定点
*/
public void transferZMoveQueue(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMove(position);
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂X轴相对移动到指定点
*/
public void transferXMoveBy(double position) throws Exception {
@ -213,22 +129,6 @@ public class TransferModuleService {
}
/**
* 转运机械臂X轴相对移动到指定点
*/
public void transferXMoveByQueue(double position) throws Exception {
transferXMoveByQueue(null, null, position);
}
/**
* 转运机械臂X轴相对移动到指定点
*/
public void transferXMoveByQueue(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(position);
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
/**
* 转运机械臂Z轴相对移动到指定点
*/
public void transferZMoveBy(double position) throws Exception {
@ -243,20 +143,4 @@ public class TransferModuleService {
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
/**
* 转运机械臂Z轴相对移动到指定点
*/
public void transferZMoveByQueue(double position) throws Exception {
transferZMoveByQueue(null, null, position);
}
/**
* 转运机械臂Z轴相对移动到指定点
*/
public void transferZMoveByQueue(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(position);
CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFutureArr);
}
}

2
src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

@ -94,7 +94,7 @@ public class DeviceCommandGenerator {
/**
* 龙门架 x轴回原点
* 转运 x轴回原点
*/
public static DeviceCommandBundle transferXOrigin() {
return controlMotorCmd(CmdDevice.x_motor, CmdAction.origin, null, "x轴回原点");

Loading…
Cancel
Save