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 7e7fca32..1b391200 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -47,7 +47,8 @@ public class ExecuteTheRecipe { /** * 等待超时时间 */ - public static int whileTime = 40; + //public static int whileTime = 40; + public static int whileTime = 2; /** * 监听变量值 @@ -145,6 +146,11 @@ public class ExecuteTheRecipe { ExecuteOperationSteps(data3.processname, data3.processvalue); } ExecuteOperationSteps(recipe.processname, recipe.processvalue); + + if (recipe.processname.equals("出菜")) { + BPA_GOODSRECIPE data4 = Get位置("最高", "炒菜位1"); + ExecuteOperationSteps(data4.processname, data4.processvalue); + } } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); @@ -282,6 +288,9 @@ public class ExecuteTheRecipe { case "出菜": Write_PLC_Outdishes(formulation); break; + case "清洗": + Write_PLC_CleanPan(formulation); + break; } @@ -792,7 +801,50 @@ public class ExecuteTheRecipe { Thread.sleep(100);//10 *6 } - ToastUtils.info("出菜完成,结束制作!"); + ToastUtils.info("出菜完成,锅体准备回到原位!"); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + + /** + * 写PLC 清洗 + * + * @param data + */ + private static void Write_PLC_CleanPan(HashMap data) { + try { + ToastUtils.info("准备清洗!"); + //先延迟 + for (HashMap.Entry entry : data.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + ToastUtils.info("工序:" + key + "," + value); + if (key.contains("(秒)")) { + int val = Integer.parseInt(value); + Thread.sleep(val * 1000); + } + } + + BottomClick("炒锅清洗"); + + //一直等待机器移动到该位置,否则就一直等待 6s超时 + String name = "炒锅清洗反馈"; + final boolean[] IsComplete = {false}; + long a = System.currentTimeMillis(); + while (!IsComplete[0]) { + if ((System.currentTimeMillis() - a) > 1000 * (whileTime*5)) { + break; + } else { + Object sb = ReadPLC(name);//ListeningValue.get(name); + if (sb != null) { + IsComplete[0] = (boolean) (sb); + } + } + Thread.sleep(100);//10 *6 + } + + ToastUtils.info("炒锅清洗完成!"); } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 3003308b..6451dc99 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -385,6 +385,7 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); + add(new ProcessT("清洗", Arrays.asList("等待(秒)"))); }}; /** @@ -604,6 +605,8 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); + add(new ProcessT("清洗", Arrays.asList("等待(秒)"))); + }}; /** * 小炒基础PLC模型 @@ -821,6 +824,8 @@ public class ConfigName { add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); + add(new ProcessT("清洗", Arrays.asList("等待(秒)"))); + }}; /** diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java index 99d1a714..6330f157 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java @@ -1077,10 +1077,13 @@ public class DishTestActivity extends BaseActivity { int time_c = time - ClikTime; BPA_GOODSRECIPE data = Get出菜(time_c); DataBus.getInstance().bpa_goodsrecipes.add(data); + BPA_GOODSRECIPE data2 = Get清洗(0); + DataBus.getInstance().bpa_goodsrecipes.add(data); new Thread(new Runnable() { @Override public void run() { ExecuteTheRecipe.ExecuteOperationSteps(data.processname, data.processvalue); + ExecuteTheRecipe.ExecuteOperationSteps(data2.processname, data2.processvalue); } }).start(); } @@ -1225,6 +1228,20 @@ public class DishTestActivity extends BaseActivity { return pf; } + /** + * 获取清洗 + * + * @return + */ + public BPA_GOODSRECIPE Get清洗(int k) { + BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); + pf.materialType = 1; + pf.processname = "清洗"; + pf.processms = "清洗(" + k + ")"; + pf.processvalue = "等待(秒)," + k; + return pf; + } + /** * 获取选中行的变量 * diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java index 73baa4f9..573ada4d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java @@ -300,6 +300,8 @@ public class DiyMemoryActivity extends BaseActivity { { BPA_GOODSRECIPE data1=Get出菜(time_c); DataBus.getInstance().bpa_goodsrecipes.add(data1); + BPA_GOODSRECIPE data2 = Get清洗(0); + DataBus.getInstance().bpa_goodsrecipes.add(data2); MakeRecipe(data1); ClikTime=time; } @@ -401,11 +403,18 @@ public class DiyMemoryActivity extends BaseActivity { { BPA_GOODSRECIPE data1=Get位置("最高","炒菜位1"); ExecuteTheRecipe.ExecuteOperationSteps(data1.processname,data1.processvalue); - ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname,recipe.processvalue); }else { - ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname,recipe.processvalue); + if(recipe.processname.equals("出菜")) + { + ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname,recipe.processvalue); + BPA_GOODSRECIPE data2 = Get清洗(0); + ExecuteTheRecipe.ExecuteOperationSteps(data2.processname,data2.processvalue); + }else + { + ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname,recipe.processvalue); + } } } isMake=false; @@ -471,7 +480,19 @@ public class DiyMemoryActivity extends BaseActivity { pf.processvalue="延迟(秒),"+time; return pf; } - + /** + * 获取清洗 + * + * @return + */ + public BPA_GOODSRECIPE Get清洗(int k) { + BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); + pf.materialType = 1; + pf.processname = "清洗"; + pf.processms = "清洗(" + k + ")"; + pf.processvalue = "等待(秒)," + k; + return pf; + } /** * 获取主料 * @param wz