From 9ee8d15492aeeef84863125041ceb406dc213e4e Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 22 Jan 2024 10:45:23 +0800 Subject: [PATCH] 4 --- .../business/ExecuteTheRecipe.java | 79 +++++++++++++++---- .../modules/home/fragment/Home1Fragment.java | 14 ++-- 2 files changed, 71 insertions(+), 22 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 ec1f088f..208f3436 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -465,7 +465,7 @@ public class ExecuteTheRecipe { */ private static void Write_PLC_Stir(HashMap data) { try { - int val = 0; + int val = 0; int writeValue=0; for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); @@ -473,15 +473,16 @@ public class ExecuteTheRecipe { val = Integer.parseInt(value); } else { ToastUtils.info("工序:" + key + "," + value); - int writeValue = GetMXValue(key, value); + writeValue = GetMXValue(key, value); if (ExecuteCurrentOperation != null) { ExecuteCurrentOperation.Run("搅拌" + "|" + writeValue); } + int finalWriteValue = writeValue; WritePLC(key, writeValue, new IWriteCallBack() { @Override public void onSuccess() { - ExecuteTheRecipe.showlog("搅拌,挡位-" + writeValue + ",写入成功!"); - if (writeValue == 0) { + ExecuteTheRecipe.showlog("搅拌,挡位-" + finalWriteValue + ",写入成功!"); + if (finalWriteValue == 0) { WritePLC("搅拌", false, null); } else { WritePLC("搅拌", true, null); @@ -490,9 +491,9 @@ public class ExecuteTheRecipe { @Override public void onFailure(String ErrorMsg) { - ExecuteTheRecipe.showlog("搅拌,挡位-" + writeValue + ",写入失败!原因:" + ErrorMsg); - WritePLC(key, writeValue, null); - if (writeValue == 0) { + ExecuteTheRecipe.showlog("搅拌,挡位-" + finalWriteValue + ",写入失败!原因:" + ErrorMsg); + WritePLC(key, finalWriteValue, null); + if (finalWriteValue == 0) { WritePLC("搅拌", false, null); } else { WritePLC("搅拌", true, null); @@ -502,7 +503,30 @@ public class ExecuteTheRecipe { } } - if (val > 0) { + //region 回读验证 + Object obj= ReadPLC("搅拌"); + if(obj!=null) + { + ExecuteTheRecipe.showlog("搅拌回读信号,挡位-" + writeValue + ",开关状态:" + obj); + if(writeValue==0) + { + if((boolean) obj) + { + ExecuteTheRecipe.showlog("搅拌重写,写入开关状态:false,写入成功!"); + WritePLC("搅拌", false, null); + } + }else + { + if(!(boolean) obj) + { + ExecuteTheRecipe.showlog("搅拌重写,写入开关状态:true,写入成功!"); + WritePLC("搅拌", true, null); + } + } + } + //endregion + + if (val > 0 && !IsForcedEnd) { ThreadDelay(val); } } catch (Exception ex) { @@ -773,7 +797,7 @@ public class ExecuteTheRecipe { */ private static void Write_PLC_Heating(HashMap data) { try { - int val = 0; + int val = 0;int writeValue=0; for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); @@ -781,16 +805,17 @@ public class ExecuteTheRecipe { val = Integer.parseInt(value); } else { ExecuteTheRecipe.showlog("工序:" + key + "," + value); - int writeValue = GetMXValue(key, value); + writeValue = GetMXValue(key, value); if (ExecuteCurrentOperation != null) { ExecuteCurrentOperation.Run("加热" + "|" + writeValue); } //写加热挡位 + int finalWriteValue = writeValue; WritePLC(key, writeValue, new IWriteCallBack() { @Override public void onSuccess() { - ExecuteTheRecipe.showlog("写加热挡位:" + writeValue + "成功"); - if (writeValue == 0) { + ExecuteTheRecipe.showlog("写加热挡位:" + finalWriteValue + "成功"); + if (finalWriteValue == 0) { ConfigName.getInstance().IsOpenHuoLi = false; WritePLC("加热", false, null); } else { @@ -801,9 +826,9 @@ public class ExecuteTheRecipe { @Override public void onFailure(String ErrorMsg) { - ExecuteTheRecipe.showlog("写加热挡位:" + writeValue + "失败,错误原因:" + ErrorMsg); - WritePLC(key, writeValue, null); - if (writeValue == 0) { + ExecuteTheRecipe.showlog("写加热挡位:" + finalWriteValue + "失败,错误原因:" + ErrorMsg); + WritePLC(key, finalWriteValue, null); + if (finalWriteValue == 0) { ConfigName.getInstance().IsOpenHuoLi = false; WritePLC("加热", false, null); } else { @@ -816,6 +841,29 @@ public class ExecuteTheRecipe { } } + //region 回读验证 + Object obj= ReadPLC("加热"); + if(obj!=null) + { + ExecuteTheRecipe.showlog("加热回读信号,挡位-" + writeValue + ",开关状态:" + obj); + if(writeValue==0) + { + if((boolean) obj) + { + ExecuteTheRecipe.showlog("加热重写,写入开关状态:false,写入成功!"); + WritePLC("加热", false, null); + } + }else + { + if(!(boolean) obj) + { + ExecuteTheRecipe.showlog("加热重写,写入开关状态:true,写入成功!"); + WritePLC("加热", true, null); + } + } + } + //endregion + if (val > 0 && !IsForcedEnd) { ThreadDelay(val); } @@ -2233,6 +2281,7 @@ public class ExecuteTheRecipe { */ public static void showlog(String msg) { Log.e("hbl", msg); + ToastUtils.info(msg); } //endregion 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 55ec3571..c175af48 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 @@ -482,10 +482,10 @@ public class Home1Fragment extends BaseFragment { public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { Log.e("鼠标", "按下: "); -// if (!IsMake(false)) -// { -// return false; -// } + if (!IsMake(false)) + { + return false; + } int jd = (int) nifty_slider3.getValue(); ExecuteTheRecipe.WritePLC("转动速度", jd, new IWriteCallBack() { @Override @@ -744,15 +744,15 @@ public class Home1Fragment extends BaseFragment { writeValue = value; } } - ExecuteTheRecipe.BottomClick("平移-去" + writeValue); + ExecuteTheRecipe.BottomClick1("平移-去" + writeValue); Log.d("移动去", writeValue); } else { - ExecuteTheRecipe.BottomClick("平移-去1号位"); + ExecuteTheRecipe.BottomClick1("平移-去1号位"); Log.d("移动去", "1号位"); } } else { if (!MakeCipe.processname.equals("主料")) { - ExecuteTheRecipe.BottomClick("平移-去1号位"); + ExecuteTheRecipe.BottomClick1("平移-去1号位"); Log.d("移动去", "1号位"); } }