Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandParams.java
#	src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusServiceImpl.java
master
HSZ_HeSongZhen 2 months ago
parent
commit
40d1ebfc5e
  1. 7
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
  2. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
  3. 9
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
  4. 6
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java
  5. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeCloseCommand.java
  6. 38
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java
  7. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java
  8. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  9. 7
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
  10. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThickCommand.java
  11. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThinCommand.java
  12. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWasteCommand.java
  13. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWaterCommand.java
  14. 1
      src/main/java/com/iflytop/sgs/app/controller/DevicePointController.java
  15. 36
      src/main/java/com/iflytop/sgs/app/controller/MotorController.java
  16. 2
      src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java
  17. 70
      src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java
  18. 32
      src/main/java/com/iflytop/sgs/app/service/device/DeviceStopService.java
  19. 4
      src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java
  20. 4
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java
  21. 4
      src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java
  22. 2
      src/main/java/com/iflytop/sgs/common/service/GDDeviceStatusService.java
  23. 0
      src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusServiceImpl.java

7
src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java

@ -8,10 +8,12 @@ import com.iflytop.sgs.app.model.bo.status.device.TubeState;
import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceSensorService;
import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService;
import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.ValveStateCode; import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode;
@ -37,11 +39,10 @@ public class CleanStartCommand extends BaseCommandHandler {
private final TransferModuleService transferModuleService; private final TransferModuleService transferModuleService;
private final DeviceStateService deviceStateService; private final DeviceStateService deviceStateService;
private final SystemConfigService systemConfigService; private final SystemConfigService systemConfigService;
private final DeviceSensorService deviceSensorService;
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//TODO 需要先更新一下传感器状态
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//判断转运模块托盘状态 Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//判断转运模块托盘状态
double cleanWaterVolume = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量 double cleanWaterVolume = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量
double waterScale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数 double waterScale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数
@ -56,6 +57,8 @@ public class CleanStartCommand extends BaseCommandHandler {
TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘
return runAsync(() -> { return runAsync(() -> {
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
boolean LIQUID_TRAY_EXIST=deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//监测加液位是否有托盘
Assert.isTrue(LIQUID_TRAY_EXIST, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//机械臂是否有托盘
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition); solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition);

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

@ -41,7 +41,7 @@ public class LiquidAddCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//todo 更新阀的状态
//todo 获取阀门的状态
return runAsync(() -> { return runAsync(() -> {

9
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java

@ -8,10 +8,12 @@ import com.iflytop.sgs.app.model.bo.status.device.TubeState;
import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceSensorService;
import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService;
import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.ValveStateCode; import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode;
@ -37,11 +39,10 @@ public class LiquidReduceCommand extends BaseCommandHandler {
private final DevicePositionService devicePositionService; private final DevicePositionService devicePositionService;
private final TransferModuleService transferModuleService; private final TransferModuleService transferModuleService;
private final SystemConfigService systemConfigService; private final SystemConfigService systemConfigService;
private final DeviceSensorService deviceSensorService;
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//todo 需要更新一下传感器的状态
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//机械臂是否有托盘
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点 Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置
@ -49,10 +50,12 @@ public class LiquidReduceCommand extends BaseCommandHandler {
TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘
double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce)); double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));
return runAsync(() -> { return runAsync(() -> {
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
boolean LIQUID_TRAY_EXIST=deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//监测加液位是否有托盘
Assert.isTrue(LIQUID_TRAY_EXIST, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//机械臂是否有托盘
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开
for (TubeState tubeState : trayState.getTubes()) { for (TubeState tubeState : trayState.getTubes()) {
if (tubeState.isAddSolution() && tubeState.isExists()) { if (tubeState.isAddSolution() && tubeState.isExists()) {

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

@ -5,10 +5,12 @@ import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.device.DeviceSensorService;
import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.HeatModuleService;
import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode;
import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.exception.AppException;
@ -32,6 +34,7 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler {
private final DevicePositionService devicePositionService; private final DevicePositionService devicePositionService;
private final DeviceStateService deviceStateService; private final DeviceStateService deviceStateService;
private final DeviceSensorService deviceSensorService;
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception { public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
@ -42,9 +45,6 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler {
} else { } else {
targetHeatModuleCode = null; targetHeatModuleCode = null;
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(),()->new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//转运模块是否有托盘 Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(),()->new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//转运模块是否有托盘
} }
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeCloseCommand.java

@ -0,0 +1,36 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 蜂鸣器关闭
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("door_close")
public class DebugBeeCloseCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle beepCloseDeviceCommandBundle = DeviceCommandGenerator.beepClose();
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beepCloseDeviceCommandBundle);
CommandUtil.wait(doorSetDeviceCommandSetFuture);
});
}
}

38
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java

@ -0,0 +1,38 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 蜂鸣器打开
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("door_close")
public class DebugBeeOpenCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String mode = cmdDTO.getStringParam("mode");
return runAsync(() -> {
DeviceCommandBundle beeOpenDeviceCommand = DeviceCommandGenerator.beepOpen(mode);
CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beeOpenDeviceCommand);
CommandUtil.wait(doorMoveDeviceCommandFuture);
});
}
}

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

@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
* 处理停止加热器指令 todo 小何确定次序
* 处理停止加热器指令
*/ */
@Slf4j @Slf4j
@Component @Component

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java

@ -31,14 +31,11 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume"); Double volume = cmdDTO.getDoubleParam("volume");
//todo 监测阀门开启状态 将加液量转换成电机转数
Double scale = Double.valueOf(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_thin));
Double scale = Double.valueOf(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));
Double position = volume * scale; Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed"); Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> { return runAsync(() -> {
CmdDirection cmdDirection = CmdDirection.forward;
DeviceCommandBundle deviceCommand; DeviceCommandBundle deviceCommand;
if (speed != null) { if (speed != null) {
deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(position); deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(position);

7
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java

@ -2,11 +2,13 @@ package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping; import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.cmd.CmdDirection; import com.iflytop.sgs.common.enums.cmd.CmdDirection;
import com.iflytop.sgs.common.utils.CommandUtil; import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -24,12 +26,13 @@ import java.util.concurrent.CompletableFuture;
@CommandDebugMapping("liquid_pump_reduce") @CommandDebugMapping("liquid_pump_reduce")
public class DebugLiquidPumpReduceCommand extends BaseCommandHandler { public class DebugLiquidPumpReduceCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService; private final DeviceCommandService deviceCommandService;
private final SystemConfigService systemConfigService;
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume"); Double volume = cmdDTO.getDoubleParam("volume");
//todo 量转换成转数
Double position = Double.valueOf(1000);
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));
double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed"); Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> { return runAsync(() -> {

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThickCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.utils.CommandUtil; import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
* 阀转换到浓硝酸通道 todo 需要与小何确定次序
* 阀转换到浓硝酸通道
*/ */
@Slf4j @Slf4j
@Component @Component
@ -27,7 +28,7 @@ public class DebugLiquidValveOpenThickCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(1);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(ValveStateCode.thin.getChannel());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture); CommandUtil.wait(deviceCommandFuture);
}); });

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThinCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.utils.CommandUtil; import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -27,7 +28,7 @@ public class DebugLiquidValveOpenThinCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(2);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(ValveStateCode.thick.getChannel());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture); CommandUtil.wait(deviceCommandFuture);
}); });

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWasteCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.utils.CommandUtil; import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
* 阀转换到废液通道 todo 需要与小何确定次序
* 阀转换到废液通道
*/ */
@Slf4j @Slf4j
@Component @Component
@ -27,7 +28,7 @@ public class DebugLiquidValveOpenWasteCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(4);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(ValveStateCode.waste.getChannel());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture); CommandUtil.wait(deviceCommandFuture);
}); });

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWaterCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.ValveStateCode;
import com.iflytop.sgs.common.utils.CommandUtil; import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
* 阀转换到蒸馏水通道 todo 需要与小何确定次序
* 阀转换到蒸馏水通道
*/ */
@Slf4j @Slf4j
@Component @Component
@ -27,7 +28,7 @@ public class DebugLiquidValveOpenWaterCommand extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(3);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(ValveStateCode.water.getChannel());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture); CommandUtil.wait(deviceCommandFuture);
}); });

1
src/main/java/com/iflytop/sgs/app/controller/DevicePointController.java

@ -4,6 +4,7 @@ import com.iflytop.sgs.app.model.dto.AddDevicePositionDTO;
import com.iflytop.sgs.app.model.entity.DevicePosition; import com.iflytop.sgs.app.model.entity.DevicePosition;
import com.iflytop.sgs.app.model.vo.DevicePositionVO; import com.iflytop.sgs.app.model.vo.DevicePositionVO;
import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.common.enums.DevicePartId;
import com.iflytop.sgs.common.result.Result; import com.iflytop.sgs.common.result.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;

36
src/main/java/com/iflytop/sgs/app/controller/MotorController.java

@ -0,0 +1,36 @@
package com.iflytop.sgs.app.controller;
import com.iflytop.sgs.app.service.device.DeviceSensorService;
import com.iflytop.sgs.common.enums.DevicePartId;
import com.iflytop.sgs.common.result.Result;
import com.iflytop.sgs.hardware.exception.HardwareException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
* 认证控制
*/
@Tag(name = "设备")
@RestController
@RequestMapping("/api/motor")
@RequiredArgsConstructor
@Slf4j
public class MotorController {
private DeviceSensorService deviceSensorService;
@Operation(summary = "获取当前电机位置")
@GetMapping("/position/{motor}")
public Result<Double> getPosition(@PathVariable String motor) {
DevicePartId devicePartId = DevicePartId.valueOf(motor);
try {
Double position = deviceSensorService.getSensorStatus(devicePartId);
return Result.success(position);
} catch (HardwareException e) {
throw new RuntimeException(e);
}
}
}

