From 3cea587049a0a32ded2a753b30c54e4ab39ce1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Fri, 14 Feb 2025 14:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qyft/gd/device/controller/TestController.java | 227 ++++++++++++++++++++- 1 file changed, 225 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/qyft/gd/device/controller/TestController.java b/src/main/java/com/qyft/gd/device/controller/TestController.java index f8282f2..9961360 100644 --- a/src/main/java/com/qyft/gd/device/controller/TestController.java +++ b/src/main/java/com/qyft/gd/device/controller/TestController.java @@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "测试") @@ -21,9 +22,231 @@ public class TestController { @Operation(summary = "开门") @GetMapping("/openDoor") public Result openDoor() { - deviceService.openDoor(); - return Result.success(); + boolean success = deviceService.openDoor(); + if (success) { + return Result.success(); + } else { + return Result.failed("开门失败"); + } } + @Operation(summary = "关门") + @GetMapping("/closeDoor") + public Result closeDoor() { + boolean success = deviceService.closeDoor(); + if (success) { + return Result.success(); + } else { + return Result.failed("关门失败"); + } + } + + @Operation(summary = "张开夹爪") + @GetMapping("/openClaw") + public Result openClaw() { + boolean success = deviceService.openClaw(); + if (success) { + return Result.success(); + } else { + return Result.failed("张开夹爪失败"); + } + } + + @Operation(summary = "收合夹爪") + @GetMapping("/closeClaw") + public Result closeClaw() { + boolean success = deviceService.closeClaw(); + if (success) { + return Result.success(); + } else { + return Result.failed("收合夹爪失败"); + } + } + + @Operation(summary = "移动导轨机械臂的导轨") + @GetMapping("/moveRailArmRail") + public Result moveRailArmRail(@RequestParam double distance) { + boolean success = deviceService.moveRailArmRail(distance); + if (success) { + return Result.success(); + } else { + return Result.failed("移动导轨机械臂的导轨失败"); + } + } + + @Operation(summary = "移动导轨机械臂的关节") + @GetMapping("/moveRailArmJoint") + public Result moveRailArmJoint(@RequestParam double joint1, @RequestParam double joint2, @RequestParam double distance) { + boolean success = deviceService.moveRailArmJoint(joint1, joint2, distance); + if (success) { + return Result.success(); + } else { + return Result.failed("移动导轨机械臂的关节失败"); + } + } + + @Operation(summary = "导轨机械臂运动到指定点位") + @GetMapping("/moveRailArmToPoint") + public Result moveRailArmToPoint(@RequestParam int x, @RequestParam int y, @RequestParam int z) { + boolean success = deviceService.moveRailArmToPoint(x, y, z); + if (success) { + return Result.success(); + } else { + return Result.failed("导轨机械臂运动到指定点位失败"); + } + } + + @Operation(summary = "设置导轨机械臂的速度") + @GetMapping("/setRailArmSpeed") + public Result setRailArmSpeed(@RequestParam int speed) { + boolean success = deviceService.setRailArmSpeed(speed); + if (success) { + return Result.success(); + } else { + return Result.failed("设置导轨机械臂的速度失败"); + } + } + + @Operation(summary = "移动加液机械臂的关节") + @GetMapping("/moveLiquidArmJoint") + public Result moveLiquidArmJoint(@RequestParam double joint1, @RequestParam double joint2) { + boolean success = deviceService.moveLiquidArmJoint(joint1, joint2); + if (success) { + return Result.success(); + } else { + return Result.failed("移动加液机械臂的关节失败"); + } + } + + @Operation(summary = "加液机械臂运动到指定点位") + @GetMapping("/moveLiquidArmToPoint") + public Result moveLiquidArmToPoint(@RequestParam int x, @RequestParam int y, @RequestParam int z) { + boolean success = deviceService.moveLiquidArmToPoint(x, y, z); + if (success) { + return Result.success(); + } else { + return Result.failed("加液机械臂运动到指定点位失败"); + } + } + + @Operation(summary = "设置加液机械臂的速度") + @GetMapping("/setLiquidArmSpeed") + public Result setLiquidArmSpeed(@RequestParam int speed) { + boolean success = deviceService.setLiquidArmSpeed(speed); + if (success) { + return Result.success(); + } else { + return Result.failed("设置加液机械臂的速度失败"); + } + } + @Operation(summary = "加液") + @GetMapping("/addLiquid") + public Result addLiquid(@RequestParam int pumpId, @RequestParam int volume) { + boolean success = deviceService.addLiquid(pumpId, volume); + if (success) { + return Result.success(); + } else { + return Result.failed("加液失败"); + } + } + + @Operation(summary = "设置加液泵流量") + @GetMapping("/setFlowRate") + public Result setFlowRate(@RequestParam int pumpId, @RequestParam int flowRate) { + boolean success = deviceService.setFlowRate(pumpId, flowRate); + if (success) { + return Result.success(); + } else { + return Result.failed("设置加液泵流量失败"); + } + } + + @Operation(summary = "开始摇匀") + @GetMapping("/startShaking") + public Result startShaking() { + boolean success = deviceService.startShaking(); + if (success) { + return Result.success(); + } else { + return Result.failed("开始摇匀失败"); + } + } + + @Operation(summary = "停止摇匀") + @GetMapping("/stopShaking") + public Result stopShaking() { + boolean success = deviceService.stopShaking(); + if (success) { + return Result.success(); + } else { + return Result.failed("停止摇匀失败"); + } + } + + @Operation(summary = "设置摇匀速度") + @GetMapping("/setShakingSpeed") + public Result setShakingSpeed(@RequestParam int speed) { + boolean success = deviceService.setShakingSpeed(speed); + if (success) { + return Result.success(); + } else { + return Result.failed("设置摇匀速度失败"); + } + } + + @Operation(summary = "开始加热") + @GetMapping("/startHeating") + public Result startHeating(@RequestParam int temperature) { + boolean success = deviceService.startHeating(temperature); + if (success) { + return Result.success(); + } else { + return Result.failed("开始加热失败"); + } + } + + @Operation(summary = "停止加热") + @GetMapping("/stopHeating") + public Result stopHeating() { + boolean success = deviceService.stopHeating(); + if (success) { + return Result.success(); + } else { + return Result.failed("停止加热失败"); + } + } + + @Operation(summary = "抬起托盘到指定高度") + @GetMapping("/moveTrayToHeight") + public Result moveTrayToHeight(@RequestParam double distance) { + boolean success = deviceService.moveTrayToHeight(distance); + if (success) { + return Result.success(); + } else { + return Result.failed("抬起托盘到指定高度失败"); + } + } + + @Operation(summary = "设置托盘抬起速度") + @GetMapping("/setTraySpeed") + public Result setTraySpeed(@RequestParam int speed) { + boolean success = deviceService.setTraySpeed(speed); + if (success) { + return Result.success(); + } else { + return Result.failed("设置托盘抬起速度失败"); + } + } + + @Operation(summary = "拍照") + @GetMapping("/takePhoto") + public Result takePhoto() { + boolean success = deviceService.takePhoto(); + if (success) { + return Result.success(); + } else { + return Result.failed("拍照失败"); + } + } }