9 changed files with 154 additions and 89 deletions
-
19src/src/main/java/com/my/graphiteDigesterBg/diframe/DiDeviceRegisterManager.java
-
2src/src/main/java/com/my/graphiteDigesterBg/diframe/connection/DiConSerialPort.java
-
93src/src/main/java/com/my/graphiteDigesterBg/move/MoveHeatPlateSlotHeating.java
-
25src/src/main/java/com/my/graphiteDigesterBg/resource/ResHeatingTubeRackSlot.java
-
26src/src/main/java/com/my/graphiteDigesterBg/resource/ResHeatingTubeRackSlotManager.java
-
32src/src/main/java/com/my/graphiteDigesterBg/step/StepHeating.java
-
35src/src/main/java/com/my/graphiteDigesterBg/task/TaskHeating.java
-
9src/src/main/resources/device.yml
-
2src/web/src/pages/main/contents/OperationTubeRackTemperature.vue
@ -0,0 +1,93 @@ |
|||||
|
package com.my.graphiteDigesterBg.move; |
||||
|
import com.my.graphiteDigesterBg.diframe.DiTaskMoveBase; |
||||
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlot; |
||||
|
import com.my.graphiteDigesterBg.resource.ResHeatingTubeRackSlotManager; |
||||
|
import java.util.Timer; |
||||
|
import java.util.TimerTask; |
||||
|
public class MoveHeatPlateSlotHeating extends DiTaskMoveBase { |
||||
|
// finish callback |
||||
|
public interface FinishCallback { |
||||
|
void callback(); |
||||
|
} |
||||
|
|
||||
|
// slot index |
||||
|
public Integer slotIndex; |
||||
|
// temperature |
||||
|
public Integer temperature; |
||||
|
// duration |
||||
|
public Integer duration; |
||||
|
// done callback |
||||
|
private FinishCallback finishCallback; |
||||
|
// slot |
||||
|
private ResHeatingTubeRackSlot slot; |
||||
|
// is heating on |
||||
|
private Boolean isHeatingOn; |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class); |
||||
|
this.slot = slotMan.getSlotByIndex(this.slotIndex); |
||||
|
this.slot.destTemperature = this.temperature * 100; |
||||
|
this.slot.heatingDuration = this.duration * 60; |
||||
|
this.slot.heatingStartedAt = null; |
||||
|
this.slot.isHeating = true; |
||||
|
this.isHeatingOn = false; |
||||
|
|
||||
|
String message = String.format("试管架%d : 开始加热", this.slotIndex); |
||||
|
this.getDevice().getRuntimeVariables().setString(message, "StatusMessage"); |
||||
|
this.heating(); |
||||
|
} |
||||
|
|
||||
|
// on done |
||||
|
public void onFinish( FinishCallback callback ) { |
||||
|
this.finishCallback = callback; |
||||
|
} |
||||
|
|
||||
|
// heating |
||||
|
public void heating() { |
||||
|
String heaterKey = "HeatPlateSlotHeater" + this.slotIndex; |
||||
|
// 如果温度低于目标温度,打开加热器 |
||||
|
if ( this.slot.temperature < this.slot.destTemperature ) { |
||||
|
if ( !this.isHeatingOn ) { |
||||
|
this.getDevice().getIO().setValue(heaterKey, 1); |
||||
|
this.isHeatingOn = true; |
||||
|
} |
||||
|
this.heatingContinue(); |
||||
|
return ; |
||||
|
} |
||||
|
|
||||
|
// 如果温度高于目标温度,关闭加热器 |
||||
|
if ( this.isHeatingOn ) { |
||||
|
this.getDevice().getIO().setValue(heaterKey, 0); |
||||
|
this.isHeatingOn = false; |
||||
|
} |
||||
|
|
||||
|
// 开始计时 |
||||
|
if ( null == this.slot.heatingStartedAt ) { |
||||
|
this.slot.heatingStartedAt = (int)(System.currentTimeMillis()/1000); |
||||
|
} |
||||
|
|
||||
|
// 检查时间到了没有 ~~~ |
||||
|
var duration = System.currentTimeMillis()/1000 - this.slot.heatingStartedAt; |
||||
|
if ( duration > this.slot.heatingDuration ) { |
||||
|
String message = String.format("试管架%d : 加热完成", this.slotIndex); |
||||
|
this.getDevice().getRuntimeVariables().setString(message, "StatusMessage"); |
||||
|
this.slot.isHeating = false; |
||||
|
this.finishCallback.callback(); |
||||
|
return ; |
||||
|
} |
||||
|
|
||||
|
this.heatingContinue(); |
||||
|
} |
||||
|
|
||||
|
// continue heating |
||||
|
private void heatingContinue() { |
||||
|
var timer = new Timer(); |
||||
|
timer.schedule(new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
MoveHeatPlateSlotHeating.this.heating(); |
||||
|
} |
||||
|
}, 5000); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue