diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8fe53452..334b21ad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -45,6 +45,9 @@ + { } private T _value; - public T getValue(){ return _value; } + public T getValue(){ return _value; } public void setValue(T value){ if (value != null && !value.equals(_value) || !IsFirst) { diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Executor.java b/app/src/main/java/com/bonait/bnframework/HBL/Executor.java index d2a88a88..6be2fe2a 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Executor.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Executor.java @@ -27,14 +27,11 @@ public class Executor { private ExecutorService executor= Executors.newCachedThreadPool() ; public void runThread(IRun run) { - executor.submit(new Runnable(){ - @Override - public void run() { - try { - if(run!=null)run.Run(); - }catch(Exception ex) { - MessageLog.ShowError("runThread 异常:"+ex.getMessage()); - } + executor.submit(()->{ + try { + if(run!=null)run.Run(); + }catch(Exception ex) { + MessageLog.ShowError("runThread 异常:"+ex.getMessage()); } }); } diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT.java b/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT.java index 8488b9d1..d9a438ce 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT.java @@ -3,3 +3,5 @@ package com.bonait.bnframework.HBL.Interface; public interface IRunT { void Run(T t); } + + diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT2.java b/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT2.java new file mode 100644 index 00000000..936688f3 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/HBL/Interface/IRunT2.java @@ -0,0 +1,5 @@ +package com.bonait.bnframework.HBL.Interface; + +public interface IRunT2 { + void Run(T1 t1, T2 t2);; +} diff --git a/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java b/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java new file mode 100644 index 00000000..cb9e396e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java @@ -0,0 +1,50 @@ +package com.bonait.bnframework.HBL; + +import com.bonait.bnframework.HBL.Interface.IRun; +import com.bonait.bnframework.HBL.Interface.IRunT; +import com.bonait.bnframework.HBL.Logs.MessageLog; + +import java.util.concurrent.ConcurrentHashMap; + +public class NotifyEvent { + private static volatile NotifyEvent _instance; + public synchronized static NotifyEvent get(){ + if(_instance == null)_instance = new NotifyEvent(); + return _instance; + } + private NotifyEvent(){} + private ConcurrentHashMap _runMap = new ConcurrentHashMap(); + + public void Register(String name,IRun run){ + _runMap.put(name,run); + } + + public void Register(String name, IRunT run){ + _runMap.put(name,run); + } + + public void Notify(String name){ + try{ + if(_runMap.containsKey(name)&&_runMap.get(name)!=null){ + if(_runMap.get(name) instanceof IRun){ + ((IRun)_runMap.get(name)).Run(); + } + } + }catch(Exception e){ + MessageLog.ShowError(e); + } + } + + public void Notify(String name,T value){ + try{ + if(_runMap.containsKey(name)&&_runMap.get(name)!=null){ + if(_runMap.get(name) instanceof IRunT){ + ((IRunT)_runMap.get(name)).Run(value); + } + } + }catch(Exception e){ + MessageLog.ShowError(e); + } + } + +} diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index e087cc6a..64658b1e 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -1020,36 +1020,36 @@ public class ConfigData { */ public void RevertPLCProcess() { try { - List plcaddresses = ConfigName.getInstance().PlcAddress_大炒; - List processTS = ConfigName.getInstance().Process_大炒; - - if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { - plcaddresses = ConfigName.getInstance().PlcAddress_大炒; - processTS = ConfigName.getInstance().Process_大炒; - } else if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本")) { - plcaddresses = ConfigName.getInstance().PlcAddress_大炒自动投料; - processTS = ConfigName.getInstance().Process_大炒自动投料; - } else if (ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { - plcaddresses = ConfigName.getInstance().PlcAddress_小炒; - processTS = ConfigName.getInstance().Process_小炒; - } +// List plcaddresses = ConfigName.getInstance().PlcAddress_大炒; + List processTS = ConfigName.getInstance().Process_压力锅; + +// if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { +// plcaddresses = ConfigName.getInstance().PlcAddress_大炒; +// processTS = ConfigName.getInstance().Process_大炒; +// } else if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本")) { +// plcaddresses = ConfigName.getInstance().PlcAddress_大炒自动投料; +// processTS = ConfigName.getInstance().Process_大炒自动投料; +// } else if (ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { +// plcaddresses = ConfigName.getInstance().PlcAddress_小炒; +// processTS = ConfigName.getInstance().Process_小炒; +// } //region 恢复PLC - ArrayList arrayList = QueryDB.GetPlcaddressALL(); - for (BPA_PLCADDRESS item : arrayList) { - QueryDB.DeletePlcaddress(item); - } - int k = 1; - for (Res_PLCADDRESS item : plcaddresses) { - BPA_PLCADDRESS plc = new BPA_PLCADDRESS(); - plc.name = item.name; - plc.address = item.address; - plc.isread = item.isread; - plc.iswrite = item.iswrite; - plc.sort = k; - k++; - QueryDB.AddPlcaddress(plc); - } +// ArrayList arrayList = QueryDB.GetPlcaddressALL(); +// for (BPA_PLCADDRESS item : arrayList) { +// QueryDB.DeletePlcaddress(item); +// } +// int k = 1; +// for (Res_PLCADDRESS item : plcaddresses) { +// BPA_PLCADDRESS plc = new BPA_PLCADDRESS(); +// plc.name = item.name; +// plc.address = item.address; +// plc.isread = item.isread; +// plc.iswrite = item.iswrite; +// plc.sort = k; +// k++; +// QueryDB.AddPlcaddress(plc); +// } //endregion //region 恢复工序 diff --git a/app/src/main/java/com/bonait/bnframework/business/ControlAdress.java b/app/src/main/java/com/bonait/bnframework/business/ControlAdress.java index 6c1460ab..a17b3a3b 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ControlAdress.java +++ b/app/src/main/java/com/bonait/bnframework/business/ControlAdress.java @@ -20,5 +20,16 @@ public enum ControlAdress { 允许开盖压力, 反转位时间, 防干烧温度, - 排冷气温度 + 排冷气温度, + 温度下限, + 温度上限, + 压力下限, + 压力上限, + 焖制中, + 加热档位, + 设定压力, + 计时温度, + 烹饪时间, + 烹饪完成 + } diff --git a/app/src/main/java/com/bonait/bnframework/business/Func.java b/app/src/main/java/com/bonait/bnframework/business/Func.java new file mode 100644 index 00000000..7c55d7a9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/business/Func.java @@ -0,0 +1,24 @@ +package com.bonait.bnframework.business; + +public enum Func { + /** + * 加热功能 + * par:加热温度,加热档位 + */ + 加热, + /** + * 泄压功能 + * par:泄压压力 + */ + 泄压, + /** + * 保温功能 + * par:保温温度,保温时间 + */ + 保温, + /** + *烹饪功能 + * par:烹饪温度,烹饪时间 + */ + 烹饪, +} 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 ca7e8f3c..5da51fd3 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -233,6 +233,8 @@ public class MainInit { { ConfigData.getInstance().RevertPLCProcess(); } + + ConfigData.getInstance().RevertPLCProcess(); } /** * 删除表-重新生成新表 diff --git a/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java b/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java index 127b23e0..4ae19e10 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java +++ b/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java @@ -1,10 +1,16 @@ package com.bonait.bnframework.business; import com.bonait.bnframework.HBL.Communication.Modbus.ModbusMaster; +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.OperateResultT; import com.bonait.bnframework.HBL.Thread.ThreadManager; +import com.bonait.bnframework.common.db.mode.BPA_FORMULA; +import com.bonait.bnframework.common.utils.ToastUtils; +import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public class ModbusHelper extends ModbusMaster { @@ -23,48 +29,33 @@ public class ModbusHelper extends ModbusMaster { put(ControlAdress.锅体正转,new PLCModel("M24",DefaultValue.BOOLEAN,OperationModel.W)); put(ControlAdress.锅体反转,new PLCModel("M25",DefaultValue.BOOLEAN,OperationModel.W)); put(ControlAdress.泄压阀启停,new PLCModel("M26",DefaultValue.BOOLEAN,OperationModel.W)); + put(ControlAdress.烹饪完成,new PLCModel("M32",DefaultValue.BOOLEAN,OperationModel.R)); put(ControlAdress.一键上升,new PLCModel("M0",DefaultValue.BOOLEAN,OperationModel.W)); put(ControlAdress.一键下降,new PLCModel("M1",DefaultValue.BOOLEAN,OperationModel.W)); - put(ControlAdress.一键翻转,new PLCModel("M4",DefaultValue.BOOLEAN,OperationModel.W)); put(ControlAdress.一键回位,new PLCModel("M5",DefaultValue.BOOLEAN,OperationModel.W)); put(ControlAdress.停止,new PLCModel("M6",DefaultValue.BOOLEAN,OperationModel.W)); + put(ControlAdress.焖制中,new PLCModel("----",DefaultValue.BOOLEAN,OperationModel.RW)); put(ControlAdress.心跳,new PLCModel("D204",DefaultValue.SHORT,OperationModel.W)); put(ControlAdress.当前温度,new PLCModel("D100",DefaultValue.SHORT,OperationModel.R)); put(ControlAdress.当前压力,new PLCModel("D101",DefaultValue.SHORT,OperationModel.R)); - put(ControlAdress.当前档位,new PLCModel("D103",DefaultValue.SHORT,OperationModel.RW)); - put(ControlAdress.允许开盖压力,new PLCModel("D200",DefaultValue.SHORT,OperationModel.RW)); - put(ControlAdress.反转位时间,new PLCModel("D201",DefaultValue.SHORT,OperationModel.RW)); - put(ControlAdress.防干烧温度,new PLCModel("D202",DefaultValue.SHORT,OperationModel.RW)); - put(ControlAdress.排冷气温度,new PLCModel("D203",DefaultValue.SHORT,OperationModel.RW)); + put(ControlAdress.允许开盖压力,new PLCModel("D200",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.排冷气温度,new PLCModel("D203",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.温度下限,new PLCModel("D210",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.温度上限,new PLCModel("D211",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.压力下限,new PLCModel("D213",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.压力上限,new PLCModel("D214",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.加热档位,new PLCModel("D300",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.设定压力,new PLCModel("D301",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.计时温度,new PLCModel("D303",DefaultValue.SHORT,OperationModel.W)); + put(ControlAdress.烹饪时间,new PLCModel("D304",DefaultValue.SHORT,OperationModel.W)); }}; - static ConcurrentHashMap InputModel=new ConcurrentHashMap(){{ - put(Input.锅盖上限,new PLCModel("X0",DefaultValue.BOOLEAN,OperationModel.R) ); - put(Input.锅盖下限,new PLCModel("X1",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.锅盖开启,new PLCModel("X2",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.锅盖关闭,new PLCModel("X3",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.锅体原点,new PLCModel("X4",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.锅体极限,new PLCModel("X5",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.急停,new PLCModel("X6",DefaultValue.BOOLEAN,OperationModel.R)); - put(Input.相序保护器,new PLCModel("X7",DefaultValue.BOOLEAN,OperationModel.R)); - }}; - - static ConcurrentHashMap OutPutModel=new ConcurrentHashMap(){{ - put(OutPut.锅盖上升,new PLCModel("Y0",DefaultValue.BOOLEAN,OperationModel.R) ); - put(OutPut.锅盖下降,new PLCModel("Y1",DefaultValue.BOOLEAN,OperationModel.R)); - put(OutPut.锅盖开启,new PLCModel("Y2",DefaultValue.BOOLEAN,OperationModel.R)); - put(OutPut.锅盖关闭,new PLCModel("Y3",DefaultValue.BOOLEAN,OperationModel.R)); - put(OutPut.锅体正转,new PLCModel("Y4",DefaultValue.BOOLEAN,OperationModel.R)); - put(OutPut.锅体反转,new PLCModel("Y5",DefaultValue.BOOLEAN,OperationModel.R)); - put(OutPut.泄压阀启停,new PLCModel("Y6",DefaultValue.BOOLEAN,OperationModel.R)); - }}; - - public void RtuInit(String comName,int baudRate){ - new Thread(()->{ RtuConnect(comName,baudRate).OnSource(()->{ GetPlcStatus();});}).start(); - } - - public void TcpInit(String ip,int port){ - new Thread(()->{ TcpConnect(ip,port);}).start(); + private void Sleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } private PLCModel getPLC(ControlAdress func){ @@ -76,25 +67,6 @@ public class ModbusHelper extends ModbusMaster { } } - private PLCModel getPLC(Input func){ - if(InputModel.containsKey(func)){ - return InputModel.get(func); - }else{ - MessageLog.ShowInfo("不存在控制地址:"+func.toString()); - return new PLCModel(); - } - } - - private PLCModel getPLC(OutPut func){ - if(OutPutModel.containsKey(func)){ - return OutPutModel.get(func); - }else{ - MessageLog.ShowInfo("不存在控制地址:"+func.toString()); - return new PLCModel(); - } - } - - private void GetPlcStatus(){ ThreadManager.get().StartLong("PLC变量状态",true,()->{ @@ -102,38 +74,156 @@ public class ModbusHelper extends ModbusMaster { controlAddress.forEach((key,value)->{ if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ - OperateResultT res = ReadShort(value.PlcAddress); + OperateResultT res = ReadShort(value.PlcAddress); if(res.isSuccess){ value.Value .setValue(res.Content); - ExecuteTheRecipe. ListeningValue.put(key.toString(), res.Content); } } }); - InputModel.forEach((key,value)->{ - if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ - OperateResultT res = ReadInputCoil(value.PlcAddress); - if(res.isSuccess){ - value.Value .setValue(res.Content); - ExecuteTheRecipe. ListeningValue.put(key.toString(), res.Content); - } - } - }); + Thread.sleep(1); + }); + } - OutPutModel.forEach((key,value)->{ - if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ - OperateResultT res = ReadBool(value.PlcAddress); - if(res.isSuccess){ - value.Value .setValue(res.Content); - ExecuteTheRecipe. ListeningValue.put(key.toString(), res.Content); - } - } - }); + public NotifyPropVar IsRunning=new NotifyPropVar(false); + public void RtuInit(String comName,int baudRate){ + new Thread(()->{ RtuConnect(comName,baudRate).OnSource(()->{ GetPlcStatus();});}).start(); + } - Thread.sleep(1); - }); + /** + * 写入系统参数到PLC + * @param func + * @param value + */ + public void WritePar(ControlAdress func,short value){ + if(controlAddress.containsKey(func)){ + WriteShort(controlAddress.get(func).PlcAddress,value); + } + } + + /** + * 写入订单数据到PLC + * @param formula + */ + public void WriteOrder(BPA_FORMULA formula){ + try{ + if(formula==null)return; + WriteShort(controlAddress.get(ControlAdress.加热档位).PlcAddress,(short)(formula.HeatingGear)); + WriteShort(controlAddress.get(ControlAdress.设定压力).PlcAddress,(short)(formula.ReliefPressure)); + WriteShort(controlAddress.get(ControlAdress.计时温度).PlcAddress,(short)(formula.TimingTemperature)); + WriteShort(controlAddress.get(ControlAdress.烹饪时间).PlcAddress,(short)(formula.CookingTime*10)); + ToastUtils.info("开始执行配方:"+formula.Name); + IsRunning.setValue(true); + }catch(Exception e){ + MessageLog.ShowError(e); + } + } + + /** + * 设置变量监听通知 + * @param func + * @param action + * @param + */ + public void setPLCNotify(ControlAdress func, IRunT action){ + if(controlAddress.containsKey(func)){ + controlAddress.get(func).Value.ChangeNotify=action; + } + } + + /** + * 写布尔信号 + * @param func + * @param value + */ + public void WriteBoolSingle(ControlAdress func, Boolean value){ + if(controlAddress.containsKey(func)){ + Executor.get().runThread(()->{ + WriteBool(controlAddress.get(func).PlcAddress,value); + }); + } } + /** + * 写脉冲信号 + * @param func + */ + public void PulseSignal(ControlAdress func){ + if(controlAddress.containsKey(func)){ + Executor.get().runThread(()->{ + WriteBool(controlAddress.get(func).PlcAddress,true); + Sleep(1000); + WriteBool(controlAddress.get(func).PlcAddress,false); + }); + } + } } + + + + + +// static ConcurrentHashMap InputModel=new ConcurrentHashMap(){{ +// put(Input.锅盖上限,new PLCModel("X0",DefaultValue.BOOLEAN,OperationModel.R) ); +// put(Input.锅盖下限,new PLCModel("X1",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.锅盖开启,new PLCModel("X2",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.锅盖关闭,new PLCModel("X3",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.锅体原点,new PLCModel("X4",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.锅体极限,new PLCModel("X5",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.急停,new PLCModel("X6",DefaultValue.BOOLEAN,OperationModel.R)); +// put(Input.相序保护器,new PLCModel("X7",DefaultValue.BOOLEAN,OperationModel.R)); +// }}; +// +// static ConcurrentHashMap OutPutModel=new ConcurrentHashMap(){{ +// put(OutPut.锅盖上升,new PLCModel("Y0",DefaultValue.BOOLEAN,OperationModel.R) ); +// put(OutPut.锅盖下降,new PLCModel("Y1",DefaultValue.BOOLEAN,OperationModel.R)); +// put(OutPut.锅盖开启,new PLCModel("Y2",DefaultValue.BOOLEAN,OperationModel.R)); +// put(OutPut.锅盖关闭,new PLCModel("Y3",DefaultValue.BOOLEAN,OperationModel.R)); +// put(OutPut.锅体正转,new PLCModel("Y4",DefaultValue.BOOLEAN,OperationModel.R)); +// put(OutPut.锅体反转,new PLCModel("Y5",DefaultValue.BOOLEAN,OperationModel.R)); +// put(OutPut.泄压阀启停,new PLCModel("Y6",DefaultValue.BOOLEAN,OperationModel.R)); +// }}; + + + +// InputModel.forEach((key,value)->{ +// if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ +// OperateResultT res = ReadInputCoil(value.PlcAddress); +// if(res.isSuccess){ +// value.Value .setValue(res.Content); +// ExecuteTheRecipe. ListeningValue.put(key.toString(), res.Content); +// } +// } +// }); +// +// OutPutModel.forEach((key,value)->{ +// if(value.operationModel== OperationModel.R||value.operationModel==OperationModel.RW){ +// OperateResultT res = ReadBool(value.PlcAddress); +// if(res.isSuccess){ +// value.Value .setValue(res.Content); +// ExecuteTheRecipe. ListeningValue.put(key.toString(), res.Content); +// } +// } +// }); + + + +// private PLCModel getPLC(Input func){ +// if(InputModel.containsKey(func)){ +// return InputModel.get(func); +// }else{ +// MessageLog.ShowInfo("不存在控制地址:"+func.toString()); +// return new PLCModel(); +// } +// } +// +// private PLCModel getPLC(OutPut func){ +// if(OutPutModel.containsKey(func)){ +// return OutPutModel.get(func); +// }else{ +// MessageLog.ShowInfo("不存在控制地址:"+func.toString()); +// return new PLCModel(); +// } +// } \ No newline at end of file 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 0c55a490..c9e837a4 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 @@ -4,6 +4,7 @@ import android.app.Application; import android.content.Context; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.Func; import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.db.mode.BPA_USER; import com.bonait.bnframework.common.db.mode.Res_PLCADDRESS; @@ -381,6 +382,16 @@ public class ConfigName { add(new ProcessT("出菜", Arrays.asList("等待(秒)"))); }}; + /** + * 压力锅工序模型 + */ + public List Process_压力锅 = new ArrayList() {{ + add(new ProcessT(Func.加热.toString(), Arrays.asList("加热温度", "加热档位"))); + add(new ProcessT(Func.泄压.toString(), Arrays.asList("泄压压力"))); + add(new ProcessT(Func.保温.toString(), Arrays.asList("保温温度", "保温时间"))); + add(new ProcessT(Func.烹饪.toString(), Arrays.asList("烹饪温度", "烹饪时间"))); + }}; + /** * 大炒自动投料基础PLC模型 */ @@ -823,7 +834,7 @@ public class ConfigName { data = "1号位、2号位、3号位、4号位"; } else if (item.equals("正转速度") || item.equals("反转速度") || item.equals("转动速度") || item.equals("搅拌速度")) { data = "停止、最低、低速、中速、高速、最高、极高"; - } else if (item.equals("加热功率") || item.equals("热锅功率")) { + } else if (item.equals("加热功率") || item.equals("热锅功率")||item.equals("加热档位")) { data = "停止、一档、二档、三档、四档、五档、六档、七档、八档"; } return data; diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java index 37d81e43..a124a4e4 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java @@ -29,4 +29,6 @@ public interface MessageName { String OpenMakeGoodFrom="OpenMakeGoodFrom";//打开制作界面 String GoodIsCunZai="GoodIsCunZai"; + + String OpenDeviceFrom="OpenDeviceFrom";//打开设备页面 } 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..6608af2b 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,9 +6,13 @@ import android.database.sqlite.SQLiteDatabase; import android.util.Log; import android.widget.TableRow; +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.common.constant.ConfigName; import com.bonait.bnframework.common.db.file.DBHelper; import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; +import com.bonait.bnframework.common.db.mode.BPA_FORMULA; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.file.DBHelper; import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; @@ -47,6 +51,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -2404,7 +2409,6 @@ public class QueryDB { } //endregion - //region BPA_PLCADDRESS PLC地址管理表 /** * 新增工序模型表 @@ -2864,6 +2868,16 @@ 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_FORMULA": + data = new BPA_FORMULA(); + //私有 + ((BPA_FORMULA) data).Name = cursor.getString( (int)cursor.getColumnIndex("Name")); + ((BPA_FORMULA) data).Url = cursor.getString( (int)cursor.getColumnIndex("Url")); + ((BPA_FORMULA) data).HeatingGear = cursor.getInt((int) cursor.getColumnIndex("HeatingGear")); + ((BPA_FORMULA) data).TimingTemperature = cursor.getInt((int) cursor.getColumnIndex("TimingTemperature")); + ((BPA_FORMULA) data).CookingTime = cursor.getInt((int) cursor.getColumnIndex("CookingTime")); + ((BPA_FORMULA) data).ReliefPressure = cursor.getInt((int) cursor.getColumnIndex("ReliefPressure")); + break; } ((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); ((ModeBase) data).createTime = cursor.getString((int) cursor.getColumnIndex("createTime")); @@ -2878,6 +2892,7 @@ public class QueryDB { cursor.close(); db.close(); } catch (Exception e) { + MessageLog.ShowError(e); Log.d("查询异常", "查询异常: " + e.getMessage()); db.close(); } finally { @@ -2886,4 +2901,118 @@ public class QueryDB { return rlts; } //endregion + + //region 压力锅配方数据 + + /** + * 检查名称是否存在 + * @param name + * @return + */ + public static boolean checkName(String name){ + try{ + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and Name=?"; + String[] args = new String[]{"0", name}; + List data = new ArrayList<>(); + ArrayList obj = Get(BPA_FORMULA.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_FORMULA) k); + } + return data.size() > 0; + }catch(Exception e){ + return false; + } + } + + /** + * 获取所有配方数据 + * @return + */ + public static OperateResultT> getFormulaAll(){ + try{ + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + List data = new ArrayList<>(); + ArrayList obj = Get(BPA_FORMULA.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_FORMULA) k); + } + return OperateResultT.CreateSuccess(data); + }catch(Exception e){ + return OperateResultT.CreateFailedT(e); + } + } + + public static OperateResultT getFormula(String id){ + try{ + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0", id}; + List data = new ArrayList<>(); + List obj = Get(BPA_FORMULA.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_FORMULA) k); + } + if (data.size() > 0) { + return OperateResultT.CreateSuccess(data.get(0)); + } else { + return OperateResultT.CreateFailedT("未查询到有效的数据"); + } + }catch(Exception e){ + return OperateResultT.CreateFailedT(e); + } + } + + /** + * 添加配方数据 + * @return + */ + public static OperateResult addFormula(BPA_FORMULA formula){ + try{ + if(formula == null)return OperateResult.CreateFailed("对象内容不正确"); + boolean isName = checkName(formula.Name); + if(isName)return OperateResult.CreateFailed("名称已存在"); + boolean res = Add(BPA_FORMULA.class, formula); + if(res) return OperateResult.CreateSuccess(); + else return OperateResult.CreateFailed("添加数据失败"); + }catch(Exception e){ + return OperateResult.CreateFailed(e); + } + } + + /** + * 修改配方数据 + * @param formula + * @return + */ + public static OperateResult UpdataFormula(BPA_FORMULA formula){ + try{ + if(formula == null)return OperateResult.CreateFailed("对象内容不正确"); + boolean isName = checkName(formula.Name); + if(isName)return OperateResult.CreateFailed("名称已存在"); + boolean res = Update(BPA_FORMULA.class, formula); + if(res) return OperateResult.CreateSuccess(); + else return OperateResult.CreateFailed("修改数据失败"); + }catch(Exception e){ + return OperateResult.CreateFailed(e); + } + } + + /** + * 删除数据配方 + * @param id + * @return + */ + public static OperateResult ReamoveFormula(String id){ + try{ + boolean res = Delete(BPA_FORMULA.class, id); + if(res) return OperateResult.CreateSuccess(); + else return OperateResult.CreateFailed("删除数据失败"); + }catch(Exception e){ + return OperateResult.CreateFailed(e); + } + } + //endregion } 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..9c333745 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 @@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteOpenHelper; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA; +import com.bonait.bnframework.common.db.mode.BPA_FORMULA; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; import com.bonait.bnframework.common.db.mode.BPA_CRAFT; @@ -125,6 +126,8 @@ public class DBHelper extends SQLiteOpenHelper { CreateTablesAll(BPA_CLOUDDATA.class,null);//云端表 CreateTablesAll(BPA_PLCADDRESS.class,null);//工序模型表 + CreateTablesAll(BPA_FORMULA.class,null);//压力锅配方参数表 + ForeignKeys(); } /** diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_FORMULA.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_FORMULA.java new file mode 100644 index 00000000..531f6f95 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_FORMULA.java @@ -0,0 +1,58 @@ +package com.bonait.bnframework.common.db.mode; + +/** + * 压力锅配方参数表 + */ +public class BPA_FORMULA extends ModeBase{ + /** + * 配方名称 + */ + public String Name; + + /** + * 商品Url + */ + public String Url; + + /** + * 加热档位 + */ + public int HeatingGear; + + /** + * 计时温度 + */ + public int TimingTemperature; + + /** + * 烹饪时间 + */ + public int CookingTime; + + /** + * 泄压压力 + */ + public int ReliefPressure; + + /** + * 创建配方数据 + * @param name 配方名称 + * @param url 图片地址 + * @param heatingGear 加热档位 + * @param timingsTemperature 计时温度 + * @param cookingTime 烹饪时间 + * @param reliefPressure 泄压压力 + */ + public BPA_FORMULA(String name,String url,int heatingGear,int timingsTemperature,int cookingTime,int reliefPressure){ + Name = name; + HeatingGear = heatingGear; + TimingTemperature = timingsTemperature; + CookingTime =cookingTime; + ReliefPressure = reliefPressure; + Url = url; + } + + public BPA_FORMULA(){ + + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java index 56180bf2..883208db 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java @@ -1,19 +1,22 @@ package com.bonait.bnframework.modules.home.activity; -import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.ViewPager; import android.app.Activity; import android.os.Bundle; -import android.util.Log; import android.view.KeyEvent; -import android.view.MenuItem; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; +import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; +import com.bonait.bnframework.HBL.Dialog.DialogManager; +import com.bonait.bnframework.HBL.Interface.IRunT2; +import com.bonait.bnframework.HBL.NotifyEvent; +import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ControlAdress; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.business.ModbusHelper; import com.bonait.bnframework.common.base.BaseActivity; @@ -31,20 +34,14 @@ import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.BottomNavigationBar; import com.bonait.bnframework.manager.ActivityLifecycleManager; import com.bonait.bnframework.modules.home.adapter.FragmentAdapter; -import com.bonait.bnframework.modules.home.fragment.Home1Fragment; -import com.bonait.bnframework.modules.home.fragment.Home2Fragment; import com.bonait.bnframework.modules.home.fragment.Home4Fragment; +import com.bonait.bnframework.modules.home.fragment.HomeFragmentDevice; import com.bonait.bnframework.modules.home.fragment.HomeFragmentPR; -import com.bonait.bnframework.modules.home.fragment.HomeFragmentSBKZ; import com.bonait.bnframework.modules.home.fragment.from.CookingActivity; -import com.bonait.bnframework.modules.mine.fragment.MyFragment; -import com.google.android.material.bottomnavigation.BottomNavigationView; import com.lzy.okgo.OkGo; import com.qmuiteam.qmui.widget.QMUIViewPager; import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -119,7 +116,7 @@ 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 HomeFragmentDevice()); viewPager.setAdapter(fragmentAdapter); MessageManager.getInstance().registerMessageReceiver(this, MessageName.SelectZY, new MessageLooper.OnMessageListener() { @@ -134,17 +131,8 @@ public class BottomNavigationNewActivity extends BaseActivity { } }); - //打开制作界面 - MessageManager.getInstance().registerMessageReceiver(this, MessageName.OpenMakeGoodFrom, new MessageLooper.OnMessageListener() { - @Override - public void onMessage(Object msg) { - if (msg != null) { - String id = (String) msg; - goods = QueryDB.GetGoodsId(id); - cooking.initData(goods, activity, myClickListener); - cooking.setVisibility(View.VISIBLE); - } - } + NotifyEvent.get().Register(MessageName.OpenDeviceFrom,()->{ + this.runOnUiThread(()->{viewPager.setCurrentItem(2);}); }); } @@ -193,8 +181,7 @@ public class BottomNavigationNewActivity extends BaseActivity { * * @param view */ - @OnClick({R.id.penrenzhong - }) + @OnClick({R.id.penrenzhong}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.penrenzhong: @@ -232,55 +219,16 @@ public class BottomNavigationNewActivity extends BaseActivity { ConfigData.getInstance().ToggleEnvironment(); //2.初始化PLC ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600); -// ReconnectModbus(); - //制作线程 - MakeThread(); - //初始化阿里云连接 - //AliyunIOTManager.getInstance().OpenDev(this); - } - /** - * 重新连接plc - */ - public void ReconnectModbus() { -// try { -// -// ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { -// @Override -// public void Run() throws InterruptedException { -// try { -// if (ConfigName.getInstance().PlcIsConnect) { -// //ping 不通 -// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); -// if (!status) //ping 不通 连接 -// { -// MessageLog.ShowInfo("PLC状态断开,尝试连接..."); -// ConfigName.getInstance().PlcIsConnect = false; -// } -// } else { -// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); -// if (status) { -// MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); -// ModbusTcpServer.ConnectPLC(); -// } else { -// MessageLog.ShowInfo("PLC状态断开,尝试连接..."); -// ConfigName.getInstance().PlcIsConnect = false; -// } -// } -// Thread.sleep(10000); -// } catch (Exception e) { -// Log.i("PLC", "PLC重连接失败!" + e.getMessage()); -// } -// } -// -// @Override -// public void RunComplete() throws InterruptedException { -// } -// }); -// } catch (Exception e) { -// MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage()); -// } + ModbusHelper.get().setPLCNotify(ControlAdress.烹饪完成,(s)->{ + if(s){ + DialogManager.showInfo(this,"烹饪完成,请及时查看!", AlertDialogButton.OK,(result)->{ + ModbusHelper.get().WriteBoolSingle(ControlAdress.烹饪完成,false); + }); + } + }); } + //endregion //region 制作 @@ -290,184 +238,16 @@ public class BottomNavigationNewActivity extends BaseActivity { //商品 public BPA_GOODS goods = null; - /** - * 商品制作线程 - */ - public void MakeThread() { - ExecuteTheRecipe.context = this; - new Thread(new Runnable() { - @Override - public void run() { - while (true) { - try { - if (ExecuteTheRecipe.IsStart && goods != null) { - long startTime= System.currentTimeMillis(); //起始时间 - try { - //获取工艺 - ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id); - goodsrecipesL = goodsrecipes; - gongxuIndex = 1; - int m = 0; - for (BPA_GOODSRECIPE item : goodsrecipes) { - while (ExecuteTheRecipe.IsPause) - { - ToastUtils.info("客官,当前菜品已暂停炒制!!!"); - Thread.sleep(1000); - } - MakeCipe = item; - gongxuIndex++; - runOnUiThread(new Runnable() { - @Override - public void run() { - cooking.SetMiaoShu("正在执行:" + item.processms); - } - }); - boolean status = ExecuteTheRecipe.Execute(item, goodsrecipes, m); - m++; - } - } catch (Exception ex) { - ToastUtils.error("异常信息:" + ex.getMessage()); - } finally { -// ExecuteTheRecipe.WritePLC("搅拌", false, null); -// ExecuteTheRecipe.WritePLC("加热", false, null); - ConfigName.getInstance().IsOpenHuoLi = false; - ExecuteTheRecipe.BottomClick("平移-去1号位"); - gongxuIndex = 10000; - MakeCipe = null; - goodsrecipesL = null; - ExecuteTheRecipe.IsStart = false; - - long endTime = System.currentTimeMillis(); //结束时间 - int time=(int) ((endTime-startTime)/1000); - Log.e("运行时长",String.format("方法使用时间 %d s",time)); - - if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(goods.id,time);} - - ExecuteTheRecipe.all_list=new ArrayList<>(); - runOnUiThread(new Runnable() { - @Override - public void run() { - onRecordStop(); - if (ExecuteTheRecipe.IsForcedEnd)//强制结束 - { - ToastUtils.info("客官,当前菜品已强制结束!!!"); - //初始化 - ExecuteTheRecipe.BottomClick("初始化"); - } - } - }); - } - } - Thread.sleep(1000); - } 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()); - } - } + private void analysis(String[] funcs, IRunT2 action){ + for(int i=0;isetPLCNotify(ControlAdress.当前温度,(s)->{ + activity.runOnUiThread(()->{tv_temperature.setText("温度:"+ String.format("%.2f",s/10f) +" ℃");}); + }); + + ModbusHelper.get().setPLCNotify(ControlAdress.当前压力,(s)->{ + activity.runOnUiThread(()->{tv_pressure.setText("压力:"+ String.format("%.2f",s/10f) +" kpa");}); + }); + + ModbusHelper.get().IsRunning.ChangeNotify=(s)->{ + activity.runOnUiThread(()->{ + BtnEnable(!s); + }); + }; + + btn_PotLid_Up.setOnTouchListener(touchListener); + btn_PotLid_Down.setOnTouchListener(touchListener); + btn_PotLid_Open.setOnTouchListener(touchListener); + btn_PotLid_Close.setOnTouchListener(touchListener); + btn_PotBody_Forward.setOnTouchListener(touchListener); + btn_PotBody_Reversal.setOnTouchListener(touchListener); + btn_PressureReliefValve.setOnTouchListener(touchListener); + } + + private void BtnEnable(boolean value){ + btn_PotLid_Up.setEnabled(value); + btn_PotLid_Down.setEnabled(value); + btn_PotLid_Open.setEnabled(value); + btn_PotLid_Close.setEnabled(value); + btn_PotBody_Forward.setEnabled(value); + btn_PotBody_Reversal.setEnabled(value); + btn_PressureReliefValve.setEnabled(value); + btn_OneKey_Up.setEnabled(value); + btn_OneKey_Down.setEnabled(value); + btn_OneKey_Home.setEnabled(value); + + btn_PotLid_Up.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PotLid_Down.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PotLid_Open.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PotLid_Close.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PotBody_Forward.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PotBody_Reversal.setTextColor(value?Color.WHITE: Color.GRAY); + btn_PressureReliefValve.setTextColor(value?Color.WHITE: Color.GRAY); + btn_OneKey_Up.setTextColor(value?Color.WHITE: Color.GRAY); + btn_OneKey_Down.setTextColor(value?Color.WHITE: Color.GRAY); + btn_OneKey_Home.setTextColor(value?Color.WHITE: Color.GRAY); + } + + @OnClick({R.id.btn_OneKey_Up, R.id.btn_OneKey_Down, R.id.btn_OneKey_Home, R.id.btn_Stop}) + public void onViewClicked(View view) { + if(!ModbusHelper.get().getConnected()){ + DialogManager.showWarn(activity,"设备未连接,请连接后重试!", AlertDialogButton.OK,null); + return ; + } + switch (view.getId()) { + case R.id.btn_OneKey_Up: + ModbusHelper.get().PulseSignal(ControlAdress.一键上升); + break; + case R.id.btn_OneKey_Down: + ModbusHelper.get().PulseSignal(ControlAdress.一键下降); + break; + case R.id.btn_OneKey_Home: + ModbusHelper.get().PulseSignal(ControlAdress.一键回位); + break; + case R.id.btn_Stop: + DialogManager.showWarn(activity,"请问是否停止当前正在焖制的任务?",AlertDialogButton.OKCancel,(s)->{ + if(s){ + ModbusHelper.get().PulseSignal(ControlAdress.停止); + ModbusHelper.get().IsRunning.setValue(false); + } + }); + break; + } + } + + public View.OnTouchListener touchListener = new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + + if(!ModbusHelper.get().getConnected()){ + if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){ + DialogManager.showWarn(activity,"设备未连接,请连接后重试!", AlertDialogButton.OK,null); + } + return false; + } + + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + InchingControl(view,true);//手指按下 + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + InchingControl(view,false);//手指松开 + } + return false; + } + }; + + public void InchingControl(View view,Boolean IsChick) + { + switch (view.getId()) { + case R.id.btn_PotLid_Up: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅盖上升,IsChick); + break; + case R.id.btn_PotLid_Down: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅盖下降,IsChick); + break; + case R.id.btn_PotLid_Open: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅盖开启,IsChick); + break; + case R.id.btn_PotLid_Close: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅盖关闭,IsChick); + break; + case R.id.btn_PotBody_Forward: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅体正转,IsChick); + break; + case R.id.btn_PotBody_Reversal: + ModbusHelper.get().WriteBoolSingle(ControlAdress.锅体反转,IsChick); + break; + case R.id.btn_PressureReliefValve: + ModbusHelper.get().WriteBoolSingle(ControlAdress.泄压阀启停,IsChick); + break; + } + } + + /** + * 当在activity设置viewPager + BottomNavigation + fragment时, + * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, + * 必须加上此方法,禁止fragment左滑返回上一界面。 + *

+ * 切记!切记!切记!否则会闪退! + *

+ * 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 + */ + @Override + protected boolean canDragBack() { + return false; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java index 9bdd5366..b89033fb 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java @@ -23,9 +23,16 @@ import android.view.View; import android.widget.RelativeLayout; import android.widget.TextView; +import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; +import com.bonait.bnframework.HBL.Dialog.DialogManager; +import com.bonait.bnframework.HBL.Executor; +import com.bonait.bnframework.HBL.Logs.MessageLog; +import com.bonait.bnframework.HBL.NotifyEvent; +import com.bonait.bnframework.MainApplication; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.business.ModbusHelper; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; @@ -102,7 +109,7 @@ public class HomeFragmentPR extends BaseFragment { activity = getActivity(); initTopBar(); SelectTab(1); - + NotifyEvent.get().Register("商品信息刷新",()->{initData();}); } @SuppressLint("HandlerLeak") @@ -122,57 +129,6 @@ public class HomeFragmentPR extends BaseFragment { mTopBar.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.topbj1)); mTopBar.setTitle("菜谱"); mTopBar.addRightTextButton("设备状态:"+(ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"),R.id.status_image); - - new Thread(new Runnable() { - @Override - public void run() { - while (true) - { - try { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - mTopBar.removeAllRightViews(); - mTopBar.addRightTextButton("设备状态:"+(ConfigName.getInstance().PlcIsConnect ? "已连接" : "未连接"),R.id.status_image); - } - }); - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - } - }).start(); - /** - * 刷新菜品 - */ - MessageManager.getInstance().registerMessageReceiver(activity, MessageName.GetOrganize, new MessageLooper.OnMessageListener() { - @Override - public void onMessage(Object msg) { - if (msg != null && isAdded()) { - ConfigData.getInstance().GetGevGood(context, mHandler); - } - } - }); - /** - * 刷新菜品 - */ - MessageManager.getInstance().registerMessageReceiver(activity, MessageName.ScGood, new MessageLooper.OnMessageListener() { - @Override - public void onMessage(Object msg) { - if (msg != null && isAdded()) { - String str = (String) msg; - if (str.equals("Good")) { - initData(); - if (qupenren.getVisibility() == View.VISIBLE) { - qupenren.RefreshData(); - } - } else { - ConfigData.getInstance().GetGevGood(context, mHandler); - } - } - } - }); - search_view.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { @@ -187,44 +143,29 @@ public class HomeFragmentPR extends BaseFragment { }); } + + /** * 初始化显示数据 */ private void initData() { - StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager - (3, StaggeredGridLayoutManager.VERTICAL); + StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recycler_view.setLayoutManager(layout); - ArrayList good = new ArrayList<>(); - String name = search_view.getQuery().toString(); - if (name.isEmpty()) { - good = QueryDB.GetGoodsALL(); - } else { - good = QueryDB.GetGoodsLike(name); - } - - List Bendi_id = new ArrayList<>(); - ArrayList contents_bdcp = new ArrayList<>(); - ArrayList contents_ydcp = new ArrayList<>(); - for (BPA_GOODS item : good) { - if (item.url == null) { - item.url = "未知"; + QueryDB.getFormulaAll().OnFinally(s->{ + if(s.isSuccess){ + ArrayList contents_bdcp = new ArrayList<>(); + s.Content.forEach(item->{ + if (item.Url == null) {item.Url = "未知"; } + contents_bdcp.add(new SectionItem(item.Name, "", item.id, item.Url, false, false, true)); + }); + good_adapter adapter = new good_adapter(context, contents_bdcp, myClickListener); + recycler_view.setAdapter(adapter); + }else{ + MessageLog.ShowError(s.message); } - contents_bdcp.add(new SectionItem(item.name, String.valueOf(item.maketime), item.id, item.url, item.issc == 1, false, true)); - Bendi_id.add(item.id); - } - - for (CloudGood item : ConfigName.getInstance().cloudGoods) { - contents_ydcp.add(new SectionItem(item.goods_Name, "180", item.id, item.goods_ImgUrl, false, true, Bendi_id.contains(item.id) ? true : false)); - } + }); - if (SelectIndex == 1) { - good_adapter adapter = new good_adapter(context, contents_bdcp, myClickListener); - recycler_view.setAdapter(adapter); - } else { - good_adapter adapter = new good_adapter(context, contents_ydcp, myClickListener); - recycler_view.setAdapter(adapter); - } } public MyClickListener myClickListener = new MyClickListener() { @@ -240,8 +181,7 @@ public class HomeFragmentPR extends BaseFragment { switch (k) { case 1: - QueryDB.DeleteGoodsid(goodid); - QueryDB.DeleteGoodsSrecipeList(goodid); + QueryDB.ReamoveFormula(goodid); initData(); break; case 2: @@ -252,6 +192,7 @@ public class HomeFragmentPR extends BaseFragment { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("id", goodid); startActivity(intent); + qupenren.setVisibility(View.GONE); break; case 99: Intent intent1 = new Intent(getContext(), CookingSimulatedActivity.class); @@ -262,14 +203,29 @@ public class HomeFragmentPR extends BaseFragment { case 4: //打开查看窗体 qupenren.SetData(item, myClickListener); qupenren.setVisibility(View.VISIBLE); + DiyUpdate1Activity.SelectId=goodid; break; case 5: //打开制作窗体 //判断是否正在制作 - if (ExecuteTheRecipe.IsStart) { - ToastUtils.warning("请耐心等待商品制作结束!!!"); - } else { - MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, goodid); - qupenren.setVisibility(View.GONE); + + if(ModbusHelper.get().IsRunning.getValue()){ + DialogManager.showWarn(context,"制作中,请稍后后再试!", AlertDialogButton.OK,null); + }else{ + if(ModbusHelper.get().getConnected()){ + DialogManager.showInfo(context,"是否开始制作商品?", AlertDialogButton.YesNo,(s)->{ + if(s){ + QueryDB.getFormula(goodid).OnSource(order->{ + Executor.get().runThread(()->{ + ModbusHelper.get().WriteOrder(order.Content); + getActivity().runOnUiThread( ()->{qupenren.setVisibility(View.GONE);}); + NotifyEvent.get().Notify(MessageName.OpenDeviceFrom); + }); + }); + } + }); + }else{ + DialogManager.showWarn(context,"设备未连接,请连接后重试!", AlertDialogButton.OK,null); + } } break; case 0://关闭窗体 @@ -285,8 +241,7 @@ public class HomeFragmentPR extends BaseFragment { * * @param view */ - @OnClick({R.id.quanbucaipu, R.id.yunduancaipu - }) + @OnClick({R.id.quanbucaipu, R.id.yunduancaipu}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.quanbucaipu: diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java index 892fb99f..177f9963 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java @@ -13,6 +13,7 @@ import android.view.View; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; @@ -20,11 +21,17 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.Spinner; +import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; +import com.bonait.bnframework.HBL.Dialog.DialogManager; +import com.bonait.bnframework.HBL.NotifyEvent; +import com.bonait.bnframework.HBL.Result.OperateResult; +import com.bonait.bnframework.HBL.Result.OperateResultT; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_FORMULA; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; @@ -66,13 +73,35 @@ public class DiyUpdate1Activity extends BaseActivity { @BindView(R.id.check) CheckBox check;//默认收藏 @BindView(R.id.hrgx) - Spinner hrgx;//工序 + Spinner hrgx;//档位 + + @BindView(R.id.shengchengnewcaipu) + Button shengchengnewcaipu; + + /** + * 加热计时温度 + */ + @BindView(R.id.Timing_Temperature) + EditText et_Timing_Temperature; + + /** + * 泄压压力 + */ + @BindView(R.id.Relief_Pressure) + EditText et_Relief_Pressure; + + /** + * 烹饪时间 + */ + @BindView(R.id.Cooking_Time) + EditText et_Cooking_Time; + Map hrgx_map = new LinkedHashMap<>(); Map hrgx_map_index = new LinkedHashMap<>(); - @BindView(R.id.gxchid) - LinearLayout gxchid;//工序子集 - @BindView(R.id.datatab_gxbz) - ListView datatab_gxbz;//工序步骤 +// @BindView(R.id.gxchid) +// LinearLayout gxchid;//工序子集 +// @BindView(R.id.datatab_gxbz) +// ListView datatab_gxbz;//工序步骤 public gongxubuzhou_adapter gxbz_adapter = null; /** * 工序步骤 @@ -86,7 +115,10 @@ public class DiyUpdate1Activity extends BaseActivity { /** * 当前商品 */ - public BPA_GOODS good = null; + public BPA_FORMULA good = null; + + public String ImageUrl; + public static String SelectId; @Override protected void onCreate(Bundle savedInstanceState) { @@ -96,71 +128,67 @@ public class DiyUpdate1Activity extends BaseActivity { initTopBar(); initData(); SetGood(); + + + + } private void initData() { - //1.初始化轮播图 - //Drawable_Get(Banner_list); - //2.初始化工序 - ArrayList data = QueryDB.GetProcessALL(); - int i = 0; - String id = ""; - for (BPA_PROCESS item : data) { - hrgx_map.put(item.name, item.id); - hrgx_map_index.put(item.name, i); - if (i == 0) { - id = item.id; - } - i++; + + List spinners = new ArrayList(); + for (int i =1;i<=8;i++){ + spinners.add(i); } - ArrayAdapter adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); + ArrayAdapter adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, spinners); adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); hrgx.setAdapter(adapter_kk); - hrgx.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View view, MotionEvent motionEvent) { - isUserClicked = true; - view.performClick(); - return false; - } - }); - hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - if (isUserClicked)//不是用户点击返回 - { - String id = hrgx_map.get(hrgx.getSelectedItem().toString()); - SelectItemFrom(id); - isUserClicked = false; - } - } - - @Override - public void onNothingSelected(AdapterView adapterView) { - } - }); - SelectItemFrom(id); +// hrgx.setOnTouchListener(new View.OnTouchListener() { +// @Override +// public boolean onTouch(View view, MotionEvent motionEvent) { +// isUserClicked = true; +// view.performClick(); +// return false; +// } +// }); +// hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { +// @Override +// public void onItemSelected(AdapterView adapterView, View view, int i, long l) { +// if (isUserClicked)//不是用户点击返回 +// { +// String id = hrgx_map.get(hrgx.getSelectedItem().toString()); +// SelectItemFrom(id); +// isUserClicked = false; +// } +// } +// +// @Override +// public void onNothingSelected(AdapterView adapterView) { +// } +// }); +// SelectItemFrom(1); //3.工序步骤 - gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item1, (List) bpa_goodsrecipes, null); - datatab_gxbz.setAdapter(gxbz_adapter); - datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long l) { - // TODO Auto-generated method stub - gxbz_adapter.setSelectedPosition(position); - gxbz_adapter.notifyDataSetInvalidated(); - - SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 - } - }); +// gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item1, (List) bpa_goodsrecipes, null); +// datatab_gxbz.setAdapter(gxbz_adapter); +// datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { +// @Override +// public void onItemClick(AdapterView parent, View view, int position, long l) { +// // TODO Auto-generated method stub +// gxbz_adapter.setSelectedPosition(position); +// gxbz_adapter.notifyDataSetInvalidated(); +// +// SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 +// } +// }); //图标选择 MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickImage, new MessageLooper.OnMessageListener() { @Override public void onMessage(Object msg) { if (msg != null) { - good.url = (String) msg; - new MyBitmapUtils().disPlay(cpfm, good.url); + good.Url = (String) msg; + ImageUrl=(String) msg; + new MyBitmapUtils().disPlay(cpfm, good.Url); } } }); @@ -181,60 +209,60 @@ public class DiyUpdate1Activity extends BaseActivity { }); } - /** - * 根据选中步骤显示变量 - * - * @param goodsrecipe - */ - public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) { - try { - //1.根据工序名称显示工序集合 - hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname)); - String id = hrgx_map.get(hrgx.getSelectedItem().toString()); - SelectItemFrom(id); - - //2.根据工序变量集合-获取变量名称和值 - final HashMap formulation = new HashMap<>(); - //region 获取变量名称和值 - String text = goodsrecipe.processvalue; - 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 - - //3.查询子集-填充变量 - for (Map.Entry entry : formulation.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - String STR = formulation.get(key); - } - - for (int i = 0; i < gxchid.getChildCount(); i++) { - fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); - String res = formulation.get(gongxu.model.name); - if (res != null) { - gongxu.SetValues(res); - } - } - } catch (Exception ex) { - } - } +// /** +// * 根据选中步骤显示变量 +// * +// * @param goodsrecipe +// */ +// public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) { +// try { +// //1.根据工序名称显示工序集合 +// hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname)); +// String id = hrgx_map.get(hrgx.getSelectedItem().toString()); +// SelectItemFrom(id); +// +// //2.根据工序变量集合-获取变量名称和值 +// final HashMap formulation = new HashMap<>(); +// //region 获取变量名称和值 +// String text = goodsrecipe.processvalue; +// 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 +// +// //3.查询子集-填充变量 +// for (Map.Entry entry : formulation.entrySet()) { +// String key = entry.getKey(); +// String value = entry.getValue(); +// String STR = formulation.get(key); +// } +// +//// for (int i = 0; i < gxchid.getChildCount(); i++) { +//// fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); +//// String res = formulation.get(gongxu.model.name); +//// if (res != null) { +//// gongxu.SetValues(res); +//// } +//// } +// } catch (Exception ex) { +// } +// } /** * 设置当前商品 @@ -243,121 +271,139 @@ public class DiyUpdate1Activity extends BaseActivity { */ public void SetGood() { try { - Intent intent = getIntent(); - String id = intent.getStringExtra("id"); - if (!id.isEmpty()) { - good = QueryDB.GetGoodsId(id); - if (good != null) { - bpa_goodsrecipes.clear(); - ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); - for (BPA_GOODSRECIPE item : goodsrecipes) { - bpa_goodsrecipes.add(item); + if(SelectId!=null&&!SelectId.isEmpty()) { + QueryDB.getFormula(SelectId).OnSource(s->{ + good=s.Content; + ArrayAdapter adapter = (ArrayAdapter) hrgx.getAdapter(); + for (int i = 0; i < adapter.getCount(); i++) { + if (String.valueOf(good.HeatingGear).equals(adapter.getItem(i).toString())) { + hrgx.setSelection(i); + break; + } } - edittext.setText(good.name); - check.setChecked(good.issc == 1); - zzsc.setText(good.maketime + ""); - gxbz_adapter.notifyDataSetChanged();//刷新商品配方 - new MyBitmapUtils().disPlay(cpfm, good.url); - } + edittext.setText(good.Name); + et_Timing_Temperature.setText(String.valueOf(good.TimingTemperature)); + et_Cooking_Time.setText(String.valueOf(good.CookingTime)); + et_Relief_Pressure.setText(String.valueOf(good.ReliefPressure)); + }); } - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); - } catch (Exception ex) { - } - } - - /** - * 根据选中工序id显示集合 - * - * @param id - */ - public void SelectItemFrom(String id) { - try { - gxchid.removeAllViews(); - ArrayList mode = QueryDB.GetProcessModelProcessID(id); - if (mode.size() > 0)//工序 - { - for (BPA_PROCESSModel item : mode) { - item_gx gx = new item_gx(); - gx.datatype = item.datatype; - gx.name = item.name; - gx.data = item.data; - gx.IsWL = false; - fragment_gx gongxu = new fragment_gx(this, null, gx); - gxchid.addView(gongxu); - } - } else //物料 - { - ArrayList materials = QueryDB.GetMaterialALL(); - for (BPA_MATERIAL item2 : materials) { - item_gx gx = new item_gx(); - gx.datatype = 0;//液体料都是数字 - gx.name = item2.name; - gx.IsWL = true; - fragment_gx gongxu = new fragment_gx(this, null, gx); - gxchid.addView(gongxu); - } - } +// +// Intent intent = getIntent(); +// String id = intent.getStringExtra("id"); +// if (!id.isEmpty()) { +// good = QueryDB.GetGoodsId(id); +// if (good != null) { +// bpa_goodsrecipes.clear(); +// ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); +// for (BPA_GOODSRECIPE item : goodsrecipes) { +// bpa_goodsrecipes.add(item); +// } +// edittext.setText(good.name); +// check.setChecked(good.issc == 1); +// zzsc.setText(good.maketime + ""); +// gxbz_adapter.notifyDataSetChanged();//刷新商品配方 +// new MyBitmapUtils().disPlay(cpfm, good.url); +// } +// } +// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); } catch (Exception ex) { - } - } - /** - * 获取选中行的变量 - * - * @return - */ - public BPA_GOODSRECIPE GetSelectItemFromValue() { - BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); - try { - String name = hrgx.getSelectedItem().toString(); - boolean IsVerify = true; - String description = ""; - // 延迟,100|延迟,100|延迟,100|延迟,100| - String data = ""; - String desc = ""; - if (name.contains("液体料")) { - pf.materialType = 0; - for (int i = 0; i < gxchid.getChildCount(); i++) { - fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); - String values = gongxu.GetValues(); - if (!values.isEmpty()) { - data += gongxu.model.name + "," + values + "|"; - desc += values + ","; - } - } - - if (data.isEmpty()) { - IsVerify = false; - description += "物料-不能为空,请勾选一个物料\n"; - } - } else { - pf.materialType = 1; - for (int i = 0; i < gxchid.getChildCount(); i++) { - fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); - String values = gongxu.GetValues(); - if (values.isEmpty()) { - IsVerify = false; - description += gongxu.model.name + "-不能为空\n"; - } else { - data += gongxu.model.name + "," + values + "|"; - desc += values + ","; - } - } - } - if (IsVerify) { - pf.processname = name; - pf.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")"; - pf.processvalue = data.substring(0, data.length() - 1); - return pf; - } else { - ToastUtils.info("数据验证失败,原因:" + description); - return null; - } - } catch (Exception ex) { - return null; } } + +// /** +// * 根据选中工序id显示集合 +// * +// * @param id +// */ +// public void SelectItemFrom(String id) { +// try { +//// gxchid.removeAllViews(); +//// ArrayList mode = QueryDB.GetProcessModelProcessID(id); +//// if (mode.size() > 0)//工序 +//// { +//// for (BPA_PROCESSModel item : mode) { +//// item_gx gx = new item_gx(); +//// gx.datatype = item.datatype; +//// gx.name = item.name; +//// gx.data = item.data; +//// gx.IsWL = false; +//// fragment_gx gongxu = new fragment_gx(this, null, gx); +//// gxchid.addView(gongxu); +//// } +//// } else //物料 +//// { +//// ArrayList materials = QueryDB.GetMaterialALL(); +//// for (BPA_MATERIAL item2 : materials) { +//// item_gx gx = new item_gx(); +//// gx.datatype = 0;//液体料都是数字 +//// gx.name = item2.name; +//// gx.IsWL = true; +//// fragment_gx gongxu = new fragment_gx(this, null, gx); +//// gxchid.addView(gongxu); +//// } +//// } +// } catch (Exception ex) { +// } +// } + +// /** +// * 获取选中行的变量 +// * +// * @return +// */ +// public BPA_GOODSRECIPE GetSelectItemFromValue() { +// BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE(); +// try { +// String name = hrgx.getSelectedItem().toString(); +// boolean IsVerify = true; +// String description = ""; +// // 延迟,100|延迟,100|延迟,100|延迟,100| +// String data = ""; +// String desc = ""; +// if (name.contains("液体料")) { +// pf.materialType = 0; +//// for (int i = 0; i < gxchid.getChildCount(); i++) { +//// fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); +//// String values = gongxu.GetValues(); +//// if (!values.isEmpty()) { +//// data += gongxu.model.name + "," + values + "|"; +//// desc += values + ","; +//// } +//// } +// +// if (data.isEmpty()) { +// IsVerify = false; +// description += "物料-不能为空,请勾选一个物料\n"; +// } +// } else { +// pf.materialType = 1; +//// for (int i = 0; i < gxchid.getChildCount(); i++) { +//// fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); +//// String values = gongxu.GetValues(); +//// if (values.isEmpty()) { +//// IsVerify = false; +//// description += gongxu.model.name + "-不能为空\n"; +//// } else { +//// data += gongxu.model.name + "," + values + "|"; +//// desc += values + ","; +//// } +//// } +// } +// if (IsVerify) { +// pf.processname = name; +// pf.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")"; +// pf.processvalue = data.substring(0, data.length() - 1); +// return pf; +// } else { +// ToastUtils.info("数据验证失败,原因:" + description); +// return null; +// } +// } catch (Exception ex) { +// return null; +// } +// } private void initTopBar() { mTopBar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.topbj1)); mTopBar.setTitle("编辑菜谱"); @@ -374,7 +420,7 @@ public class DiyUpdate1Activity extends BaseActivity { * * @param view */ - @OnClick({R.id.add_hrgx, R.id.update_gx, R.id.delete_gx, R.id.shangyi, R.id.xiayi, R.id.caozuomoshi, R.id.shengchengcaipu, R.id.shengchengnewcaipu, R.id.cpfm}) + @OnClick({ R.id.shengchengcaipu, R.id.shengchengnewcaipu, R.id.cpfm}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.cpfm://菜谱封面 @@ -383,169 +429,203 @@ public class DiyUpdate1Activity extends BaseActivity { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); break; - case R.id.add_hrgx://添加工序 - BPA_GOODSRECIPE goodsrecipe = GetSelectItemFromValue(); - if (goodsrecipe != null) { - bpa_goodsrecipes.add(GetSelectItemFromValue()); - gxbz_adapter.notifyDataSetChanged(); - } - break; - case R.id.update_gx://修改工序 - int index_update = gxbz_adapter.getSelectedPosition(); - if (index_update >= 0 && index_update < bpa_goodsrecipes.size()) { - BPA_GOODSRECIPE obj_update = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_update); - String selectname = hrgx.getSelectedItem().toString(); - if (!obj_update.processname.equals(selectname)) { - ToastUtils.info("请先选择工序!"); - return; - } - bpa_goodsrecipes.set(index_update, GetSelectItemFromValue()); - gxbz_adapter.notifyDataSetChanged(); - ToastUtils.info("修改步骤" + (index_update + 1) + ":" + obj_update.processname + "成功!"); - } else { - ToastUtils.info("请先选择工序!"); - } - break; - case R.id.delete_gx://删除工序 - int index_delete = gxbz_adapter.getSelectedPosition(); - if (index_delete >= 0 && index_delete < bpa_goodsrecipes.size()) { - BPA_GOODSRECIPE obj_delete = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_delete); - bpa_goodsrecipes.remove(obj_delete); - gxbz_adapter.notifyDataSetChanged(); - - //移动光标 - if (index_delete - 1 >= 0) { - SetSelectPos(index_delete - 1); - } - ToastUtils.info("删除工序" + obj_delete.processname + "成功!"); - } else { - ToastUtils.info("请先选择工序!"); - } - break; - case R.id.shangyi://上移 - int index_up = gxbz_adapter.getSelectedPosition(); - ; - if (index_up > 0) { - BPA_GOODSRECIPE obj_up = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_up); - bpa_goodsrecipes.remove(obj_up); - bpa_goodsrecipes.add(index_up - 1, obj_up); - gxbz_adapter.notifyDataSetChanged(); - - //移动光标 - SetSelectPos(index_up - 1); - } else { - ToastUtils.info("已经最顶部!"); - } - break; - case R.id.xiayi://下移 - int index_down = gxbz_adapter.getSelectedPosition(); - if (index_down < bpa_goodsrecipes.size() - 1 && index_down >= 0) { - BPA_GOODSRECIPE obj_down = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_down); - bpa_goodsrecipes.remove(obj_down); - bpa_goodsrecipes.add(index_down + 1, obj_down); - gxbz_adapter.notifyDataSetChanged(); - - //移动光标 - SetSelectPos(index_down + 1); - } else { - ToastUtils.info("已经最底部!"); - } - break; - case R.id.caozuomoshi://操作模式 - Intent intent1 = new Intent(getContext(), DiyMemoryActivity.class); - intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent1); - break; +// case R.id.add_hrgx://添加工序 +// BPA_GOODSRECIPE goodsrecipe = GetSelectItemFromValue(); +// if (goodsrecipe != null) { +// bpa_goodsrecipes.add(GetSelectItemFromValue()); +// gxbz_adapter.notifyDataSetChanged(); +// } +// break; +// case R.id.update_gx://修改工序 +// int index_update = gxbz_adapter.getSelectedPosition(); +// if (index_update >= 0 && index_update < bpa_goodsrecipes.size()) { +// BPA_GOODSRECIPE obj_update = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_update); +// String selectname = hrgx.getSelectedItem().toString(); +// if (!obj_update.processname.equals(selectname)) { +// ToastUtils.info("请先选择工序!"); +// return; +// } +// bpa_goodsrecipes.set(index_update, GetSelectItemFromValue()); +// gxbz_adapter.notifyDataSetChanged(); +// ToastUtils.info("修改步骤" + (index_update + 1) + ":" + obj_update.processname + "成功!"); +// } else { +// ToastUtils.info("请先选择工序!"); +// } +// break; +// case R.id.delete_gx://删除工序 +// int index_delete = gxbz_adapter.getSelectedPosition(); +// if (index_delete >= 0 && index_delete < bpa_goodsrecipes.size()) { +// BPA_GOODSRECIPE obj_delete = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_delete); +// bpa_goodsrecipes.remove(obj_delete); +// gxbz_adapter.notifyDataSetChanged(); +// +// //移动光标 +// if (index_delete - 1 >= 0) { +// SetSelectPos(index_delete - 1); +// } +// ToastUtils.info("删除工序" + obj_delete.processname + "成功!"); +// } else { +// ToastUtils.info("请先选择工序!"); +// } +// break; +// case R.id.shangyi://上移 +// int index_up = gxbz_adapter.getSelectedPosition(); +// ; +// if (index_up > 0) { +// BPA_GOODSRECIPE obj_up = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_up); +// bpa_goodsrecipes.remove(obj_up); +// bpa_goodsrecipes.add(index_up - 1, obj_up); +// gxbz_adapter.notifyDataSetChanged(); +// +// //移动光标 +// SetSelectPos(index_up - 1); +// } else { +// ToastUtils.info("已经最顶部!"); +// } +// break; +// case R.id.xiayi://下移 +// int index_down = gxbz_adapter.getSelectedPosition(); +// if (index_down < bpa_goodsrecipes.size() - 1 && index_down >= 0) { +// BPA_GOODSRECIPE obj_down = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_down); +// bpa_goodsrecipes.remove(obj_down); +// bpa_goodsrecipes.add(index_down + 1, obj_down); +// gxbz_adapter.notifyDataSetChanged(); +// +// //移动光标 +// SetSelectPos(index_down + 1); +// } else { +// ToastUtils.info("已经最底部!"); +// } +// break; +// case R.id.caozuomoshi://操作模式 +// Intent intent1 = new Intent(getContext(), DiyMemoryActivity.class); +// intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); +// startActivity(intent1); +// break; case R.id.shengchengnewcaipu: String name1 = edittext.getText().toString(); - if (name1.isEmpty()) { - ToastUtils.info("菜谱名称不能为空!"); + if(name1.isEmpty()){ + DialogManager.showWarn(this,"菜谱名称不能为空!", AlertDialogButton.OK,null); return; - } else { - boolean isSucess = QueryDB.GetGoodsIs(name1); - if (isSucess) { - ToastUtils.info("菜谱名称已存在!"); - return; - } - //按钮点击 - String title = "生成菜谱操作提示!"; - String message = "请问客官确定要生成[" + name1 + "]菜谱吗?"; - 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()); - } + } + if(QueryDB.checkName(name1)){ + DialogManager.showWarn(this,"菜谱名称已存在!", AlertDialogButton.OK,null); + return; + } - 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); + DialogManager.showInfo(this,"请问是否生成 ["+name1+"] 菜谱?", AlertDialogButton.YesNo,(s)->{ + if(s){ + try{ + int heatingGear = Integer.parseInt(hrgx.getSelectedItem().toString()); + int timingsTemperature = Integer.parseInt(et_Timing_Temperature.getText().toString()); + int cookingTime = Integer.parseInt(et_Cooking_Time.getText().toString()); + int reliefPressure = Integer.parseInt(et_Relief_Pressure.getText().toString()); + OperateResult result = QueryDB.addFormula(new BPA_FORMULA(name1,ImageUrl,heatingGear,timingsTemperature,cookingTime,reliefPressure)); + if(result.isSuccess) + { + ToastUtils.info("菜谱添加成功!"); + NotifyEvent.get().Notify("商品信息刷新"); } - ToastUtils.info("菜谱复刻成功!"); - dialog.dismiss(); - MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good"); + else DialogManager.showError(this,"添加菜谱失败,"+result.message,AlertDialogButton.OK,null); finish(); + }catch(Exception e){ + DialogManager.showError(this,"添加菜谱失败,"+e.getMessage(),AlertDialogButton.OK,null); } - }); - - } + } + }); + + + +// +// if (name1.isEmpty()) { +//// ToastUtils.info("菜谱名称不能为空!"); +// DialogManager.showWarn(this,"菜谱名称不能为空!", AlertDialogButton.OK,null); +// return; +// } else { +// boolean isSucess = QueryDB.checkName(name1); +// if (isSucess) { +// ToastUtils.info("菜谱名称已存在!"); +// return; +// } +// //按钮点击 +// String title = "生成菜谱操作提示!"; +// String message = "请问客官确定要生成[" + name1 + "]菜谱吗?"; +// 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; +// if(good!=null) 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(); +// } +// }); +// +// } break; case R.id.shengchengcaipu://修改菜谱 - String name = edittext.getText().toString(); - if (name.isEmpty()) { - ToastUtils.info("菜谱名称不能为空!"); - return; - } else { - boolean isSucess = QueryDB.GetGoodsIs(name, good.id); - if (isSucess) { - ToastUtils.info("菜谱名称已存在!"); - return; - } - //按钮点击 - String title = "保存菜谱操作提示!"; - String message = "请问客官确定要保存[" + name + "]菜谱吗?"; - 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(); - } - }); - - } +// String name = edittext.getText().toString(); +// if (name.isEmpty()) { +// ToastUtils.info("菜谱名称不能为空!"); +// return; +// } else { +// boolean isSucess = QueryDB.GetGoodsIs(name, good.id); +// if (isSucess) { +// ToastUtils.info("菜谱名称已存在!"); +// return; +// } +// //按钮点击 +// String title = "保存菜谱操作提示!"; +// String message = "请问客官确定要保存[" + name + "]菜谱吗?"; +// 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(); +// } +// }); +// +// } break; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParSetActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParSetActivity.java new file mode 100644 index 00000000..2f511881 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParSetActivity.java @@ -0,0 +1,171 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; + +import androidx.core.content.ContextCompat; + +import com.bonait.bnframework.HBL.Executor; +import com.bonait.bnframework.HBL.Logs.MessageLog; +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ControlAdress; +import com.bonait.bnframework.business.ModbusHelper; +import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.helper.ConfigUtil; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.mode.add_silos_message; +import com.bonait.bnframework.modules.home.fragment.mode.imagebuttom; +import com.bonait.bnframework.modules.home.fragment.mode.jingdutiao1; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class SystemParSetActivity extends BaseActivity { + + //region 变量 + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + + /** + * 温度上限 + */ + @BindView(R.id.et_Temperature_Upper_Limit) + EditText et_Temperature_Upper_Limit; + + /** + * 温度下限 + */ + @BindView(R.id.et_Temperature_Lower_Limit) + EditText et_Temperature_Lower_Limit; + + /** + * 压力上限 + */ + @BindView(R.id.et_Pressure_Upper_Limit) + EditText et_Pressure_Upper_Limit; + + /** + * 压力下限 + */ + @BindView(R.id.et_Pressure_Lower_Limit) + EditText et_Pressure_Lower_Limit; + + /** + * 允许开盖压力 + */ + @BindView(R.id.et_OpenLid_pressure) + EditText et_OpenLid_pressure; + + /** + * 排冷气温度 + */ + @BindView(R.id.et_Exhaust_Air_Temperature) + EditText et_Exhaust_Air_Temperature; + + public Context context; + public Activity activity=null; + //endregion + + //region 界面实例 + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_system_par_set); + ButterKnife.bind(this); + context = this; + activity=this; + initTopBar(); + InitData(); + } + //endregion + + //region 私有方法 + + /** + * 初始化顶部弹框 + */ + private void initTopBar() { + mTopBar.setBackgroundColor(ContextCompat.getColor(context, R.color.topbj1)); + mTopBar.setTitle("系统参数设置"); + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + + } + + private String getConfig(String key){ + Context dishesCon = ConfigName.getInstance().dishesCon; + return String.valueOf(ConfigUtil.read(dishesCon, key,0 )); + } + + /** + * 初始化数据 + */ + public void InitData() { + try{ + et_Temperature_Upper_Limit.setText(getConfig("Temperature_Upper_Limit")); + et_Temperature_Lower_Limit.setText(getConfig("Temperature_Lower_Limit")); + et_Pressure_Upper_Limit.setText(getConfig("Pressure_Upper_Limit")); + et_Pressure_Lower_Limit.setText(getConfig("Pressure_Lower_Limit")); + et_OpenLid_pressure.setText(getConfig("OpenLid_pressure")); + et_Exhaust_Air_Temperature.setText(getConfig("Exhaust_Air_Temperature")); + }catch(Exception e){ + MessageLog.ShowError(e); + } + } + + + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.btn_save}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.btn_save: + try{ + short Temperature_Upper_Limit = Short.parseShort(et_Temperature_Upper_Limit.getText().toString()); + short Temperature_Lower_Limit = Short.parseShort(et_Temperature_Lower_Limit.getText().toString()); + short Pressure_Upper_Limit = Short.parseShort(et_Pressure_Upper_Limit.getText().toString()); + short Pressure_Lower_Limit = Short.parseShort(et_Pressure_Lower_Limit.getText().toString()); + short OpenLid_pressure = Short.parseShort(et_OpenLid_pressure.getText().toString()); + short Exhaust_Air_Temperature = Short.parseShort(et_Exhaust_Air_Temperature.getText().toString()); + Context dishesCon = ConfigName.getInstance().dishesCon; + ConfigUtil.write(dishesCon, "Temperature_Upper_Limit",Temperature_Upper_Limit ); + ConfigUtil.write(dishesCon, "Temperature_Lower_Limit",Temperature_Lower_Limit); + ConfigUtil.write(dishesCon, "Pressure_Upper_Limit",Pressure_Upper_Limit ); + ConfigUtil.write(dishesCon, "Pressure_Lower_Limit",Pressure_Lower_Limit ); + ConfigUtil.write(dishesCon, "OpenLid_pressure",OpenLid_pressure ); + ConfigUtil.write(dishesCon, "Exhaust_Air_Temperature", Exhaust_Air_Temperature); + Executor.get().runThread(()->{ + ModbusHelper.get().WritePar(ControlAdress.温度上限,Temperature_Upper_Limit); + ModbusHelper.get().WritePar(ControlAdress.温度下限,Temperature_Lower_Limit); + ModbusHelper.get().WritePar(ControlAdress.压力上限,Pressure_Upper_Limit); + ModbusHelper.get().WritePar(ControlAdress.压力下限,Pressure_Lower_Limit); + ModbusHelper.get().WritePar(ControlAdress.允许开盖压力,OpenLid_pressure); + ModbusHelper.get().WritePar(ControlAdress.排冷气温度,Exhaust_Air_Temperature); + this.runOnUiThread(()->{ ToastUtils.info("保存成功!");}); + }); + }catch (Exception e){ + MessageLog.ShowError(e); + } + break; + } + } + //endregion +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java index e3d0dabd..f3e2e887 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java @@ -14,8 +14,13 @@ import android.widget.TextView; import androidx.annotation.Nullable; +import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; +import com.bonait.bnframework.HBL.Dialog.DialogManager; +import com.bonait.bnframework.HBL.Executor; +import com.bonait.bnframework.MainApplication; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.business.ModbusHelper; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.QueryDB; @@ -38,30 +43,33 @@ public class add_qupenren extends LinearLayout { @BindView(R.id.quzhizuo) Button quzhizuo; + @BindView(R.id.edit_func) + Button edit_func; + @BindView(R.id.quzhizuo_ms) TextView quzhizuo_ms; - @BindView(R.id.bianji) - RelativeLayout bianji; +// @BindView(R.id.bianji) +// RelativeLayout bianji; - @BindView(R.id.chaozhi) - RelativeLayout chaozhi; +// @BindView(R.id.chaozhi) +// RelativeLayout chaozhi; @BindView(R.id.close_from) Button close_from; @BindView(R.id.good_name) TextView good_name;//商品名称 - @BindView(R.id.yihao_text) - TextView yihao_text;//1号 - - @BindView(R.id.erhao_text) - TextView erhao_text;//1号 - - @BindView(R.id.sanhao_text) - TextView sanhao_text;//1号 - - @BindView(R.id.sihao_text) - TextView sihao_text;//1号 +// @BindView(R.id.yihao_text) +// TextView yihao_text;//1号 +// +// @BindView(R.id.erhao_text) +// TextView erhao_text;//1号 +// +// @BindView(R.id.sanhao_text) +// TextView sanhao_text;//1号 +// +// @BindView(R.id.sihao_text) +// TextView sihao_text;//1号 /** * 点击事件 */ @@ -93,11 +101,6 @@ public class add_qupenren extends LinearLayout { ConcurrentHashMap resultData= DataBus.getInstance().GetMainDisplayText(id); - yihao_text.setText(resultData.get(1)+""); - erhao_text.setText(resultData.get(2)+""); - sanhao_text.setText(resultData.get(3)+""); - sihao_text.setText(resultData.get(4)+""); - if(ExecuteTheRecipe.IsStart) { quzhizuo.setVisibility(View.GONE); @@ -138,25 +141,14 @@ public class add_qupenren extends LinearLayout { private void initEvent() { if (ConfigName.getInstance().user.userID.equals("研发用户")) { - bianji.setVisibility(View.VISIBLE); + edit_func.setVisibility(View.VISIBLE); } else { - bianji.setVisibility(View.GONE); + edit_func.setVisibility(View.GONE); } quzhizuo.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - if (!ConfigName.getInstance().PlcIsConnect) { - ToastUtils.warning("PLC未准备就绪!!!"); - 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); } @@ -171,7 +163,7 @@ public class add_qupenren extends LinearLayout { } }); - bianji.setOnClickListener(new OnClickListener() { + edit_func.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (mListener != null) { @@ -180,13 +172,5 @@ public class add_qupenren extends LinearLayout { } }); - chaozhi.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - if (mListener != null) { - mListener.clickListenerNew(view, 99, mode); - } - } - }); } } \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java index a59a9599..6ac3b7a9 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java @@ -348,17 +348,17 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL QMUIStatusBarHelper.setStatusBarDarkMode(LoginActivity.this); - if(ConfigName.getInstance().user.name.equals("admin") || ConfigName.getInstance().user.account.equals("admin") || ConfigName.getInstance().user.userID.equals("超级管理员")) - { - Intent intent = new Intent(LoginActivity.this, BottomNavigation2Activity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - }else - { +// if(ConfigName.getInstance().user.name.equals("admin") || ConfigName.getInstance().user.account.equals("admin") || ConfigName.getInstance().user.userID.equals("超级管理员")) +// { +// Intent intent = new Intent(LoginActivity.this, BottomNavigation2Activity.class); +// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); +// startActivity(intent); +// }else +// { Intent intent = new Intent(LoginActivity.this, BottomNavigationNewActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); - } +// } ToastUtils.info("登录成功!"); // 结束所有Activity ActivityLifecycleManager.get().finishAllActivity(); diff --git a/app/src/main/res/drawable-xxhdpi/ylg.png b/app/src/main/res/drawable-xxhdpi/ylg.png new file mode 100644 index 00000000..c42155f7 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ylg.png differ diff --git a/app/src/main/res/drawable/bg_btn_dialog_qupenren.xml b/app/src/main/res/drawable/bg_btn_dialog_qupenren.xml new file mode 100644 index 00000000..8b29f758 --- /dev/null +++ b/app/src/main/res/drawable/bg_btn_dialog_qupenren.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/control_but_back.xml b/app/src/main/res/drawable/control_but_back.xml new file mode 100644 index 00000000..01636a3e --- /dev/null +++ b/app/src/main/res/drawable/control_but_back.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/edit_border.xml b/app/src/main/res/drawable/edit_border.xml new file mode 100644 index 00000000..56b538d5 --- /dev/null +++ b/app/src/main/res/drawable/edit_border.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shadow_backcolor.xml b/app/src/main/res/drawable/shadow_backcolor.xml new file mode 100644 index 00000000..4c511842 --- /dev/null +++ b/app/src/main/res/drawable/shadow_backcolor.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_diy_update1.xml b/app/src/main/res/layout/activity_diy_update1.xml index bc0e2cc0..61dafb1b 100644 --- a/app/src/main/res/layout/activity_diy_update1.xml +++ b/app/src/main/res/layout/activity_diy_update1.xml @@ -143,161 +143,118 @@ android:layout_marginBottom="@dimen/dp_10" android:background="@color/color3" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +