From 145de2dcd3124f236e7d06bcdee17c7be08048b1 Mon Sep 17 00:00:00 2001
From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com>
Date: 星期一, 11 十一月 2024 18:34:13 +0800
Subject: [PATCH] 修改搜索按照index索引

---
 HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java
index 6f5f7a6..6d8dfcc 100644
--- a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -166,7 +166,7 @@
      * @param commandType 鍛戒护绫诲瀷
      */
     public static void handle(UdpDataBean getDatas, int commandType) {
-//        Log.e("panlili", "commandType=" + Integer.toHexString(commandType) + " sourceSubnetID=" + getDatas.sourceSubnetID + " sourceDeviceID=" + getDatas.sourceDeviceID);
+        Log.e("panlili", "commandType=" + Integer.toHexString(commandType) + " sourceSubnetID=" + getDatas.sourceSubnetID + " sourceDeviceID=" + getDatas.sourceDeviceID);
         switch (commandType) {
             case Configuration.SEARCH_GATEWAY_BACK_COMMAND:
                 break;
@@ -382,7 +382,7 @@
      *
      * @param getDatas
      */
-    private static void handleSearchData(UdpDataBean getDatas) {
+    private static synchronized void handleSearchData(UdpDataBean getDatas) {
 
         DevicesData devicesData = new DevicesData();
         devicesData.setSourceSubnetID(getDatas.sourceSubnetID);
@@ -439,11 +439,13 @@
             EventBus.getDefault().post(new DiscoverNewDevicesEvent(devicesData));
 
             //杩囨护鎺夎儗鏅煶涔愶紝鑳屾櫙闊充箰娌℃湁澶囨敞杩斿洖
-            if (devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) {
-                for (int i = 0, len = devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().size(); i < len; i++) {
+            if (devicesData.getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) {
+                for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) {
                     ListRemarks listRemarksTemp = new ListRemarks();
                     listRemarksTemp.setCallBack(false);
-                    listRemarksTemp.setAppliancesInfo(devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(i));
+                    AppliancesInfo appliancesInfo = devicesData.getAppliancesInfoList().get(i);
+                    Log.d("panlili", "HDLDeviceManager.java:handleSearchData----->getChannelNum= " + appliancesInfo.getChannelNum() + " getDeviceKey=" + appliancesInfo.getDeviceKey());
+                    listRemarksTemp.setAppliancesInfo(appliancesInfo);
                     listRemarks.add(listRemarksTemp);
                 }
             }
@@ -1204,7 +1206,7 @@
                 for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) {
                     if ((infos.get(appPos).getDeviceSubnetID()) == (getDatas.addBytes[0] & 0xFF)
                             && (infos.get(appPos).getDeviceDeviceID()) == (getDatas.addBytes[1] & 0xFF)
-                            && ((infos.get(appPos).getChannelNum()) == (getDatas.addBytes[2] & 0xFF))
+                            && ((infos.get(appPos).getDeviceIndex()) == (getDatas.addBytes[2] & 0xFF))//搴忓彿
                             && (infos.get(appPos).getBigType()) == (getDatas.addBytes[3] & 0xFF)
                             && ((infos.get(appPos).getLittleType()) == (getDatas.addBytes[4] & 0xFF))) {
 
@@ -1222,6 +1224,7 @@
                         HDLLog.I("remarkStr鑾峰彇鐨勫娉ㄥ悕涓猴細" + remarkStr);
                         devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setChannelNum(getDatas.addBytes[5] & 0xFF);
                         devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setRemarks(remarkStr);
+//                        HDLLog.I("getRemarks()锛�" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getRemarks());
 
                         String key = "K" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getBigType()
                                 + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getLittleType()
@@ -1233,9 +1236,10 @@
                         listRemarksOutter:
                         for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) {
                             //鎵惧埌F44B瀵瑰簲鐨勮澶囧洖璺紝鍒ゆ柇鏄惁宸茬粡鎷垮埌浜嗘暟鎹��
+
                             if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == (getDatas.addBytes[0] & 0xFF)
                                     && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == (getDatas.addBytes[1] & 0xFF)
-                                    && listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() == (getDatas.addBytes[2] & 0xFF)
+                                    && listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() == (getDatas.addBytes[2] & 0xFF)
                                     && listRemarks.get(lRPos).getAppliancesInfo().getBigType() == (getDatas.addBytes[3] & 0xFF)
                                     && listRemarks.get(lRPos).getAppliancesInfo().getLittleType() == (getDatas.addBytes[4] & 0xFF)) {
 
@@ -1251,7 +1255,7 @@
                                         } else {
                                             HDLLog.I("涓嶅瓨鍦ㄧ殑璁惧澶囨敞锛屽啀娆℃悳绱㈠娉ㄣ�傝澶囷細瀛愮綉鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID()
                                                     + "璁惧鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID()
-                                                    + "鍥炶矾鍙�" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum()
+                                                    + "搴忓垪鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex()
                                                     + "澶囨敞锛�" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks());
                                             HandleSearch.getDevRemarks();
                                             break listRemarksOutter;
@@ -1260,7 +1264,7 @@
                                 } else {
                                     HDLLog.I("杩斿洖澶囨敞璁惧锛氬瓙缃戝彿锛�" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID()
                                             + ",璁惧鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID()
-                                            + ",鍥炶矾鍙�" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum()
+                                            + ",搴忓垪鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex()
                                             + ",澶囨敞锛�" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks());
                                     listRemarks.get(lRPos).setCallBack(true);
                                     HandleSearch.getDevRemarks();
@@ -2693,8 +2697,8 @@
      * @param mRemarks    澶囨敞
      * @return Boolean
      */
-    public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
-        return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+    public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) {
+        return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks);
     }
 
     /**
@@ -2706,8 +2710,8 @@
      * @param mRemarks    澶囨敞
      * @return Boolean
      */
-    public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
-        return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+    public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) {
+        return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks);
     }
 
     /**
@@ -2722,9 +2726,9 @@
      * @param mRemarks
      * @return
      */
-    public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+    public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) {
         try {
-            DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+            DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks);
             if (mDevicesData != null) {
                 devicesDataList.add(mDevicesData);
                 HandleSearch.OnDeviceListGetSuccessCallBack();
@@ -2752,7 +2756,7 @@
      * @param mRemarks
      * @return
      */
-    public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+    public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) {
         try {
 
             if (!DeviceParser.isWantData(mBigType, mLittleType)) {//鍒ゆ柇鏄惁鏀寔鐨勫ぇ绫诲皬绫�
@@ -2770,7 +2774,7 @@
                     DevicesData mDevicesData = devicesDataList.get(i);
                     bCanAdd = getIfCanAddDevice(mDevicesData.getAppliancesInfoList(), mBigType, mLittleType, mChannelNum);
                     if (bCanAdd) {//娣诲姞瀛愮綉鍙� 璁惧鍙� 宸插瓨鍦紝骞朵笖娌℃湁鐩稿悓鐨勫瓙缃戝彿璁惧鍙�
-                        AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mRemarks, mRemarks);
+                        AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mIndex, mRemarks, mRemarks);
                         devicesDataList.get(i).getAppliancesInfoList().add(mAppliancesInfo);
                         HandleSearch.OnDeviceListGetSuccessCallBack();
                         HDLLog.I("鏀寔鐨勮澶囷紝鍏佽娣诲姞");
@@ -2780,7 +2784,7 @@
             }
 
             if (!bExistSubnetID) {
-                return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+                return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks);
             }
 
             return bCanAdd;

--
Gitblit v1.8.0