You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
382 lines
9.7 KiB
382 lines
9.7 KiB
package com.dreamworks.boditech.controller;
|
|
import com.dreamworks.boditech.controller.entity.ApiResponse;
|
|
import com.dreamworks.boditech.driver.Device;
|
|
import com.dreamworks.boditech.driver.actuator.ActIncubator;
|
|
import com.dreamworks.boditech.driver.actuator.ActModuleIncubatorTemperature;
|
|
import com.dreamworks.boditech.driver.actuator.ActModuleTestCardBoxCaseTemperature;
|
|
import com.dreamworks.boditech.driver.actuator.ActuatorModule;
|
|
import com.dreamworks.boditech.driver.entity.*;
|
|
import com.dreamworks.boditech.driver.task.Task;
|
|
import com.dreamworks.boditech.service.DeviceService;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
|
|
@Controller
|
|
public class DeviceController extends BaseController {
|
|
@Resource
|
|
private DeviceService deviceService;
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/power-off")
|
|
public ApiResponse powerOff() {
|
|
DeviceService theDeviceService = this.deviceService;
|
|
TimerTask timerTask = new TimerTask() {
|
|
@Override
|
|
public void run() {
|
|
theDeviceService.powerOff();
|
|
}
|
|
};
|
|
Timer timer = new Timer();
|
|
timer.schedule(timerTask, 1000);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/reboot")
|
|
public ApiResponse reboot() {
|
|
DeviceService theDeviceService = this.deviceService;
|
|
TimerTask timerTask = new TimerTask() {
|
|
@Override
|
|
public void run() {
|
|
theDeviceService.reboot();
|
|
}
|
|
};
|
|
Timer timer = new Timer();
|
|
timer.schedule(timerTask, 1000);
|
|
return this.success();
|
|
}
|
|
|
|
/**
|
|
* load consumable resources
|
|
* @return api response
|
|
*/
|
|
@ResponseBody
|
|
@PostMapping("/api/device/load")
|
|
public ApiResponse load() {
|
|
this.deviceService.load();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/unload")
|
|
public ApiResponse unload() {
|
|
this.deviceService.unload();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/temperature-get")
|
|
public ApiResponse temperatureGet() {
|
|
Integer mid = ActuatorModule.TEST_CARD_BOX_CASE_TEMPERATURE;
|
|
ActModuleTestCardBoxCaseTemperature module = (ActModuleTestCardBoxCaseTemperature)this.deviceService.device.getActuator(mid);
|
|
Double temperature = module.getTemperature();
|
|
return this.success(Map.of(
|
|
"testCardBoxCase", temperature
|
|
));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/pipette-tip-update-by-box")
|
|
public ApiResponse pipetteTipUpdate( @RequestBody ParamPipetteTipUpdate param ) {
|
|
this.deviceService.pipetteTipUpdateByBox(param);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/pipette-tip-box-status-get")
|
|
public ApiResponse pipetteTipStatusGet() {
|
|
return this.success(this.deviceService.device.pipetteTips.getAll());
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/buffer-tube-update-by-box")
|
|
public ApiResponse bufferTubeUpdateByBox( @RequestBody ParamBufferTubeUpdateByBox param) {
|
|
this.deviceService.bufferTubeUpdateByBox(param);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/status-get")
|
|
public ApiResponse status() {
|
|
String status = "READY";
|
|
if ( this.deviceService.device.testCards.getIsLoaded() ) {
|
|
status = "CONSUMABLES_LOADED";
|
|
}
|
|
if ( this.deviceService.isExecutorRunning() ) {
|
|
status = this.deviceService.getExecutorWorkingStatus();
|
|
}
|
|
return this.success(Map.of("status", status));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/incubator-status-get")
|
|
public ApiResponse incubatorStatusGet() {
|
|
Device device = this.deviceService.device;
|
|
ActIncubator incubator = (ActIncubator)device.getActuator(ActuatorModule.INCUBATOR_MOTOR);
|
|
IncubatorSlot[] slots = incubator.getSlots();
|
|
|
|
ActModuleIncubatorTemperature temperatureMod = (ActModuleIncubatorTemperature)device.getActuator(ActuatorModule.INCUBATOR_TEMPERATURE);
|
|
Double temperature = temperatureMod.getTemperature();
|
|
return this.success(Map.of(
|
|
"temperature", temperature,
|
|
"slots", slots
|
|
));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/start")
|
|
public ApiResponse start() {
|
|
this.deviceService.start();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/stop")
|
|
public ApiResponse stop() {
|
|
this.deviceService.stop();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/pause")
|
|
public ApiResponse pause() {
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/resume")
|
|
public ApiResponse resume() {
|
|
return this.success();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer initCount = 3;
|
|
@ResponseBody
|
|
@PostMapping("/api/device/init")
|
|
public ApiResponse init() {
|
|
if ( initCount > 0 ) {
|
|
this.initCount --;
|
|
ApiResponse response = new ApiResponse();
|
|
response.success = false;
|
|
response.message = "";
|
|
response.data = List.of(
|
|
Map.of("message","请确认试管帽夹中无试管帽","type","manual"),
|
|
Map.of("message","移液枪复位","type","auto"),
|
|
Map.of("message","机械臂复位","type","auto"),
|
|
Map.of("message","孵育盘复位","type","auto")
|
|
);
|
|
return response;
|
|
} else {
|
|
this.initCount = 3;
|
|
return this.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/service-status-get")
|
|
public ApiResponse serviceStatusGet() {
|
|
String deviceConnection = this.deviceService.device.getConnectionStatus();
|
|
// @TODO : 想个办法获取数据库连接状态
|
|
String databaseConnection = "connected";
|
|
return this.success(Map.of(
|
|
"deviceConnection", deviceConnection,
|
|
"databaseConnection", databaseConnection
|
|
));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/restore")
|
|
public ApiResponse restore() {
|
|
this.deviceService.reset(true);
|
|
return this.success();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@RequestMapping("/api/device/id-chip-status-get")
|
|
public ApiResponse statusGet() {
|
|
return this.success(Map.of(
|
|
"status" , "OFFLINE"
|
|
));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/test-card-load")
|
|
public ApiResponse testCardLoad(@RequestHeader(name="IS-FS-READY",required = false) String isFsReady ) {
|
|
// @TODO : 删除该标记
|
|
if ( "NO".equals(isFsReady) ) {
|
|
return this.success();
|
|
}
|
|
|
|
this.deviceService.testCardLoad();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/test-card-update-by-box")
|
|
public ApiResponse testCardUpdateByBox( @RequestBody ParamTestCardUpdateByBox update ) {
|
|
this.deviceService.testCardUpdateByBox(update);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/test-card-status-get")
|
|
public ApiResponse testCardStatusGet() {
|
|
return this.success(this.deviceService.device.testCards.getAllBoxes());
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/buffer-tube-load")
|
|
public ApiResponse bufferTubeLoad() {
|
|
// List<CsmBufferTube> list = this.deviceService.bufferTubeLoad();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/buffer-tube-status-get")
|
|
public ApiResponse bufferTubeStatusGet() {
|
|
return this.success(this.deviceService.device.bufferTubes.getAllBoxes());
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/large-buffer-tube-load")
|
|
public ApiResponse largeBufferTubeLoad() {
|
|
// List< CsmLargeBufferTube> list = this.deviceService.largeBufferTubeLoad();
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/large-buffer-tube-update")
|
|
public ApiResponse largeBufferTubeUpdate(@RequestBody ParamLargeBufferTubeUpdate param) {
|
|
this.deviceService.largeBufferTubeUpdate(param);
|
|
return this.success();
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/large-buffer-tube-status-get")
|
|
public ApiResponse largeBufferTubeStatusGet() {
|
|
return this.success(this.deviceService.device.largeBufferTubes.getAll());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/trash-box-status-get")
|
|
public ApiResponse trashBoxStatusGet() {
|
|
return this.success(Map.of(
|
|
"status", "EMPTY"
|
|
));
|
|
}
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/test-tube-rack-status-get")
|
|
public ApiResponse testTubeRackStatusGet() {
|
|
List<Map<String,Object>> tubes = new ArrayList<>();
|
|
for ( int i=0; i<10; i++ ) {
|
|
List<Map<String,Object>> tasks = new ArrayList<>();
|
|
for ( int ti=0; ti<3; ti++ ) {
|
|
Map<String,Object> task = new HashMap<>();
|
|
task.put("projectName", "hsCRP");
|
|
task.put("projectId", "01");
|
|
tasks.add(task);
|
|
}
|
|
|
|
Map<String,Object> tube = new HashMap<>();
|
|
tube.put("index", Integer.toString(i));
|
|
tube.put("status", "WAITING");
|
|
tube.put("sampleUID", "016");
|
|
tube.put("sampleType","FB");
|
|
tube.put("projects",tasks);
|
|
tubes.add(tube);
|
|
}
|
|
|
|
return this.success(Map.of(
|
|
"type" , "AUTO",
|
|
"tubes", tubes
|
|
));
|
|
}
|
|
}
|