From c9978ac37e3e9817ab07b25dbb499b28918403fd Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 20 十月 2020 15:49:54 +0800 Subject: [PATCH] 2020-10-20 1.增加RGB和CCT灯控制协议 --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 172 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 144 insertions(+), 28 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 34d027c..54518fe 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 @@ -17,7 +17,9 @@ import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.CCTBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.SecurityBackInfo; @@ -38,8 +40,10 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightCCTCtrlBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightRGBCtrlBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; @@ -118,28 +122,30 @@ /** * 閰嶇疆绠�鏄撶紪绋嬫悳绱㈣繑鍥炵殑榛樿鍙傛暟 - * @param mSDKLocalBigClass 澶х被ID + * + * @param mSDKLocalBigClass 澶х被ID * @param mSDKLocalSmallClass 灏忕被ID - * @param mSDKLocalRemark 澶囨敞 + * @param mSDKLocalRemark 澶囨敞 */ - public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark){ + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark) { SDKLocalBigClass = mSDKLocalBigClass; SDKLocalSmallClass = mSDKLocalSmallClass; - if(mSDKLocalRemark != null){ + if (mSDKLocalRemark != null) { SDKLocalRemark = mSDKLocalRemark; } isAllowEasyProgrammingSearch = true; } - public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass){ - setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass,null); + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass) { + setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass, null); } /** * 璁剧疆鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱� + * * @param isAllow */ - public static void setIsAllowEasyProgrammingSearch(boolean isAllow){ + public static void setIsAllowEasyProgrammingSearch(boolean isAllow) { isAllowEasyProgrammingSearch = isAllow; } @@ -180,6 +186,12 @@ case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709鏂板 handleCtrlData(getDatas); + break; + case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: //2020-10-19鏂板 + handleRGBCCTCtrlData(getDatas); + break; + case Configuration.LIGHT_RGB_STATE_BACK_COMMAND: //2020-10-19鏂板 + handleRGBCCTStateData(getDatas); break; case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709鏂板 handleGeothermalCtrlData(getDatas); @@ -326,7 +338,7 @@ * @param getDatas */ private static void sendDeviceSearchBackInfo(UdpDataBean getDatas) { - byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); + byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); byte[] addBytes = new byte[25]; addBytes[0] = getDatas.addBytes[0]; addBytes[1] = getDatas.addBytes[1]; @@ -352,11 +364,12 @@ /** * 鏀跺埌绠�鏄撶紪绋嬫悳绱㈤潪缃戠粶璁惧 + * * @param getDatas */ - public static void handleDeviceSearchBackData(UdpDataBean getDatas){ + public static void handleDeviceSearchBackData(UdpDataBean getDatas) { //鍒ゆ柇鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱㈠拰鍥炲 - if(!isAllowEasyProgrammingSearch) return; + if (!isAllowEasyProgrammingSearch) return; if (getDatas.addBytes.length == 2) { sendDeviceSearchBackInfo(getDatas); @@ -365,7 +378,7 @@ for (int i = 2, len = getDatas.addBytes.length; i < len; i++) { if (i % 2 == 0) { if ((getDatas.addBytes[i] & 0xFF) == Crc.localSubnetID - && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID + && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID ) { isExit = true; break; @@ -373,14 +386,13 @@ } } - if(!isExit){ + if (!isExit) { sendDeviceSearchBackInfo(getDatas); } } } - /** @@ -595,9 +607,10 @@ * 澶勭悊鐏厜杩斿洖 * 2020-1-18 * 淇娣峰悎璋冨厜娣峰悎寮�鍏� 绫绘ā鍧楅棶棰� + * * @param getDatas */ - private static void handleLightCtrlData(UdpDataBean getDatas){ + private static void handleLightCtrlData(UdpDataBean getDatas) { if (TextUtils.isEmpty(HandleSearch.rcuIp)) { outter: @@ -607,7 +620,7 @@ ) { List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { - if(infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10 ){ + if (infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10) { if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) { @@ -628,7 +641,7 @@ } - }else { + } else { if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { @@ -776,7 +789,7 @@ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); inner: for (int j = 0, len2 = infos.size(); j < len2; j++) { - if(infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO + if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE ) { @@ -1981,7 +1994,7 @@ hvacBytes[i - 23] = getDatas.addBytes[i]; } - HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length)); + 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()) { @@ -2409,7 +2422,7 @@ devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; - }else { + } else { HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); } } @@ -2450,7 +2463,7 @@ } break outter; - }else { + } else { HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); } } @@ -2458,7 +2471,6 @@ } } } - /** @@ -2554,21 +2566,23 @@ /** * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵�� + * * @param info * @param success */ - public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean 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; + public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info) { + Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); + if (success == null) success = false; return success; } @@ -2576,6 +2590,7 @@ * 淇濆瓨璁惧鏁版嵁鍒楄〃 * 鏍规嵁闇�瑕侊紝瀹炴椂淇濆瓨褰撳墠鏁版嵁 * 2019-10-14 + * * @return boolean */ public static boolean saveDevicesDataList() { @@ -2619,7 +2634,7 @@ HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; HDLUdpCore.closeSocket6000(); HDLUdpCore.init6008(); - }else { + } else { HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; HDLUdpCore.closeSocket6008(); HDLUdpCore.init6000(); @@ -2629,8 +2644,7 @@ } - - private static void setRemarkList(){ + private static void setRemarkList() { listRemarks.clear(); for (int j = 0; j < devicesDataList.size(); j++) { if (devicesDataList.get(j).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) { @@ -2877,4 +2891,106 @@ } + /** + * RGB CCT璁惧鎺у埗鏁版嵁 + * 2020-10-20 鏂板 + * + * @param getDatas + */ + private static void handleRGBCCTCtrlData(UdpDataBean getDatas) { + if (getDatas.addBytes.length >= 9) { + //1-5//1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + if (getDatas.addBytes[5] == 3) {//RGB + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { + + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) + ) { + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + RGBBackInfo info = new RGBBackInfo(mInfo); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(info, true)); + } + } + break outter;//璺冲嚭寰幆 + } + } + } else if (getDatas.addBytes[5] == 2) {//CCT + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { + + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) + ) { + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + CCTBackInfo info = new CCTBackInfo(mInfo); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new LightCCTCtrlBackEvent(info, true)); + } + } + break outter;//璺冲嚭寰幆 + } + } + + } + + } + + + } + + /** + * RGB CCT 鐘舵�佽鍙栧洖澶嶆暟鎹� + * 2020-10-20 鏂板 + * + * @param getDatas + */ + private static void handleRGBCCTStateData(UdpDataBean getDatas) { + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB || infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT) + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 9) { + byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); + if (getBytes == null || getBytes.length < 9) {//鏍囧噯鍗忚闀垮害鏄�11锛屼絾鏄姄鍖呭彂鐜版湁鐨勮澶囦細灏戜簬11 + getBytes = new byte[11]; + } + System.arraycopy(getDatas.addBytes, 0, getBytes, 0, Math.min(getDatas.addBytes.length, 11)); + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); + isGetDeviceStateSuccess = true; + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + } else { + HDLLog.E("RGB CCT鐘舵�佸弽棣堟暟鎹紓甯�"); + } + + break outter; + } else { +// HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + + } + } -- Gitblit v1.8.0