|
|
@@ -186,17 +186,13 @@ object ModBusController {
|
|
|
return null
|
|
|
}
|
|
|
val dockB = dockList.find { it.addr == byteArray[0] }
|
|
|
- return dockB?.parseStatus(byteArray) ?: let {
|
|
|
- val temp = DockBean(byteArray[0], null, mutableListOf())
|
|
|
- dockList.add(temp)
|
|
|
- temp.parseStatus(byteArray)
|
|
|
- }
|
|
|
+ return dockB?.parseStatus(byteArray)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 读取设备类型
|
|
|
*/
|
|
|
- fun readDeviceType(done: ((res: List<ByteArray>) -> Unit)? = null) {
|
|
|
+ private fun readDeviceType(done: ((res: List<ByteArray>) -> Unit)? = null) {
|
|
|
modBusManager?.sendToAll(MBFrame.READ_DEVICE_TYPE) { res ->
|
|
|
done?.invoke(res)
|
|
|
}
|
|
|
@@ -205,8 +201,13 @@ object ModBusController {
|
|
|
/**
|
|
|
* 更新设备类型
|
|
|
*/
|
|
|
- fun updateDeviceType(idx: Byte?, type: Byte?) {
|
|
|
- dockList.find { it.addr == idx }?.type = type
|
|
|
+ private fun updateDeviceType(idx: Byte, type: Byte?) {
|
|
|
+ val dock = dockList.find { it.addr == idx }
|
|
|
+ dock?.let {
|
|
|
+ it.type = type
|
|
|
+ } ?: let {
|
|
|
+ dockList.add(DockBean(idx, type, mutableListOf()))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|