diff --git a/src/main/java/com/dreamworks/boditech/driver/Device.java b/src/main/java/com/dreamworks/boditech/driver/Device.java index a520762..8422d9c 100644 --- a/src/main/java/com/dreamworks/boditech/driver/Device.java +++ b/src/main/java/com/dreamworks/boditech/driver/Device.java @@ -6,7 +6,6 @@ import com.dreamworks.boditech.driver.connection.ComWebsocket; import com.dreamworks.boditech.driver.connection.ComLisClient; import com.dreamworks.boditech.driver.consumable.*; import com.dreamworks.boditech.driver.entity.DeviceLogEntry; -import com.dreamworks.boditech.entity.WebsocketServerMessageErrorEvent; import com.dreamworks.boditech.mapper.DeviceLogMapper; import com.dreamworks.boditech.service.*; import com.dreamworks.boditech.utils.MyByteBuffer; @@ -74,7 +73,7 @@ public class Device { this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_RACK_EXIT_MOTOR, this)); this.appendActuator(new ActCodeScanner(ActuatorModule.TEST_TUBE_RACK_SCANNER, this)); this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR, this)); - this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR, this)); + this.appendActuator(new ActTestTubeCapClipMotor(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR, this)); this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_SHAKING_SHAKE_MOTOR, this)); this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_SHAKING_ROTATE_MOTOR, this)); this.appendActuator(new ActMotor(ActuatorModule.TEST_TUBE_SHAKING_CLIP_MOTOR, this)); diff --git a/src/main/java/com/dreamworks/boditech/driver/actuator/ActTestTubeCapClipMotor.java b/src/main/java/com/dreamworks/boditech/driver/actuator/ActTestTubeCapClipMotor.java new file mode 100644 index 0000000..086c511 --- /dev/null +++ b/src/main/java/com/dreamworks/boditech/driver/actuator/ActTestTubeCapClipMotor.java @@ -0,0 +1,59 @@ +package com.dreamworks.boditech.driver.actuator; +import com.dreamworks.boditech.driver.Device; +import com.dreamworks.boditech.service.RuntimeVariableService; + +import java.util.Map; +public class ActTestTubeCapClipMotor extends ActMotor { + // runtime variable status : empty + public static final String RT_STATUS_EMPTY = "EMPTY"; + // runtime variable status : tube + public static final String RT_STATUS_TUBE = "TUBE"; + // runtime variable status : cap + public static final String RT_STATUS_CAP = "CAP"; + + // constructor + public ActTestTubeCapClipMotor(Integer mid, Device device) { + super(mid, device); + } + + // open + public void open() { + this.moveTo("shakeTestTubeCapClipOpen"); + RuntimeVariableService rtVariables = this.getDevice().runtimeVariableService; + rtVariables.setString("DeviceTubeCapClipStatus", ActTestTubeCapClipMotor.RT_STATUS_EMPTY); + rtVariables.setString("DeviceTubeCapClipTubeType", ""); + } + + // close + public void close() { + this.moveTo("shakeTestTubeCapClipClose"); + RuntimeVariableService rtVariables = this.getDevice().runtimeVariableService; + rtVariables.setString("DeviceTubeCapClipStatus", ActTestTubeCapClipMotor.RT_STATUS_EMPTY); + rtVariables.setString("DeviceTubeCapClipTubeType", ""); + } + + // clip tube body + public void clipTubeBody( String tubeType ) { + this.moveTo("shakeTestTubeCapClipClose"); + RuntimeVariableService rtVariables = this.getDevice().runtimeVariableService; + rtVariables.setString("DeviceTubeCapClipStatus", ActTestTubeCapClipMotor.RT_STATUS_TUBE); + rtVariables.setString("DeviceTubeCapClipTubeType", tubeType); + } + + // clip tube cap + public void clipTubeCap( String tubeType ) { + this.moveTo("shakeTestTubeCapClipClose"); + RuntimeVariableService rtVariables = this.getDevice().runtimeVariableService; + rtVariables.setString("DeviceTubeCapClipStatus", ActTestTubeCapClipMotor.RT_STATUS_CAP); + } + + // get clip status + public String getClipStatus() { + return this.getDevice().runtimeVariableService.getString("DeviceTubeCapClipStatus"); + } + + // get clip tube type + public String getClipTubeType() { + return this.getDevice().runtimeVariableService.getString("DeviceTubeCapClipTubeType"); + } +} diff --git a/src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java b/src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java index e07adc8..47905fe 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java +++ b/src/main/java/com/dreamworks/boditech/driver/task/TaskStartReset.java @@ -2,6 +2,7 @@ package com.dreamworks.boditech.driver.task; import com.dreamworks.boditech.driver.Device; import com.dreamworks.boditech.driver.DeviceRegister; import com.dreamworks.boditech.driver.actuator.*; +import com.dreamworks.boditech.driver.consumable.CsmSampleTube; import com.dreamworks.boditech.driver.entity.IncubatorSlot; import com.dreamworks.boditech.driver.entity.WsMessageEvent; import com.dreamworks.boditech.service.AccountService; @@ -70,19 +71,11 @@ public class TaskStartReset extends TaskBase { ActPipette pipette = (ActPipette)this.device.getActuator(ActuatorModule.ARM_Z_PIPETTE); pipette.initDevice(); - // 05. 摇匀电机复位 - // @TODO : 摇匀电机没有零点,暂时没法复位 - // 06. 试管帽夹复位 - LOG.info("[reset] test tube shaking cap clip motor"); - ActMotor testTubeShakingCapClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR); - testTubeShakingCapClipMotor.moveTo("testTubeShakingCapClipClose"); + this.testTubeCapClipMotorReset(); - // 07. 摇匀升降电机复位 - LOG.info("[reset] test tube shaking move motor"); - ActMotor testTubeShakingMoveMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR); - testTubeShakingMoveMotor.reset(); - this.cleanTestTubeCapClipIfError(); + // 05. 摇匀电机复位 + // @TODO : 摇匀电机没有零点,暂时没法复位 // 08. 试管架电机复位 LOG.info("[reset] test tube rack move motor"); @@ -130,6 +123,57 @@ public class TaskStartReset extends TaskBase { } /** + * 试管帽夹复位 + * - 如果试管帽夹中没有任何东西,直接打开,然后上升到零点,关闭 + * - 如果试管帽夹中有试管,先把试管放到试管架上,然后打开,上升到零点,关闭 + * - 如果试管夹中有试管帽,先判断什么类型的试管,然后盖上试管帽,上升到零点,关闭 + */ + private void testTubeCapClipMotorReset() { + LOG.info("[reset] test tube shaking cap clip motor"); + + ActMotor moveMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR); + ActTestTubeCapClipMotor clipMotor = (ActTestTubeCapClipMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR); + // 没有夹住任何东西,直接打开,然后上升到零点,关闭 + if (ActTestTubeCapClipMotor.RT_STATUS_EMPTY.equals(clipMotor.getClipStatus())) { + clipMotor.open(); + moveMotor.reset(); + clipMotor.close(); + return ; + } + + // 有试管,先把试管放到试管架上,然后打开,上升到零点,关闭 + if ( ActTestTubeCapClipMotor.RT_STATUS_TUBE.equals(clipMotor.getClipStatus()) ) { + moveMotor.reset(); + moveMotor.moveTo("shakeTestTubeMoveCapClip"); + clipMotor.open(); + moveMotor.reset(); + clipMotor.close(); + return ; + } + + // 有试管帽,先判断什么类型的试管,然后盖上试管帽,上升到零点,关闭 + if ( ActTestTubeCapClipMotor.RT_STATUS_CAP.equals(clipMotor.getClipStatus()) ) { + String tubeType = clipMotor.getClipTubeType(); + if (CsmSampleTube.TYPE_BLOOD_TUBE_5ML.equals(tubeType)) { // 5ml全血试管 + ActMotor testTubeShakingClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CLIP_MOTOR); + testTubeShakingClipMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); + + moveMotor.reset(); + moveMotor.moveTo("shakeTestTubeMoveCapClip"); + clipMotor.open(); + moveMotor.moveTo("shakeTestTubeMoveStandby"); + clipMotor.close(); + + testTubeShakingClipMotor.rotate(ActMotor.ROTATE_DIRECTION_COUNTER_CLOCKWISE); + testTubeShakingClipMotor.stop(); + } else if (CsmSampleTube.TYPE_BLOOD_TUBE_3ML.equals(tubeType)) { // 3ml全血试管 + // @TODO : 3ml全血试管暂时没法盖试管帽,试管帽夹需要调整角度,但目前无法调整 + throw new RuntimeException("3ml全血试管暂时没法盖试管帽,试管帽夹需要调整角度,但目前无法调整"); + } + } + } + + /** * 清理孵育盘, 孵育盘卡位状态由数据库获取,清理完成后重置数据库变量。 * 数据库变量由每次获取和释放孵育盘卡位时更新。 */ @@ -190,21 +234,6 @@ public class TaskStartReset extends TaskBase { } } - // clean test tube cap clip if error - private void cleanTestTubeCapClipIfError() { - if ( !Objects.equals(this.mode, TaskStartReset.MODE_ERROR) ) { - return; - } - - // @TODO : 出错的情况下这个时候可能还存在试管,需要把试管放回到试管架上 - // @TODO : 但是这个时候也可能试管不在试管帽夹上 ~~~ 这个目前判断不了 - // @TODO : 额 ~~~ 这个要不然直接忽略掉, 因为前台已经给弹框提示要清理了 ~~~ -// testTubeShakingMoveMotor.moveTo("testTubeShakingCapPickUp"); -// testTubeShakingCapClipMotor.moveTo("testTubeShakingCapClipOpen"); -// testTubeShakingMoveMotor.moveTo("testTubeShakingUpDownStandBy"); -// testTubeShakingCapClipMotor.moveTo("testTubeShakingCapClipClose"); - } - // clean test tube rack track if error private void cleanTestTubeRackTrackIfError() { if ( !Objects.equals(this.mode, TaskStartReset.MODE_ERROR) ) { diff --git a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java b/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java index 4db5297..09e0496 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java +++ b/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java @@ -20,7 +20,7 @@ public class StepPretreatment extends StepBase { // task test private TaskTest taskTest; // test tube cap clip motor - private ActMotor testTubeCapClipMotor; + private ActTestTubeCapClipMotor testTubeCapClipMotor; // test tube move motor private ActMotor testTubeMoveMotor; // test tube shake motor @@ -50,7 +50,7 @@ public class StepPretreatment extends StepBase { this.taskTest = (TaskTest)task; Device device = executor.getDevice(); - this.testTubeCapClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR); + this.testTubeCapClipMotor = (ActTestTubeCapClipMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CAP_CLIP_MOTOR); this.testTubeMoveMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR); this.testTubeShakeMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_SHAKE_MOTOR); this.testTubeClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CLIP_MOTOR); @@ -115,12 +115,13 @@ public class StepPretreatment extends StepBase { // 全血5ml试管 private void shakeBloodTube5ml() { - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); + this.testTubeCapClipMotor.open(); this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipClose"); + this.testTubeCapClipMotor.clipTubeBody(CsmSampleTube.TYPE_BLOOD_TUBE_5ML); this.testTubeMoveMotor.moveTo("shakeTestTubeMoveStandby"); this.shakeMotorExecute(); this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); + this.testTubeCapClipMotor.clipTubeCap(CsmSampleTube.TYPE_BLOOD_TUBE_5ML); this.uncap("shaking"); }