Browse Source

现场改动1

tags/old_version_1
fyf 1 year ago
parent
commit
4810474e66
20 changed files with 507 additions and 115 deletions
  1. +0
    -1
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +23
    -5
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +10
    -1
      app/src/main/java/com/bonait/bnframework/common/base/BaseActivity.java
  4. +10
    -9
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  5. +106
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java
  6. +29
    -27
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java
  7. +70
    -26
      app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java
  8. +56
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java
  9. +34
    -25
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java
  10. +22
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java
  11. +73
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/huoli_control.java
  12. +2
    -0
      app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java
  13. +23
    -14
      app/src/main/res/layout/fragment_home1.xml
  14. +3
    -0
      app/src/main/res/layout/item/layout/fragment_item_plc_control.xml
  15. +36
    -0
      app/src/main/res/layout/item/layout/item_huolikongzhi.xml
  16. +4
    -2
      app/src/main/res/layout/item/layout/item_imagebutton.xml
  17. BIN
     
  18. BIN
     
  19. +3
    -3
      app/src/main/res/values/colors.xml
  20. +3
    -0
      app/src/main/res/values/styles.xml

+ 0
- 1
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -952,7 +952,6 @@ public class ConfigData {
public void PLC_Init() {
//PLC连接成功,启动数据监听
ExecuteTheRecipe.Listening();

}
//endregion
}


+ 23
- 5
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -3,6 +3,7 @@ package com.bonait.bnframework.business;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Handler;

import androidx.annotation.NonNull;

@@ -31,6 +32,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import kotlin.UShort;

/**
* 执行配方
*/
@@ -337,7 +340,7 @@ public class ExecuteTheRecipe {
}
Thread.sleep(100);//10 *6
}
WritePLC(value, false, null);
ToastUtils.info("炒锅到达"+value+",继续制作!!!");

}
@@ -475,6 +478,7 @@ public class ExecuteTheRecipe {
}
//
ToastUtils.info("主料倒入完成,继续制作!");
WritePLC("平移-去1号位",true,null);
}
}
} catch (Exception ex) {
@@ -567,7 +571,8 @@ public class ExecuteTheRecipe {
}
}
WritePLC("出菜", true, null);

WritePLC("搅拌", false, null);
WritePLC("加热", false, null);
//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "出餐启动反馈";
final boolean[] IsComplete = {false};
@@ -622,6 +627,8 @@ public class ExecuteTheRecipe {
ToastUtils.info("点击按钮:" + data);
//原点位,等待机器移动倒响应位置
WritePLC(data, true, null);
Thread.sleep(500);//10 *6
WritePLC(data, false, null);
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -676,6 +683,14 @@ public class ExecuteTheRecipe {

//region PLC监听线程
public static void Listening() {
ExecuteTheRecipe.WritePLC("初始化", true, null);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC("初始化", false, null);
}
}, 500);