2
src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java

@ -6,6 +6,7 @@ import com.iflytop.sgs.common.enums.HeatModuleCode;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -43,4 +44,5 @@ public class DeviceInitService {
heatArea.add(new HeatModuleState(code)); heatArea.add(new HeatModuleState(code));
} }
} }
} }

70
src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java

@ -0,0 +1,70 @@
package com.iflytop.sgs.app.service.device;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.bo.status.device.SolutionContainerState;
import com.iflytop.sgs.app.model.bo.status.device.SolutionModuleState;
import com.iflytop.sgs.common.enums.ContainerCode;
import com.iflytop.sgs.common.enums.DevicePartId;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.service.GDDeviceStatusService;
import com.iflytop.sgs.hardware.exception.HardwareException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class DeviceSensorService {
private final GDDeviceStatusService deviceStatusService;
private final DeviceStateService deviceStateService;
/*
* 获取传感器状态
* */
public boolean getSensorStatus(DeviceSensorCode sensorCode) throws HardwareException {
return deviceStatusService.getInputState(sensorCode.name());
}
/*
* 获取电机位置
* */
public Double getSensorStatus(DevicePartId devicePartId) throws HardwareException {
return deviceStatusService.getStepMotorPostion(devicePartId.name());
}
@Scheduled(fixedRate = 1000)
public void deviceSensorSchedule() throws HardwareException {
HeatModuleState heat_module_01 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_01);
heat_module_01.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_1_EXIST));
HeatModuleState heat_module_02 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_02);
heat_module_02.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_2_EXIST));
HeatModuleState heat_module_03 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_03);
heat_module_03.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_3_EXIST));
HeatModuleState heat_module_04 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04);
heat_module_04.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST));
SolutionModuleState solutionModuleState = deviceStateService.getDeviceState().getSolutionModule();
//todo 需要确认传感器个数以及这个传感器是否是加液传感器
solutionModuleState.setFeedAreaTrayStatus(this.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST));
SolutionContainerState container_01 = solutionModuleState.getContainerStateByCode(ContainerCode.container_01);
container_01.setEmpty(this.getSensorStatus(DeviceSensorCode.THIN_LOW_LEVEL));
SolutionContainerState container_02 = solutionModuleState.getContainerStateByCode(ContainerCode.container_02);
container_02.setEmpty(this.getSensorStatus(DeviceSensorCode.THICK_LOW_LEVEL));
SolutionContainerState container_03 = solutionModuleState.getContainerStateByCode(ContainerCode.container_03);
container_03.setEmpty(this.getSensorStatus(DeviceSensorCode.WATER_LOW_LEVEL));
SolutionContainerState container_04 = solutionModuleState.getContainerStateByCode(ContainerCode.container_04);
container_04.setFull(this.getSensorStatus(DeviceSensorCode.WASTE_HIGH_LEVEL));
}
}

32
src/main/java/com/iflytop/sgs/app/service/device/DeviceStopService.java

