diff --git a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/HeatAreaMoveTitrationAreaCommand.java b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/HeatAreaMoveTitrationAreaCommand.java index fadb736..0df3193 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/HeatAreaMoveTitrationAreaCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/HeatAreaMoveTitrationAreaCommand.java @@ -43,9 +43,9 @@ public class HeatAreaMoveTitrationAreaCommand extends BaseCommandHandler { if (!tubeExist) throw new AppException(ResultCode.TARGET_MODULE_NO_TUBE);//目标模块无试管 boolean heatTubeExist = switch (heatModuleCode) { //加热位是否存在试管 case MultipleModuleCode.MODULE_1 -> - deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_1).isBubeExist(); + deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_1).isTubeExist(); case MultipleModuleCode.MODULE_2 -> - deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_2).isBubeExist(); + deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_2).isTubeExist(); }; if (heatTubeExist) throw new AppException(ResultCode.TARGET_MODULE_OCCUPIED);//目标模块被占用 //3、判断夹爪是否夹取了试管 todo diff --git a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationAreaMoveHeatAreaCommand.java b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationAreaMoveHeatAreaCommand.java index f6dff01..c7cffe0 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationAreaMoveHeatAreaCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationAreaMoveHeatAreaCommand.java @@ -43,9 +43,9 @@ public class TitrationAreaMoveHeatAreaCommand extends BaseCommandHandler { if (!tubeExist) throw new AppException(ResultCode.TARGET_MODULE_NO_TUBE);//目标模块无试管 boolean heatTubeExist = switch (heatModuleCode) { //加热位是否存在试管 case MultipleModuleCode.MODULE_1 -> - deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_1).isBubeExist(); + deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_1).isTubeExist(); case MultipleModuleCode.MODULE_2 -> - deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_2).isBubeExist(); + deviceState.getHeatModuleStateMap().get(MultipleModuleCode.MODULE_2).isTubeExist(); }; if (heatTubeExist) throw new AppException(ResultCode.TARGET_MODULE_OCCUPIED);//目标模块被占用 //3、判断夹爪是否夹取了试管 todo diff --git a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationMoveTrayAreaCommand.java b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationMoveTrayAreaCommand.java index 6344e55..e2ea262 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationMoveTrayAreaCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TitrationMoveTrayAreaCommand.java @@ -38,9 +38,9 @@ public class TitrationMoveTrayAreaCommand extends BaseCommandHandler { MultipleModuleCode titrationModuleCode = MultipleModuleCode.valueOf(moduleCode); boolean tubeExist = switch (titrationModuleCode) { //1首先滴定位试管状态 case MultipleModuleCode.MODULE_1 -> - deviceState.getTitrationModuleStateMap().get(titrationModuleCode).isBubeExist(); + deviceState.getTitrationModuleStateMap().get(titrationModuleCode).isTubeExist(); case MultipleModuleCode.MODULE_2 -> - deviceState.getTitrationModuleStateMap().get(titrationModuleCode).isBubeExist(); + deviceState.getTitrationModuleStateMap().get(titrationModuleCode).isTubeExist(); }; if (!tubeExist) throw new AppException(ResultCode.TARGET_MODULE_NO_TUBE);//目标被占用 //3、判断夹爪是否夹取了试管 todo diff --git a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TrayMoveTitrationAreaCommand.java b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TrayMoveTitrationAreaCommand.java index 3853803..35cf156 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TrayMoveTitrationAreaCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/control/transfer/TrayMoveTitrationAreaCommand.java @@ -57,9 +57,9 @@ public class TrayMoveTitrationAreaCommand extends BaseCommandHandler { //判断滴定位传感器状态 boolean titrationExist = switch (titrationModuleCode) { //1、首先检测试管所在的托盘传感器的值 case MultipleModuleCode.MODULE_1 -> - deviceState.getTitrationModuleStateMap().get(MultipleModuleCode.MODULE_1).isBubeExist(); + deviceState.getTitrationModuleStateMap().get(MultipleModuleCode.MODULE_1).isTubeExist(); case MultipleModuleCode.MODULE_2 -> - deviceState.getTitrationModuleStateMap().get(MultipleModuleCode.MODULE_2).isBubeExist(); + deviceState.getTitrationModuleStateMap().get(MultipleModuleCode.MODULE_2).isTubeExist(); }; if (titrationExist) throw new AppException(ResultCode.TARGET_MODULE_OCCUPIED);//目标模块被占用 //移动到滴定位上方 diff --git a/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsExecutionService.java b/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsExecutionService.java index 5e3b890..c947b3d 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsExecutionService.java +++ b/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsExecutionService.java @@ -47,19 +47,33 @@ public class CraftsExecutionService { moveToTitration();//移动至滴定 //TODO 调用相机判断滴定位是否存在试管 Long solutionId = params.getLong("solutionId");//使用的溶液id - Double amount = params.getDouble("amount");//加液量 + Double amount = params.getDouble("amount");//加液量 Long colorId = params.getLong("colorId");//终点颜色 String type = params.getStr("type");//加液方式 AddSolutionType addSolutionType = AddSolutionType.valueOf(type); - Integer waitTime = params.getInt("waitTime");//加液后等待时长 + Long waitTime = params.getLong("waitTime");//加液后等待时长 Double maxAmount = params.getDouble("maxAmount");//滴定最大体积 Boolean stirFlag = params.getBool("stirFlag");//是否搅拌 - if(AddSolutionType.fixed.equals(addSolutionType)){//定量加液 - titrationModuleService.addSolutionStart(craftsContext.getCurrentTitrationModuleCode(), solutionId, amount); - }else if(AddSolutionType.segmented.equals(addSolutionType)){//分段加液 - - }else if(AddSolutionType.titration.equals(addSolutionType)){//滴定加液 + if(stirFlag){ + //调用开始搅拌 + } + if (AddSolutionType.fixed.equals(addSolutionType)) {//定量加液 + titrationModuleService.addSolutionStart(craftsContext.getCurrentTitrationModuleCode(), solutionId, amount); + } else if (AddSolutionType.segmented.equals(addSolutionType) || AddSolutionType.titration.equals(addSolutionType)) {//分段加液、滴定加液 + double currentVolume = 0; + while (true) { + titrationModuleService.addSolutionStart(craftsContext.getCurrentTitrationModuleCode(), solutionId, amount); + currentVolume += amount; + sleep(waitTime); + //TODO 调用相机获取当前颜色 然后break + if (currentVolume >= maxAmount) {//达到最大体积,停止滴定 + break; + } + } + } + if(stirFlag){ + //调用停止搅拌 } return true; } @@ -75,18 +89,32 @@ public class CraftsExecutionService { return true; } - private boolean waiting(CraftsContext craftsContext, JSONObject params) { + private boolean waiting(CraftsContext craftsContext, JSONObject params) throws InterruptedException { + Integer seconds = params.getInt("second", 0); + sleep(seconds * 1000L); return true; } + //移动至滴定 - private void moveToTitration(){ + private void moveToTitration() { //动态分配使用的模块 } + //移动至加热 - private void moveToHeat(){ + private void moveToHeat() { //动态分配使用的模块 } + /** + * 延时等待 + */ + private void sleep(Long millis) throws InterruptedException { + if (millis == null) { + return; + } + Thread.sleep(millis); + } + private void wait(CraftsContext craftsContext, CommandFuture... futures) throws Exception { wait(craftsContext, null, futures); } diff --git a/src/main/java/com/iflytop/colortitration/app/core/state/HeatModuleState.java b/src/main/java/com/iflytop/colortitration/app/core/state/HeatModuleState.java index e0a251c..358f3a0 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/state/HeatModuleState.java +++ b/src/main/java/com/iflytop/colortitration/app/core/state/HeatModuleState.java @@ -21,7 +21,7 @@ public class HeatModuleState { private MultipleModuleCode moduleCode; @Schema(description = "是否存在试管,true 存在 false不存在") - private boolean bubeExist = false; + private boolean tubeExist = false; @Schema(description = "是否启动加热,true为正在加热,false为未在加热") private boolean open = false; diff --git a/src/main/java/com/iflytop/colortitration/app/core/state/TitrationModuleState.java b/src/main/java/com/iflytop/colortitration/app/core/state/TitrationModuleState.java index cbb279b..1eb9a44 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/state/TitrationModuleState.java +++ b/src/main/java/com/iflytop/colortitration/app/core/state/TitrationModuleState.java @@ -19,7 +19,7 @@ public class TitrationModuleState { private MultipleModuleCode moduleCode; @Schema(description = "是否存在试管,true 存在 false不存在") - private boolean bubeExist = false; + private boolean tubeExist = false; public TitrationModuleState(MultipleModuleCode moduleCode) { this.moduleCode = moduleCode; diff --git a/src/main/java/com/iflytop/colortitration/app/core/state/TubeState.java b/src/main/java/com/iflytop/colortitration/app/core/state/TubeState.java index 9b5b6d1..3151a6b 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/state/TubeState.java +++ b/src/main/java/com/iflytop/colortitration/app/core/state/TubeState.java @@ -20,10 +20,10 @@ import java.util.List; public class TubeState { @Schema(description = "试管位编号") - private Integer bubeNum; + private Integer tubeNum; @Schema(description = "是否存在试管,true 存在 false不存在") - private boolean bubeExist = true; + private boolean tubeExist = true; @Schema(description = "滴定状态") private TitrationStatus titrationStatus = TitrationStatus.NOT_STARTED; @@ -46,7 +46,7 @@ public class TubeState { @Schema(description = "当前试管工艺队列的编号") private Integer queueNum; - public TubeState(Integer bubeNum) { - this.bubeNum = bubeNum; + public TubeState(Integer tubeNum) { + this.tubeNum = tubeNum; } } diff --git a/src/main/java/com/iflytop/colortitration/app/model/dto/TrayTubeSetExistDTO.java b/src/main/java/com/iflytop/colortitration/app/model/dto/TrayTubeSetExistDTO.java index 994c3b2..19567b2 100644 --- a/src/main/java/com/iflytop/colortitration/app/model/dto/TrayTubeSetExistDTO.java +++ b/src/main/java/com/iflytop/colortitration/app/model/dto/TrayTubeSetExistDTO.java @@ -14,6 +14,6 @@ public class TrayTubeSetExistDTO { @NotNull @Schema(description = "是否存在试管 true存在 false不存在") - private Boolean bubeExist; + private Boolean tubeExist; } diff --git a/src/main/java/com/iflytop/colortitration/app/service/TubeService.java b/src/main/java/com/iflytop/colortitration/app/service/TubeService.java index ee86a42..0bc395d 100644 --- a/src/main/java/com/iflytop/colortitration/app/service/TubeService.java +++ b/src/main/java/com/iflytop/colortitration/app/service/TubeService.java @@ -18,7 +18,7 @@ public class TubeService { */ public void setTubeExist(List trayTubeSetExistDTOList) { for (TrayTubeSetExistDTO trayTubeSetExistDTO : trayTubeSetExistDTOList) { - deviceState.getTrayTubeStateMap().get(trayTubeSetExistDTO.getTubeNum()).setBubeExist(trayTubeSetExistDTO.getBubeExist()); + deviceState.getTrayTubeStateMap().get(trayTubeSetExistDTO.getTubeNum()).setTubeExist(trayTubeSetExistDTO.getTubeExist()); } }