sige 1 year ago
parent
commit
5b673f24d7
  1. BIN
      app.db
  2. 178
      src/main/java/com/iflytop/digester/StartResetTaskThread.java
  3. 18
      src/main/java/com/iflytop/digester/deviceinstance/HeatingTurntableInstance.java
  4. 5
      src/main/java/com/iflytop/digester/deviceinstance/HeatingTurntableSlot.java
  5. 23
      src/main/java/com/iflytop/digester/deviceinstance/LiquidAdditionInstance.java
  6. 3
      src/main/resources/application.yml
  7. 2
      web

BIN
app.db

178
src/main/java/com/iflytop/digester/StartResetTaskThread.java

@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StartResetTaskThread extends Thread {
@ -27,98 +28,61 @@ public class StartResetTaskThread extends Thread {
this.setProgressMessage("设备初始化...");
UfCmdSnippetExecutor.execute("StartResetInitDevices");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
// this.setupHeatingSlotCover();
// this.setupPeristalticPump();
if ( this.isErrorTubeRackRequired ) {
this.setupErrorTubeRack();
}
this.setupHeatingSlotCover();
// this.setupPeristalticPump();
//
// this.setProgressMessage("设备初始化 : 相机");
// DiActCameraBasler camera = this.getActuator(MyDevice.ACT_CAMERA, DiActCameraBasler.class);
// camera.setEnable(true);
//
// this.setProgressMessage("设备初始化 : 定时刷新加热盘温度");
// var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class);
// slotMan.startTemperatureRefresh();
//
// if ( this.isErrorTubeRackRequired ) {
// this.setProgressMessage("设备初始化 : 放入异常处理试管架");
// doorMotor.reset(); // 打开设备门
// DiMdbNotification.taskAction(this, "TaskStartResetErrorTubeRackPutIn");
// this.waitAction("TaskStartResetErrorTubeRackPutIn");
// }
//
// this.getDevice().getIO().setValue("LightRed", 0);
// this.getDevice().getIO().setValue("LightGreen", 1);
this.setProgressMessage("设备初始化 : 定时刷新加热盘温度");
device.heatingTurntable.temperatureMonitorStart();
UfCmdSnippetExecutor.execute("StatusLampRunning");
this.setProgressMessage("设备初始化 : 完成");
device.setStatus("ready");
UfMdbRuntimeVariable.setString("设备已就绪","device.message");
}
//
// // 设置蠕动泵
// private void setupPeristalticPump() {
// int peristalticPumpCount = 1;
// var actuators = this.getDevice().getActuators().getAll();
// for ( var actuator : actuators ) {
// if (actuator instanceof DiActPeristalticPump pump) {
// this.setProgressMessage("设备初始化 : 蠕动泵复位 " + peristalticPumpCount + "/16");
// pump.setEnable(true);
// peristalticPumpCount++;
// }
// }
//
// Boolean enableSetup = this.getDevice().getEnv().getProperty("app.liquidPeristalticPumpPipeSetupEnable",Boolean.class);
// assert enableSetup != null;
// if ( !enableSetup ) {
// return ;
// }
//
// DiActMotor liquidPlateMotor = this.getActuator(MyDevice.ACT_LIQUID_PLATE_MOTOR, DiActMotor.class);
// DiActMotor liquidMotor = this.getActuator(MyDevice.ACT_LIQUID_MOTOR, DiActMotor.class);
//
// this.setProgressMessage("设备初始化 : 初始化加液管路");
// MoveDoorOpen.execute(this.getDevice());
// DiMdbNotification.taskAction(this, "TaskStartResetPumpPipeSetupTubeRankPutIn");
// this.waitAction("TaskStartResetPumpPipeSetupTubeRankPutIn");
// MoveDoorClose.execute(this.getDevice());
//
// // 加液管充满
// for ( int i=0; i<8; i++ ) {
// 设置蠕动泵
private void setupPeristalticPump() {
for ( int i=0; i<16; i++ ) {
// this.setProgressMessage("设备初始化 : 初始化蠕动泵 " + (i+1) + "/16");
// UfCmdSnippetExecutor.execute(String.format("PeristalticPumpEnable.%d",i));
}
Boolean enableSetup = UfApplication.getApp().getEnv().getProperty("app.liquidPeristalticPumpPipeSetupEnable",Boolean.class);
assert enableSetup != null;
if ( !enableSetup ) {
return ;
}
this.setProgressMessage("设备初始化 : 初始化加液管路");
UfCmdSnippetExecutor.execute("DoorOpen");
UfMdbNotification.action("TaskStartResetPumpPipeSetupTubeRankPutIn", new HashMap<>());
this.waitAction("TaskStartResetPumpPipeSetupTubeRankPutIn");
UfCmdSnippetExecutor.execute("DoorClose");
// 加液管充满
Device device = Device.getInstance();
var tubes = List.of(0,4, 3,2, 15,11, 12,13, 1,5, 6,7, 14,10, 9,8);
for ( int i=0; i<8; i++ ) {
// this.setProgressMessage("设备初始化 : 初始化加液管路 " + (i+1) + "/8");
// if ( 0 == i%2 ) {
// liquidMotor.moveTo("LiquidArmPumpGroupOut");
// liquidPlateMotor.moveTo("LiquidPlateSlotPumpOutGroup",i/2);
// } else {
// liquidMotor.moveTo("LiquidArmPumpGroupIn");
// liquidPlateMotor.moveTo("LiquidPlateSlotPumpInGroup", i/2);
// }
//
// var pump0 = this.getActuator("LiquidPeristalticPump_"+i+"_0", DiActPeristalticPump.class);
// var pump1 = this.getActuator("LiquidPeristalticPump_"+i+"_1", DiActPeristalticPump.class);
// var pipeVolumeCircle0 = pump1.getLocationValue("LiquidPeristalticPumpPipeVolumeCircle",i, 0);
// var pipeVolumeCircle1 = pump1.getLocationValue("LiquidPeristalticPumpPipeVolumeCircle",i, 1);
// this.batchExecute(List.of(
// () -> pump0.moveBy(pipeVolumeCircle0),
// () -> pump1.moveBy(pipeVolumeCircle1)
// ));
// pump0.retract();
// pump1.retract();
// }
//
// liquidMotor.moveTo("LiquidArmStandby");
//
// // 加液管充满, 需要取出试管架
// MoveDoorOpen.execute(this.getDevice());
// DiMdbNotification.taskAction(this, "TaskStartResetPumpPipeSetupTubeRankTakeOut");
// this.waitAction("TaskStartResetPumpPipeSetupTubeRankTakeOut");
// MoveDoorClose.execute(this.getDevice());
// }
//
// var tubeList = tubes.subList(i*2, i*2+2);
// var pumpList = List.of(2*i, 2*i+1);
// device.liquidAddition.addLiquidToTubes(tubeList, pumpList, 10000);
}
// 加液管充满, 需要取出试管架
UfCmdSnippetExecutor.execute("DoorOpen");
UfMdbNotification.action("TaskStartResetPumpPipeSetupTubeRankTakeOut", new HashMap<>());
this.waitAction("TaskStartResetPumpPipeSetupTubeRankTakeOut");
UfCmdSnippetExecutor.execute("DoorClose");
}
/**
* 清理试管架
* @issue : <a href="http://127.0.0.1:5566/issues/85">无法获取加液位置是否存在试管架</a>
@ -173,43 +137,21 @@ public class StartResetTaskThread extends Thread {
UfCmdSnippetExecutor.execute("DoorClose");
}
}
//
// // 异常处理位试管架取出
// public void actionErrorTubeRackTakeOut() {
// var action = this.getAction("TaskStartResetErrorTubeRackTakeOut");
// action.finish();
// }
//
// // 放入异常处理位试管架
// public void actionErrorTubeRackPutIn() {
// var slotMan = this.getResourceManager(ResHeatingTubeRackSlotManager.class);
// var slot = slotMan.getErrorSlot();
//
// // 关闭设备门
// DiActMotor doorMotor = this.getActuator(MyDevice.ACT_DOOR_MOTOR, DiActMotor.class);
// doorMotor.moveToIO(1, 1);
//
// var move = new MoveMoveTubeRackFromLiquidPlateToHeatPlate();
// move.slotIndex = slot.index;
// move.setDevice(this.getDevice());
// move.run();
// slot.lock();
//
// var action = this.getAction("TaskStartResetErrorTubeRackPutIn");
// action.finish();
// }
//
// // 蠕动泵管路初始化
// public void actionPumpPipeSetupTubeRankPutIn() {
// var action = this.getAction("TaskStartResetPumpPipeSetupTubeRankPutIn");
// action.finish();
// }
//
// // 蠕动泵管路初始化
// public void actionPumpPipeSetupTubeRankTakeOut() {
// var action = this.getAction("TaskStartResetPumpPipeSetupTubeRankTakeOut");
// action.finish();
// }
// 放入异常处理位试管架
public void setupErrorTubeRack() {
Integer errorSlotIndex = UfApplication.getApp().getEnv().getProperty("app.errorSlotIndex", Integer.class);
this.setProgressMessage("设备初始化 : 放入异常处理试管架");
UfCmdSnippetExecutor.execute("DoorOpen");
UfMdbNotification.action("TaskStartResetErrorTubeRackPutIn", new HashMap<>());
this.waitAction("TaskStartResetErrorTubeRackPutIn");
// 关闭设备门
UfCmdSnippetExecutor.execute("DoorClose");
// 移动试管架至异常处理区
UfCmdSnippetExecutor.execute(String.format("TubeRackMoveToHeatingTurntable.%d", errorSlotIndex));
Device.getInstance().heatingTurntable.getSlotByIndex(errorSlotIndex).setTubeRackNo("ErrorSlot");
}
// wait for continue
private void waitAction( String key ) {

18
src/main/java/com/iflytop/digester/deviceinstance/HeatingTurntableInstance.java

@ -3,6 +3,8 @@ import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.TimerTask;
@Component
public class HeatingTurntableInstance {
// 槽位列表
@ -47,6 +49,22 @@ public class HeatingTurntableInstance {
throw new RuntimeException("加热位已满, 无法分配新的加热位");
}
// 启动温度监控
public void temperatureMonitorStart() {
for (HeatingTurntableSlot slot : slots) {
slot.refreshCurTemperature();
}
var timerTask = new TimerTask() {
@Override
public void run() {
HeatingTurntableInstance.this.temperatureMonitorStart();
}
};
var timer = new java.util.Timer();
timer.schedule(timerTask, 5000);
}
// public void heating(Integer index, Integer temperature, Integer duration ) throws InterruptedException {
// // 执行加热
// }

5
src/main/java/com/iflytop/digester/deviceinstance/HeatingTurntableSlot.java

@ -73,4 +73,9 @@ public class HeatingTurntableSlot {
public void setTubeRackLocation( String location ) {
this.tubeRackLocation = location;
}
// 刷新当前温度
public void refreshCurTemperature() {
}
}

23
src/main/java/com/iflytop/digester/deviceinstance/LiquidAdditionInstance.java

@ -36,38 +36,34 @@ public class LiquidAdditionInstance {
return this.liquids.get(index);
}
// 针对试管加液
public void addLiquidToTubes(List<Integer> tubes, String type, int volume ) {
var pumpIndexes = this.getPumpIndexForGroupOutAndIn(type);
// add liquid to tubes by given pump indexes
public void addLiquidToTubes(List<Integer> tubes, List<Integer> pumpIndexes, int volume ) {
var pumpGroupOutIndex = pumpIndexes.get(0);
var pumpGroupInIndex = pumpIndexes.get(1);
for ( int batchIndex=0; batchIndex<4; batchIndex++ ) {
// 外圈加液
UfCmdSnippetExecutor.execute("LiquidAdditionPrepare.Out." + batchIndex);
if ( this.checkTubeExists("GOUT", batchIndex, "TOUT", tubes) ) { // 外圈外侧试管加液
if ( this.checkTubeExists("GOUT", batchIndex, "TOUT", tubes) ) {
UfCmdSnippetExecutor.execute(
"LiquidAdditionPump" + pumpGroupOutIndex,
Map.of("volume", volume)
);
}
if ( this.checkTubeExists("GOUT", batchIndex, "TIN", tubes) ) { // 外圈内侧试管加液
if ( this.checkTubeExists("GOUT", batchIndex, "TIN", tubes) ) {
UfCmdSnippetExecutor.execute(
"LiquidAdditionPump" + pumpGroupInIndex,
Map.of("volume", volume)
);
}
// 内圈加液
UfCmdSnippetExecutor.execute("LiquidAdditionPrepare.In." + batchIndex);
if ( this.checkTubeExists("GIN", batchIndex, "TOUT", tubes) ) { // 内圈外侧试管加液
if ( this.checkTubeExists("GIN", batchIndex, "TOUT", tubes) ) {
UfCmdSnippetExecutor.execute(
"LiquidAdditionPump" + pumpGroupOutIndex,
Map.of("volume", volume)
);
}
if ( this.checkTubeExists("GIN", batchIndex, "TIN", tubes) ) { // 内圈内侧试管加液
if ( this.checkTubeExists("GIN", batchIndex, "TIN", tubes) ) {
UfCmdSnippetExecutor.execute(
"LiquidAdditionPump" + pumpGroupInIndex,
Map.of("volume", volume)
@ -75,10 +71,15 @@ public class LiquidAdditionInstance {
}
}
// 加液复位
UfCmdSnippetExecutor.execute("LiquidAdditionReset");
}
// 针对试管加液
public void addLiquidToTubes(List<Integer> tubes, String type, int volume ) {
var pumpIndexes = this.getPumpIndexForGroupOutAndIn(type);
this.addLiquidToTubes(tubes, pumpIndexes, volume);
}
// 检查试管是否存在
private Boolean checkTubeExists(String groupType, Integer batchIndex, String slotType, List<Integer> tubes) {
var slotIndexes = Map.of(

3
src/main/resources/application.yml

@ -32,4 +32,5 @@ mqtt-broker:
transbot-topic : "transbot"
app :
errorSlotIndex : 4
errorSlotIndex : 4
liquidPeristalticPumpPipeSetupEnable : true

2
web

@ -1 +1 @@
Subproject commit 2b865293c1311ba5bcefddcb1df3ac83a97799ef
Subproject commit bdddf3ebad65ae4cccdf4d01b7ee9fb6b57c8965
Loading…
Cancel
Save