From 4f841eac608f6f22a573b4f7ed713679e89c2e5b Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 30 九月 2019 13:47:49 +0800
Subject: [PATCH] 2019-9-30 1.修改方案,解决不支持控制5台以上空调问题。

---
 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java |  524 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 280 insertions(+), 244 deletions(-)

diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
index 8fb85bf..3203374 100644
--- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
+++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -47,6 +47,7 @@
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
 
 import static com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil.byte2String;
 
@@ -67,27 +68,23 @@
     public static List<RcuLight> rcuLightList = new ArrayList<>();
     public static List<RcuCurtain> rcuCurtainList = new ArrayList<>();
     public static boolean isLogicCtrl = false;
+    public static ConcurrentHashMap<String, Boolean> ctrlSuccessStateHashMap = new ConcurrentHashMap<>();//2019-8-2
 
-    public static byte[] air1Info = null;
-    public static byte[] air2Info = null;
-    public static byte[] air3Info = null;
-    public static byte[] air4Info = null;
+//    public static byte[] air1Info = null;
+//    public static byte[] air2Info = null;
+//    public static byte[] air3Info = null;
+//    public static byte[] air4Info = null;
+    //        air4Info[寮�鍏崇姸鎬侊紝妯″紡锛岃缃俯搴︼紝椋庨�燂紝褰撳墠娓╁害锛屾槸鍚︽憜椋� ];
 
     public static boolean isGetRcuIpSuccess = false;
-
-    public static boolean isLightCtrlSuccess = false; //鍒ゆ柇鐏厜鏄惁鎺у埗鎴愬姛
-
-    public static boolean isCurtainCtrlSuccess = false; //鍒ゆ柇绐楀笜鏄惁鎺у埗鎴愬姛
-
-    public static boolean isACCtrlSuccess = false; //鍒ゆ柇绌鸿皟鏄惁鎺у埗鎴愬姛
-
-    public static boolean isSceneCtrlSuccess = false; //鍒ゆ柇鍦烘櫙鏄惁鎺у埗鎴愬姛
-
     public static boolean isGetDeviceStateSuccess = false; //鍒ゆ柇鑾峰彇璁惧鐘舵�佹槸鍚︽帶鍒舵垚鍔�
 
