Browse Source

fix:增加使能 失能

master
王梦远 2 months ago
parent
commit
7aa18112a2
  1. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorDisableCommand.java
  2. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorEnableCommand.java
  3. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java
  4. 43
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOriginCommand.java
  5. 43
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLightOpenCommand.java
  6. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorDisableCommand.java
  7. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorEnableCommand.java
  8. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXDisableCommand.java
  9. 36
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXEnableCommand.java

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorDisableCommand.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_disable")
public class DebugDoorDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle doorSetDeviceCommandBundle = DeviceCommandGenerator.doorDisable();
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorSetDeviceCommandBundle);
CommandUtil.wait(doorSetDeviceCommandSetFuture);
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorEnableCommand.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_enable")
public class DebugDoorEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle doorSetDeviceCommandBundle = DeviceCommandGenerator.doorEnable();
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorSetDeviceCommandBundle);
CommandUtil.wait(doorSetDeviceCommandSetFuture);
});
}
}

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

@ -38,7 +38,7 @@ public class DebugDoorOpenCommand extends BaseCommandHandler {
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorSetDeviceCommandBundle);
CommandUtil.wait(doorSetDeviceCommandSetFuture);
}
DeviceCommandBundle doorMoveDeviceCommand =DeviceCommandGenerator.doorMove(devicePosition.getDistance());
DeviceCommandBundle doorMoveDeviceCommand =DeviceCommandGenerator.doorMoveBy(devicePosition.getDistance());
CommandFuture deviceCommandOpenFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorMoveDeviceCommand);
CommandUtil.wait(deviceCommandOpenFuture);
});

43
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOriginCommand.java

@ -0,0 +1,43 @@
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_origin")
public class DebugDoorOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
if (speed != null) {
DeviceCommandBundle doorSetDeviceCommandBundle = DeviceCommandGenerator.doorSet(speed);
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorSetDeviceCommandBundle);
CommandUtil.wait(doorSetDeviceCommandSetFuture);
}
DeviceCommandBundle doorMoveDeviceCommand = DeviceCommandGenerator.doorOrigin();
CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorMoveDeviceCommand);
CommandUtil.wait(doorMoveDeviceCommandFuture);
});
}
}

43
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLightOpenCommand.java

@ -0,0 +1,43 @@
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.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.cmd.CmdColor;
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;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 蜂鸣器打开
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("light_open")
public class DebugLightOpenCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String color = cmdDTO.getStringParam("color");
CmdColor colorEnum = CmdColor.valueOf(color);
return runAsync(() -> {
DeviceCommandBundle beeOpenDeviceCommand = DeviceCommandGenerator.tricolorLightOpen(colorEnum);
CommandFuture lightOpenDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beeOpenDeviceCommand);
CommandUtil.wait(lightOpenDeviceCommandFuture);
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorDisableCommand.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("liquid_motor_disable")
public class DebugLiquidMotorDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidMotorDisable();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorEnableCommand.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("liquid_motor_enable")
public class DebugLiquidMotorEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidMotorEnable();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXDisableCommand.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;
/**
* x轴电机停止
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("x_disable")
public class DebugMotorXDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXDisable();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXEnableCommand.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;
/**
* x轴电机停止
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("x_enable")
public class DebugMotorXEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXEnable();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}
Loading…
Cancel
Save