|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.dreamworks.boditech.driver.task; |
|
|
|
import com.dreamworks.boditech.driver.Device; |
|
|
|
import com.dreamworks.boditech.driver.actuator.*; |
|
|
|
import com.dreamworks.boditech.entity.MdbTestTube; |
|
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTask; |
|
|
|
import com.dreamworks.boditech.entity.MdbTestTubeRackTestTaskTube; |
|
|
|
import com.dreamworks.boditech.service.TestService; |
|
|
@ -20,6 +21,10 @@ public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
private ActModuleTestTubeRackMovement testTubeMovement; |
|
|
|
// testTubeFeedMotor |
|
|
|
private ActMotor testTubeFeedMotor; |
|
|
|
// testTubeMoveMotor |
|
|
|
private ActMotor testTubeMoveMotor; |
|
|
|
// testTubeScanner |
|
|
|
private ActCodeScanner testTubeScanner; |
|
|
|
// testTubeExistsStatus |
|
|
|
private boolean[] testTubeExistsStatus; |
|
|
|
// testTubeBarcodes |
|
|
@ -49,7 +54,8 @@ public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
this.device = executor.getDevice(); |
|
|
|
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); |
|
|
|
this.testTubeMoveMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_MOVE_MOTOR); |
|
|
|
this.testTubeScanner = (ActCodeScanner)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_SCANNER); |
|
|
|
ActMotor testTubeRotateMotor = (ActMotor) this.device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_ROTATE_MOTOR); |
|
|
|
|
|
|
|
// 01. 入料 |
|
|
@ -60,13 +66,15 @@ public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
int tubeDistance = this.device.getLocationByName("testTubeRackTubeDistance"); |
|
|
|
int existsCheckStartPos = this.device.getLocationByName("testTubeRackExistsCheckStart"); |
|
|
|
for ( int i = 0; i < 10; i++ ) { |
|
|
|
testTubeMoveMotor.moveTo(existsCheckStartPos + i * tubeDistance); |
|
|
|
this.testTubeMoveMotor.moveTo(existsCheckStartPos + i * tubeDistance); |
|
|
|
Integer isExists = this.testTubeMovement.readIO(ActModuleTestTubeRackMovement.IO_TEST_TUBE_EXISTS); |
|
|
|
this.testTubeExistsStatus[i] = Objects.equals(this.device.getIOValueByName("testTubeRackTubeExistsYes"), isExists); |
|
|
|
} |
|
|
|
|
|
|
|
// 03. 试管架类型检测 |
|
|
|
this.testTubeRackTypeDetect(); |
|
|
|
|
|
|
|
// 03. 逐个扫描试管 |
|
|
|
ActCodeScanner testTubeScanner = (ActCodeScanner)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_SCANNER); |
|
|
|
this.testTubeBarcodes = new String[10]; |
|
|
|
int scanStartPos = this.device.getLocationByName("testTubeRackScanStart"); |
|
|
|
for ( int i = 0; i < 10; i++ ) { |
|
|
@ -74,21 +82,15 @@ public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
this.testTubeBarcodes[i] = ""; |
|
|
|
continue ; |
|
|
|
} |
|
|
|
testTubeMoveMotor.moveTo(scanStartPos + i * tubeDistance); |
|
|
|
this.testTubeMoveMotor.moveTo(scanStartPos + i * tubeDistance); |
|
|
|
testTubeRotateMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); |
|
|
|
String code = testTubeScanner.scan(1000); |
|
|
|
String code = this.testTubeScanner.scan(1000); |
|
|
|
testTubeRotateMotor.reset(); |
|
|
|
this.testTubeBarcodes[i] = code; |
|
|
|
} |
|
|
|
|
|
|
|
if ( this.mdbTask.tubeType.isEmpty() ) { |
|
|
|
// @TODO : 试管为空需要扫描试管架了 |
|
|
|
this.mdbTask.tubeType = "BloodTube5ml"; |
|
|
|
this.testService.regularTaskUpdate(this.mdbTask); |
|
|
|
} |
|
|
|
|
|
|
|
// 04. 扫描完成后推送到预备区域 |
|
|
|
testTubeMoveMotor.moveTo("testTubeRackStandby"); |
|
|
|
this.testTubeMoveMotor.moveTo("testTubeRackStandby"); |
|
|
|
|
|
|
|
this.appendTestTasksToExecutor(executor); |
|
|
|
TaskBatchTubeExit exitTask = new TaskBatchTubeExit(); |
|
|
@ -158,4 +160,38 @@ public class TaskTestTubeRackPrepare extends TaskBase { |
|
|
|
// 任然没有找到 |
|
|
|
throw new AppRuntimeException(AppError.TEST_TUBE_RACK_FEED_RACK_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
// 试管架类型检测 |
|
|
|
private void testTubeRackTypeDetect() { |
|
|
|
if ( !this.mdbTask.tubeType.isEmpty() ) { |
|
|
|
return ; |
|
|
|
} |
|
|
|
|
|
|
|
this.testTubeMoveMotor.moveTo("testTubeRackTubeTypeScan"); |
|
|
|
String typeCode = this.testTubeScanner.scan(1000); |
|
|
|
if ( "0000".equals(typeCode) ) { |
|
|
|
// 如果是全血试管架,还需要检查当前是高试管还是低试管 ~~~ |
|
|
|
// !!! 禁止一个试管架中既有高试管又有低试管 |
|
|
|
ActMotor testTubeCapClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR); |
|
|
|
ActMotor testTubeShakeMoveMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR); |
|
|
|
|
|
|
|
this.testTubeMoveMotor.moveTo("testTubeRackTubeSamplingStart"); |
|
|
|
testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); |
|
|
|
testTubeShakeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); |
|
|
|
testTubeCapClipMotor.moveTo("shakeTestTubeCapClipClose"); |
|
|
|
Integer clipMotorPos = testTubeCapClipMotor.readPos(); |
|
|
|
Integer btHighThreshold = this.device.getLocationByName("shakeTestTubeCapClipCloseBTHighThreshold"); |
|
|
|
typeCode = btHighThreshold > clipMotorPos ? "0000H" : "0000L"; |
|
|
|
testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); |
|
|
|
testTubeShakeMoveMotor.reset(); |
|
|
|
testTubeCapClipMotor.moveTo("shakeTestTubeCapClipClose"); |
|
|
|
} |
|
|
|
|
|
|
|
MdbTestTube testTube = this.testService.testTubeFindByCode(typeCode); |
|
|
|
if ( null == testTube ) { |
|
|
|
throw new AppRuntimeException(AppError.TEST_TUBE_RACK_TYPE_NOT_SUPPORTED); |
|
|
|
} |
|
|
|
this.mdbTask.tubeType = testTube.key; |
|
|
|
this.testService.regularTaskUpdate(this.mdbTask); |
|
|
|
} |
|
|
|
} |