Browse Source

add:增加对泵转速的限制

master
王梦远 2 months ago
parent
commit
3cacce3926
  1. 7
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  2. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
  3. 6
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java
  4. 5
      src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java

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

@ -1,7 +1,9 @@
package com.iflytop.sgs.app.cmd.debug;
import cn.hutool.core.lang.Assert;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.model.entity.SystemConfig;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
@ -10,6 +12,8 @@ import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
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.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -35,8 +39,11 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);

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

@ -1,5 +1,6 @@
package com.iflytop.sgs.app.cmd.debug;
import cn.hutool.core.lang.Assert;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.SystemConfigService;
@ -10,6 +11,8 @@ import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
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.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -36,6 +39,8 @@ public class DebugLiquidPumpReduceCommand extends BaseCommandHandler {
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand);
CommandUtil.wait(deviceCommandFuture);

6
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java

@ -3,11 +3,14 @@ package com.iflytop.sgs.app.cmd.debug;
import cn.hutool.core.lang.Assert;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.model.entity.SystemConfig;
import com.iflytop.sgs.app.service.api.SystemConfigService;
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.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.cmd.CmdDirection;
import com.iflytop.sgs.common.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
@ -27,6 +30,7 @@ import java.util.concurrent.CompletableFuture;
@CommandDebugMapping("liquid_pump_start")
public class DebugLiquidPumpStartCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final SystemConfigService systemConfigService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
@ -36,6 +40,8 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler {
CmdDirection cmdDirection = CmdDirection.valueOf(direction);
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand);
CommandUtil.wait(deviceCommandFuture);

5
src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java

@ -4,7 +4,6 @@ import lombok.Getter;
/**
* 系统配置累
*
*/
@Getter
public enum SystemConfigCode {
@ -17,7 +16,9 @@ public enum SystemConfigCode {
volume_clean("清洁时加水的量"),
number_reduce("抽液时机蠕动泵的转数"),
cycle_clean_max
("清洁最大次数");
("清洁最大次数"),
liquid_max_speed
("蠕动泵最大转速");
private String description;

Loading…
Cancel
Save