From 255beef8a443ab5a6c73b4fd113f8b2b3eb36754 Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 22 Jul 2023 11:45:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=BB=E9=A1=B5=20?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=B6=E4=BD=9C=EF=BC=8C=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ConfigData.java | 11 +- .../business/ExecuteTheRecipe.java | 51 ++- .../common/constant/ConfigName.java | 82 ++++- .../adapter/FilePickerShowAdapter.java | 18 +- .../activity/BottomNavigation2Activity.java | 3 +- .../modules/home/fragment/Home1Fragment.java | 332 +++++++++++------- .../from/fragment/systeminternetfragment.java | 81 +++-- .../fragment/mode/imagebutton_control.java | 8 +- .../res/layout/fragment_system_internet.xml | 6 +- .../item/layout/item_file_picker_show.xml | 48 ++- 10 files changed, 423 insertions(+), 217 deletions(-) diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 8c00c78f..2d9af119 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -930,14 +930,6 @@ public class ConfigData { * 连接PLC */ public void ConnectPLC() { - ConfigName.getInstance().PLC_Address.clear(); - ArrayList address = QueryDB.GetPlcaddressALL(); - for (BPA_PLCADDRESS item : address) { - if (!item.address.isEmpty() && !item.address.equals("-------------")) { - ConfigName.getInstance().PLC_Address.put(item.name, item); - } - } - ExecuteTheRecipe.Listening();//启动数据监听 new Thread(new Runnable() { @Override public void run() { @@ -959,7 +951,8 @@ public class ConfigData { * PLC初始化完成时,需要注册的服务 */ public void PLC_Init() { - + //PLC连接成功,启动数据监听 + ExecuteTheRecipe.Listening(); } //endregion 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 638ac54c..f6e17675 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -36,29 +36,64 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ExecuteTheRecipe { + //region 变量 /** * 等待超时时间 */ - public static int whileTime = 2; + public static int whileTime = 10; /** * 监听变量值 */ public static HashMap ListeningValue = new HashMap(); + /** + * 外部界面 + */ + public static Context context = null; + + /** + * 商品是否强制结束 + */ + public static boolean IsForcedEnd = false; + //endregion + + //region 强制结束 + /** + * 设置强制结束 + */ + public static void SetForcedEnd() + { + ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); + IsForcedEnd=true; + } + + /** + * 停止强制结束 + */ + public static void StopForcedEnd() + { + IsForcedEnd=false; + } + //endregion + + //region 执行配方 /** * 执行配方 * * @param recipe * @return */ - public static Context context = null; - public static boolean Execute(BPA_GOODSRECIPE recipe) { boolean status = false; try { - ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms); //1.解析 + if(IsForcedEnd) + { + ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); + return false; + } + ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms); if (recipe.materialType == 0)//正常物料 { ExecuteMaterialIssuance(recipe.processvalue); @@ -180,6 +215,7 @@ public class ExecuteTheRecipe { ToastUtils.error("异常信息:" + ex.getMessage()); } } + //endregion //region 物料PLC控制 @@ -640,6 +676,13 @@ public class ExecuteTheRecipe { //region PLC监听线程 public static void Listening() { + ConfigName.getInstance().PLC_Address.clear(); + ArrayList address = QueryDB.GetPlcaddressALL(); + for (BPA_PLCADDRESS item : address) { + if (!item.address.isEmpty() && !item.address.equals("-------------")) { + ConfigName.getInstance().PLC_Address.put(item.name, item); + } + } 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 85cc2f65..682de8f7 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 @@ -577,10 +577,6 @@ public class ConfigName { //翻转正转模型 add(new Res_PLCADDRESS("翻转正转", "M10.4", 0, 1)); - add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1)); - - - //翻转反转模型 add(new Res_PLCADDRESS("翻转反转", "M10.5", 0, 1)); add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1)); @@ -589,6 +585,8 @@ public class ConfigName { add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); + //主料 + add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); //抽水放水 add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 0, 1)); @@ -614,21 +612,20 @@ public class ConfigName { //液体料模型 add(new Res_PLCADDRESS("液体料", "-------------", 0, 0)); - add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1)); - add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1)); - add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1)); + add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1)); + add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1)); + add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1)); + add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1)); + add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1)); add(new Res_PLCADDRESS("料仓1下料手动", "M12.3", 0, 1)); add(new Res_PLCADDRESS("料仓2下料手动", "M12.4", 0, 1)); add(new Res_PLCADDRESS("料仓3下料手动", "M12.5", 0, 1)); - add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1)); add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1)); add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1)); add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1)); - add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1)); - add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1)); - add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1)); - add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1)); - + add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1)); + add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1)); + add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1)); //上下限 add(new Res_PLCADDRESS("位置上下限", "-------------", 0, 0)); @@ -649,6 +646,54 @@ public class ConfigName { add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 1, 1)); add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 1, 1)); + //自动投料-平移轴 + add(new Res_PLCADDRESS("转轴控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("平移-点动正转", "M14.0", 0, 1)); + add(new Res_PLCADDRESS("平移-点动反转", "M14.1", 0, 1)); + add(new Res_PLCADDRESS("平移-回原点", "M14.2", 0, 1)); + add(new Res_PLCADDRESS("平移-去1号位", "M14.3", 0, 1)); + add(new Res_PLCADDRESS("平移-去2号位", "M14.4", 0, 1)); + add(new Res_PLCADDRESS("平移-去3号位", "M14.5", 0, 1)); + add(new Res_PLCADDRESS("平移-去4号位", "M14.6", 0, 1)); + add(new Res_PLCADDRESS("平移-1#位置设定", "M15.0", 0, 1)); + add(new Res_PLCADDRESS("平移-2#位置设定", "M15.1", 0, 1)); + add(new Res_PLCADDRESS("平移-3#位置设定", "M15.2", 0, 1)); + add(new Res_PLCADDRESS("平移-4#位置设定", "M15.3", 0, 1)); + + add(new Res_PLCADDRESS("翻转-点动正转", "M16.0", 0, 1)); + add(new Res_PLCADDRESS("翻转-点动反转", "M16.1", 0, 1)); + add(new Res_PLCADDRESS("翻转-回原点", "M16.2", 0, 1)); + add(new Res_PLCADDRESS("翻转-去1号位", "M16.3", 0, 1)); + add(new Res_PLCADDRESS("翻转-去2号位", "M16.4", 0, 1)); + add(new Res_PLCADDRESS("翻转-去3号位", "M16.5", 0, 1)); + add(new Res_PLCADDRESS("翻转-去4号位", "M16.6", 0, 1)); + add(new Res_PLCADDRESS("翻转-1#位置设定", "M17.0", 0, 1)); + add(new Res_PLCADDRESS("翻转-2#位置设定", "M17.1", 0, 1)); + add(new Res_PLCADDRESS("翻转-3#位置设定", "M17.2", 0, 1)); + add(new Res_PLCADDRESS("翻转-4#位置设定", "M17.3", 0, 1)); + add(new Res_PLCADDRESS("倒菜启动", "M17.4", 0, 1)); + add(new Res_PLCADDRESS("磁铁吸合", "M17.5", 0, 1)); + + //自动投料-翻转轴 + add(new Res_PLCADDRESS("转轴监控", "-------------", 0, 0)); + add(new Res_PLCADDRESS("平移-伺服当前值", "VD220", 1, 1)); + add(new Res_PLCADDRESS("平移-点动速度", "VD224", 1, 1)); + add(new Res_PLCADDRESS("平移-回原点速度", "VD228", 1, 1)); + add(new Res_PLCADDRESS("平移-定位运行速度", "VD232", 1, 1)); + add(new Res_PLCADDRESS("平移-1号位置值", "VD236", 1, 1)); + add(new Res_PLCADDRESS("平移-2号位置值", "VD240", 1, 1)); + add(new Res_PLCADDRESS("平移-3号位置值", "VD244", 1, 1)); + add(new Res_PLCADDRESS("平移-4号位置值", "VD248", 1, 1)); + + add(new Res_PLCADDRESS("翻转-伺服当前值", "VD260", 1, 1)); + add(new Res_PLCADDRESS("翻转-点动速度", "VD264", 1, 1)); + add(new Res_PLCADDRESS("翻转-回原点速度", "VD268", 1, 1)); + add(new Res_PLCADDRESS("翻转-定位运行速度", "VD272", 1, 1)); + add(new Res_PLCADDRESS("翻转-1号位置值", "VD276", 1, 1)); + add(new Res_PLCADDRESS("翻转-2号位置值", "VD280", 1, 1)); + add(new Res_PLCADDRESS("翻转-3号位置值", "VD284", 1, 1)); + add(new Res_PLCADDRESS("翻转-4号位置值", "VD288", 1, 1)); + //反馈信号 add(new Res_PLCADDRESS("反馈信号", "-------------", 0, 0)); add(new Res_PLCADDRESS("初始化完成", "M40.0", 1, 0)); @@ -667,6 +712,15 @@ public class ConfigName { add(new Res_PLCADDRESS("炒锅清洗反馈", "M41.5", 1, 0)); add(new Res_PLCADDRESS("出餐启动反馈", "M41.6", 1, 0)); add(new Res_PLCADDRESS("炒锅倒菜减速位", "M41.7", 1, 0)); + add(new Res_PLCADDRESS("平移轴在1号位", "M43.0", 1, 0)); + add(new Res_PLCADDRESS("平移轴在2号位", "M43.1", 1, 0)); + add(new Res_PLCADDRESS("平移轴在3号位", "M43.2", 1, 0)); + add(new Res_PLCADDRESS("平移轴在4号位", "M43.3", 1, 0)); + add(new Res_PLCADDRESS("翻转轴在1号位", "M44.0", 1, 0)); + add(new Res_PLCADDRESS("翻转轴在2号位", "M44.1", 1, 0)); + add(new Res_PLCADDRESS("翻转轴在3号位", "M44.2", 1, 0)); + add(new Res_PLCADDRESS("翻转轴在4号位", "M44.3", 1, 0)); + add(new Res_PLCADDRESS("倒菜完成", "M44.4", 1, 0)); //检测信号 add(new Res_PLCADDRESS("监测信号", "-------------", 0, 0)); @@ -700,7 +754,7 @@ public class ConfigName { add(new ProcessT("搅拌", Arrays.asList("搅拌速度", "延迟(秒)"))); add(new ProcessT("位置", Arrays.asList("转动速度", "位置动作", "延迟(秒)"))); add(new ProcessT("加热", Arrays.asList("加热功率", "延迟(秒)"))); - add(new ProcessT("主料", Arrays.asList("主料名称", "主料重量", "延迟(秒)", "投料动作"))); + add(new ProcessT("主料", Arrays.asList("主料名称", "主料位置", "主料重量", "投料动作"))); add(new ProcessT("液体料", new ArrayList<>())); add(new ProcessT("延迟", Arrays.asList("延迟(秒)"))); add(new ProcessT("出菜", Arrays.asList("延迟(秒)"))); diff --git a/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java b/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java index 1a3e20df..80c83626 100644 --- a/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -74,7 +75,7 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); - for(BPA_GOODSRECIPE item:goodsrecipes) - { - + for (BPA_GOODSRECIPE item : goodsrecipes) { ExecuteTheRecipe.Execute(item); } - }catch (Exception ex) - { + } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); - }finally { - Activity activity=getActivity(); - if(activity!=null) - { + } finally { + Activity activity = getActivity(); + if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { @@ -376,7 +404,19 @@ public class Home1Fragment extends BaseFragment { } } } + Thread.sleep(1000); + } catch (InterruptedException e) { + ToastUtils.info("异常信息:" + e.getMessage()); + } + } + } + }).start(); + new Thread(new Runnable() { + @Override + public void run() { + while (true) { + try { SxUI(); Thread.sleep(1000); } catch (InterruptedException e) { @@ -390,40 +430,46 @@ public class Home1Fragment extends BaseFragment { /** * 刷新UI界面 */ - public void SxUI() - { - Activity activity=getActivity(); - if(activity!=null) - { + public void SxUI() { + Activity activity = getActivity(); + if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { - Object val_wd= ExecuteTheRecipe.getListingValue("当前锅底温度"); - Object val_wz= ExecuteTheRecipe.getListingValue("编码器当前位值"); - if(val_wd!=null) - { - chaoguo_wendu.setText(val_wd+""); - }else - { + Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度"); + Object val_wz = ExecuteTheRecipe.getListingValue("编码器当前位值"); + Object val_jbpl = ExecuteTheRecipe.getListingValue("搅拌频率"); + Object val_fzpv = ExecuteTheRecipe.getListingValue("翻转频率"); + + if (val_wd != null) { + chaoguo_wendu.setText(val_wd + ""); + } else { chaoguo_wendu.setText("未知"); } - if(val_wz!=null) - { - chaoguo_weizhi.setText(val_wz+""); - }else - { + if (val_wz != null) { + chaoguo_weizhi.setText(val_wz + ""); + } else { chaoguo_weizhi.setText("未知"); } - plc_zhuangtai.setText(ConfigName.getInstance().PlcIsConnect?"已连接":"断开"); - plc_zhuangtai.setTextColor(ConfigName.getInstance().PlcIsConnect? Color.GREEN:Color.BLACK); + if (val_jbpl != null) { + int val=Integer.parseInt(String.valueOf(val_jbpl)); + nifty_slider2.setValue(val,true); + } + + if (val_fzpv != null) { + int val=Integer.parseInt(String.valueOf(val_jbpl)); + nifty_slider3.setValue(val,true); + } - SetBottonStatus(false); + plc_zhuangtai.setText(ConfigName.getInstance().PlcIsConnect ? "已连接" : "断开"); + plc_zhuangtai.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.GREEN : Color.BLACK); } }); } } + /** * 设置进度条百分比 * @@ -434,7 +480,7 @@ public class Home1Fragment extends BaseFragment { try { jingdu.setProgress((usertime * 100) / alltime); jingdu.setSecondProgress((usertime * 100) / alltime); - shengyushijian.setText("预计剩余时间:" + (alltime-usertime) + "s"); + shengyushijian.setText("预计剩余时间:" + (alltime - usertime) + "s"); } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } @@ -450,10 +496,10 @@ public class Home1Fragment extends BaseFragment { Status = status; if (status) { startbutton.setImageResource(R.mipmap.tzzz); - TimerCount(good.maketime,true);//开始计时器,记录进度条 + TimerCount(good.maketime, true);//开始计时器,记录进度条 } else { startbutton.setImageResource(R.mipmap.qdzz); - TimerCount(0,false);//停止计时器 + TimerCount(0, false);//停止计时器 } if (good != null) { SetProcesssUI(good.maketime, 0); @@ -467,33 +513,31 @@ public class Home1Fragment extends BaseFragment { /** * 计时器 + * * @param alltime * @param status */ public void TimerCount(int alltime, boolean status) { - if(status) - { - if(countDownTimer==null) - { + if (status) { + if (countDownTimer == null) { countDownTimer = new CountDownTimer(alltime * 1000, 1000) { @Override public void onTick(long millisUntilFinished) { int overtime = (int) ((millisUntilFinished) / 1000);//剩余时间 - SetProcesssUI(alltime,alltime-overtime); + SetProcesssUI(alltime, alltime - overtime); } + @Override public void onFinish() { - SetProcesssUI(alltime,alltime);//进度条100% + SetProcesssUI(alltime, alltime);//进度条100% } }; } countDownTimer.start(); - }else - { - if(countDownTimer!=null) - { + } else { + if (countDownTimer != null) { countDownTimer.cancel(); - countDownTimer=null; + countDownTimer = null; } } } @@ -505,8 +549,8 @@ public class Home1Fragment extends BaseFragment { */ @OnClick({R.id.xzcp, R.id.startbutton, R.id.qdjb, R.id.tzjb , R.id.yaoqian, R.id.tingyao - , R.id.ydw, R.id.dcw, R.id.clw,R.id.qxw,R.id.ccw1,R.id.ccw2,R.id.ccw3 - , R.id.chushihua,R.id.jiting}) + , R.id.ydw, R.id.dcw, R.id.clw, R.id.qxw, R.id.ccw1, R.id.ccw2, R.id.ccw3 + , R.id.chushihua, R.id.jiting}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.xzcp://选择菜谱按钮点击 @@ -515,81 +559,125 @@ public class Home1Fragment extends BaseFragment { break; case R.id.startbutton: if (Status) { - ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!"); - return; -// //按钮点击 -// String title = "停止操作提示!"; -// String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?"; -// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { -// @Override -// public void onClick(QMUIDialog dialog, int index) { -// SetBottonStatus(false); -// dialog.dismiss(); -// } -// }); +// ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!"); +// return; + //按钮点击 + String title = "停止操作提示!"; + String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?"; + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + //强制结束 + ExecuteTheRecipe.SetForcedEnd(); + dialog.dismiss(); + } + }); } else { if (good == null) { ToastUtils.info("请先选择一个商品"); return; } + //if (!IsMake(false)) { return; } //按钮点击 String title = "开始操作提示!"; String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?"; AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { + ExecuteTheRecipe.StopForcedEnd(); SetBottonStatus(true); - dialog.dismiss(); } }); } break; - case R.id.qdjb://开始搅拌 + case R.id.qdjb://开始清洗 + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Clean(MyStatus.Start); break; - case R.id.tzjb://停止搅拌 + case R.id.tzjb://停止清洗 + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Clean(MyStatus.Stop); break; case R.id.yaoqian: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Start); break; case R.id.tingyao: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Stop); break; case R.id.ydw://R.id.ydw, R.id.dcw, R.id.clw,R.id.qxw,R.id.ccw1,R.id.ccw2,R.id.ccw3 + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("原点位"); break; case R.id.dcw: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("倒菜位"); break; case R.id.clw: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("抽料位"); break; case R.id.qxw: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("清洗位"); break; case R.id.ccw1: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("炒菜位1"); break; case R.id.ccw2: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("炒菜位2"); break; case R.id.ccw3: + if (!IsMake(true)) { return; } ExecuteTheRecipe.Write_PLC_Location("炒菜位3"); break; - case R.id.chushihua: + if (!IsMake(true)) { return; } ToastUtils.info("点击按钮:初始化"); - ExecuteTheRecipe.WritePLC("初始化", true,null); + ExecuteTheRecipe.WritePLC("初始化", true, null); break; case R.id.jiting: + if (!IsMake(true)) { return; } ToastUtils.info("点击按钮:急停"); - ExecuteTheRecipe.WritePLC("停止", true,null); + ExecuteTheRecipe.WritePLC("停止", true, null); break; } } + /** + * 是否可以制作商品 + * @return + */ + public boolean IsMake(boolean k) + { + if (!ConfigName.getInstance().PlcIsConnect) { + ToastUtils.warning("PLC未准备就绪!!!"); + return false; + } + + Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); + Object jiting = ExecuteTheRecipe.getListingValue("设备急停"); + if (chushiover == null || !(boolean) chushiover) { + ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); + return false; + } + if (jiting == null || !(boolean) jiting) { + ToastUtils.warning("设备已急停,请检查设备!!!"); + return false; + } + + if (Status && k) + { + ToastUtils.warning("客官,商品制作未结束请勿进行其他操作.请耐心等待商品制作结束!!!"); + return false; + } + return true; + } + /** * 跳转界面 */ diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java index e192df3c..38dba402 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java @@ -1,6 +1,7 @@ package com.bonait.bnframework.modules.home.fragment.from.fragment; import android.content.Context; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -10,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.view.LayoutInflater; @@ -52,7 +54,7 @@ import pub.devrel.easypermissions.EasyPermissions; /** * 资源管理 */ -public class systeminternetfragment extends BaseFragment{ +public class systeminternetfragment extends BaseFragment { @BindView(R.id.rl_file) RecyclerView mRecyclerView; @BindView(R.id.rl_yx_file) @@ -60,6 +62,7 @@ public class systeminternetfragment extends BaseFragment{ @BindView(R.id.baocunbendi) Button baocunbendi; private Context context; + @Override protected View onCreateView() { View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_internet, null); @@ -75,7 +78,7 @@ public class systeminternetfragment extends BaseFragment{ FlushedImage(); } - @OnClick({R.id.xuanzhewenjian,R.id.baocunbendi}) + @OnClick({R.id.xuanzhewenjian, R.id.baocunbendi}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.xuanzhewenjian://保存按钮 @@ -84,13 +87,12 @@ public class systeminternetfragment extends BaseFragment{ break; case R.id.baocunbendi://保存按钮 BitmapFactory.Options options = new BitmapFactory.Options(); - options.inSampleSize=2;//宽高压缩为原来的1/2 - for (FileEntity item:PickerManager.getInstance().files) - { - File file= item.getFile(); + options.inSampleSize = 2;//宽高压缩为原来的1/2 + for (FileEntity item : PickerManager.getInstance().files) { + File file = item.getFile(); try { - Bitmap bitmap1= BitmapFactory.decodeStream(new FileInputStream(file)); - new LocalCacheUtils().setBitmapToLocal(file.getName(),bitmap1); + Bitmap bitmap1 = BitmapFactory.decodeStream(new FileInputStream(file)); + new LocalCacheUtils().setBitmapToLocal(file.getName(), bitmap1); } catch (Exception e) { } } @@ -98,10 +100,11 @@ public class systeminternetfragment extends BaseFragment{ break; } } - ArrayList yx_files=new ArrayList<>(); - private static final String CACHE_PATH= Environment.getExternalStorageDirectory().getAbsolutePath()+"/hblxiaochaodb/WebImage"; - public void FlushedImage() - { + + ArrayList yx_files = new ArrayList<>(); + private static final String CACHE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hblxiaochaodb/WebImage"; + + public void FlushedImage() { File path = new File(CACHE_PATH);// 获得路径 File[] files = path.listFiles();// 读取文件 yx_files.clear(); @@ -113,24 +116,25 @@ public class systeminternetfragment extends BaseFragment{ } else { e = new FileEntity(absolutePath, f, false); } - if(f.isFile()) - { - String[] imgs = {"png","jpg","jpeg","gif"}; - e.setFileType(new FileType("IMG",imgs,0)); + if (f.isFile()) { + String[] imgs = {"png", "jpg", "jpeg", "gif"}; + e.setFileType(new FileType("IMG", imgs, 0)); yx_files.add(e); } } rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); - FilePickerShowAdapter adapter = new FilePickerShowAdapter(context,yx_files); + FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); rl_yx_file.setAdapter(adapter); - adapter.setOnDeleteListener(new OnDeleteListener() { + adapter.setOnItemClickListener(new OnFileItemClickListener() { @Override - public void delete(int position) { - File file= yx_files.get(position).getFile(); - if (file.exists() && file.isFile()) - { - file.delete(); - } + public void click(int position) { + + String path=yx_files.get(position).getPath(); + //打开系统相册浏览照片 + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.parse("file://" + path), "image/*"); + startActivity(intent); } }); } @@ -147,19 +151,24 @@ public class systeminternetfragment extends BaseFragment{ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if(requestCode == Constants.REQ_CODE){ + if (requestCode == Constants.REQ_CODE) { mRecyclerView.setLayoutManager(new LinearLayoutManager(context)); - FilePickerShowAdapter adapter = new FilePickerShowAdapter(context,PickerManager.getInstance().files); + FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, PickerManager.getInstance().files); mRecyclerView.setAdapter(adapter); - String res = "("+ PickerManager.getInstance().files.size()+"/"+PickerManager.getInstance().maxCount+")"; - baocunbendi.setText(getString(R.string.file_select_res1,res)); -// adapter.setOnItemClickListener(new OnFileItemClickListener() { -// @Override -// public void click(int position) { -// startActivity(Intent.createChooser(OpenFile.openFile(PickerManager.getInstance().files.get(position).getPath(),getBaseFragmentActivity()), "选择程序")); -// } -// }); + String res = "(" + PickerManager.getInstance().files.size() + "/" + PickerManager.getInstance().maxCount + ")"; + baocunbendi.setText(getString(R.string.file_select_res1, res)); + adapter.setOnItemClickListener(new OnFileItemClickListener() { + @Override + public void click(int position) { + + String path=PickerManager.getInstance().files.get(position).getPath(); + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.parse("file://" + path), "image/*"); + startActivity(intent); + } + }); } } @@ -173,9 +182,9 @@ public class systeminternetfragment extends BaseFragment{ * 当在activity设置viewPager + BottomNavigation + fragment时, * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, * 必须加上此方法,禁止fragment左滑返回上一界面。 - * + *

* 切记!切记!切记!否则会闪退! - * + *

* 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 */ @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java index 2a6215f0..0cef8f75 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java @@ -75,7 +75,7 @@ public class imagebutton_control extends LinearLayout { text_u.setText(""); } - SetStatus(); + SetStatus(Status); } @OnClick({R.id.startjb}) @@ -83,7 +83,7 @@ public class imagebutton_control extends LinearLayout { switch (view.getId()) { case R.id.startjb: Status=!Status; - SetStatus(); + SetStatus(Status); break; } @@ -97,9 +97,9 @@ public class imagebutton_control extends LinearLayout { * 设置级别 * @param */ - public void SetStatus() + public void SetStatus(boolean status) { - if(Status) + if(status) { image_u.setImageResource(ks_ys); }else diff --git a/app/src/main/res/layout/fragment_system_internet.xml b/app/src/main/res/layout/fragment_system_internet.xml index 63ddbf26..275b5ec1 100644 --- a/app/src/main/res/layout/fragment_system_internet.xml +++ b/app/src/main/res/layout/fragment_system_internet.xml @@ -38,8 +38,7 @@ android:layout_height="match_parent" android:layout_marginTop="5dp" android:layout_marginBottom="@dimen/dp_10" - - android:background="@color/main_background"> +> + android:layout_marginBottom="@dimen/dp_10"> - + + + + + > + tools:text="image.png" /> - + android:layout_width="wrap_content" + android:layout_height="match_parent"> + + + \ No newline at end of file