From 31da1c43be943f424951613eae7e5d9f9bf2c2b0 Mon Sep 17 00:00:00 2001 From: liup Date: Fri, 19 Apr 2024 18:14:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=82=92=E6=9C=BA=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 10 + .idea/migrations.xml | 10 + .idea/misc.xml | 1 - app/build.gradle | 6 + app/src/main/AndroidManifest.xml | 6 + app/src/main/assets/error_code.json | 132 ++ .../Communication/Modbus/ExceptionServer.java | 2 + .../Communication/Modbus/ModbusMaster.java | 5 +- .../bnframework/HBL/DataUtil/DataType.java | 2 + .../HBL/DataUtil/ErrorCodeManager.java | 39 + .../HBL/DataUtil/ErrorCodeUtil.java | 64 + .../bnframework/HBL/Logs/MessageLog.java | 8 +- .../bnframework/Model/ErrorCodeBean.java | 34 + .../bnframework/Service/AnalogConvert.java | 3 + .../bnframework/Service/ControlAdress.java | 50 +- .../bnframework/Service/ModbusHelper.java | 296 +++- .../BottomNavigationNewActivity.java | 224 +-- .../ActivityViewModel/CookingNewActivity.java | 410 +++++ .../ActivityViewModel/DishTestActivity.java | 38 +- .../ActivityViewModel/DiyMemoryActivity.java | 13 + .../ActivityViewModel/DiyUpdate1Activity.java | 210 ++- .../ActivityViewModel/WelcomeActivity.java | 2 + .../Adapter/silos_calibrate_adapter.java | 85 + .../ViewModel/Adapter/sp_adapter.java | 5 + .../ViewModel/CustomView/XComDialog.java | 285 ++++ .../ViewModel/CustomView/add_qupenren.java | 21 +- .../FragmentViewModel/HomeDeviceFragment.java | 55 + .../FragmentViewModel/HomeFragmentPR.java | 9 + .../SystemSeasoningsetFragment.java | 149 +- .../business/ExecuteTheRecipe.java | 347 ++-- .../bonait/bnframework/business/MainInit.java | 49 +- .../common/constant/ConfigName.java | 2 + .../bnframework/common/constant/DataBus.java | 6 + .../bonait/bnframework/common/db/QueryDB.java | 129 +- .../bnframework/common/db/file/DBHelper.java | 20 +- .../bnframework/common/db/file/Table.java | 3 + .../bnframework/common/db/mode/BPA_GOODS.java | 23 + .../common/db/mode/BPA_GOODSRECIPE.java | 24 + .../common/db/mode/BPA_PROCESS.java | 16 + .../common/db/mode/BPA_PROCESSModel.java | 18 + .../bnframework/common/db/mode/BPA_SILOS.java | 25 + .../common/db/mode/BPA_SILOS_CALIBRATE.java | 41 + .../bnframework/common/db/mode/ModeBase.java | 14 + .../common/helper/CrashHandler.java | 3 + .../common/utils/AlertDialogUtils.java | 15 + .../bnframework/common/utils/FileUtils.java | 24 + .../layout/activity_bottom_navigation_new.xml | 16 +- .../main/res/layout/activity_cooking_new.xml | 145 ++ app/src/main/res/layout/activity_dishtest.xml | 28 +- .../main/res/layout/activity_diy_memory.xml | 2 +- .../main/res/layout/activity_diy_update1.xml | 1 + .../datatab/layout/silos_calibrate_item.xml | 119 ++ .../res/layout/dialog_with_cancel_confirm.xml | 76 + .../main/res/layout/fragment_home_device.xml | 32 + .../main/res/layout/fragment_home_sbkz.xml | 6 +- .../layout/fragment_system_seasoningset.xml | 151 ++ .../res/layout/season_jiaozhun_layout.xml | 148 ++ .../res/mipmap-xxxhdpi/device_small_cook1.png | Bin 0 -> 83918 bytes .../res/mipmap-xxxhdpi/device_small_cook2.png | Bin 0 -> 70625 bytes .../res/mipmap-xxxhdpi/device_small_cook3.png | Bin 0 -> 38943 bytes .../res/mipmap-xxxhdpi/device_small_cook4.png | Bin 0 -> 67657 bytes app/src/main/res/values/dimens.xml | 1422 ++++++++++++++++- app/src/main/res/values/strings.xml | 7 + app/src/main/res/values/styles.xml | 8 +- 64 files changed, 4697 insertions(+), 397 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/migrations.xml create mode 100644 app/src/main/assets/error_code.json create mode 100644 app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeManager.java create mode 100644 app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeUtil.java create mode 100644 app/src/main/java/com/bonait/bnframework/Model/ErrorCodeBean.java create mode 100644 app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/CookingNewActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/silos_calibrate_adapter.java create mode 100644 app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/XComDialog.java create mode 100644 app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java create mode 100644 app/src/main/res/layout/activity_cooking_new.xml create mode 100644 app/src/main/res/layout/datatab/layout/silos_calibrate_item.xml create mode 100644 app/src/main/res/layout/dialog_with_cancel_confirm.xml create mode 100644 app/src/main/res/layout/fragment_home_device.xml create mode 100644 app/src/main/res/layout/season_jiaozhun_layout.xml create mode 100644 app/src/main/res/mipmap-xxxhdpi/device_small_cook1.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/device_small_cook2.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/device_small_cook3.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/device_small_cook4.png diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 00000000..0c0c3383 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 00000000..f8051a6f --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index c3df9b04..e9a58ca7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/build.gradle b/app/build.gradle index db84ce9e..c13c85b5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,6 +54,9 @@ android { } } + buildFeatures { + viewBinding = true + } } dependencies { @@ -162,4 +165,7 @@ dependencies { //MQTT // implementation files('libs\\org.eclipse.paho.android.service-1.1.1.jar') // implementation files('libs\\org.eclipse.paho.client.mqttv3-1.2.5.jar') + + //日志工具 可定位代码行数 + api 'com.apkfuns.logutils:library:1.7.5' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 87c80ac2..d2e612de 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -176,6 +176,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/error_code.json b/app/src/main/assets/error_code.json new file mode 100644 index 00000000..fdd9bb4b --- /dev/null +++ b/app/src/main/assets/error_code.json @@ -0,0 +1,132 @@ +[ + { + "code": "1", + "description": "机芯散热器温度超过 78℃", + "name": "IGBT过热" + }, + { + "code": "2", + "description": "电源电压过高大于 450V", + "name": "直流母线过压" + }, + { + "code": "3", + "description": "直流母线欠压", + "name": "电源电压过低低于300V" + }, + { + "code": "4", + "description": "", + "name": "" + }, + { + "code": "5", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + }, + { + "code": "", + "description": "", + "name": "" + } +] \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ExceptionServer.java b/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ExceptionServer.java index 485e7f3c..d5bbea93 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ExceptionServer.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ExceptionServer.java @@ -13,6 +13,7 @@ public class ExceptionServer { { try { int add = GetAddress(Address); + MessageLog.ShowInfo( "ExceptionServer add="+add); if (add < 0) { MessageLog.ShowError("地址解析失败=" + Address); return; @@ -32,6 +33,7 @@ public class ExceptionServer { } public int GetAddress(String address) { + MessageLog.ShowInfo("GetAddress address="+address); if (address == null) return -1; if (address.length() > 0) { address = address.trim(); diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java b/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java index 766f975f..134cc38a 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java @@ -2,6 +2,7 @@ package com.bonait.bnframework.HBL.Communication.Modbus; import static com.bonait.bnframework.HBL.DataUtil.DataConvertLib.ByteToShort; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Communication.CommBase; import com.bonait.bnframework.HBL.DataUtil.FloatLib; import com.bonait.bnframework.HBL.DataUtil.IntLib; @@ -187,7 +188,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{ } public OperateResult Write(String address,T value) { if(!getConnected()){ return OperateResult.CreateFailed("设备未连接");} - AtomicReferenceresultValue=new AtomicReference<>(); + AtomicReference resultValue=new AtomicReference<>(); try{ String typeName= value.getClass().getCanonicalName(); switch(typeName){ @@ -327,8 +328,10 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{ if(!getConnected()){ return OperateResultT.CreateFailedT("设备未连接");} AtomicReference>resultValue=new AtomicReference<>(); ReadShort(address,1).OnSource((s)->{ + LogUtils.d("ReadShort 读操作 返回结果:"+s.Content[0]); resultValue.set(OperateResultT.CreateSuccess(s.Content[0])); }).OnFailed(s->{ + LogUtils.d("ReadShort 读操作 失败:"+s.message); resultValue.set(OperateResultT.CreateFailedT(s.message)); }); return resultValue.get(); diff --git a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/DataType.java b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/DataType.java index fcf2a57b..24c600b2 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/DataType.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/DataType.java @@ -1,5 +1,7 @@ package com.bonait.bnframework.HBL.DataUtil; +import java.io.Serializable; + public class DataType { public static final String STRING=""; public static final byte BYTE=0; diff --git a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeManager.java b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeManager.java new file mode 100644 index 00000000..b44e1149 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeManager.java @@ -0,0 +1,39 @@ +package com.bonait.bnframework.HBL.DataUtil; + +import com.alibaba.fastjson.JSON; +import com.bonait.bnframework.MainApplication; +import com.bonait.bnframework.Model.ErrorCodeBean; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.utils.FileUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 设备故障错误码 + * */ +public class ErrorCodeManager { + private static final String ERROR_CODE_FILE_NAME = "error_code.json"; + private static volatile ErrorCodeManager mInstance = new ErrorCodeManager(); + private List mDataBeans = new ArrayList<>(); + private ErrorCodeManager() { + + } + + public static ErrorCodeManager getInstance() { + if (mInstance==null) { + synchronized (ErrorCodeManager.class){ + if(mInstance == null){ + mInstance = new ErrorCodeManager(); + } + } + } + return mInstance; + } + + public void initData(){ + String cache = FileUtils.getJson("error_code.json", MainApplication.getContext()); + mDataBeans = JSON.parseArray(cache,ErrorCodeBean.class); + } + +} diff --git a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeUtil.java b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeUtil.java new file mode 100644 index 00000000..d7c7496e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/ErrorCodeUtil.java @@ -0,0 +1,64 @@ +package com.bonait.bnframework.HBL.DataUtil; + +import android.widget.Switch; + +import androidx.annotation.NonNull; + +public class ErrorCodeUtil { + public String errorCodeToString(int code) { + String result = "正常"; + switch (code){ + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 16: + break; + case 17: + break; + case 18: + break; + case 19: + break; + case 20: + break; + case 21: + break; + case 22: + break; + case 23: + break; + case 24: + break; + case 25: + break; + } + return result; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Logs/MessageLog.java b/app/src/main/java/com/bonait/bnframework/HBL/Logs/MessageLog.java index 0bc1b775..b027f825 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Logs/MessageLog.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Logs/MessageLog.java @@ -2,6 +2,7 @@ package com.bonait.bnframework.HBL.Logs; import android.util.Log; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; @@ -15,17 +16,20 @@ public class MessageLog { MsgNotify = new IMessageLogNotify() { @Override public void ErrorMsg(String msg) { - Log.e("错误日志",msg); +// Log.e("错误日志",msg); + LogUtils.e("错误日志"+msg); } @Override public void InfoMsg(String msg) { - Log.i("信息日志",msg); +// Log.i("信息日志",msg); + LogUtils.i("信息日志"+msg); } @Override public void WarnMsg(String msg) { Log.w("警告日志",msg); + LogUtils.w("警告日志"+msg); } }; ThreadManager.get().StartLong("日志信息保存",true,()->{ diff --git a/app/src/main/java/com/bonait/bnframework/Model/ErrorCodeBean.java b/app/src/main/java/com/bonait/bnframework/Model/ErrorCodeBean.java new file mode 100644 index 00000000..820901a4 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/Model/ErrorCodeBean.java @@ -0,0 +1,34 @@ +package com.bonait.bnframework.Model; + +import java.util.List; + +public class ErrorCodeBean { + + private String code; + private String name; + private String description; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/Service/AnalogConvert.java b/app/src/main/java/com/bonait/bnframework/Service/AnalogConvert.java index f36a7639..d0959dac 100644 --- a/app/src/main/java/com/bonait/bnframework/Service/AnalogConvert.java +++ b/app/src/main/java/com/bonait/bnframework/Service/AnalogConvert.java @@ -52,6 +52,9 @@ public class AnalogConvert { public static short Scale(short InputValue, short InputMax, short InputMin, short OutMax, short OutMin){ try{ + if(((InputMax - InputMin) + OutMin)==0){ + return 0; + } float tempValue = (OutMax - OutMin) * (InputValue - InputMin) / (InputMax - InputMin) + OutMin; short num =(short)tempValue; // if (num > OutMax) return OutMax; diff --git a/app/src/main/java/com/bonait/bnframework/Service/ControlAdress.java b/app/src/main/java/com/bonait/bnframework/Service/ControlAdress.java index 22eea5cc..8ec265c9 100644 --- a/app/src/main/java/com/bonait/bnframework/Service/ControlAdress.java +++ b/app/src/main/java/com/bonait/bnframework/Service/ControlAdress.java @@ -1,13 +1,47 @@ package com.bonait.bnframework.Service; public enum ControlAdress { - 心跳, - 加热档位, - 启动加热, - 停止加热, - 加热模组状态, - 急停按钮状态, - 升降电机上升, - + 心跳,//D0 + 掉线标志,//M100 + 加热档位,//D51 0-100 + 启动加热,//M50 (启动时需判断是否正在加热状态) + 停止加热,//M51 + 错误码,//M52 + 加水,//M4 + 加水时间,//D1000 + 液体1,//M5 + 液体2,//M6 + 液体3,//M7 + 液体4,//M8 + 液体5,//M9 + 液体6,//M10 + 液体时间1,//D1001 + 液体时间2,//D1002 + 液体时间3,//D1003 + 液体时间4,//D1004 + 液体时间5,//D1005 + 液体时间6,//D1006 + 液体7,//M11 + 液体8,//M12 + 液体9,//M13 + 液体时间7,//D1007 + 液体时间8,//D1008 + 液体时间9,//D1009 + 勾芡,//M14 + 勾芡时间,//D1010 + 主料1,//M17 + 主料2,//M18 + 主料3,//M19 + 主料4,//M20 + 主料5,//M21 + 上升,//M22 + 下降,//M23 + 搅拌正转,//M24 + 搅拌反转,//M24 + 搅拌停止,//M26 + 搅拌档位,//M26 + 搅拌检测,//X2 + 升降检测上限位,//X1 + 升降检测下限位,//X4 } diff --git a/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java b/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java index 5df0b503..587f8192 100644 --- a/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java +++ b/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java @@ -1,63 +1,87 @@ package com.bonait.bnframework.Service; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Communication.Modbus.ModbusMaster; import com.bonait.bnframework.HBL.DataUtil.DataType; import com.bonait.bnframework.HBL.DataUtil.NotifyPropVar; import com.bonait.bnframework.HBL.Executor; import com.bonait.bnframework.HBL.Interface.IRunT; import com.bonait.bnframework.HBL.Logs.MessageLog; -import com.bonait.bnframework.HBL.Result.OperateResult; import com.bonait.bnframework.HBL.Result.OperateResultT; import com.bonait.bnframework.HBL.Thread.ThreadManager; +import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_CALIBRATION_PAR; -import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; +import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; public class ModbusHelper extends ModbusMaster { private static volatile ModbusHelper instance = null; public synchronized static ModbusHelper get(){ - if(instance==null)instance=new ModbusHelper(); + if(instance==null){ + synchronized (ModbusHelper.class){ + if(instance==null){ + instance=new ModbusHelper(); + } + } + } return instance; } private ModbusHelper(){} -// static ConcurrentHashMap controlAddress=new ConcurrentHashMap(){{ -// put(ControlAdress.锅盖上升,new PLCModel("M20", DataType.BOOLEAN, OperationModel.W) ); -// put(ControlAdress.锅盖下降,new PLCModel("M21",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.锅盖开启,new PLCModel("M22",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.锅盖关闭,new PLCModel("M23",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.锅体正转,new PLCModel("M24",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.锅体反转,new PLCModel("M25",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.泄压阀启停,new PLCModel("M26",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.烹饪完成,new PLCModel("M32",DataType.BOOLEAN,OperationModel.R)); -// put(ControlAdress.一键上升,new PLCModel("M0",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.一键下降,new PLCModel("M1",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.一键回位,new PLCModel("M5",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.停止,new PLCModel("M6",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.配方启动,new PLCModel("M11",DataType.BOOLEAN,OperationModel.W)); -// put(ControlAdress.心跳,new PLCModel("D204",DataType.SHORT,OperationModel.W)); -// put(ControlAdress.当前温度,new PLCModel("D100",DataType.SHORT,OperationModel.R)); -// put(ControlAdress.当前压力,new PLCModel("D101",DataType.SHORT,OperationModel.R)); -// put(ControlAdress.允许开盖压力,new PLCModel("D200",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.排冷气温度,new PLCModel("D203",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.温度下限,new PLCModel("D210",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.温度上限,new PLCModel("D211",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.压力下限,new PLCModel("D213",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.压力上限,new PLCModel("D214",DataType.SHORT,OperationModel.RW)); -// put(ControlAdress.加热档位,new PLCModel("D300",DataType.SHORT,OperationModel.W)); -// put(ControlAdress.设定压力,new PLCModel("D301",DataType.SHORT,OperationModel.W)); -// put(ControlAdress.计时温度,new PLCModel("D303",DataType.SHORT,OperationModel.W)); -// put(ControlAdress.烹饪时间,new PLCModel("D304",DataType.SHORT,OperationModel.W)); -// put(ControlAdress.当前时间,new PLCModel("D10",DataType.SHORT,OperationModel.R)); -// }}; - - private ConcurrentHashMap calibrationParMap=new ConcurrentHashMap<>(); - public void Add(BPA_CALIBRATION_PAR item){ - if(item==null)return ; - calibrationParMap.put(item.Name,item); - } - private OperateResultT getCalibrationPar(String name){ + public ConcurrentHashMap controlAddress=new ConcurrentHashMap(){{ + put(ControlAdress.心跳,new PLCModel("D0", DataType.SHORT, OperationModel.W) ); +// put(ControlAdress.掉线标志,new PLCModel("M100",DataType.BOOLEAN,OperationModel.R)); + put(ControlAdress.加热档位,new PLCModel("D51",DataType.SHORT,OperationModel.W)); + put(ControlAdress.启动加热,new PLCModel("M50",DataType.BOOLEAN,OperationModel.RW)); + put(ControlAdress.停止加热,new PLCModel("M51",DataType.BOOLEAN,OperationModel.RW)); + put(ControlAdress.错误码,new PLCModel("M52",DataType.BOOLEAN,OperationModel.R)); + put(ControlAdress.加水时间,new PLCModel("D1000",DataType.SHORT,OperationModel.W)); + put(ControlAdress.加水,new PLCModel("M4",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间1,new PLCModel("D1001",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体1,new PLCModel("M5",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间2,new PLCModel("D1002",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体2,new PLCModel("M6",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间3,new PLCModel("D1003",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体3,new PLCModel("M7",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间4,new PLCModel("D1004",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体4,new PLCModel("M8",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间5,new PLCModel("D1005",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体5,new PLCModel("M9",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间6,new PLCModel("D1006",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体6,new PLCModel("M10",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间7,new PLCModel("D1007",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体7,new PLCModel("M11",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间8,new PLCModel("D1008",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体8,new PLCModel("M12",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.液体时间9,new PLCModel("D1009",DataType.SHORT,OperationModel.W)); + put(ControlAdress.液体9,new PLCModel("M13",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.勾芡时间,new PLCModel("D1010",DataType.SHORT,OperationModel.W)); + put(ControlAdress.勾芡,new PLCModel("M14",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.主料1,new PLCModel("M17",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.主料2,new PLCModel("M18",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.主料3,new PLCModel("M19",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.主料4,new PLCModel("M20",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.主料5,new PLCModel("M21",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.上升,new PLCModel("M22",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.下降,new PLCModel("M23",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.搅拌正转,new PLCModel("M24",DataType.BOOLEAN,OperationModel.W)); +// put(ControlAdress.搅拌反转,new PLCModel("M24",DataType.BOOLEAN,OperationModel.W)); + put(ControlAdress.搅拌停止,new PLCModel("M26",DataType.BOOLEAN,OperationModel.W)); +// put(ControlAdress.搅拌档位,new PLCModel("M26",DataType.BOOLEAN,OperationModel.W)); +// put(ControlAdress.升降检测上限位,new PLCModel("X2",DataType.BOOLEAN,OperationModel.W)); +// put(ControlAdress.升降检测下限位,new PLCModel("X4",DataType.BOOLEAN,OperationModel.W)); + }}; + + private ConcurrentHashMap calibrationParMap=new ConcurrentHashMap<>(); + public void Add(ArrayList list){ + if(list.isEmpty())return ; + list.forEach(item ->{ + calibrationParMap.put(item.name,item); + }); + } + private OperateResultT getCalibrationPar(String name){ if(calibrationParMap.containsKey(name)){ return OperateResultT.CreateSuccess(calibrationParMap.get(name)); }else{ @@ -79,66 +103,190 @@ public class ModbusHelper extends ModbusMaster { * @param GearPosition 加热档位 * @param command 启动或停止 */ - public void Heating(short GearPosition,boolean command){ + public void Heating(int GearPosition,boolean command){ //D51:档位设置,M50:启动加热,M51:停止加热 WriteBool(command?"M51":"M50",false); - WriteShort("D51",command?GearPosition:0); + WriteShort("D51", (short) (command?GearPosition:0)); WriteBool(command?"M50":"M51",true); + MessageLog.ShowInfo("Heating GearPosition="+GearPosition + ";command="+command); } /** * 加水控制 * @param value */ - public void AddWater(short value){ - getCalibrationPar("加水阀1").OnSource(item->{ - WriteShort("D1000",value); - WriteBool("M4",true); + public void addWater(int value){ + getCalibrationPar(ControlAdress.加水.toString()).OnSource(item->{ + BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content; + WriteShort(getPLC(ControlAdress.加水时间).PlcAddress, + AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin, + (short) bean.outputTimeMax, (short) bean.outputTimeMin)); + WriteBool(getPLC(ControlAdress.加水).PlcAddress,true); }) ; } - public void AddLiquid(){ + /** + * 液体料控制 + * @param value 量 + * @param position 几号仓 + */ + public void addSeason(int value,int position){ + ControlAdress controlAdress = ControlAdress.液体1; + ControlAdress controlTimeAdress = ControlAdress.液体时间1; + switch (position){ + case 1: + controlAdress = ControlAdress.液体1; + controlTimeAdress = ControlAdress.液体时间1; + break; + case 2: + controlAdress = ControlAdress.液体2; + controlTimeAdress = ControlAdress.液体时间2; + break; + case 3: + controlAdress = ControlAdress.液体3; + controlTimeAdress = ControlAdress.液体时间3; + break; + case 4: + controlAdress = ControlAdress.液体4; + controlTimeAdress = ControlAdress.液体时间4; + break; + case 5: + controlAdress = ControlAdress.液体5; + controlTimeAdress = ControlAdress.液体时间5; + break; + case 6: + controlAdress = ControlAdress.液体6; + controlTimeAdress = ControlAdress.液体时间6; + break; + case 7: + controlAdress = ControlAdress.液体7; + controlTimeAdress = ControlAdress.液体时间7; + break; + case 8: + controlAdress = ControlAdress.液体8; + controlTimeAdress = ControlAdress.液体时间8; + break; + case 9: + controlAdress = ControlAdress.液体9; + controlTimeAdress = ControlAdress.液体时间9; + break; + } + ControlAdress finalControlTimeAdress = controlTimeAdress; + ControlAdress finalControlAdress = controlAdress; + getCalibrationPar(controlAdress.toString()).OnSource(item->{ + BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content; + WriteShort(getPLC(finalControlTimeAdress).PlcAddress, + AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin, + (short) bean.outputTimeMax, (short) bean.outputTimeMin)); + WriteBool(getPLC(finalControlAdress).PlcAddress,true); + }) ; + LogUtils.d("液体料控制 addSeason value="+value+";position="+position); } + /** + * 勾芡控制 + * @param value + */ + public void addThickenWater(int value){ + getCalibrationPar(ControlAdress.勾芡.toString()).OnSource(item->{ + BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content; + WriteShort(getPLC(ControlAdress.勾芡时间).PlcAddress, + AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin, + (short) bean.outputTimeMax, (short) bean.outputTimeMin)); + WriteBool(getPLC(ControlAdress.勾芡).PlcAddress,true); + }) ; + LogUtils.d("勾芡控制 addThickenWater value="+value); + } + /** + * 主料控制 + * @param position + */ + public void addMainFood(int position){ + ControlAdress controlAdress = ControlAdress.主料1; + switch (position){ + case 1: + controlAdress = ControlAdress.主料1; + break; + case 2: + controlAdress = ControlAdress.主料2; + break; + case 3: + controlAdress = ControlAdress.主料3; + break; + case 4: + controlAdress = ControlAdress.主料4; + break; + case 5: + controlAdress = ControlAdress.主料5; + break; + } + WriteBool(getPLC(controlAdress).PlcAddress,true); + LogUtils.d("添加主料 addMainFood position="+position); + } + /** + * 升降电机控制 + * @param status 1 上升 2下降 + */ + public void setUpdDownMotor(int status){ + if(status == 2){ + WriteBool(getPLC(ControlAdress.上升).PlcAddress,false); + WriteBool(getPLC(ControlAdress.下降).PlcAddress,true); + }else { + WriteBool(getPLC(ControlAdress.下降).PlcAddress,false); + WriteBool(getPLC(ControlAdress.上升).PlcAddress,true); + } + LogUtils.d("升降电机控制 setUpdDownMotor status="+status); + } + /** + * 搅拌电机控制 + * @param status 1 正转启动 2停止 + */ + public void setStirMotor(int status){ + if(status == 2){ + WriteBool(getPLC(ControlAdress.搅拌正转).PlcAddress,false); + WriteBool(getPLC(ControlAdress.搅拌停止).PlcAddress,true); + }else { + WriteBool(getPLC(ControlAdress.搅拌正转).PlcAddress,true); + WriteBool(getPLC(ControlAdress.搅拌停止).PlcAddress,false); + } + LogUtils.d("升降电机控制 setStirMotor status="+status); + } - -// private PLCModel getPLC(ControlAdress func){ -// if(controlAddress.containsKey(func)){ -// return controlAddress.get(func); -// }else{ -// MessageLog.ShowInfo("不存在控制地址:"+func.toString()); -// return new PLCModel(); -// } -// } + public PLCModel getPLC(ControlAdress func){ + if(controlAddress.containsKey(func)){ + return controlAddress.get(func); + }else{ + MessageLog.ShowInfo("不存在控制地址:"+func.toString()); + return new PLCModel(); + } + } private void GetPlcStatus(){ ThreadManager.get().StartLong("PLC变量状态",true,()->{ - -// WriteShort(getPLC(ControlAdress.心跳).PlcAddress, (short) 0); -// -// controlAddress.forEach((key,value)->{ -// if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ -// if(value.Value.getValue() instanceof Short){ -// OperateResultT res = ReadShort(value.PlcAddress); -// if(res.isSuccess){ -// value.Value .setValue(res.Content); -// } -// }else if (value.Value.getValue() instanceof Boolean){ -// OperateResultT res = ReadBool(value.PlcAddress); -// if(res.isSuccess){ -// value.Value .setValue(res.Content); -// } -// } -// -// } -// }); + WriteShort(getPLC(ControlAdress.心跳).PlcAddress, (short) 0); + + controlAddress.forEach((key,value)->{ + if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ + if(value.Value.getValue() instanceof Short){ + OperateResultT res = ReadShort(value.PlcAddress); + if(res.isSuccess){ + value.Value.setValue(res.Content); + } + }else if (value.Value.getValue() instanceof Boolean){ + OperateResultT res = ReadBool(value.PlcAddress); + if(res.isSuccess){ + value.Value.setValue(res.Content); + } + } + } + }); Thread.sleep(1); }); } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java index 23e66ed3..de8b3338 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java @@ -10,10 +10,12 @@ import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Logs.MessageLog; import com.bonait.bnframework.HBL.Thread.IThread; import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.FragmentViewModel.HomeDeviceFragment; import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseActivity; @@ -55,7 +57,7 @@ public class BottomNavigationNewActivity extends BaseActivity { QMUIViewPager viewPager; @BindView(R.id.cooking) - CookingActivity cooking; + CookingNewActivity cooking; @BindView(R.id.penrenzhong) LinearLayout penrenzhong; @@ -114,7 +116,8 @@ public class BottomNavigationNewActivity extends BaseActivity { FragmentAdapter fragmentAdapter = new FragmentAdapter(getSupportFragmentManager()); fragmentAdapter.addFragment(new HomeFragmentPR()); fragmentAdapter.addFragment(new Home4Fragment()); - fragmentAdapter.addFragment(new HomeFragmentSBKZ()); +// fragmentAdapter.addFragment(new HomeFragmentSBKZ()); + fragmentAdapter.addFragment(new HomeDeviceFragment()); viewPager.setAdapter(fragmentAdapter); MessageManager.getInstance().registerMessageReceiver(this, MessageName.SelectZY, new MessageLooper.OnMessageListener() { @@ -297,6 +300,7 @@ public class BottomNavigationNewActivity extends BaseActivity { try { //获取工艺 ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id); + LogUtils.d("制作线程 MakeThread 启动 ==》 菜品配方 goodsrecipes="+goodsrecipes.toString()); goodsrecipesL = goodsrecipes; gongxuIndex = 1; int m = 0; @@ -311,7 +315,7 @@ public class BottomNavigationNewActivity extends BaseActivity { runOnUiThread(new Runnable() { @Override public void run() { - cooking.SetMiaoShu("正在执行:" + item.processms); + cooking.SetMiaoShu("正在执行:名称" + item.processms+";描述="+item.processms+";变量="+item.processvalue); } }); boolean status = ExecuteTheRecipe.Execute(item, goodsrecipes, m); @@ -320,10 +324,10 @@ public class BottomNavigationNewActivity extends BaseActivity { } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } finally { - ExecuteTheRecipe.WritePLC("搅拌", false, null); - ExecuteTheRecipe.WritePLC("加热", false, null); +// ExecuteTheRecipe.WritePLC("搅拌", false, null); +// ExecuteTheRecipe.WritePLC("加热", false, null); ConfigName.getInstance().IsOpenHuoLi = false; - ExecuteTheRecipe.BottomClick("平移-去1号位"); +// ExecuteTheRecipe.BottomClick("平移-去1号位"); gongxuIndex = 10000; MakeCipe = null; goodsrecipesL = null; @@ -331,7 +335,7 @@ public class BottomNavigationNewActivity extends BaseActivity { long endTime = System.currentTimeMillis(); //结束时间 int time=(int) ((endTime-startTime)/1000); - Log.e("运行时长",String.format("方法使用时间 %d s",time)); + LogUtils.d("运行时长 "+String.format("方法使用时间 %d s",time)); if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(goods.id,time);} @@ -344,7 +348,7 @@ public class BottomNavigationNewActivity extends BaseActivity { { ToastUtils.info("客官,当前菜品已强制结束!!!"); //初始化 - ExecuteTheRecipe.BottomClick("初始化"); +// ExecuteTheRecipe.BottomClick("初始化"); } } }); @@ -358,106 +362,106 @@ public class BottomNavigationNewActivity extends BaseActivity { } }).start(); - new Thread(new Runnable() { - @Override - public void run() { - while (true) { - try { - - if (ExecuteTheRecipe.IsStart && goods != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { - try { - if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { - //获取工艺 - int k = 1; - ArrayList goodsrecipes = goodsrecipesL; - BPA_GOODSRECIPE recipe = null; - for (BPA_GOODSRECIPE item : goodsrecipes) { - k++; - if (k > gongxuIndex) { - if (item.processname.contains("主料") && !MakeCipe.processname.equals("主料") && recipe == null) { - recipe = item; - } - } - } - - if (recipe != null) { - HashMap formulation = new HashMap<>(); - String text = recipe.processvalue; - //region 获取仓号和值 - List data = new ArrayList<>(); - if (text.contains("|")) { - String[] res = text.split("[|]"); - for (int i = 0; i < res.length; i++) { - data.add(res[i]); - } - } else { - data.add(text); - } - for (String item : data) { - if (!item.isEmpty() && item.contains(",")) { - String[] wl = item.split("[,]"); - if (wl != null && wl.length == 2) { - String name = wl[0]; - String val = wl[1]; - formulation.put(name, val); - } - } - } - //endregion - boolean ishand = true; - - //region 判断是否手动 - if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { - ishand = true; - } else { - for (HashMap.Entry entry : formulation.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - if (key.contains("投料动作")) { - if (value.contains("手动投料")) { - ishand = true; - } else { - ishand = false; - } - } - } - } - //endregion - - if (!ishand) { - String writeValue = "1号位"; - for (HashMap.Entry entry : formulation.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - if (key.contains("主料位置")) { - writeValue = value; - } - } - ExecuteTheRecipe.BottomClick("平移-去" + writeValue); - Log.d("移动去", writeValue); - } else { - ExecuteTheRecipe.BottomClick("平移-去1号位"); - Log.d("移动去", "1号位"); - } - } else { - if (!MakeCipe.processname.equals("主料")) { - ExecuteTheRecipe.BottomClick("平移-去1号位"); - Log.d("移动去", "1号位"); - } - } - } - - } catch (Exception ex) { - ToastUtils.error("异常信息:" + ex.getMessage()); - } - } - Thread.sleep(3000); - } catch (InterruptedException e) { - ToastUtils.info("异常信息:" + e.getMessage()); - } - } - } - }).start(); +// new Thread(new Runnable() { +// @Override +// public void run() { +// while (true) { +// try { +// +// if (ExecuteTheRecipe.IsStart && goods != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { +// try { +// if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { +// //获取工艺 +// int k = 1; +// ArrayList goodsrecipes = goodsrecipesL; +// BPA_GOODSRECIPE recipe = null; +// for (BPA_GOODSRECIPE item : goodsrecipes) { +// k++; +// if (k > gongxuIndex) { +// if (item.processname.contains("主料") && !MakeCipe.processname.equals("主料") && recipe == null) { +// recipe = item; +// } +// } +// } +// +// if (recipe != null) { +// HashMap formulation = new HashMap<>(); +// String text = recipe.processvalue; +// //region 获取仓号和值 +// List data = new ArrayList<>(); +// if (text.contains("|")) { +// String[] res = text.split("[|]"); +// for (int i = 0; i < res.length; i++) { +// data.add(res[i]); +// } +// } else { +// data.add(text); +// } +// for (String item : data) { +// if (!item.isEmpty() && item.contains(",")) { +// String[] wl = item.split("[,]"); +// if (wl != null && wl.length == 2) { +// String name = wl[0]; +// String val = wl[1]; +// formulation.put(name, val); +// } +// } +// } +// //endregion +// boolean ishand = true; +// +// //region 判断是否手动 +// if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { +// ishand = true; +// } else { +// for (HashMap.Entry entry : formulation.entrySet()) { +// String key = entry.getKey(); +// String value = entry.getValue(); +// if (key.contains("投料动作")) { +// if (value.contains("手动投料")) { +// ishand = true; +// } else { +// ishand = false; +// } +// } +// } +// } +// //endregion +// +// if (!ishand) { +// String writeValue = "1号位"; +// for (HashMap.Entry entry : formulation.entrySet()) { +// String key = entry.getKey(); +// String value = entry.getValue(); +// if (key.contains("主料位置")) { +// writeValue = value; +// } +// } +// ExecuteTheRecipe.BottomClick("平移-去" + writeValue); +// Log.d("移动去", writeValue); +// } else { +// ExecuteTheRecipe.BottomClick("平移-去1号位"); +// Log.d("移动去", "1号位"); +// } +// } else { +// if (!MakeCipe.processname.equals("主料")) { +// ExecuteTheRecipe.BottomClick("平移-去1号位"); +// Log.d("移动去", "1号位"); +// } +// } +// } +// +// } catch (Exception ex) { +// ToastUtils.error("异常信息:" + ex.getMessage()); +// } +// } +// Thread.sleep(3000); +// } catch (InterruptedException e) { +// ToastUtils.info("异常信息:" + e.getMessage()); +// } +// } +// } +// }).start(); } /** @@ -470,7 +474,7 @@ public class BottomNavigationNewActivity extends BaseActivity { switch (v.getId()) { case R.id.start_goodmake://启动按钮 ExecuteTheRecipe.IsPause = false; - ExecuteTheRecipe.WritePLC("暂停开关",false,null); +// ExecuteTheRecipe.WritePLC("暂停开关",false,null); if (Status) { onRecordStart(); } @@ -480,7 +484,7 @@ public class BottomNavigationNewActivity extends BaseActivity { break; case R.id.zanting_goodmake://暂停按钮 ExecuteTheRecipe.IsPause = Status; - ExecuteTheRecipe.WritePLC("暂停开关",Status,null); +// ExecuteTheRecipe.WritePLC("暂停开关",Status,null); if (Status) { onRecordPause(); } else { diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/CookingNewActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/CookingNewActivity.java new file mode 100644 index 00000000..8ccae96f --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/CookingNewActivity.java @@ -0,0 +1,410 @@ +package com.bonait.bnframework.ViewModel.ActivityViewModel; + +import android.app.Activity; +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.HBL.Interface.IRunT; +import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.CustomView.imagebuttom; +import com.bonait.bnframework.ViewModel.CustomView.imagebuttom3; +import com.bonait.bnframework.ViewModel.CustomView.jingdutiao; +import com.bonait.bnframework.ViewModel.CustomView.newhuoli_control; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import java.util.concurrent.ConcurrentHashMap; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class CookingNewActivity extends LinearLayout { + + //region 变量 + @BindView(R.id.device_image) + ImageView device_image; + +// @BindView(R.id.touliao_k) +// LinearLayout touliao_k; +// +// @BindView(R.id.touliao_m) +// LinearLayout touliao_m; + + @BindView(R.id.goodname) + TextView goodname; +// +// @BindView(R.id.chaoguo_wendu) +// TextView chaoguo_wendu; + + @BindView(R.id.gongxumiaoshu) + TextView gongxumiaoshu;//工序描述 + + @BindView(R.id.start_goodmake) + imagebuttom start_goodmake;//开始 + + @BindView(R.id.zanting_goodmake) + public imagebuttom zanting_goodmake;//暂停 + @BindView(R.id.runtime) + TextView runtime;//计时器 倒计时 + + @BindView(R.id.t_jindu) + jingdutiao t_jindu;//计时器 + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + + +// @BindView(R.id.huoli) +// newhuoli_control huoli; +// +// @BindView(R.id.fanchaoshudu) +// imagebuttom3 fanchaoshudu; +// +// +// @BindView(R.id.guokoucaoxiang) +// imagebuttom3 guokoucaoxiang; +// +// @BindView(R.id.chushui) +// imagebuttom3 chushui; +// +// @BindView(R.id.touliao1) +// imagebuttom3 touliao1; +// +// @BindView(R.id.touliao2) +// imagebuttom3 touliao2; +// +// @BindView(R.id.touliao3) +// imagebuttom3 touliao3; +// +// @BindView(R.id.touliao4) +// imagebuttom3 touliao4; +// +// @BindView(R.id.yeliao1) +// imagebuttom3 yeliao1; +// @BindView(R.id.yeliao2) +// imagebuttom3 yeliao2; +// @BindView(R.id.yeliao3) +// imagebuttom3 yeliao3; + + private Context contextMian; + private View root; + + public Activity activity = null; + //endregion + + //region 界面实例 + public CookingNewActivity(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + contextMian = context; + root = LayoutInflater.from(context).inflate(R.layout.activity_cooking_new, this); + ButterKnife.bind(this, root); + initTopBar(); + + SxUIThread(); + } + //endregion + + //region 公共方法 + + /** + * 初始化数据 + */ + public void initData(BPA_GOODS goods, Activity ac, MyClickListener listener) { + //根据商品id查询 + activity = ac; + +// yeliao1.setTag(ConfigName.getInstance().SilosDisplayMaterial.get(1)+""); +// yeliao1.Init(); +// +// yeliao2.setTag(ConfigName.getInstance().SilosDisplayMaterial.get(2)+""); +// yeliao2.Init(); +// +// yeliao3.setTag(ConfigName.getInstance().SilosDisplayMaterial.get(3)+""); +// yeliao3.Init(); +// +// ConcurrentHashMap resultData= DataBus.getInstance().GetMainDisplayText(goods.id); +// touliao1.setTag(resultData.get(1)+"-按钮"); +// touliao1.Init(); +// +// touliao2.setTag(resultData.get(2)+"-按钮"); +// touliao2.Init(); +// +// touliao3.setTag(resultData.get(3)+"-按钮"); +// touliao3.Init(); +// +// touliao4.setTag(resultData.get(4)+"-按钮"); +// touliao4.Init(); + + goodname.setText(goods.name + ""); + start_goodmake.mListener = listener; + zanting_goodmake.mListener = listener; + SetReset(); + SetRest1(); + SetProcess(goods.maketime, 0); + SetMiaoShu("等待开始..."); + LogUtils.d("制作时长goods.maketime="+goods.maketime); + runtime.setText(formatTime(goods.maketime)); + +// if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { +// touliao_k.setVisibility(View.GONE); +// touliao_m.setVisibility(View.GONE); +// device_image.setImageResource(R.mipmap.device00); +// }else +// { +// touliao_k.setVisibility(View.VISIBLE); +// touliao_m.setVisibility(View.VISIBLE); +// device_image.setImageResource(R.mipmap.device1); +// } + } + + /** + * 设置描述 + * + * @param text + */ + public void SetMiaoShu(String text) { + gongxumiaoshu.setText(text + ""); + } + + /** + * 设置进度条 + * + * @param + */ + public void SetProcess(int alltime, int usertime) { + try { + t_jindu.SetValue((usertime * 100) / alltime); + runtime.setText(formatTime((alltime - usertime))); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + + /** + * 复位 + */ + public void SetReset() { + SetMiaoShu("等待开始..."); + zanting_goodmake.SetStatus(false); + zanting_goodmake.setVisibility(View.GONE); + } + + /** + * 复位 + */ + public void SetZanTing(boolean data) { + zanting_goodmake.setVisibility(data ? View.VISIBLE : View.GONE); + } + + public void SetRest1() { + start_goodmake.SetStatus(false); + if(flicker_buttom!=null) + { + flicker_buttom.setVisibility(View.VISIBLE); + flicker_buttom.SetStatusKK(false); + flicker_buttom=null; + } +// huoli.SetLevel(0); + } + //endregion + + //region 私有方法 + + /** + * 将毫秒转化为 分钟:秒 的格式 100* 1000 + * + * @param millisecond 毫秒 + * @return + */ + public String formatTime(long millisecond) { + int minute;//分钟 + int second;//秒数 + minute = (int) ((millisecond / 1) / 60); + second = (int) ((millisecond / 1) % 60); + if (minute < 10) { + if (second < 10) { + return "0" + minute + " : " + "0" + second; + } else { + return "0" + minute + " : " + second; + } + } else { + if (second < 10) { + return minute + " : " + "0" + second; + } else { + return minute + " : " + second; + } + } + } + + /** + * 初始化顶部弹框 + */ + private void initTopBar() { + mTopBar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.topbj1)); + mTopBar.setTitle("菜谱烹饪"); + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if (ExecuteTheRecipe.IsStart) { + ToastUtils.warning("请等待制作完成后退出..."); + return; + } + setVisibility(View.GONE); + } + }); + } + + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.kancaipu}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.kancaipu://看菜谱 + MessageManager.getInstance().sendMessage(MessageName.SelectZY, 0); + break; + } + } + + /** + * 闪烁buttom + */ + public imagebuttom3 flicker_buttom=null; + /** + * 刷新UI界面 + */ + public void SxUIThread() { + new Thread(new Runnable() { + @Override + public void run() { + + while (true) { + try { + if (activity != null && getVisibility() == View.VISIBLE) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度"); + if (val_wd != null) { +// chaoguo_wendu.setText(val_wd + "°C"); + } else { +// chaoguo_wendu.setText("??°C"); + } + + //闪烁 + if (flicker_buttom != null) { + flicker_buttom.setVisibility(flicker_buttom.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE); + } + } + }); + } + Thread.sleep(1000); + } catch (InterruptedException e) { + ToastUtils.info("异常信息:" + e.getMessage()); + } + } + } + }).start(); + + ExecuteTheRecipe.ExecuteCurrentOperation=new IRunT() { + @Override + public void Run(Object o) { + String data=(String)o; + if (activity != null && getVisibility() == View.VISIBLE) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + if(data.contains("|")) + { + String[] K= data.split("[|]"); + if (K.length>=2) + { + String name=K[0]; + String val=K[1]; + if(flicker_buttom!=null) + { + flicker_buttom.setVisibility(View.VISIBLE); + flicker_buttom.SetStatusKK(false); + } + flicker_buttom=null; +// switch (name) { +// case "搅拌": +// flicker_buttom=fanchaoshudu; +// flicker_buttom.SetStatusKK(true); +// break; +// case "位置": +// flicker_buttom=guokoucaoxiang; +// flicker_buttom.SetStatusKK(true); +// break; +// case "加热": +// huoli.SetLevel(Integer.parseInt(val)); +// break; +// case "主料": +// if(val.equals("1号位")) +// { +// flicker_buttom=touliao1; +// }else if(val.equals("2号位")) +// { +// flicker_buttom=touliao2; +// }else if(val.equals("3号位")) +// { +// flicker_buttom=touliao3; +// }else if(val.equals("4号位")) +// { +// flicker_buttom=touliao4; +// } +// flicker_buttom.SetStatusKK(true); +// break; +// case "加水": +// flicker_buttom=chushui; +// flicker_buttom.SetStatusKK(true); +// break; +// case "液体料": +// if(val.equals("1")) +// { +// flicker_buttom=yeliao1; +// flicker_buttom.SetStatusKK(true); +// }else if(val.equals("2")) +// { +// flicker_buttom=yeliao2; +// flicker_buttom.SetStatusKK(true); +// }else if(val.equals("3")) +// { +// flicker_buttom=yeliao3; +// flicker_buttom.SetStatusKK(true); +// } +// break; +// } + } + } + } + }); + } + } + }; + } + //endregion + + //region 外部调用 + //endregion + +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DishTestActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DishTestActivity.java index 196e3143..a9d01d58 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DishTestActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DishTestActivity.java @@ -102,7 +102,8 @@ public class DishTestActivity extends BaseActivity { @BindView(R.id.touliao4) imagebuttom3 touliao4; - + @BindView(R.id.touliao5) + imagebuttom3 touliao5; @BindView(R.id.yeliao1) imagebuttom3 yeliao1; @BindView(R.id.yeliao2) @@ -174,7 +175,10 @@ public class DishTestActivity extends BaseActivity { @BindView(R.id.liaohe4) TextView liaohe4; + @BindView(R.id.liaohe5) + TextView liaohe5; public String liaohetext4 = ""; + public String liaohetext5 = ""; @BindView(R.id.gongyibuzhoujilu) @@ -453,6 +457,9 @@ public class DishTestActivity extends BaseActivity { case 4: liaohetext4 = data1 + ""; break; + case 5: + liaohetext5 = data1 + ""; + break; } ShowIndex++; SetShowNameData(ShowIndex); @@ -532,11 +539,12 @@ public class DishTestActivity extends BaseActivity { liaohe2.setVisibility(liaohetext2.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe3.setVisibility(liaohetext3.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe4.setVisibility(liaohetext4.isEmpty() ? View.INVISIBLE : View.VISIBLE); - + liaohe5.setVisibility(liaohetext5.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe1.setText(liaohetext1 + ""); liaohe2.setText(liaohetext2 + ""); liaohe3.setText(liaohetext3 + ""); liaohe4.setText(liaohetext4 + ""); + liaohe5.setText(liaohetext5 + ""); liaohedata_num.setText("①号料盒"); liaohedata_text.setText(liaohetext1 + ""); @@ -549,10 +557,12 @@ public class DishTestActivity extends BaseActivity { liaohe2.setVisibility(liaohetext2.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe3.setVisibility(liaohetext3.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe4.setVisibility(liaohetext4.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe5.setVisibility(liaohetext5.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe1.setText(liaohetext1 + ""); liaohe2.setText(liaohetext2 + ""); liaohe3.setText(liaohetext3 + ""); liaohe4.setText(liaohetext4 + ""); + liaohe5.setText(liaohetext5 + ""); liaohedata_num.setText("②号料盒"); liaohedata_text.setText(liaohetext2 + ""); break; @@ -564,10 +574,12 @@ public class DishTestActivity extends BaseActivity { liaohe2.setVisibility(liaohetext2.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe3.setVisibility(liaohetext3.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe4.setVisibility(liaohetext4.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe5.setVisibility(liaohetext5.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe1.setText(liaohetext1 + ""); liaohe2.setText(liaohetext2 + ""); liaohe3.setText(liaohetext3 + ""); liaohe4.setText(liaohetext4 + ""); + liaohe5.setText(liaohetext5 + ""); liaohedata_num.setText("③号料盒"); liaohedata_text.setText(liaohetext3 + ""); break; @@ -579,14 +591,33 @@ public class DishTestActivity extends BaseActivity { liaohe2.setVisibility(liaohetext2.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe3.setVisibility(liaohetext3.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe4.setVisibility(liaohetext4.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe5.setVisibility(liaohetext5.isEmpty() ? View.INVISIBLE : View.VISIBLE); liaohe1.setText(liaohetext1 + ""); liaohe2.setText(liaohetext2 + ""); liaohe3.setText(liaohetext3 + ""); liaohe4.setText(liaohetext4 + ""); + liaohe5.setText(liaohetext5 + ""); liaohedata_num.setText("④号料盒"); liaohedata_text.setText(liaohetext4 + ""); break; case 5: + caipingmingchen.setVisibility(View.GONE); + liaohedata.setVisibility(View.VISIBLE); + + liaohe1.setVisibility(liaohetext1.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe2.setVisibility(liaohetext2.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe3.setVisibility(liaohetext3.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe4.setVisibility(liaohetext4.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe5.setVisibility(liaohetext5.isEmpty() ? View.INVISIBLE : View.VISIBLE); + liaohe1.setText(liaohetext1 + ""); + liaohe2.setText(liaohetext2 + ""); + liaohe3.setText(liaohetext3 + ""); + liaohe4.setText(liaohetext4 + ""); + liaohe5.setText(liaohetext5 + ""); + liaohedata_num.setText("⑤号料盒"); + liaohedata_text.setText(liaohetext5 + ""); + break; + case 6: caipingmingchen.setVisibility(View.GONE); liaohedata.setVisibility(View.GONE); @@ -602,6 +633,9 @@ public class DishTestActivity extends BaseActivity { touliao4.setTag(liaohetext4 + "-按钮"); touliao4.Init(); + + touliao5.setTag(liaohetext5 + "-按钮"); + touliao5.Init(); break; } } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyMemoryActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyMemoryActivity.java index bdcf6473..b10095c2 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyMemoryActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyMemoryActivity.java @@ -6,11 +6,15 @@ import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.os.SystemClock; +import android.util.DisplayMetrics; import android.view.View; +import android.view.WindowManager; +import android.widget.Button; import android.widget.Chronometer; import android.widget.ImageView; import android.widget.LinearLayout; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Interface.IRun; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; @@ -261,6 +265,15 @@ public class DiyMemoryActivity extends BaseActivity { ClickZL(time,time_c,4); break; case R.id.ydw://原点位 + final float scale = getResources().getDisplayMetrics().density; + int width = ((Button)findViewById(R.id.ydw)).getWidth(); + int width2 = ((LinearLayout)findViewById(R.id.start_bj)).getWidth(); + int height = ((Button)findViewById(R.id.ydw)).getWidth(); + WindowManager wm = (WindowManager) (getSystemService(Context.WINDOW_SERVICE)); + DisplayMetrics dm = new DisplayMetrics(); + wm.getDefaultDisplay().getMetrics(dm); + int mScreenWidth = dm.widthPixels; + LogUtils.d(" 屏幕分辨率 width="+width+";scale="+scale+";width2="+width2+";height="+height+";mScreenWidth="+mScreenWidth); ClickWZ(time,time_c,"原点位"); break; case R.id.dcw://到菜位 diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyUpdate1Activity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyUpdate1Activity.java index 9bb555b0..ce5b8523 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyUpdate1Activity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/DiyUpdate1Activity.java @@ -16,8 +16,12 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.Spinner; +import android.widget.TextView; +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.HBL.Logs.MessageLog; import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.CustomView.XComDialog; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; @@ -165,11 +169,13 @@ public class DiyUpdate1Activity extends BaseActivity { MessageManager.getInstance().registerMessageReceiver(this, MessageName.DIY, new MessageLooper.OnMessageListener() { @Override public void onMessage(Object msg) { + MessageLog.ShowInfo("onMessage 图标选择 msg="+msg); if (msg != null) { bpa_goodsrecipes.clear(); for (BPA_GOODSRECIPE item : DataBus.getInstance().bpa_goodsrecipes) { bpa_goodsrecipes.add(item); } + LogUtils.e("图标选择 bpa_goodsrecipes="+bpa_goodsrecipes.toString()); zzsc.setText(DataBus.getInstance().TimeOut + ""); gxbz_adapter.notifyDataSetChanged(); } @@ -228,6 +234,7 @@ public class DiyUpdate1Activity extends BaseActivity { gongxu.SetValues(res); } } + LogUtils.e("SetSelectGX formulation="+formulation.toString()); } catch (Exception ex) { } } @@ -249,6 +256,7 @@ public class DiyUpdate1Activity extends BaseActivity { for (BPA_GOODSRECIPE item : goodsrecipes) { bpa_goodsrecipes.add(item); } + LogUtils.e("SetGood bpa_goodsrecipes="+bpa_goodsrecipes.toString()); edittext.setText(good.name); check.setChecked(good.issc == 1); zzsc.setText(good.maketime + ""); @@ -280,6 +288,7 @@ public class DiyUpdate1Activity extends BaseActivity { gx.data = item.data; gx.IsWL = false; fragment_gx gongxu = new fragment_gx(this, null, gx); + LogUtils.d("SelectItemFrom gx="+gx.toString()); gxchid.addView(gongxu); } } else //物料 @@ -291,6 +300,7 @@ public class DiyUpdate1Activity extends BaseActivity { gx.name = item2.name; gx.IsWL = true; fragment_gx gongxu = new fragment_gx(this, null, gx); + LogUtils.d("SelectItemFrom gx="+gx.toString()); gxchid.addView(gongxu); } } @@ -345,6 +355,7 @@ public class DiyUpdate1Activity extends BaseActivity { pf.processname = name; pf.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")"; pf.processvalue = data.substring(0, data.length() - 1); + LogUtils.d("修改工序 pf="+pf.toString()); return pf; } else { ToastUtils.info("数据验证失败,原因:" + description); @@ -466,37 +477,85 @@ public class DiyUpdate1Activity extends BaseActivity { //按钮点击 String title = "生成菜谱操作提示!"; String message = "请问客官确定要生成[" + name1 + "]菜谱吗?"; - AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { +// AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { +// @Override +// public void onClick(QMUIDialog dialog, int index) { +// int sc = 60 * 3; +// if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { +// sc = Integer.parseInt(zzsc.getText().toString()); +// } +// +// ArrayList goods = QueryDB.GetGoodsALL(); +// BPA_GOODS good1 = new BPA_GOODS(); +// good1.name = name1; +// good1.status = 1; +// good1.sort = goods.size() + 1; +// good1.maketime = sc; +// good1.issc = check.isChecked() ? 1 : 0; +// good1.url = good.url; +// QueryDB.AddGoods(good1); +// for (int k = 0; k < bpa_goodsrecipes.size(); k++) { +// BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); +// item.id = java.util.UUID.randomUUID().toString(); +// item.goodsID = good1.id; +// item.sort = k + 1; +// QueryDB.AddGoodsSrecipe(item); +// } +// ToastUtils.info("菜谱复刻成功!"); +// dialog.dismiss(); +// MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); +// finish(); +// } +// }); + AlertDialogUtils.showCancelAndConfirmDialog(this, new XComDialog.OnDialogListener(){ + @Override - public void onClick(QMUIDialog dialog, int index) { - int sc = 60 * 3; - if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { - sc = Integer.parseInt(zzsc.getText().toString()); - } - - ArrayList goods = QueryDB.GetGoodsALL(); - BPA_GOODS good1 = new BPA_GOODS(); - good1.name = name1; - good1.status = 1; - good1.sort = goods.size() + 1; - good1.maketime = sc; - good1.issc = check.isChecked() ? 1 : 0; - good1.url = good.url; - QueryDB.AddGoods(good1); - for (int k = 0; k < bpa_goodsrecipes.size(); k++) { - BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); - item.id = java.util.UUID.randomUUID().toString(); - item.goodsID = good1.id; - item.sort = k + 1; - QueryDB.AddGoodsSrecipe(item); - } - ToastUtils.info("菜谱复刻成功!"); - dialog.dismiss(); - MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); - finish(); + public void onDialogClick(View layoutView, XComDialog xCom) { + TextView tvTitle = layoutView.findViewById(R.id.tv_title); + TextView tvContent = layoutView.findViewById(R.id.tv_content); + TextView tvCancel = layoutView.findViewById(R.id.tv_cancel); + TextView tvConfirm = layoutView.findViewById(R.id.tv_confirm); + + tvTitle.setText(getString(R.string.tip_create_menu_title)); + tvContent.setText(getString(R.string.tip_create_menu_content,name1)); + tvCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + xCom.dismissX(); + } + }); + tvConfirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int sc = 60 * 3; + if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { + sc = Integer.parseInt(zzsc.getText().toString()); + } + + ArrayList goods = QueryDB.GetGoodsALL(); + BPA_GOODS good1 = new BPA_GOODS(); + good1.name = name1; + good1.status = 1; + good1.sort = goods.size() + 1; + good1.maketime = sc; + good1.issc = check.isChecked() ? 1 : 0; + good1.url = good.url; + QueryDB.AddGoods(good1); + for (int k = 0; k < bpa_goodsrecipes.size(); k++) { + BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); + item.id = java.util.UUID.randomUUID().toString(); + item.goodsID = good1.id; + item.sort = k + 1; + QueryDB.AddGoodsSrecipe(item); + } + ToastUtils.info("菜谱复刻成功!"); + xCom.dismissX(); + MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); + finish(); + } + }); } }); - } break; case R.id.shengchengcaipu://修改菜谱 @@ -513,34 +572,79 @@ public class DiyUpdate1Activity extends BaseActivity { //按钮点击 String title = "保存菜谱操作提示!"; String message = "请问客官确定要保存[" + name + "]菜谱吗?"; - AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { +// AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { +// @Override +// public void onClick(QMUIDialog dialog, int index) { +// int sc = 60 * 3; +// if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { +// sc = Integer.parseInt(zzsc.getText().toString()); +// } +// good.maketime = sc; +// good.issc = check.isChecked() ? 1 : 0; +// good.name = name; +// QueryDB.UpdateGoods(good); +// ArrayList pe = QueryDB.GetGoodsSrecipeID(good.id); +// for (BPA_GOODSRECIPE item : pe) { +// QueryDB.DeleteGoodsSrecipe(item); +// } +// for (int k = 0; k < bpa_goodsrecipes.size(); k++) { +// BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); +// item.goodsID = good.id; +// item.sort = k + 1; +// QueryDB.AddGoodsSrecipe(item); +// } +// ToastUtils.info("菜谱修改成功!"); +// dialog.dismiss(); +// MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); +// finish(); +// } +// }); + AlertDialogUtils.showCancelAndConfirmDialog(this, new XComDialog.OnDialogListener(){ + @Override - public void onClick(QMUIDialog dialog, int index) { - int sc = 60 * 3; - if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { - sc = Integer.parseInt(zzsc.getText().toString()); - } - good.maketime = sc; - good.issc = check.isChecked() ? 1 : 0; - good.name = name; - QueryDB.UpdateGoods(good); - ArrayList pe = QueryDB.GetGoodsSrecipeID(good.id); - for (BPA_GOODSRECIPE item : pe) { - QueryDB.DeleteGoodsSrecipe(item); - } - for (int k = 0; k < bpa_goodsrecipes.size(); k++) { - BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); - item.goodsID = good.id; - item.sort = k + 1; - QueryDB.AddGoodsSrecipe(item); - } - ToastUtils.info("菜谱修改成功!"); - dialog.dismiss(); - MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); - finish(); + public void onDialogClick(View layoutView, XComDialog xCom) { + TextView tvTitle = layoutView.findViewById(R.id.tv_title); + TextView tvContent = layoutView.findViewById(R.id.tv_content); + TextView tvCancel = layoutView.findViewById(R.id.tv_cancel); + TextView tvConfirm = layoutView.findViewById(R.id.tv_confirm); + + tvTitle.setText(getString(R.string.tip_save_menu_title)); + tvContent.setText(getString(R.string.tip_save_menu_content,name)); + tvCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + xCom.dismissX(); + } + }); + tvConfirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int sc = 60 * 3; + if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) { + sc = Integer.parseInt(zzsc.getText().toString()); + } + good.maketime = sc; + good.issc = check.isChecked() ? 1 : 0; + good.name = name; + QueryDB.UpdateGoods(good); + ArrayList pe = QueryDB.GetGoodsSrecipeID(good.id); + for (BPA_GOODSRECIPE item : pe) { + QueryDB.DeleteGoodsSrecipe(item); + } + for (int k = 0; k < bpa_goodsrecipes.size(); k++) { + BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k); + item.goodsID = good.id; + item.sort = k + 1; + QueryDB.AddGoodsSrecipe(item); + } + ToastUtils.info("菜谱修改成功!"); + xCom.dismissX(); + MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); + finish(); + } + }); } }); - } break; } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/WelcomeActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/WelcomeActivity.java index b0f40f5f..a65e4e5a 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/WelcomeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/WelcomeActivity.java @@ -9,6 +9,7 @@ import androidx.annotation.NonNull; import android.view.KeyEvent; +import com.bonait.bnframework.HBL.DataUtil.ErrorCodeManager; import com.bonait.bnframework.R; import com.bonait.bnframework.business.MainInit; import com.bonait.bnframework.common.base.BaseActivity; @@ -189,6 +190,7 @@ public class WelcomeActivity extends BaseActivity { private void skipToLoginActivity() { //初始化 MainInit.Init(ConfigName.getInstance().app); + ErrorCodeManager.getInstance().initData(); ConfigName.getInstance().IsPortraitScreen=ScreenUtils.IsPortraitScreen(this); // 跳转到登录页面 diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/silos_calibrate_adapter.java b/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/silos_calibrate_adapter.java new file mode 100644 index 00000000..5f6ffa93 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/silos_calibrate_adapter.java @@ -0,0 +1,85 @@ +package com.bonait.bnframework.ViewModel.Adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.helper.I.MyClickListener; + +import java.util.List; + + +/** + * 料仓校准表 + */ +public class silos_calibrate_adapter extends ArrayAdapter { + /** + * 内部点击事件 + */ + private MyClickListener mListener; + private List datas; + int resource1; + public silos_calibrate_adapter(@NonNull Context context, int resource, @NonNull List objects, MyClickListener listener) { + super(context, resource, objects); + mListener = listener; + datas=objects; + this.resource1=resource; + } + //每个子项被滚动到屏幕内的时候会被调用 + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) getItem(position);//得到当前项选中item实例 + //为每一个子项加载设定的布局 + View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); + //分别获取 image view 和 textview 的实例 + + TextView num = view.findViewById(R.id.tv_num); + TextView desc = view.findViewById(R.id.tv_desc); + TextView outputMax = view.findViewById(R.id.tv_output_max); + TextView outputMin = view.findViewById(R.id.tv_output_min); + TextView inputMax = view.findViewById(R.id.tv_intput_max); + TextView inputMin = view.findViewById(R.id.tv_intput_min); + // 设置要显示的图片和文字 + num.setText(bean.num+""); + desc.setText(bean.name+""); + outputMax.setText(bean.outputTimeMax+""); + outputMin.setText(bean.outputTimeMin+""); + inputMax.setText(bean.inputWightMax+""); + inputMin.setText(bean.inputWightMin+""); + outputMax.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bean); + } + }); + outputMin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bean); + } + }); + inputMax.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bean); + } + }); + inputMin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bean); + } + }); + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/sp_adapter.java b/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/sp_adapter.java index d2d8e5d8..84f4a21c 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/sp_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/Adapter/sp_adapter.java @@ -41,6 +41,11 @@ public class sp_adapter extends RecyclerView.Adapter { mLayoutInflater = LayoutInflater.from(context); } + public void updateData(){ + goods = DataBus.getInstance().Goods; + notifyDataSetChanged(); + } + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/XComDialog.java b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/XComDialog.java new file mode 100644 index 00000000..86815c32 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/XComDialog.java @@ -0,0 +1,285 @@ +package com.bonait.bnframework.ViewModel.CustomView; + + +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.graphics.Rect; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.LinearLayout; + +import androidx.appcompat.app.AppCompatActivity; + +import com.bonait.bnframework.R; + + +/** + * + * <<==通用弹框封装==>> + * 如果设置动画无效,可能 mDialog.show()先调用有影响 + * + * new XComDialog(this,R.layout.view_xcom_dialog) + * .init() + * .setWindowSize() + * .setDialogListener(new XComDialog.OnDialogListener() { + * @Override + * public void onViewClick(View mLayoutView, final AlertDialog mDialog) { + * Button button= mLayoutView.findViewById(R.id.bt_colse); + * button.setOnClickListener(new View.OnClickListener() { + * @Override + * public void onClick(View v) { + * mDialog.dismiss(); + * } + * }); + * } + * }); + * + */ + +public class XComDialog { + private AppCompatActivity mContext;//上下文 + private int mThemeResId;//主题 + private View mLayoutView;//布局 + private Window window;//窗口 + private Dialog mDialog;//弹框 + public XComDialog xComDialog; + + + /** + * 布局接口 + */ + public static interface OnDialogListener { + public void onDialogClick(View layoutView, XComDialog xCom);//监听 + } + /** + * 布局接口 + */ + public static interface OnDialogListener2 { + public void onDialogClick(View layoutView, XComDialog xCom,Dialog mDialog);//监听 + } + + /** + * 对外监听 + */ + public XComDialog setDialogListener(OnDialogListener listener) { + listener.onDialogClick(mLayoutView, xComDialog); + return this; + } + /** + * 对外监听 + */ + public XComDialog setDialogListener2(OnDialogListener2 listener) { + listener.onDialogClick(mLayoutView, xComDialog,mDialog); + return this; + } + + /** + * 默认主题 + * + * @param context + * @param id_Layout + */ + public XComDialog(AppCompatActivity context, int id_Layout) { + this.mContext = context; + this.mThemeResId = R.style.dialogCommonTheme; + this.mLayoutView = LayoutInflater.from(mContext).inflate(id_Layout, null); + this.xComDialog=this; + } + + /** + * 自定主题 + * + * @param context + * @param themeResId + * @param id_Layout + */ + public XComDialog(AppCompatActivity context, int themeResId, int id_Layout) { + this.mContext = context; + this.mThemeResId = themeResId; + this.mLayoutView = LayoutInflater.from(mContext).inflate(id_Layout, null); + this.xComDialog=this; + } + + /** + * 初始化Dialog + */ + public XComDialog init() { +// mDialog = new AlertDialog.Builder(mContext, mThemeResId).create(); + mDialog = new Dialog(mContext); + mDialog.setCanceledOnTouchOutside(true);//点击外部不消失 + mDialog.setCancelable(true);//按返回键退出 + mDialog.show(); + return this; + } + public XComDialog init(boolean isBack, boolean isOut ) { +// mDialog = new AlertDialog.Builder(mContext, mThemeResId).create(); + mDialog = new Dialog(mContext,mThemeResId); + mDialog.setCancelable(isBack);//按返回键退出 + mDialog.setCanceledOnTouchOutside(isOut); + mDialog.show(); + return this; + } + public XComDialog init(boolean isBack, boolean isOut,boolean isSetShowInput) { +// mDialog = new AlertDialog.Builder(mContext, mThemeResId).create(); + mDialog = new Dialog(mContext,mThemeResId);//用Dialog代替AlertDialog才能弹出键盘 + mDialog.setCancelable(isBack);//按返回键退出 + mDialog.setCanceledOnTouchOutside(isOut); + ShowInput(isSetShowInput); + mDialog.show(); + + return this; + } + + /** + * 默认 弹框大小 透明度 + */ + public XComDialog setWindowSize() { + mDialog.getWindow().setDimAmount(0.5f);//设置透明度 + window = mDialog.getWindow(); + window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + window.setContentView(mLayoutView);//设置弹框布局 + + moveTop(); + window.setGravity(Gravity.CENTER); + + return this; + } + + + /** + * 默认 弹框大小 透明度 + */ + public XComDialog setWindowSizeMax() { + mDialog.getWindow().setDimAmount(0.5f);//设置透明度 + window = mDialog.getWindow(); + window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); + window.setContentView(mLayoutView);//设置弹框布局 + + moveTop(); + window.setGravity(Gravity.CENTER); + + return this; + } + + + /** + * 设置 大小与透明度 + * + * @param width + * @param height + * @param amount + * @return + */ + public XComDialog setWindowSize(int width, int height, float amount) { + + mDialog.getWindow().setDimAmount(amount);//设置透明度 + window = mDialog.getWindow(); + window.setLayout(width, height); + window.setContentView(mLayoutView);//设置弹框布局 + + return this; + } + + /** + * 设置弹框大小 透明度 当含listview数据时使用 + * + * @param width + * @param height + * @param self true自适应高度 ,false指定高度 + * @param amount + * @return + */ + public XComDialog setWindowSize(int width, int height, boolean self, float amount) { + if (self) { + mDialog.getWindow().setDimAmount(amount);//设置透明度 + window = mDialog.getWindow(); + window.setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT); + window.setContentView(mLayoutView);//设置弹框布局 + + return this; + } else { + mDialog.getWindow().setDimAmount(amount);//设置透明度 + window = mDialog.getWindow(); + window.setLayout(width, height); + window.setContentView(mLayoutView);//设置弹框布局 + + return this; + } + } + + /** + * 方式 与位置 + */ + public XComDialog setGravity(int animation, int gravity) { + window.setWindowAnimations(animation); //添加动画 + window.setGravity(gravity); + if (gravity == Gravity.CENTER) { + moveTop(); + } + return this; + } + + + + //关闭 + public void dismissX() { + if (mDialog != null && mDialog.isShowing()) { + mDialog.dismiss(); + mDialog = null;//清空对象 + window = null; + } + } + + /** + * 向上移动 虚拟键一般高度 + * 使至弹框居中 + */ + private void moveTop() { + WindowManager.LayoutParams lp = window.getAttributes(); + int y = getBotBarHeight();//虚拟键高度 + lp.y = -y / 2; // 偏移原来坐标 向上 + window.setAttributes(lp); + } + + /** + * 获取底部 虚拟键 高度 + * + * @return + */ + public int getBotBarHeight() { + Rect rect = new Rect(); + mContext.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); + int winHeight = mContext.getWindow().getDecorView().getHeight(); + return winHeight - rect.bottom; + } + + /** + * 是否显示输入法 + * @param isSet + */ + private void ShowInput(boolean isSet){ + if(isSet) { + mDialog.setOnShowListener(new DialogInterface.OnShowListener() { + @Override + public void onShow(DialogInterface dialog) { + InputMethodManager inputMethodManager = + (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); + } + }); + mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + InputMethodManager inputMethodManager = + (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0); + } + }); + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/add_qupenren.java b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/add_qupenren.java index e113c1ac..44d17bf2 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/add_qupenren.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/add_qupenren.java @@ -136,17 +136,20 @@ public class add_qupenren extends LinearLayout { quzhizuo.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - if (!ConfigName.getInstance().PlcIsConnect) { - ToastUtils.warning("PLC未准备就绪!!!"); - return; + if(!ConfigName.TEST){ + if (!ConfigName.getInstance().PlcIsConnect) { + ToastUtils.warning("PLC未准备就绪!!!"); + return; + } + + Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); + //Object jiting = ExecuteTheRecipe.getListingValue("设备急停"); + if (chushiover == null || !(boolean) chushiover) { + ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); + return; + } } - Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); - //Object jiting = ExecuteTheRecipe.getListingValue("设备急停"); - if (chushiover == null || !(boolean) chushiover) { - ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); - return; - } if (mListener != null) { mListener.clickListenerNew(view, 5, mode); } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java new file mode 100644 index 00000000..f6178ba3 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java @@ -0,0 +1,55 @@ +package com.bonait.bnframework.ViewModel.FragmentViewModel; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.HBL.DataUtil.DataType; +import com.bonait.bnframework.HBL.DataUtil.NotifyPropVar; +import com.bonait.bnframework.HBL.Interface.IRunT; +import com.bonait.bnframework.R; +import com.bonait.bnframework.Service.ControlAdress; +import com.bonait.bnframework.Service.ModbusHelper; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.databinding.FragmentHomeDeviceBinding; + +import butterknife.ButterKnife; + +public class HomeDeviceFragment extends BaseFragment { + protected FragmentHomeDeviceBinding mViewBinding; + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_home_device, null); + ButterKnife.bind(this, root); + mViewBinding = FragmentHomeDeviceBinding.inflate(getLayoutInflater()); + return root; + } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + init(); + } + + + private void init(){ + NotifyPropVar notifyPropVar = (NotifyPropVar)ModbusHelper.get().getPLC(ControlAdress.错误码).Value; + if(notifyPropVar!=null){ + notifyPropVar.Register(HomeDeviceFragment.class.getSimpleName(), new IRunT() { + @Override + public void Run(Short aShort) { + LogUtils.d("HomeDeviceFragment aShort="+aShort); + mViewBinding.deviceErrorCode.post(new Runnable() { + @Override + public void run() { + mViewBinding.deviceErrorCode.setText(" "+aShort); + } + }); + } + }); + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeFragmentPR.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeFragmentPR.java index 431c7328..53eb708d 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeFragmentPR.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeFragmentPR.java @@ -12,6 +12,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Color; +import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -181,6 +182,14 @@ public class HomeFragmentPR extends BaseFragment { StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager (3, StaggeredGridLayoutManager.VERTICAL); recycler_view.setLayoutManager(layout); +// recycler_view.addItemDecoration(new RecyclerView.ItemDecoration() { +// @Override +// public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, +// @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { +// super.getItemOffsets(outRect, view, parent, state); +// outRect.right = getResources().getDimensionPixelSize(R.dimen.dp_12); +// } +// }); ArrayList good = new ArrayList<>(); String name = search_view.getQuery().toString(); diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java index f15ea377..46eb3386 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java @@ -20,6 +20,7 @@ import android.widget.ListView; import android.widget.Spinner; import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.Adapter.silos_calibrate_adapter; import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.ConfigName; @@ -28,6 +29,7 @@ import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_PROCESS; import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; import com.bonait.bnframework.common.db.res.lcMode; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.AlertDialogUtils; @@ -66,7 +68,11 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL @BindView(R.id.datatab_lc) ListView datatab_lc;//料仓 + + @BindView(R.id.datatab_silos_calibrate) + ListView datatab_silos_calibrate;//料仓校准 ArrayList lcModes = new ArrayList<>(); + ArrayList silosCalibrates = new ArrayList<>(); @BindView(R.id.datatab_gxmx) ListView datatab_gxmx;//工序 @@ -101,6 +107,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL Initdata_wl(); Initdata_lc(); Initdata_gx(); + Initdata_silos_calibrate(); } @SuppressLint("HandlerLeak") @@ -111,6 +118,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL Initdata_wl(); Initdata_lc(); Initdata_gx(); + Initdata_silos_calibrate(); } } }; @@ -222,6 +230,146 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL } } + /** + * 初始化料仓校准数据加载 + */ + public void Initdata_silos_calibrate() { + try { + silosCalibrates = QueryDB.GetSilosCalibrateAll(); + silos_calibrate_adapter adapter2 = new silos_calibrate_adapter(context, R.layout.silos_calibrate_item, silosCalibrates, new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)data; + switch (v.getId()){ + case R.id.tv_output_max: + final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(context); + assert bean != null; + builder1.setTitle(bean.name + " 输出时间最大值(s)") + .setPlaceholder("在此输入值") + .setDefaultText(bean.outputTimeMax + "") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder1.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateSilosCalibrate(bean.id, Integer.parseInt(text.toString()),-1,-1,-1); + Initdata_silos_calibrate(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("值不能为空!"); + } + } + }) + .show(); + break; + case R.id.tv_output_min: + final QMUIDialog.EditTextDialogBuilder builder2 = new QMUIDialog.EditTextDialogBuilder(context); + assert bean != null; + builder2.setTitle(bean.name + " 输出时间最小值(s)") + .setPlaceholder("在此输入值") + .setDefaultText(bean.outputTimeMin + "") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder2.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateSilosCalibrate(bean.id, -1,Integer.parseInt(text.toString()),-1,-1); + Initdata_silos_calibrate(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("值不能为空!"); + } + } + }) + .show(); + break; + case R.id.tv_intput_max: + final QMUIDialog.EditTextDialogBuilder builder3 = new QMUIDialog.EditTextDialogBuilder(context); + assert bean != null; + builder3.setTitle(bean.name + " 输出重量最大值(g)") + .setPlaceholder("在此输入值") + .setDefaultText(bean.outputTimeMin + "") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder3.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateSilosCalibrate(bean.id, -1,1,Integer.parseInt(text.toString()),-1); + Initdata_silos_calibrate(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("值不能为空!"); + } + } + }) + .show(); + break; + case R.id.tv_intput_min: + final QMUIDialog.EditTextDialogBuilder builder4 = new QMUIDialog.EditTextDialogBuilder(context); + assert bean != null; + builder4.setTitle(bean.name + " 输出重量最大值(g)") + .setPlaceholder("在此输入值") + .setDefaultText(bean.outputTimeMin + "") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder4.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateSilosCalibrate(bean.id, -1,1,-1,Integer.parseInt(text.toString())); + Initdata_silos_calibrate(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("值不能为空!"); + } + } + }) + .show(); + break; + } + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + } + }); + datatab_silos_calibrate.setAdapter(adapter2); + } catch (Exception e) { + + } + } + /** * 初始化数据加载 */ @@ -324,7 +472,6 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL @Override public void clickListenerNew(View v, int k, Object data) { - lcMode lc = (lcMode) data; switch (v.getId()) { case R.id.name://修改物料 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 bfa41fb0..a079cc25 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -9,6 +9,7 @@ import android.util.Log; import androidx.annotation.NonNull; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.HBL.Interface.IRun; import com.bonait.bnframework.HBL.Interface.IRunT; import com.bonait.bnframework.HBL.Thread.IThread; @@ -19,6 +20,7 @@ import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.db.mode.BPA_SILOS; +import com.bonait.bnframework.common.db.mode.ModeBase; import com.bonait.bnframework.common.helper.ByteHelper; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.ViewModel.CustomView.MyStatus; @@ -121,23 +123,33 @@ public class ExecuteTheRecipe { return false; } ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms); + LogUtils.d("开始执行 "+ recipe.sort + "、" + recipe.processms); +// if (recipe.materialType == 0)//正常物料 +// { +// //先到达抽料位 +// BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); +// ExecuteOperationSteps(data1.processname, data1.processvalue); +// +// ExecuteMaterialIssuance(recipe.processvalue); +// } else if (recipe.materialType == 1)//工序模型 +// { +// if (recipe.processname.equals("抽水")) { +// BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); +// ExecuteOperationSteps(data1.processname, data1.processvalue); +// } else if (recipe.processname.equals("主料")) { +// BPA_GOODSRECIPE data1 = Get位置("最高", "炒菜位1"); +// ExecuteOperationSteps(data1.processname, data1.processvalue); +// } +// +// ExecuteOperationSteps(recipe.processname, recipe.processvalue); +// } + if (recipe.materialType == 0)//正常物料 { - //先到达抽料位 - BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); - ExecuteOperationSteps(data1.processname, data1.processvalue); - + ExecuteOperationSteps(selectpf.processname, selectpf.processvalue); ExecuteMaterialIssuance(recipe.processvalue); } else if (recipe.materialType == 1)//工序模型 { - if (recipe.processname.equals("抽水")) { - BPA_GOODSRECIPE data1 = Get位置("最高", "抽料位"); - ExecuteOperationSteps(data1.processname, data1.processvalue); - } else if (recipe.processname.equals("主料")) { - BPA_GOODSRECIPE data1 = Get位置("最高", "炒菜位1"); - ExecuteOperationSteps(data1.processname, data1.processvalue); - } - ExecuteOperationSteps(recipe.processname, recipe.processvalue); } } catch (Exception ex) { @@ -196,25 +208,25 @@ public class ExecuteTheRecipe { Thread.sleep(200);//等待写入完成 //一直等待下料完成 否则就一直等待 40s超时 - for (Map.Entry entry : formulation.entrySet()) { - BPA_SILOS silos = entry.getKey(); - Integer val = entry.getValue(); - String name = "料仓" + silos.num + "下料完成"; - final boolean[] IsComplete = {false}; - long a = System.currentTimeMillis(); - while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - break; - } else { -// Object sb = ReadPLC(name);// ListeningValue.get(name); -// if (sb != null) { -// IsComplete[0] = (boolean) (sb); -// } - } - Thread.sleep(100);//10 *6 - } - ToastUtils.info(name); - } +// for (Map.Entry entry : formulation.entrySet()) { +// BPA_SILOS silos = entry.getKey(); +// Integer val = entry.getValue(); +// String name = "料仓" + silos.num + "下料完成"; +// final boolean[] IsComplete = {false}; +// long a = System.currentTimeMillis(); +// while (!IsComplete[0]) { +// if ((System.currentTimeMillis() - a) > 1000 * whileTime) { +// break; +// } else { +//// Object sb = ReadPLC(name);// ListeningValue.get(name); +//// if (sb != null) { +//// IsComplete[0] = (boolean) (sb); +//// } +// } +// Thread.sleep(100);//10 *6 +// } +// ToastUtils.info(name); +// } } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); @@ -254,13 +266,14 @@ public class ExecuteTheRecipe { //endregion //写入PLC if (formulation.size() > 0) { + LogUtils.d("ExecuteOperationSteps 执行工序步骤 processname="+processname+"; formulation="+formulation); switch (processname) { case "搅拌": Write_PLC_Stir(formulation); break; - case "位置": - Write_PLC_Location(formulation); - break; +// case "位置": +// Write_PLC_Location(formulation); +// break; case "加热": Write_PLC_Heating(formulation); break; @@ -273,12 +286,16 @@ public class ExecuteTheRecipe { case "延迟": Write_PLC_Delay(formulation); break; + case "勾芡": + Write_PLC_addThickenWater(formulation); + break; + case "升降": + Write_PLC_setUpdDownMotor(formulation); + break; case "出菜": Write_PLC_Outdishes(formulation); break; } - - } } } catch (Exception ex) { @@ -300,23 +317,24 @@ public class ExecuteTheRecipe { if (ExecuteCurrentOperation != null) { ExecuteCurrentOperation.Run("液体料|" + silos.num); } - ToastUtils.info("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0); + ToastUtils.info("准备写入仓号需求:" + silos.num + "," + val / 10.0);//为啥 + ModbusHelper.get().addSeason(val,silos.num); - String name = "料仓" + silos.num + "下料完成"; +// String name = "料仓" + silos.num + "下料完成"; // ExecuteTheRecipe.WritePLC(name, false, null); - final boolean[] IsComplete = {false}; - WritePLC("料仓" + silos.num + "需求值", val,()->{ - BottomClick("料仓" + silos.num + "下料"); - IsComplete[0] = true; - }); - long a = System.currentTimeMillis(); - while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * whileTime) { - break; - } - Thread.sleep(100);//10 *6 - } +// final boolean[] IsComplete = {false}; +// WritePLC("料仓" + silos.num + "需求值", val,()->{ +// BottomClick("料仓" + silos.num + "下料"); +// IsComplete[0] = true; +// }); +// long a = System.currentTimeMillis(); +// while (!IsComplete[0]) { +// if ((System.currentTimeMillis() - a) > 1000 * whileTime) { +// break; +// } +// Thread.sleep(100);//10 *6 +// } //減去料仓数量 int otherG = silos.silosmargin - (val / 10); @@ -346,18 +364,26 @@ public class ExecuteTheRecipe { val = Integer.parseInt(value); } else { ToastUtils.info("工序:" + key + "," + value); - int writeValue = GetMXValue(key, value); if (ExecuteCurrentOperation != null) { - ExecuteCurrentOperation.Run("搅拌" + "|" + writeValue); + ExecuteCurrentOperation.Run("搅拌" + "|" + value); + } + if(value.contains("启动")){ + ModbusHelper.get().setStirMotor(1); + }else { + ModbusHelper.get().setStirMotor(2); } +// int writeValue = GetMXValue(key, value); +// if (ExecuteCurrentOperation != null) { +// ExecuteCurrentOperation.Run("搅拌" + "|" + writeValue); +// } +// WritePLC(key, writeValue, ()->{ +// if (writeValue == 0) { +// WritePLC("搅拌", false, null); +// } else { +// WritePLC("搅拌", true, null); +// } +// }); - WritePLC(key, writeValue, ()->{ - if (writeValue == 0) { - WritePLC("搅拌", false, null); - } else { - WritePLC("搅拌", true, null); - } - }); } } @@ -437,29 +463,28 @@ public class ExecuteTheRecipe { private static void Write_PLC_Ingredients(HashMap data) { try { //是否手动 - boolean ishand = true; - ToastUtils.info("准备倒入主料!"); +// boolean ishand = true; +// ToastUtils.info("准备倒入主料!"); //region 判断是否手动 - if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { - ishand = true; - } else { - for (HashMap.Entry entry : data.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - if (key.contains("投料动作")) { - if (value.contains("手动投料")) { - ishand = true; - } else { - ishand = false; - } - } - } - } +// if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { +// ishand = true; +// } else { +// for (HashMap.Entry entry : data.entrySet()) { +// String key = entry.getKey(); +// String value = entry.getValue(); +// if (key.contains("投料动作")) { +// if (value.contains("手动投料")) { +// ishand = true; +// } else { +// ishand = false; +// } +// } +// } +// } //endregion - - if (ishand) { + /*if (ishand) { if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { ExecuteTheRecipe.BottomClick("平移-去1号位"); } @@ -576,17 +601,28 @@ public class ExecuteTheRecipe { ExecuteTheRecipe.BottomClick("平移-去1号位"); Log.d("移动去", "1号位"); } - } + }*/ //判断是否有烹饪时间 int val = 0; + int position = 1;//几号位 + String name = "";//主料名称 for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key.contains("(秒)")) { val = Integer.parseInt(value); + } else if(key.contains("名称")){ + name = value; + }else if(key.contains("位置")){ + position = Integer.parseInt(value); } } + ToastUtils.info("工序: 主料名称:"+name + " 主料位置:" + position); + if (ExecuteCurrentOperation != null) { + ExecuteCurrentOperation.Run("主料" + "|" + position); + } + ModbusHelper.get().addMainFood(position); if (val > 0) { Thread.sleep(val * 1000); } @@ -638,28 +674,42 @@ public class ExecuteTheRecipe { private static void Write_PLC_Heating(HashMap data) { try { int val = 0; + int hotNum = 0;//加热档位 + boolean startHot = false;//是否启动加热 for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key.contains("(秒)")) { val = Integer.parseInt(value); - } else { + } else if(key.contains("档位")){ + hotNum = Integer.parseInt(value); + }else { ToastUtils.info("工序:" + key + "," + value); - int writeValue = GetMXValue(key, value); if (ExecuteCurrentOperation != null) { - ExecuteCurrentOperation.Run("加热" + "|" + writeValue); + ExecuteCurrentOperation.Run("加热" + "|" + value); } - WritePLC(key, writeValue, ()->{ - if (writeValue == 0) { - ConfigName.getInstance().IsOpenHuoLi = false; - WritePLC("加热", false, null); - } else { - ConfigName.getInstance().IsOpenHuoLi = true; - WritePLC("加热", true, null); - } - }); + if(value.contains("启动")){ + startHot = true; + }else { + startHot= false; + } + +// int writeValue = GetMXValue(key, value); +// if (ExecuteCurrentOperation != null) { +// ExecuteCurrentOperation.Run("加热" + "|" + writeValue); +// } +// WritePLC(key, writeValue, ()->{ +// if (writeValue == 0) { +// ConfigName.getInstance().IsOpenHuoLi = false; +// WritePLC("加热", false, null); +// } else { +// ConfigName.getInstance().IsOpenHuoLi = true; +// WritePLC("加热", true, null); +// } +// }); } } + ModbusHelper.get().Heating(hotNum,startHot); if (val > 0) { Thread.sleep(val * 1000); @@ -690,13 +740,14 @@ public class ExecuteTheRecipe { ExecuteCurrentOperation.Run("加水" + "|" + val); } if (val > 0) { - WritePLC("炒锅抽水", true,null); - new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); - } - }, val * 1000); + ModbusHelper.get().addWater(val); +// WritePLC("炒锅抽水", true,null); +// new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { +// @Override +// public void run() { +// ExecuteTheRecipe.WritePLC("炒锅抽水", false, null); +// } +// }, val * 1000); } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); @@ -713,7 +764,7 @@ public class ExecuteTheRecipe { for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); + ToastUtils.info("工序:" + "等待"+value+"秒"); if (key.contains("(秒)")) { int val = Integer.parseInt(value); Thread.sleep(val * 1000); @@ -731,36 +782,33 @@ public class ExecuteTheRecipe { */ private static void Write_PLC_Outdishes(HashMap data) { try { - ToastUtils.info("准备出菜!"); - //先延迟 for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - ToastUtils.info("工序:" + key + "," + value); + ToastUtils.info("工序: 等待"+value+"秒后出菜"); if (key.contains("(秒)")) { int val = Integer.parseInt(value); Thread.sleep(val * 1000); } } - - BottomClick("出菜"); +// BottomClick("出菜"); //一直等待机器移动到该位置,否则就一直等待 6s超时 - String name = "出餐启动反馈"; - final boolean[] IsComplete = {false}; - long a = System.currentTimeMillis(); - while (!IsComplete[0]) { - if ((System.currentTimeMillis() - a) > 1000 * 120) { - break; - } else { - Object sb = ReadPLC(name);//ListeningValue.get(name); - if (sb != null) { - IsComplete[0] = (boolean) (sb); - } - } - Thread.sleep(100);//10 *6 - } +// String name = "出餐启动反馈"; +// final boolean[] IsComplete = {false}; +// long a = System.currentTimeMillis(); +// while (!IsComplete[0]) { +// if ((System.currentTimeMillis() - a) > 1000 * 120) { +// break; +// } else { +// Object sb = ReadPLC(name);//ListeningValue.get(name); +// if (sb != null) { +// IsComplete[0] = (boolean) (sb); +// } +// } +// Thread.sleep(100);//10 *6 +// } ToastUtils.info("出菜完成,结束制作!"); } catch (Exception ex) { @@ -805,6 +853,69 @@ public class ExecuteTheRecipe { } //endregion + /** + * 写PLC 出菜 + * + * @param data + */ + private static void Write_PLC_addThickenWater(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); + if (ExecuteCurrentOperation != null) { + ExecuteCurrentOperation.Run("勾芡" + "|" + value); + } + ModbusHelper.get().addThickenWater(val); + } + } + ToastUtils.info("出菜完成,结束制作!"); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + + /** + * 写PLC 出菜 + * + * @param data + */ + private static void Write_PLC_setUpdDownMotor(HashMap data) { + try { + int val = 0; + //先延迟 + for (HashMap.Entry entry : data.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + ToastUtils.info("工序:" + key + "," + value); + if (key.contains("(秒)")) { + val = Integer.parseInt(value); + ToastUtils.info("工序:" + "升降," + value); + if (ExecuteCurrentOperation != null) { + ExecuteCurrentOperation.Run("升降" + "|" + value); + } + }else if(key.contains("升降")){ + if(value.contains("升")){ + ModbusHelper.get().setUpdDownMotor(1); + }else { + ModbusHelper.get().setUpdDownMotor(2); + } + } + } + if(val > 0){ + Thread.sleep(val * 1000); + } + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + //region 主页按钮 /** diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java index b5f2fbca..5af64c9f 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -2,9 +2,15 @@ package com.bonait.bnframework.business; import android.app.Activity; import android.app.Application; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; import android.util.Log; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.BuildConfig; +import com.bonait.bnframework.MainApplication; +import com.bonait.bnframework.Service.ControlAdress; +import com.bonait.bnframework.Service.ModbusHelper; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.Constants; import com.bonait.bnframework.common.constant.DataBus; @@ -18,6 +24,7 @@ import com.bonait.bnframework.common.db.mode.BPA_LOG; import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; import com.bonait.bnframework.common.db.mode.BPA_USER; import com.bonait.bnframework.common.db.res.AlertLogEnum; import com.bonait.bnframework.common.db.res.UserLogEnum; @@ -212,9 +219,9 @@ public class MainInit { - //10个料仓 - if (QueryDB.GetSilosALL().size() == 0) { - for (int i = 0; i < 11; i++) { + //9个料仓 + if (QueryDB.GetSilosALL().isEmpty()) { + for (int i = 0; i < 9; i++) { BPA_SILOS silo = new BPA_SILOS(); silo.id = java.util.UUID.randomUUID().toString(); silo.num = i + 1; @@ -233,6 +240,42 @@ public class MainInit { { ConfigData.getInstance().RevertPLCProcess(); } + + //11个料仓 1-9个液体 10水阀 11勾芡 +// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_SILOS_CALIBRATE.class,null); + if (QueryDB.GetSilosCalibrateAll().isEmpty()) { + if(!DBHelper.getInstance(MainApplication.getContext()).doesTableExist(BPA_SILOS_CALIBRATE.class)){ + DBHelper.getInstance(MainApplication.getContext()).CreateTablesAll(BPA_SILOS_CALIBRATE.class,null); + } + for (int i = 1; i < 10; i++) { + BPA_SILOS_CALIBRATE silo = new BPA_SILOS_CALIBRATE(); + silo.name = "液体"+i; + silo.num = i; + silo.outputTimeMax = 5; + silo.outputTimeMin = 0; + silo.inputWightMax = 100; + silo.inputWightMin = 0; + QueryDB.AddSilosCalibrate(silo); + } + BPA_SILOS_CALIBRATE silo = new BPA_SILOS_CALIBRATE(); + silo.name = ControlAdress.加水.toString(); + silo.num = 10; + silo.outputTimeMax = 5; + silo.outputTimeMin = 0; + silo.inputWightMax = 100; + silo.inputWightMin = 0; + QueryDB.AddSilosCalibrate(silo); + BPA_SILOS_CALIBRATE silo2 = new BPA_SILOS_CALIBRATE(); + silo2.name = ControlAdress.勾芡.toString(); + silo2.num = 11; + silo2.outputTimeMax = 5; + silo2.outputTimeMin = 0; + silo2.inputWightMax = 100; + silo2.inputWightMin = 0; + QueryDB.AddSilosCalibrate(silo2); + LogUtils.d(" 首次创建 料仓校准 silo2="+silo2.toString()+QueryDB.GetSilosCalibrateAll()); + } + ModbusHelper.get().Add(QueryDB.GetSilosCalibrateAll()); } /** * 删除表-重新生成新表 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 fee1e126..5ba5726d 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 @@ -30,6 +30,8 @@ import java.util.concurrent.ConcurrentHashMap; * 配置文件 */ public class ConfigName { + //是否是测试模式 + public final static boolean TEST = true; //region 单例模式 private static ConfigName mInstance; //实例变量设置私有,防止直接通过类名访问 diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index e679cb20..927a7cf8 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -1,6 +1,7 @@ package com.bonait.bnframework.common.constant; import com.bonait.bnframework.HBL.Interface.IRun; +import com.bonait.bnframework.Model.ErrorCodeBean; 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; @@ -47,6 +48,7 @@ public class DataBus { String text2=""; String text3=""; String text4=""; + String text5=""; try { ArrayList goodsrecipes= QueryDB.GetGoodsSrecipeID(goodid); @@ -99,6 +101,9 @@ public class DataBus { }else if(formulation.get("主料位置").toString().equals("4号位")) { text4+=formulation.get("主料名称"); + }else if(formulation.get("主料位置").toString().equals("5号位")) + { + text5+=formulation.get("主料名称"); } } } @@ -112,6 +117,7 @@ public class DataBus { resultData.put(2,text2); resultData.put(3,text3); resultData.put(4,text4); + resultData.put(5,text5); return resultData; } //endregion diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 8d3dd974..e8f7f013 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteDatabase; import android.util.Log; import android.widget.TableRow; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.file.DBHelper; import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; @@ -28,6 +29,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESS; import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; import com.bonait.bnframework.common.db.mode.BPA_SUGAR; import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; @@ -164,6 +166,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_MATERIAL) k); } + LogUtils.d("GetMaterialALL 获取所有物料信息 data="+data.toString()); return data; } @@ -320,6 +323,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_SILOS) k); } + LogUtils.d(" GetSilosALL 获取所有料仓管理 data="+data.toString()); return data; } @@ -637,6 +641,7 @@ public class QueryDB { data.add(silos); } } + LogUtils.d("根据物料名称查询料仓 GetSolisByMaterialName data="+data.toString()); return data; } //endregion @@ -732,6 +737,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODS) k); } + LogUtils.d("GetGoodsALL 获取所有商品(菜谱) data=" + data.toString()); return data; } @@ -741,7 +747,7 @@ public class QueryDB { * @return */ public static ArrayList GetGoodsLike(String name) { - String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String orderby = Desc_Sort_Up;//先按排序 创建时间倒序 String where = "isDelete=? and name like ?"; String[] args = new String[]{"0","%" + name + "%"}; ArrayList data = new ArrayList<>(); @@ -749,6 +755,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODS) k); } + LogUtils.d("GetGoodsLike 模糊查询商品(菜谱) data=" + data.toString()); return data; } @@ -766,6 +773,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODS) k); } + LogUtils.d("GetGoodsStateALL 获取所有启用的商品 data=" + data.toString()); return data; } @@ -784,6 +792,7 @@ public class QueryDB { data.add((BPA_GOODS) k); } if (data.size() > 0) { + LogUtils.d("GetGoodsId根据id查询商品 data=" + data.toString()); return data.get(0); } else { return null; @@ -806,6 +815,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODS) k); } + LogUtils.d("GetGoodsIs 判断商品数据是否存在 data=" + data.toString()); return data.size() > 0; } @@ -863,6 +873,7 @@ public class QueryDB { for (Object k : obj) { data = (BPA_GOODS) k; } + LogUtils.d("GetGoodsSortIs 根据排序查询商品 data=" + data.toString()); return data; } @@ -945,6 +956,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_GOODSRECIPE) k); } + LogUtils.d("GetGoodsSrecipeALL 获取所有商品配方明细 data=" + data.toString()); return data; } /** @@ -963,6 +975,7 @@ public class QueryDB { BPA_GOODSRECIPE k = (BPA_GOODSRECIPE) item; data.add(k); } + LogUtils.d("GetGoodsSrecipeID 根据商品id查询配方信息 data=" + data.toString()); return data; } /** @@ -2197,6 +2210,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_PROCESS) k); } + LogUtils.d("GetProcessID data=" + data.toString()); return data; } @@ -2218,6 +2232,7 @@ public class QueryDB { for (Object k : obj) { bpa_material = (BPA_PROCESS) k; } + LogUtils.d("GetProcessID data=" + data.toString()); return bpa_material; } catch (Exception e) { Log.d("物料ID查询工序信息", "物料ID查询工序信息异常: " + e.getMessage()); @@ -2287,6 +2302,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_PROCESSModel) k); } + LogUtils.d("GetProcessModelALL data=" + data.toString()); return data; } /** @@ -2306,6 +2322,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_PROCESSModel) k); } + LogUtils.d("GetProcessModelProcessID 工序ID查询工序模型表 data=" + data.toString()); return data; } catch (Exception e) { Log.d("物料ID查询工序信息", "物料ID查询工序信息异常: " + e.getMessage()); @@ -2331,6 +2348,7 @@ public class QueryDB { for (Object k : obj) { bpa_material = (BPA_PROCESSModel) k; } + LogUtils.d("GetProcessModelID ID查询工序模型表 data=" + data.toString()); return bpa_material; } catch (Exception e) { Log.d("物料ID查询工序信息", "物料ID查询工序信息异常: " + e.getMessage()); @@ -2400,6 +2418,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_CLOUDDATA) k); } + LogUtils.d("GetClouddataALL 获取所有工序模型表 data=" + data.toString()); return data; } //endregion @@ -2453,6 +2472,7 @@ public class QueryDB { for (Object k : obj) { data.add((BPA_PLCADDRESS) k); } + LogUtils.d("GetPlcaddressALL 获取所有工序模型表 data=" + data.toString()); return data; } /** @@ -2473,6 +2493,7 @@ public class QueryDB { for (Object k : obj) { bpa_material = (BPA_PLCADDRESS) k; } + LogUtils.d("GetPlcaddressID ID查询工序模型表 data=" + data.toString()); return bpa_material; } catch (Exception e) { return null; @@ -2489,6 +2510,99 @@ public class QueryDB { Update(BPA_PLCADDRESS.class, material); } } + + //BPA_SILOS_CALIBRATE 料仓校准表 + /** + * 新增料仓校准 + * add liup 20240418 + * + * @param data + * @return 是否成功 + */ + public static boolean AddSilosCalibrate(BPA_SILOS_CALIBRATE data) { + return Add(BPA_SILOS_CALIBRATE.class, data); + } + + /** + * 查询所有料仓校准 + * add liup 20240418 + * @return + */ + public static ArrayList GetSilosCalibrateAll() { + String orderby = "num";//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SILOS_CALIBRATE.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_SILOS_CALIBRATE) k); + } + LogUtils.d(" GetSilosCalibrateLIst 查询所有料仓校准 data="+data.toString()); + return data; + } + + /** + * 根据ID查询料仓校准 + * + * @return + */ + public static BPA_SILOS_CALIBRATE GetSilosCalibrate(String id) { + BPA_SILOS_CALIBRATE data = null; + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0", id}; + ArrayList obj = Get(BPA_SILOS_CALIBRATE.class, where, args, orderby); + for (Object k : obj) { + data = (BPA_SILOS_CALIBRATE) k; + } + return data; + } + + /** + * 根据名称查询料仓校准 + * + * @return + */ + public static BPA_SILOS_CALIBRATE GetSilosCalibrateByNum(int num) { + BPA_SILOS_CALIBRATE data = null; + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and num=?"; + String[] args = new String[]{"0", num+""}; + ArrayList obj = Get(BPA_SILOS_CALIBRATE.class, where, args, orderby); + for (Object k : obj) { + data = (BPA_SILOS_CALIBRATE) k; + } + return data; + } + + /** + * 修改料仓校准 + * + * @param id + * @param outputMax + * @param outputMin + * @param inputMax + * @param inputMin + */ + public static void UpdateSilosCalibrate(String id, int outputMax,int outputMin,int inputMax,int inputMin) { + BPA_SILOS_CALIBRATE silos = GetSilosCalibrate(id); + if (silos != null) { + if(outputMax>=0){ + silos.outputTimeMax = outputMax; + } + if(outputMin>=0){ + silos.outputTimeMin = outputMin; + } + if(inputMax>=0){ + silos.inputWightMax = inputMax; + } + if(inputMin>=0){ + silos.inputWightMin = inputMin; + } + Update(BPA_SILOS_CALIBRATE.class, silos); + } + } + //endregion //region 私有 @@ -2532,6 +2646,7 @@ public class QueryDB { long insert = db.insert(c.getSimpleName(), null, cv); db.close(); isSucess= insert > 0; + LogUtils.d(" 添加表数据 "+c.getSimpleName()+" "+isSucess); } catch (Exception e) { db.close(); isSucess= false; @@ -2583,6 +2698,7 @@ public class QueryDB { db.update(c.getSimpleName(), cv, "id = ?", new String[]{id}); db.close(); isSucess= true; + LogUtils.d("修改数据 Update "+c.getSimpleName()); } catch (Exception e) { db.close(); isSucess= false; @@ -2863,6 +2979,17 @@ public class QueryDB { ((BPA_PLCADDRESS) data).isread = cursor.getInt((int) cursor.getColumnIndex("isread")); ((BPA_PLCADDRESS) data).iswrite = cursor.getInt((int) cursor.getColumnIndex("iswrite")); + break; + case "BPA_SILOS_CALIBRATE": + data = new BPA_SILOS_CALIBRATE(); + //私有 + ((BPA_SILOS_CALIBRATE) data).name = cursor.getString((int) cursor.getColumnIndex("name")); + ((BPA_SILOS_CALIBRATE) data).num = cursor.getInt((int) cursor.getColumnIndex("num")); + ((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getInt((int) cursor.getColumnIndex("outputTimeMax")); + ((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getInt((int) cursor.getColumnIndex("outputTimeMin")); + ((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getInt((int) cursor.getColumnIndex("inputWightMin")); + ((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getInt((int) cursor.getColumnIndex("inputWightMax")); + break; } ((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java b/app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java index 061ebf19..ce1d226c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/file/DBHelper.java @@ -1,9 +1,11 @@ package com.bonait.bnframework.common.db.file; import android.content.Context; +import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; @@ -24,6 +26,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESS; import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE; import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; import com.bonait.bnframework.common.db.mode.BPA_SUGAR; import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; @@ -124,6 +127,7 @@ public class DBHelper extends SQLiteOpenHelper { CreateTablesAll(BPA_CLOUDDATA.class,null);//云端表 CreateTablesAll(BPA_PLCADDRESS.class,null);//工序模型表 + CreateTablesAll(BPA_SILOS_CALIBRATE.class,null);//料仓校准模型表 ForeignKeys(); } @@ -131,7 +135,7 @@ public class DBHelper extends SQLiteOpenHelper { * 创建数据库表 * @param c */ - private void CreateTablesAll(Class c,String premarykey) + public void CreateTablesAll(Class c,String premarykey) { if (premarykey == null){ @@ -160,6 +164,20 @@ public class DBHelper extends SQLiteOpenHelper { db.endTransaction(); } + /** + * 判断表是否存在 + * @param c + * @return + */ + public boolean doesTableExist(Class c) { + SQLiteDatabase db =this.getWritableDatabase(); + Cursor cursor = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table' AND name=?", new String[]{c.getSimpleName()}); + boolean exists = cursor.moveToFirst(); + cursor.close(); + LogUtils.d(" doesTableExist 判断表是否存在 "+c.getSimpleName()+" exists="+exists); + return exists; + } + private void CreateRelationshipTables(Class c, Map map){ SQLiteDatabase db =this.getWritableDatabase(); db.beginTransaction(); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/file/Table.java b/app/src/main/java/com/bonait/bnframework/common/db/file/Table.java index 9ae6b8da..ba87d6a8 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/file/Table.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/file/Table.java @@ -2,6 +2,8 @@ package com.bonait.bnframework.common.db.file; import android.util.Log; +import com.apkfuns.logutils.LogUtils; + import java.util.ArrayList; import java.util.Map; @@ -47,6 +49,7 @@ public class Table { sb.deleteCharAt(sb.length()-1); sb.append(")"); Log.i("sql:",sb.toString()); + LogUtils.d(" createSQL 创建表 "+sb); return sb.toString(); } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java index 6882a83a..b58fe998 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODS.java @@ -1,5 +1,7 @@ package com.bonait.bnframework.common.db.mode; +import com.google.gson.Gson; + /** * BPA_GOODS[商品表] * 创建人:fengyoufu add 20230412 @@ -19,4 +21,25 @@ public class BPA_GOODS extends ModeBase { public int issc; //工艺id public String gyid; + + @Override + public String toString() { + return "BPA_GOODS{" + + "name='" + name + '\'' + + ", url='" + url + '\'' + + ", sort=" + sort + + ", status=" + status + + ", maketime=" + maketime + + ", issc=" + issc + + ", gyid='" + gyid + '\'' + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java index 8dfd168a..8c150f32 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java @@ -1,5 +1,7 @@ package com.bonait.bnframework.common.db.mode; +import androidx.annotation.NonNull; + /** * BPA_GOODSRECIPE[商品配方明细表] * 创建人:fengyoufu add 20230412 @@ -22,4 +24,26 @@ public class BPA_GOODSRECIPE extends ModeBase { //模型变量 public String processvalue; + + @Override + public String toString() { + return "BPA_GOODSRECIPE{" + + "goodsID='" + goodsID + '\'' + + ", materialID='" + materialID + '\'' + + ", value=" + value + + ", sort=" + sort + + ", materialType=" + materialType + + ", processms='" + processms + '\'' + + ", processname='" + processname + '\'' + + ", processvalue='" + processvalue + '\'' + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESS.java index bf7a6c7c..4015e57d 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESS.java @@ -8,4 +8,20 @@ public class BPA_PROCESS extends ModeBase{ public int sort; //名称 public String name; + + @Override + public String toString() { + return "BPA_PROCESS{" + + "sort=" + sort + + ", name='" + name + '\'' + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java index 216f62c9..967f081e 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java @@ -25,4 +25,22 @@ public class BPA_PROCESSModel extends ModeBase{ */ public int sort; + @Override + public String toString() { + return "BPA_PROCESSModel{" + + "processid='" + processid + '\'' + + ", name='" + name + '\'' + + ", datatype=" + datatype + + ", data='" + data + '\'' + + ", sort=" + sort + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java index ed2c1029..2ad8d36d 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java @@ -27,4 +27,29 @@ public class BPA_SILOS extends ModeBase { public int silosmargin; //料仓总量 public int siloszl; + + @Override + public String toString() { + return "BPA_SILOS{" + + "num=" + num + + ", name='" + name + '\'' + + ", warningValue=" + warningValue + + ", thrsoleValue=" + thrsoleValue + + ", plcValue='" + plcValue + '\'' + + ", bValue=" + bValue + + ", jValue=" + jValue + + ", status=" + status + + ", Sort=" + Sort + + ", silosmargin=" + silosmargin + + ", siloszl=" + siloszl + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java new file mode 100644 index 00000000..8f86f4fb --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java @@ -0,0 +1,41 @@ +package com.bonait.bnframework.common.db.mode; + +/** + * BPA_SILOS[料仓管理表] + * 创建人:fengyoufu add 20230412 + */ +public class BPA_SILOS_CALIBRATE extends ModeBase { + //料仓名称 + public String name; + //料仓编号 + public int num; + //输出时间最大值:s + public int outputTimeMax; + //输出时间最小值:s + public int outputTimeMin; + //输入重量最大值: g + public int inputWightMax; + //输入重量最小值: g + public int inputWightMin; + + + @Override + public String toString() { + return "BPA_SILOS_CALIBRATE{" + + "name='" + name + '\'' + + "num='" + num + '\'' + + ", outputTimeMax=" + outputTimeMax + + ", outputTimeMin=" + outputTimeMin + + ", inputWightMax=" + inputWightMax + + ", inputWightMin=" + inputWightMin + + ", id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/ModeBase.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/ModeBase.java index 17fee5a3..cd6680b2 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/ModeBase.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/ModeBase.java @@ -31,4 +31,18 @@ public class ModeBase { isDelete=0; //Log.i("日志","创建时间:"+ createTime); } + + @Override + public String toString() { + return "ModeBase{" + + "id='" + id + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", deleteTime='" + deleteTime + '\'' + + ", deviceID='" + deviceID + '\'' + + ", userID='" + userID + '\'' + + ", isDelete=" + isDelete + + ", exp='" + exp + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java b/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java index f33a8f4b..bab83b28 100644 --- a/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java +++ b/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java @@ -13,6 +13,8 @@ import android.os.SystemClock; import android.util.Log; import android.widget.Toast; +import com.bonait.bnframework.common.constant.ConfigName; + import java.io.File; import java.io.FileOutputStream; import java.io.FilenameFilter; @@ -85,6 +87,7 @@ public class CrashHandler implements UncaughtExceptionHandler { * @return true:��������˸��쳣��Ϣ; ���򷵻�false. */ private boolean handleException(Throwable ex) { + if(ConfigName.TEST) return false; if (ex == null) return false; diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java index 1ed9d6b1..e3d92169 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java @@ -1,7 +1,12 @@ package com.bonait.bnframework.common.utils; +import android.app.Activity; import android.content.Context; +import androidx.appcompat.app.AppCompatActivity; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.CustomView.XComDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; @@ -65,6 +70,16 @@ public class AlertDialogUtils { .create(mCurrentDialogStyle).show(); } + /** + * 对话框,有取消确定按钮 + * */ + public static void showCancelAndConfirmDialog(AppCompatActivity activity, XComDialog.OnDialogListener onClickListener) { + new XComDialog(activity, R.layout.dialog_with_cancel_confirm) + .init(true, true) + .setWindowSizeMax() + .setDialogListener(onClickListener); + } + /** * 对话框,自定义确定按钮 * */ diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/FileUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/FileUtils.java index 9014fef2..e8fcb5f9 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/FileUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/FileUtils.java @@ -1,7 +1,11 @@ package com.bonait.bnframework.common.utils; +import android.content.Context; +import android.content.res.AssetManager; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.BufferedReader; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; @@ -9,6 +13,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; @@ -1297,4 +1302,23 @@ public class FileUtils { } } } + + public static String getJson(String fileName, Context context) { + //将json数据变成字符串 + StringBuilder stringBuilder = new StringBuilder(); + try { + //获取assets资源管理器 + AssetManager assetManager = context.getAssets(); + //通过管理器打开文件并读取 + BufferedReader bf = new BufferedReader(new InputStreamReader( + assetManager.open(fileName))); + String line; + while ((line = bf.readLine()) != null) { + stringBuilder.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + return stringBuilder.toString(); + } } diff --git a/app/src/main/res/layout/activity_bottom_navigation_new.xml b/app/src/main/res/layout/activity_bottom_navigation_new.xml index 777c3eb7..281dba2f 100644 --- a/app/src/main/res/layout/activity_bottom_navigation_new.xml +++ b/app/src/main/res/layout/activity_bottom_navigation_new.xml @@ -39,7 +39,18 @@ app:water_mark_textSize="14px" /> - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_dishtest.xml b/app/src/main/res/layout/activity_dishtest.xml index 2d1944e9..f559d413 100644 --- a/app/src/main/res/layout/activity_dishtest.xml +++ b/app/src/main/res/layout/activity_dishtest.xml @@ -156,7 +156,14 @@ android:layout_marginLeft="25dp" android:layout_marginTop="155dp" android:orientation="horizontal"> - + + + +