|
@@ -1,6 +1,8 @@
|
|
|
package com.grkj.iscs.modbus
|
|
package com.grkj.iscs.modbus
|
|
|
|
|
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
|
|
+import com.grkj.iscs.extentions.removeLeadingZeros
|
|
|
|
|
+import com.grkj.iscs.extentions.toHexStrings
|
|
|
import com.grkj.iscs.util.Executor
|
|
import com.grkj.iscs.util.Executor
|
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
|
import java.util.concurrent.Executors
|
|
import java.util.concurrent.Executors
|
|
@@ -135,7 +137,11 @@ object ModBusController {
|
|
|
val noLockIdxList = deviceBean.lockList.filter { !it.hasLock }.map { it.idx } as MutableList<Int>
|
|
val noLockIdxList = deviceBean.lockList.filter { !it.hasLock }.map { it.idx } as MutableList<Int>
|
|
|
|
|
|
|
|
hasLockIdxList.forEach { idx ->
|
|
hasLockIdxList.forEach { idx ->
|
|
|
- readLockRfid(deviceBean.addr!!.toInt() - 1, idx)
|
|
|
|
|
|
|
+ readLockRfid(deviceBean.addr!!.toInt() - 1, idx) { res ->
|
|
|
|
|
+ val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
|
|
+ LogUtil.i("初始化锁具 RFID : $rfid")
|
|
|
|
|
+ updateLockRfid(deviceBean.addr!!.toInt(), idx, rfid)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
controlLockBuckle(true, deviceBean.addr!!.toInt() - 1, noLockIdxList)
|
|
controlLockBuckle(true, deviceBean.addr!!.toInt() - 1, noLockIdxList)
|
|
@@ -152,7 +158,11 @@ object ModBusController {
|
|
|
deviceBean.keyList.forEach { key ->
|
|
deviceBean.keyList.forEach { key ->
|
|
|
if (key.hasKey) {
|
|
if (key.hasKey) {
|
|
|
LogUtil.i("initKey : ${deviceBean.addr!!.toInt() - 1} : ${key.isLeft}")
|
|
LogUtil.i("initKey : ${deviceBean.addr!!.toInt() - 1} : ${key.isLeft}")
|
|
|
- readKeyRfid(deviceBean.addr!!.toInt() - 1, key.isLeft)
|
|
|
|
|
|
|
+ readKeyRfid(deviceBean.addr!!.toInt() - 1, key.isLeft) { isLeft, res ->
|
|
|
|
|
+ val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
|
|
+ LogUtil.i("初始化钥匙 RFID : $rfid")
|
|
|
|
|
+ updateKeyRfid(deviceBean.addr!!.toInt(), isLeft, rfid)
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
// TODO 关闭钥匙卡扣
|
|
// TODO 关闭钥匙卡扣
|
|
|
}
|
|
}
|