|
|
@@ -15,15 +15,7 @@ import com.grkj.iscs.util.ToastUtils
|
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
|
|
|
|
class PresentationPresenter : BasePresenter<IPresentationView>() {
|
|
|
- fun initModbus() {
|
|
|
- ModBusController.setSlaveCount(1)
|
|
|
- ModBusController.interruptReadTrashBinStatus(false)
|
|
|
- ModBusController.start(mContext!!)
|
|
|
- ModBusController.unregisterListener(mContext!!)
|
|
|
-
|
|
|
-
|
|
|
- ModBusController.initDevicesStatus()
|
|
|
-
|
|
|
+ fun registerStatusListener() {
|
|
|
ModBusController.registerStatusListener(this) { res ->
|
|
|
LogUtil.i("设备状态:${(res as List<ByteArray>).map { it.toHexStrings() }}")
|
|
|
res.forEach { bytes ->
|
|
|
@@ -35,23 +27,14 @@ class PresentationPresenter : BasePresenter<IPresentationView>() {
|
|
|
if (deviceBean.isExist) {
|
|
|
when (deviceBean.type) {
|
|
|
DEVICE_TYPE_KEY -> {
|
|
|
-
|
|
|
+ // TODO 读工作票
|
|
|
}
|
|
|
DEVICE_TYPE_LOCK -> {
|
|
|
ModBusController.readLockRfid(dockBean.addr.toInt() - 1, deviceBean.idx) { res ->
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
ModBusController.updateLockRfid(dockBean.addr.toInt(), deviceBean.idx, rfid)
|
|
|
}
|
|
|
- }
|
|
|
- DEVICE_TYPE_CARD -> {
|
|
|
- ModBusController.readPortalCaseCardRfid(dockBean.addr.toInt() - 1) { res ->
|
|
|
- val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
- println("卡片RFID : $rfid")
|
|
|
- ToastUtils.tip("卡片RFID : $rfid")
|
|
|
- }
|
|
|
- }
|
|
|
- DEVICE_TYPE_FINGERPRINT -> {
|
|
|
-
|
|
|
+ ModBusController.controlLockBuckle(false, deviceBean.idx, dockBean.addr.toInt() - 1)
|
|
|
}
|
|
|
}
|
|
|
}
|