@ -0,0 +1,32 @@
package com.iflytop.sgs.app.service.device;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
public class DeviceStopService {
private final DeviceCommandService deviceCommandService;
public void stopAll() {
//门电机
DeviceCommandBundle doorStopDeviceCommandBundle = DeviceCommandGenerator.doorStop();
deviceCommandService.sendCommand(null, null, doorStopDeviceCommandBundle);
//x轴
DeviceCommandBundle xStopDeviceCommandBundle = DeviceCommandGenerator.transferXStop();
deviceCommandService.sendCommand(null, null, xStopDeviceCommandBundle);
//z轴
DeviceCommandBundle yStopDeviceCommandBundle = DeviceCommandGenerator.transferZStop();
deviceCommandService.sendCommand(null, null, yStopDeviceCommandBundle);
//机械臂
DeviceCommandBundle liquidMotorStopDeviceCommandBundle = DeviceCommandGenerator.liquidMotorStop();
deviceCommandService.sendCommand(null, null, liquidMotorStopDeviceCommandBundle);
//蠕动泵
DeviceCommandBundle liquidPumpStopDeviceCommandBundle = DeviceCommandGenerator.liquidPumpStop();
deviceCommandService.sendCommand(null, null, liquidPumpStopDeviceCommandBundle);
}
}

4
src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java

@ -2,6 +2,7 @@ package com.iflytop.sgs.app.ws.client;
import com.iflytop.sgs.app.core.CommandPoolManager; import com.iflytop.sgs.app.core.CommandPoolManager;
import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.DeviceStopService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -16,6 +17,7 @@ import java.net.URI;
public class DeviceEmergencyStopConfig { public class DeviceEmergencyStopConfig {
private final DeviceStateService deviceStateService; private final DeviceStateService deviceStateService;
private final CommandPoolManager commandPoolManager; private final CommandPoolManager commandPoolManager;
private final DeviceStopService deviceStopService;
@Value("${iflytophald.ip}") @Value("${iflytophald.ip}")
String ip; String ip;
@ -31,7 +33,7 @@ public class DeviceEmergencyStopConfig {
log.info("触发急停{}", s); log.info("触发急停{}", s);
try { try {
commandPoolManager.forceShutdownAll();//强制终止现在运行的所有指令 commandPoolManager.forceShutdownAll();//强制终止现在运行的所有指令
//stepCommandService.stopAll();
deviceStopService.stopAll();
deviceStateService.getDeviceState().setEmergencyStop(true); deviceStateService.getDeviceState().setEmergencyStop(true);
} catch (Exception e) { } catch (Exception e) {
log.error("设备急停失败:{}", e.getMessage()); log.error("设备急停失败:{}", e.getMessage());

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

@ -558,7 +558,9 @@ public class DeviceCommandGenerator {
* 蜂鸣器 * 蜂鸣器
* *
*/ */
public static DeviceCommandBundle beepOpen() {
public static DeviceCommandBundle beepOpen(String mode) {
DeviceCommandParams params = new DeviceCommandParams();
params.setMode(mode);
return controlCmd(CmdDevice.beep, CmdAction.open, null, "蜂鸣器 开启"); return controlCmd(CmdDevice.beep, CmdAction.open, null, "蜂鸣器 开启");
} }

4
src/main/java/com/iflytop/sgs/common/enums/SensorStateCode.java → src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java

@ -7,7 +7,7 @@ import lombok.Getter;
* *
*/ */
@Getter @Getter
public enum SensorStateCode {
public enum DeviceSensorCode {
E_STOP("急停"), E_STOP("急停"),
HEATER_TRAY_1_EXIST("加热位1托盘存在状态"), HEATER_TRAY_1_EXIST("加热位1托盘存在状态"),
HEATER_TRAY_2_EXIST("加热位2托盘存在状态"), HEATER_TRAY_2_EXIST("加热位2托盘存在状态"),
@ -23,7 +23,7 @@ public enum SensorStateCode {
private String description; private String description;
SensorStateCode(String description) {
DeviceSensorCode(String description) {
this.description = description; this.description = description;
} }
} }

2
src/main/java/com/iflytop/sgs/common/service/GDDeviceStatusInterface.java → src/main/java/com/iflytop/sgs/common/service/GDDeviceStatusService.java

@ -6,7 +6,7 @@ import com.iflytop.sgs.hardware.type.Servo.LeisaiServoMId;
import com.iflytop.sgs.hardware.type.StepMotor.StepMotorMId; import com.iflytop.sgs.hardware.type.StepMotor.StepMotorMId;
import com.iflytop.sgs.hardware.type.driver.HeaterRodSlavedId; import com.iflytop.sgs.hardware.type.driver.HeaterRodSlavedId;
public interface GDDeviceStatusInterface {
public interface GDDeviceStatusService {
/** /**
* 获取步进电机的原点状态 * 获取步进电机的原点状态

0
src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusService.java → src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusServiceImpl.java

Loading…
Cancel
Save