-    public static boolean isFreshAirCtrlSuccess = false; //鍒ゆ柇鏂伴绯荤粺鏄惁鎺у埗鎴愬姛
-
-    public static boolean isGeothermalCtrlSuccess = false; //鍒ゆ柇鍦扮儹妯″潡鏄惁鎺у埗鎴愬姛
+//    public static boolean isLightCtrlSuccess = false; //鍒ゆ柇鐏厜鏄惁鎺у埗鎴愬姛
+//    public static boolean isCurtainCtrlSuccess = false; //鍒ゆ柇绐楀笜鏄惁鎺у埗鎴愬姛
+//    public static boolean isACCtrlSuccess = false; //鍒ゆ柇绌鸿皟鏄惁鎺у埗鎴愬姛
+//    public static boolean isSceneCtrlSuccess = false; //鍒ゆ柇鍦烘櫙鏄惁鎺у埗鎴愬姛
+//    public static boolean isFreshAirCtrlSuccess = false; //鍒ゆ柇鏂伴绯荤粺鏄惁鎺у埗鎴愬姛
+//    public static boolean isGeothermalCtrlSuccess = false; //鍒ゆ柇鍦扮儹妯″潡鏄惁鎺у埗鎴愬姛
 
 
     /**
@@ -506,7 +503,8 @@
                                     info.setBrightness(getDatas.addBytes[2] & 0xFF);
 //                                  info.setChannelCount(getDatas.AddBytes[3] & 0xFF);
 //                                  info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF);
-                                    isLightCtrlSuccess = true;
+//                                    isLightCtrlSuccess = true;
+                                    setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                     EventBus.getDefault().post(new LightFeedBackEvent(info, true));
                                     break outter;
                                 }
@@ -547,7 +545,8 @@
                                         info1.setBrightness(getDatas.addBytes[2] & 0xFF);
                                         info1.setChannelCount(getDatas.addBytes[3] & 0xFF);
                                         info1.setDeviceChannelCount(getDatas.addBytes[4] & 0xFF);
-                                        isLightCtrlSuccess = true;
+//                                        isLightCtrlSuccess = true;
+                                        setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                         EventBus.getDefault().post(new LightFeedBackEvent(info1, true));
                                         break outter;
                                     }
@@ -642,7 +641,8 @@
                             curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks());
                             curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks());
                             curtainCtrlBackInfo.setAppliancesInfo(curtainInfo);
-                            isCurtainCtrlSuccess = true;
+//                            isCurtainCtrlSuccess = true;
+                            setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
 
                             if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO
                                     || curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER) {
@@ -694,7 +694,8 @@
                                 //                濡傛灉鏈夊涓┖璋冮潰鏉匡紝杩欏皢浼氬嚭閿�
                                 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
                                 airCtrlBackInfo.setAppliancesInfo(infos.get(j));
-                                isACCtrlSuccess = true;
+//                                isACCtrlSuccess = true;
+                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                 if ((getDatas.addBytes[0] & 0xFF) == AirCtrlParser.airMode) {
                                     airCtrlBackInfo.setCurState(new byte[]{getDatas.addBytes[0], getDatas.addBytes[1]});
                                     byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState();
@@ -810,33 +811,35 @@
                                 int indexI = devIndex;
                                 int indexJ = appIndex;
 
-                                final byte[] oldAirInfo;
-                                switch (getDatas.addBytes[0] & 0xFF) {
-                                    case 1:
-                                        oldAirInfo = air1Info;
-                                        break;
-                                    case 2:
-                                        oldAirInfo = air2Info;
-                                        break;
-                                    case 3:
-                                        oldAirInfo = air3Info;
-                                        break;
-                                    case 4:
-                                        oldAirInfo = air4Info;
-                                        break;
-                                    default:
-                                        oldAirInfo = new byte[1];
-                                        break;
-                                }
+                                byte[] oldAirInfo = airInfo.getArrCurState();
+//                                switch (getDatas.addBytes[0] & 0xFF) {
+//                                    case 1:
+//                                        oldAirInfo = air1Info;
+//                                        break;
+//                                    case 2:
+//                                        oldAirInfo = air2Info;
+//                                        break;
+//                                    case 3:
+//                                        oldAirInfo = air3Info;
+//                                        break;
+//                                    case 4:
+//                                        oldAirInfo = air4Info;
+//                                        break;
+//                                    default:
+//                                        oldAirInfo = new byte[1];
+//                                        break;
+//                                }
                                 byte[] newAirInfo = getDatas.addBytes;
                                 byte[] curAirInfo = new byte[]{0};
                                 boolean isModeChange = false;
                                 if (oldAirInfo == null || oldAirInfo.length == 0) {
-                                    return;
+                                    oldAirInfo = AirCtrlParser.getNewAcByte();
+
                                 }
+                                setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                 for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) {
                                     if (oldAirInedx == 0) {
-                                        if (oldAirInfo[0] != newAirInfo[8]) {
+//                                        if (oldAirInfo[0] != newAirInfo[8]) {//2019 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙e喅寮�鐘舵�佷笅,璋冪敤寮�鍛戒护鐘舵�佷笅,涓嶅仠閲嶅彂闂
                                             oldAirInfo[0] = newAirInfo[8];
                                             curAirInfo = new byte[]{AirCtrlParser.airSwich, newAirInfo[8]};
                                             if (curAirInfo.length > 1) {
@@ -845,11 +848,12 @@
                                                 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
                                                 airCtrlBackInfo.setAppliancesInfo(airInfo);
                                                 airCtrlBackInfo.setCurState(curAirInfo);
-                                                isACCtrlSuccess = true;
+//                                                isACCtrlSuccess = true;
+//                                                setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                                 EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
 
                                             }
-                                        }
+//                                        }
                                     } else if (oldAirInedx == 1) {
 //                        int mode = ((newAirInfo[4] & 0xf0) >> 4);
                                         int mode = newAirInfo[9] & 0xff;
@@ -863,7 +867,8 @@
                                                 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
                                                 airCtrlBackInfo.setAppliancesInfo(airInfo);
                                                 airCtrlBackInfo.setCurState(curAirInfo);
-                                                isACCtrlSuccess = true;
+//                                                isACCtrlSuccess = true;
+//                                                setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                                 EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
 
                                             }
@@ -895,7 +900,8 @@
                                                 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
                                                 airCtrlBackInfo.setAppliancesInfo(airInfo);
                                                 airCtrlBackInfo.setCurState(curAirInfo);
-                                                isACCtrlSuccess = true;
+//                                                isACCtrlSuccess = true;
+//                                                setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                                 EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
 
                                             }
@@ -912,7 +918,8 @@
                                                 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
                                                 airCtrlBackInfo.setAppliancesInfo(airInfo);
                                                 airCtrlBackInfo.setCurState(curAirInfo);
-                                                isACCtrlSuccess = true;
+//                                                isACCtrlSuccess = true;
+//                                                setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                                 EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
 
                                             }
@@ -920,44 +927,18 @@
                                     }
                                 }
 
-                                switch (getDatas.addBytes[0] & 0xFF) {
-                                    case 1:
-                                        air1Info = oldAirInfo;
-                                        break;
-                                    case 2:
-                                        air2Info = oldAirInfo;
-                                        break;
-                                    case 3:
-                                        air3Info = oldAirInfo;
-                                        break;
-                                    case 4:
-                                        air4Info = oldAirInfo;
-                                        break;
-                                }
 
-
-                                if (curAirInfo.length > 1) {
-//                    if (isModeChange) {
-//                        isACCtrlSuccess = true;
-//                        getAirInfo(hvacInfo);
-//                    } else {
-//                        airInfo.setArrCurState(oldAirInfo);
-//                        AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
-//                        airCtrlBackInfo.setAppliancesInfo(airInfo);
-//                        airCtrlBackInfo.setCurState(curAirInfo);
-//                        isACCtrlSuccess = true;
-//                        EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
-//                    }
-
-                                    devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
-                                    airInfo.setArrCurState(oldAirInfo);
-                                    AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
-                                    airCtrlBackInfo.setAppliancesInfo(airInfo);
-                                    airCtrlBackInfo.setCurState(curAirInfo);
-                                    isACCtrlSuccess = true;
-                                    EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
-
-                                }
+//                                if (curAirInfo.length > 1) {
+//                                    devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+//                                    airInfo.setArrCurState(oldAirInfo);
+//                                    AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+//                                    airCtrlBackInfo.setAppliancesInfo(airInfo);
+//                                    airCtrlBackInfo.setCurState(curAirInfo);
+////                                    isACCtrlSuccess = true;
+//                                    setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+//                                    EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+//
+//                                }
 
 
                                 break outter;
@@ -991,7 +972,8 @@
                                 logicCtrlBackInfo.setAppliancesInfo(sceneInfo);
                                 logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF);
                                 logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF);
-                                isSceneCtrlSuccess = true;
+//                                isSceneCtrlSuccess = true;
+                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                 EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true));
                                 break outter;
                             }
@@ -1015,7 +997,8 @@
                                 devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes);
                                 AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
                                 FreshAirBackInfo info = new FreshAirBackInfo(mFreshAirInfo);
-                                isFreshAirCtrlSuccess = true;
+//                                isFreshAirCtrlSuccess = true;
+                                setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                 EventBus.getDefault().post(new FreshAirFeedBackEvent(info, true));
                                 break outter;
                             }
@@ -1060,7 +1043,8 @@
                                         AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
 
                                         GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true);
-                                        isGeothermalCtrlSuccess = true;
+//                                        isGeothermalCtrlSuccess = true;
+                                        setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
                                         EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS));
                                     } else {
 
@@ -1224,120 +1208,150 @@
                                 && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) {
                             AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ);
                             if (appliancesInfo.getPort() != 0) {
-//                                byte[] airbytes = getDatas.addBytes;
-//                                String airString = "209a 闄勫姞鏁版嵁:";
-//                                for (int i = 0; i < airbytes.length; i++) {
-//                                    airString += (airbytes[i] & 0xff) + ",";
-//                                }
-//                                HDLLog.info( airString);
-                                switch (getDatas.addBytes[airIndex * 11] & 0xff) {
-                                    case 1:
-                                        handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo);
-                                        air1Info[0] = getDatas.addBytes[1 + 0 * 11];
+                                byte[] oldAirInfo = appliancesInfo.getArrCurState();
+
+                                if (oldAirInfo == null || oldAirInfo.length == 0) {
+                                    oldAirInfo = AirCtrlParser.getNewAcByte();
+                                }
 
 
-                                        air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4);
+                                handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo);
+
+                                oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11];
+
+                                oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4);
 
 
-                                        switch (air1Info[0] & 0xff) {
-                                            case 0:
-                                                air1Info[2] = getDatas.addBytes[2 + 0 * 11];
-                                                break;
-                                            case 1:
-                                                air1Info[2] = getDatas.addBytes[6 + 0 * 11];
-                                                break;
-                                            case 3:
-                                                air1Info[2] = getDatas.addBytes[8 + 0 * 11];
-                                                break;
-                                            case 4:
-                                                air1Info[2] = getDatas.addBytes[9 + 0 * 11];
-                                                break;
-
-                                        }
-
-                                        air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f);
-                                        air1Info[4] = getDatas.addBytes[5 + 0 * 11];
-                                        air1Info[5] = getDatas.addBytes[10 + 0 * 11];
-//                                        HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]);
-//                                        String arrString = "209a 闄勫姞鏁版嵁锛�";
-//                                        for (int i = 0; i < getDatas.addBytes.length; i++) {
-//                                            arrString += (getDatas.addBytes[i] & 0xff) + ",";
-//                                        }
-//                                        HDLLog.info( arrString);
-                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info);
+                                switch (oldAirInfo[0] & 0xff) {
+                                    case 0:
+                                        oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11];
                                         break;
-                                    case 2:
-                                        handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo);
-                                        air2Info[0] = getDatas.addBytes[1 + 1 * 11];
-                                        air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4);
-                                        switch (air2Info[0] & 0xff) {
-                                            case 0:
-                                                air2Info[2] = getDatas.addBytes[2 + 1 * 11];
-                                                break;
-                                            case 1:
-                                                air2Info[2] = getDatas.addBytes[6 + 1 * 11];
-                                                break;
-                                            case 3:
-                                                air2Info[2] = getDatas.addBytes[8 + 1 * 11];
-                                                break;
-                                            case 4:
-                                                air2Info[2] = getDatas.addBytes[9 + 1 * 11];
-                                                break;
-
-                                        }
-                                        air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f);
-                                        air2Info[4] = getDatas.addBytes[5 + 1 * 11];
-                                        air2Info[5] = getDatas.addBytes[10 + 1 * 11];
-                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info);
+                                    case 1:
+                                        oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11];
                                         break;
                                     case 3:
-                                        handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo);
-                                        air3Info[0] = getDatas.addBytes[1 + 2 * 11];
-                                        air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4);
-                                        switch (air3Info[0] & 0xff) {
-                                            case 0:
-                                                air3Info[2] = getDatas.addBytes[2 + 2 * 11];
-                                                break;
-                                            case 1:
-                                                air3Info[2] = getDatas.addBytes[6 + 2 * 11];
-                                                break;
-                                            case 3:
-                                                air3Info[2] = getDatas.addBytes[8 + 2 * 11];
-                                                break;
-                                            case 4:
-                                                air3Info[2] = getDatas.addBytes[9 + 2 * 11];
-                                                break;
-                                        }
-                                        air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f);
-                                        air3Info[4] = getDatas.addBytes[5 + 2 * 11];
-                                        air3Info[5] = getDatas.addBytes[10 + 2 * 11];
-                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info);
+                                        oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11];
                                         break;
                                     case 4:
-                                        handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo);
-                                        air4Info[0] = getDatas.addBytes[1 + 3 * 11];
-                                        air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4);
-                                        switch (air4Info[0] & 0xff) {
-                                            case 0:
-                                                air4Info[2] = getDatas.addBytes[2 + 3 * 11];
-                                                break;
-                                            case 1:
-                                                air4Info[2] = getDatas.addBytes[6 + 3 * 11];
-                                                break;
-                                            case 3:
-                                                air4Info[2] = getDatas.addBytes[8 + 3 * 11];
-                                                break;
-                                            case 4:
-                                                air4Info[2] = getDatas.addBytes[9 + 3 * 11];
-                                                break;
-                                        }
-                                        air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f);
-                                        air4Info[4] = getDatas.addBytes[5 + 3 * 11];
-                                        air4Info[5] = getDatas.addBytes[10 + 3 * 11];
-                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info);
+                                        oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11];
                                         break;
 
                                 }
+
+                                oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f);
+                                oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11];
+                                oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11];
+                                devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+
+
+//                                switch (getDatas.addBytes[airIndex * 11] & 0xff) {
+//                                    case 1:
+//                                        handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo);
+//                                        air1Info[0] = getDatas.addBytes[1 + 0 * 11];
+//
+//
+//                                        air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4);
+//
+//
+//                                        switch (air1Info[0] & 0xff) {
+//                                            case 0:
+//                                                air1Info[2] = getDatas.addBytes[2 + 0 * 11];
+//                                                break;
+//                                            case 1:
+//                                                air1Info[2] = getDatas.addBytes[6 + 0 * 11];
+//                                                break;
+//                                            case 3:
+//                                                air1Info[2] = getDatas.addBytes[8 + 0 * 11];
+//                                                break;
+//                                            case 4:
+//                                                air1Info[2] = getDatas.addBytes[9 + 0 * 11];
+//                                                break;
+//
+//                                        }
+//
+//                                        air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f);
+//                                        air1Info[4] = getDatas.addBytes[5 + 0 * 11];
+//                                        air1Info[5] = getDatas.addBytes[10 + 0 * 11];
+////                                        HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]);
+////                                        String arrString = "209a 闄勫姞鏁版嵁锛�";
+////                                        for (int i = 0; i < getDatas.addBytes.length; i++) {
+////                                            arrString += (getDatas.addBytes[i] & 0xff) + ",";
+////                                        }
+////                                        HDLLog.info( arrString);
+//                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info);
+//                                        break;
+//                                    case 2:
+//                                        handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo);
+//                                        air2Info[0] = getDatas.addBytes[1 + 1 * 11];
+//                                        air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4);
+//                                        switch (air2Info[0] & 0xff) {
+//                                            case 0:
+//                                                air2Info[2] = getDatas.addBytes[2 + 1 * 11];
+//                                                break;
+//                                            case 1:
+//                                                air2Info[2] = getDatas.addBytes[6 + 1 * 11];
+//                                                break;
+//                                            case 3:
+//                                                air2Info[2] = getDatas.addBytes[8 + 1 * 11];
+//                                                break;
+//                                            case 4:
+//                                                air2Info[2] = getDatas.addBytes[9 + 1 * 11];
+//                                                break;
+//
+//                                        }
+//                                        air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f);
+//                                        air2Info[4] = getDatas.addBytes[5 + 1 * 11];
+//                                        air2Info[5] = getDatas.addBytes[10 + 1 * 11];
+//                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info);
+//                                        break;
+//                                    case 3:
+//                                        handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo);
+//                                        air3Info[0] = getDatas.addBytes[1 + 2 * 11];
+//                                        air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4);
+//                                        switch (air3Info[0] & 0xff) {
+//                                            case 0:
+//                                                air3Info[2] = getDatas.addBytes[2 + 2 * 11];
+//                                                break;
+//                                            case 1:
+//                                                air3Info[2] = getDatas.addBytes[6 + 2 * 11];
+//                                                break;
+//                                            case 3:
+//                                                air3Info[2] = getDatas.addBytes[8 + 2 * 11];
+//                                                break;
+//                                            case 4:
+//                                                air3Info[2] = getDatas.addBytes[9 + 2 * 11];
+//                                                break;
+//                                        }
+//                                        air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f);
+//                                        air3Info[4] = getDatas.addBytes[5 + 2 * 11];
+//                                        air3Info[5] = getDatas.addBytes[10 + 2 * 11];
+//                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info);
+//                                        break;
+//                                    case 4:
+//                                        handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo);
+//                                        air4Info[0] = getDatas.addBytes[1 + 3 * 11];
+//                                        air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4);
+//                                        switch (air4Info[0] & 0xff) {
+//                                            case 0:
+//                                                air4Info[2] = getDatas.addBytes[2 + 3 * 11];
+//                                                break;
+//                                            case 1:
+//                                                air4Info[2] = getDatas.addBytes[6 + 3 * 11];
+//                                                break;
+//                                            case 3:
+//                                                air4Info[2] = getDatas.addBytes[8 + 3 * 11];
+//                                                break;
+//                                            case 4:
+//                                                air4Info[2] = getDatas.addBytes[9 + 3 * 11];
+//                                                break;
+//                                        }
+//                                        air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f);
+//                                        air4Info[4] = getDatas.addBytes[5 + 3 * 11];
+//                                        air4Info[5] = getDatas.addBytes[10 + 3 * 11];
+//                                        devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info);
+//                                        break;
+//
+//                                }
                             }
                         }
                     }
@@ -1530,21 +1544,21 @@
                                 case 0:
                                     byte[] airInfo = new byte[6];
                                     System.arraycopy(getDatas.addBytes, 23, airInfo, 0, airInfo.length);
-                                    switch (getDatas.addBytes[2] & 0xFF) {
-                                        case 1:
-                                            air1Info = airInfo;
-                                            break;
-                                        case 2:
-                                            air2Info = airInfo;
-                                            break;
-                                        case 3:
-                                            air3Info = airInfo;
-                                            break;
-                                        case 4:
-                                            air4Info = airInfo;
-                                            break;
-
-                                    }
+//                                    switch (getDatas.addBytes[2] & 0xFF) {
+//                                        case 1:
+//                                            air1Info = airInfo;
+//                                            break;
+//                                        case 2:
+//                                            air2Info = airInfo;
+//                                            break;
+//                                        case 3:
+//                                            air3Info = airInfo;
+//                                            break;
+//                                        case 4:
+//                                            air4Info = airInfo;
+//                                            break;
+//
+//                                    }
                                     devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(airInfo);
                                     newInfo1 = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos);
                                     break;
@@ -1557,27 +1571,27 @@
 
 //        getAppInfo(newInfo);
         final AppliancesInfo newInfo = newInfo1;
-        final byte[] airCurInfo;
         if (newInfo == null) {
             return;
         }
-        switch (newInfo.getChannelNum()) {
-            case 1:
-                airCurInfo = air1Info;
-                break;
-            case 2:
-                airCurInfo = air2Info;
-                break;
-            case 3:
-                airCurInfo = air3Info;
-                break;
-            case 4:
-                airCurInfo = air4Info;
-                break;
-            default:
-                airCurInfo = new byte[]{0, 0};
-                break;
-        }
+        final byte[] airCurInfo = newInfo1.getArrCurState();
+//        switch (newInfo.getChannelNum()) {
+//            case 1:
+//                airCurInfo = air1Info;
+//                break;
+//            case 2:
+//                airCurInfo = air2Info;
+//                break;
+//            case 3:
+//                airCurInfo = air3Info;
+//                break;
+//            case 4:
+//                airCurInfo = air4Info;
+//                break;
+//            default:
+//                airCurInfo = new byte[]{0, 0};
+//                break;
+//        }
 
         new Timer().schedule(new TimerTask() {
             @Override
@@ -1808,30 +1822,33 @@
                                         for (int i = 23; i < getDatas.addBytes.length; i++) {
                                             hvacBytes[i - 23] = getDatas.addBytes[i];
                                         }
-                                        devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes);
-                                        switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) {
-                                            case 1:
-                                                if (air1Info == null) {
-                                                    air1Info = hvacBytes;
-                                                }
-                                                break;
-                                            case 2:
-                                                if (air2Info == null) {
-                                                    air2Info = hvacBytes;
-                                                }
-                                                break;
-                                            case 3:
-                                                if (air3Info == null) {
-                                                    air3Info = hvacBytes;
-                                                }
-                                                break;
-                                            case 4:
-                                                if (air4Info == null) {
-                                                    air4Info = hvacBytes;
-                                                }
-                                                break;
 
-                                        }
+                                        HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛�  "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length));
+
+                                        devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes);
+//                                        switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) {
+//                                            case 1:
+//                                                if (air1Info == null) {
+//                                                    air1Info = hvacBytes;
+//                                                }
+//                                                break;
+//                                            case 2:
+//                                                if (air2Info == null) {
+//                                                    air2Info = hvacBytes;
+//                                                }
+//                                                break;
+//                                            case 3:
+//                                                if (air3Info == null) {
+//                                                    air3Info = hvacBytes;
+//                                                }
+//                                                break;
+//                                            case 4:
+//                                                if (air4Info == null) {
+//                                                    air4Info = hvacBytes;
+//                                                }
+//                                                break;
+//
+//                                        }
                                         break;
                                     case 3:
                                         byte[] newBytes = new byte[getDatas.addBytes.length - 24 + 1];
@@ -1886,6 +1903,7 @@
                         }
                         listRemarksOutter:
                         for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) {
+
                             //鎵惧埌E44B瀵瑰簲鐨勮澶囧洖璺紝鍒ゆ柇鏄惁宸茬粡鎷垮埌浜嗘暟鎹��
                             if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == getDatas.sourceSubnetID
                                     && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == getDatas.sourceDeviceID
@@ -1946,7 +1964,7 @@
             ) {
                 List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                 for (int j = 0, len2 = infos.size(); j < len2; j++) {
-                    HDLLog.info("HDL big:锛�" + devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType());
+//                    HDLLog.info("HDL big:锛�" + devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType());
                     switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) {
                         case Configuration.LIGTH_BIG_TYPE:
                             isGetDeviceStateSuccess = true;
@@ -2370,5 +2388,23 @@
         }
     }
 
+    /**
+     * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵��
+     * @param info
+     * @param success
+     */
+    public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success){
+        ctrlSuccessStateHashMap.put(info.getDeviceKey(), success);
+    }
 
+    /**
+     * 鑾峰彇鏄惁鎺у埗鎴愬姛
+     * @param info
+     * @return 缁撴灉
+     */
+    public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info){
+        Boolean success =  ctrlSuccessStateHashMap.get(info.getDeviceKey());
+        if(success == null) success = false;
+        return success;
+    }
 }

--
Gitblit v1.8.0