package com.cmvr.web.controller.api;

import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.edge.client.model.EdgeCommonVO;
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
import com.cmvr.edge.client.model.humanoid.EdgeSpeedJVO;
import com.cmvr.edge.client.service.EdgeHumanoidRobotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "边缘--机械臂")
@RestController
@RequestMapping("/api/humanoid")
@RequiredArgsConstructor
public class EdgeHumanoidRobotController {

    private final EdgeHumanoidRobotService edgeHumanoidRobotService;

    @ApiOperation("moveJ")
    @PostMapping("/moveJ")
    public AjaxResult moveJ(@RequestBody EdgeMoveJVO moveJVO) {
        return AjaxResult.ok(edgeHumanoidRobotService.moveJ(moveJVO));
    }

    @ApiOperation("speedJ")
    @PostMapping("/speedJ")
    public AjaxResult speedJ(@RequestBody EdgeSpeedJVO speedJVO) {
        return AjaxResult.ok(edgeHumanoidRobotService.speedJ(speedJVO));
    }

    @ApiOperation("获取关节状态")
    @GetMapping("/getJointState")
    public AjaxResult status(EdgeCommonVO vo) {
        return AjaxResult.ok(edgeHumanoidRobotService.getJointState(vo));
    }

    @ApiOperation("使能开")
    @GetMapping("/torqueOn")
    public AjaxResult torqueOn(EdgeCommonVO vo) {
        return AjaxResult.ok(edgeHumanoidRobotService.torqueOn(vo));
    }

    @ApiOperation("使能关")
    @GetMapping("/torqueOff")
    public AjaxResult torqueOff(EdgeCommonVO vo) {
        return AjaxResult.ok(edgeHumanoidRobotService.torqueOff(vo));
    }

}
