Browse Source

Merge remote-tracking branch 'origin/桌面小炒机' into 桌面小炒机

桌面小炒机
liup 4 months ago
parent
commit
e854e56308
6 changed files with 33 additions and 7 deletions
  1. +7
    -1
      app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java
  2. +4
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/RecProcessActivity.java
  3. +4
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java
  4. +2
    -3
      app/src/main/res/layout/activity_cook.xml
  5. +14
    -0
      app/src/main/res/layout/dialog/layout/layout_stir_control.xml
  6. +2
    -3
      app/src/main/res/layout/fragment_home_devices.xml

+ 7
- 1
app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java View File

@@ -280,7 +280,6 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
new ExceptionServer(address, length, new IExceptionHandling() { new ExceptionServer(address, length, new IExceptionHandling() {
@Override @Override
public void onSuccess(int add) throws InterruptedException, ExecutionException, ModbusTransportException, ModbusInitException, ModbusRespException { public void onSuccess(int add) throws InterruptedException, ExecutionException, ModbusTransportException, ModbusInitException, ModbusRespException {
IsConnected = true;
ReadCoilsResponse res = mw.syncReadCoil(SlaveId, add, length); ReadCoilsResponse res = mw.syncReadCoil(SlaveId, add, length);
boolean[] data = res.getBooleanData(); boolean[] data = res.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length); boolean[] result = Arrays.copyOfRange(data, 0, length);
@@ -288,6 +287,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
LogUtils.d(TAG+"ReadBool address="+address+" 读操作 成功:data="+data.toString()+" bytes="+result); LogUtils.d(TAG+"ReadBool address="+address+" 读操作 成功:data="+data.toString()+" bytes="+result);
} }
resultValue.set(OperateResultT.CreateSuccess(result)); resultValue.set(OperateResultT.CreateSuccess(result));
IsConnected = true;
} }


@Override @Override
@@ -329,6 +329,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
boolean[] data = res.getBooleanData(); boolean[] data = res.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length); boolean[] result = Arrays.copyOfRange(data, 0, length);
resultValue.set(OperateResultT.CreateSuccess(result)); resultValue.set(OperateResultT.CreateSuccess(result));
IsConnected = true;
} }


@Override @Override
@@ -370,6 +371,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
} }
if (data.length == length) { if (data.length == length) {
resultValue.set(OperateResultT.CreateSuccess(data)); resultValue.set(OperateResultT.CreateSuccess(data));
IsConnected = true;
} }
} }


@@ -409,6 +411,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
int[] tempValues= IntLib.ToInts(res.getData(),ReadDataFormat); int[] tempValues= IntLib.ToInts(res.getData(),ReadDataFormat);
if(tempValues.length==length){ if(tempValues.length==length){
resultValue.set(OperateResultT.CreateSuccess(tempValues)); resultValue.set(OperateResultT.CreateSuccess(tempValues));
IsConnected = true;
}else{ }else{
resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配")); resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配"));
} }
@@ -458,6 +461,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
if(data.length==tempLength){ if(data.length==tempLength){
byte[] result = Arrays.copyOfRange(data, 0, length); byte[] result = Arrays.copyOfRange(data, 0, length);
resultValue.set(OperateResultT.CreateSuccess(result)); resultValue.set(OperateResultT.CreateSuccess(result));
IsConnected = true;
}else{ }else{
resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配")); resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配"));
} }
@@ -485,6 +489,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
try { try {
if (data.length ==length*2) { if (data.length ==length*2) {
resultValue.set(OperateResultT.CreateSuccess(new String(data, "UTF-8").trim())); resultValue.set(OperateResultT.CreateSuccess(new String(data, "UTF-8").trim()));
IsConnected = true;
} }
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,字符串解析失败:"+ex.toString())); resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,字符串解析失败:"+ex.toString()));
@@ -512,6 +517,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
float[] tempValues = FloatLib.ToFloats(res.getData(),ReadDataFormat); float[] tempValues = FloatLib.ToFloats(res.getData(),ReadDataFormat);
if (tempValues.length == length) { if (tempValues.length == length) {
resultValue.set(OperateResultT.CreateSuccess(tempValues)); resultValue.set(OperateResultT.CreateSuccess(tempValues));
IsConnected = true;
}else{ }else{
resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配")); resultValue.set(OperateResultT.CreateFailedT(address+",读取失败,返回长度和实际读取长度不匹配"));
} }


+ 4
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/RecProcessActivity.java View File

@@ -359,6 +359,10 @@ public class RecProcessActivity extends BaseActivity {
break; break;


case "打散搅拌": case "打散搅拌":
if(isUp){
NewToastUtil.getInstance().showToast("上升状态无法启动搅拌");
return;
}
isScatterStir = true; isScatterStir = true;
viewBinding.device.btnStir.setBackgroundResource(R.drawable.bg_btn_run_anim_looper); viewBinding.device.btnStir.setBackgroundResource(R.drawable.bg_btn_run_anim_looper);
((AnimationDrawable)viewBinding.device.btnStir.getBackground()).start(); ((AnimationDrawable)viewBinding.device.btnStir.getBackground()).start();


+ 4
- 0
app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java View File

@@ -242,6 +242,10 @@ public class HomeDevicesFragment extends BaseFragment {
break; break;


case "打散搅拌": case "打散搅拌":
if(isUp){
NewToastUtil.getInstance().showToast("上升状态无法启动搅拌");
return;
}
isScatterStir = true; isScatterStir = true;
viewBinding.device.btnStir.setBackgroundResource(R.drawable.bg_btn_run_anim_looper); viewBinding.device.btnStir.setBackgroundResource(R.drawable.bg_btn_run_anim_looper);
((AnimationDrawable)viewBinding.device.btnStir.getBackground()).start(); ((AnimationDrawable)viewBinding.device.btnStir.getBackground()).start();


+ 2
- 3
app/src/main/res/layout/activity_cook.xml View File

@@ -13,7 +13,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginTop="@dimen/home_tab_height" android:layout_marginTop="@dimen/home_tab_height"
android:background="@mipmap/makenewbj"
> >
<!--android:background="@color/qmui_config_color_white"--> <!--android:background="@color/qmui_config_color_white"-->


@@ -40,7 +39,7 @@
android:singleLine="true" android:singleLine="true"
android:ellipsize="middle" android:ellipsize="middle"
android:layout_marginEnd="@dimen/dp_110" android:layout_marginEnd="@dimen/dp_110"
android:textColor="@color/white"
android:textColor="@color/black"
android:textSize="45dp" /> android:textSize="45dp" />


<TextView <TextView
@@ -50,7 +49,7 @@
android:fontFamily="@font/ziti0" android:fontFamily="@font/ziti0"
android:text="00 : 00" android:text="00 : 00"
android:layout_below="@id/goodname" android:layout_below="@id/goodname"
android:textColor="@color/white"
android:textColor="@color/black"
android:textSize="50dp" android:textSize="50dp"
android:textStyle="bold" /> android:textStyle="bold" />




+ 14
- 0
app/src/main/res/layout/dialog/layout/layout_stir_control.xml View File

@@ -18,6 +18,20 @@
android:paddingLeft="@dimen/dp_20" android:paddingLeft="@dimen/dp_20"
/> />


<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="@id/title_fire"
app:layout_constraintBottom_toBottomOf="@id/title_fire"
app:layout_constraintLeft_toLeftOf="parent"
android:textSize="@dimen/sp_28"
android:textColor="#FF9800"
android:textStyle="bold"
android:gravity="center"
android:text="(上升状态禁止搅拌)"
android:paddingLeft="@dimen/dp_230"
/>

<TextView <TextView
android:id="@+id/tv_fire_select" android:id="@+id/tv_fire_select"
android:layout_width="wrap_content" android:layout_width="wrap_content"


+ 2
- 3
app/src/main/res/layout/fragment_home_devices.xml View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@mipmap/makenewbj"
android:layout_height="match_parent"> android:layout_height="match_parent">


<TextView <TextView
@@ -10,7 +9,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/dp_10" android:padding="@dimen/dp_10"
android:textSize="@dimen/sp_32" android:textSize="@dimen/sp_32"
android:textColor="@color/white"
android:textColor="@color/black"
android:textStyle="bold" android:textStyle="bold"
android:text="设备状态:" android:text="设备状态:"
/> />
@@ -21,7 +20,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/dp_10" android:padding="@dimen/dp_10"
android:textSize="@dimen/sp_32" android:textSize="@dimen/sp_32"
android:textColor="@color/white"
android:textColor="@color/black"
android:textStyle="bold" android:textStyle="bold"
android:text="设备信息:" android:text="设备信息:"
android:layout_marginTop="@dimen/dp_50" android:layout_marginTop="@dimen/dp_50"


Loading…
Cancel
Save