From b16476303e75b4a8d2e179b51a05a20e08ab9946 Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 21 Oct 2023 10:48:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BB=A1=E7=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ExecuteTheRecipe.java | 76 +++++++ .../common/constant/ConfigName.java | 53 +++-- .../bnframework/common/constant/DataBus.java | 2 + .../bonait/bnframework/common/db/QueryDB.java | 13 ++ .../bnframework/common/db/mode/BPA_SILOS.java | 4 +- .../common/db/res/SilosLsjyMode.java | 3 + .../modules/home/adapter/lsjy_adapter.java | 140 ++++++++++-- .../modules/home/adapter/wdsz_adapter.java | 35 ++- .../home/fragment/MakeGoodFragment.java | 89 ++++---- .../from/fragment/JiaoYan_lsjy_fragment.java | 115 +++++----- .../fragment/mode/add_manguan_control.java | 201 ++++++++++++++++++ app/src/main/res/drawable/huanxing.xml | 13 ++ .../layout => }/fragment_jiaoyan_zdbs.xml | 41 ++-- .../main/res/layout/fragment_make_good.xml | 6 +- .../layout/item/layout/dialog_add_manguan.xml | 158 ++++++++++++++ .../main/res/layout/item/layout/lsjy_item.xml | 159 +++++++++----- app/src/main/res/mipmap-xxxhdpi/aibs.png | Bin 0 -> 33367 bytes .../res/mipmap-xxxhdpi/manguangtubiao.png | Bin 0 -> 12763 bytes 18 files changed, 846 insertions(+), 262 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_manguan_control.java create mode 100644 app/src/main/res/drawable/huanxing.xml rename app/src/main/res/layout/{datatab/layout => }/fragment_jiaoyan_zdbs.xml (80%) create mode 100644 app/src/main/res/layout/item/layout/dialog_add_manguan.xml create mode 100644 app/src/main/res/mipmap-xxxhdpi/aibs.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/manguangtubiao.png 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 915bc1dd..1850273d 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -116,6 +116,38 @@ public class ExecuteTheRecipe { * 当前制作商品 */ public static ResGoodsMake GoodMake=null; + + /** + * 出料口重量 + */ + public static int OutletWeigh=0; + + /** + * 杯子检测 + */ + public static boolean IsCup=false; + + /** + * 水池温度 + */ + public static int WaterTemp=0; + + /** + * 果糖左温度 + */ + public static int SugarTempLeft=0; + /** + * 果糖右温度 + */ + public static int SugarTempRight=0; + /** + * 重量刷新提示 + */ + public static IRun WeighComplete; + /** + * 温度刷新提示 + */ + public static IRun TempComplete; //endregion //region 执行配方 @@ -264,6 +296,50 @@ public class ExecuteTheRecipe { } }); + + ThreadManager.Get().StartLong("PLC设备-温度重量", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { + if(!IsMakeGood) + { + Object zl= ExecuteTheRecipe.ReadPLC("称当前重量"); + OutletWeigh=zl==null?0:(int)zl; + Object bz= ExecuteTheRecipe.ReadPLC("出料口检测"); + IsCup=bz==null?false:(boolean) bz; + Object obj1= ExecuteTheRecipe.ReadPLC("水池温度"); + WaterTemp=obj1==null?0:(int)obj1; + + if (!ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) + { + Object obj2= ExecuteTheRecipe.ReadPLC("果糖左温度"); + Object obj3= ExecuteTheRecipe.ReadPLC("果糖右温度"); + SugarTempLeft=obj2==null?0:(int)obj2; + SugarTempRight=obj3==null?0:(int)obj3; + } + + if (WeighComplete!=null) + { + WeighComplete.Run(); + } + if (TempComplete!=null) + { + TempComplete.Run(); + } + + } + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + Thread.sleep(200); + } + + @Override + public void RunComplete() throws InterruptedException { + + } + }); + ThreadManager.Get().StartLong("PLC设备-自动加热补水", true, new IThread() { @Override public void Run() throws InterruptedException { 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 7c25ca38..83644a07 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 @@ -423,18 +423,18 @@ public class ConfigName { //手动控制 add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("M_蠕动泵1", "M50.0", 1, 1)); - add(new Res_PLCADDRESS("M_蠕动泵2", "M50.1", 1, 1)); - add(new Res_PLCADDRESS("M_蠕动泵3", "M50.2", 1, 1)); - add(new Res_PLCADDRESS("M_蠕动泵4", "M50.3", 1, 1)); - add(new Res_PLCADDRESS("M_蠕动泵5", "M50.4", 1, 1)); - add(new Res_PLCADDRESS("M_隔膜泵1", "M50.5", 1, 1)); - add(new Res_PLCADDRESS("M_隔膜泵2", "M50.6", 1, 1)); - add(new Res_PLCADDRESS("M_隔膜泵3", "M50.7", 1, 1)); - add(new Res_PLCADDRESS("M_隔膜泵4", "M51.0", 1, 1)); - add(new Res_PLCADDRESS("M_隔膜泵5", "M51.1", 1, 1)); - add(new Res_PLCADDRESS("M_果糖泵1", "M51.2", 1, 1)); - add(new Res_PLCADDRESS("M_果糖泵2", "M51.3", 1, 1)); + add(new Res_PLCADDRESS("手动控制1", "M50.0", 1, 1)); + add(new Res_PLCADDRESS("手动控制2", "M50.1", 1, 1)); + add(new Res_PLCADDRESS("手动控制3", "M50.2", 1, 1)); + add(new Res_PLCADDRESS("手动控制4", "M50.3", 1, 1)); + add(new Res_PLCADDRESS("手动控制5", "M50.4", 1, 1)); + add(new Res_PLCADDRESS("手动控制6", "M50.5", 1, 1)); + add(new Res_PLCADDRESS("手动控制7", "M50.6", 1, 1)); + add(new Res_PLCADDRESS("手动控制8", "M50.7", 1, 1)); + add(new Res_PLCADDRESS("手动控制9", "M51.0", 1, 1)); + add(new Res_PLCADDRESS("手动控制10", "M51.1", 1, 1)); + add(new Res_PLCADDRESS("手动控制11", "M51.2", 1, 1)); + add(new Res_PLCADDRESS("手动控制12", "M51.3", 1, 1)); add(new Res_PLCADDRESS("M_清洗液泵", "M51.4", 1, 1)); add(new Res_PLCADDRESS("M_排水阀开", "M53.4", 1, 1)); @@ -734,27 +734,26 @@ public class ConfigName { //手动控制 add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("M_蠕动泵1", "M50.0", 1, 1)); - - add(new Res_PLCADDRESS("M_外置仓1正转", "M50.0", 1, 1)); - add(new Res_PLCADDRESS("M_外置仓2正转", "M50.1", 1, 1)); - add(new Res_PLCADDRESS("M_外置仓3正转", "M50.2", 1, 1)); - add(new Res_PLCADDRESS("M_外置仓4正转", "M50.3", 1, 1)); - add(new Res_PLCADDRESS("M_外置仓5正转", "M50.4", 1, 1)); - add(new Res_PLCADDRESS("M_外置仓6正转", "M50.5", 1, 1)); + add(new Res_PLCADDRESS("手动控制1", "M50.0", 1, 1)); + add(new Res_PLCADDRESS("手动控制2", "M50.1", 1, 1)); + add(new Res_PLCADDRESS("手动控制3", "M50.2", 1, 1)); + add(new Res_PLCADDRESS("手动控制4", "M50.3", 1, 1)); + add(new Res_PLCADDRESS("手动控制5", "M50.4", 1, 1)); + add(new Res_PLCADDRESS("手动控制6", "M50.5", 1, 1)); + add(new Res_PLCADDRESS("手动控制7", "M51.4", 1, 1)); + add(new Res_PLCADDRESS("手动控制8", "M51.5", 1, 1)); + add(new Res_PLCADDRESS("手动控制9", "M51.6", 1, 1)); + add(new Res_PLCADDRESS("手动控制10", "M51.7", 1, 1)); + add(new Res_PLCADDRESS("手动控制11", "M52.0", 1, 1)); + add(new Res_PLCADDRESS("手动控制12", "M52.1", 1, 1)); + add(new Res_PLCADDRESS("手动控制13", "M52.2", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓1反转", "M50.6", 1, 1)); add(new Res_PLCADDRESS("M_外置仓2反转", "M50.7", 1, 1)); add(new Res_PLCADDRESS("M_外置仓3反转", "M51.0", 1, 1)); add(new Res_PLCADDRESS("M_外置仓4反转", "M51.1", 1, 1)); add(new Res_PLCADDRESS("M_外置仓5反转", "M51.2", 1, 1)); add(new Res_PLCADDRESS("M_外置仓6反转", "M51.3", 1, 1)); - add(new Res_PLCADDRESS("M_粉料通道1", "M51.4", 1, 1)); - add(new Res_PLCADDRESS("M_粉料通道2", "M51.5", 1, 1)); - add(new Res_PLCADDRESS("M_粉料通道3", "M51.6", 1, 1)); - add(new Res_PLCADDRESS("M_酱油通道", "M51.7", 1, 1)); - add(new Res_PLCADDRESS("M_醋通道", "M52.0", 1, 1)); - add(new Res_PLCADDRESS("M_猪油通道", "M52.1", 1, 1)); - add(new Res_PLCADDRESS("M_牛油通道", "M52.2", 1, 1)); add(new Res_PLCADDRESS("M_保温池进水阀", "M53.4", 1, 1)); add(new Res_PLCADDRESS("M_保温池排水阀", "M53.5", 1, 1)); diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index e9cf5943..e8e1d80b 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -338,6 +338,8 @@ public class DataBus { // String s = String.valueOf(val); mode.jzkg= false;//kg==null?false:(boolean) kg; mode.Value="0.0";// //String.format("%.1f", (Double.parseDouble(s) / 10)); + mode.mgtime=silo.bValue; + mode.id=silo.id; SilosLsjy.add(mode); } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 6988e628..7b854190 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -405,6 +405,19 @@ public class QueryDB { } return data; } + /** + * 修改满管时间 + * + * @param id + * @param data + */ + public static void UpdateMGTime(String id, int data) { + BPA_SILOS silos = GetSilosID(id); + if (silos != null) { + silos.bValue = data; + Update(BPA_SILOS.class, silos); + } + } /** * 修改校准值 diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java index ed2c1029..a8269637 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java @@ -14,8 +14,8 @@ public class BPA_SILOS extends ModeBase { //下线阈值:20g public int thrsoleValue; //PLC控制信号量 - public String plcValue; - //标准值 标准 1s出多少g(出场标准) + public String plcValue;// + //标准值 标准 1s出多少g(出场标准) 更改为 满管 需要时间 public int bValue; //校准值 实际校准1s出多少g public int jValue; diff --git a/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java b/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java index 8ac7475e..50089a3f 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java @@ -17,4 +17,7 @@ public class SilosLsjyMode { public boolean jzkg; //通道校准值 public String Value; + + public String id;//料仓id + public int mgtime;//满管时间 } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java index 86595c25..eca9d1ae 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java @@ -3,13 +3,17 @@ package com.bonait.bnframework.modules.home.adapter; import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; +import android.os.SystemClock; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.Chronometer; import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -18,11 +22,14 @@ import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.res.SilosLsjyMode; +import com.bonait.bnframework.common.helper.I.IRun; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.utils.ToastUtils; import com.suke.widget.SwitchButton; +import java.sql.Struct; import java.util.List; /** @@ -53,25 +60,23 @@ public class lsjy_adapter extends RecyclerView.Adapter public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { try { if (holder instanceof MyGoodLCViewHolder) { + MyGoodLCViewHolder myViewHolder = (MyGoodLCViewHolder) holder; SilosLsjyMode goodsMake= mainGoods.get(position); String name= "通道"+goodsMake.num+"(" +goodsMake.name+")"; + myViewHolder.num=goodsMake.num; myViewHolder.name.setText(name+""); myViewHolder.wlname.setText(goodsMake.materialName+""); - // myViewHolder.edittext_xs.setText(goodsMake.xs+""); myViewHolder.control_switch.setChecked(goodsMake.jzkg); myViewHolder.edittext_tdzl.setText(goodsMake.Value+""); + myViewHolder.edittext_mgsj.setText(goodsMake.mgtime+""); + myViewHolder.control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(SwitchButton view, boolean isChecked) { - //boolean ischick= myViewHolder.control_switch.isChecked(); DataBus.getInstance().SilosLsjy.get(position).jzkg=isChecked; ExecuteTheRecipe.WritePLC("通道" + goodsMake.num+"校准开关", isChecked, null); - //goodsMake.jzkg=ischick; - //notifyDataSetChanged(); -// ExecuteTheRecipe.WritePLC("通道1校准开关",ischick,null); -// ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭")); } }); @@ -79,16 +84,11 @@ public class lsjy_adapter extends RecyclerView.Adapter @Override public void onClick(View view) { String value = myViewHolder.edittext_tdzl.getText().toString(); - //String value1=myViewHolder.edittext_xs.getText().toString(); Short val = 0; - //float xs= 1.0F; try { val = (short) Math.round((Double.parseDouble(value) * 10)); - //xs=Float.parseFloat(value1); } catch (Exception e) { } - - //ExecuteTheRecipe.WritePLC("出料系数"+goodsMake.num,xs,null); ExecuteTheRecipe.WritePLC("校准值" + goodsMake.num, val, new IWriteCallBack() { @Override public void onSuccess() { @@ -101,13 +101,109 @@ public class lsjy_adapter extends RecyclerView.Adapter } }); + String value1 = myViewHolder.edittext_mgsj.getText().toString(); + int val1 = 0; + try { + val1 =(value1==null|| value1.isEmpty())?0:Integer.parseInt(value1); + QueryDB.UpdateMGTime(DataBus.getInstance().SilosLsjy.get(position).id,val1); + } catch (Exception e) { + } + } }); + final int[] time = {0}; + final int[] zl = {0}; + //开始计算满管时间 + myViewHolder.save_mg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + zl[0] =ExecuteTheRecipe.OutletWeigh; + StartTime(myViewHolder); + } + }); + + //为Chronomter绑定事件监听器,超过一小时自动日内告知 + myViewHolder.runtime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { + @Override + public void onChronometerTick(Chronometer chronometer) { + //如果计时到现在超过了一小时秒 10s + if (SystemClock.elapsedRealtime() - myViewHolder.runtime.getBase() > 10 * 1000) { + time[0] =StopTime(myViewHolder); + DataBus.getInstance().SilosLsjy.get(position).mgtime=time[0]; + QueryDB.UpdateMGTime(DataBus.getInstance().SilosLsjy.get(position).id,time[0]); + } + } + }); + + ExecuteTheRecipe.WeighComplete=new IRun() { + @Override + public void Run() { + if(ExecuteTheRecipe.OutletWeigh >=(zl[0]+2)) + { + time[0] =StopTime(myViewHolder); + DataBus.getInstance().SilosLsjy.get(position).mgtime=time[0]; + QueryDB.UpdateMGTime(DataBus.getInstance().SilosLsjy.get(position).id,time[0]); + } + } + }; + + } } catch (Exception e) { e.printStackTrace(); } } + + /** + * 启动定时器 + */ + public void StartTime(MyGoodLCViewHolder myGoodLCViewHolder) { + myGoodLCViewHolder.jishiqi.setVisibility(View.VISIBLE); + myGoodLCViewHolder.main_laout.setVisibility(View.GONE); + + myGoodLCViewHolder.runtime.setBase(SystemClock.elapsedRealtime()); + myGoodLCViewHolder.runtime.start(); + + new Thread(new Runnable() { + @Override + public void run() { + try { + //自动模式 + ExecuteTheRecipe.WritePLC("手自切换", false, null); + //开启 + ExecuteTheRecipe.WritePLC("手动控制"+myGoodLCViewHolder.num,true,null); + } catch (Exception e) { + + } + } + }).start(); + } + + /** + * 停止定时器 + */ + public int StopTime(MyGoodLCViewHolder myGoodLCViewHolder) { + myGoodLCViewHolder.jishiqi.setVisibility(View.GONE); + myGoodLCViewHolder.main_laout.setVisibility(View.VISIBLE); + long elapsedMillis = SystemClock.elapsedRealtime() - myGoodLCViewHolder.runtime.getBase(); + myGoodLCViewHolder.runtime.stop(); + + int time=(int) (elapsedMillis / 1000); + myGoodLCViewHolder.edittext_mgsj.setText(time+""); + + new Thread(new Runnable() { + @Override + public void run() { + try { + ExecuteTheRecipe.WritePLC("手动控制"+myGoodLCViewHolder.num,false,null); + } catch (Exception e) { + + } + } + }).start(); + return time;//当前点击多少秒 + } + private Activity findActivity(@NonNull Context context) { if (context instanceof Activity) { return (Activity) context; @@ -152,10 +248,6 @@ public class lsjy_adapter extends RecyclerView.Adapter * 物料名称 */ TextView wlname; - /** - * 系数 - */ - //EditText edittext_xs; /** * 校准开关 */ @@ -168,6 +260,16 @@ public class lsjy_adapter extends RecyclerView.Adapter * 保存值 */ Button save_value; + + + EditText edittext_mgsj; + Button save_mg; + + RelativeLayout jishiqi; + LinearLayout main_laout; + Chronometer runtime; + + int num=0; public MyGoodLCViewHolder(View view) { super(view); name = (TextView) view.findViewById(R.id.name); @@ -176,6 +278,14 @@ public class lsjy_adapter extends RecyclerView.Adapter control_switch = (SwitchButton)view.findViewById(R.id.control_switch); edittext_tdzl=(EditText) view.findViewById(R.id.edittext_tdzl); save_value=(Button) view.findViewById(R.id.save_value); + + + edittext_mgsj=(EditText) view.findViewById(R.id.edittext_mgsj); + save_mg=(Button) view.findViewById(R.id.save_mg); + + jishiqi=view.findViewById(R.id.jishiqi); + main_laout=view.findViewById(R.id.main_laout); + runtime=view.findViewById(R.id.runtime); } } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java index f07f9f53..e4657dba 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java @@ -24,6 +24,7 @@ import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.res.SilosLsjyMode; import com.bonait.bnframework.common.db.res.wdszMode; +import com.bonait.bnframework.common.helper.I.IRun; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.helper.InputFilterMinMax; import com.bonait.bnframework.common.utils.ToastUtils; @@ -72,12 +73,18 @@ public class wdsz_adapter extends RecyclerView.Adapter myViewHolder.temp.setText(goodsMake.temp+""); myViewHolder.control_switch.setChecked(goodsMake.autoheat); - final String[] temp = {"0"}; Handler mHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case 0: - myViewHolder.temp.setText(temp[0]+""); + if(goodsMake.name.equals("水池温度")) + { + myViewHolder.temp.setText(ExecuteTheRecipe.WaterTemp+""); + } else if (goodsMake.name.equals("果糖左温度")) { + myViewHolder.temp.setText(ExecuteTheRecipe.SugarTempLeft+""); + }else if (goodsMake.name.equals("果糖右温度")) { + myViewHolder.temp.setText(ExecuteTheRecipe.SugarTempRight+""); + } break; case 1: @@ -89,28 +96,12 @@ public class wdsz_adapter extends RecyclerView.Adapter } }; - new Thread(new Runnable() { + ExecuteTheRecipe.TempComplete=new IRun() { @Override - public void run() { - while(true) - { - try { - if(ConfigName.getInstance().PlcIsConnect && !ExecuteTheRecipe.IsMakeGood) - { - Object obj= ExecuteTheRecipe.ReadPLC(goodsMake.name); - if(obj!=null) - { - temp[0] =String.valueOf(obj); - mHandler.sendEmptyMessage(0); - } - } - Thread.sleep(200); - } catch (InterruptedException e) { - } - } + public void Run() { + mHandler.sendEmptyMessage(0); } - }).start(); - + }; myViewHolder.control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(SwitchButton view, boolean isChecked) { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java index 529a1ee0..ab0a798f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java @@ -35,8 +35,10 @@ import com.bonait.bnframework.common.db.res.ResGoodProperty; import com.bonait.bnframework.common.db.res.ResGoodsMake; import com.bonait.bnframework.common.db.res.SilosLsjyMode; import com.bonait.bnframework.common.helper.I.IRun; +import com.bonait.bnframework.common.helper.I.IThread; import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.helper.ThreadManager; import com.bonait.bnframework.common.linktab.LinkMode; import com.bonait.bnframework.common.linktab.TopItemDecoration; import com.bonait.bnframework.common.linktab.good.GoodLeftAdapter; @@ -50,6 +52,7 @@ import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; import com.bonait.bnframework.modules.home.adapter.wl_adapter; import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control; +import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control; import com.bonait.bnframework.modules.home.fragment.mode.add_pf_control; import com.litao.slider.NiftySlider; import com.orhanobut.logger.Logger; @@ -100,11 +103,12 @@ public class MakeGoodFragment extends BaseFragment { @BindView(R.id.add_makegood) add_makegood_control add_makegood; + @BindView(R.id.add_manguan) + add_manguan_control add_manguan; + @BindView(R.id.good_gengxin) Button good_gengxin; - - /** * 当前温度 */ @@ -265,7 +269,7 @@ public class MakeGoodFragment extends BaseFragment { return; } - if (!clk) + if (!ExecuteTheRecipe.IsCup) { ToastUtils.warning("出料口没有检测到器皿!"); return; @@ -279,7 +283,7 @@ public class MakeGoodFragment extends BaseFragment { Object sx=ExecuteTheRecipe.ReadPLC("果糖左温度设置"); int wdsz=sx==null?0:(int)sx; - if(gt1wd siloslist=new ArrayList<>(); + /** + * 点击事件 + */ + public MyClickListener mListener = null; + private View root; + + private Context contextMian; + + public add_manguan_control(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + contextMian=context; + root = LayoutInflater.from(context).inflate(R.layout.dialog_add_manguan, this); + ButterKnife.bind(this, root); + Init(); + } + + + public void Init() { + //初始化界面控件的事件 + initEvent(); + } + + + private void initData() { + //2.填充规则数据,查询所有属性大类 + siloslist= QueryDB.GetSilosALL(); + } + + /** + * 设置数据 + * + * @param + */ + public void SetData() { + try { + initData(); + } catch (Exception ex) { + + } + } + + + private void initEvent() { + quzhizuo.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + SaveData(); + } + }); + close_from_good.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.clickListenerNew(v, 0, null); + } + } + }); + + //为Chronomter绑定事件监听器,超过一小时自动日内告知 + runtime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { + @Override + public void onChronometerTick(Chronometer chronometer) { + //如果计时到现在超过了一小时秒 10s + if (SystemClock.elapsedRealtime() - runtime.getBase() > 120 * 1000) { + StopTime(); + } + } + }); + } + + private Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + switch (msg.what) { + case 0: + if(i>=siloslist.size()) + { + StopTime(); + ToastUtils.info("料仓满管完成!"); + } + break; + case 1: + + break; + case 2: + + break; + } + + } + }; + + int i=0; + /** + * 保存数据 + */ + public boolean SaveData() { + i=0; + ToastUtils.info("料仓满管开始!"); + StartTime(); + ExecuteTheRecipe.WritePLC("手自切换", false, null); + for (BPA_SILOS item:siloslist) + { + int time=item.bValue<=0?5:item.bValue;//默认5秒 + ExecuteTheRecipe.WritePLC("手动控制"+item.num,true,null); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ExecuteTheRecipe.WritePLC("手动控制"+item.num,false,null); + mHandler.sendEmptyMessage(0); + i++; + } + }, time * 1000); + } + + return false; + } + + + /** + * 启动定时器 + */ + public void StartTime() { + jishiqi.setVisibility(View.VISIBLE); + image_gz.setVisibility(View.GONE); + + runtime.setBase(SystemClock.elapsedRealtime()); + runtime.start(); + } + + /** + * 停止定时器 + */ + public int StopTime() { + jishiqi.setVisibility(View.GONE); + image_gz.setVisibility(View.VISIBLE); + long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase(); + runtime.stop(); + + int time=(int) (elapsedMillis / 1000); + return time;//当前点击多少秒 + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/huanxing.xml b/app/src/main/res/drawable/huanxing.xml new file mode 100644 index 00000000..400d1c30 --- /dev/null +++ b/app/src/main/res/drawable/huanxing.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/fragment_jiaoyan_zdbs.xml b/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml similarity index 80% rename from app/src/main/res/layout/datatab/layout/fragment_jiaoyan_zdbs.xml rename to app/src/main/res/layout/fragment_jiaoyan_zdbs.xml index cce5f70e..595163fc 100644 --- a/app/src/main/res/layout/datatab/layout/fragment_jiaoyan_zdbs.xml +++ b/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml @@ -12,22 +12,21 @@ android:background="@color/main_background" android:orientation="vertical"> - - - + android:src="@mipmap/aibs"> + + + + android:focusable="true"/> + + - - - -