Prechádzať zdrojové kódy

增加模拟紧急按钮取消按键功能

weizhengliang 1 mesiac pred
rodič
commit
6cdfc28438

+ 26 - 0
conversion_box/src/main/java/com/wdkl/app/ncs/conversion_box/activity/MainActivity.kt

@@ -1116,6 +1116,24 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
                             Log.e(TAG, "error func: ?拔针按键")
                         }
                     }
+
+                    "P" -> {
+                        //紧急按钮取消
+                        Log.e(TAG,"sos call list size: " + Constant.sosInteractions.size)
+                        if (Constant.sosInteractions.size > 0) {
+                            val iterator = Constant.sosInteractions.iterator()
+                            while (iterator.hasNext()) {
+                                val it = iterator.next()
+                                Log.e(TAG, "mac: " + it.fromEthIp + ", click mac: " + addr)
+                                if (addr.equals(it.fromEthIp, true)) {
+                                    val tcpModel = OtherUtil.SOSButtonCancel(it.fromDeviceId, it.id)
+                                    TcpClient.getInstance().sendMsg(tcpModel.toJson())
+
+                                    iterator.remove()
+                                }
+                            }
+                        }
+                    }
                 }
             } else {
                 //这里实际上是执行了“E”指令
@@ -2113,6 +2131,14 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
                             val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                             nursingMap.set(interactionVO.fromEthIp.toUpperCase(Locale.ROOT), interactionVO.id)
                         } else {
+                            if (tcpModel.action == TcpAction.SideAction.SOS_CALL) {
+                                //记录交互id用于取消紧急呼叫
+                                if (tcpModel.data != null) {
+                                    val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+                                    Constant.sosInteractions.add(interactionVO)
+                                }
+                            }
+
                             //门灯控制
                             controlDoorLight(tcpModel)
                         }

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

@@ -1,6 +1,7 @@
 package com.wdkl.ncs.android.middleware.common;
 
 import com.wdkl.ncs.android.middleware.model.vo.FrameAudioRoomVO;
+import com.wdkl.ncs.android.middleware.model.vo.InteractionVO;
 
 import java.util.ArrayList;
 
@@ -112,6 +113,9 @@ public class Constant {
     //Interaction ID
     public static Integer interactionId = -1;
 
+    //紧急呼叫interactionId
+    public static ArrayList<InteractionVO> sosInteractions = new ArrayList<>();
+
     //是否打开签到功能
     public static boolean nursingSign = false;
 

+ 9 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/channel/OtherUtil.java

@@ -51,6 +51,15 @@ public class OtherUtil {
         return tcpModel;
     }
 
+    public static TcpModel SOSButtonCancel(Integer fromId, Integer interactionId){
+        TcpModel tcpModel = new TcpModel(null);
+        tcpModel.setType(TcpType.SOS);
+        tcpModel.setAction(TcpAction.SOSAction.CANCEL);
+        tcpModel.setFromId(fromId);
+        tcpModel.setData(interactionId);
+        return tcpModel;
+    }
+
     public static TcpModel reInforce(Integer fromId){
         TcpModel tcpModel = new TcpModel(null);
         tcpModel.setType(TcpType.REINFORCE);