diff --git a/app/build.gradle b/app/build.gradle index c41cc1e3..a888b814 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -158,4 +158,6 @@ dependencies { //MQTT // implementation files('libs\\org.eclipse.paho.android.service-1.1.1.jar') // implementation files('libs\\org.eclipse.paho.client.mqttv3-1.2.5.jar') + + } 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 b941613f..61806621 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -137,14 +137,13 @@ public class ExecuteTheRecipe { ExecuteMaterialIssuance(recipe.processvalue); } else if (recipe.materialType == 1)//工序模型 { - if (recipe.processname.equals("抽水")) { - BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); - ExecuteOperationSteps(data1.processname, data1.processvalue); + if (recipe.processname.equals("加水")) { + BPA_GOODSRECIPE data2 = Get位置("最高", "抽料位"); + ExecuteOperationSteps(data2.processname, data2.processvalue); } else if (recipe.processname.equals("主料")) { - BPA_GOODSRECIPE data1 = Get位置("最高", "炒菜位1"); - ExecuteOperationSteps(data1.processname, data1.processvalue); + BPA_GOODSRECIPE data3 = Get位置("最高", "炒菜位1"); + ExecuteOperationSteps(data3.processname, data3.processvalue); } - ExecuteOperationSteps(recipe.processname, recipe.processvalue); } } catch (Exception ex) { @@ -670,22 +669,15 @@ public class ExecuteTheRecipe { if (ExecuteCurrentOperation != null) { ExecuteCurrentOperation.Run("加热" + "|" + writeValue); } - WritePLC(key, writeValue, new IWriteCallBack() { - @Override - public void onSuccess() { - if (writeValue == 0) { - ConfigName.getInstance().IsOpenHuoLi = false; - WritePLC("加热", false, null); - } else { - ConfigName.getInstance().IsOpenHuoLi = true; - WritePLC("加热", true, null); - } - } - - @Override - public void onFailure(String ErrorMsg) { - } - }); + //写加热挡位 + WritePLC(key, writeValue, null); + if (writeValue == 0) { + ConfigName.getInstance().IsOpenHuoLi = false; + WritePLC("加热", false, null); + } else { + ConfigName.getInstance().IsOpenHuoLi = true; + WritePLC("加热", true, null); + } } } @@ -719,12 +711,22 @@ public class ExecuteTheRecipe { } if (val > 0) { WritePLC("炒锅抽水", true, null); + final boolean[] IsComplete = {false}; new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { - ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); + IsComplete[0] = true; } }, val * 1000); + + long a = System.currentTimeMillis(); + while (!IsComplete[0]) { + if ((System.currentTimeMillis() - a) > 1000 * whileTime) { + break; + } + Thread.sleep(100); + } + ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); @@ -779,7 +781,7 @@ public class ExecuteTheRecipe { final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * 120) { + if ((System.currentTimeMillis() - a) > 1000 * (whileTime*3)) { break; } else { Object sb = ReadPLC(name);//ListeningValue.get(name); diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/SendUdpMode.java b/app/src/main/java/com/bonait/bnframework/common/helper/SendUdpMode.java new file mode 100644 index 00000000..011cebfe --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/SendUdpMode.java @@ -0,0 +1,15 @@ +package com.bonait.bnframework.common.helper; + +public class SendUdpMode { + public String ip; + public int port; + //数据格式 + public String data; + + public SendUdpMode(String _IP,int _PORT,String _DATA) + { + this.ip=_IP; + this.port=_PORT; + this.data=_DATA; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/UdpHelper.java b/app/src/main/java/com/bonait/bnframework/common/helper/UdpHelper.java new file mode 100644 index 00000000..b469fd67 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/UdpHelper.java @@ -0,0 +1,194 @@ +package com.bonait.bnframework.common.helper; + +import android.annotation.SuppressLint; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.charset.Charset; + +/** + * UDP 帮助类 + */ +public class UdpHelper { + //region 变量 + private static final String TAG = "UDP帮助"; + /** + * 服务端口 + */ + public int ServerPort = 10000; + /** + * 是否启动监听 + */ + private volatile boolean isRuning = false; + /** + * 接收数据服务端 + */ + private DatagramSocket receiveSocket = null; + /** + * 反馈数据 + */ + public Handler myHandler = null; + /** + * 服务端 + */ + private ServerThread serverThread = new ServerThread(); + /** + * 客户端 + */ + public ClientThread clientThread = new ClientThread(); + + //endregion + + //region 外部调用 + + /** + * 服务启动监听 + * + * @param port + */ + public void Start(int port) { + ServerPort = port; + try { + receiveSocket = new DatagramSocket(port); + } catch (SocketException e) { + } + isRuning = true; + } + + /** + * 停止监听 + */ + public void Stop() { + isRuning = false; + if(receiveSocket!=null) + { + receiveSocket.close(); + } + } + + /** + * 发送数据 + * + * @param ip + * @param port + * @param data + */ + public void SendData(String ip, int port, String data) { + Message msg = Message.obtain(); + msg.obj = new SendUdpMode(ip, port, data); + msg.what = 1; + clientThread.mhandler.sendMessage(msg); + } + //endregion + + //region 线程 + + /** + * 发送数据线程 + */ + public class ClientThread extends Thread { + private Handler mhandler = null; + + @SuppressLint("HandlerLeak") + @Override + public void run() { + Looper.prepare(); + mhandler = new Handler() { + @Override + public void handleMessage(Message msg) { + SendUdpMode message = (SendUdpMode) msg.obj; + byte[] data = message.data.getBytes(Charset.forName("GBK")); + + DatagramPacket dpSend = null; + DatagramSocket sendSocket = null; + try { + InetAddress inetAddress = InetAddress.getByName(message.ip.toString().trim()); + dpSend = new DatagramPacket(data, data.length, inetAddress, message.port); + } catch (UnknownHostException e) { + } + try { + double start = System.currentTimeMillis(); + for (int i = 0; i < 1; i++) { + sendSocket = new DatagramSocket(); + sendSocket.send(dpSend); + sendSocket.close(); + Thread.sleep(80); + Log.i(TAG, "发送数据: " + new String(data)); + } + double end = System.currentTimeMillis(); + double times = end - start; + Log.i(TAG, "发送数据所用时间: " + times + "ms"); + } catch (IOException e) { + Log.i(TAG, "发送数据异常: " + e.getMessage()); + } catch (InterruptedException e) { + Log.i(TAG, "发送数据异常: " + e.getMessage()); + } finally { + if (sendSocket != null) { + sendSocket.close(); + } + } + } + }; + Looper.loop(); + } + } + + /** + * 服务线程 + */ + private class ServerThread extends Thread { + @Override + public void run() { + while (true) { + if (isRuning) { + byte[] receiveData = new byte[1024]; + DatagramPacket dpReceive = null; + dpReceive = new DatagramPacket(receiveData, receiveData.length); + try { + receiveSocket.receive(dpReceive); + } catch (IOException e) { + e.printStackTrace(); + } + String recIp = dpReceive.getAddress().toString().substring(1); + String port = String.valueOf(dpReceive.getPort()); + String content = ""; + content = new String(receiveData, 0, dpReceive.getLength(), Charset.forName("GBK")); + if (dpReceive != null) { + Message revMessage = Message.obtain(); + revMessage.what = 1; + revMessage.obj = "收到来自" + recIp + ":" + port + "的信息:" + content; + Log.i(TAG, "收到来自" + recIp + ":" + port + "的信息:" + content); + if (myHandler != null) { + myHandler.sendMessage(revMessage); + } + } + } + } + } + } + //endregion + + //region 私有 + private static UdpHelper mInstance; //实例变量设置私有,防止直接通过类名访问 + + public static synchronized UdpHelper getInstance() { //静态同步方法作为唯一的实例对象获取方式 + if (mInstance == null) { + mInstance = new UdpHelper(); + } + return mInstance; + } + + private UdpHelper() { //默认构造函数私有,防止类外直接new创建对象 + clientThread.start(); + serverThread.start(); + } + //endregion +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java index 0f7a8ed2..a016e7e8 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java @@ -461,7 +461,7 @@ public class BottomNavigationNewActivity extends BaseActivity { ToastUtils.error("异常信息:" + ex.getMessage()); } } - Thread.sleep(3000); + Thread.sleep(5000); } catch (InterruptedException e) { ToastUtils.info("异常信息:" + e.getMessage()); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java index 01d0c031..3f921c2b 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java @@ -11,6 +11,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; @@ -73,6 +74,10 @@ public class good_adapter extends RecyclerView.Adapter String url = mode.getAddress(); boolean isCloud = mode.getIsCloud();//是否云端商品 +// myViewHolder.cardView.setRadius(20);//设置图片圆角的半径大小 +// myViewHolder.cardView.setCardElevation(10);//设置阴影部分大小 +// myViewHolder.cardView.setContentPadding(2, 2, 2, 2);//设置图片距离阴影大小 + if (isCloud) { myViewHolder.Sc_text.setText("下载"); myViewHolder.sc_layout.setImageResource(R.mipmap.yxz); @@ -92,8 +97,7 @@ public class good_adapter extends RecyclerView.Adapter myViewHolder.Sc_text.setVisibility(View.VISIBLE); myViewHolder.sc_layout.setVisibility(View.VISIBLE); - }else - { + } else { myViewHolder.sc_image.setVisibility(View.GONE); myViewHolder.delete_text.setVisibility(View.GONE); myViewHolder.Sc_text.setVisibility(View.GONE); @@ -103,8 +107,7 @@ public class good_adapter extends RecyclerView.Adapter myViewHolder.tvTag.setText(name); myViewHolder.tvNote.setText("时间:" + mode.getNote() + "秒"); //设置图片 - if(url!=null && !url.isEmpty() &&!url.equals("未知")) - { + if (url != null && !url.isEmpty() && !url.equals("未知")) { myBitmapUtils.disPlay(myViewHolder.ImageUrl, url); } //上传按钮点击 @@ -168,8 +171,7 @@ public class good_adapter extends RecyclerView.Adapter if (isCloud) { ToastUtils.warning("请先下载该商品!"); } else { - if (mListener!=null) - { + if (mListener != null) { mListener.clickListenerNew(view, 4, mode); } } @@ -228,11 +230,12 @@ public class good_adapter extends RecyclerView.Adapter public static class MyLCViewHolder1 extends RecyclerView.ViewHolder { private TextView tvTag, tvNote, tvAccount, Sc_text; - public RelativeLayout delete_text,shangchuang; - private ImageView ImageUrl,sc_layout;//图片 + public RelativeLayout delete_text, shangchuang; + private ImageView ImageUrl, sc_layout;//图片 private ImageView sc_image;//是否收藏 + private CardView cardView; public boolean IsSC = false; @@ -241,11 +244,12 @@ public class good_adapter extends RecyclerView.Adapter tvTag = view.findViewById(R.id.Tag_text); tvNote = view.findViewById(R.id.Note_text); Sc_text = view.findViewById(R.id.Sc_text); - sc_layout=view.findViewById(R.id.sc_layout); + sc_layout = view.findViewById(R.id.sc_layout); delete_text = view.findViewById(R.id.delete_text); sc_image = view.findViewById(R.id.sc_image);//收藏 ImageUrl = view.findViewById(R.id.ImageUrl);//图片 - shangchuang= view.findViewById(R.id.shangchuang); + shangchuang = view.findViewById(R.id.shangchuang); + cardView = view.findViewById(R.id.cardView); } } } 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 81ebd572..63a8b166 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 @@ -24,6 +24,7 @@ import android.view.MotionEvent; import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.SeekBar; @@ -100,9 +101,9 @@ public class Home1Fragment extends BaseFragment { @BindView(R.id.startbutton) ImageView startbutton;//启动安 @BindView(R.id.choushui_control) - imagebutton_control choushui_control;//抽水 + LinearLayout choushui_control;//抽水 @BindView(R.id.fangshui_control) - imagebutton_control fangshui_control;//防水 + LinearLayout fangshui_control;//防水 @BindView(R.id.chaoguo_wendu) QMUILinkTextView chaoguo_wendu;// @BindView(R.id.chaoguo_weizhi) @@ -355,43 +356,79 @@ public class Home1Fragment extends BaseFragment { //endregion //抽水启动 - choushui_control.mListener = new MyClickListener() { - @Override - public void clickListener(View v, Object data) { - boolean status = !(boolean) data; -// if (!IsMake(true)) -// { -// return; -// } - choushui_control.SetStatus(status); - ToastUtils.info("点击按钮:炒锅抽水" + status); - ExecuteTheRecipe.WritePLC("炒锅抽水", status, null); - } +// choushui_control.mListener = new MyClickListener() { +// @Override +// public void clickListener(View v, Object data) { +// boolean status = !(boolean) data; +//// if (!IsMake(true)) +//// { +//// return; +//// } +// choushui_control.SetStatus(status); +// ToastUtils.info("点击按钮:炒锅抽水" + status); +// ExecuteTheRecipe.WritePLC("炒锅抽水", status, null); +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } +// }; +// //放水启动 +// fangshui_control.mListener = new MyClickListener() { +// @Override +// public void clickListener(View v, Object data) { +// boolean status = !(boolean) data; +//// if (!IsMake(true)) +//// { +//// return; +//// } +// fangshui_control.SetStatus(status); +// ToastUtils.info("点击按钮:炒锅放水" + status); +// ExecuteTheRecipe.WritePLC("炒锅放水", status, null); +// } +// +// @Override +// public void clickListenerNew(View v, int k, Object data) { +// +// } +// }; + choushui_control.setOnTouchListener(new View.OnTouchListener() { @Override - public void clickListenerNew(View v, int k, Object data) { - + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("抽料位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + ExecuteTheRecipe.WritePLC("炒锅抽水", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); + } + } else { + ToastUtils.warning("请先控制锅口朝向:抽料位"); + ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); + } + return false; } - }; - //放水启动 - fangshui_control.mListener = new MyClickListener() { + }); + fangshui_control.setOnTouchListener(new View.OnTouchListener() { @Override - public void clickListener(View v, Object data) { - boolean status = !(boolean) data; -// if (!IsMake(true)) -// { -// return; -// } - fangshui_control.SetStatus(status); - ToastUtils.info("点击按钮:炒锅放水" + status); - ExecuteTheRecipe.WritePLC("炒锅放水", status, null); + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("清洗位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + ExecuteTheRecipe.WritePLC("炒锅放水", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + ExecuteTheRecipe.WritePLC("炒锅放水", false, null); + } + } else { + ToastUtils.warning("请先控制锅口朝向:清洗位"); + ExecuteTheRecipe.WritePLC("炒锅放水", false, null); + } + return false; } + }); - @Override - public void clickListenerNew(View v, int k, Object data) { - - } - }; btn_jiaoban.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { @Override @@ -506,7 +543,7 @@ public class Home1Fragment extends BaseFragment { try { if (Status && good != null) { - long startTime= System.currentTimeMillis(); //起始时间 + long startTime = System.currentTimeMillis(); //起始时间 try { //获取工艺 ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); @@ -527,19 +564,21 @@ public class Home1Fragment extends BaseFragment { ExecuteTheRecipe.WritePLC("搅拌", false, null); ExecuteTheRecipe.WritePLC("加热", false, null); - ConfigName.getInstance().IsOpenHuoLi= false; + ConfigName.getInstance().IsOpenHuoLi = false; ExecuteTheRecipe.BottomClick("平移-去1号位"); gongxuIndex = 10000; MakeCipe = null; goodsrecipesL = null; long endTime = System.currentTimeMillis(); //结束时间 - int time=(int) ((endTime-startTime)/1000); - Log.e("运行时长",String.format("方法使用时间 %d s",time)); + int time = (int) ((endTime - startTime) / 1000); + Log.e("运行时长", String.format("方法使用时间 %d s", time)); - if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(good.id,time);} + if (!ExecuteTheRecipe.IsForcedEnd) { + QueryDB.UpdateGoodsMakeTime(good.id, time); + } - ExecuteTheRecipe.all_list=new ArrayList<>(); + ExecuteTheRecipe.all_list = new ArrayList<>(); Activity activity = getActivity(); if (activity != null) { @@ -659,7 +698,7 @@ public class Home1Fragment extends BaseFragment { ToastUtils.error("异常信息:" + ex.getMessage()); } } - Thread.sleep(3000); + Thread.sleep(5000); } catch (InterruptedException e) { ToastUtils.info("异常信息:" + e.getMessage()); } @@ -685,7 +724,8 @@ public class Home1Fragment extends BaseFragment { /** * 温控开关 true 断开 false 闭合 */ - public boolean TempBool=false; + public boolean TempBool = false; + /** * 刷新UI界面 */ @@ -702,13 +742,13 @@ public class Home1Fragment extends BaseFragment { //Object val_wd =new Random().nextInt(250); if (val_wd != null) { - int dq_wd= (int)val_wd;//当前锅底温度 - if(dq_wd>=(ConfigName.getInstance().MaxTemp-5)) //如果当前温度大于最大温度限制 断开 + int dq_wd = (int) val_wd;//当前锅底温度 + if (dq_wd >= (ConfigName.getInstance().MaxTemp - 5)) //如果当前温度大于最大温度限制 断开 { - TempBool=true;//设置断开 - }else if(dq_wd<=(ConfigName.getInstance().MaxTemp-20))//需要闭合 + TempBool = true;//设置断开 + } else if (dq_wd <= (ConfigName.getInstance().MaxTemp - 20))//需要闭合 { - TempBool=false;//闭合 + TempBool = false;//闭合 } // if(ConfigName.getInstance().PlcIsConnect) @@ -732,8 +772,8 @@ public class Home1Fragment extends BaseFragment { // } // } // } - wk_zhuangtai.setText(TempBool?"断开":"闭合"); - wk_zhuangtai.setTextColor(TempBool?Color.parseColor("#F44336"):Color.parseColor("#01675B")); + wk_zhuangtai.setText(TempBool ? "断开" : "闭合"); + wk_zhuangtai.setTextColor(TempBool ? Color.parseColor("#F44336") : Color.parseColor("#01675B")); chaoguo_wendu.setText(val_wd + ""); } else { wk_zhuangtai.setText("闭合"); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java index 9bdd5366..06f4158f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java @@ -121,19 +121,18 @@ public class HomeFragmentPR extends BaseFragment { private void initTopBar() { mTopBar.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.topbj1)); mTopBar.setTitle("菜谱"); - mTopBar.addRightTextButton("设备状态:"+(ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"),R.id.status_image); + mTopBar.addRightTextButton("设备状态:" + (ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"), R.id.status_image); new Thread(new Runnable() { @Override public void run() { - while (true) - { + while (true) { try { activity.runOnUiThread(new Runnable() { @Override public void run() { mTopBar.removeAllRightViews(); - mTopBar.addRightTextButton("设备状态:"+(ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"),R.id.status_image); + mTopBar.addRightTextButton("设备状态:" + (ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"), R.id.status_image); } }); Thread.sleep(1000); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java index b5365b89..70246bc0 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java @@ -7,7 +7,9 @@ import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.content.Context; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; @@ -195,23 +197,99 @@ public class HomeFragmentSBKZ extends BaseFragment { guokoucaoxiang_dc.mListener = myClickListener; guokoucaoxiang_qx.mListener = myClickListener; - chushui.mListener = myClickListener; - xiguoshui.mListener = myClickListener; - touliao1.mListener = myClickListener; touliao2.mListener = myClickListener; touliao3.mListener = myClickListener; touliao4.mListener = myClickListener; - yeliao1.mListener = myClickListener; - yeliao2.mListener = myClickListener; - yeliao3.mListener = myClickListener; - + chushui.SetOnTounch(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("抽料位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + SetIDTouch(R.id.chushui, true); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + SetIDTouch(R.id.chushui, false); + } + } else { + ToastUtils.warning("请先控制锅口朝向:抽料位"); + SetIDTouch(R.id.chushui, false); + } + return false; + } + }); + xiguoshui.SetOnTounch(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("清洗位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + SetIDTouch(R.id.xiguoshui, true); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + SetIDTouch(R.id.xiguoshui, false); + } + } else { + ToastUtils.warning("请先控制锅口朝向:清洗位"); + SetIDTouch(R.id.xiguoshui, false); + } + return false; + } + }); + yeliao1.SetOnTounch(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("抽料位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + SetIDTouch(R.id.yeliao1, true); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + SetIDTouch(R.id.yeliao1, false); + } + } else { + ToastUtils.warning("请先控制锅口朝向:抽料位"); + SetIDTouch(R.id.yeliao1, false); + } + return false; + } + }); + yeliao2.SetOnTounch(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("抽料位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + SetIDTouch(R.id.yeliao2, true); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + SetIDTouch(R.id.yeliao2, false); + } + } else { + ToastUtils.warning("请先控制锅口朝向:抽料位"); + SetIDTouch(R.id.yeliao2, false); + } + return false; + } + }); + yeliao3.SetOnTounch(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + Object ob = ExecuteTheRecipe.getListingValue("抽料位反馈"); + if (ob != null && (boolean) ob) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + SetIDTouch(R.id.yeliao3, true); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + SetIDTouch(R.id.yeliao3, false); + } + } else { + ToastUtils.warning("请先控制锅口朝向:抽料位"); + SetIDTouch(R.id.yeliao3, false); + } + return false; + } + }); huoli.mListener = myClickListener; - chuchan.mListener = myClickListener; - DataBus.getInstance().SilosRefresh = new IRun() { @Override public void Run() { @@ -231,8 +309,7 @@ public class HomeFragmentSBKZ extends BaseFragment { touliao_k.setVisibility(View.GONE); touliao_m.setVisibility(View.GONE); device_image.setImageResource(R.mipmap.device00); - }else - { + } else { touliao_k.setVisibility(View.VISIBLE); touliao_m.setVisibility(View.VISIBLE); device_image.setImageResource(R.mipmap.device1); @@ -347,12 +424,6 @@ public class HomeFragmentSBKZ extends BaseFragment { case R.id.guokoucaoxiang_qx: SetMouthFacing(MouthFacingEnum.清洗位); break; - case R.id.chushui: - PumpWater(isclick); - break; - case R.id.xiguoshui: - PotWashingWater(isclick); - break; case R.id.touliao1: MainDish(1); break; @@ -365,16 +436,6 @@ public class HomeFragmentSBKZ extends BaseFragment { case R.id.touliao4: MainDish(4); break; - - case R.id.yeliao1: - Pumping(1, isclick); - break; - case R.id.yeliao2: - Pumping(2, isclick); - break; - case R.id.yeliao3: - Pumping(3, isclick); - break; case R.id.huoli: SetFire(hl); break; @@ -390,6 +451,37 @@ public class HomeFragmentSBKZ extends BaseFragment { } }; + + /** + * 设置是否按下 + * + * @param id + * @param ismode + */ + public void SetIDTouch(int id, boolean ismode) { + switch (id) { + case R.id.chushui: + PumpWater(ismode); + Log.e("锅内加水", ismode ? "按下" : "松开"); + break; + case R.id.xiguoshui: + PotWashingWater(ismode); + Log.e("洗锅水枪", ismode ? "按下" : "松开"); + break; + case R.id.yeliao1: + Pumping(1, ismode); + Log.e("液料1号", ismode ? "按下" : "松开"); + break; + case R.id.yeliao2: + Pumping(2, ismode); + Log.e("液料2号", ismode ? "按下" : "松开"); + break; + case R.id.yeliao3: + Pumping(3, ismode); + Log.e("液料3号", ismode ? "按下" : "松开"); + break; + } + } //endregion //region 公共函数 @@ -502,7 +594,7 @@ public class HomeFragmentSBKZ extends BaseFragment { */ public void PumpWater(boolean isselectd) { ExecuteTheRecipe.WritePLC("炒锅抽水", isselectd, null); - ToastUtils.warning("锅内加水:" + (isselectd ? "打开" : "关闭")); + //ToastUtils.warning("锅内加水:" + (isselectd ? "打开" : "关闭")); } /** @@ -512,7 +604,7 @@ public class HomeFragmentSBKZ extends BaseFragment { */ public void PotWashingWater(boolean isselectd) { ExecuteTheRecipe.WritePLC("炒锅放水", isselectd, null); - ToastUtils.warning("洗锅水枪:" + (isselectd ? "打开" : "关闭")); + //ToastUtils.warning("洗锅水枪:" + (isselectd ? "打开" : "关闭")); } public boolean isMake = false; @@ -547,8 +639,10 @@ public class HomeFragmentSBKZ extends BaseFragment { isMake = false; } }).start(); + }else + { + ToastUtils.warning("请耐心等待上一次投料结束!!!"); } - } /** @@ -558,8 +652,7 @@ public class HomeFragmentSBKZ extends BaseFragment { */ public void Pumping(int num, boolean isselectd) { ExecuteTheRecipe.WritePLC("料仓" + (num) + "手动开关", isselectd, null); - - ToastUtils.warning("料仓:" + num + "," + (isselectd ? "打开" : "关闭")); + //ToastUtils.warning("料仓:" + num + "," + (isselectd ? "打开" : "关闭")); } /** 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 21aac47d..7c60d210 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 @@ -692,7 +692,7 @@ public class DishTestActivity extends BaseActivity { //重置暂停开关 IsPause = false; zanting_goodmake.SetStatus(false); - zanting_goodmake.setVisibility(View.GONE); + zanting_goodmake.setVisibility(View.INVISIBLE); ExecuteTheRecipe.WritePLC("暂停开关", false, null); ExecuteTheRecipe.WritePLC("搅拌", false, null); @@ -751,6 +751,7 @@ public class DishTestActivity extends BaseActivity { guoneichoushui.setVisibility(View.VISIBLE); runtime_cs.setBase(SystemClock.elapsedRealtime()); runtime_cs.start(); + IsChouShui=true; } }); } @@ -769,6 +770,12 @@ public class DishTestActivity extends BaseActivity { DataBus.getInstance().PumpWaterTimeOut = (int) (elapsedMillis / 1000); ClikTime = (int) ((SystemClock.elapsedRealtime() - runtime.getBase()) / 1000); + if(IsChouShui) + { + BPA_GOODSRECIPE data = Get加水(DataBus.getInstance().PumpWaterTimeOut); + DataBus.getInstance().bpa_goodsrecipes.add(data); + } + IsChouShui=false; } }); } @@ -981,11 +988,13 @@ public class DishTestActivity extends BaseActivity { }).start(); } + boolean IsChouShui=false; /** * 抽水 */ public void PumpWater(boolean isselectd) { if (isselectd) { + int time = (int) ((SystemClock.elapsedRealtime() - runtime.getBase()) / 1000);//当前点击多少秒 int time_c = time - ClikTime; new Thread(new Runnable() { @@ -1003,7 +1012,6 @@ public class DishTestActivity extends BaseActivity { @Override public void run() { BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); - //DataBus.getInstance().bpa_goodsrecipes.add(data1); ExecuteTheRecipe.ExecuteOperationSteps(data1.processname, data1.processvalue); runOnUiThread(new Runnable() { @Override @@ -1019,8 +1027,6 @@ public class DishTestActivity extends BaseActivity { }).start(); } else { onRecordStop_CS(); - BPA_GOODSRECIPE data = Get加水(DataBus.getInstance().PumpWaterTimeOut); - DataBus.getInstance().bpa_goodsrecipes.add(data); } ExecuteTheRecipe.WritePLC("炒锅抽水", isselectd, null); ToastUtils.warning("锅内加水:" + isselectd); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java index e3d0dabd..66fa84da 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java @@ -146,17 +146,17 @@ public class add_qupenren extends LinearLayout { quzhizuo.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - if (!ConfigName.getInstance().PlcIsConnect) { - ToastUtils.warning("PLC未准备就绪!!!"); - return; - } - - Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); - //Object jiting = ExecuteTheRecipe.getListingValue("设备急停"); - if (chushiover == null || !(boolean) chushiover) { - ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); - return; - } +// if (!ConfigName.getInstance().PlcIsConnect) { +// ToastUtils.warning("PLC未准备就绪!!!"); +// return; +// } +// +// Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); +// //Object jiting = ExecuteTheRecipe.getListingValue("设备急停"); +// if (chushiover == null || !(boolean) chushiover) { +// ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); +// return; +// } if (mListener != null) { mListener.clickListenerNew(view, 5, mode); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom3.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom3.java index dad7375f..9a8315a1 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom3.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom3.java @@ -24,6 +24,8 @@ public class imagebuttom3 extends LinearLayout { @BindView(R.id.image_u) ImageView image_u; + @BindView(R.id.image_layout) + LinearLayout image_layout; @BindView(R.id.text_u) TextView text_u; private int ys0 = R.mipmap.sb2; @@ -39,6 +41,7 @@ public class imagebuttom3 extends LinearLayout { */ public MyClickListener mListener = null; + private View root; public imagebuttom3(Context context, @Nullable AttributeSet attrs) { @@ -87,6 +90,17 @@ public class imagebuttom3 extends LinearLayout { IsEnable = true; } SetStatus(false); + + + } + + /** + * 设置 + * @param listener + */ + public void SetOnTounch(OnTouchListener listener) + { + image_layout.setOnTouchListener(listener); } @OnClick({R.id.image_layout}) diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java index fd6a8485..ce3886a8 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java @@ -79,9 +79,9 @@ public class newhuoli_control extends LinearLayout { ImageViews.add(hl7); ImageViews.add(hl8); - ImageViews.get(0).setVisibility(View.GONE); - ImageViews.get(1).setVisibility(View.GONE); - ImageViews.get(2).setVisibility(View.GONE); +// ImageViews.get(0).setVisibility(View.GONE); +// ImageViews.get(1).setVisibility(View.GONE); +// ImageViews.get(2).setVisibility(View.GONE); if(ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi)!=null) diff --git a/app/src/main/res/layout/activity_bottom_navigation_new.xml b/app/src/main/res/layout/activity_bottom_navigation_new.xml index 83a3af6c..4b068b77 100644 --- a/app/src/main/res/layout/activity_bottom_navigation_new.xml +++ b/app/src/main/res/layout/activity_bottom_navigation_new.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/white" + android:background="#F6F4ED" tools:context=".modules.home.activity.BottomNavigationNewActivity"> + + + + - - - - - + + android:textStyle="bold" /> + + android:textStyle="bold" /> + + android:textStyle="bold" /> + - - diff --git a/app/src/main/res/layout/activity_cookingsimulated.xml b/app/src/main/res/layout/activity_cookingsimulated.xml index 497a0555..fef39d69 100644 --- a/app/src/main/res/layout/activity_cookingsimulated.xml +++ b/app/src/main/res/layout/activity_cookingsimulated.xml @@ -99,6 +99,19 @@ android:layout_alignParentRight="true" android:layout_marginTop="5dp" android:src="@mipmap/zhijietuichu1"/> + + + + + - - - - - - - - - - - - + android:background="#F6F4ED"> + android:layout_weight="0.4"> - - - - - - + android:layout_marginLeft="30dp"> - - + android:layout_centerVertical="true" + android:orientation="vertical"> - + - + - - - + + + + + + + + + + + - - + - - - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="25dp" - android:layout_marginTop="155dp" - android:orientation="horizontal"> + - + + + + + + + + + + + - + - + - + + - + + + + + + + + + + + + + - - - - - - - - - - + + - - + + - - - - - + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="40dp" + android:layout_marginTop="140dp" + android:orientation="horizontal"> - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + android:layout_weight="0.4" + android:background="#BEAA6A"> - - - - - - + - - - - - - + android:divider="#00000000" + android:dividerHeight="3dp" /> + - - + + + - + android:focusable="true" + android:visibility="gone"> + + + android:focusable="true" + android:visibility="gone"> + + + + + android:layout_height="wrap_content" + android:layout_marginLeft="20dp" + android:layout_marginTop="50dp" + android:layout_marginRight="40dp"> + + android:text="" + android:textColor="@color/white" /> + + android:text="" + android:textColor="@color/white" /> + + android:text="" + android:textColor="@color/white" /> + + android:text="" + android:textColor="@color/white" /> @@ -742,33 +757,37 @@ + android:focusable="true" + android:visibility="gone"> + + + + + android:src="@mipmap/jl1" /> +