diff --git a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java index 9058d4b..989b6fd 100644 --- a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java +++ b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java @@ -32,14 +32,14 @@ public class EdgeArmController { @ApiOperation("关闭力矩") @GetMapping("/torqueOff") public AjaxResult torqueOff(EdgeCommonVO vo) { - Common.CommandHeader.Feedback result = edgeArmService.torqueOff(vo); + edgeArmService.torqueOff(vo); return AjaxResult.ok(); } @ApiOperation("开启力矩") @GetMapping("/torqueOn") public AjaxResult torqueOn(EdgeCommonVO vo) { - Common.CommandHeader.Feedback result = edgeArmService.torqueOn(vo); + edgeArmService.torqueOn(vo); return AjaxResult.ok(); } diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeArmOperateService.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeArmOperateService.java index a03ece6..cf4ab3a 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeArmOperateService.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeArmOperateService.java @@ -12,6 +12,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Objects; + /** * 机械臂边缘操作服务 * 处理机械臂相关的设备行为,如末端运动到指定位置 @@ -51,32 +53,31 @@ public class EdgeArmOperateService implements EdgeOperateService { // 先调用开启力矩 edgeArmService.torqueOn(edgeCommonVO); - switch (action) { - case ARM_MOVE_TO_POINT: { - log.info("执行机械臂末端运动到指定点操作,设备ID: {}", deviceId); - - // 从输入参数中获取坐标信息 - Double x = inputParams.getDouble("x"); - Double y = inputParams.getDouble("y"); - Double z = inputParams.getDouble("z"); - Double rx = inputParams.getDouble("rx"); - Double ry = inputParams.getDouble("ry"); - Double rz = inputParams.getDouble("rz"); - String frame = inputParams.getString("frame"); - Double velocity = inputParams.getDouble("velocity"); - Double acceleration = inputParams.getDouble("acceleration"); - Double blendRadius = inputParams.getDouble("blendRadius"); - - // 参数验证 - if (x == null || y == null || z == null) { - throw new GlobalException("X、Y、Z坐标不能为空"); - } - if (rx == null || ry == null || rz == null) { - throw new GlobalException("RX、RY、RZ旋转角度不能为空"); - } + if (Objects.requireNonNull(action) == ActionEnum.ARM_MOVE_TO_POINT) { + log.info("执行机械臂末端运动到指定点操作,设备ID: {}", deviceId); - // 直接调用边缘端机械臂服务执行笛卡尔空间直线运动 - ArmCommand.MoveL.Response result = edgeArmService.moveL( + // 从输入参数中获取坐标信息 + Double x = inputParams.getDouble("x"); + Double y = inputParams.getDouble("y"); + Double z = inputParams.getDouble("z"); + Double rx = inputParams.getDouble("rx"); + Double ry = inputParams.getDouble("ry"); + Double rz = inputParams.getDouble("rz"); + String frame = inputParams.getString("frame"); + Double velocity = inputParams.getDouble("velocity"); + Double acceleration = inputParams.getDouble("acceleration"); + Double blendRadius = inputParams.getDouble("blendRadius"); + + // 参数验证 + if (x == null || y == null || z == null) { + throw new GlobalException("X、Y、Z坐标不能为空"); + } + if (rx == null || ry == null || rz == null) { + throw new GlobalException("RX、RY、RZ旋转角度不能为空"); + } + + // 直接调用边缘端机械臂服务执行笛卡尔空间直线运动 + edgeArmService.moveL( edgeCommonVO, x, y, @@ -88,15 +89,11 @@ public class EdgeArmOperateService implements EdgeOperateService { velocity, acceleration, blendRadius - ); - - log.info("机械臂末端运动任务下发成功"); - - break; - } + ); - default: - throw new GlobalException("不支持的机械臂操作类型: " + action); + log.info("机械臂末端运动任务下发成功"); + } else { + throw new GlobalException("不支持的机械臂操作类型: " + action); } return TaskNodeExecuteResult.success(); diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeTouchOperateService.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeTouchOperateService.java index cafbd3d..72f1fd9 100644 --- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeTouchOperateService.java +++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/operator/edge/EdgeTouchOperateService.java @@ -12,6 +12,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Objects; + @Slf4j @Service @@ -33,13 +35,12 @@ public class EdgeTouchOperateService implements EdgeOperateService { String deviceId = inputParams.getString("deviceId"); String touchParams = inputParams.getString("touchParams"); - switch (action) { - case TOUCH: { - EdgeArmMoveJVO edgeArmMoveJVO = JSON.parseObject(touchParams, EdgeArmMoveJVO.class); - edgeArmMoveJVO.setTerminalId(terminalId); - edgeArmMoveJVO.setDeviceId(deviceId); + if (Objects.requireNonNull(action) == ActionEnum.TOUCH) { + EdgeArmMoveJVO edgeArmMoveJVO = JSON.parseObject(touchParams, EdgeArmMoveJVO.class); + edgeArmMoveJVO.setTerminalId(terminalId); + edgeArmMoveJVO.setDeviceId(deviceId); - edgeArmService.moveJ( + edgeArmService.moveJ( edgeArmMoveJVO, edgeArmMoveJVO.getTarget(), edgeArmMoveJVO.getVelocity(), @@ -47,12 +48,9 @@ public class EdgeTouchOperateService implements EdgeOperateService { edgeArmMoveJVO.getBlendRadius(), edgeArmMoveJVO.getJointVelocityLimits(), edgeArmMoveJVO.getAsynchronous() - ); - break; - } - - default: - throw new GlobalException("不支持的触控操作类型: " + action); + ); + } else { + throw new GlobalException("不支持的触控操作类型: " + action); } return TaskNodeExecuteResult.success(); }