Przeglądaj źródła

1

tags/old_version_1
fyf 1 rok temu
rodzic
commit
2ae39385ca
8 zmienionych plików z 214 dodań i 74 usunięć
  1. +2
    -2
      app/src/main/java/com/bonait/bnframework/MainApplication.java
  2. +66
    -21
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +2
    -2
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +5
    -5
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
  5. +4
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java
  6. +17
    -18
      app/src/main/res/layout/activity_diy.xml
  7. +17
    -18
      app/src/main/res/layout/activity_diy_update.xml
  8. +101
    -4
      app/src/main/res/layout/fragment_home1.xml

+ 2
- 2
app/src/main/java/com/bonait/bnframework/MainApplication.java Wyświetl plik

@@ -159,7 +159,7 @@ public class MainApplication extends Application {
ConfigData.getInstance().RevertPLC();
}

RevertProcess();
}
/**
* 删除表-重新生成新表
@@ -193,7 +193,7 @@ public class MainApplication extends Application {
List<String> mxname=Arrays.asList("搅拌","位置","加热","主料","液体料","延迟","出菜");
Map<String,List<String>> 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<>());


+ 66
- 21
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java Wyświetl plik

@@ -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<String, String> data) {
try {

for (HashMap.Entry<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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());
}


+ 2
- 2
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java Wyświetl plik

@@ -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));


//加热模型


+ 5
- 5
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java Wyświetl plik

@@ -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<Drawable> 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<BPA_PROCESS> 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();
}
/**
* 点击事件


+ 4
- 4
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java Wyświetl plik

@@ -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<Drawable> 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<BPA_PROCESS> 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();
}
/**
* 点击事件


+ 17
- 18
app/src/main/res/layout/activity_diy.xml Wyświetl plik

@@ -18,8 +18,7 @@
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="160dp">
android:layout_height="match_parent">
<LinearLayout
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
@@ -292,21 +291,21 @@
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.youth.banner.Banner
android:id="@+id/Banner_Main"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
app:image_scale_type="fit_xy"
app:indicator_height="10dp"
app:indicator_margin="5dp"
app:indicator_width="10dp" />
</RelativeLayout>
<!-- <RelativeLayout-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginRight="10dp">-->
<!-- <com.youth.banner.Banner-->
<!-- android:id="@+id/Banner_Main"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="160dp"-->
<!-- android:layout_gravity="center"-->
<!-- app:image_scale_type="fit_xy"-->
<!-- app:indicator_height="10dp"-->
<!-- app:indicator_margin="5dp"-->
<!-- app:indicator_width="10dp" />-->
<!-- </RelativeLayout>-->
</RelativeLayout>
</LinearLayout>

+ 17
- 18
app/src/main/res/layout/activity_diy_update.xml Wyświetl plik

@@ -18,8 +18,7 @@
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="160dp">
android:layout_height="match_parent">
<LinearLayout
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
@@ -308,21 +307,21 @@
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.youth.banner.Banner
android:id="@+id/Banner_Main"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
app:image_scale_type="fit_xy"
app:indicator_height="10dp"
app:indicator_margin="5dp"
app:indicator_width="10dp" />
</RelativeLayout>
<!-- <RelativeLayout-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginRight="10dp">-->
<!-- <com.youth.banner.Banner-->
<!-- android:id="@+id/Banner_Main"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="160dp"-->
<!-- android:layout_gravity="center"-->
<!-- app:image_scale_type="fit_xy"-->
<!-- app:indicator_height="10dp"-->
<!-- app:indicator_margin="5dp"-->
<!-- app:indicator_width="10dp" />-->
<!-- </RelativeLayout>-->
</RelativeLayout>
</LinearLayout>

+ 101
- 4
app/src/main/res/layout/fragment_home1.xml Wyświetl plik

@@ -159,18 +159,20 @@ android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">

<com.bonait.bnframework.modules.home.fragment.mode.huoli_control
android:id="@+id/huoli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>

<!-- 液体 -->
<RelativeLayout
android:padding="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="2dp"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
@@ -179,12 +181,107 @@ android:orientation="vertical">
android:layout_height="wrap_content"/>
</RelativeLayout>

<!-- 清洗 -->
<!-- 搅拌 -->
<LinearLayout
android:layout_marginTop="2dp"
android:padding="5dp"
android:background="@color/qmui_config_color_white"
android:layout_width="match_parent"
android:layout_height="60dp">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="16dp"
android:text="搅拌选择"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/dp_10">
<LinearLayout
android:id="@+id/startjb"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/start" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="搅拌"
android:textSize="19dp"/>
</RelativeLayout>
</LinearLayout>

<!--边框分割细线-->
<RelativeLayout
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="1dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:background="@color/activity_background" />
</RelativeLayout>

<LinearLayout
android:id="@+id/stopjb"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/stop"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="停止"
android:textSize="19dp"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

<!-- 清洗 -->
<LinearLayout
android:layout_marginTop="10dp"
android:padding="5dp"
android:background="@color/qmui_config_color_white"
android:layout_width="match_parent"
android:layout_height="100dp">

<RelativeLayout


Ładowanie…
Anuluj
Zapisz