ConfigName.getInstance().PLC_Address.clear();
ArrayList<BPA_PLCADDRESS> address = QueryDB.GetPlcaddressALL();
for (BPA_PLCADDRESS item : address) {
@@ -683,6 +698,8 @@ public class ExecuteTheRecipe {
ConfigName.getInstance().PLC_Address.put(item.name, item);
}
}


ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() {
@Override
public void Run() throws InterruptedException {
@@ -732,7 +749,7 @@ public class ExecuteTheRecipe {
ModbusTcpServer.get().WriteBool(plcaddress.address, (boolean) value, callback);
} else if (plcaddress.address.toUpperCase().startsWith("VW"))//short
{
ModbusTcpServer.get().WriteShort(plcaddress.address, (Short) value, callback);
ModbusTcpServer.get().WriteShort(plcaddress.address, Short.parseShort(value.toString()), callback);
}
}
}
@@ -757,8 +774,9 @@ public class ExecuteTheRecipe {
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
ModbusTcpServer.get().ReadInt(plcaddress.address, 1, val -> {
ReturnsVariable[0] = val[0];

ModbusTcpServer.get().ReadInt(plcaddress.address, 1, ints -> {
ReturnsVariable[0] = ints[0];
});
} else if (plcaddress.address.toUpperCase().startsWith("M"))//bool
{


+ 10
- 1
app/src/main/java/com/bonait/bnframework/common/base/BaseActivity.java View File

@@ -3,12 +3,14 @@ package com.bonait.bnframework.common.base;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.common.constant.Constants;
import com.bonait.bnframework.common.helper.ActiveMax;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.arch.QMUIActivity;
@@ -25,10 +27,17 @@ import pub.devrel.easypermissions.EasyPermissions;
* Created by LY on 2019/3/21.
*/
@SuppressLint("Registered")
public class BaseActivity extends QMUIActivity implements EasyPermissions.PermissionCallbacks {
public class BaseActivity extends QMUIActivity implements EasyPermissions.PermissionCallbacks {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
//ActiveMax.MaxFrom(this);
super.onCreate(savedInstanceState);
}

@Override
protected int backViewInitOffset() {

return QMUIDisplayHelper.dp2px(MainApplication.getContext(), 100);
}



+ 10
- 9
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -401,7 +401,6 @@ public class ConfigName {

//位置动作
add(new Res_PLCADDRESS("原点位", "M11.4", 0, 1));
add(new Res_PLCADDRESS("投料位", "M11.4", 0, 1));
add(new Res_PLCADDRESS("倒菜位", "M12.7", 0, 1));
add(new Res_PLCADDRESS("抽料位", "M11.7", 0, 1));
add(new Res_PLCADDRESS("清洗位", "M13.0", 0, 1));
@@ -601,7 +600,6 @@ public class ConfigName {

//位置动作
add(new Res_PLCADDRESS("原点位", "M11.4", 0, 1));
add(new Res_PLCADDRESS("投料位", "M11.4", 0, 1));
add(new Res_PLCADDRESS("倒菜位", "M12.7", 0, 1));
add(new Res_PLCADDRESS("抽料位", "M11.7", 0, 1));
add(new Res_PLCADDRESS("清洗位", "M13.0", 0, 1));
@@ -773,7 +771,7 @@ public class ConfigName {
if (item.equals("搅拌动作")) {
data = "正转反转、一直正转、一直反转";
} else if (item.equals("位置动作")) {
data = "原点位、投料位、出餐启动、倒菜位、抽料位、清洗位、炒菜位1、炒菜位2、炒菜位3";
data = "原点位、出餐启动、倒菜位、抽料位、清洗位、炒菜位1、炒菜位2、炒菜位3";
} else if (item.equals("投料动作")) {
//data = "投出抖动三次、投出等待三秒、直接投出、手动投料";
data = "投出等待三秒、直接投出、手动投料";
@@ -782,7 +780,7 @@ public class ConfigName {
} else if (item.equals("正转速度") || item.equals("反转速度") || item.equals("转动速度") || item.equals("搅拌速度")) {
data = "停止、最低、低速、中速、高速、最高、极高";
} else if (item.equals("加热功率") || item.equals("热锅功率")) {
data = "停止、一档、二档、三档、四档、五档";
data = "停止、一档、二档、三档、四档、五档、六档、七档、八档";
}
return data;
}
@@ -804,11 +802,14 @@ public class ConfigName {
*/
public ConcurrentHashMap<String, Integer> HeatingGear = new ConcurrentHashMap<String, Integer>() {{
put("停止", 0);
put("一档", 2);
put("二档", 4);
put("三档", 6);
put("四档", 8);
put("五档", 10);
put("一档", 1);
put("二档", 2);
put("三档", 3);
put("四档", 4);
put("五档", 5);
put("六档", 6);
put("七档", 7);
put("八档", 8);
}};
/**
* 炒锅状态上报信息


+ 106
- 0
app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java View File

@@ -0,0 +1,106 @@
package com.bonait.bnframework.common.helper;

import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;

import java.util.ArrayList;
import java.util.List;

public class ActiveMax {
/**
* 最大化窗体
* View.SYSTEM_UI_FLAG_LAYOUT_STABLE:全屏显示时保证尺寸不变。
* View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN:Activity全屏显示,状态栏显示在Activity页面上面。
* View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION:效果同View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
* View.SYSTEM_UI_FLAG_HIDE_NAVIGATION:隐藏导航栏
* View.SYSTEM_UI_FLAG_FULLSCREEN:Activity全屏显示,且状态栏被隐藏覆盖掉。
* View.SYSTEM_UI_FLAG_VISIBLE:Activity非全屏显示,显示状态栏和导航栏。
* View.INVISIBLE:Activity伸展全屏显示,隐藏状态栏。
* View.SYSTEM_UI_LAYOUT_FLAGS:效果同View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
* View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY:必须配合View.SYSTEM_UI_FLAG_FULLSCREEN和View.SYSTEM_UI_FLAG_HIDE_NAVIGATION组合使用,达到的效果是拉出状态栏和导航栏后显示一会儿消失。
*
* @param activity
*/
public static List<Activity> activities=new ArrayList<>();
public static void MaxFrom(Activity activity) {
// 全屏展示
if(!activities.contains(activity))
{
activities.add(activity);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 全屏显示,隐藏状态栏和导航栏,拉出状态栏和导航栏显示一会儿后消失。
// activity.getWindow().getDecorView().setSystemUiVisibility(
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
//activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

} else {
// 全屏显示,隐藏状态栏
activity.getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);
}
}

// 注册监听器
activity.getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(keyboardVisibilityListener);
}

/**
* 家农安
*/
private static ViewTreeObserver.OnGlobalLayoutListener keyboardVisibilityListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// 在此处处理键盘关闭事件
// 检查键盘的可见性和高度等信息来判断键盘是否关闭
for (Activity activity:activities)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 全屏显示,隐藏状态栏和导航栏,拉出状态栏和导航栏显示一会儿后消失。
activity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} else {
// 全屏显示,隐藏状态栏
activity.getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);
}
}
}
}
};

public static void closeMaxFrom(Activity activity) {
// 全屏展示
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 全屏显示,隐藏状态栏和导航栏,拉出状态栏和导航栏显示一会儿后消失。
activity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} else {
// 全屏显示,隐藏状态栏
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
}
}

// 非全屏显示,显示状态栏和导航栏
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}

+ 29
- 27
app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java View File

@@ -1,6 +1,9 @@
package com.bonait.bnframework.common.modbus;


import android.os.Looper;

import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
@@ -48,7 +51,7 @@ public class ModbusTcpServer {
private ModbusTcpServer() {
}

ModbusParam param;
static ModbusParam param;

private int GetAddress(String address) {
if (address == null) return -1;
@@ -154,16 +157,15 @@ public class ModbusTcpServer {

if(returnMsg.indexOf("100% packet loss")!=-1){
System.out.println("与 " +address +" 连接不畅通.");
ToastUtils.info("与 " +address +" 连接不畅通.");

//ToastUtils.info("与 " +address +" 连接不畅通.");
return false;
} else{
ToastUtils.info("与 " +address +" 连接畅通.");
System.out.println("与 " +address +" 连接畅通.");
//ToastUtils.info("与 " +address +" 连接不畅通.");
return true;
}
} catch (IOException e) {
e.printStackTrace();
// e.printStackTrace();
}
return false;

@@ -187,13 +189,7 @@ public class ModbusTcpServer {
}
}
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!");
String host=ConfigName.getInstance().Address;
int port=ConfigName.getInstance().Post;
param = TcpParam.create(host, port)
.setTimeout(1000)
.setRetries(0)
.setEncapsulated(false)
.setKeepAlive(true);

while (ConfigName.getInstance().PlcIsConnect==false)
{
ConnectPLC();
@@ -204,8 +200,15 @@ public class ModbusTcpServer {
/**
* 连接PLC
*/
public void ConnectPLC()
public static void ConnectPLC()
{
String host=ConfigName.getInstance().Address;
int port=ConfigName.getInstance().Post;
param = TcpParam.create(host, port)
.setTimeout(1000)
.setRetries(0)
.setEncapsulated(false)
.setKeepAlive(true);
ModbusTcpHelper.get().init(param, new ModbusCallback<ModbusMaster>() {
@Override
public void onSuccess(ModbusMaster modbusMaster) {
@@ -384,10 +387,6 @@ public class ModbusTcpServer {
byte[] tempData = new byte[6];
tempData[0] = data[1];
tempData[1] = data[0];
tempData[2] = data[3];
tempData[3] = data[2];
tempData[4] = data[5];
tempData[5] = data[4];
if (callback != null) callback.onSuccess(tempData);
} catch (InterruptedException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
@@ -555,22 +554,25 @@ public class ModbusTcpServer {
ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length * 2);
byte[] data = res.getData();
int[] tempValues = new int[length];
for (int i = 0; i < length; i++) {
byte[] tempData = new byte[4];
for (int m = 0; m < 4; m++) {
tempData[m] = data[i * 4 + m];
}
if(data.length>=4)
{
for (int i = 0; i < length; i++) {
byte[] tempData = new byte[4];
for (int m = 0; m < 4; m++) {
tempData[m] = data[i * 4 + m];
}
// Integer a1 = tempValues[i] = BytesToInt(tempData, DataFormat.ABCD);
// Integer a2 = tempValues[i] = BytesToInt(tempData, DataFormat.BADC);
// Integer a3 = tempValues[i] = BytesToInt(tempData, DataFormat.CDAB);
// Integer a4 = tempValues[i] = BytesToInt(tempData, DataFormat.DCBA);
tempValues[i] = BytesToInt(tempData, DataFormat.BADC);
}
}else
{
MessageLog.ShowError("ReadInt onFailure,Address=" );

tempValues[i] = BytesToInt(tempData, DataFormat.BADC);

}
if (tempValues.length == length) {
if (callback != null) callback.onSuccess(tempValues);
}
if (callback != null) callback.onSuccess(tempValues);
} catch (InterruptedException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {


+ 70
- 26
app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java View File

@@ -11,6 +11,9 @@ import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;

import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -215,39 +218,80 @@ public class ToastUtils {
public static Toast custom(@NonNull Context context, @NonNull String message, @DrawableRes int iconRes, @ColorInt int textColor, @ColorInt int tintColor, int duration, boolean withIcon, boolean shouldTint) {
return custom(context, message, getDrawable(context, iconRes), textColor, tintColor, duration, withIcon, shouldTint);
}
public static Handler mHandler = new Handler(Looper.getMainLooper());

@CheckResult
public static Toast custom(@NonNull Context context, @NonNull String message, Drawable icon, @ColorInt int textColor, @ColorInt int tintColor, int duration, boolean withIcon, boolean shouldTint) {
if (currentToast == null) {
currentToast = new Toast(context);
}
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null);
final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon);
final TextView toastTextView = toastLayout.findViewById(R.id.toast_text);
Drawable drawableFrame;
if (Looper.myLooper() == Looper.getMainLooper()) {
if (currentToast == null) {
currentToast = new Toast(context);
}
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null);
final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon);
final TextView toastTextView = toastLayout.findViewById(R.id.toast_text);
Drawable drawableFrame;

if (shouldTint) {
drawableFrame = tint9PatchDrawableFrame(context, tintColor);
} else {
drawableFrame = getDrawable(context, R.mipmap.toast_frame);
}
setBackground(toastLayout, drawableFrame);

if (withIcon) {
if (icon == null) {
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
}
setBackground(toastIcon, icon);
} else {
toastIcon.setVisibility(View.GONE);
}

if (shouldTint) {
drawableFrame = tint9PatchDrawableFrame(context, tintColor);
} else {
drawableFrame = getDrawable(context, R.mipmap.toast_frame);
}
setBackground(toastLayout, drawableFrame);
toastTextView.setTextColor(textColor);
toastTextView.setText(message);
toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL));

if (withIcon) {
if (icon == null) {
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
}
setBackground(toastIcon, icon);
currentToast.setView(toastLayout);
currentToast.setDuration(duration);
return currentToast;
} else {
toastIcon.setVisibility(View.GONE);
mHandler.post(new Runnable() {
@Override
public void run() {
if (currentToast == null) {
currentToast = new Toast(context);
}
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null);
final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon);
final TextView toastTextView = toastLayout.findViewById(R.id.toast_text);
Drawable drawableFrame;

if (shouldTint) {
drawableFrame = tint9PatchDrawableFrame(context, tintColor);
} else {
drawableFrame = getDrawable(context, R.mipmap.toast_frame);
}
setBackground(toastLayout, drawableFrame);

if (withIcon) {
if (icon == null) {
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
}
setBackground(toastIcon, icon);
} else {
toastIcon.setVisibility(View.GONE);
}

toastTextView.setTextColor(textColor);
toastTextView.setText(message);
toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL));

currentToast.setView(toastLayout);
currentToast.setDuration(duration);

}
});
}

toastTextView.setTextColor(textColor);
toastTextView.setText(message);
toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL));

currentToast.setView(toastLayout);
currentToast.setDuration(duration);
return currentToast;
}



+ 56
- 1
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java View File

@@ -4,9 +4,17 @@ import android.os.Bundle;
import androidx.annotation.NonNull;

import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.viewpager.widget.ViewPager;

import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;

@@ -160,8 +168,55 @@ public class BottomNavigation2Activity extends BaseActivity {
//判断连接环境
ConfigData.getInstance().ToggleEnvironment();
//2.初始化PLC
ConfigData.getInstance().ConnectPLC();
ReconnectModbus();
//初始化阿里云连接
//AliyunIOTManager.getInstance().OpenDev(this);
}

/**
* 重新连接plc
*/
public void ReconnectModbus()
{
try {

ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
if(ConfigName.getInstance().PlcIsConnect)
{
//ping 不通
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1);
if(!status) //ping 不通 连接
{
MessageLog.ShowInfo("PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcIsConnect=false;
}
}else
{
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1);
if(status)
{
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!");
ModbusTcpServer.ConnectPLC();
}else
{
MessageLog.ShowInfo("PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcIsConnect=false;
}
}
Thread.sleep(10000);
} catch (Exception e) {
Log.i("PLC", "PLC重连接失败!"+e.getMessage());
}
}
@Override
public void RunComplete() throws InterruptedException {
}
});
}catch (Exception e) {
MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage());
}
}
}

+ 34
- 25
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java View File

@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import android.os.CountDownTimer;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -105,7 +106,7 @@ public class Home1Fragment extends BaseFragment {
@BindView(R.id.chaoguo_weizhi)
QMUILinkTextView chaoguo_weizhi;//
@BindView(R.id.plc_zhuangtai)
QMUILinkTextView plc_zhuangtai;//
ImageView plc_zhuangtai;//

@BindView(R.id.nifty_slider2)
NiftySlider nifty_slider2;//
@@ -440,8 +441,8 @@ public class Home1Fragment extends BaseFragment {
public void run() {
Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度");
Object val_wz = ExecuteTheRecipe.getListingValue("编码器当前位值");
Object val_jbpl = ExecuteTheRecipe.getListingValue("搅拌频率");
Object val_fzpv = ExecuteTheRecipe.getListingValue("翻转频率");
// Object val_jbpl = ExecuteTheRecipe.getListingValue("搅拌频率");
// Object val_fzpv = ExecuteTheRecipe.getListingValue("翻转频率");

if (val_wd != null) {
chaoguo_wendu.setText(val_wd + "");
@@ -455,18 +456,17 @@ public class Home1Fragment extends BaseFragment {
chaoguo_weizhi.setText("未知");
}

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

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);
// }

plc_zhuangtai.setImageResource(ConfigName.getInstance().PlcIsConnect ?R.mipmap.yjzt:R.mipmap.yjzt1);
}
});
}
@@ -553,7 +553,7 @@ public class Home1Fragment extends BaseFragment {
, 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})
public void onViewClicked(View view) {
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.xzcp://选择菜谱按钮点击
skipToActivity(CpxzActivity.class);
@@ -638,16 +638,24 @@ public class Home1Fragment extends BaseFragment {
ExecuteTheRecipe.Write_PLC_Location("炒菜位3");
break;
case R.id.chushihua:
if (!IsMake(true)) { return; }
ToastUtils.info("点击按钮:初始化");
ExecuteTheRecipe.WritePLC("初始化", true, null);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC("初始化", false, null);
}
}, 500);
break;
case R.id.jiting:
if (!IsMake(true)) { return; }
ToastUtils.info("点击按钮:急停");
ExecuteTheRecipe.WritePLC("停止", true, null);


