|
|
@ -4,13 +4,18 @@ import com.dreamworks.boditech.driver.DeviceRegister; |
|
|
|
import com.dreamworks.boditech.driver.actuator.*; |
|
|
|
import com.dreamworks.boditech.driver.entity.IncubatorSlot; |
|
|
|
import com.dreamworks.boditech.driver.entity.WsMessageEvent; |
|
|
|
import com.dreamworks.boditech.service.AccountService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
public class TaskStartReset extends TaskBase { |
|
|
|
// mode : normal |
|
|
|
public static final Integer MODE_NORMAL = 0; |
|
|
|
// mode : error |
|
|
|
public static final Integer MODE_ERROR = 1; |
|
|
|
|
|
|
|
// logger |
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(TaskStartReset.class); |
|
|
|
// reset mode |
|
|
|
public Integer mode = MODE_NORMAL; |
|
|
|
// device instance |
|
|
@ -24,92 +29,89 @@ public class TaskStartReset extends TaskBase { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void execute(Executor executor) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
this.device = executor.getDevice(); |
|
|
|
this.analysisPushMotor = (ActMotor)device.getActuator(ActuatorModule.ANALYSIS_PUSH_MOTOR); |
|
|
|
this.analysisScanMotor = (ActMotor)device.getActuator(ActuatorModule.ANALYSIS_SCAN_MOTOR); |
|
|
|
if ( !this.device.enable ) { |
|
|
|
return ; |
|
|
|
} |
|
|
|
|
|
|
|
//01. 试管夹复位 |
|
|
|
LOG.info("[reset] test tube shaking clip motor"); |
|
|
|
ActMotor testTubeShakingClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CLIP_MOTOR); |
|
|
|
testTubeShakingClipMotor.reset(); |
|
|
|
this.sendResetStepMessage("TEST_TUBE_SHAKING_CLIP_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 02. 试管夹旋转复位 |
|
|
|
LOG.info("[reset] test tube shaking clip rotate motor"); |
|
|
|
ActMotor testTubeShakingClipRotateMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_ROTATE_MOTOR); |
|
|
|
testTubeShakingClipRotateMotor.reset(); |
|
|
|
this.sendResetStepMessage("TEST_TUBE_SHAKING_CLIP_ROTATE_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 03. 机械臂Z轴复位 |
|
|
|
LOG.info("[reset] arm z motor"); |
|
|
|
ActMotor armZMotor = (ActMotor)device.getActuator(ActuatorModule.ARM_Z_MOTOR); |
|
|
|
armZMotor.reset(); |
|
|
|
this.sendResetStepMessage("ARM_Z_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 04. 机械臂XY轴复位 |
|
|
|
LOG.info("[reset] arm xy motor"); |
|
|
|
ActArmXY armXY = (ActArmXY)device.getActuator(ActuatorModule.ARM_XY); |
|
|
|
armXY.reset(); |
|
|
|
this.sendResetStepMessage("ARM_XY_RESET"); |
|
|
|
|
|
|
|
// 05. 丢弃移液枪头 |
|
|
|
// 05. 初始化移液枪头 |
|
|
|
LOG.info("[reset] pipette"); |
|
|
|
ActPipette pipette = (ActPipette)this.device.getActuator(ActuatorModule.ARM_Z_PIPETTE); |
|
|
|
pipette.dropTip(); |
|
|
|
armXY.reset(); |
|
|
|
this.sendResetStepMessage("ARM_Z_PIPETTE_DROP_TIP"); |
|
|
|
pipette.initDevice(); |
|
|
|
|
|
|
|
// 05. 摇匀电机复位 |
|
|
|
// @TODO : 摇匀电机没有零点,暂时没法复位 |
|
|
|
this.sendResetStepMessage("TEST_TUBE_SHAKING_SHAKE_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 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.sendResetStepMessage("TEST_TUBE_SHAKING_CAP_CLIP_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 07. 摇匀升降电机复位 |
|
|
|
LOG.info("[reset] test tube shaking move motor"); |
|
|
|
ActMotor testTubeShakingMoveMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_MOVE_MOTOR); |
|
|
|
testTubeShakingMoveMotor.reset(); |
|
|
|
this.sendResetStepMessage("TEST_TUBE_SHAKING_MOVE_MOTOR_RESET"); |
|
|
|
this.cleanTestTubeCapClipIfError(); |
|
|
|
|
|
|
|
// 08. 试管架电机复位 |
|
|
|
LOG.info("[reset] test tube rack move motor"); |
|
|
|
ActMotor testTubeRackMoveMotor = (ActMotor) device.getActuator(ActuatorModule.TEST_TUBE_RACK_MOVE_MOTOR); |
|
|
|
testTubeRackMoveMotor.reset(); |
|
|
|
this.sendResetStepMessage("TEST_TUBE_RACK_MOVE_MOTOR_RESET"); |
|
|
|
this.cleanTestTubeRackTrackIfError(); |
|
|
|
|
|
|
|
// 09. 板夹仓推杆电机复位 |
|
|
|
LOG.info("[reset] test card feed motor"); |
|
|
|
this.testCardFeedMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_CARD_FEED_MOTOR); |
|
|
|
this.cleanTestCardFeedTrackIfError(); |
|
|
|
this.testCardFeedMotor.reset(); |
|
|
|
this.testCardFeedMotor.moveTo("testCardFeedStandBy"); |
|
|
|
this.sendResetStepMessage("TEST_CARD_FEED_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 10. 板夹仓复位 |
|
|
|
LOG.info("[reset] test card box motor"); |
|
|
|
ActMotor testCardBoxMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_CARD_BOX_MOTOR); |
|
|
|
testCardBoxMotor.reset(); |
|
|
|
this.sendResetStepMessage("TEST_CARD_BOX_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 11. 光学扫描电机复位 |
|
|
|
LOG.info("[reset] analysis scan motor"); |
|
|
|
this.analysisScanMotor.reset(); |
|
|
|
this.analysisScanMotor.moveTo("analysisScanMotorStandBy"); |
|
|
|
this.sendResetStepMessage("ANALYSIS_SCAN_MOTOR_RESET"); |
|
|
|
|
|
|
|
this.cleanAnalysisPullTrackIfError(); |
|
|
|
|
|
|
|
// 12. 孵育盘电机复位 |
|
|
|
LOG.info("[reset] incubator motor"); |
|
|
|
ActIncubator incubatorMotor = (ActIncubator)device.getActuator(ActuatorModule.INCUBATOR_MOTOR); |
|
|
|
incubatorMotor.reset(); |
|
|
|
this.sendResetStepMessage("INCUBATOR_MOTOR_RESET"); |
|
|
|
|
|
|
|
// 11. 光学推杆电机复位 |
|
|
|
IncubatorSlot incubatorSlot = incubatorMotor.getFreeSlot(); |
|
|
|
LOG.info("[reset] analysis push motor"); |
|
|
|
IncubatorSlot incubatorSlot = incubatorMotor.getSlotByIndex(10); |
|
|
|
incubatorMotor.moveTo(incubatorSlot.getExitLocation()); |
|
|
|
this.analysisPushMotor.reset(); |
|
|
|
this.analysisPushMotor.moveTo("analysisPushMotorStandby"); |
|
|
|
this.sendResetStepMessage("ANALYSIS_PUSH_MOTOR_RESET"); |
|
|
|
|
|
|
|
this.cleanIncubatorIfError(); |
|
|
|
|
|
|
|
LOG.info("[reset] task finished, cost {}s", (System.currentTimeMillis() - startTime)/1000.00); |
|
|
|
} |
|
|
|
|
|
|
|
// clean incubator if error |
|
|
@ -185,12 +187,4 @@ public class TaskStartReset extends TaskBase { |
|
|
|
ActMotor testTubeRackFeedMotor = (ActMotor)this.device.getActuator(ActuatorModule.TEST_TUBE_RACK_FEED_MOTOR); |
|
|
|
testTubeRackFeedMotor.moveTo(500); |
|
|
|
} |
|
|
|
|
|
|
|
// send reset step message |
|
|
|
private void sendResetStepMessage( String message ) { |
|
|
|
WsMessageEvent event = new WsMessageEvent(); |
|
|
|
event.name = "RESET_STEP_UPDATE"; |
|
|
|
event.data = message; |
|
|
|
this.device.websocketServerService.send(event); |
|
|
|
} |
|
|
|
} |