@@ -4,16 +4,15 @@ | |||
<component name="GradleSettings"> | |||
<option name="linkedExternalProjectsSettings"> | |||
<GradleProjectSettings> | |||
<option name="testRunner" value="GRADLE" /> | |||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | |||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
<option name="gradleJvm" value="Android Studio default JDK" /> | |||
<option name="gradleJvm" value="corretto-11" /> | |||
<option name="modules"> | |||
<set> | |||
<option value="$PROJECT_DIR$" /> | |||
<option value="$PROJECT_DIR$/app" /> | |||
</set> | |||
</option> | |||
<option name="resolveExternalAnnotations" value="false" /> | |||
</GradleProjectSettings> | |||
</option> | |||
</component> |
@@ -1,5 +1,5 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK" /> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK" /> | |||
</project> |
@@ -18,18 +18,18 @@ public class NotifyPropVar<T extends Serializable> { | |||
private LinkedHashMap<String,IRunT<T>> changedNotifys=new LinkedHashMap<>(); | |||
public void Register(String key,IRunT<T> 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> 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; | |||
} | |||
} | |||
@@ -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 <T> void Notify(String name,T value){ | |||
public <T> 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); | |||
} | |||
} | |||
@@ -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); | |||
@@ -7,6 +7,9 @@ import java.io.Serializable; | |||
public class PLCModel<T extends Serializable> { | |||
public String PlcAddress; | |||
public NotifyPropVar<T> Value; | |||
public <T> T getValue(){ | |||
return (T)Value.getValue(); | |||
} | |||
public OperationModel operationModel; | |||
public PLCModel(String add,T defaultValue,OperationModel om){ | |||
PlcAddress = add; | |||
@@ -43,7 +43,7 @@ public class UpdateAppUtils { | |||
/** | |||
* 当前版本号 | |||
*/ | |||
private static String myVersionCode = "1.4"; | |||
private static String myVersionCode = "1.5"; | |||
/** | |||
* 服务器的版本号 | |||
*/ | |||
@@ -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().<Boolean>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); | |||
}); | |||
@@ -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"); | |||
}); | |||
}); | |||
@@ -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); | |||
}); | |||
}); | |||
} | |||
@@ -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{ | |||