4 changed files with 73 additions and 5 deletions
-
1src/main/java/com/iflytop/sgs/app/controller/DevicePointController.java
-
36src/main/java/com/iflytop/sgs/app/controller/MotorController.java
-
5src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java
-
36src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java
@ -0,0 +1,36 @@ |
|||||
|
package com.iflytop.sgs.app.controller; |
||||
|
|
||||
|
import com.iflytop.sgs.app.service.device.DeviceSensorService; |
||||
|
import com.iflytop.sgs.common.enums.DevicePartId; |
||||
|
import com.iflytop.sgs.common.result.Result; |
||||
|
import com.iflytop.sgs.hardware.exception.HardwareException; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* 认证控制 |
||||
|
*/ |
||||
|
@Tag(name = "设备") |
||||
|
@RestController |
||||
|
@RequestMapping("/api/motor") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class MotorController { |
||||
|
|
||||
|
private DeviceSensorService deviceSensorService; |
||||
|
|
||||
|
@Operation(summary = "获取当前电机位置") |
||||
|
@GetMapping("/position/{motor}") |
||||
|
public Result<Double> getPosition(@PathVariable String motor) { |
||||
|
DevicePartId devicePartId = DevicePartId.valueOf(motor); |
||||
|
try { |
||||
|
Double position = deviceSensorService.getSensorStatus(devicePartId); |
||||
|
return Result.success(position); |
||||
|
} catch (HardwareException e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue