Ver Fonte

添加还设备自动关卡扣

Frankensteinly há 1 ano atrás
pai
commit
b49d29de81

+ 9 - 1
app/src/main/java/com/grkj/iscs/BusinessManager.kt

@@ -66,6 +66,7 @@ object BusinessManager {
                                     ModBusController.updateLockRfid(dockBean.addr.toInt(), lockBean.idx, rfid)
                                 }
                             }
+                            // TODO 关卡扣
                         }
                     }
                     DOCK_TYPE_PORTABLE -> {
@@ -74,13 +75,20 @@ object BusinessManager {
                             if (deviceBean.isExist) {
                                 when (deviceBean.type) {
                                     DEVICE_TYPE_KEY -> {
-
+                                        ModBusController.readKeyRfid(dockBean.addr.toInt() - 1, deviceBean.idx) { isLeft, res ->
+                                            val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
+                                            ModBusController.updateKeyRfid(dockBean.addr.toInt(), true, rfid)
+                                            // TODO 从HTTP读取Mac
+                                            // TODO 蓝牙通信
+                                        }
+                                        ModBusController.controlKeyBuckle(false, isLeft = true, dockBean.addr.toInt() - 1)
                                     }
                                     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)
                                         }
+                                        ModBusController.controlLockBuckle(false, dockBean.addr.toInt() - 1, deviceBean.idx)
                                     }
                                     DEVICE_TYPE_CARD -> {
                                         ModBusController.readPortalCaseCardRfid(dockBean.addr.toInt() - 1) { res ->

+ 3 - 20
app/src/main/java/com/grkj/iscs/presentation/PresentationPresenter.kt

@@ -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)
                                     }
                                 }
                             }