From 163fd4a48d59cc1415e3f398e6ab4db81f081d7b Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 10 Jan 2024 15:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ExecuteTest.java | 2 +- .../from/fragment/AutoTestMoreFragment.java | 85 ++++++++++++++++++- .../from/fragment/AutoTestOneFragment.java | 66 +++++++------- .../res/layout/fragment_auto_test_more.xml | 32 +++++++ 4 files changed, 146 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java index 48d35527..a1111eeb 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTest.java @@ -146,7 +146,7 @@ public class ExecuteTest { } }); long a = System.currentTimeMillis(); - while (!IsComplete[0]) { + while (!IsComplete[0] && !IsForcedEnd) { if ((System.currentTimeMillis() - a) > 1000 * whileTime) { break; } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestMoreFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestMoreFragment.java index 20fecb29..8aecf08e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestMoreFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestMoreFragment.java @@ -18,12 +18,15 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTest; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.res.MakeStatus; +import com.bonait.bnframework.common.db.res.StatusMode; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.image.MyBitmapUtils; import com.bonait.bnframework.common.message.MessageManager; @@ -34,7 +37,9 @@ import com.bonait.bnframework.modules.home.fragment.from.Cpxz1Activity; import com.bonait.bnframework.modules.home.fragment.from.CpxzActivity; import com.orhanobut.logger.Logger; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import butterknife.BindView; @@ -64,7 +69,11 @@ public class AutoTestMoreFragment extends BaseFragment { @BindView(R.id.jieshutuichu) ImageView jieshutuichu;//结束退出 + @BindView(R.id.miaoshu) + EditText miaoshu;// + @BindView(R.id.qingkong) + Button qingkong;// //endregion //region 界面 @@ -130,7 +139,12 @@ public class AutoTestMoreFragment extends BaseFragment { skipToActivity(Cpxz1Activity.class); } }); - + qingkong.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ClearMiaosShu(); + } + }); DataBus.getInstance().mListener1 = new MyClickListener() { @Override public void clickListener(View v, Object data) { @@ -178,7 +192,38 @@ public class AutoTestMoreFragment extends BaseFragment { } }).start(); + new Thread(new Runnable() { + @Override + public void run() { + while (true) { + try { + //故障信息 + for (StatusMode item: ConfigName.getInstance().statusModes) + { + if(ExecuteTheRecipe.getConcurrentHash(item.sort)) + { + SetMiaosShu1(item.Name); + } + } + + String x1= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("搅拌电机")); + String x2= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("翻转电机")); + if(!x1.equals("无故障")) + { + SetMiaosShu1("搅拌电机故障代码:"+x1); + } + if(!x2.equals("无故障")) + { + SetMiaosShu1("翻转电机故障代码:"+x2); + } + Thread.sleep(2000); + } catch (Exception ex) { + + } + } + } + }).start(); } @@ -267,5 +312,43 @@ public class AutoTestMoreFragment extends BaseFragment { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } + + /** + * 不重复 + * @param text + */ + public void SetMiaosShu1(String text) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + String YL= miaoshu.getText().toString(); + if(!YL.isEmpty() && YL.contains(text)) + { + + }else + { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date(); + String tempMsg = YL+ formatter.format(date) + ":" + text + "\n"; + miaoshu.setText(tempMsg); + ToastUtils.warning(formatter.format(date) + ":" + text); + } + } + }); + } + + /** + * 清空显示 + * + * @param + */ + public void ClearMiaosShu() { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + miaoshu.setText(""); + } + }); + } //endregion } \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestOneFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestOneFragment.java index ed2e746f..66c4b375 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestOneFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/AutoTestOneFragment.java @@ -278,41 +278,31 @@ public class AutoTestOneFragment extends BaseFragment { case 0: MakeGKCX_JB(); break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; } + } - - //故障信息 - for (StatusMode item:ConfigName.getInstance().statusModes) + //故障信息 + for (StatusMode item:ConfigName.getInstance().statusModes) + { + if(ExecuteTheRecipe.getConcurrentHash(item.sort)) { - if(ExecuteTheRecipe.getConcurrentHash(item.sort)) - { - SetMiaosShu1(item.Name); - } + SetMiaosShu1(item.Name); } + } - String x1= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("搅拌电机")); - String x2= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("翻转电机")); - if(!x1.equals("无故障")) - { - SetMiaosShu1("搅拌电机故障代码:"+x1); - } + String x1= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("搅拌电机")); + String x2= ConfigName.getInstance().statusModes_电机.get(ExecuteTheRecipe.getConcurrentHash_dj("翻转电机")); + if(!x1.equals("无故障")) + { + SetMiaosShu1("搅拌电机故障代码:"+x1); + } - if(!x2.equals("无故障")) - { - SetMiaosShu1("翻转电机故障代码:"+x2); - } + if(!x2.equals("无故障")) + { + SetMiaosShu1("翻转电机故障代码:"+x2); } - Thread.sleep(1000); + + Thread.sleep(2000); } catch (Exception ex) { } @@ -770,20 +760,22 @@ public class AutoTestOneFragment extends BaseFragment { add("八档"); }}; for (String item : Dwei) { - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - jiaredangwei.setText(item + ""); - } - }); - if (ExecuteTest.IsStart) { - for (jiaobanCount = 0; jiareCount < jiareAllCount; jiareAllCount++) { - if (ExecuteTest.IsStart) { + if (ExecuteTest.IsStart && !ExecuteTest.IsForcedEnd) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + jiaredangwei.setText(item + ""); + } + }); + + for (int i = 0; i < jiareAllCount; i++) { + if (ExecuteTest.IsStart && !ExecuteTest.IsForcedEnd) { ExecuteTest.ExecuteOperationSteps(ExecuteTest.Get加热(item).processname, ExecuteTest.Get加热(item).processvalue); ExecuteTest.ThreadDelay(jiareJR);//加热持续多少秒 ExecuteTheRecipe.WritePLC("加热", false, null); ExecuteTest.ThreadDelay(jiareLQ * 60);//冷却多少分钟 + jiareCount=i+1; getActivity().runOnUiThread(new Runnable() { @Override public void run() { diff --git a/app/src/main/res/layout/fragment_auto_test_more.xml b/app/src/main/res/layout/fragment_auto_test_more.xml index 26342d80..99f1f736 100644 --- a/app/src/main/res/layout/fragment_auto_test_more.xml +++ b/app/src/main/res/layout/fragment_auto_test_more.xml @@ -115,6 +115,38 @@ + + + +