1 changed files with 108 additions and 0 deletions
@ -0,0 +1,108 @@ |
|||||
|
package com.iflytop.a800.controller; |
||||
|
import com.iflytop.a800.device.Device; |
||||
|
import com.iflytop.a800.task.MaterialLoadTask; |
||||
|
import com.iflytop.uf.controller.UfApiControllerBase; |
||||
|
import com.iflytop.uf.controller.UfApiResponse; |
||||
|
import com.iflytop.uf.model.UfMdbRuntimeVariable; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
@Controller |
||||
|
public class MaterialController extends UfApiControllerBase { |
||||
|
@PostMapping("/api/material/load") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse load() { |
||||
|
var task = new MaterialLoadTask(); |
||||
|
try { |
||||
|
task.start(); |
||||
|
task.join(); |
||||
|
} catch (InterruptedException e) { |
||||
|
return this.error("任务执行失败 : " + e.getMessage()); |
||||
|
} |
||||
|
if ( task.hasError() ) { |
||||
|
return this.error(task.getErrorMessage()); |
||||
|
} |
||||
|
return this.success(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/unload") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse unload() { |
||||
|
Device.getInstance().testCard.clear(); |
||||
|
Device.getInstance().bufferTube.clear(); |
||||
|
Device.getInstance().largeBufferTube.clear(); |
||||
|
UfMdbRuntimeVariable.setString("IsMaterialLoaded", "no"); |
||||
|
return this.success(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/api/material/test-card-status-get") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse testCardStatusGet() { |
||||
|
var cardMan = Device.getInstance().testCard; |
||||
|
var boxes = cardMan.getBoxes(); |
||||
|
return this.success(boxes); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/test-card-update-by-box") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse testCardUpdateByBox(@RequestBody Map<String, Object> params) { |
||||
|
Integer index = (Integer)params.get("index"); |
||||
|
Integer cardAmount = (Integer)params.get("cardAmount"); |
||||
|
var cardMan = Device.getInstance().testCard; |
||||
|
cardMan.getBoxByIndex(index).cardAmount = cardAmount; |
||||
|
return this.success(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/buffer-tube-status-get") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse bufferTubeStatusGet() { |
||||
|
var bufferTubes = Device.getInstance().bufferTube; |
||||
|
var list = bufferTubes.getZones(); |
||||
|
return this.success(list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/buffer-tube-update-by-box") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse bufferTubeUpdateByBox(@RequestBody Map<String, Object> params) { |
||||
|
Integer index = (Integer)params.get("index"); |
||||
|
Integer tubeAmount = (Integer)params.get("tubeAmount"); |
||||
|
var bufferTubes = Device.getInstance().bufferTube; |
||||
|
bufferTubes.getZoneByIndex(index).tubeAmount = tubeAmount; |
||||
|
return this.success(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/large-buffer-tube-status-get") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse largeBufferTubeStatusGet() { |
||||
|
var largeBufferTubes = Device.getInstance().largeBufferTube; |
||||
|
var list = largeBufferTubes.getTubes(); |
||||
|
return this.success(list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/pipette-tip-update-by-box") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse pipetteTipUpdateByBox(@RequestBody Map<String, Object> params) { |
||||
|
Integer index = (Integer)params.get("index"); |
||||
|
Integer tipAmount = (Integer)params.get("tipAmount"); |
||||
|
var pipette = Device.getInstance().pipette; |
||||
|
pipette.setTipAmount(index, tipAmount); |
||||
|
return this.success(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/material/pipette-tip-box-status-get") |
||||
|
@ResponseBody |
||||
|
public UfApiResponse pipetteTipBoxStatusGet() { |
||||
|
var pipette = Device.getInstance().pipette; |
||||
|
var amountList = pipette.getTipAmountList(); |
||||
|
var list = List.of( |
||||
|
Map.of("index", 0, "tipAmount", amountList.get(0)), |
||||
|
Map.of("index", 1, "tipAmount", amountList.get(1)), |
||||
|
Map.of("index", 2, "tipAmount", amountList.get(2)) |
||||
|
); |
||||
|
return this.success(list); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue