diff --git a/app/src/main/java/com/bonait/bnframework/MainApplication.java b/app/src/main/java/com/bonait/bnframework/MainApplication.java index 2662722e..58a48d9c 100644 --- a/app/src/main/java/com/bonait/bnframework/MainApplication.java +++ b/app/src/main/java/com/bonait/bnframework/MainApplication.java @@ -159,7 +159,7 @@ public class MainApplication extends Application { ConfigData.getInstance().RevertPLC(); } - RevertProcess(); + } /** * 删除表-重新生成新表 @@ -193,7 +193,7 @@ public class MainApplication extends Application { List mxname=Arrays.asList("搅拌","位置","加热","主料","液体料","延迟","出菜"); Map> mx=new IdentityHashMap<>(); mx.put("搅拌",Arrays.asList("搅拌速度","延迟(秒)")); - mx.put("位置",Arrays.asList("位置动作","转动速度","延迟(秒)")); + mx.put("位置",Arrays.asList("转动速度","位置动作","延迟(秒)")); mx.put("加热",Arrays.asList("加热功率","延迟(秒)")); mx.put("主料",Arrays.asList("主料名称","主料重量","延迟(秒)","投料动作")); mx.put("液体料",new ArrayList<>()); 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 8760308a..2763ec99 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -1,6 +1,10 @@ package com.bonait.bnframework.business; +import android.app.Activity; import android.content.Context; +import android.content.ContextWrapper; + +import androidx.annotation.NonNull; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.QueryDB; @@ -31,6 +35,11 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ExecuteTheRecipe { + /** + * 等待超时时间 + */ + public static int whileTime=2; + /** * 监听变量值 */ @@ -195,7 +204,7 @@ public class ExecuteTheRecipe { final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * 60) { + if ((System.currentTimeMillis() - a) > 1000 * whileTime) { break; }else { @@ -224,15 +233,13 @@ public class ExecuteTheRecipe { */ private static void Write_PLC_Stir(HashMap data) { try { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); - if (key.contains("延迟")) { int val = Integer.parseInt(value); - ToastUtils.info("延迟:" + value + "s"); Thread.sleep(val * 1000); } else { int writeValue = GetMXValue(key,value); @@ -267,13 +274,13 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); - if (key.contains("延迟")) { int val = Integer.parseInt(value); - ToastUtils.info("延迟:" + value + "s"); Thread.sleep(val * 1000); + } else if (key.contains("速度")) { + int writeValue = GetMXValue(key,value); + WritePLC(key, writeValue,null); } else { //原点位,等待机器移动倒响应位置 WritePLC(value, true,null); @@ -283,7 +290,7 @@ public class ExecuteTheRecipe { final boolean[] IsComplete = {false}; long a = System.currentTimeMillis(); while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * 60) { + if ((System.currentTimeMillis() - a) > 1000 * whileTime) { break; }else { @@ -326,13 +333,31 @@ public class ExecuteTheRecipe { ToastUtils.info("工序:手动投料," + name + "," + zl); String title = "手动投料-温馨提示!"; String message = "客官请投入主料,["+name+"]重量"+zl+"g,投入后点击[确定]继续流程!"; - AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - dialog.dismiss(); - } - }); + final boolean[] IsComplete = {false}; + Activity activity = findActivity(context); + if (activity != null) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + IsComplete[0]=true; + dialog.dismiss(); + } + }); + } catch (Exception e) { + + } + } + }); + } + + while (!IsComplete[0]) { + Thread.sleep(100);//10 *6 + } ToastUtils.info("确定完成,继续制作!"); } catch (Exception ex) { @@ -340,6 +365,16 @@ public class ExecuteTheRecipe { } } + private static Activity findActivity(@NonNull Context context) { + if (context instanceof Activity) { + return (Activity) context; + } else if (context instanceof ContextWrapper) { + return findActivity(((ContextWrapper) context).getBaseContext()); + } else { + return null; + } + } + /** * 写PLC 加热 * @@ -350,12 +385,9 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); - if (key.contains("延迟")) { int val = Integer.parseInt(value); - ToastUtils.info("延迟:" + value + "s"); Thread.sleep(val * 1000); } else { int writeValue = GetMXValue(key,value); @@ -391,9 +423,9 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); + ToastUtils.info("工序:" + key + "," + value); if (key.contains("延迟")) { int val = Integer.parseInt(value); - ToastUtils.info("延迟:" + value + "s"); Thread.sleep(val * 1000); } } @@ -412,12 +444,9 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); - if (key.contains("延迟")) { int val = Integer.parseInt(value); - ToastUtils.info("延迟:" + value + "s"); Thread.sleep(val * 1000); } } @@ -497,7 +526,23 @@ public class ExecuteTheRecipe { */ public static void Write_PLC_HuoLI(int data) { try { + WritePLC("加热功率", data*2, new IWriteCallBack() { + @Override + public void onSuccess() { + if(data==0) + { + WritePLC("加热",false,null); + }else + { + WritePLC("加热",true,null); + } + } + @Override + public void onFailure(String ErrorMsg) { + } + }); ToastUtils.info("火力按钮点击,当前级别:" + data); + } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } 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 cdca095b..c0f240ad 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 @@ -231,12 +231,12 @@ public class ConfigName { //翻转正转模型 add(new Res_PLCADDRESS("翻转正转","M10.4",0,1)); - add(new Res_PLCADDRESS("正转速度","VW104",1,1)); + add(new Res_PLCADDRESS("转动速度","VW104",1,1)); //翻转反转模型 add(new Res_PLCADDRESS("翻转反转","M10.5",0,1)); - add(new Res_PLCADDRESS("反转速度","VW104",1,1)); + add(new Res_PLCADDRESS("转动速度","VW104",1,1)); //加热模型 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java index b45b9380..0cbb1edf 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java @@ -75,9 +75,9 @@ public class DiyActivity extends BaseActivity { EditText zzsc;//制作时长 @BindView(R.id.check) CheckBox check;//默认收藏 - @BindView(R.id.Banner_Main) - Banner Banner_Main;//轮播图 - //用于存放获取的图片 +// @BindView(R.id.Banner_Main) +// Banner Banner_Main;//轮播图 +// //用于存放获取的图片 List Banner_list = new ArrayList<>(); @BindView(R.id.hrgx) @@ -111,7 +111,7 @@ public class DiyActivity extends BaseActivity { private void initData() { //1.初始化轮播图 - Drawable_Get(Banner_list); + //Drawable_Get(Banner_list); //2.初始化工序 ArrayList data=QueryDB.GetProcessALL(); int i=0;String id=""; @@ -378,7 +378,7 @@ public class DiyActivity extends BaseActivity { private void Banner_Set(List arrayList) { //这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源 //setImageLoader(一个实体类)用于加载图片到手机页面上显示 - Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start(); + //Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start(); } /** * 点击事件 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java index e94dc255..5c7af256 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java @@ -65,8 +65,8 @@ public class DiyUpdateActivity extends BaseActivity { EditText zzsc;//制作时长 @BindView(R.id.check) CheckBox check;//默认收藏 - @BindView(R.id.Banner_Main) - Banner Banner_Main;//轮播图 +// @BindView(R.id.Banner_Main) +// Banner Banner_Main;//轮播图 //用于存放获取的图片 List Banner_list = new ArrayList<>(); @@ -107,7 +107,7 @@ public class DiyUpdateActivity extends BaseActivity { private void initData() { //1.初始化轮播图 - Drawable_Get(Banner_list); + //Drawable_Get(Banner_list); //2.初始化工序 ArrayList data=QueryDB.GetProcessALL(); int i=0;String id=""; @@ -404,7 +404,7 @@ public class DiyUpdateActivity extends BaseActivity { private void Banner_Set(List arrayList) { //这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源 //setImageLoader(一个实体类)用于加载图片到手机页面上显示 - Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start(); + //Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start(); } /** * 点击事件 diff --git a/app/src/main/res/layout/activity_diy.xml b/app/src/main/res/layout/activity_diy.xml index 2ab7df78..eb902fa4 100644 --- a/app/src/main/res/layout/activity_diy.xml +++ b/app/src/main/res/layout/activity_diy.xml @@ -18,8 +18,7 @@ android:background="@color/qmui_config_color_white"> + android:layout_height="match_parent"> - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_diy_update.xml b/app/src/main/res/layout/activity_diy_update.xml index a956d1e8..b00b423e 100644 --- a/app/src/main/res/layout/activity_diy_update.xml +++ b/app/src/main/res/layout/activity_diy_update.xml @@ -18,8 +18,7 @@ android:background="@color/qmui_config_color_white"> + android:layout_height="match_parent"> - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home1.xml b/app/src/main/res/layout/fragment_home1.xml index e91f39c3..b6e44487 100644 --- a/app/src/main/res/layout/fragment_home1.xml +++ b/app/src/main/res/layout/fragment_home1.xml @@ -159,18 +159,20 @@ android:orientation="vertical"> + + android:layout_centerInParent="true" /> android:layout_height="wrap_content"/> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +