Browse Source

调整设备控制方法定义

增加设备状态实体
master
白凤吉 6 months ago
parent
commit
8ed8e52a2b
  1. 6
      src/main/java/com/qyft/gd/device/controller/TestController.java
  2. 11
      src/main/java/com/qyft/gd/device/model/bo/DeviceAlarm.java
  3. 82
      src/main/java/com/qyft/gd/device/model/bo/DeviceStatus.java
  4. 6
      src/main/java/com/qyft/gd/device/service/DeviceService.java
  5. 4
      src/main/java/com/qyft/gd/service/CMDService.java

6
src/main/java/com/qyft/gd/device/controller/TestController.java

@ -142,7 +142,7 @@ public class TestController {
@Operation(summary = "加液")
@GetMapping("/addLiquid")
public Result<String> addLiquid(@RequestParam int pumpId, @RequestParam int volume) {
public Result<String> addLiquid(@RequestParam String pumpId, @RequestParam int volume) {
boolean success = deviceService.addLiquid(pumpId, volume);
if (success) {
return Result.success();
@ -197,8 +197,8 @@ public class TestController {
@Operation(summary = "开始加热")
@GetMapping("/startHeating")
public Result<String> startHeating(@RequestParam int temperature) {
boolean success = deviceService.startHeating(temperature);
public Result<String> startHeating(@RequestParam String heaterId, @RequestParam int temperature) {
boolean success = deviceService.startHeating(heaterId, temperature);
if (success) {
return Result.success();
} else {

11
src/main/java/com/qyft/gd/device/model/bo/DeviceAlarm.java

@ -0,0 +1,11 @@
package com.qyft.gd.device.model.bo;
import lombok.Data;
/**
* 设备报警信息
*/
@Data
public class DeviceAlarm {
private String msg;
}

82
src/main/java/com/qyft/gd/device/model/bo/DeviceStatus.java

@ -1,11 +1,93 @@
package com.qyft.gd.device.model.bo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 设备当前状态
*/
@Schema(description = "设备当前状态")
@Data
public class DeviceStatus {
@Schema(description = "门状态,true为开启状态,false为关闭状态")
private Boolean doorStatus;
@Schema(description = "导轨机械臂状态")
private RailArm railArm;
@Schema(description = "加液机械臂状态")
private LiquidArm liquidArm;
@Schema(description = "加液泵状态")
private List<Pump> pump;
@Schema(description = "摇匀状态,true为正在摇匀,false为停止摇匀")
private Boolean shakingStatus;
@Schema(description = "摇匀速度")
private Integer shakingSpeed;
@Schema(description = "加热状态,true为正在摇匀,false为停止摇匀")
private Boolean heatingStatus;
@Schema(description = "加热器状态")
private List<Heater> heater;
@Data
class RailArm{
@Schema(description = "所在x坐标")
private Integer x;
@Schema(description = "所在y坐标")
private Integer y;
@Schema(description = "所在z坐标")
private Integer z;
@Schema(description = "轴1角度")
private Double joint1;
@Schema(description = "轴2角度")
private Double joint2;
@Schema(description = "导轨移动距离")
private Double railDistance;
@Schema(description = "夹爪移动距离")
private Double clawDistance;
@Schema(description = "机械臂速度")
private int speed;
@Schema(description = "夹爪状态,true为张开状态,false为闭合状态")
private Boolean clawStatus;
}
@Data
class LiquidArm{
@Schema(description = "所在x坐标")
private Integer x;
@Schema(description = "所在y坐标")
private Integer y;
@Schema(description = "所在z坐标")
private Integer z;
@Schema(description = "轴1角度")
private Double joint1;
@Schema(description = "轴2角度")
private Double joint2;
@Schema(description = "机械臂速度")
private int speed;
}
@Data
class Pump{
@Schema(description = "加液泵id")
private String pumpId;
@Schema(description = "加液泵流量")
private Integer flowRate;
}
@Data
class Heater{
@Schema(description = "加热器id")
private String heaterId;
@Schema(description = "托盘状态,true为存在托盘,false为无托盘")
private Boolean trayStatus;
@Schema(description = "托盘移动的距离")
private Double trayHeight;
@Schema(description = "托盘移动的速度")
private Double traySpeed;
@Schema(description = "加热状态,true为正在加热,false为未加热")
private Double heatingStatus;
@Schema(description = "加热目标温度")
private Double temperature;
}
}

6
src/main/java/com/qyft/gd/device/service/DeviceService.java

@ -197,7 +197,7 @@ public class DeviceService {
* @param pumpId 泵id
* @param volume 液体体积
*/
public boolean addLiquid(int pumpId, int volume) {
public boolean addLiquid(String pumpId, int volume) {
Map<String, Object> params = new HashMap<>();
params.put("pumpId", pumpId);
params.put("volume", volume);
@ -271,10 +271,12 @@ public class DeviceService {
/**
* 开始加热
*
* @param heaterId 加热器id
* @param temperature 温度值
*/
public boolean startHeating(int temperature) {
public boolean startHeating(String heaterId, int temperature) {
Map<String, Object> params = new HashMap<>();
params.put("heaterId", heaterId);
params.put("temperature", temperature);
DeviceFeedback deviceFeedback = tcpClient.sendCommand("startHeating", params);
if (deviceFeedback == null || deviceFeedback.getError() != null) {

4
src/main/java/com/qyft/gd/service/CMDService.java

@ -95,7 +95,7 @@ public class CMDService {
// 开始加热
private Boolean startHeat(CMDForm cmdForm) {
List<Supplier<Boolean>> cmdList = new ArrayList<>();
cmdList.add(() -> deviceService.startHeating((Integer) cmdForm.getParams().get("time")));
cmdList.add(() -> deviceService.startHeating((String) cmdForm.getParams().get("heaterId"),(Integer) cmdForm.getParams().get("time")));
return run(cmdList);
}
// 摇匀
@ -140,7 +140,7 @@ public class CMDService {
// TODO 获取加液位是否有试管(传感器?)
// TODO 溶液id 容量
Map<String, Object> params = cmdForm.getParams();
cmdList.add(() -> deviceService.addLiquid((Integer) params.get("pumpId"), ((Integer)params.get("volume"))));
cmdList.add(() -> deviceService.addLiquid((String) params.get("pumpId"), ((Integer)params.get("volume"))));
return run(cmdList);
}
// 放下托盘

Loading…
Cancel
Save