Pārlūkot izejas kodu

钥匙分配添加待机模式判断

Frankensteinly 7 mēneši atpakaļ
vecāks
revīzija
870460ab9e

+ 4 - 0
app/src/main/java/com/grkj/iscs/BusinessManager.kt

@@ -147,6 +147,7 @@ object BusinessManager {
                                     mEventBus.postValue(MsgEvent(MSG_EVENT_LOADING, LoadingMsg(false, null, true)))
                                     val dock = ModBusController.getDockByKeyMac(it.data.bleBean.bleDevice.mac)
                                     ModBusController.controlKeyBuckle(true, keyBean.isLeft, dock?.addr)
+                                    keyBean.isReady = false
                                     ToastUtils.tip(R.string.take_out_key)
                                 }
                                 // 强制结束Loading防止有loading仍在显示
@@ -163,6 +164,7 @@ object BusinessManager {
                         // 待机模式
                         2 -> {
                             if (it.data.res == 1) {
+                                ModBusController.getKeyByMac(it.data.bleBean.bleDevice.mac)?.isReady = true
                                 // 延时再次获取当前状态,触发handleCurrentMode里工作票下发状态检查
                                 Executor.delayOnMain(500) {
                                     getCurrentStatus(1, it.data.bleBean.bleDevice)
@@ -1264,6 +1266,8 @@ object BusinessManager {
                                 }
                             }
                         }
+                    } ?: let {
+                        key.isReady = true
                     }
                 }
             }

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

@@ -54,6 +54,7 @@ class DockBean(
                                     changeList.add(keyBean.clone())
                                     keyBean.rfid = null
                                     keyBean.mac = null
+                                    keyBean.isReady = false
                                 } else {
                                     changeList.add(keyBean)
                                 }
@@ -67,6 +68,7 @@ class DockBean(
                                     changeList.add(keyBean.clone())
                                     keyBean.rfid = null
                                     keyBean.mac = null
+                                    keyBean.isReady = false
                                 } else {
                                     changeList.add(keyBean)
                                 }
@@ -246,14 +248,15 @@ class DockBean(
         var isLeft: Boolean,
         var isCharging: Boolean,
         var rfid: String?,
-        var mac: String?
+        var mac: String?,
+        var isReady: Boolean = false
     ) : DeviceBean(DEVICE_TYPE_KEY, idx, isExist) {
         override fun toString(): String {
-            return "KeyBean(isLeft=$isLeft, isCharging=$isCharging, rfid=$rfid, mac=$mac)"
+            return "KeyBean(isLeft=$isLeft, isCharging=$isCharging, rfid=$rfid, mac=$mac, isReady=$isReady)"
         }
 
         fun clone(): KeyBean {
-            return KeyBean(idx, isExist, isLeft, isCharging, rfid, mac)
+            return KeyBean(idx, isExist, isLeft, isCharging, rfid, mac, isReady)
         }
     }
 

+ 2 - 2
app/src/main/java/com/grkj/iscs/modbus/ModBusController.kt

@@ -517,7 +517,7 @@ object ModBusController {
     }
 
     /**
-     * 获取一个钥匙(存在的、有RFID、有Mac、连接的)
+     * 获取一个钥匙(存在的、有RFID、有Mac、连接的、是待机模式的
      *
      * @return 底座地址,钥匙
      */
@@ -533,7 +533,7 @@ object ModBusController {
         keyList.forEach {
             LogUtil.i("keyStatus : ${it.isExist} - ${it.rfid} - ${it.mac} - ${BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice} - ${BleManager.getInstance().isConnected(BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice)}")
         }
-        val key = keyList.find { it.isExist && it.rfid != null && it.mac != null &&
+        val key = keyList.find { it.isExist && it.rfid != null && it.mac != null && it.isReady &&
                 BleManager.getInstance().isConnected(BusinessManager.getBleDeviceByMac(it.mac!!)?.bleDevice) }
         if (key == null) {
             LogUtil.e("getOneKey : no key match")