|
@@ -28,16 +28,56 @@ class ModbusActivity : BaseMvpActivity<IModbusView, ModBusPresenter, ActivityMod
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- mBinding?.buckleStatus?.setOnClickListener {
|
|
|
|
|
- ModBusController.readBuckleStatus(null, { res ->
|
|
|
|
|
- LogUtil.i("单卡扣状态 : ${res.toHexStrings()}")
|
|
|
|
|
- },
|
|
|
|
|
- { res ->
|
|
|
|
|
- LogUtil.i("多卡扣状态 : ${res.map { it.toHexStrings()}}")
|
|
|
|
|
- res.forEach { bytes ->
|
|
|
|
|
|
|
+ mBinding?.keyBuckleStatus?.setOnClickListener {
|
|
|
|
|
+ // TODO slaveIdx暂时写死,调试用
|
|
|
|
|
+ ModBusController.readBuckleStatus(false, 1) { type, res ->
|
|
|
|
|
+ LogUtil.i("单slave卡扣状态 : $type - ${res.toHexStrings()}")
|
|
|
|
|
+ when (type) {
|
|
|
|
|
+ 0 -> {
|
|
|
|
|
+ val isLeftLock = (res[4].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+ val isRightLock = (res[4].toInt() shr 4) and 0x1 == 1
|
|
|
|
|
+ println("钥匙底座卡扣状态 : $isLeftLock - $isRightLock")
|
|
|
|
|
+ }
|
|
|
|
|
+ 1 -> {
|
|
|
|
|
+ val tempList = mutableListOf<Boolean>()
|
|
|
|
|
+ for (i in 0..7) {
|
|
|
|
|
+ tempList.add((res[4].toInt() shr i) and 0x1 == 1)
|
|
|
|
|
+ }
|
|
|
|
|
+ println("锁具底座卡扣1-8状态 : $tempList")
|
|
|
|
|
+ }
|
|
|
|
|
+ 2 -> {
|
|
|
|
|
+ val lock9Status = (res[4].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+ val lock10Status = (res[4].toInt() shr 1) and 0x1 == 1
|
|
|
|
|
+ println("锁具底座卡扣9、10状态 : $lock9Status - $lock10Status")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ mBinding?.lockBuckleStatus?.setOnClickListener {
|
|
|
|
|
+ // TODO slaveIdx暂时写死,调试用
|
|
|
|
|
+ ModBusController.readBuckleStatus(true, 0) { type, res ->
|
|
|
|
|
+ LogUtil.i("单slave卡扣状态 : $type - ${res.toHexStrings()}")
|
|
|
|
|
+ when (type) {
|
|
|
|
|
+ 0 -> {
|
|
|
|
|
+ val isLeftLock = (res[4].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+ val isRightLock = (res[4].toInt() shr 4) and 0x1 == 1
|
|
|
|
|
+ println("钥匙底座卡扣状态 : $isLeftLock - $isRightLock")
|
|
|
|
|
+ }
|
|
|
|
|
+ 1 -> {
|
|
|
|
|
+ val tempList = mutableListOf<Boolean>()
|
|
|
|
|
+ for (i in 0..7) {
|
|
|
|
|
+ tempList.add((res[4].toInt() shr i) and 0x1 == 1)
|
|
|
|
|
+ }
|
|
|
|
|
+ println("锁具底座卡扣1-8状态 : $tempList")
|
|
|
|
|
+ }
|
|
|
|
|
+ 2 -> {
|
|
|
|
|
+ val lock9Status = (res[4].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+ val lock10Status = (res[4].toInt() shr 1) and 0x1 == 1
|
|
|
|
|
+ println("锁具底座卡扣9、10状态 : $lock9Status - $lock10Status")
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mBinding?.deviceType?.setOnClickListener {
|
|
mBinding?.deviceType?.setOnClickListener {
|
|
@@ -108,6 +148,14 @@ class ModbusActivity : BaseMvpActivity<IModbusView, ModBusPresenter, ActivityMod
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ mBinding?.keyRfid?.setOnClickListener {
|
|
|
|
|
+ // TODO 暂时写死,调试用
|
|
|
|
|
+ ModBusController.readKeyRfid(1, true) { res ->
|
|
|
|
|
+ val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
|
|
+ println("钥匙RFID : $rfid")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
mBinding?.exit?.setOnClickListener { finish() }
|
|
mBinding?.exit?.setOnClickListener { finish() }
|
|
|
}
|
|
}
|
|
|
|
|
|