From 0c789fae208242440946d52b3c3808b2c20c28ad Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 19 Jan 2024 14:29:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BC=95=E8=B3=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ExecuteTheRecipe.java | 26 ++++++++++++++----- .../activity/BottomNavigation2Activity.java | 2 +- .../activity/BottomNavigationNewActivity.java | 4 ++- .../modules/home/fragment/Home1Fragment.java | 1 + 4 files changed, 25 insertions(+), 8 deletions(-) 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 4249cd37..5b6a61f8 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -149,6 +149,14 @@ public class ExecuteTheRecipe { ExecuteTheRecipe.showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); return false; } + + if(!ConfigName.getInstance().PlcIsConnect) + { + ExecuteTheRecipe.showlog("客官,检测到硬件已经断开连接,主动停止炒制!!!"); + IsForcedEnd=true; + return false; + } + ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms); if (recipe.materialType == 0)//正常物料 @@ -1955,7 +1963,7 @@ public class ExecuteTheRecipe { ExecuteTheRecipe.showlog("工序线程等待-------时长:" + delay + "秒,请耐心等待,开始计时!"); long startTime = System.currentTimeMillis(); - while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) // + while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) { try { Thread.sleep(100); @@ -1978,15 +1986,18 @@ public class ExecuteTheRecipe { final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); ExecuteTheRecipe.showlog(name + ",等待中"); - while (!IsComplete[0] && !IsForcedEnd) { + while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) { if ((System.currentTimeMillis() - a) > 1000 * whileTime) { ExecuteTheRecipe.showlog(name + ",异常超时退出!"); break; } else { - Object sb = ReadPLC(name);//ListeningValue.get(name); + Object sb = ReadPLC(name); if (sb != null) { IsComplete[0] = (boolean) (sb); - ExecuteTheRecipe.showlog(name + ",接收到信号!"); + if(IsComplete[0]) + { + ExecuteTheRecipe.showlog(name + ",接收到信号!"); + } } } try { @@ -2009,7 +2020,7 @@ public class ExecuteTheRecipe { final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); ExecuteTheRecipe.showlog(name + ",等待中"); - while (!IsComplete[0] && !IsForcedEnd) { + while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) { if ((System.currentTimeMillis() - a) > 1000 * whileTime * k) { ExecuteTheRecipe.showlog(name + ",异常超时退出!"); break; @@ -2017,7 +2028,10 @@ public class ExecuteTheRecipe { Object sb = ReadPLC(name);//ListeningValue.get(name); if (sb != null) { IsComplete[0] = (boolean) (sb); - ExecuteTheRecipe.showlog(name + ",接收到信号!"); + if(IsComplete[0]) + { + ExecuteTheRecipe.showlog(name + ",接收到信号!"); + } } } try { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java index aa55d9d4..8e6945ee 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java @@ -227,7 +227,7 @@ public class BottomNavigation2Activity extends BaseActivity { } } } - Thread.sleep(10000); + Thread.sleep(3000); } catch (Exception e) { Log.i("PLC", "PLC重连接失败!" + e.getMessage()); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java index 609e8a82..c779c5eb 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java @@ -324,7 +324,7 @@ public class BottomNavigationNewActivity extends BaseActivity { } } } - Thread.sleep(10000); + Thread.sleep(3000); } catch (Exception e) { Log.i("PLC", "PLC重连接失败!" + e.getMessage()); } @@ -396,6 +396,8 @@ public class BottomNavigationNewActivity extends BaseActivity { } finally { ExecuteTheRecipe.WritePLC("搅拌", false, null); ExecuteTheRecipe.WritePLC("加热", false, null); + ExecuteTheRecipe.WritePLC("暂停开关", false, null); + ConfigName.getInstance().IsOpenHuoLi = false; ExecuteTheRecipe.BottomClick("平移-去1号位"); gongxuIndex = 10000; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java index 00fc65f3..b64b7eda 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java @@ -595,6 +595,7 @@ public class Home1Fragment extends BaseFragment { } finally { ExecuteTheRecipe.WritePLC("搅拌", false, null); ExecuteTheRecipe.WritePLC("加热", false, null); + ExecuteTheRecipe.WritePLC("暂停开关", false, null); ConfigName.getInstance().IsOpenHuoLi = false; ExecuteTheRecipe.BottomClick("平移-去1号位"); gongxuIndex = 10000;