Browse Source

优化门灯控制

weizhengliang 2 years ago
parent
commit
3afbe77380

+ 8 - 9
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -121,7 +121,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
     private var clickSosTime : Long = 0
     private var clickVersionTime : Long = 0
     private var clickCount = 1
-    private var callNums = 0
 
     private var serverSuccess = false
     private var cancelRestart = false
@@ -601,7 +600,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 showMessage(R.string.net_error)
             }
 
-            callNums == 0
+            Constant.callNums == 0
             DoorLightHelper.resetDoorLight()
 
             SpeechUtil.getInstance().stopSpeak()
@@ -1313,24 +1312,24 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
     private fun callControl(tcpModel: TcpModel) {
         if (tcpModel.action == TcpAction.SideAction.CALL) {
-            callNums++
+            Constant.callNums++
             SerialPortHelper.setDoorLight(1, "200")
         } else if (tcpModel.action == TcpAction.SideAction.SOS_CALL) {
             SerialPortHelper.setDoorLight(1, "200")
             Constant.sosOn = true
         } else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
-            callNums--
-            if (callNums < 0) {
-                callNums = 0
+            Constant.callNums--
+            if (Constant.callNums < 0) {
+                Constant.callNums = 0
             }
 
             //如果当前还有其他床位呼叫或者是紧急呼叫则不重置门灯
-            if (callNums == 0 && !Constant.sosOn) {
+            if (Constant.callNums == 0 && !Constant.sosOn) {
                 DoorLightHelper.resetDoorLight()
             }
         } else if (tcpModel.action == TcpAction.SideAction.SOS_CANCEL) {
             Constant.sosOn = false
-            if (callNums == 0) {
+            if (Constant.callNums == 0) {
                 DoorLightHelper.resetDoorLight()
             }
         }
@@ -1444,7 +1443,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     showCalls()
                 }
             } else {
-                callNums == 0
+                Constant.callNums == 0
                 DoorLightHelper.resetDoorLight()
             }
         } catch (ex: Exception) {

+ 5 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/MainFragment.kt

@@ -94,7 +94,11 @@ class MainFragment: BaseFragment<MainFragmentPresenter, MainViewLayoutBinding>()
             }
 
             Constant.bedCustomIn = count > 0
-            DoorLightHelper.resetDoorLight()
+
+            //当前没有呼叫则
+            if (Constant.callNums == 0 && !Constant.sosOn) {
+                DoorLightHelper.resetDoorLight()
+            }
 
             if (simulateBed) {
                 EventBus.getDefault().post(MessageEvent("remove_call_bed", Constant.EVENT_REMOVE_CALL_BED))

+ 2 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/SOSHelper.java

@@ -29,8 +29,8 @@ public class SOSHelper {
 
             Constant.sosOn = true;
 
-            //60s之后紧急按钮灯自动复位
-            handler.sendEmptyMessageDelayed(110, 60000);
+            //5min之后紧急按钮灯自动复位
+            handler.sendEmptyMessageDelayed(110, 300000);
         }
     }
 

+ 1 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constant.java

@@ -135,6 +135,7 @@ public class Constant {
     public static boolean sosOn = false;
     //床位是否有人入住
     public static boolean bedCustomIn = false;
+    public static int callNums = 0;
 
     //来电设备id
     public static Integer fromId = -1;