소스 검색

增加多路电源开关控制

weizhengliang 1 년 전
부모
커밋
d5f1e67d05
1개의 변경된 파일14개의 추가작업 그리고 4개의 파일을 삭제
  1. 14 4
      conversion_box/src/main/java/com/wdkl/app/ncs/conversion_box/activity/MainActivity.kt

+ 14 - 4
conversion_box/src/main/java/com/wdkl/app/ncs/conversion_box/activity/MainActivity.kt

@@ -1786,15 +1786,25 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
                         }else if(tcpModel.action==TcpAction.DeviceAction.OPEN_DEBUG) { //打开设备网络调试
                             AppUpdateHelper.openNetWorkDebug()
                         }else if (tcpModel.action==TcpAction.DeviceAction.S485_POWER_RESET) { //控制485线路板通断 0_1 重启第一路 0_1_0 关闭第一路 0_1_1 打开第一路 0_0_0关闭板上所有电路
+                            if (tcpModel.data == null) {
+                                return
+                            }
+
                             val pwcontrol = tcpModel.data.toString().split('_')
                             DeviceUtil.s485PowerResetSuccess(Constant.DEVICE_ID,tcpModel.data.toString(),tcpModel.tid)
                             if(pwcontrol.size==2){
-                                PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(),pwcontrol[1].toInt(),true)
-                                AppTool.Time.delay(3000){
-                                    PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(),pwcontrol[1].toInt(),false)
+                                val lines = pwcontrol[1].split(",")
+                                for (line in lines) {
+                                    PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(), line.toInt(), true)
+                                    AppTool.Time.delay(3000){
+                                        PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(), line.toInt(),false)
+                                    }
                                 }
                             }else if(pwcontrol.size==3){
-                                PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(),pwcontrol[1].toInt(),pwcontrol[2].toInt()==0)
+                                val lines = pwcontrol[1].split(",")
+                                for (line in lines) {
+                                    PowerControlUtil.controlPowerControl(pwcontrol[0].toInt(), line.toInt(), pwcontrol[2].toInt() == 0)
+                                }
                             }
                         }
                     } /*else if (tcpModel.type == TcpType.BROADCAST) {