|
|
@ -1,7 +1,9 @@ |
|
|
|
package com.dreamworks.boditech.driver.task; |
|
|
|
import com.dreamworks.boditech.driver.Device; |
|
|
|
import com.dreamworks.boditech.driver.actuator.*; |
|
|
|
import com.dreamworks.boditech.driver.entity.LisTestInfo; |
|
|
|
import com.dreamworks.boditech.driver.entity.TaskBatchTubeTestInfo; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
public class TaskBatchTubePrepare extends TaskBase { |
|
|
@ -13,6 +15,10 @@ public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
private ActModuleTestTubeRackMovement testTubeMovement; |
|
|
|
// testTubeFeedMotor |
|
|
|
private ActMotor testTubeFeedMotor; |
|
|
|
// testTubeExistsStatus |
|
|
|
private boolean[] testTubeExistsStatus; |
|
|
|
// testTubeBarcodes |
|
|
|
private String[] testTubeBarcodes; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void execute( Executor executor ) { |
|
|
@ -22,59 +28,84 @@ public class TaskBatchTubePrepare extends TaskBase { |
|
|
|
this.testTubeFeedMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_FEED_MOTOR); |
|
|
|
this.testTubeMovement = (ActModuleTestTubeRackMovement)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_MOVEMENT); |
|
|
|
ActMotor testTubeMoveMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_MOVE_MOTOR); |
|
|
|
ActMotor testTubeRotateMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_ROTATE_MOTOR); |
|
|
|
ActMotor testTubeRotateMotor = (ActMotor) this.device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_ROTATE_MOTOR); |
|
|
|
|
|
|
|
this.testTubeRackFeed(); |
|
|
|
|
|
|
|
// 02. 检查试管有无 |
|
|
|
boolean[] testTubeExistsStatus = new boolean[10]; |
|
|
|
this.testTubeExistsStatus = new boolean[10]; |
|
|
|
int tubeDistance = this.device.getLocationByName("testTubeRackTubeDistance"); |
|
|
|
int existsCheckStartPos = this.device.getLocationByName("testTubeRackExistsCheckStart"); |
|
|
|
for ( int i = 0; i < 10; i++ ) { |
|
|
|
testTubeMoveMotor.moveTo(existsCheckStartPos + i * tubeDistance); |
|
|
|
Integer isExists = this.testTubeMovement.readIO(ActModuleTestTubeRackMovement.IO_TEST_TUBE_EXISTS); |
|
|
|
testTubeExistsStatus[i] = Objects.equals(this.device.getIOValueByName("testTubeRackTubeExistsYes"), isExists); |
|
|
|
this.testTubeExistsStatus[i] = Objects.equals(this.device.getIOValueByName("testTubeRackTubeExistsYes"), isExists); |
|
|
|
} |
|
|
|
|
|
|
|
// 03. 逐个扫描试管 |
|
|
|
ActCodeScanner testTubeScanner = (ActCodeScanner)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_SCANNER); |
|
|
|
String[] testTubeBarcodes = new String[10]; |
|
|
|
this.testTubeBarcodes = new String[10]; |
|
|
|
int scanStartPos = this.device.getLocationByName("testTubeRackScanStart"); |
|
|
|
for ( int i = 0; i < 10; i++ ) { |
|
|
|
if ( !testTubeExistsStatus[i] ) { |
|
|
|
testTubeBarcodes[i] = ""; |
|
|
|
if ( !this.testTubeExistsStatus[i] ) { |
|
|
|
this.testTubeBarcodes[i] = ""; |
|
|
|
continue ; |
|
|
|
} |
|
|
|
testTubeMoveMotor.moveTo(scanStartPos + i * tubeDistance); |
|
|
|
testTubeRotateMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); |
|
|
|
String code = testTubeScanner.scan(1000); |
|
|
|
testTubeRotateMotor.reset(); |
|
|
|
testTubeBarcodes[i] = code; |
|
|
|
this.testTubeBarcodes[i] = code; |
|
|
|
} |
|
|
|
|
|
|
|
// 04. 扫描完成后推送到预备区域 |
|
|
|
testTubeMoveMotor.moveTo("testTubeRackStandby"); |
|
|
|
|
|
|
|
// 05. 追加测试到执行器 |
|
|
|
for ( TaskBatchTubeTestInfo test : this.tests ) { |
|
|
|
if ( !testTubeExistsStatus[test.tubeIndex] ) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
TaskTestRegular task = new TaskTestRegular(); |
|
|
|
task.tubeIndex = test.tubeIndex; |
|
|
|
task.patientId = test.patientId; |
|
|
|
task.barcode = test.barcode.isEmpty() ? testTubeBarcodes[test.tubeIndex] : task.barcode; |
|
|
|
task.tubeType = test.testTube; |
|
|
|
task.projectName = test.project; |
|
|
|
task.bloodType = test.blood; |
|
|
|
executor.appendTask(task); |
|
|
|
} |
|
|
|
this.appendTestTasksToExecutor(executor); |
|
|
|
TaskBatchTubeExit exitTask = new TaskBatchTubeExit(); |
|
|
|
executor.appendTask(exitTask); |
|
|
|
|
|
|
|
this.setStatus(Task.STATUS_FINISHED); |
|
|
|
} |
|
|
|
|
|
|
|
// 追加测试到执行器 |
|
|
|
private void appendTestTasksToExecutor(Executor executor) { |
|
|
|
for ( TaskBatchTubeTestInfo test : this.tests ) { |
|
|
|
if ( !this.testTubeExistsStatus[test.tubeIndex] ) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
String barCode = test.barcode; |
|
|
|
if ( barCode.isEmpty() ) { |
|
|
|
barCode = this.testTubeBarcodes[test.tubeIndex]; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取LIS测试信息 |
|
|
|
LisTestInfo lisTestInfo = device.lis.requestTestInfo(barCode); |
|
|
|
if ( null == lisTestInfo ) { |
|
|
|
lisTestInfo = new LisTestInfo(); |
|
|
|
lisTestInfo.sampleType = ""; |
|
|
|
lisTestInfo.projectNames = new ArrayList<>(); |
|
|
|
} |
|
|
|
lisTestInfo.sampleType = test.blood.isEmpty() ? lisTestInfo.sampleType : test.blood; |
|
|
|
lisTestInfo.projectNames = test.projectNames.isEmpty() ? lisTestInfo.projectNames : test.projectNames; |
|
|
|
|
|
|
|
// 追加测试任务 |
|
|
|
for ( String projectName : lisTestInfo.projectNames ) { |
|
|
|
TaskTestRegular task = new TaskTestRegular(); |
|
|
|
task.tubeIndex = test.tubeIndex; |
|
|
|
task.patientCode = test.patientCode; |
|
|
|
task.tubeType = test.testTube; |
|
|
|
task.barcode = barCode; |
|
|
|
task.projectName = projectName; |
|
|
|
task.bloodType = lisTestInfo.sampleType; |
|
|
|
executor.appendTask(task); |
|
|
|
|
|
|
|
Device.LOG.info("append test task: {}", task.projectName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 入料 |
|
|
|
private void testTubeRackFeed() { |
|
|
|
Integer testTubeExistsInTrack = this.testTubeMovement.readIO(ActModuleTestTubeRackMovement.IO_TEST_TUBE_RACK_EXISTS_IN_TRACK); |
|
|
|