|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.iflytop.gd.hardware.controller; |
|
|
|
|
|
|
|
import com.iflytop.gd.common.result.Result; |
|
|
|
import com.iflytop.gd.hardware.exception.HardwareException; |
|
|
|
import com.iflytop.gd.hardware.service.StepMotorService; |
|
|
|
import com.iflytop.gd.hardware.type.StepMotor.DeviceStepMotorId; |
|
|
@ -49,170 +50,192 @@ public class StepMotorController { |
|
|
|
// 基础设置 |
|
|
|
@PostMapping("/speed-level") |
|
|
|
@Operation(summary = "设置速度等级") |
|
|
|
public void setStepMotorSpeedLevel(@RequestParam StepMotorSpeedLevel speedLevel) { |
|
|
|
public Result<?> setStepMotorSpeedLevel(@RequestParam StepMotorSpeedLevel speedLevel) { |
|
|
|
stepMotorService.setStepMotorSpeedLevel(speedLevel); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 基础操作 |
|
|
|
@PostMapping("/enable") |
|
|
|
@Operation(summary = "电源开启") |
|
|
|
public void enableMotor(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> enableMotor(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.enableMotor(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/disable") |
|
|
|
@Operation(summary = "电源关闭") |
|
|
|
public void disableMotor(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> disableMotor(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.disableMotor(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/move-to-zero") |
|
|
|
@Operation(summary = "回Home") |
|
|
|
public void stepMotorEasyMoveToZero(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> stepMotorEasyMoveToZero(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.stepMotorEasyMoveToZero(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/move-to-zero-quick") |
|
|
|
@Operation(summary = "快速回Home") |
|
|
|
public void stepMotorEasyMoveToZeroPointQuickBlock(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> stepMotorEasyMoveToZeroPointQuickBlock(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.stepMotorEasyMoveToZeroPointQuickBlock(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/stop") |
|
|
|
@Operation(summary = "停止") |
|
|
|
public void stepMotorStop(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> stepMotorStop(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.stepMotorStop(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 相对移动 |
|
|
|
@PostMapping("/move-by-forward") |
|
|
|
@Operation(summary = "正向点动") |
|
|
|
public void stepMotorEasyMoveByForward( |
|
|
|
public Result<?> stepMotorEasyMoveByForward( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer dpos) throws HardwareException { |
|
|
|
stepMotorService.stepMotorEasyMoveByForward(deviceId, dpos); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/move-by-backward") |
|
|
|
@Operation(summary = "反向点动") |
|
|
|
public void stepMotorEasyMoveByBackward( |
|
|
|
public Result<?> stepMotorEasyMoveByBackward( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer dpos) throws HardwareException { |
|
|
|
stepMotorService.stepMotorEasyMoveByBackward(deviceId, dpos); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 绝对移动 |
|
|
|
@PostMapping("/move-to") |
|
|
|
@Operation(summary = "移动(绝对)") |
|
|
|
public void stepMotorEasyMoveTo( |
|
|
|
public Result<?> stepMotorEasyMoveTo( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer pos) throws HardwareException { |
|
|
|
stepMotorService.stepMotorEasyMoveTo(deviceId, pos); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 旋转 |
|
|
|
@PostMapping("/rotate-forward") |
|
|
|
@Operation(summary = "正转") |
|
|
|
public void rotateForward(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> rotateForward(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.rotateForward(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/rotate-backward") |
|
|
|
@Operation(summary = "反转") |
|
|
|
public void rotateBackward(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
public Result<?> rotateBackward(@RequestParam DeviceStepMotorId deviceId) throws HardwareException { |
|
|
|
stepMotorService.rotateBackward(deviceId); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 寄存器配置 |
|
|
|
@PostMapping("/mres") |
|
|
|
@Operation(summary = "设置细分") |
|
|
|
public void setMres( |
|
|
|
public Result<?> setMres( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer mres) throws HardwareException { |
|
|
|
stepMotorService.setMres(deviceId, mres); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/irun") |
|
|
|
@Operation(summary = "设置IRUN") |
|
|
|
public void setIRUN( |
|
|
|
public Result<?> setIRUN( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer irun) throws HardwareException { |
|
|
|
stepMotorService.setIRUN(deviceId, irun); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/ihold") |
|
|
|
@Operation(summary = "设置IHOLD") |
|
|
|
public void setIHOLD( |
|
|
|
public Result<?> setIHOLD( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer ihold) throws HardwareException { |
|
|
|
stepMotorService.setIHOLD(deviceId, ihold); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/start-stop-vel") |
|
|
|
@Operation(summary = "设置起停速度") |
|
|
|
public void setStartAndStopVel( |
|
|
|
public Result<?> setStartAndStopVel( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer v) throws HardwareException { |
|
|
|
stepMotorService.setStartAndStopVel(deviceId, v); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/v1") |
|
|
|
@Operation(summary = "设置V1") |
|
|
|
public void setV1( |
|
|
|
public Result<?> setV1( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer v) throws HardwareException { |
|
|
|
stepMotorService.setV1(deviceId, v); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/acceleration") |
|
|
|
@Operation(summary = "设置加速度") |
|
|
|
public void setA1AndD1( |
|
|
|
public Result<?> setA1AndD1( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer acc) throws HardwareException { |
|
|
|
stepMotorService.setA1AndD1(deviceId, acc); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/max-acceleration") |
|
|
|
@Operation(summary = "设置最大加速度") |
|
|
|
public void setAmaxAndDmax( |
|
|
|
public Result<?> setAmaxAndDmax( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer acc) throws HardwareException { |
|
|
|
stepMotorService.setAmaxAndDmax(deviceId, acc); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/default-velocity") |
|
|
|
@Operation(summary = "设置默认速度") |
|
|
|
public void setDefaultVel( |
|
|
|
public Result<?> setDefaultVel( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer v) throws HardwareException { |
|
|
|
stepMotorService.setDefaultVel(deviceId, v); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/speed") |
|
|
|
@Operation(summary = "设置速度") |
|
|
|
public void setSpeed( |
|
|
|
public Result<?> setSpeed( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer low, |
|
|
|
@RequestParam Integer mid, |
|
|
|
@RequestParam Integer high) throws HardwareException { |
|
|
|
stepMotorService.setSpeed(deviceId, low, mid, high); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/one-circle-pulse") |
|
|
|
@Operation(summary = "设置一圈脉冲数") |
|
|
|
public void setOneCirclePulse( |
|
|
|
public Result<?> setOneCirclePulse( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer pulse, |
|
|
|
@RequestParam Integer denominator) throws HardwareException { |
|
|
|
stepMotorService.setOneCirclePulse(deviceId, pulse, denominator); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/dzero") |
|
|
|
@Operation(summary = "设置DZero") |
|
|
|
public void setDZero( |
|
|
|
public Result<?> setDZero( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam Integer dzero) throws HardwareException { |
|
|
|
stepMotorService.setDZero(deviceId, dzero); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/reg") |
|
|
@ -225,11 +248,12 @@ public class StepMotorController { |
|
|
|
|
|
|
|
@PostMapping("/reg") |
|
|
|
@Operation(summary = "设置寄存器") |
|
|
|
public void setReg( |
|
|
|
public Result<?> setReg( |
|
|
|
@RequestParam DeviceStepMotorId deviceId, |
|
|
|
@RequestParam StepMotorRegIndex reg, |
|
|
|
@RequestParam Integer val) throws HardwareException { |
|
|
|
stepMotorService.setReg(deviceId, reg, val); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
// 状态查询 |
|
|
|