diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6e5389ed..804e304a 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,15 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index cba3440e..c3df9b04 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/NotifyPropVar.java b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/NotifyPropVar.java index 47acc067..7eb4463c 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/NotifyPropVar.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/DataUtil/NotifyPropVar.java @@ -18,18 +18,18 @@ public class NotifyPropVar { private LinkedHashMap> changedNotifys=new LinkedHashMap<>(); public void Register(String key,IRunT notify){ - if(changedNotifys.containsKey(key))changedNotifys.remove(key); +// if(changedNotifys.containsKey(key))changedNotifys.remove(key); changedNotifys.put(key,notify); } private T _value; - public T getValue(){ return _value; } +// public T getValue(){ return _value; } + public T getValue(){ return (T) _value; } public void setValue(T value){ - if (value != null && !value.equals(_value) || !IsFirst) - { + if (value != null && !value.equals(_value) || !IsFirst) { _value=value; if(ChangeNotify!=null) ChangeNotify.Run(value); - changedNotifys.values().forEach(item->{item.Run(value);}); + changedNotifys.values().forEach(item->{if(item!=null) item.Run(value);}); IsFirst = true; } } diff --git a/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java b/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java index cb9e396e..99763505 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/NotifyEvent.java @@ -3,6 +3,7 @@ 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 com.bonait.bnframework.HBL.Result.OperateResult; import java.util.concurrent.ConcurrentHashMap; @@ -23,27 +24,37 @@ public class NotifyEvent { _runMap.put(name,run); } - public void Notify(String name){ + public OperateResult Send(String name){ try{ if(_runMap.containsKey(name)&&_runMap.get(name)!=null){ if(_runMap.get(name) instanceof IRun){ ((IRun)_runMap.get(name)).Run(); + return OperateResult.CreateSuccess(); + }else{ + return OperateResult.CreateFailed("注册类型和发送消息类型不匹配"); } + }else{ + return OperateResult.CreateFailed(name+"消息未注册"); } }catch(Exception e){ - MessageLog.ShowError(e); + return OperateResult.CreateFailed(e); } } - public void Notify(String name,T value){ + public OperateResult Send(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); + return OperateResult.CreateSuccess(); + }else{ + return OperateResult.CreateFailed("注册类型和发送消息类型不匹配"); } + }else{ + return OperateResult.CreateFailed(name+"消息未注册"); } }catch(Exception e){ - MessageLog.ShowError(e); + return OperateResult.CreateFailed(e); } } 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 6d6a430e..e08fb65b 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java +++ b/app/src/main/java/com/bonait/bnframework/business/ModbusHelper.java @@ -156,6 +156,7 @@ public class ModbusHelper extends ModbusMaster { } } + /** * 写入订单数据到PLC * @param formula @@ -167,6 +168,7 @@ public class ModbusHelper extends ModbusMaster { WriteShort(controlAddress.get(ControlAdress.设定压力).PlcAddress,(short)(AnalogConvert.getCurrentPressureAnalog((short)formula.ReliefPressure))); WriteShort(controlAddress.get(ControlAdress.计时温度).PlcAddress,(short)(AnalogConvert.getCurrentTemperatureAnalog((short)formula.TimingTemperature))); WriteShort(controlAddress.get(ControlAdress.烹饪时间).PlcAddress,(short)(formula.CookingTime*600)); +// WriteInt(controlAddress.get(ControlAdress.烹饪时间).PlcAddress,formula.CookingTime*600); WriteBool(controlAddress.get(ControlAdress.配方启动).PlcAddress,true); Sleep(1000); WriteBool(controlAddress.get(ControlAdress.配方启动).PlcAddress,false); diff --git a/app/src/main/java/com/bonait/bnframework/business/PLCModel.java b/app/src/main/java/com/bonait/bnframework/business/PLCModel.java index ce8b4d1a..908b8910 100644 --- a/app/src/main/java/com/bonait/bnframework/business/PLCModel.java +++ b/app/src/main/java/com/bonait/bnframework/business/PLCModel.java @@ -7,6 +7,9 @@ import java.io.Serializable; public class PLCModel { public String PlcAddress; public NotifyPropVar Value; + public T getValue(){ + return (T)Value.getValue(); + } public OperationModel operationModel; public PLCModel(String add,T defaultValue,OperationModel om){ PlcAddress = add; diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java index c02c4a06..8a0adb33 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java @@ -43,7 +43,7 @@ public class UpdateAppUtils { /** * 当前版本号 */ - private static String myVersionCode = "1.4"; + private static String myVersionCode = "1.5"; /** * 服务器的版本号 */ 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 ddc2e8f6..50faf95a 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,16 +1,9 @@ package com.bonait.bnframework.modules.home.activity; -import androidx.annotation.RequiresApi; import androidx.viewpager.widget.ViewPager; -import android.Manifest; import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.os.Build; import android.os.Bundle; -import android.provider.Settings; import android.view.KeyEvent; import android.view.View; import android.widget.LinearLayout; @@ -19,11 +12,8 @@ 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.Logs.MessageLog; import com.bonait.bnframework.HBL.NotifyEvent; -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.R; import com.bonait.bnframework.business.AnalogConvert; import com.bonait.bnframework.business.ConfigData; @@ -32,20 +22,15 @@ import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.business.Input; 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.Constants; import com.bonait.bnframework.common.constant.MessageName; -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; import com.bonait.bnframework.common.helper.CountDownTimerExt; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; -import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.NetworkUtils; import com.bonait.bnframework.common.utils.ToastUtils; -import com.bonait.bnframework.common.utils.UpdateAppUtils; import com.bonait.bnframework.common.view.BottomNavigationBar; import com.bonait.bnframework.manager.ActivityLifecycleManager; import com.bonait.bnframework.modules.home.adapter.FragmentAdapter; @@ -55,8 +40,6 @@ import com.bonait.bnframework.modules.home.fragment.HomeFragmentPR; import com.bonait.bnframework.modules.home.fragment.from.CookingActivity; import com.lzy.okgo.OkGo; import com.qmuiteam.qmui.widget.QMUIViewPager; -import com.qmuiteam.qmui.widget.dialog.QMUIDialog; -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import java.io.File; import java.util.ArrayList; @@ -65,8 +48,6 @@ import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import pub.devrel.easypermissions.AfterPermissionGranted; -import pub.devrel.easypermissions.EasyPermissions; public class BottomNavigationNewActivity extends BaseActivity { @@ -267,10 +248,11 @@ public class BottomNavigationNewActivity extends BaseActivity { // getSerialPorts().OnSource(s->{ // s.Content.forEach(item->{MessageLog.ShowError(item);}); // }); + ModbusHelper.get().setPLCNotify(ControlAdress.烹饪完成,"主界面烹饪完成通知",(s)->{ if(s){ DialogManager.showInfo(this,"烹饪完成,请及时查看!", AlertDialogButton.OK,(result)->{ - NotifyEvent.get().Notify("烹饪完成"); + NotifyEvent.get().Send("烹饪完成"); ModbusHelper.get().WriteBoolSingle(ControlAdress.烹饪完成,false); ModbusHelper.get().IsRunning.setValue(false); }); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentDevice.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentDevice.java index c453bc4c..f537b099 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentDevice.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentDevice.java @@ -160,6 +160,7 @@ public class HomeFragmentDevice extends BaseFragment { */ public String formatTime(long millisecond) { try{ + if(millisecond<0)return "00 : 00"; int minute =(int)(millisecond/60000);//分钟 int second=(int)(millisecond%60000)/1000;//秒数 if (minute < 10) { @@ -209,6 +210,7 @@ public class HomeFragmentDevice extends BaseFragment { NotifyEvent.get().Register("烹饪完成",()->{ activity.runOnUiThread(()->{ BtnEnable(true); + tv_time.setText("00 : 00"); }); }); 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 1d3ee644..3db92319 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 @@ -1,10 +1,7 @@ package com.bonait.bnframework.modules.home.fragment; -import static com.bonait.bnframework.MainApplication.getContext; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; @@ -20,7 +17,6 @@ import android.os.Handler; import android.os.Message; import android.view.LayoutInflater; import android.view.View; -import android.widget.RelativeLayout; import android.widget.TextView; import com.bonait.bnframework.HBL.Dialog.AlertDialogButton; @@ -28,42 +24,24 @@ 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.Input; import com.bonait.bnframework.business.ModbusHelper; import com.bonait.bnframework.business.PLCModel; import com.bonait.bnframework.common.base.BaseFragment; 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.QueryDB; -import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.helper.I.MyClickListener; -import com.bonait.bnframework.common.message.MessageLooper; -import com.bonait.bnframework.common.message.MessageManager; -import com.bonait.bnframework.common.model.mode.CloudGood; -import com.bonait.bnframework.common.utils.AlertDialogUtils; -import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.good_adapter; -import com.bonait.bnframework.modules.home.fragment.from.CookingActivity; import com.bonait.bnframework.modules.home.fragment.from.CookingSimulatedActivity; import com.bonait.bnframework.modules.home.fragment.from.DiyUpdate1Activity; -import com.bonait.bnframework.modules.home.fragment.from.DiyUpdateActivity; -import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader; import com.bonait.bnframework.modules.home.fragment.mode.SectionItem; import com.bonait.bnframework.modules.home.fragment.mode.add_qupenren; -import com.litao.slider.NiftySlider; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; -import com.qmuiteam.qmui.widget.dialog.QMUIDialog; -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; -import com.qmuiteam.qmui.widget.section.QMUISection; import java.util.ArrayList; -import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -220,7 +198,7 @@ public class HomeFragmentPR extends BaseFragment { Executor.get().runThread(()->{ ModbusHelper.get().WriteOrder(order.Content); getActivity().runOnUiThread( ()->{qupenren.setVisibility(View.GONE);}); - NotifyEvent.get().Notify(MessageName.OpenDeviceFrom); + NotifyEvent.get().Send(MessageName.OpenDeviceFrom); }); }); } 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 84179400..711c38ee 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 @@ -2,57 +2,37 @@ package com.bonait.bnframework.modules.home.fragment.from; import static com.bonait.bnframework.MainApplication.getContext; -import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import android.content.Intent; -import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.view.MotionEvent; 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; -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; -import com.bonait.bnframework.common.db.mode.BPA_PROCESS; -import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; import com.bonait.bnframework.common.image.MyBitmapUtils; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; -import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.CircleImageView; import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter; -import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx; -import com.bonait.bnframework.modules.home.fragment.mode.item_gx; -import com.qmuiteam.qmui.widget.QMUIRadiusImageView2; import com.qmuiteam.qmui.widget.QMUITopBarLayout; -import com.qmuiteam.qmui.widget.dialog.QMUIDialog; -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -444,6 +424,11 @@ public class DiyUpdate1Activity extends BaseActivity { DialogManager.showError(this,"最大压力不能超过 200", AlertDialogButton.OK,null); return; } + + if( Integer.parseInt(et_Cooking_Time.getText().toString())>50){ + DialogManager.showError(this,"炒制时间不能超过 50", AlertDialogButton.OK,null); + return; + } }catch (Exception e){ DialogManager.showError(this,"请输入合法的压力值", AlertDialogButton.OK,null); } @@ -460,7 +445,7 @@ public class DiyUpdate1Activity extends BaseActivity { if(result.isSuccess) { ToastUtils.info("菜谱添加成功!"); - NotifyEvent.get().Notify("商品信息刷新"); + NotifyEvent.get().Send("商品信息刷新"); } else DialogManager.showError(this,"添加菜谱失败,"+result.message,AlertDialogButton.OK,null); finish(); @@ -479,18 +464,23 @@ public class DiyUpdate1Activity extends BaseActivity { int cookingTime = Integer.parseInt(et_Cooking_Time.getText().toString()); int reliefPressure = Integer.parseInt(et_Relief_Pressure.getText().toString()); - if( Integer.parseInt(et_Relief_Pressure.getText().toString())>200){ + if( reliefPressure>200){ DialogManager.showError(this,"最大压力不能超过 200", AlertDialogButton.OK,null); return; } + if( cookingTime>50){ + DialogManager.showError(this,"炒制时间不能超过 50", AlertDialogButton.OK,null); + return; + } + BPA_FORMULA data = new BPA_FORMULA(name,ImageUrl,heatingGear,timingsTemperature,cookingTime,reliefPressure); data.id=SelectId; OperateResult result = QueryDB.UpdataFormula(data); if(result.isSuccess){ ToastUtils.info("菜谱修改成功!"); - NotifyEvent.get().Notify("商品信息刷新"); + NotifyEvent.get().Send("商品信息刷新"); } else DialogManager.showError(this,"修改菜谱失败,"+result.message,AlertDialogButton.OK,null); // finish(); }else{