|
|
@@ -1,5 +1,7 @@
|
|
|
package com.grkj.iscs.modbus
|
|
|
|
|
|
+import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_CARD
|
|
|
+import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_FINGERPRINT
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_LOCK
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_ELEC_LOCK_BOARD
|
|
|
@@ -122,10 +124,23 @@ class DockBean(
|
|
|
deviceList.add(KeyBean(0, isKeyExist, true, isKeyCharging, null, null))
|
|
|
}
|
|
|
|
|
|
+ val isCardExist = (byteArray[3].toInt() shr 4) and 0x1 == 1
|
|
|
+ val isFingerPrintExist = (byteArray[3].toInt() shr 5) and 0x1 == 1
|
|
|
val isDockCharging = (byteArray[3].toInt() shr 6) and 0x1 == 1
|
|
|
val isDockFullCharged = (byteArray[3].toInt() shr 7) and 0x1 == 1
|
|
|
+ println("便携式底座状态 : $isCardExist - $isFingerPrintExist - $isDockCharging - $isDockFullCharged")
|
|
|
+
|
|
|
+ // TODO 便携柜 list
|
|
|
+ if (getCardList().isEmpty()) {
|
|
|
+ deviceList.add(CardBean(0, isCardExist))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (getFingerPrintList().isEmpty()) {
|
|
|
+ deviceList.add(FingerPrintBean(0, isFingerPrintExist))
|
|
|
+ }
|
|
|
|
|
|
val changeList = mutableListOf<DeviceBean>()
|
|
|
+ // 锁具变化
|
|
|
for (i in 0 until getLockList().size) {
|
|
|
if (getLockList()[i].isExist != tempList[i]) {
|
|
|
getLockList()[i].isExist = tempList[i]
|
|
|
@@ -136,6 +151,7 @@ class DockBean(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 蓝牙钥匙变化
|
|
|
if (getKeyList()[0].isExist != isKeyExist) {
|
|
|
getKeyList()[0].isExist = isKeyExist
|
|
|
changeList.add(getKeyList()[0])
|
|
|
@@ -145,6 +161,17 @@ class DockBean(
|
|
|
getKeyList()[0].mac = null
|
|
|
}
|
|
|
}
|
|
|
+ // 卡片变化
|
|
|
+ if (getCardList()[0].isExist != isCardExist) {
|
|
|
+ getCardList()[0].isExist = isCardExist
|
|
|
+ changeList.add(getCardList()[0])
|
|
|
+ }
|
|
|
+ // 指纹变化
|
|
|
+ if (getFingerPrintList()[0].isExist != isFingerPrintExist) {
|
|
|
+ getFingerPrintList()[0].isExist = isFingerPrintExist
|
|
|
+ changeList.add(getFingerPrintList()[0])
|
|
|
+ }
|
|
|
+ LogUtil.i("便携式刷新状态 : $changeList")
|
|
|
return DockBean(addr, type, changeList)
|
|
|
}
|
|
|
else -> return null
|
|
|
@@ -160,6 +187,14 @@ class DockBean(
|
|
|
return deviceList.filter { it.type == 1 } as MutableList<LockBean>
|
|
|
}
|
|
|
|
|
|
+ fun getCardList(): MutableList<CardBean> {
|
|
|
+ return deviceList.filter { it.type == 2 } as MutableList<CardBean>
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getFingerPrintList(): MutableList<FingerPrintBean> {
|
|
|
+ return deviceList.filter { it.type == 3 } as MutableList<FingerPrintBean>
|
|
|
+ }
|
|
|
+
|
|
|
fun getBit(by: Byte): String {
|
|
|
val sb = StringBuffer()
|
|
|
sb.append((by.toInt() shr 7) and 0x1)
|
|
|
@@ -181,7 +216,7 @@ class DockBean(
|
|
|
* @param idx 锁具底座时:锁具序号 0-9 钥匙底座时:0-左 1-右 便携式底座:锁具0-2 钥匙0
|
|
|
* @param isExist true:有设备 false:无设备
|
|
|
*/
|
|
|
- open class DeviceBean(
|
|
|
+ sealed class DeviceBean(
|
|
|
var type: Int,
|
|
|
var idx: Int,
|
|
|
var isExist: Boolean
|
|
|
@@ -210,4 +245,20 @@ class DockBean(
|
|
|
isExist: Boolean,
|
|
|
var rfid: String?
|
|
|
) : DeviceBean(DEVICE_TYPE_LOCK, idx, isExist)
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡
|
|
|
+ */
|
|
|
+ class CardBean(
|
|
|
+ idx: Int,
|
|
|
+ isExist: Boolean
|
|
|
+ ) : DeviceBean(DEVICE_TYPE_CARD, idx, isExist)
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指纹
|
|
|
+ */
|
|
|
+ class FingerPrintBean(
|
|
|
+ idx: Int,
|
|
|
+ isExist: Boolean
|
|
|
+ ) : DeviceBean(DEVICE_TYPE_FINGERPRINT, idx, isExist)
|
|
|
}
|