|
|
@@ -309,7 +309,24 @@ class DockBean(
|
|
|
if ((byteArray[4].toInt() shr i) and 0x1 == 1) {
|
|
|
val switchBoardAddr = (0x20 + i).toByte()
|
|
|
ModBusController.readSwitchStatus(addr, switchBoardAddr) { res ->
|
|
|
- //todo 开关量新增
|
|
|
+ val switchStatus: MutableList<Boolean> = mutableListOf()
|
|
|
+ for (switchIdx in 0..7) {
|
|
|
+ switchStatus.add((res[4].toInt() shr switchIdx) and 0x1 == 1)
|
|
|
+ }
|
|
|
+ for (switchIdx in 0..7) {
|
|
|
+ switchStatus.add((res[3].toInt() shr switchIdx) and 0x1 == 1)
|
|
|
+ }
|
|
|
+ for (idx in 0 until switchStatus.size) {
|
|
|
+ if (getSwitchList().isEmpty()) {
|
|
|
+ deviceList.add(
|
|
|
+ SwitchBean(
|
|
|
+ idx,
|
|
|
+ switchBoardAddr,
|
|
|
+ switchStatus[idx]
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -483,6 +500,7 @@ class DockBean(
|
|
|
*/
|
|
|
class SwitchBean(
|
|
|
idx: Int,
|
|
|
- isExist: Boolean,
|
|
|
- ) : DeviceBean(DEVICE_TYPE_SWITCH, idx, isExist)
|
|
|
+ val switchBoardAddr: Byte,
|
|
|
+ var enabled: Boolean
|
|
|
+ ) : DeviceBean(DEVICE_TYPE_SWITCH, idx, true)
|
|
|
}
|