|
|
@ -49,6 +49,30 @@ public class CMDController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Operation(summary = "电机移动到原点") |
|
|
|
@PostMapping("/motorMoveToHome") |
|
|
|
public Result<String> motorMoveToHome(@RequestBody CMDForm cmdForm) { |
|
|
|
try { |
|
|
|
|
|
|
|
if (cmdForm.getCommandId() == null || cmdForm.getCommandId().isEmpty()) { |
|
|
|
String commandId = UUID.randomUUID().toString(); |
|
|
|
cmdForm.setCommandId(commandId); |
|
|
|
} |
|
|
|
if (cmdForm.getCommandName() == null || cmdForm.getCommandName().isEmpty()) { |
|
|
|
cmdForm.setCommandName("motorMoveToHome"); |
|
|
|
} |
|
|
|
log.info("接收到指令: {}", JSONUtil.toJsonStr(cmdForm)); |
|
|
|
if (cmdService.motorMoveToHome(cmdForm)) { |
|
|
|
return Result.success(cmdForm.getCommandId()); |
|
|
|
} else { |
|
|
|
return Result.failed("参数错误"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("指令执行异常: {}", JSONUtil.toJsonStr(cmdForm), e); |
|
|
|
return Result.failed("执行失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Operation(summary = "三通阀切换") |
|
|
|
@PostMapping("/switchThreeWayValve") |
|
|
|
public Result<String> switchThreeWayValve(@RequestBody CMDForm cmdForm) { |
|
|
@ -280,6 +304,29 @@ public class CMDController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Operation(summary = "设定指定轴的速度") |
|
|
|
@PostMapping("/setMotorSpeed") |
|
|
|
public Result<String> setMotorSpeed(@RequestBody CMDForm cmdForm) { |
|
|
|
try { |
|
|
|
if (cmdForm.getCommandId() == null || cmdForm.getCommandId().isEmpty()) { |
|
|
|
String commandId = UUID.randomUUID().toString(); |
|
|
|
cmdForm.setCommandId(commandId); |
|
|
|
} |
|
|
|
if (cmdForm.getCommandName() == null || cmdForm.getCommandName().isEmpty()) { |
|
|
|
cmdForm.setCommandName("setMotorSpeed"); |
|
|
|
} |
|
|
|
log.info("接收到指令: {}", JSONUtil.toJsonStr(cmdForm)); |
|
|
|
if (cmdService.setMotorSpeed(cmdForm)) { |
|
|
|
return Result.success(cmdForm.getCommandId()); |
|
|
|
} else { |
|
|
|
return Result.failed("参数错误"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("指令执行异常: {}", JSONUtil.toJsonStr(cmdForm), e); |
|
|
|
return Result.failed("执行失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Operation(summary = "测试: 停止指定轴运动") |
|
|
|
@PostMapping("/stopMotor") |
|
|
|
public Result<String> stopMotor(@RequestBody CMDForm cmdForm) { |
|
|
|