1 changed files with 70 additions and 0 deletions
@ -0,0 +1,70 @@ |
|||||
|
package com.qyft.ms.app.front.cmd.test; |
||||
|
|
||||
|
import com.qyft.ms.app.core.SelfMoveTestGenerator; |
||||
|
import com.qyft.ms.app.device.status.DeviceStatus; |
||||
|
import com.qyft.ms.system.common.annotation.CommandMapping; |
||||
|
import com.qyft.ms.system.common.device.command.CommandFuture; |
||||
|
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; |
||||
|
import com.qyft.ms.system.core.handler.BaseCommandHandler; |
||||
|
import com.qyft.ms.system.model.bo.DeviceCommand; |
||||
|
import com.qyft.ms.system.model.form.FrontCmdControlForm; |
||||
|
import com.qyft.ms.system.service.WebSocketService; |
||||
|
import com.qyft.ms.system.service.device.DeviceCommandService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.concurrent.CompletableFuture; |
||||
|
|
||||
|
/** |
||||
|
* 自检移动测试 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RequiredArgsConstructor |
||||
|
@CommandMapping("move_test")//业务指令注解 |
||||
|
public class MoveTestCommand extends BaseCommandHandler { |
||||
|
private final WebSocketService webSocketService; |
||||
|
private final DeviceCommandService deviceCommandService; |
||||
|
private final DeviceStatus deviceStatus; |
||||
|
|
||||
|
@Override |
||||
|
public CompletableFuture<Void> handle(FrontCmdControlForm form) { |
||||
|
return runAsync(() -> { |
||||
|
try { |
||||
|
//deviceSensorService.collectSensorState();//收集传感器转态 |
||||
|
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "1、各项传感器正常", 25, "success")); |
||||
|
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(200.0); //移动到200mm处 |
||||
|
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXPositionSetCommand); |
||||
|
commandWait(motorXPositionSetCommandFuture); |
||||
|
|
||||
|
DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();//x轴回原点 |
||||
|
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); |
||||
|
commandWait(motorXOriginCommandFuture); |
||||
|
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "2、x轴电机检测完毕", 50, "success")); |
||||
|
|
||||
|
|
||||
|
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(100.0);//y轴移动100mm |
||||
|
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYPositionSetCommand); |
||||
|
commandWait(motorYPositionSetCommandFuture); |
||||
|
|
||||
|
DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin();//y轴回原点 |
||||
|
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); |
||||
|
commandWait(motorYOriginCommandFuture); |
||||
|
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "3、y轴电机检测完毕", 75, "success")); |
||||
|
|
||||
|
DeviceCommand motorZPositionCommand = DeviceCommandGenerator.motorZPositionSet(50.0);//z轴50mm处 |
||||
|
CommandFuture motorZPositionCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionCommand); |
||||
|
commandWait(motorZPositionCommandFuture); |
||||
|
|
||||
|
DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin();//z轴回原点 |
||||
|
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZOriginCommand); |
||||
|
commandWait(motorZOriginCommandFuture); |
||||
|
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(form.getCmdId(), form.getCmdCode(), "4、z轴电机检测完毕", 100, "success")); |
||||
|
} finally { |
||||
|
// deviceStatus.setSelfTestCompleted(true); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue