Эх сурвалжийг харах

refactor(修改):
- 开关量采集新增

周文健 5 сар өмнө
parent
commit
6132d0cadc

+ 21 - 3
app/src/main/java/com/grkj/iscs/modbus/DockBean.kt

@@ -309,7 +309,24 @@ class DockBean(
                         if ((byteArray[4].toInt() shr i) and 0x1 == 1) {
                             val switchBoardAddr = (0x20 + i).toByte()
                             ModBusController.readSwitchStatus(addr, switchBoardAddr) { res ->
-                                //todo 开关量新增
+                                val switchStatus: MutableList<Boolean> = mutableListOf()
+                                for (switchIdx in 0..7) {
+                                    switchStatus.add((res[4].toInt() shr switchIdx) and 0x1 == 1)
+                                }
+                                for (switchIdx in 0..7) {
+                                    switchStatus.add((res[3].toInt() shr switchIdx) and 0x1 == 1)
+                                }
+                                for (idx in 0 until switchStatus.size) {
+                                    if (getSwitchList().isEmpty()) {
+                                        deviceList.add(
+                                            SwitchBean(
+                                                idx,
+                                                switchBoardAddr,
+                                                switchStatus[idx]
+                                            )
+                                        )
+                                    }
+                                }
                             }
                         }
                     }
@@ -483,6 +500,7 @@ class DockBean(
      */
     class SwitchBean(
         idx: Int,
-        isExist: Boolean,
-    ) : DeviceBean(DEVICE_TYPE_SWITCH, idx, isExist)
+        val switchBoardAddr: Byte,
+        var enabled: Boolean
+    ) : DeviceBean(DEVICE_TYPE_SWITCH, idx, true)
 }

+ 0 - 1
app/src/main/res/layout/item_rv_key_dock_status.xml

@@ -5,7 +5,6 @@
     android:layout_height="wrap_content"
     android:layout_marginHorizontal="@dimen/common_spacing_small"
     android:layout_marginVertical="@dimen/common_spacing_smallest"
-    android:background="@color/white"
     android:orientation="horizontal"
     android:padding="@dimen/common_spacing_small">
 

+ 0 - 1
app/src/main/res/layout/item_rv_lock_dock_status.xml

@@ -5,7 +5,6 @@
     android:layout_height="wrap_content"
     android:layout_marginHorizontal="@dimen/common_spacing_small"
     android:layout_marginVertical="@dimen/common_spacing_smallest"
-    android:background="@color/white"
     android:paddingHorizontal="@dimen/common_spacing_small">
 
     <androidx.recyclerview.widget.RecyclerView