diff --git a/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java b/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java index eb70886b..8ed82612 100644 --- a/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java +++ b/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java @@ -52,6 +52,11 @@ public class DoubleFryingpanControl extends ControlBase { RobotData.RobotHome=value[0]; }); + //机器人原点位 + ModbusMaster.get().ReadBool(RobotAddress("M661"),1,1,value->{ + RobotData.RobotReady=value[0]; + }); + //机器人任务反馈 ModbusMaster.get().ReadShort("GI5",1,1,value->{ RobotData.RobotTaskFeedback=value[0]; diff --git a/app/src/main/java/com/bonait/bnframework/business/RobotData.java b/app/src/main/java/com/bonait/bnframework/business/RobotData.java index cdaaeac1..5f7b9adf 100644 --- a/app/src/main/java/com/bonait/bnframework/business/RobotData.java +++ b/app/src/main/java/com/bonait/bnframework/business/RobotData.java @@ -29,7 +29,10 @@ public class RobotData { */ public static boolean[] WarehouseLocHavingBasin=new boolean[4]; - + /** + * 机器人准备就绪 + */ + public static boolean RobotReady; /** * 机器人到达维护位置 diff --git a/app/src/main/java/com/bonait/bnframework/dialog/DialogManager.java b/app/src/main/java/com/bonait/bnframework/dialog/DialogManager.java index 8cb6a0a5..5c08a4be 100644 --- a/app/src/main/java/com/bonait/bnframework/dialog/DialogManager.java +++ b/app/src/main/java/com/bonait/bnframework/dialog/DialogManager.java @@ -1,9 +1,16 @@ package com.bonait.bnframework.dialog; + +import android.app.Activity; import android.content.Context; +import android.content.ContextWrapper; import android.view.Gravity; import android.view.View; +import androidx.annotation.NonNull; + import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.res.UserLogEnum; +import com.bonait.bnframework.common.helper.MessageLog; public class DialogManager { @@ -23,15 +30,15 @@ public class DialogManager { } return mInstance; } - + public Activity activityMain=null; public DialogView initView(Context context, int layout) { - return new DialogView(context,layout, R.style.CustomDialog, Gravity.CENTER); + return new DialogView(context, layout, R.style.CustomDialog, Gravity.CENTER); } - public DialogView initView(Context context,int layout,int gravity) { - return new DialogView(context,layout, R.style.mydialog, gravity); + public DialogView initView(Context context, int layout, int gravity,Activity activity) { + activityMain=activity; + return new DialogView(context, layout, R.style.mydialog, gravity); } - // 显示弹框 public void show(DialogView view) { if (view != null) { @@ -42,10 +49,10 @@ public class DialogManager { } // 显示弹框 - public void show(DialogView view,int closeId) { + public void show(DialogView view, int closeId) { if (view != null) { if (!view.isShowing()) { - if(!view.findViewById(closeId).hasOnClickListeners()){ + if (!view.findViewById(closeId).hasOnClickListeners()) { view.findViewById(closeId).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view1) { @@ -53,7 +60,13 @@ public class DialogManager { } }); } - view.show(); + if (activityMain!=null && !activityMain.isFinishing()) { + view.show(); + } + else + { + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"弹框Active获取失败"); + } } } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java index b55efa5c..07864a59 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java @@ -9,6 +9,7 @@ import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; @@ -33,6 +34,7 @@ import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.res.UserLogEnum; import com.bonait.bnframework.common.helper.I.IRun; import com.bonait.bnframework.common.helper.MessageLog; import com.bonait.bnframework.common.linktab.LinkMode; @@ -136,16 +138,19 @@ public class DoubleFryingpanFragment extends BaseFragment { tv_Status2.setText(s2); String status = ModbusMaster.get().IsConnected?"已连接":"未连接"; mTopBar.setTitle("机器人连接状态:"+ status); - + if(!IsMaintenanceMode&&RobotData.RobotReachTending){ + btn_maintenance.setText("完成维护"); + IsMaintenanceMode=true; + } } }); } }; - mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM); - mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set1,Gravity.BOTTOM); - mWarehouselocSelectVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_warehouseloc_select,Gravity.BOTTOM); + mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM,getActivity()); + mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set1,Gravity.BOTTOM,getActivity()); + mWarehouselocSelectVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_warehouseloc_select,Gravity.BOTTOM,getActivity()); } @@ -192,6 +197,11 @@ public class DoubleFryingpanFragment extends BaseFragment { return; } + if(!RobotData.RobotReady){ + AlertDialogUtils.showDialog(getContext(),"提示","机器人初始化失败"); + return; + } + DoubleFryingpanControl.getInstance(). GoodDown(fry.GoodID,fry.FryingPanNum); try { @@ -233,7 +243,17 @@ public class DoubleFryingpanFragment extends BaseFragment { }); DialogManager.getInstance().hide(mDialogVisual);//关闭商品选择窗口 - DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 + try { + DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 + } + catch (RuntimeException ex) + { + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"打开参数配置弹框出错:"+ex.getMessage()); + } + catch(Exception ex){ + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"打开参数配置弹框出错111:"+ex.getMessage()); + } + ParSetInit(R.id.location_selection_1,new String[] {"0", "1", "2", "3", "4","5","6"}); ParSetInit(R.id.location_selection_2,new String[] {"0", "1", "2", "3", "4","5","6"}); ParSetInit(R.id.accessories_selection_1,new String[] {"0", "1", "2", "3", "4","5"}); @@ -267,6 +287,8 @@ public class DoubleFryingpanFragment extends BaseFragment { } }); + Warehouseloc=0; + }catch(InterruptedException ex){ } @@ -315,17 +337,18 @@ public class DoubleFryingpanFragment extends BaseFragment { if (msg != null) { BPA_GOODS goods = (BPA_GOODS) msg; fry.GoodID= goods.id; - OpenParSet(); -// getActivity().runOnUiThread(new Runnable() { -// @Override -// public void run() { -// if(!getActivity().isFinishing()){ -// -// } -// -// } -// }); + if(!ModbusMaster.get().IsConnected){ + AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); + return; + } + + if(!RobotData.RobotReady){ + AlertDialogUtils.showDialog(getContext(),"提示","机器人初始化失败"); + return; + } + + OpenParSet(); } } }); @@ -344,22 +367,34 @@ public class DoubleFryingpanFragment extends BaseFragment { } }); + if(btn_warehousing==null||btn_maintenance==null)return; + //手动入库 btn_warehousing.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view){ - if(!ModbusMaster.get().IsConnected){ - AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); - return; - } - if(RobotData.RobotIdle){ - WarehouselocInit(); - mWarehouselocSelectVisual.setCanceledOnTouchOutside(false); - DialogManager.getInstance().show(mWarehouselocSelectVisual,R.id.close_dialog); //打开商品选择窗口 - } - else{ - AlertDialogUtils.showDialog(getContext(),"提示","机器人忙碌中,请稍后"); - } +// if(!ModbusMaster.get().IsConnected){ +// AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); +// return; +// } +// +// if(!RobotData.RobotReady){ +// AlertDialogUtils.showDialog(getContext(),"提示","机器人初始化失败"); +// return; +// } + +// if(RobotData.RobotIdle){ +// WarehouselocInit(); +// mWarehouselocSelectVisual.setCanceledOnTouchOutside(false); +// DialogManager.getInstance().show(mWarehouselocSelectVisual,R.id.close_dialog); //打开位置选择窗口 +// } +// else{ +// AlertDialogUtils.showDialog(getContext(),"提示","机器人忙碌中,请稍后"); +// } + + WarehouselocInit(); + mWarehouselocSelectVisual.setCanceledOnTouchOutside(false); + DialogManager.getInstance().show(mWarehouselocSelectVisual,R.id.parset_close_dialog); //打开位置选择窗口 } }); @@ -371,14 +406,20 @@ public class DoubleFryingpanFragment extends BaseFragment { AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); return; } - if(!IsMaintenanceMode) + + if(!RobotData.RobotReady){ + AlertDialogUtils.showDialog(getContext(),"提示","机器人初始化失败"); + return; + } + + if(!RobotData.RobotReachTending) { if(RobotData.RobotIdle){ AlertDialogUtils.showDialog(getContext(), "提示", "是否进入机器人维护模式?", new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { btn_maintenance.setEnabled(false);//禁用按钮 - btn_warehousing.setText("维护模式中..."); + btn_maintenance.setText("维护模式中..."); ModbusMaster.get().WriteShort("GI0",(short) (41),1,null);//写入机器人主任务,指定入库位置 new Thread(new Runnable() { @Override @@ -390,8 +431,8 @@ public class DoubleFryingpanFragment extends BaseFragment { getActivity().runOnUiThread(new Runnable() { @Override public void run() { - btn_warehousing.setText("完成维护"); - btn_warehousing.setEnabled(true);//取消禁用按钮 + btn_maintenance.setText("完成维护"); + btn_maintenance.setEnabled(true);//取消禁用按钮 } }); @@ -399,6 +440,8 @@ public class DoubleFryingpanFragment extends BaseFragment { } } }).start(); + + dialog.dismiss(); } }); @@ -409,8 +452,7 @@ public class DoubleFryingpanFragment extends BaseFragment { } else{ ModbusMaster.get().WriteBool(DoubleFryingpanControl.getInstance().RobotAddress("M520"), true,1,null);//写入机器人主任务,指定入库位置 - btn_warehousing.setText("维护"); - IsMaintenanceMode=false; + btn_maintenance.setText("维护"); } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/RobotMain.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/RobotMain.java index 9e5ea305..4ecc08dd 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/RobotMain.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/RobotMain.java @@ -178,8 +178,8 @@ public class RobotMain extends BaseFragment { }; - mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM); - mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set,Gravity.BOTTOM); + mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM,getActivity()); + mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set,Gravity.BOTTOM,getActivity()); } @SuppressLint("HandlerLeak") diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java index e79f35cc..8a35a499 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java @@ -52,7 +52,7 @@ public class SheZhifragment extends BaseFragment { * 初始化TopBar */ private void initTopBar() { - mTopBar.setTitle("订单管理"); + mTopBar.setTitle("设置"); } // @OnClick({R.id.xtcs,R.id.imagegl,R.id.shebeixinxi diff --git a/app/src/main/res/drawable/spinner_text_br.xml b/app/src/main/res/drawable/spinner_text_br.xml index 0a77226d..6f24011e 100644 --- a/app/src/main/res/drawable/spinner_text_br.xml +++ b/app/src/main/res/drawable/spinner_text_br.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/activity_par_set1.xml b/app/src/main/res/layout/datatab/layout/activity_par_set1.xml index 5151bd4a..3e8dc7ab 100644 --- a/app/src/main/res/layout/datatab/layout/activity_par_set1.xml +++ b/app/src/main/res/layout/datatab/layout/activity_par_set1.xml @@ -27,7 +27,8 @@ + android:layout_height="wrap_content"/> + android:layout_height="wrap_content"/> + android:layout_height="wrap_content"/> + android:layout_height="wrap_content"/> @@ -147,17 +158,19 @@ android:layout_weight="1" android:layout_marginRight="10dp" android:background="@drawable/button4" + tools:ignore="TouchTargetSizeCheck" android:text="确认" - android:layout_height="wrap_content"/> + android:layout_height="40dp"/>