new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC("停止", false, null);
}
}, 500);
break;
}
}
@@ -664,15 +672,16 @@ public class Home1Fragment extends BaseFragment {
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
Object jiting = 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 (jiting == null || !(boolean) jiting) {
// ToastUtils.warning("设备已急停,请检查设备!!!");
// return false;
// }

if (Status && k)
{


+ 22
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java View File

@@ -225,12 +225,34 @@ public class CpActivity extends BaseActivity {

private void initTopBar() {
mTopBar.setTitle("菜谱管理");
/**
* 返回按钮
*/
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
/**
* 新建商品
*/
mTopBar.addRightTextButton("新建商品",R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skipToActivity(DiyActivity.class);
}
});
}

/**
* 跳转界面
*/
private void skipToActivity(Class da) {
// 跳转到登录页面
Intent intent = new Intent(context, da);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}

@Override


+ 73
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/huoli_control.java View File

@@ -28,6 +28,12 @@ public class huoli_control extends LinearLayout {
ImageView hl4;
@BindView(R.id.hl5)
ImageView hl5;
@BindView(R.id.hl6)
ImageView hl6;
@BindView(R.id.hl7)
ImageView hl7;
@BindView(R.id.hl8)
ImageView hl8;
/**
* 当前状态
*/
@@ -56,7 +62,7 @@ public class huoli_control extends LinearLayout {
}

@OnClick({R.id.colse,
R.id.hl1,R.id.hl2,R.id.hl3,R.id.hl4,R.id.hl5})
R.id.hl1,R.id.hl2,R.id.hl3,R.id.hl4,R.id.hl5,R.id.hl6,R.id.hl7,R.id.hl8})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.colse://选择菜谱按钮点击
@@ -83,6 +89,15 @@ public class huoli_control extends LinearLayout {
case R.id.hl5:
SetLevel(5);
break;
case R.id.hl6:
SetLevel(6);
break;
case R.id.hl7:
SetLevel(7);
break;
case R.id.hl8:
SetLevel(8);
break;
}

if(mListener!=null)
@@ -107,6 +122,9 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==2)
{
Status=true;
@@ -116,6 +134,9 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==3)
{
Status=true;
@@ -125,6 +146,9 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==4)
{
Status=true;
@@ -134,6 +158,9 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==5)
{
Status=true;
@@ -143,6 +170,48 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==6)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==7)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==8)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlqd);
hl8.setImageResource(R.mipmap.hlqd);
}else
{
Status=false;
@@ -152,6 +221,9 @@ public class huoli_control extends LinearLayout {
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
}
}

+ 2
- 0
app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java View File

