From 01b016cca264229a9c16dd96057cbe5c2c87d54b Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Thu, 26 Sep 2024 13:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=93=E9=80=81=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=81=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release/output-metadata.json | 2 +- .../business/ExecuteTheRecipe.java | 77 ++++++++++++++++--- .../bnframework/modbus/ModbusCenter.java | 8 +- 3 files changed, 72 insertions(+), 15 deletions(-) diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 0971ec01..4b7a8b4e 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -13,7 +13,7 @@ "attributes": [], "versionCode": 102, "versionName": "1.0.2", - "outputFile": "robot-xiaochao-v102-202409241716-unsigned-release.apk" + "outputFile": "robot-xiaochao-v102-202409261248-unsigned-release.apk" } ], "elementType": "File" diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java index fe2010e6..9051a960 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -74,6 +74,9 @@ public class ExecuteTheRecipe { boolean isError = false; long startTime = System.currentTimeMillis(); //起始时间 showlog("开始烹饪菜谱【" + orderDetail.goodsName + "】"); + ModbusCenter.rackWritePlc("输送线停止",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线停止",false,null); try { //获取工艺 ArrayList goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(orderDetail.groupId); @@ -1150,6 +1153,7 @@ public class ExecuteTheRecipe { try { showlog("准备出菜!"); //先延迟 + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); @@ -1244,6 +1248,9 @@ public class ExecuteTheRecipe { }); Thread.sleep(100); + ModbusCenter.rackWritePlc("输送线停止",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线停止",false,null); ThreadWhile(deviceNum,deviceNum+"机器人到位请求炒锅出餐倒菜"); if(ConfigName.IsForcedEnd[deviceNum-1]){ Thread.sleep(100); @@ -1319,11 +1326,36 @@ public class ExecuteTheRecipe { try{ ThreadWhile(deviceNum,deviceNum+"炒锅出餐完成"); ConfigName.getInstance().isPutFinish = true; -// if((Boolean) ModbusCenter.rackReadPlc("输送线进料菜盆检测")){ - ModbusCenter.rackWritePlc("输送线启动",true,null); - Thread.sleep(500); - ModbusCenter.rackWritePlc("输送线启动",false,null); -// } + ModbusCenter.rackWritePlc("输送线启动",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线启动",false,null); + + ThreadManager.get().execute(new Runnable() { + @Override + public void run() { + try{ + if(ModbusCenter.getListingValue("输送线出料菜盆检测") instanceof Boolean){ + boolean isStart = (boolean) ModbusCenter.getListingValue("输送线出料菜盆检测"); + long a = System.currentTimeMillis(); + Thread.sleep(15000); + while (!isStart) { + Thread.sleep(1000); + if ((System.currentTimeMillis() - a) > 1000 * 20) { + break; + } + isStart = (boolean) ModbusCenter.getListingValue("输送线出料菜盆检测"); + if(isStart){ + break; + } + } + } + ModbusCenter.rackWritePlc("输送线停止",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线停止",false,null); + }catch (Exception e){ + } + } + }); }catch (Exception e){ } @@ -1334,11 +1366,36 @@ public class ExecuteTheRecipe { try{ ThreadWhile(deviceNum,deviceNum+"炒锅出餐完成"); ConfigName.getInstance().isPutFinish = true; -// if((Boolean) ModbusCenter.rackReadPlc("输送线进料菜盆检测")){ - ModbusCenter.rackWritePlc("输送线启动",true,null); - Thread.sleep(500); - ModbusCenter.rackWritePlc("输送线启动",false,null); -// } + ModbusCenter.rackWritePlc("输送线启动",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线启动",false,null); + + ThreadManager.get().execute(new Runnable() { + @Override + public void run() { + try{ + if(ModbusCenter.getListingValue("输送线出料菜盆检测") instanceof Boolean){ + boolean isStart = (boolean) ModbusCenter.getListingValue("输送线出料菜盆检测"); + long a = System.currentTimeMillis(); + Thread.sleep(15000); + while (!isStart) { + Thread.sleep(1000); + if ((System.currentTimeMillis() - a) > 1000 * 20) { + break; + } + isStart = (boolean) ModbusCenter.getListingValue("输送线出料菜盆检测"); + if(isStart){ + break; + } + } + } + ModbusCenter.rackWritePlc("输送线停止",true,null); + Thread.sleep(500); + ModbusCenter.rackWritePlc("输送线停止",false,null); + }catch (Exception e){ + } + } + }); }catch (Exception e){ } diff --git a/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java b/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java index 7cc198c6..8ad26e19 100644 --- a/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java +++ b/app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java @@ -216,7 +216,7 @@ public class ModbusCenter { listeningValue.put("输送线出料菜盆检测", val[1]); listeningValue.put("输送线进料菜盆检测", val[0]); if(val[0]){ - LogUtils.d("输送线进料菜盆检测 M12.3 true"); + LogUtils.d("输送线进料菜盆检测 M12.2 true"); if( ConfigName.getInstance().isPutFinish){ ThreadManager.get().execute(new Runnable() { @Override @@ -226,7 +226,7 @@ public class ModbusCenter { if(RackModbusTcpServer.get().plcIsConnect){ if(val[0]){ ConfigName.getInstance().isPutFinish = false; - RackModbusTcpServer.get().WriteBool("输送线停止",true,null); + ModbusCenter.rackWritePlc("输送线停止",true,null); Thread.sleep(500); ModbusCenter.rackWritePlc("输送线停止",false,null); } @@ -239,10 +239,10 @@ public class ModbusCenter { }); } }else if(val[1]){ - LogUtils.d("输送线出料菜盆检测 M12.2 true"); + LogUtils.d("输送线出料菜盆检测 M12.3 true"); try{ ConfigName.getInstance().isPutFinish = false; - RackModbusTcpServer.get().WriteBool("输送线停止",true,null); + ModbusCenter.rackWritePlc("输送线停止",true,null); Thread.sleep(500); ModbusCenter.rackWritePlc("输送线停止",false,null); }catch (Exception e){