Browse Source

现场代码同步

master
白凤吉 3 months ago
parent
commit
ce8cd1c238
  1. 33
      src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java
  2. 35
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java

33
src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java

@ -0,0 +1,33 @@
package com.iflytop.gd.app.cmd;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.app.service.DeviceStateService;
import com.iflytop.gd.common.annotation.CommandMapping;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 摇匀回原点
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("shake_origin")//业务指令注解
public class ShakeOriginCommand extends BaseCommandHandler {
private final DeviceCommandUtilService deviceCommandUtilService;
private final DeviceStateService deviceStateService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
deviceCommandUtilService.shakeOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());//摇匀回原点
deviceStateService.setSolutionModuleStateShaking(true);
});
}
}

35
src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java

@ -0,0 +1,35 @@
package com.iflytop.gd.app.cmd.debug;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 处理摇匀回原点
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("debug_shaker_reset")
public class DebugShakerResetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
});
}
}
Loading…
Cancel
Save