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.
395 lines
9.5 KiB
395 lines
9.5 KiB
package com.dreamworks.boditech.controller;
|
|
import com.dreamworks.boditech.controller.entity.ApiResponse;
|
|
import com.dreamworks.boditech.driver.actuator.ActModuleTestCardBoxCaseTemperature;
|
|
import com.dreamworks.boditech.driver.actuator.ActuatorModule;
|
|
import com.dreamworks.boditech.driver.entity.ParamBufferTubeUpdateByBox;
|
|
import com.dreamworks.boditech.driver.entity.ParamLargeBufferTubeUpdate;
|
|
import com.dreamworks.boditech.driver.entity.ParamPipetteTipUpdate;
|
|
import com.dreamworks.boditech.driver.entity.ParamTestCardUpdateByBox;
|
|
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/start")
|
|
public ApiResponse start() {
|
|
this.deviceService.start();
|
|
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/init")
|
|
public ApiResponse init() {
|
|
// this.deviceService.reset(false);
|
|
return this.success();
|
|
}
|
|
|
|
@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-update-by-box")
|
|
public ApiResponse bufferTubeUpdateByBox( @RequestBody ParamBufferTubeUpdateByBox param) {
|
|
this.deviceService.bufferTubeUpdateByBox(param);
|
|
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/emergency-slot-status-get")
|
|
public ApiResponse emergencySlotStatusGet() {
|
|
return this.success(Map.of(
|
|
"slotA", Map.of("status","EMPTY"),
|
|
"slotB", Map.of("status","EMPTY")
|
|
));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/status-get")
|
|
public ApiResponse status() {
|
|
return this.success(Map.of(
|
|
"status", "WAIT_FOR_TUBE_RACK"
|
|
));
|
|
}
|
|
|
|
@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();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/trash-box-status-get")
|
|
public ApiResponse trashBoxStatusGet() {
|
|
return this.success(Map.of(
|
|
"status", "EMPTY"
|
|
));
|
|
}
|
|
|
|
@ResponseBody
|
|
@PostMapping("/api/device/incubator-status-get")
|
|
public ApiResponse incubatorStatusGet() {
|
|
List<Map<String,Object>> slots = new ArrayList<>();
|
|
for ( int i=0; i<20; i++) {
|
|
Map<String,Object> slot = new HashMap<>();
|
|
slot.put("index", Integer.toString(i));
|
|
slot.put("status", "INUSE");
|
|
slot.put("task", Map.of(
|
|
"recordUUID", "202110-01",
|
|
"samplePID", "ABCD1234",
|
|
"sampleUID", "016",
|
|
"projectName", "hsCRP",
|
|
"lotCode", "1234567890",
|
|
"tubeIndex", "05",
|
|
"tubeType", "WB",
|
|
"sampleType", "FB",
|
|
"incubateStartedAt", "2012-12-15 00:00:44",
|
|
"incubateTime", "3600"
|
|
));
|
|
slots.add(slot);
|
|
}
|
|
|
|
return this.success(Map.of(
|
|
"temperature", 37,
|
|
"slots", slots
|
|
));
|
|
}
|
|
|
|
@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
|
|
));
|
|
}
|
|
}
|