diff --git a/app/build.gradle b/app/build.gradle
index f501acfc..0dbc2cd9 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -197,7 +197,7 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
//leak 内存泄漏检测
- debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3'
+// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3'
//腾讯bugly
//sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 609100f3..da7d3e53 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,13 +4,17 @@
package="com.bonait.bnframework">
+
-
+
@@ -22,6 +26,7 @@
-->
-
+
@@ -213,7 +219,8 @@
-
+
>");
}) ;
@@ -262,17 +262,17 @@ public class ModbusHelper extends ModbusMaster {
* @param value
* * @param isCalibration 是否是校准
*/
- public void addThickenWater(int value,boolean isCalibration){
+ public void addThickenWater(float value,boolean isCalibration){
getCalibrationPar(ControlAdress.勾芡.toString()).OnSource(item->{
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content;
short scale;
if(isCalibration){
- scale = (short) value;
+ scale = (short) (value*100);
}else{
- scale = AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin,
- (short) bean.outputTimeMax, (short) bean.outputTimeMin);
+ scale = (short) AnalogConvert.Scale( value, bean.inputWightMax, bean.inputWightMin,
+ bean.outputTimeMax, bean.outputTimeMin);
}
- WriteShort(getPLC(ControlAdress.勾芡时间).PlcAddress, (short) (scale*100));
+ WriteShort(getPLC(ControlAdress.勾芡时间).PlcAddress, scale);
WriteBool(getPLC(ControlAdress.勾芡).PlcAddress,true);
LogUtils.d(TAG+"勾芡控制 addThickenWater value="+value+"scale="+scale);
}) ;
@@ -517,7 +517,7 @@ public class ModbusHelper extends ModbusMaster {
deviceErrorCode = bytes[0] & 0xFF;
}
}
- Thread.sleep(ConfigName.TEST?2000:200);
+ Thread.sleep(ConfigName.TEST?500:200);
});
}
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigation2Activity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigation2Activity.java
index 10f942b5..3a65cd74 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigation2Activity.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigation2Activity.java
@@ -1,37 +1,28 @@
package com.bonait.bnframework.ViewModel.ActivityViewModel;
import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.MenuItem;
import androidx.annotation.NonNull;
+import androidx.viewpager.widget.ViewPager;
-import com.bonait.bnframework.HBL.Logs.MessageLog;
-import com.bonait.bnframework.HBL.Thread.IThread;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
+import com.bonait.bnframework.R;
import com.bonait.bnframework.Service.ModbusHelper;
+import com.bonait.bnframework.ViewModel.Adapter.FragmentAdapter;
+import com.bonait.bnframework.ViewModel.FragmentViewModel.Home2Fragment;
import com.bonait.bnframework.ViewModel.FragmentViewModel.HomeDeviceFragment;
+import com.bonait.bnframework.ViewModel.FragmentViewModel.MyFragment;
import com.bonait.bnframework.business.ConfigData;
-import com.bonait.bnframework.common.constant.ConfigName;
-import com.bonait.bnframework.common.utils.NetworkUtils;
-import com.google.android.material.bottomnavigation.BottomNavigationView;
-
-import androidx.viewpager.widget.ViewPager;
-
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MenuItem;
-import android.view.View;
-
-import com.bonait.bnframework.R;
+import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
-import com.bonait.bnframework.manager.ActivityLifecycleManager;
-import com.bonait.bnframework.common.base.BaseActivity;
+import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
-import com.bonait.bnframework.ViewModel.FragmentViewModel.Home1Fragment;
-import com.bonait.bnframework.ViewModel.FragmentViewModel.Home2Fragment;
-import com.bonait.bnframework.ViewModel.Adapter.FragmentAdapter;
-import com.bonait.bnframework.ViewModel.FragmentViewModel.MyFragment;
+import com.bonait.bnframework.manager.ActivityLifecycleManager;
+import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.lzy.okgo.OkGo;
import com.qmuiteam.qmui.widget.QMUIViewPager;
@@ -190,9 +181,7 @@ public class BottomNavigation2Activity extends BaseActivity {
//判断连接环境
ConfigData.getInstance().ToggleEnvironment();
//初始化modbus
- if(!ModbusHelper.get().getConnected()){
- ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
- }
+ ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
//初始化阿里云连接
//AliyunIOTManager.getInstance().OpenDev(this);
}
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java
index 13ca1d32..19baefb8 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java
@@ -250,9 +250,8 @@ public class BottomNavigationNewActivity extends BaseActivity {
// //2.初始化PLC
// ReconnectModbus();
//初始化modbus
- if(!ModbusHelper.get().getConnected()){
- ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
- }
+ ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
+
//制作线程
MakeThread();
//初始化阿里云连接
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
index 3bcac745..9834b66e 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
@@ -230,7 +230,7 @@ public class HomeDeviceFragment extends BaseFragment {
if(!waterValue.isEmpty()){
ToastUtils.info("开始加水 "+waterValue+"g");
ThreadManager.get().execute(new Thread(() -> {
- ModbusHelper.get().addWater(Integer.parseInt(viewBinding.editWater.getText().toString()),false);
+ ModbusHelper.get().addWater(Float.parseFloat(viewBinding.editWater.getText().toString()),false);
}));
}else {
ToastUtils.info("值不能为空!");
@@ -241,7 +241,7 @@ public class HomeDeviceFragment extends BaseFragment {
if(!value.isEmpty()){
ToastUtils.info("开始勾芡 "+value+"g");
ThreadManager.get().execute(new Thread(() -> {
- ModbusHelper.get().addThickenWater(Integer.parseInt(viewBinding.editQianWater.getText().toString()), false);
+ ModbusHelper.get().addThickenWater(Float.parseFloat(viewBinding.editQianWater.getText().toString()), false);
}));
}else {
ToastUtils.info("值不能为空!");
@@ -253,7 +253,7 @@ public class HomeDeviceFragment extends BaseFragment {
if(!value2.isEmpty()){
ToastUtils.info("添加调料 "+(seasoningPos+1)+"号仓 "+value2+"g");
ThreadManager.get().execute(new Thread(() -> {
- ModbusHelper.get().addMaterial(Integer.parseInt(value2),(seasoningPos+1),false);
+ ModbusHelper.get().addMaterial(Float.parseFloat(value2),(seasoningPos+1),false);
}));
}else {
ToastUtils.info("值不能为空!");
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java
index 9c809c05..7bb23a0e 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/SystemSeasoningsetFragment.java
@@ -18,14 +18,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
-import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.R;
import com.bonait.bnframework.Service.ModbusHelper;
-import com.bonait.bnframework.ui.adapter.SilosAdapter;
import com.bonait.bnframework.ViewModel.Adapter.process_adapter;
import com.bonait.bnframework.ViewModel.Adapter.silos_calibrate_adapter;
-import com.bonait.bnframework.ViewModel.CustomView.XComDialog;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
@@ -42,6 +39,7 @@ import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.ui.adapter.MaterialAdapter;
+import com.bonait.bnframework.ui.adapter.SilosAdapter;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
@@ -257,94 +255,89 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL
case R.id.tv_intput_max:
case R.id.tv_intput_min:
case R.id.tv_output_max:
- AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(),R.layout.dialog_silos_calibrates_edit,
- new XComDialog.OnDialogListener(){
- @Override
- public void onDialogClick(View layoutView, XComDialog xCom) {
- TextView tvTitle = layoutView.findViewById(R.id.tv_title);
- EditText editOutMax = layoutView.findViewById(R.id.edit_out_max);
- EditText editOutMin = layoutView.findViewById(R.id.edit_out_min);
- EditText editInMax = layoutView.findViewById(R.id.edit_in_max);
- EditText editInMin = layoutView.findViewById(R.id.edit_in_min);
- TextView tvCancel = layoutView.findViewById(R.id.tv_cancel);
- TextView tvConfirm = layoutView.findViewById(R.id.tv_confirm);
- TextView tvMaxCalibration = layoutView.findViewById(R.id.tv_max_calibration);
- TextView tvMinCalibration = layoutView.findViewById(R.id.tv_min_calibration);
-
- DisplayManager.scaleView(layoutView.findViewById(R.id.tv_1));
- DisplayManager.scaleView(layoutView.findViewById(R.id.tv_2));
- DisplayManager.scaleView(layoutView.findViewById(R.id.tv_3));
- DisplayManager.scaleView(layoutView.findViewById(R.id.tv_4));
- DisplayManager.scaleView(tvCancel);
- DisplayManager.scaleView(tvConfirm);
- DisplayManager.scaleView(editOutMax);
- DisplayManager.scaleView(editOutMin);
- DisplayManager.scaleView(editInMax);
- DisplayManager.scaleView(editInMin);
- DisplayManager.scaleView(tvMaxCalibration);
- DisplayManager.scaleView(tvMinCalibration);
- assert bean != null;
- tvTitle.setText(bean.name + "号仓校准:");
- editOutMax.setText(bean.outputTimeMax+"");
- editOutMin.setText(bean.outputTimeMin+"");
- editInMax.setText(bean.inputWightMax+"");
- editInMin.setText(bean.inputWightMin+"");
-
- tvCancel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- xCom.dismissX();
- }
- });
- tvConfirm.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CharSequence outMax = editOutMax.getText();
- CharSequence outMin = editOutMin.getText();
- CharSequence inMax = editInMax.getText();
- CharSequence inMin = editInMin.getText();
-
- if (outMax != null && outMax.length() > 0 &&
- outMin != null && outMin.length() > 0 &&
- inMax != null && inMax.length() > 0&&
- inMin != null && inMin.length() > 0) {
- LogUtils.d(bean.id+" outMax"+outMax +"outMin="+outMin+"inMax="+inMax+"inMin="+inMin);
- QueryDB.UpdateSilosCalibrate(bean.id, Integer.parseInt(outMax.toString()),Integer.parseInt(outMin.toString()),
- Integer.parseInt(inMax.toString()),Integer.parseInt(inMin.toString()));
- Initdata_silos_calibrate();
- xCom.dismissX();
- } else {
- ToastUtils.info("值不能为空!");
- }
- }
- });
-
- tvMaxCalibration.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CharSequence outMax = editOutMax.getText();
- if (outMax != null && outMax.length() > 0){
- startCalibration(Integer.parseInt(outMax.toString()),position+1);
- }else {
- ToastUtils.info("值不能为空!");
- }
-
- }
- });
- tvMinCalibration.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CharSequence outMin = editOutMin.getText();
- if (outMin != null && outMin.length() > 0){
- startCalibration(Integer.parseInt(outMin.toString()),position+1);
- }else {
- ToastUtils.info("值不能为空!");
- }
-
- }
- });
- }
- });
+// AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(),R.layout.dialog_silos_calibrates_edit,
+// new XComDialog.OnDialogListener(){
+// @Override
+// public void onDialogClick(View layoutView, XComDialog xCom) {
+// TextView tvTitle = layoutView.findViewById(R.id.tv_title);
+// EditText editOutMax = layoutView.findViewById(R.id.edit_out_max);
+// EditText editOutMin = layoutView.findViewById(R.id.edit_out_min);
+// EditText editInMax = layoutView.findViewById(R.id.edit_in_max);
+// EditText editInMin = layoutView.findViewById(R.id.edit_in_min);
+// TextView tvCancel = layoutView.findViewById(R.id.tv_cancel);
+// TextView tvConfirm = layoutView.findViewById(R.id.tv_confirm);
+// TextView tvMaxCalibration = layoutView.findViewById(R.id.tv_max_calibration);
+// TextView tvMinCalibration = layoutView.findViewById(R.id.tv_min_calibration);
+//
+// DisplayManager.scaleView(layoutView.findViewById(R.id.tv_1));
+// DisplayManager.scaleView(layoutView.findViewById(R.id.tv_2));
+// DisplayManager.scaleView(layoutView.findViewById(R.id.tv_3));
+// DisplayManager.scaleView(layoutView.findViewById(R.id.tv_4));
+// DisplayManager.scaleView(tvCancel);
+// DisplayManager.scaleView(tvConfirm);
+// DisplayManager.scaleView(editOutMax);
+// DisplayManager.scaleView(editOutMin);
+// DisplayManager.scaleView(editInMax);
+// DisplayManager.scaleView(editInMin);
+// DisplayManager.scaleView(tvMaxCalibration);
+// DisplayManager.scaleView(tvMinCalibration);
+// assert bean != null;
+// tvTitle.setText(bean.name + "号仓校准:");
+// editOutMax.setText(bean.outputTimeMax+"");
+// editOutMin.setText(bean.outputTimeMin+"");
+// editInMax.setText(bean.inputWightMax+"");
+// editInMin.setText(bean.inputWightMin+"");
+//
+// tvCancel.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// xCom.dismissX();
+// }
+// });
+// tvConfirm.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// if(editOutMax.getText().toString().isEmpty()||editOutMin.getText().toString().isEmpty()||
+// editInMax.getText().toString().isEmpty()||editInMin.getText().toString().isEmpty()){
+// ToastUtils.info("值不能为空!");
+// return;
+// }
+// float outMax = Float.parseFloat(editOutMax.getText().toString());
+// float outMin = Float.parseFloat(editOutMin.getText().toString());
+// float inMax = Float.parseFloat(editInMax.getText().toString());
+// float inMin = Float.parseFloat(editInMin.getText().toString());
+//
+// LogUtils.d(bean.id+" outMax"+outMax +"outMin="+outMin+"inMax="+inMax+"inMin="+inMin);
+// QueryDB.UpdateSilosCalibrate(bean.id, outMax,outMin,
+// inMax,inMin);
+// xCom.dismissX();
+// }
+// });
+//
+// tvMaxCalibration.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// if(editOutMax.getText().toString().isEmpty()){
+// ToastUtils.info("值不能为空!");
+// return;
+// }
+// startCalibration(Float.parseFloat(editOutMax.getText().toString()),position+1);
+//
+// }
+// });
+// tvMinCalibration.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// if(editOutMin.getText().toString().isEmpty()){
+// ToastUtils.info("值不能为空!");
+// return;
+// }
+// startCalibration(Float.parseFloat(editOutMin.getText().toString()),position+1);
+//
+// }
+// });
+// }
+// });
break;
}
@@ -356,7 +349,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL
}
}
- private void startCalibration(int value,int position){
+ private void startCalibration(float value,int position){
ThreadManager.get().execute(new Runnable() {
@Override
public void run() {
@@ -381,7 +374,7 @@ public class SystemSeasoningsetFragment extends BaseFragment implements MyClickL
break;
}
- Thread.sleep(value * 1000L);
+ Thread.sleep((long) (value * 1000L));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
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 660f3a86..c3b744f3 100644
--- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java
+++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java
@@ -245,27 +245,27 @@ public class MainInit {
BPA_SILOS_CALIBRATE silo = new BPA_SILOS_CALIBRATE();
silo.name = "液体"+i;
silo.num = i;
- silo.outputTimeMax = 5;
- silo.outputTimeMin = 2;
- silo.inputWightMax = 50;
- silo.inputWightMin = 20;
+ silo.outputTimeMax = 5.00f;
+ silo.outputTimeMin = 2.00f;
+ silo.inputWightMax = 50.00f;
+ silo.inputWightMin = 20.00f;
QueryDB.AddSilosCalibrate(silo);
}
BPA_SILOS_CALIBRATE silo = new BPA_SILOS_CALIBRATE();
silo.name = ControlAdress.加水.toString();
silo.num = 10;
- silo.outputTimeMax = 5;
- silo.outputTimeMin = 2;
- silo.inputWightMax = 50;
- silo.inputWightMin = 20;
+ silo.outputTimeMax = 5.00f;
+ silo.outputTimeMin = 2.00f;
+ silo.inputWightMax = 50.00f;
+ silo.inputWightMin = 20.00f;
QueryDB.AddSilosCalibrate(silo);
BPA_SILOS_CALIBRATE silo2 = new BPA_SILOS_CALIBRATE();
silo2.name = ControlAdress.勾芡.toString();
silo2.num = 11;
- silo2.outputTimeMax = 5;
- silo2.outputTimeMin = 2;
- silo2.inputWightMax = 50;
- silo2.inputWightMin = 20;
+ silo2.outputTimeMax = 5.00f;
+ silo2.outputTimeMin = 2.00f;
+ silo2.inputWightMax = 50.00f;
+ silo2.inputWightMin = 20.00f;
QueryDB.AddSilosCalibrate(silo2);
LogUtils.d(" 首次创建 料仓校准 silo2="+silo2.toString()+QueryDB.GetSilosCalibrateAll());
}
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 8e59faa8..9b01d1e4 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
@@ -2608,7 +2608,8 @@ public class QueryDB {
* @param inputMax
* @param inputMin
*/
- public static void UpdateSilosCalibrate(String id, int outputMax,int outputMin,int inputMax,int inputMin) {
+ public static boolean UpdateSilosCalibrate(String id, float outputMax,float outputMin,float inputMax,float inputMin) {
+ boolean success = false;
BPA_SILOS_CALIBRATE silos = GetSilosCalibrate(id);
if (silos != null) {
if(outputMax>=0){
@@ -2623,9 +2624,10 @@ public class QueryDB {
if(inputMin>=0){
silos.inputWightMin = inputMin;
}
- Update(BPA_SILOS_CALIBRATE.class, silos);
+ success = Update(BPA_SILOS_CALIBRATE.class, silos);
ModbusHelper.get().Add(QueryDB.GetSilosCalibrateAll());
}
+ return success;
}
//endregion
@@ -3033,10 +3035,10 @@ public class QueryDB {
//私有
((BPA_SILOS_CALIBRATE) data).name = cursor.getString((int) cursor.getColumnIndex("name"));
((BPA_SILOS_CALIBRATE) data).num = cursor.getInt((int) cursor.getColumnIndex("num"));
- ((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getInt((int) cursor.getColumnIndex("outputTimeMax"));
- ((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getInt((int) cursor.getColumnIndex("outputTimeMin"));
- ((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getInt((int) cursor.getColumnIndex("inputWightMin"));
- ((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getInt((int) cursor.getColumnIndex("inputWightMax"));
+ ((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getFloat((int) cursor.getColumnIndex("outputTimeMax"));
+ ((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getFloat((int) cursor.getColumnIndex("outputTimeMin"));
+ ((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getFloat((int) cursor.getColumnIndex("inputWightMin"));
+ ((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getFloat((int) cursor.getColumnIndex("inputWightMax"));
break;
case "BPA_ATTRIBUTE":
data = new BPA_ATTRIBUTE();
diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java
index 8f86f4fb..c69613d6 100644
--- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java
+++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java
@@ -10,13 +10,13 @@ public class BPA_SILOS_CALIBRATE extends ModeBase {
//料仓编号
public int num;
//输出时间最大值:s
- public int outputTimeMax;
+ public float outputTimeMax;
//输出时间最小值:s
- public int outputTimeMin;
+ public float outputTimeMin;
//输入重量最大值: g
- public int inputWightMax;
+ public float inputWightMax;
//输入重量最小值: g
- public int inputWightMin;
+ public float inputWightMin;
@Override
diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java
index cf9eb33d..dac38298 100644
--- a/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java
+++ b/app/src/main/java/com/bonait/bnframework/common/utils/AlertDialogUtils.java
@@ -81,6 +81,16 @@ public class AlertDialogUtils {
.setDialogListener(onClickListener);
}
+ /**
+ * 对话框,外界可关闭
+ * */
+ public static void showDialogNoBack(AppCompatActivity activity,int inflateId, XComDialog.OnDialogListener onClickListener) {
+ new XComDialog(activity, inflateId)
+ .init(false, false)
+ .setWindowSize()
+ .setDialogListener(onClickListener);
+ }
+
/**
* 功能暂未开通
* 对话框,有取消确定按钮
diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java
index ff935408..0db44ea4 100644
--- a/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java
+++ b/app/src/main/java/com/bonait/bnframework/common/utils/CookTimeUtils.java
@@ -3,7 +3,6 @@ package com.bonait.bnframework.common.utils;
import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.Service.AnalogConvert;
import com.bonait.bnframework.common.db.QueryDB;
-import com.bonait.bnframework.common.db.file.DBHelper;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE;
@@ -38,20 +37,16 @@ public class CookTimeUtils {
if (value !=null && value.contains(",")) {
String[] wl = value.split("[,]");
if (wl.length == 2) {
- int val;
+ float val;
String name = wl[0];
- if(wl[1].contains(".")){
- val = (int) Math.round((Double.parseDouble(wl[1])));
- }else {
- val = Integer.parseInt(wl[1]);
- }
+ val = Float.parseFloat(wl[1]);
// 根据名称查询料仓号 重量需根据校准值换算成时间
List silos = QueryDB.GetSolisByMaterialName(name);
if(!silos.isEmpty()){
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum( silos.get(0).num);
- short valueDeal = AnalogConvert.Scale((short) val, (short) bean.inputWightMax, (short) bean.inputWightMin,
- (short) bean.outputTimeMax, (short) bean.outputTimeMin);
+ int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin,
+ bean.outputTimeMax, bean.outputTimeMin);
time += valueDeal;
LogUtils.d("measureCookTime name="+name+";重量="+val+";换算时间="+valueDeal);
}
@@ -74,23 +69,19 @@ public class CookTimeUtils {
}else if(value!=null && value.contains("(克),")){
String[] res = value.split("克");
if(res.length==2){
- int val = 0;
- if(res[1].contains(".")){
- val = (int) Math.round((Double.parseDouble(res[1].substring(2))));
- }else {
- val = Integer.parseInt(res[1].substring(2));
- }
+ float val = 0;
+ val = Float.parseFloat(res[1].substring(2));
//1
if(item.processname.contains("加水")){
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum(10);
- short valueDeal = AnalogConvert.Scale((short) val, (short) bean.inputWightMax, (short) bean.inputWightMin,
- (short) bean.outputTimeMax, (short) bean.outputTimeMin);
+ int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin,
+ bean.outputTimeMax, bean.outputTimeMin);
LogUtils.d("measureCookTime 加水重量="+val+";换算加水时间="+valueDeal);
time += valueDeal;
}else if(item.processname.contains("勾芡")){
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE) QueryDB.GetSilosCalibrateByNum(11);
- short valueDeal = AnalogConvert.Scale((short) val, (short) bean.inputWightMax, (short) bean.inputWightMin,
- (short) bean.outputTimeMax, (short) bean.outputTimeMin);
+ int valueDeal = AnalogConvert.Scale( val, bean.inputWightMax, bean.inputWightMin,
+ bean.outputTimeMax, bean.outputTimeMin);
LogUtils.d("measureCookTime 加水重量="+val+";换算加水时间="+valueDeal);
time += valueDeal;
}
diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/SilosFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/SilosFragment.java
index 9f91f048..836818b1 100644
--- a/app/src/main/java/com/bonait/bnframework/ui/fragment/SilosFragment.java
+++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/SilosFragment.java
@@ -27,9 +27,9 @@ import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.DisplayManager;
-import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.databinding.FragmentSilosBinding;
import com.bonait.bnframework.ui.adapter.SilosAdapter;
+import com.bonait.bnframework.ui.widget.NewToastUtil;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import java.util.ArrayList;
@@ -129,7 +129,7 @@ public class SilosFragment extends BaseFragment {
case R.id.btn_calibrates:
BPA_SILOS_CALIBRATE bean = QueryDB.GetSilosCalibrateByNum(position+1);
if(bean!=null){
- AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(),R.layout.dialog_silos_calibrates_edit,
+ AlertDialogUtils.showDialogNoBack((AppCompatActivity) getActivity(),R.layout.dialog_silos_calibrates_edit,
new XComDialog.OnDialogListener(){
@Override
public void onDialogClick(View layoutView, XComDialog xCom) {
@@ -139,9 +139,11 @@ public class SilosFragment extends BaseFragment {
EditText editInMax = layoutView.findViewById(R.id.edit_in_max);
EditText editInMin = layoutView.findViewById(R.id.edit_in_min);
TextView tvCancel = layoutView.findViewById(R.id.tv_cancel);
- TextView tvConfirm = layoutView.findViewById(R.id.tv_confirm);
+ TextView btnSave = layoutView.findViewById(R.id.btn_save);
TextView tvMaxCalibration = layoutView.findViewById(R.id.tv_max_calibration);
TextView tvMinCalibration = layoutView.findViewById(R.id.tv_min_calibration);
+ TextView tvTest = layoutView.findViewById(R.id.btn_test);
+ EditText editTest = layoutView.findViewById(R.id.edit_test);
DisplayManager.scaleViewGroup(layoutView.findViewById(R.id.ll_content));
@@ -152,62 +154,66 @@ public class SilosFragment extends BaseFragment {
editInMax.setText(bean.inputWightMax+"");
editInMin.setText(bean.inputWightMin+"");
+ tvTest.setOnClickListener(view->{
+ if(editTest.getText().toString().isEmpty()){
+ NewToastUtil.getInstance().showToastError("模拟重量不能为空!");
+ return;
+ }
+ startCalibration(Float.parseFloat(editTest.getText().toString()),position+1,false);
+ });
tvCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
xCom.dismissX();
}
});
- tvConfirm.setOnClickListener(new View.OnClickListener() {
+ btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- CharSequence outMax = editOutMax.getText();
- CharSequence outMin = editOutMin.getText();
- CharSequence inMax = editInMax.getText();
- CharSequence inMin = editInMin.getText();
+ if(editOutMax.getText().toString().isEmpty()||editOutMin.getText().toString().isEmpty()||
+ editInMax.getText().toString().isEmpty()||editInMin.getText().toString().isEmpty()){
+ NewToastUtil.getInstance().showToastError("值不能为空!");
+ return;
+ }
+ float outMax = Float.parseFloat(editOutMax.getText().toString());
+ float outMin = Float.parseFloat(editOutMin.getText().toString());
+ float inMax = Float.parseFloat(editInMax.getText().toString());
+ float inMin = Float.parseFloat(editInMin.getText().toString());
- if (outMax != null && outMax.length() > 0 &&
- outMin != null && outMin.length() > 0 &&
- inMax != null && inMax.length() > 0&&
- inMin != null && inMin.length() > 0) {
- LogUtils.d(bean.id+" outMax"+outMax +"outMin="+outMin+"inMax="+inMax+"inMin="+inMin);
- QueryDB.UpdateSilosCalibrate(bean.id, Integer.parseInt(outMax.toString()),Integer.parseInt(outMin.toString()),
- Integer.parseInt(inMax.toString()),Integer.parseInt(inMin.toString()));
- xCom.dismissX();
- } else {
- ToastUtils.info("值不能为空!");
+ LogUtils.d(bean.id+" outMax"+outMax +"outMin="+outMin+"inMax="+inMax+"inMin="+inMin);
+ if(QueryDB.UpdateSilosCalibrate(bean.id, outMax,outMin,inMax,inMin)){
+ NewToastUtil.getInstance().showToast("保存成功");
+ }else {
+ NewToastUtil.getInstance().showToastError("保存失败");
}
+
}
});
tvMaxCalibration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- CharSequence outMax = editOutMax.getText();
- if (outMax != null && outMax.length() > 0){
- startCalibration(Integer.parseInt(outMax.toString()),position+1);
- }else {
- ToastUtils.info("值不能为空!");
+ if(editOutMax.getText().toString().isEmpty()){
+ NewToastUtil.getInstance().showToastError("值不能为空!");
+ return;
}
-
+ startCalibration(Float.parseFloat(editOutMax.getText().toString()),position+1,true);
}
});
tvMinCalibration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- CharSequence outMin = editOutMin.getText();
- if (outMin != null && outMin.length() > 0){
- startCalibration(Integer.parseInt(outMin.toString()),position+1);
- }else {
- ToastUtils.info("值不能为空!");
+ if(editOutMin.getText().toString().isEmpty()){
+ NewToastUtil.getInstance().showToastError("值不能为空!");
+ return;
}
-
+ startCalibration(Float.parseFloat(editOutMin.getText().toString()),position+1,true);
}
});
}
});
}else {
- ToastUtils.info("校准数据未初始化!");
+ NewToastUtil.getInstance().showToastError("校准数据未初始化!请联系管理员");
}
break;
}
@@ -219,8 +225,9 @@ public class SilosFragment extends BaseFragment {
* 开始出料
* @param value 出料时间
* @param position 仓号
+ * @param isCalibration 是否是校准
*/
- private void startCalibration(int value,int position){
+ private void startCalibration(float value,int position,boolean isCalibration){
ThreadManager.get().execute(new Runnable() {
@Override
public void run() {
@@ -235,17 +242,17 @@ public class SilosFragment extends BaseFragment {
case 7:
case 8:
case 9:
- ModbusHelper.get().addMaterial(value,position,true);
+ ModbusHelper.get().addMaterial(value,position,isCalibration);
break;
case 10:
- ModbusHelper.get().addWater(value,true);
+ ModbusHelper.get().addWater(value,isCalibration);
break;
case 11:
- ModbusHelper.get().addThickenWater(value,true);
+ ModbusHelper.get().addThickenWater(value,isCalibration);
break;
}
- Thread.sleep(value * 1000L);
+ Thread.sleep((long) (value * 1000L));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
diff --git a/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java b/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java
index fa93f623..616fb8ac 100644
--- a/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java
+++ b/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java
@@ -58,6 +58,26 @@ public class NewToastUtil {
toast.show();
}
+ public void showToastError(String message){
+ if(toast != null){
+ toast.cancel();
+ }
+ toast = new Toast(MainApplication.getContext());
+// toast.cancel();
+ String content = message;
+ if(message.length() > 50){
+ content = message.substring(0,50)+"...";
+ }
+ View layout = LayoutInflater.from(MainApplication.getContext()).inflate(R.layout.view_layout_error_toast,null);
+ ViewLayoutToastBinding binding = ViewLayoutToastBinding.bind(layout);
+ DisplayManager.scaleViewGroup(binding.getRoot());
+ binding.toastText.setText(content);
+ toast.setGravity(Gravity.BOTTOM,0,DimensUtil.getDimens(180));
+ toast.setDuration(Toast.LENGTH_SHORT);
+ toast.setView(layout);
+ toast.show();
+ }
+
/**
* 设置部分字体颜色
diff --git a/app/src/main/res/layout/dialog_silos_calibrates_edit.xml b/app/src/main/res/layout/dialog_silos_calibrates_edit.xml
index b1b72b73..6789a46d 100644
--- a/app/src/main/res/layout/dialog_silos_calibrates_edit.xml
+++ b/app/src/main/res/layout/dialog_silos_calibrates_edit.xml
@@ -27,7 +27,7 @@
android:textStyle="bold"
android:textSize="@dimen/sp_42"
android:textColor="@color/black"
- android:layout_marginTop="20dp"
+ android:layout_marginTop="@dimen/dp_10"
/>
+
@@ -83,24 +97,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
-
-
diff --git a/app/src/main/res/layout/fragment_home_device.xml b/app/src/main/res/layout/fragment_home_device.xml
index 414b2658..0ba421bb 100644
--- a/app/src/main/res/layout/fragment_home_device.xml
+++ b/app/src/main/res/layout/fragment_home_device.xml
@@ -91,7 +91,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
- app:layout_constraintTop_toBottomOf="@id/deviceErrorCode"
+ app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintLeft_toLeftOf="parent"
android:textSize="@dimen/sp_32"
android:textColor="@color/black"
@@ -255,7 +255,8 @@
android:layout_marginLeft="@dimen/dp_40"
android:background="@drawable/input_bj"
android:hint="加水重量(g)"
- android:inputType="number"
+ android:inputType="text"
+ android:digits="0123456789."
android:maxLines="1"
android:padding="@dimen/dp_5"
android:layout_gravity="center_vertical"
@@ -290,7 +291,8 @@
android:layout_marginLeft="@dimen/dp_40"
android:background="@drawable/input_bj"
android:hint="勾芡重量(g)"
- android:inputType="number"
+ android:inputType="text"
+ android:digits="0123456789."
android:maxLines="1"
android:padding="@dimen/dp_5"
android:layout_gravity="center_vertical"
@@ -336,7 +338,8 @@
android:layout_marginLeft="@dimen/dp_20"
android:background="@drawable/input_bj"
android:hint="重量(g)"
- android:inputType="number"
+ android:inputType="text"
+ android:digits="0123456789."
android:maxLines="1"
android:padding="@dimen/dp_5"
android:layout_gravity="center_vertical"
diff --git a/app/src/main/res/layout/item/layout/view_layout_error_toast.xml b/app/src/main/res/layout/item/layout/view_layout_error_toast.xml
new file mode 100644
index 00000000..c21e1f43
--- /dev/null
+++ b/app/src/main/res/layout/item/layout/view_layout_error_toast.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
\ No newline at end of file