@@ -30,6 +30,7 @@ import com.bonait.bnframework.common.constant.Constants;
import com.bonait.bnframework.common.constant.SPConstants;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.helper.ActiveMax;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.AnimationToolUtils;
import com.bonait.bnframework.common.utils.AppUtils;
@@ -99,6 +100,7 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);


+ 23
- 14
app/src/main/res/layout/fragment_home1.xml View File

@@ -222,7 +222,7 @@ android:orientation="vertical">

<RelativeLayout
android:layout_alignParentRight="true"
android:layout_width="120dp"
android:layout_width="180dp"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/dp_10">
<com.bonait.bnframework.modules.home.fragment.mode.imagebutton_control
@@ -297,7 +297,7 @@ android:orientation="vertical">
</RelativeLayout>

<LinearLayout
android:layout_width="120dp"
android:layout_width="180dp"
android:layout_marginRight="@dimen/dp_10"
android:layout_height="match_parent">
<RelativeLayout
@@ -381,12 +381,13 @@ android:orientation="vertical">
android:layout_height="match_parent">
<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="30dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<ImageView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:src="@mipmap/chushihua" />
</RelativeLayout>
@@ -426,8 +427,9 @@ android:orientation="vertical">
android:layout_height="match_parent">

<ImageView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:src="@mipmap/jiting" />
</RelativeLayout>
@@ -1064,20 +1066,27 @@ android:orientation="vertical">
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="16dp"
android:text="PLC状态"/>
android:text="硬件状态"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
<ImageView
android:id="@+id/plc_zhuangtai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="24dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:textSize="24dp"
android:textColor="@color/teal_primary_dark"
android:text="未连接"/>
android:src="@mipmap/yjzt">
</ImageView>
<!-- <com.qmuiteam.qmui.widget.textview.QMUILinkTextView-->
<!-- android:id="@+id/plc_zhuangtai"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:textSize="24dp"-->
<!-- android:textColor="@color/teal_primary_dark"-->
<!-- android:text="未连接"/>-->
</RelativeLayout>

</LinearLayout>


+ 3
- 0
app/src/main/res/layout/item/layout/fragment_item_plc_control.xml View File

@@ -84,6 +84,9 @@
android:layout_height="wrap_content">

<com.suke.widget.SwitchButton
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
app:sb_button_color="@color/app_color_blue"
android:id="@+id/control_switch"
android:layout_width="80dp"
android:layout_height="wrap_content"


+ 36
- 0
app/src/main/res/layout/item/layout/item_huolikongzhi.xml View File

@@ -76,4 +76,40 @@
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl6"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl7"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl8"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>
</LinearLayout>

+ 4
- 2
app/src/main/res/layout/item/layout/item_imagebutton.xml View File

@@ -10,10 +10,12 @@
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<ImageView
android:id="@+id/image_u"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="fitXY"
android:layout_centerInParent="true"
android:src="@mipmap/start" />
</RelativeLayout>


BIN
View File


BIN
View File


+ 3
- 3
app/src/main/res/values/colors.xml View File

@@ -60,7 +60,7 @@
<color name="gray_very_light">#E0E0E0</color>
<color name="gray_deep">#666666</color>
<color name="black_overlay">#66000000</color>
<color name="activity_background">#EEEEEE</color>
<color name="activity_background">#D8D8D8</color>
<color name="activity_background1">#F8F7F7</color>
<color name="transparent">#00000000</color>
<color name="main_background">#EEEEEE</color>
@@ -128,6 +128,6 @@
<color name="we_read_theme_color">#444138</color>
<color name="we_read_thumb_color">#fbf7eb</color>

<color name="pro1">#744CAF50</color>
<color name="pro2">#17000000</color>
<color name="pro1">#E24CAF50</color>
<color name="pro2">#CCCBCB</color>
</resources>

+ 3
- 0
app/src/main/res/values/styles.xml View File

@@ -41,6 +41,9 @@
<item name="android:windowBackground">@drawable/welcome</item> <!--设置启动背景图-->
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>

<style name="QDtextAppearanceListItem">


Loading…
Cancel
Save