@@ -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 | |||
@@ -4,13 +4,17 @@ | |||
package="com.bonait.bnframework"> | |||
<uses-sdk tools:overrideLibrary="com.aliyun.iot.breeze.biz,com.aliyun.iot.breeze.ota, com.aliyun.iot.breeze.sdk,com.aliyun.iot.ble,com.aliyun.alink.linksdk.tmp" /> | |||
<uses-feature | |||
android:name="android.hardware.camera" | |||
android:required="false" /> | |||
<!-- 网络权限 --> | |||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 网络连接 --> | |||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 获取网络连接状态 --> | |||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 写存储的权限 --> | |||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 读存储的权限 --> | |||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- 0未知来源的应用权限,更新App --> | |||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <!-- 在SDCard中创建与删除文件权限 --> | |||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" | |||
tools:ignore="ProtectedPermissions" /> <!-- 在SDCard中创建与删除文件权限 --> | |||
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" /> <!-- DownloadManager --> | |||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <!-- 录音权限 --> | |||
<uses-permission android:name="android.permission.RECORD_VIDEO" /> <!-- 录像权限 --> | |||
@@ -22,6 +26,7 @@ | |||
<application | |||
android:name=".MainApplication" | |||
android:allowBackup="true" | |||
android:banner="@mipmap/ico" | |||
android:hardwareAccelerated="false" | |||
android:icon="@mipmap/ico" | |||
android:label="@string/app_name" | |||
@@ -198,12 +203,13 @@ | |||
<!-- <category android:name="android.intent.category.LAUNCHER" />--> | |||
<action android:name="android.intent.action.MAIN" /> | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> | |||
<!-- <category android:name="android.intent.category.LEANBACK_LAUNCHER" />--> | |||
<category android:name="android.intent.category.DEFAULT" /> | |||
<category android:name="android.intent.category.HOME" /> | |||
</intent-filter> | |||
</activity> | |||
<activity android:name=".ViewModel.ActivityViewModel.LoginActivity" | |||
android:exported="true" | |||
android:launchMode="singleTask"> | |||
<!-- <intent-filter> --> | |||
@@ -213,7 +219,8 @@ | |||
<!-- <category android:name="android.intent.category.DEFAULT" /> --> | |||
<!-- </intent-filter> --> | |||
</activity> | |||
<activity android:name=".test.TestActivity"> | |||
<activity android:name=".test.TestActivity" | |||
android:exported="true"> | |||
<!-- | |||
<intent-filter> | |||
@@ -225,6 +232,7 @@ | |||
</activity> | |||
<activity android:name=".ViewModel.ActivityViewModel.BottomNavigation2Activity" | |||
android:launchMode="singleTask" | |||
android:exported="true" | |||
android:screenOrientation="portrait"/> | |||
<receiver | |||
@@ -107,7 +107,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{ | |||
.setStopBits(1) // 停止位 | |||
.setTimeout(500).setRetries(0); // 不重试 | |||
AtomicReference<String> errorInfo=new AtomicReference<>(""); | |||
while (IsConnected==false) | |||
while (!IsConnected) | |||
{ | |||
mw.init(param, new ModbusCallback<com.serotonin.modbus4j.ModbusMaster>() { | |||
@Override | |||
@@ -128,11 +128,9 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{ | |||
} | |||
}); | |||
if(!IsReconnection || ConfigName.TEST)break; | |||
if(IsConnected==false) Thread.sleep(5000); | |||
if(!IsConnected) Thread.sleep(5000); | |||
} | |||
if(IsConnected)return OperateResult.CreateSuccess(); | |||
else return OperateResult.CreateFailed(errorInfo.get()); | |||
return OperateResult.CreateSuccess(); | |||
}catch(Exception ex){ | |||
return OperateResult.CreateFailed(ex); | |||
} | |||
@@ -51,11 +51,11 @@ public class AnalogConvert { | |||
*/ | |||
public static short et_Pressure_Lower_Limit=0; | |||
public static short Scale(short InputValue, short InputMax, short InputMin, short OutMax, short OutMin){ | |||
public static int Scale(float InputValue, float InputMax, float InputMin, float OutMax, float OutMin){ | |||
try{ | |||
LogUtils.d("AnalogConvert measureCookTime InputValue="+InputValue+" InputMax="+InputMax+";InputMin="+InputMin+";OutMax="+OutMax+";OutMin="+OutMin); | |||
if(InputValue<=0|| InputMax<=0||InputMin<=0){ | |||
if(InputValue<0|| InputMax<0){ | |||
return 0; | |||
} | |||
if(((InputMax - InputMin) + OutMin)==0){ | |||
@@ -65,7 +65,8 @@ public class AnalogConvert { | |||
if(tempValue<=0){ | |||
tempValue = 0; | |||
} | |||
short num =(short)tempValue; | |||
// short num =(short)tempValue; | |||
int num =(int)(tempValue*100); | |||
// if (num > OutMax) return OutMax; | |||
// if (num < OutMin) return OutMin; | |||
return num; | |||
@@ -75,42 +76,42 @@ public class AnalogConvert { | |||
return 0; | |||
} | |||
/** | |||
* 获取当前实际压力值 | |||
* @param InputValue 当前实际压力的模拟量值 | |||
* @return 当前实际压力值 | |||
*/ | |||
public static short getCurrentPressure(short InputValue){ | |||
return Scale(InputValue,et_Pressure_Analog_Upper_Limit,et_Pressure_Analog_Lower_Limit,et_Pressure_Upper_Limit,et_Pressure_Lower_Limit); | |||
} | |||
/** | |||
* 获取当前实际压力的模拟量值 | |||
* @param InputValue 当前实际压力值 | |||
* @return 对应的模拟量值 | |||
*/ | |||
public static short getCurrentPressureAnalog(short InputValue){ | |||
return Scale(InputValue,et_Pressure_Upper_Limit,et_Pressure_Lower_Limit,et_Pressure_Analog_Upper_Limit,et_Pressure_Analog_Lower_Limit); | |||
} | |||
/** | |||
* 获取当前实际温度值 | |||
* @param InputValue 当前实际温度的模拟量值 | |||
* @return 当前实际温度值 | |||
*/ | |||
public static short getCurrentTemperature(short InputValue){ | |||
return Scale(InputValue,et_Temperature_Analog_Upper_Limit,et_Temperature_Analog_Lower_Limit,et_Temperature_Upper_Limit,et_Temperature_Lower_Limit); | |||
} | |||
/** | |||
* 获取当前实际温度的模拟量值 | |||
* @param InputValue 当前实际压力值 | |||
* @return 对应的模拟量值 | |||
*/ | |||
public static short getCurrentTemperatureAnalog(short InputValue){ | |||
return Scale(InputValue,et_Temperature_Upper_Limit,et_Temperature_Lower_Limit,et_Temperature_Analog_Upper_Limit,et_Temperature_Analog_Lower_Limit); | |||
} | |||
// /** | |||
// * 获取当前实际压力值 | |||
// * @param InputValue 当前实际压力的模拟量值 | |||
// * @return 当前实际压力值 | |||
// */ | |||
// public static short getCurrentPressure(short InputValue){ | |||
// return Scale(InputValue,et_Pressure_Analog_Upper_Limit,et_Pressure_Analog_Lower_Limit,et_Pressure_Upper_Limit,et_Pressure_Lower_Limit); | |||
// } | |||
// | |||
// /** | |||
// * 获取当前实际压力的模拟量值 | |||
// * @param InputValue 当前实际压力值 | |||
// * @return 对应的模拟量值 | |||
// */ | |||
// public static short getCurrentPressureAnalog(short InputValue){ | |||
// return Scale(InputValue,et_Pressure_Upper_Limit,et_Pressure_Lower_Limit,et_Pressure_Analog_Upper_Limit,et_Pressure_Analog_Lower_Limit); | |||
// } | |||
// | |||
// | |||
// /** | |||
// * 获取当前实际温度值 | |||
// * @param InputValue 当前实际温度的模拟量值 | |||
// * @return 当前实际温度值 | |||
// */ | |||
// public static short getCurrentTemperature(short InputValue){ | |||
// return Scale(InputValue,et_Temperature_Analog_Upper_Limit,et_Temperature_Analog_Lower_Limit,et_Temperature_Upper_Limit,et_Temperature_Lower_Limit); | |||
// } | |||
// | |||
// /** | |||
// * 获取当前实际温度的模拟量值 | |||
// * @param InputValue 当前实际压力值 | |||
// * @return 对应的模拟量值 | |||
// */ | |||
// public static short getCurrentTemperatureAnalog(short InputValue){ | |||
// return Scale(InputValue,et_Temperature_Upper_Limit,et_Temperature_Lower_Limit,et_Temperature_Analog_Upper_Limit,et_Temperature_Analog_Lower_Limit); | |||
// } | |||
public static void SaveConfig(){ | |||
Context dishesCon = ConfigName.getInstance().dishesCon; | |||
@@ -129,18 +129,18 @@ public class ModbusHelper extends ModbusMaster { | |||
* @param value | |||
* @param isCalibration 是否是校准 | |||
*/ | |||
public void addWater(int value,boolean isCalibration){ | |||
public void addWater(float value,boolean isCalibration){ | |||
LogUtils.d(TAG+"加水控制 addSeason "); | |||
getCalibrationPar(ControlAdress.加水.toString()).OnSource(item->{ | |||
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content; | |||
short valueDeal; | |||
if(isCalibration){ | |||
valueDeal = (short) value; | |||
valueDeal = (short) (value*100); | |||
}else { | |||
valueDeal = AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin, | |||
(short) bean.outputTimeMax, (short) bean.outputTimeMin); | |||
valueDeal = (short) AnalogConvert.Scale( value, bean.inputWightMax, bean.inputWightMin, | |||
bean.outputTimeMax, bean.outputTimeMin); | |||
} | |||
WriteShort(getPLC(ControlAdress.加水时间).PlcAddress, (short) (valueDeal*100)); | |||
WriteShort(getPLC(ControlAdress.加水时间).PlcAddress, (valueDeal)); | |||
WriteBool(getPLC(ControlAdress.加水).PlcAddress,true); | |||
readWater(); | |||
LogUtils.d(TAG+TAG+"加水控制 addSeason value="+value + "valueDeal="+valueDeal); | |||
@@ -158,7 +158,7 @@ public class ModbusHelper extends ModbusMaster { | |||
* @param position 几号仓 | |||
* @param isCalibration 是否是校准 | |||
*/ | |||
public void addMaterial(int value, int position,boolean isCalibration){ | |||
public void addMaterial(float value, int position,boolean isCalibration){ | |||
ControlAdress controlAdress = ControlAdress.液体1; | |||
ControlAdress controlTimeAdress = ControlAdress.液体时间1; | |||
switch (position){ | |||
@@ -207,12 +207,12 @@ public class ModbusHelper extends ModbusMaster { | |||
BPA_SILOS_CALIBRATE bean = (BPA_SILOS_CALIBRATE)item.Content; | |||
short valueDeal ; | |||
if(isCalibration){ | |||
valueDeal = (short) value; | |||
valueDeal = (short) (value*100); | |||
}else { | |||
valueDeal = AnalogConvert.Scale((short) value, (short) bean.inputWightMax, (short) bean.inputWightMin, | |||
(short) bean.outputTimeMax, (short) bean.outputTimeMin); | |||
valueDeal = (short) AnalogConvert.Scale( value, bean.inputWightMax, bean.inputWightMin, | |||
bean.outputTimeMax, bean.outputTimeMin); | |||
} | |||
WriteShort(getPLC(finalControlTimeAdress).PlcAddress, (short) (valueDeal*100)); | |||
WriteShort(getPLC(finalControlTimeAdress).PlcAddress, valueDeal); | |||
WriteBool(getPLC(finalControlAdress).PlcAddress,true); | |||
LogUtils.d(TAG+"液体料控制 addSeason value="+value+" ;valueDeal="+valueDeal+";position="+position+"-->>"); | |||
}) ; | |||
@@ -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); | |||
}); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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(); | |||
//初始化阿里云连接 | |||
@@ -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("值不能为空!"); | |||
@@ -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); | |||
} | |||
@@ -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()); | |||
} | |||
@@ -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(); | |||
@@ -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 | |||
@@ -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); | |||
} | |||
/** | |||
* 功能暂未开通 | |||
* 对话框,有取消确定按钮 | |||
@@ -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<BPA_SILOS> 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; | |||
} | |||
@@ -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); | |||
} | |||
@@ -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(); | |||
} | |||
/** | |||
* 设置部分字体颜色 | |||
@@ -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" | |||
/> | |||
<TextView | |||
@@ -47,29 +47,43 @@ | |||
<TextView | |||
android:id="@+id/tv_2" | |||
android:layout_width="wrap_content" | |||
android:layout_marginRight="@dimen/dp_20" | |||
android:layout_height="@dimen/dp_70" | |||
android:text="输出时间最小值(s)" | |||
android:textSize="38sp" | |||
android:layout_height="@dimen/dp_90" | |||
android:text="输出时间\n最小值(s)" | |||
android:textSize="32sp" | |||
android:layout_gravity="center_vertical" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
/> | |||
<EditText | |||
android:id="@+id/edit_out_min" | |||
android:layout_width="@dimen/dp_300" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_marginLeft="5dp" | |||
android:layout_width="300dp" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="25dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="" | |||
android:inputType="number" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:layout_gravity="center_vertical" | |||
android:textSize="32sp" /> | |||
<TextView | |||
android:id="@+id/tv_min_calibration" | |||
android:layout_width="wrap_content" | |||
android:layout_height="@dimen/dp_90" | |||
android:textSize="@dimen/sp_32" | |||
android:layout_marginLeft="25dp" | |||
android:textColor="@color/white" | |||
android:text="最小值校验" | |||
android:paddingLeft="@dimen/dp_20" | |||
android:paddingRight="@dimen/dp_20" | |||
android:background="@drawable/bg_round10_yellow_btn" | |||
android:layout_alignParentStart="true" | |||
android:gravity="center" | |||
android:layout_gravity="right" | |||
/> | |||
</LinearLayout> | |||
@@ -83,24 +97,24 @@ | |||
<TextView | |||
android:id="@+id/tv_4" | |||
android:layout_width="wrap_content" | |||
android:layout_marginRight="@dimen/dp_20" | |||
android:layout_height="@dimen/dp_70" | |||
android:text="输入重量最小值(g)" | |||
android:textSize="38sp" | |||
android:layout_marginEnd="@dimen/dp_20" | |||
android:layout_height="@dimen/dp_90" | |||
android:text="输入重量\n最小值(g)" | |||
android:textSize="32sp" | |||
android:layout_gravity="center_vertical" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
/> | |||
<EditText | |||
android:id="@+id/edit_in_min" | |||
android:layout_width="@dimen/dp_300" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="" | |||
android:inputType="number" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:layout_gravity="center_vertical" | |||
@@ -115,29 +129,42 @@ | |||
<TextView | |||
android:id="@+id/tv_1" | |||
android:layout_width="wrap_content" | |||
android:layout_marginRight="@dimen/dp_20" | |||
android:layout_height="@dimen/dp_70" | |||
android:text="输出时间最大值(s)" | |||
android:textSize="38sp" | |||
android:layout_height="@dimen/dp_90" | |||
android:text="输出时间\n最大值(s)" | |||
android:textSize="32sp" | |||
android:layout_gravity="center_vertical" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
/> | |||
<EditText | |||
android:id="@+id/edit_out_max" | |||
android:layout_width="@dimen/dp_300" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_marginLeft="5dp" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="25dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="" | |||
android:inputType="number" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:layout_gravity="center_vertical" | |||
android:textSize="32sp" /> | |||
<TextView | |||
android:id="@+id/tv_max_calibration" | |||
android:layout_width="wrap_content" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="25dp" | |||
android:textSize="@dimen/sp_32" | |||
android:textColor="@color/white" | |||
android:text="最大值校验" | |||
android:paddingLeft="@dimen/dp_20" | |||
android:paddingRight="@dimen/dp_20" | |||
android:background="@drawable/bg_round10_yellow_btn" | |||
android:gravity="center" | |||
/> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -149,24 +176,23 @@ | |||
<TextView | |||
android:id="@+id/tv_3" | |||
android:layout_width="wrap_content" | |||
android:layout_marginRight="@dimen/dp_20" | |||
android:layout_height="@dimen/dp_70" | |||
android:text="输入重量最大值(g)" | |||
android:textSize="38sp" | |||
android:layout_height="@dimen/dp_90" | |||
android:text="输入重量\n最大值(g)" | |||
android:textSize="32sp" | |||
android:layout_gravity="center_vertical" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
/> | |||
<EditText | |||
android:id="@+id/edit_in_max" | |||
android:layout_width="@dimen/dp_300" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_marginLeft="5dp" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="25dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="" | |||
android:inputType="number" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:layout_gravity="center_vertical" | |||
@@ -176,44 +202,73 @@ | |||
android:id="@+id/rl_calibration" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="30dp" | |||
android:layout_marginTop="20dp" | |||
> | |||
<TextView | |||
android:id="@+id/tv_min_calibration" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textSize="@dimen/sp_32" | |||
android:id="@+id/btn_save" | |||
android:layout_width="match_parent" | |||
android:layout_height="90dp" | |||
android:textSize="@dimen/sp_38" | |||
android:textColor="@color/white" | |||
android:text="最小值校验" | |||
android:text=" 保存校准值 " | |||
android:paddingLeft="@dimen/dp_20" | |||
android:paddingRight="@dimen/dp_20" | |||
android:paddingTop="@dimen/dp_20" | |||
android:paddingBottom="@dimen/dp_20" | |||
android:background="@drawable/bg_round10_yellow_btn" | |||
android:layout_alignParentStart="true" | |||
android:layout_marginStart="@dimen/dp_50" | |||
android:background="@drawable/bg_round10_red_btn" | |||
android:gravity="center" | |||
android:layout_centerHorizontal="true" | |||
/> | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="20dp" | |||
> | |||
<TextView | |||
android:id="@+id/tv_max_calibration" | |||
android:id="@+id/tv_5" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_height="@dimen/dp_90" | |||
android:text="模拟出料(g)" | |||
android:textSize="32sp" | |||
android:layout_gravity="center_vertical" | |||
android:gravity="center_vertical" | |||
android:textColor="@color/black" | |||
/> | |||
<EditText | |||
android:id="@+id/edit_test" | |||
android:layout_width="@dimen/dp_270" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_marginLeft="25dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="" | |||
android:inputType="text" | |||
android:digits="0123456789." | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:layout_gravity="center_vertical" | |||
android:textSize="32sp" /> | |||
<TextView | |||
android:id="@+id/btn_test" | |||
android:layout_width="wrap_content" | |||
android:layout_height="90dp" | |||
android:textSize="@dimen/sp_32" | |||
android:layout_marginLeft="25dp" | |||
android:textColor="@color/white" | |||
android:text="最大值校验" | |||
android:text=" 模拟出料 " | |||
android:paddingLeft="@dimen/dp_20" | |||
android:paddingRight="@dimen/dp_20" | |||
android:paddingTop="@dimen/dp_20" | |||
android:paddingBottom="@dimen/dp_20" | |||
android:background="@drawable/bg_round10_yellow_btn" | |||
android:gravity="center" | |||
android:layout_alignParentEnd="true" | |||
android:layout_marginEnd="@dimen/dp_50" | |||
android:layout_gravity="end" | |||
/> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
<RelativeLayout | |||
android:id="@+id/rl_btn" | |||
@@ -224,28 +279,15 @@ | |||
<TextView | |||
android:id="@+id/tv_cancel" | |||
android:layout_width="100dp" | |||
android:layout_height="100dp" | |||
android:textSize="@dimen/sp_38" | |||
android:textColor="@color/blue_primary" | |||
android:text="@string/tip_save_cancel" | |||
android:layout_alignParentStart="true" | |||
android:layout_marginStart="@dimen/dp_50" | |||
android:gravity="center" | |||
/> | |||
<TextView | |||
android:id="@+id/tv_confirm" | |||
android:layout_width="100dp" | |||
android:layout_width="200dp" | |||
android:layout_height="100dp" | |||
android:textSize="38sp" | |||
android:textColor="@color/blue_primary" | |||
android:text="@string/tip_save_confirm" | |||
android:text="关闭" | |||
android:gravity="center" | |||
android:layout_alignParentEnd="true" | |||
android:layout_marginEnd="@dimen/dp_50" | |||
/> | |||
</RelativeLayout> | |||
@@ -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" | |||
@@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:id="@+id/toast_root" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:layout_marginLeft="@dimen/dp_50" | |||
android:layout_marginRight="@dimen/dp_50" | |||
android:background="@drawable/bg_round50_red_btn" | |||
android:orientation="horizontal"> | |||
<ImageView | |||
android:id="@+id/toast_icon" | |||
android:layout_width="@dimen/dp_70" | |||
android:layout_height="@dimen/dp_70" | |||
android:src="@mipmap/boluo" | |||
/> | |||
<TextView | |||
android:id="@+id/toast_text" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textSize="@dimen/sp_32" | |||
android:textColor="@color/white" | |||
android:layout_toRightOf="@id/toast_icon" | |||
android:paddingLeft="@dimen/dp_15" | |||
android:paddingRight="@dimen/dp_30" | |||
android:gravity="center" | |||
android:layout_centerVertical="true" | |||
tools:text="信息ssss" | |||
/> | |||
</RelativeLayout> |