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/HDLCommand.java | 147 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 142 insertions(+), 5 deletions(-) diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java index 1c572c8..e1a3746 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java @@ -16,6 +16,7 @@ import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; 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.HDLSecurity.Parser.SecurityParser; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; @@ -29,6 +30,7 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; 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.SecurityArmingFeedBackEvent; import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; @@ -60,6 +62,8 @@ private static Timer securityCtrlFailTimer = null;//瀹夐槻妯″潡鎿嶄綔澶辫触Timer private static Timer commonSwitchCtrlFailTimer = null;//閫氱敤寮�鍏冲け璐imer + private static Timer lightRgbCtrlFailTimer = null;//RGB澶辫触Timer + private static Timer lightCCTCtrlFailTimer = null;//CCT澶辫触Timer /** * 鍒濆鍖� @@ -73,6 +77,7 @@ /** * 寮�鍚痓us妯″紡 * 鍚敤6000绔彛 + * * @param context */ public static void startHomeMode(Context context) { @@ -86,6 +91,7 @@ /** * 寮�鍚疪CU妯″紡 * 鍚敤6008绔彛 + * * @param context * @param newRcuIp RCU鐨処P鍦板潃 */ @@ -107,15 +113,17 @@ /** * 鑾峰彇鏈湴骞挎挱IP + * * @return */ - public static String getLocalBroadCastIp(){ + public static String getLocalBroadCastIp() { return NetWorkUtil.getLocalBroadCast(); } /** * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃 * 2019-07-10鏂板 + * * @param bOpen */ public static void setHDLLogOpen(boolean bOpen) { @@ -133,7 +141,6 @@ // private static void devicesSearch() { // HandleSearch.getRcuIp(); // } - /** @@ -762,8 +769,8 @@ && info.getChannelNum() == infos.get(j).getChannelNum() ) { //杩欓噷搴旇鏄淇鐨勶紝鏆傛椂鏈壘鍒般�� - //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� - int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); switch (state) { case -1: curState = 0; @@ -1139,6 +1146,7 @@ /** * 鑾峰彇閫氱敤寮�鍏崇姸鎬� + * * @param info */ public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) { @@ -1159,6 +1167,7 @@ /** * 鑾峰彇瀹夐槻妯″潡鐘舵�� + * * @param info */ public static void getSecurityStateFromNetwork(final AppliancesInfo info) { @@ -1180,6 +1189,7 @@ /** * 瀹夐槻妯″潡 甯冮槻璁剧疆 * 2020-06-23 + * * @param info */ public static void securityArmingCtrl(final AppliancesInfo info, int state) { @@ -1197,7 +1207,7 @@ @Override public void run() { if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { - EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info,0, false)); + EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info, 0, false)); } } }, 5000); @@ -1231,6 +1241,7 @@ /** * 鑾峰彇骞叉帴鐐逛紶鎰熷櫒妯″潡鐘舵�� + * * @param info */ public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) { @@ -1281,4 +1292,130 @@ } } + /**************************************2020-10-20 鏂板***************************************/ + /** + * 鎺у埗RGB + * + * @param info + */ + public static void lightRGBCtrl(final AppliancesInfo info, int brightness, int rStatus, int gStatus, int bStatus) { + + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { + + if (lightRgbCtrlFailTimer != null) { + lightRgbCtrlFailTimer.cancel(); + lightRgbCtrlFailTimer = null; + } + + byte[] bytes = new byte[]{ + (byte) info.getChannelNum(), + (byte) brightness, + (byte) 254, + 0, + 0, + 3, + (byte) rStatus, + (byte) gStatus, + (byte) bStatus, + 0, + 0 + }; + + addSendData(info, bytes, Configuration.CONTROL); + + lightRgbCtrlFailTimer = new Timer(); + lightRgbCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + HDLLog.info("RGB鎺у埗澶辫触"); + RGBBackInfo mRGBBackInfo = new RGBBackInfo(); + mRGBBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(mRGBBackInfo, false)); + } + } + }, mRequestTimeout); + } else { + HDLLog.info("djlCtrl: 璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + + /** + * 鑾峰彇CCT 鎴栬�匯GB鐏姸鎬� + * + * @param info + */ + public static void getRGBCCTStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_LIGHT_RGB: + case HDLApConfig.TYPE_LIGHT_CCT: + //鍙戦�丆CT RGB鐘舵�佹暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.info("涓嶆槸瀹夐槻妯″潡"); + break; + } + } + + /** + * 鎺у埗CCT + * + * @param info + */ + public static void lightCCTCtrl(final AppliancesInfo info, int brightness, int cctStatus) { + + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { + + if (lightCCTCtrlFailTimer != null) { + lightCCTCtrlFailTimer.cancel(); + lightCCTCtrlFailTimer = null; + } + + byte[] bytes = new byte[]{ + (byte) info.getChannelNum(), + (byte) brightness, + (byte) 254, + 0, + 0, + 2, + (byte) (cctStatus / 256), + (byte) (cctStatus % 256), + 0, + 0, + 0 + }; + + addSendData(info, bytes, Configuration.CONTROL); + + lightCCTCtrlFailTimer = new Timer(); + lightCCTCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + HDLLog.info("RGB鎺у埗澶辫触"); + RGBBackInfo mRGBBackInfo = new RGBBackInfo(); + mRGBBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(mRGBBackInfo, false)); + } + } + }, mRequestTimeout); + } else { + HDLLog.info("djlCtrl: 璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + } -- Gitblit v1.8.0