8 changed files with 217 additions and 53 deletions
-
33src/src/main/java/com/my/graphiteDigesterBg/step/StepHeating.java
-
28src/src/main/java/com/my/graphiteDigesterBg/step/StepHeatingStart.java
-
22src/src/main/java/com/my/graphiteDigesterBg/step/StepHeatingStop.java
-
34src/src/main/java/com/my/graphiteDigesterBg/step/StepPump.java
-
40src/src/main/java/com/my/graphiteDigesterBg/step/StepTakeOut.java
-
36src/src/main/java/com/my/graphiteDigesterBg/step/StepTempDownWait.java
-
42src/src/main/java/com/my/graphiteDigesterBg/step/StepTempKeepDelay.java
-
35src/src/main/java/com/my/graphiteDigesterBg/step/StepTempRiseWait.java
@ -1,33 +0,0 @@ |
|||||
package com.my.graphiteDigesterBg.step; |
|
||||
import com.my.graphiteDigesterBg.diframe.DiTask; |
|
||||
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
|
||||
import com.my.graphiteDigesterBg.diframe.TaskStep; |
|
||||
import com.my.graphiteDigesterBg.move.MoveHeatPlateSlotHeating; |
|
||||
import com.my.graphiteDigesterBg.task.TaskDigestion; |
|
||||
import org.slf4j.Logger; |
|
||||
import org.slf4j.LoggerFactory; |
|
||||
@TaskStep(name="Heating") |
|
||||
public class StepHeating extends DiTaskStepBase { |
|
||||
// logger |
|
||||
public static final Logger LOG = LoggerFactory.getLogger(StepHeating.class); |
|
||||
// temperature |
|
||||
public Integer temperature; |
|
||||
// duration in minutes |
|
||||
public Integer duration; |
|
||||
|
|
||||
@Override |
|
||||
public void run() { |
|
||||
var task = this.getTask(TaskDigestion.class); |
|
||||
|
|
||||
var heating = new MoveHeatPlateSlotHeating(); |
|
||||
heating.slotIndex = task.slotIndex; |
|
||||
heating.temperature = this.temperature; |
|
||||
heating.duration = this.duration; |
|
||||
heating.setDevice(task.getDevice()); |
|
||||
heating.onFinish(() -> { |
|
||||
task.setStatus(DiTask.TaskStatus.READY); |
|
||||
}); |
|
||||
heating.run(); |
|
||||
task.setStatus(DiTask.TaskStatus.WAITING); |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,28 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActHeater; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
@TaskStep(name="HeatingStart") |
||||
|
public class StepHeatingStart extends DiTaskStepBase { |
||||
|
// temperature |
||||
|
public Integer temperature; |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
var task = this.getTask(TaskDigestion.class); |
||||
|
var slot = task.getSlot(); |
||||
|
|
||||
|
var heaterKey = "HeatingPlateSlotHeater_" + slot.index; |
||||
|
var heater = this.getActuator(heaterKey, DiActHeater.class); |
||||
|
heater.setTemperature(this.temperature); |
||||
|
heater.start(); |
||||
|
|
||||
|
slot.isHeating = true; |
||||
|
slot.srcTemperature = heater.getTemperature() * 100; |
||||
|
slot.destTemperature = this.temperature * 100; |
||||
|
slot.heatingStartedAt = null; |
||||
|
String message = String.format("试管架%d : 开始加热", slot.index); |
||||
|
this.getTask().getDevice().getRuntimeVariables().setString(message, "StatusMessage"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActHeater; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
@TaskStep(name="HeatingStop") |
||||
|
public class StepHeatingStop extends DiTaskStepBase { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
var task = this.getTask(TaskDigestion.class); |
||||
|
var slot = task.getSlot(); |
||||
|
|
||||
|
slot.isHeating = false; |
||||
|
slot.destTemperature = null; |
||||
|
String message = String.format("试管架%d : 停止加热", slot.index); |
||||
|
this.getTask().getDevice().getRuntimeVariables().setString(message, "StatusMessage"); |
||||
|
|
||||
|
var heaterKey = "HeatingPlateSlotHeater_" + slot.index; |
||||
|
var heater = this.getActuator(heaterKey, DiActHeater.class); |
||||
|
heater.stop(); |
||||
|
} |
||||
|
} |
@ -1,46 +1,40 @@ |
|||||
package com.my.graphiteDigesterBg.step; |
package com.my.graphiteDigesterBg.step; |
||||
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
import com.my.graphiteDigesterBg.diframe.TaskStep; |
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
||||
import com.my.graphiteDigesterBg.move.MoveLiquidAdd; |
import com.my.graphiteDigesterBg.move.MoveLiquidAdd; |
||||
import com.my.graphiteDigesterBg.move.MoveMoveTubeRackFromHeatPlateToLiquidPlate; |
|
||||
import com.my.graphiteDigesterBg.move.MoveMoveTubeRackFromLiquidPlateToHeatPlate; |
|
||||
|
import com.my.graphiteDigesterBg.resource.ResAcidManager; |
||||
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
||||
import com.my.graphiteDigesterBg.task.TaskDigestion; |
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
|
||||
@TaskStep(name="Pump") |
@TaskStep(name="Pump") |
||||
public class StepPump extends DiTaskStepBase { |
public class StepPump extends DiTaskStepBase { |
||||
// type |
// type |
||||
public String type; |
public String type; |
||||
// amount |
// amount |
||||
public Integer amount; |
public Integer amount; |
||||
// shake |
|
||||
public Integer shake; |
|
||||
|
|
||||
@Override |
@Override |
||||
public void run() { |
public void run() { |
||||
var task = (TaskDigestion)this.getTask(); |
var task = (TaskDigestion)this.getTask(); |
||||
|
var slot = task.getSlot(); |
||||
|
if (!ResHeatingTubeRackSlot.LOCATION_LIQUID_PLATE.equals(slot.rackPosition)) { |
||||
|
task.throwException("试管架尚未移至加液区域,无法执行加液操作"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
// @TODO : 这里需要检查加液盘是否为空, 如果不为空则需要等待 ~~~ |
|
||||
|
|
||||
// move tube rack from heat plate to liquid plate |
|
||||
var moveTubeRackFromHeatPlateToLiquidPlate = new MoveMoveTubeRackFromHeatPlateToLiquidPlate(); |
|
||||
moveTubeRackFromHeatPlateToLiquidPlate.setDevice(task.getDevice()); |
|
||||
moveTubeRackFromHeatPlateToLiquidPlate.slotIndex = task.slotIndex; |
|
||||
moveTubeRackFromHeatPlateToLiquidPlate.run(); |
|
||||
|
var liquidBucketMan = task.getResourceManager(ResAcidManager.class); |
||||
|
var bucket = liquidBucketMan.getBucketByAcidType(this.type); |
||||
|
var totalVolume = this.amount * 16; |
||||
|
if ( bucket.volume < totalVolume ) { |
||||
|
throw new RuntimeException("酸液不足, 无法执行加液操作"); |
||||
|
} |
||||
|
|
||||
// add liquid |
// add liquid |
||||
var liquidAdd = new MoveLiquidAdd(); |
var liquidAdd = new MoveLiquidAdd(); |
||||
liquidAdd.setDevice(task.getDevice()); |
liquidAdd.setDevice(task.getDevice()); |
||||
liquidAdd.shakeTimes = this.shake; |
|
||||
|
liquidAdd.shakeTimes = 0; |
||||
liquidAdd.liquidType = this.type; |
liquidAdd.liquidType = this.type; |
||||
liquidAdd.liquidVolume = this.amount; |
liquidAdd.liquidVolume = this.amount; |
||||
liquidAdd.slotIndex = task.slotIndex; |
liquidAdd.slotIndex = task.slotIndex; |
||||
liquidAdd.run(); |
liquidAdd.run(); |
||||
|
|
||||
// move tube rack from liquid plate to heat plate |
|
||||
var moveTubeRackFromLiquidPlateToHeatPlate = new MoveMoveTubeRackFromLiquidPlateToHeatPlate(); |
|
||||
moveTubeRackFromLiquidPlateToHeatPlate.setDevice(task.getDevice()); |
|
||||
moveTubeRackFromLiquidPlateToHeatPlate.slotIndex = task.slotIndex; |
|
||||
moveTubeRackFromLiquidPlateToHeatPlate.run(); |
|
||||
} |
} |
||||
} |
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbNotification; |
||||
|
import com.my.graphiteDigesterBg.move.MoveDoorClose; |
||||
|
import com.my.graphiteDigesterBg.move.MoveDoorOpen; |
||||
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
@TaskStep(name="TakeOut") |
||||
|
public class StepTakeOut extends DiTaskStepBase { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
var task = (TaskDigestion)this.getTask(); |
||||
|
var slot = task.getSlot(); |
||||
|
if ( !ResHeatingTubeRackSlot.LOCATION_LIQUID_PLATE.equals(slot.rackPosition) ) { |
||||
|
task.throwException("试管架尚未移至加液区域,无法执行取出操作"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// door open |
||||
|
var moveDoorOpen = new MoveDoorOpen(); |
||||
|
moveDoorOpen.setDevice(task.getDevice()); |
||||
|
moveDoorOpen.run(); |
||||
|
|
||||
|
DiMdbNotification.taskAction(task,"TaskDigestionStepTakeOut"); |
||||
|
task.waitAction("TaskDigestionStepTakeOut"); |
||||
|
|
||||
|
// door close |
||||
|
var moveDoorClose = new MoveDoorClose(); |
||||
|
moveDoorClose.setDevice(task.getDevice()); |
||||
|
moveDoorClose.run(); |
||||
|
} |
||||
|
|
||||
|
// action done |
||||
|
public void actionDone() { |
||||
|
var task = (TaskDigestion)this.getTask(); |
||||
|
var action = task.getAction("TaskDigestionStepTakeOut"); |
||||
|
action.finish(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActHeater; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
import java.util.Timer; |
||||
|
import java.util.TimerTask; |
||||
|
@TaskStep(name="TempDownWait") |
||||
|
public class StepTempDownWait extends DiTaskStepBase { |
||||
|
// temperature |
||||
|
public Integer temperature; |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
TaskDigestion task = (TaskDigestion)this.getTask(); |
||||
|
var slot = task.getSlot(); |
||||
|
|
||||
|
var heaterKey = "HeatingPlateSlotHeater_" + slot.index; |
||||
|
var heater = this.getActuator(heaterKey, DiActHeater.class); |
||||
|
var temperature = heater.getTemperature(); |
||||
|
|
||||
|
if ( temperature <= this.temperature ) { |
||||
|
return ; |
||||
|
} |
||||
|
|
||||
|
task.setStatus(TaskDigestion.TaskStatus.STEP_WAITING); |
||||
|
var timerTask = new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
task.setStatus(TaskDigestion.TaskStatus.READY); |
||||
|
} |
||||
|
}; |
||||
|
var timer = new Timer(); |
||||
|
timer.schedule(timerTask, 5000); |
||||
|
} |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTask; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
import java.util.Timer; |
||||
|
import java.util.TimerTask; |
||||
|
@TaskStep(name="TempKeepDelay") |
||||
|
public class StepTempKeepDelay extends DiTaskStepBase { |
||||
|
// duration in minutes |
||||
|
public Integer duration; |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
TaskDigestion task = (TaskDigestion)this.getTask(); |
||||
|
var slot = task.getSlot(); |
||||
|
|
||||
|
if ( null == slot.heatingStartedAt ) { |
||||
|
LOG.info("[Heating Slot {}] start countdown", slot.index); |
||||
|
slot.heatingStartedAt = (int)(System.currentTimeMillis()/1000); |
||||
|
slot.heatingDuration = this.duration * 60; |
||||
|
} |
||||
|
|
||||
|
var duration = System.currentTimeMillis()/1000 - slot.heatingStartedAt; |
||||
|
if ( duration > slot.heatingDuration ) { // 时间到了 |
||||
|
slot.heatingStartedAt = null; |
||||
|
slot.heatingDuration = null; |
||||
|
return ; |
||||
|
} |
||||
|
|
||||
|
// 5秒后再次检查 |
||||
|
task.setStatus(DiTask.TaskStatus.STEP_WAITING); |
||||
|
var timerTask = new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
task.setStatus(DiTask.TaskStatus.READY); |
||||
|
} |
||||
|
}; |
||||
|
var timer = new Timer(); |
||||
|
timer.schedule(timerTask, 5000); |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package com.my.graphiteDigesterBg.step; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskStepBase; |
||||
|
import com.my.graphiteDigesterBg.diframe.TaskStep; |
||||
|
import com.my.graphiteDigesterBg.diframe.actuator.DiActHeater; |
||||
|
import com.my.graphiteDigesterBg.task.TaskDigestion; |
||||
|
import java.util.Timer; |
||||
|
import java.util.TimerTask; |
||||
|
@TaskStep(name="TempRiseWait") |
||||
|
public class StepTempRiseWait extends DiTaskStepBase { |
||||
|
// temperature |
||||
|
public Integer temperature; |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
TaskDigestion task = (TaskDigestion) this.getTask(); |
||||
|
var slot = task.getSlot(); |
||||
|
|
||||
|
var heaterKey = "HeatingPlateSlotHeater_" + slot.index; |
||||
|
var heater = this.getActuator(heaterKey, DiActHeater.class); |
||||
|
var temperature = heater.getTemperature(); |
||||
|
if ( temperature >= this.temperature ) { |
||||
|
return ; |
||||
|
} |
||||
|
|
||||
|
task.setStatus(TaskDigestion.TaskStatus.STEP_WAITING); |
||||
|
var timerTask = new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
task.setStatus(TaskDigestion.TaskStatus.READY); |
||||
|
} |
||||
|
}; |
||||
|
var timer = new Timer(); |
||||
|
timer.schedule(timerTask, 5000); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue