From f8bf6f53b3658b9954cbb1e0db71cd9d579eab30 Mon Sep 17 00:00:00 2001
From: fyf <11621@LAPTOP-04QQU0AO>
Date: Sat, 19 Aug 2023 15:54:54 +0800
Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E6=94=B9=E5=8A=A8-?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/jarRepositories.xml | 5 ++
.../business/ExecuteTheRecipe.java | 59 +++++++++++--------
.../bnframework/common/helper/ActiveMax.java | 5 ++
.../modules/home/fragment/Home1Fragment.java | 14 ++++-
.../home/fragment/from/DiyActivity.java | 1 +
5 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 1e2d92c1..9ce8da6d 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -31,5 +31,10 @@
+
+
+
+
+
\ No newline at end of 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 10a3fd27..d89ac571 100644
--- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
+++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Handler;
+import android.util.Log;
import androidx.annotation.NonNull;
@@ -147,12 +148,33 @@ public class ExecuteTheRecipe {
}
}
//endregion
- //写入PLC
+ //写入PLC,直接出料,不用等待
for (Map.Entry entry : formulation.entrySet()) {
Integer key = entry.getKey();
Integer value = entry.getValue();
Write_PLC_Material(key, value);
}
+
+ //一直等待下料完成 否则就一直等待 6s超时
+ for (Map.Entry entry : formulation.entrySet()) {
+ Integer num = entry.getKey();
+ Integer val = entry.getValue();
+ String name = "料仓" + num + "下料完成";
+ final boolean[] IsComplete = {false};
+ long a = System.currentTimeMillis();
+ while (!IsComplete[0]) {
+ if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
+ break;
+ } else {
+ Object sb = ReadPLC(name);// ListeningValue.get(name);
+ if (sb != null) {
+ IsComplete[0] = (boolean) (sb);
+ }
+ }
+ Thread.sleep(100);//10 *6
+ }
+ ToastUtils.info(name);
+ }
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -230,6 +252,8 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Material(int num, int val) {
try {
+ String name = "料仓" + num + "下料完成";
+ ExecuteTheRecipe.WritePLC(name, false, null);
WritePLC("料仓" + num + "需求值", val, new IWriteCallBack() {
@Override
public void onSuccess() {
@@ -240,24 +264,7 @@ public class ExecuteTheRecipe {
public void onFailure(String ErrorMsg) {
}
});
-
- //一直等待下料完成 否则就一直等待 6s超时
- String name = "料仓" + num + "下料完成";
- final boolean[] IsComplete = {false};
- long a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
- break;
- } else {
- Object sb = ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
ToastUtils.info("写入PLC仓号需求:" + num + "," + val);
-
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -333,7 +340,7 @@ public class ExecuteTheRecipe {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
- Object sb = ListeningValue.get(name);
+ Object sb = ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
@@ -441,6 +448,7 @@ public class ExecuteTheRecipe {
//1.去某一个位置
BottomClick("平移-去"+writeValue);
+ Log.d("平移", "平移-去"+writeValue);
//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "平移轴在"+writeValue;
final boolean[] IsComplete = {false};
@@ -449,13 +457,14 @@ public class ExecuteTheRecipe {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
- Object sb = ListeningValue.get(name);
+ Object sb =ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
+ Log.d("平移", name+"已经就位");
//2.给倒菜启动
BottomClick("主料");
@@ -466,16 +475,15 @@ public class ExecuteTheRecipe {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
- Object sb = ListeningValue.get(name);
+ Object sb =ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
- //
ToastUtils.info("主料倒入完成,继续制作!");
- BottomClick("平移-去1号位");
+
}
}
} catch (Exception ex) {
@@ -589,8 +597,7 @@ public class ExecuteTheRecipe {
}
}
BottomClick("出菜");
- WritePLC("搅拌", false, null);
- WritePLC("加热", false, null);
+
//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "出餐启动反馈";
final boolean[] IsComplete = {false};
@@ -599,7 +606,7 @@ public class ExecuteTheRecipe {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
- Object sb = ListeningValue.get(name);
+ Object sb =ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java b/app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java
index a77f1f85..72e5e6f3 100644
--- a/app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java
+++ b/app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java
@@ -5,6 +5,8 @@ import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;
+import com.qmuiteam.qmui.util.QMUINotchHelper;
+
import java.util.ArrayList;
import java.util.List;
@@ -30,6 +32,9 @@ public class ActiveMax {
{
activities.add(activity);
}
+
+ //QMUINotchHelper.getSafeInsetBottom(activity)
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 全屏显示,隐藏状态栏和导航栏,拉出状态栏和导航栏显示一会儿后消失。
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 9193e74e..1685c041 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
@@ -392,17 +392,29 @@ public class Home1Fragment extends BaseFragment {
//获取工艺
ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : goodsrecipes) {
- ExecuteTheRecipe.Execute(item);
+ boolean status= ExecuteTheRecipe.Execute(item);
}
+
+
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
+
+ ExecuteTheRecipe.WritePLC("搅拌", false, null);
+ ExecuteTheRecipe.WritePLC("加热", false, null);
+ ExecuteTheRecipe.BottomClick("平移-去1号位");
Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
SetBottonStatus(false);
+ if(ExecuteTheRecipe.IsForcedEnd)//强制结束
+ {
+ ToastUtils.info("客官,当前菜品已强制结束!!!");
+ //初始化
+ ExecuteTheRecipe.BottomClick("初始化");
+ }
}
});
}
diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
index 5d94f1af..405b87bd 100644
--- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
+++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
@@ -491,6 +491,7 @@ public class DiyActivity extends BaseActivity {
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱生成成功!");
+ MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good");
dialog.dismiss();
}
});