소스 검색

完善设备信息变化处理

Frankensteinly 1 년 전
부모
커밋
7fe6c366ed
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. 15 1
      app/src/main/java/com/grkj/iscs/modbus/DeviceBean.kt

+ 15 - 1
app/src/main/java/com/grkj/iscs/modbus/DeviceBean.kt

@@ -5,7 +5,7 @@ import com.grkj.iscs.util.log.LogUtil
 /**
  * RS-485 设备信息 Bean
  *
- * @param addr 设备地址
+ * @param addr 设备地址 0x01-0x16
  * @param type 0x00:钥匙底座 0x01:锁具底座  0x02:电磁锁控制板
  * @param keyList 钥匙列表,钥匙底座才有
  * @param lockList 锁具列表,锁具底座才有
@@ -44,12 +44,22 @@ class DeviceBean(
                                 keyBean.hasKey = leftHasKey
                                 keyBean.isCharging = isLeftCharging
                                 changeList.add(keyBean)
+                                // 拿走钥匙,移除钥匙信息
+                                if (!leftHasKey) {
+                                    keyBean.rfid = null
+                                    keyBean.mac = null
+                                }
                             }
                         } else {
                             if (rightHasKey != keyBean.hasKey) {
                                 keyBean.hasKey = rightHasKey
                                 keyBean.isCharging = isRightCharging
                                 changeList.add(keyBean)
+                                // 拿走钥匙,移除钥匙信息
+                                if (!rightHasKey) {
+                                    keyBean.rfid = null
+                                    keyBean.mac = null
+                                }
                             }
                         }
                     }
@@ -75,6 +85,10 @@ class DeviceBean(
                         if (lockList[i].hasLock != tempList[i]) {
                             lockList[i].hasLock = tempList[i]
                             changeList.add(lockList[i])
+                            // 拿走锁具,移除锁具信息
+                            if (!tempList[i]) {
+                                lockList[i].rfid = null
+                            }
                         }
                     }