|
|
@@ -212,10 +212,10 @@ object ModBusController {
|
|
|
logger.info("initKey : $dockList")
|
|
|
dockList.filter { it.type == DeviceConst.DOCK_TYPE_KEY || it.type == DeviceConst.DOCK_TYPE_PORTABLE }
|
|
|
.forEach { dockBean ->
|
|
|
- if (dockBean.getKeyList().isEmpty()){
|
|
|
+ if (dockBean.getKeyList().isEmpty()) {
|
|
|
ISCSConfig.canInitDevice = true
|
|
|
ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
dockBean.getKeyList().forEach { key ->
|
|
|
if (key.isExist) {
|
|
|
logger.info("initKey : ${dockBean.addr} : ${key.idx == 0}")
|
|
|
@@ -251,32 +251,52 @@ object ModBusController {
|
|
|
}
|
|
|
controlKeyBuckle(true, key.idx, dockBean.addr)
|
|
|
}
|
|
|
-
|
|
|
+ val isKeyReady =
|
|
|
+ dockList.filter { it.type == DeviceConst.DOCK_TYPE_KEY || it.type == DeviceConst.DOCK_TYPE_PORTABLE }
|
|
|
+ .all {
|
|
|
+ it.deviceList.filter { it.type == DeviceConst.DEVICE_TYPE_KEY }
|
|
|
+ .filterIsInstance<DockBean.KeyBean>()
|
|
|
+ .filter { it.isExist }
|
|
|
+ .all {
|
|
|
+ logger.info("钥匙信息:${it.rfid}")
|
|
|
+ it.rfid != null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("钥匙是否准备完毕:${isKeyReady},${ISCSConfig.isInit}")
|
|
|
+ if (isKeyReady && ISCSConfig.isInit) {
|
|
|
+ ISCSConfig.canInitDevice = true
|
|
|
+ logger.info("发送初始化完成事件")
|
|
|
+ ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
+ } else if (isKeyReady) {
|
|
|
+ ISCSConfig.canInitDevice = true
|
|
|
+ ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
controlKeyBuckle(true, key.idx, dockBean.addr)
|
|
|
+ val isKeyReady =
|
|
|
+ dockList.filter { it.type == DeviceConst.DOCK_TYPE_KEY || it.type == DeviceConst.DOCK_TYPE_PORTABLE }
|
|
|
+ .all {
|
|
|
+ it.deviceList.filter { it.type == DeviceConst.DEVICE_TYPE_KEY }
|
|
|
+ .filterIsInstance<DockBean.KeyBean>()
|
|
|
+ .filter { it.isExist }
|
|
|
+ .all {
|
|
|
+ logger.info("钥匙信息:${it.rfid}")
|
|
|
+ it.rfid != null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("钥匙是否准备完毕:${isKeyReady},${ISCSConfig.isInit}")
|
|
|
+ if (isKeyReady && ISCSConfig.isInit) {
|
|
|
+ ISCSConfig.canInitDevice = true
|
|
|
+ logger.info("发送初始化完成事件")
|
|
|
+ ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
+ } else if (isKeyReady) {
|
|
|
+ ISCSConfig.canInitDevice = true
|
|
|
+ ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
+ }
|
|
|
}
|
|
|
- val isKeyReady =
|
|
|
- dockList.filter { it.type == DeviceConst.DOCK_TYPE_KEY || it.type == DeviceConst.DOCK_TYPE_PORTABLE }
|
|
|
- .all {
|
|
|
- it.deviceList.filter { it.type == DeviceConst.DEVICE_TYPE_KEY }
|
|
|
- .filterIsInstance<DockBean.KeyBean>()
|
|
|
- .filter { it.isExist }
|
|
|
- .all {
|
|
|
- logger.info("钥匙信息:${it.rfid}")
|
|
|
- it.rfid != null
|
|
|
- }
|
|
|
- }
|
|
|
- logger.info("钥匙是否准备完毕:${isKeyReady},${ISCSConfig.isInit}")
|
|
|
- if (isKeyReady && ISCSConfig.isInit) {
|
|
|
- ISCSConfig.canInitDevice = true
|
|
|
- logger.info("发送初始化完成事件")
|
|
|
- ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
- } else if (isKeyReady) {
|
|
|
- ISCSConfig.canInitDevice = true
|
|
|
- ModbusInitCompleteEvent.sendModbusInitCompleteEvent()
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -788,6 +808,22 @@ object ModBusController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 关闭所有钥匙锁仓并关闭充电
|
|
|
+ */
|
|
|
+ fun controlAllKeyBuckleClose(complete: () -> Unit = {}) {
|
|
|
+ dockList.filter { it.type == DeviceConst.DOCK_TYPE_KEY || it.type == DeviceConst.DOCK_TYPE_PORTABLE }
|
|
|
+ .forEach { dock ->
|
|
|
+ dock.type?.let { dockType ->
|
|
|
+ ModBusCMDHelper.generateAllKeyBuckleCloseCmd(dockType).let { cmd ->
|
|
|
+ modBusManager?.sendTo(dock.addr, cmd) { res ->
|
|
|
+ complete()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 关闭所有钥匙锁仓充电
|
|
|
*/
|