From 69afac92a320033297d71e901e3c5b65e690f0b2 Mon Sep 17 00:00:00 2001 From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com> Date: 星期二, 12 十一月 2024 11:42:15 +0800 Subject: [PATCH] 增加knx科技系统温度0.5支持 --- HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java | 762 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 644 insertions(+), 118 deletions(-) diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java index 84a4bb7..9e7d2fc 100644 --- a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java +++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java @@ -1,30 +1,52 @@ package com.hdl.sdk.ttl.HDLDeviceManger.Core; import android.content.Context; +import android.util.Log; import com.hdl.sdk.ttl.Config.Configuration; import com.hdl.sdk.ttl.Config.MCUConstants; import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig; import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirTechSysBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; import com.hdl.sdk.ttl.HDLAppliances.HDLAudio.HDLAudio; import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; +import com.hdl.sdk.ttl.HDLAppliances.HDLDoorMachine.DoorMachineBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLDoorMachine.Parser.DoorMachineParser; +import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirJinMaoBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.Parser.FreshAirJinMaoParser; +import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; +import com.hdl.sdk.ttl.HDLAppliances.HDLGeothermal.GeothermalBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; +import com.hdl.sdk.ttl.HDLAppliances.HDLLight.ColourLightCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLLight.Parser.LightCtrlParser; import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo; +import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.SceneCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser.SecurityParser; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DeviceStateBean; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean; +import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ScenesData; +import com.hdl.sdk.ttl.HDLDeviceManger.Bean.SendDatas; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirTechSysFeedBackEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.ColourLightFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DoorMachineFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.FreshAirJinMaoFeedBackEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent; +import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SceneFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.UpdateRemarkFeedBackEvent; import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis; @@ -45,6 +67,7 @@ public class HDLCommand { public static int mRequestTimeout = 5000;//榛樿璇锋眰瓒呮椂鏃堕棿 + public static int mRequestCurtainTimeout = 8000;//榛樿璇锋眰瓒呮椂鏃堕棿 private static Timer getStateFailTimer = null;//鑾峰彇璁惧鐘舵�佸け璐imer private static Timer lightCtrlFailTimer = null;//鎺у埗鐏厜澶辫触Timer private static Timer curtainCtrlFailTimer = null;//鎺у埗绐楀笜澶辫触Timer @@ -55,6 +78,9 @@ private static Timer securityCtrlFailTimer = null;//瀹夐槻妯″潡鎿嶄綔澶辫触Timer private static Timer commonSwitchCtrlFailTimer = null;//閫氱敤寮�鍏冲け璐imer + private static Timer freshAirCtrlFailTimer = null;//鎺у埗鏂伴澶辫触Timer + private static Timer geothermalCtrlFailTimer = null;//鎺у埗鍦扮儹澶辫触Timer 2020-07-20 + private static Timer doorMachineCtrlFailTimer = null;//鎺у埗闂ㄩ攣澶辫触Timer // /** // * 鍒濆鍖� SDK @@ -82,18 +108,40 @@ // HDLDeviceManager.release(); // } + + /** + * 鎼滅储缃戝叧 + */ + public static void seachGateway() { + HandleSearch.seachGateway(); + } + /** * 鑾峰彇瀹跺眳璁惧 */ - public static void getHomeDevices() { - HandleSearch.getHomeDevices(); + public static void getHomeDevices(int subnetID, int deviceID) { + HandleSearch.getHomeDevices(subnetID, deviceID); + } + + /** + * 鑾峰彇瀹跺眳鍦烘櫙 + */ + public static void getHomeScenes(int subnetID, int deviceID) { + HandleSearch.seachHomeScenes(subnetID, deviceID); + } + + /** + * 鑾峰彇瀹跺眳璁惧澶囨敞 + */ + public static void getDevRemarks() { + HandleSearch.getDevRemarks(); } /** * 鍙戠幇鏂拌澶囨悳绱�,涓嶄細娓呯┖鍘熻澶囧垪琛ㄦ暟鎹� */ - public static void getNewHomeDevices() { - HandleSearch.getNewHomeDevices(); + public static void getNewHomeDevices(int subnetID, int deviceID) { + HandleSearch.getNewHomeDevices(subnetID, deviceID); } /** @@ -233,6 +281,40 @@ }, mRequestTimeout); } + /** + * 鎺у埗CCT OR RGB + * + * @param info + * @param brightness 浜害 + * @param color + */ + public static void colourLightCtrl(final AppliancesInfo info, int brightness, int color) { + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (lightCtrlFailTimer != null) { + lightCtrlFailTimer.cancel(); + lightCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { + addSendData(info, LightCtrlParser.getColourLightAddByte(info, brightness, color), Configuration.CONTROL); + + lightCtrlFailTimer = new Timer(); + lightCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + ColourLightCtrlBackInfo colourLightCtrlBackInfo = new ColourLightCtrlBackInfo(info); + EventBus.getDefault().post(new ColourLightFeedBackEvent(colourLightCtrlBackInfo, false)); + } + } + }, mRequestTimeout); + + } else { + HDLLog.I("鐏厜璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } /** * 鎺у埗绐楀笜 @@ -240,8 +322,7 @@ * @param info * @param state */ - public static void curtainCtrl(final AppliancesInfo info, int state) { -// HDLDeviceManager.isCurtainCtrlSuccess = false; + public static void curtainCtrl(final AppliancesInfo info, int state, int type) { HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (curtainCtrlFailTimer != null) { curtainCtrlFailTimer.cancel(); @@ -249,19 +330,23 @@ } byte[] bytes; if (info.getBigType() == Configuration.CURTAIN_BIG_TYPE) { - if (info.getLittleType() == 1 || info.getLittleType() == 0) { - //杩欓噷鏄垽鏂嵎甯樼數鏈哄拰寮�鍚堝笜鐢垫満 + if (info.getLittleType() == 1 || info.getLittleType() == 0 || info.getLittleType() == 3) {//鍒ゆ柇鍗峰笜鐢垫満/寮�鍚堝笜鐢垫満/棣欐牸閲屾媺甯樼數鏈� int newChannelNum; - if (state == CurtainCtrlParser.curtainOff - || state == CurtainCtrlParser.curtainOn - || state == CurtainCtrlParser.curtainPause) { - newChannelNum = info.getChannelNum(); + if (type == 0) { + if (state == CurtainCtrlParser.curtainOff + || state == CurtainCtrlParser.curtainOn + || state == CurtainCtrlParser.curtainPause) { + newChannelNum = info.getChannelNum(); + } else { + newChannelNum = info.getChannelNum() + 16; + } } else { - newChannelNum = info.getChannelNum() + 16; + newChannelNum = info.getChannelNum(); } - bytes = CurtainCtrlParser.getCurtainAddByte(newChannelNum, state); + + bytes = CurtainCtrlParser.getCurtainAddByte(newChannelNum, state, type); } else { - bytes = CurtainCtrlParser.getCurtainAddByte(info.getChannelNum(), state); + bytes = CurtainCtrlParser.getCurtainAddByte(info.getChannelNum(), state, type); } addSendData(info, bytes, Configuration.CONTROL); @@ -275,11 +360,11 @@ CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo(); curtainCtrlBackInfo.setAppliancesInfo(info); curtainCtrlBackInfo.setNum(info.getChannelNum()); + EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, false)); } } - }, mRequestTimeout); - + }, mRequestCurtainTimeout); } else { HDLLog.I("djlCtrl; 涓嶆槸绐楀笜璁惧" @@ -308,6 +393,11 @@ if (info.getBigType() == Configuration.AIR_BIG_TYPE) { if (info.getDeviceType() == HDLApConfig.TYPE_AC_PANEL) { addSendData(info, AirCtrlParser.getAirPanelAddByte(type, state), Configuration.CONTROL); + } else if (info.getDeviceType() == HDLApConfig.TYPE_AC_TECHSYS || info.getDeviceType() == HDLApConfig.TYPE_AC_KNXTECHSYS) { + byte[] airbytes = AirCtrlParser.getAirTechAddByte(info, type, state); + if (airbytes != null) { + addSendData(info, airbytes, Configuration.CONTROL); + } } else { byte[] airbytes = AirCtrlParser.getAcAddByte(info, type, state); if (airbytes != null) { @@ -323,6 +413,47 @@ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(info); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, false)); + } + } + }, mRequestTimeout); + + + } else { + HDLLog.I("绌鸿皟璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + /** + * 鎺у埗绌鸿皟娓╁害锛堟俯搴︿负娴偣鍨嬶級 + * + * @param info + * @param type + * @param temp 娓╁害 + */ + public static void airCtrlTemp(final AppliancesInfo info, int type, float temp) { + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (acCtrlFailTimer != null) { + acCtrlFailTimer.cancel(); + acCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.AIR_BIG_TYPE) { + if (info.getDeviceType() == HDLApConfig.TYPE_AC_KNXTECHSYS) { + byte[] airbytes = AirCtrlParser.getAirKNXTechAddByte(info, type, temp); + if (airbytes != null) { + addSendData(info, airbytes, Configuration.CONTROL); + } + } + + acCtrlFailTimer = new Timer(); + acCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + AirTechSysBackInfo AirTechSysBackInfo = new AirTechSysBackInfo(info); + EventBus.getDefault().post(new AirTechSysFeedBackEvent(AirTechSysBackInfo, false)); } } }, mRequestTimeout); @@ -379,6 +510,7 @@ /** * 鑾峰彇閫氱敤寮�鍏崇姸鎬� + * * @param info */ public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) { @@ -400,6 +532,7 @@ /** * 瀹夐槻妯″潡 甯冮槻璁剧疆 * 2019-7-29 + * * @param info */ public static void securityArmingCtrl(final AppliancesInfo info, int state) { @@ -417,7 +550,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); @@ -433,6 +566,7 @@ /** * 瀹夐槻妯″潡 鎶ヨ璁剧疆 * 2019-7-29 + * * @param info * @param state 鍙戦�佺殑鎶ヨ鍐呭锛屽彧鎶ヨ涓�绉� */ @@ -484,56 +618,42 @@ } }, mRequestTimeout); } else { - HDLLog.I("djlCtrl: 閫昏緫妯″潡璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + HDLLog.I("閫昏緫妯″潡璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + " LittleType = " + info.getLittleType() + " BigType = " + info.getBigType() ); } } - // 鑾峰彇鍗曚竴鍥炶矾璁惧鐘舵�� - // 璇诲彇璁惧鐘舵�� -// public static void getDeviceState(final AppliancesInfo I) { -// HDLDeviceManager.isGetDeviceStateSuccess = false; -// switch (I.getBigType()) { -// case Configuration.LIGTH_BIG_TYPE: -// addSendData(I, new byte[]{}, Configuration.STATE); -// break; -// case Configuration.CURTAIN_BIG_TYPE: -// if (I.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { -// addSendData(I, new byte[]{(byte) I.getChannelNum()}, Configuration.STATE); -// } else { -// addSendData(I, new byte[]{(byte) (I.getChannelNum() + 16)}, Configuration.STATE); -// } -// break; -// case Configuration.AIR_BIG_TYPE: -// addSendData(I, new byte[]{AirCtrlParser.airSwich}, Configuration.STATE); -//// addSendData(I,new byte[]{AirCtrlParser.refTem},Configuration.STATE); -// addSendData(I, new byte[]{AirCtrlParser.airSpeed}, Configuration.STATE); -// addSendData(I, new byte[]{AirCtrlParser.airMode}, Configuration.STATE); -//// addSendData(I,new byte[]{AirCtrlParser.heatTem},Configuration.STATE); -//// addSendData(I,new byte[]{AirCtrlParser.autoTem},Configuration.STATE); -// break; -// } -// -// if (I.getBigType() == Configuration.AIR_BIG_TYPE) { -// return; -// } -// if (getStateFailTimer != null) { -// getStateFailTimer.cancel(); -// getStateFailTimer = null; -// } -// getStateFailTimer = new Timer(); -// getStateFailTimer.schedule(new TimerTask() { -// @Override -// public void run() { -// if (!HDLDeviceManager.isGetDeviceStateSuccess) { -// EventBus.getDefault().post(new DeviceStateEvent(I, false)); -// } -// } -// }, mRequestTimeout); -// -// } + /** + * 鍦烘櫙鎺у埗 + * + * @param scenesData + */ + public static void sceneCtrl(final ScenesData scenesData) { + cusSendCommand(Configuration.LOGIC_CTRL_COMMAND, scenesData.getSourceSubnetID(), scenesData.getSourceDeviceID(), new byte[]{ + (byte) (scenesData.getAreaCodeID()), + (byte) (scenesData.getSceneID()) + }); + + if (sceneCtrlFailTimer != null) { + sceneCtrlFailTimer.cancel(); + sceneCtrlFailTimer = null; + } + sceneCtrlFailTimer = new Timer(); + sceneCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.isSceneCtrlSuccess()) { + HDLLog.I("鍦烘櫙鎺у埗澶辫触"); + SceneCtrlBackInfo sceneCtrlBackInfo = new SceneCtrlBackInfo(); + sceneCtrlBackInfo.setAreaCodeID(scenesData.getAreaCodeID()); + sceneCtrlBackInfo.setSceneID(scenesData.getSceneID()); + EventBus.getDefault().post(new SceneFeedBackEvent(sceneCtrlBackInfo, false)); + } + } + }, mRequestTimeout); + } /** * 鎺у埗绐楀笜 @@ -612,6 +732,7 @@ /** * 鑾峰彇绐楀笜璁惧鐘舵�� + * * @param info */ public static void getCurtainDeviceStateFromNetwork(final AppliancesInfo info) { @@ -620,10 +741,14 @@ } HDLDeviceManager.isGetDeviceStateSuccess = false; switch (info.getDeviceType()) { + case HDLApConfig.TYPE_CURTAIN_MODULE: + addSendData(info, new byte[]{(byte) info.getChannelNum(), 0, 1}, Configuration.STATE); + break; case HDLApConfig.TYPE_CURTAIN_GLYSTRO: case HDLApConfig.TYPE_CURTAIN_ROLLER: - case HDLApConfig.TYPE_CURTAIN_MODULE: - addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + case HDLApConfig.TYPE_CURTAIN_SHANGRILA: + //鍙鍙栫櫨鍒嗘瘮锛屼笉璇诲彇寮�鍏冲仠 + addSendData(info, new byte[]{(byte) info.getChannelNum(), 0, 2}, Configuration.STATE); break; default: HDLLog.I("涓嶆槸绐楀笜璁惧"); @@ -633,6 +758,7 @@ /** * 鑾峰彇鐏厜璁惧鐘舵�� + * * @param info */ public static void getLightDeviceStateFromNetwork(final AppliancesInfo info) { @@ -645,8 +771,9 @@ case HDLApConfig.TYPE_LIGHT_RELAY: case HDLApConfig.TYPE_LIGHT_MIX_DIMMER: case HDLApConfig.TYPE_LIGHT_MIX_RELAY: - //鍙戦�佽幏鐏厜鐘舵�佹暟鎹� - addSendData(info, new byte[0], Configuration.STATE); + //鍙戦�佽幏鍙栫伅鍏夌姸鎬佹暟鎹� + byte[] sendbytes = new byte[]{(byte) info.getChannelNum()}; + addSendData(info, sendbytes, Configuration.STATE); break; default: HDLLog.I("涓嶆槸鐏厜璁惧"); @@ -654,10 +781,35 @@ } } + /** + * 鑾峰彇CTT or RGB鐏澶囩姸鎬� + * + * @param info + */ + public static void getColourLightDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_LIGHT_CCT: + case HDLApConfig.TYPE_LIGHT_RGB: + case HDLApConfig.TYPE_LIGHT_DALI: + case HDLApConfig.TYPE_LIGHT_DMX: + //鍙戦�佽幏鍙栫伅鍏夌姸鎬佹暟鎹� + byte[] sendbytes = new byte[]{(byte) info.getChannelNum()}; + addSendData(info, sendbytes, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸CTT or RGB鐏厜璁惧"); + break; + } + } /** * 鑾峰彇閫昏緫 鍦烘櫙鍙� + * * @param info */ public static void getLogicDeviceStateFromNetwork(final AppliancesInfo info) { @@ -679,6 +831,7 @@ /** * 鑾峰彇瀹夐槻妯″潡鐘舵�� + * * @param info */ public static void getSecurityStateFromNetwork(final AppliancesInfo info) { @@ -699,6 +852,7 @@ /** * 鑾峰彇浼犳劅鍣ㄦā鍧楃姸鎬� + * * @param info */ public static void getSensorStateFromNetwork(final AppliancesInfo info) { @@ -707,34 +861,11 @@ } HDLDeviceManager.isGetDeviceStateSuccess = false; switch (info.getDeviceType()) { - case HDLApConfig.TYPE_SENSOR_DRY_CONTACT: - case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: case HDLApConfig.TYPE_SENSOR_TEMP: case HDLApConfig.TYPE_SENSOR_HUMIDITY: - case HDLApConfig.TYPE_SENSOR_ILLUMINACE: - case HDLApConfig.TYPE_SENSOR_VOC: case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: case HDLApConfig.TYPE_SENSOR_C02: - case HDLApConfig.TYPE_SENSOR_LPG: - case HDLApConfig.TYPE_SENSOR_CO_H2: - case HDLApConfig.TYPE_SENSOR_CH4: - case HDLApConfig.TYPE_SENSOR_SMOG: - case HDLApConfig.TYPE_SENSOR_WIND_SPEED: - case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE: - case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW: - case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE: - case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH: - case HDLApConfig.TYPE_SENSOR_RAIN_FALL: - case HDLApConfig.TYPE_SENSOR_WEIGHT: - case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH: - case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED: - case HDLApConfig.TYPE_SENSOR_SHAKE: - case HDLApConfig.TYPE_SENSOR_VOLTAGE: - case HDLApConfig.TYPE_SENSOR_ELECTRICITY: - case HDLApConfig.TYPE_SENSOR_POWER: - case HDLApConfig.TYPE_SENSOR_FLOODING: - case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET: - case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON: + case HDLApConfig.TYPE_SENSOR_PM_10: //鍙戦�佽幏浼犳劅鍣ㄦā鍧楃姸鎬佹暟鎹� byte[] sendDatabyte = new byte[]{ (byte) info.getBigType(), @@ -752,6 +883,7 @@ /** * 鑾峰彇骞叉帴鐐逛紶鎰熷櫒妯″潡鐘舵�� + * * @param info */ public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) { @@ -788,6 +920,7 @@ case HDLApConfig.TYPE_SENSOR_FLOODING: case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET: case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON: + case HDLApConfig.TYPE_SENSOR_PM_10: //鍙戦�佽幏浼犳劅鍣ㄦā鍧楃姸鎬佹暟鎹� byte[] sendDatabyte = new byte[]{ (byte) 1, @@ -804,6 +937,7 @@ /** * 鑾峰彇HVAC绌鸿皟璁惧鐘舵�� + * * @param info */ public static void getHVACDeviceStateFromNetwork(final AppliancesInfo info) { @@ -815,10 +949,59 @@ case HDLApConfig.TYPE_AC_HVAC: // case HDLApConfig.TYPE_AC_PANEL: //鍙戦�丠VAC鐘舵�佹暟鎹� - addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); break; default: HDLLog.I("涓嶆槸HVAC绌鸿皟璁惧"); + break; + } + } + + + /** + * 鑾峰彇绉戞妧绯荤粺鐘舵�� + * + * @param info + */ + public static void getTechSysDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_AC_TECHSYS: + case HDLApConfig.TYPE_AC_KNXTECHSYS: + //鍙戦�佺鎶�绯荤粺鐘舵�佹暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸绉戞妧绯荤粺璁惧"); + break; + } + } + + /** + * 鑾峰彇绉戞妧绯荤粺瀹ゅ唴婀垮害鐘舵�� + * + * @param info + */ + public static void getTechSysDeviceHumidityFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + info.setGetDeviceStateSuccess(false); + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_AC_KNXTECHSYS: + //鍙戦�佺鎶�绯荤粺鐘舵�佹暟鎹� + byte[] sendDatabyte = new byte[]{ + (byte) info.getBigType(), + (byte) info.getLittleType(), + (byte) info.getChannelNum() + }; + addCommandSendData(info, sendDatabyte, Configuration.SENSOR_STATE_COMMAND); + break; + default: + HDLLog.I("涓嶆槸绉戞妧绯荤粺璁惧"); break; } } @@ -848,6 +1031,7 @@ case HDLApConfig.TYPE_CURTAIN_GLYSTRO: case HDLApConfig.TYPE_CURTAIN_ROLLER: case HDLApConfig.TYPE_CURTAIN_MODULE: + case HDLApConfig.TYPE_CURTAIN_SHANGRILA: int curtainState = getCurtainState(info); info.setCurState(curtainState); EventBus.getDefault().post(new DeviceStateEvent(info, true)); @@ -857,6 +1041,8 @@ case HDLApConfig.TYPE_AC_COOLMASTER: case HDLApConfig.TYPE_AC_INFRARED: case HDLApConfig.TYPE_AC_PANEL: + case HDLApConfig.TYPE_AC_TECHSYS: + case HDLApConfig.TYPE_AC_KNXTECHSYS: //2019-8-21 澧炲姞鍒ょ┖ byte[] acState = getACState(info); if (acState != null && acState.length >= 4) { @@ -1081,6 +1267,8 @@ switch (info.getDeviceType()) { case HDLApConfig.TYPE_AC_HVAC: case HDLApConfig.TYPE_AC_PANEL: + case HDLApConfig.TYPE_AC_TECHSYS: + case HDLApConfig.TYPE_AC_KNXTECHSYS: curState = infos.get(j).getArrCurState(); break; default: @@ -1127,6 +1315,321 @@ } + /** + * 鑾峰彇鏂伴 + * + * @param info + */ + public static void getFreshAirDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_FRESH_AIR: + case HDLApConfig.TYPE_FRESH_AIR_JINMAO: + //鍙戦�佽幏鍙栨柊椋庣郴缁熸墍鏈夋暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸鏂伴绯荤粺璁惧"); + break; + } + } + + /** + * 鎺у埗鏂伴绯荤粺 + * + * @param info + * @param type + * @param state 2020-07-20 + */ + public static void freshAirCtrl(final AppliancesInfo info, int type, int state) { +// HDLDeviceManager.isFreshAirCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (freshAirCtrlFailTimer != null) { + freshAirCtrlFailTimer.cancel(); + freshAirCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.FRESH_AIR_BIG_TYPE) { + byte[] freshAirbytes = FreshAirParser.getFreshAirAddByte(info, type, state); + addSendData(info, freshAirbytes, Configuration.CONTROL); + freshAirCtrlFailTimer = new Timer(); + freshAirCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(); + mFreshAirBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new FreshAirFeedBackEvent(mFreshAirBackInfo, false)); + } + } + }, mRequestTimeout); + + + } else { + HDLLog.I("鏂伴璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + + /** + * 鑾峰彇閲戣寕鏂伴鐘舵�� + * + * @param info + */ + public static void getFreshAirJinMaoDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_FRESH_AIR_JINMAO: + //鍙戦�佽幏鍙栨柊椋庣郴缁熸墍鏈夋暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸閲戣寕鏂伴绯荤粺璁惧"); + break; + } + } + + /** + * 鎺у埗閲戣寕鏂伴 + * + * @param info + * @param type + * @param state 2020-07-20 + */ + public static void freshAirJinMaoCtrl(final AppliancesInfo info, int type, int state) { +// HDLDeviceManager.isFreshAirCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (freshAirCtrlFailTimer != null) { + freshAirCtrlFailTimer.cancel(); + freshAirCtrlFailTimer = null; + } + if (info.getDeviceType() == HDLApConfig.TYPE_FRESH_AIR_JINMAO) { + byte[] sendBytes = FreshAirJinMaoParser.getFreshAirAddByte(info, type, state); + addSendData(info, sendBytes, Configuration.CONTROL); + freshAirCtrlFailTimer = new Timer(); + freshAirCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + FreshAirJinMaoBackInfo mFreshAirJinMaoBackInfo = new FreshAirJinMaoBackInfo(); + mFreshAirJinMaoBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new FreshAirJinMaoFeedBackEvent(mFreshAirJinMaoBackInfo, false)); + } + } + }, mRequestTimeout); + + + } else { + HDLLog.I("涓嶆槸閲戣寕鏂伴绯荤粺璁惧"); + } + } + + + /** + * 鑾峰彇鍦扮儹鐘舵�� + * + * @param info + */ + public static void getGeothermalStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_GEOTHERMAL_JINMAO: + case HDLApConfig.TYPE_GEOTHERMAL_MODULE: + //鍙戦�佽幏鍙栧湴鐑郴缁熸墍鏈夋暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸鍦扮儹璁惧"); + break; + } + } + + /** + * 鎺у埗鍦扮儹妯″潡娓╁害 + * + * @param info + * @param tempInt 2020-03-15 + */ + public static void geothermalCtrlTemp(final AppliancesInfo info, int tempInt) { +// HDLDeviceManager.isGeothermalCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (geothermalCtrlFailTimer != null) { + geothermalCtrlFailTimer.cancel(); + geothermalCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { + byte[] sendbytes = GeothermalParser.getGeothermalAddByteTemp(info, tempInt); + addSendData(info, sendbytes, Configuration.CONTROL); + + geothermalCtrlFailTimer = new Timer(); + geothermalCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); + mGeothermalBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE_TIMEOUT)); + } + } + }, mRequestTimeout); + + + } else { + HDLLog.I("鍦扮儹妯″潡鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + /** + * 鎺у埗鍦扮儹妯″潡 + * + * @param info + * @param type + * @param state 2019-07-10 + */ + public static void geothermalCtrl(final AppliancesInfo info, int type, int state) { +// HDLDeviceManager.isGeothermalCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (geothermalCtrlFailTimer != null) { + geothermalCtrlFailTimer.cancel(); + geothermalCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { + byte[] sendbytes = GeothermalParser.getGeothermalAddByte(info, type, state); + addSendData(info, sendbytes, Configuration.CONTROL); + + geothermalCtrlFailTimer = new Timer(); + geothermalCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); + mGeothermalBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE_TIMEOUT)); + } + } + }, 5000); + + + } else { + HDLLog.I("鍦扮儹妯″潡鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + + /** + * 鑾峰彇闂ㄩ攣鐘舵�� + * + * @param info + */ + public static void getDoorMachineDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_DOOR_MACHINE: + //鍙戦�佽幏鍙栭棬閿佹墍鏈夋暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.I("涓嶆槸闂ㄩ攣璁惧"); + break; + } + } + + /** + * 闂ㄩ攣妯″潡 杩滅▼寮�閿佽幏鍙栧瘑閽� + * 2023-8-25 + * + * @param info + */ + public static void doorMachineGetSecret(final AppliancesInfo info) { + if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { + byte[] sendbytes = new byte[]{(byte) info.getChannelNum()}; + cusSendCommand(Configuration.DOOR_MACHINE_MODULE_CTRL_FRIST_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes); + } else { + HDLLog.I("涓嶆槸闂ㄩ攣妯″潡" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + /** + * 鎺у埗闂ㄩ攣杩滅▼寮�閿� + * + * @param info + * @param secretBytes 瀵嗛挜 + * @param password 寮�閿佸瘑鐮� 2023-08-22 + */ + public static void doorMachineCtrl(final AppliancesInfo info, byte[] secretBytes, String password, int doorStatus) { + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (doorMachineCtrlFailTimer != null) { + doorMachineCtrlFailTimer.cancel(); + doorMachineCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { + byte[] doorMachinebytes = DoorMachineParser.getDoorMachineAddByte(info, secretBytes, password, doorStatus); + addSendData(info, doorMachinebytes, Configuration.CONTROL); + doorMachineCtrlFailTimer = new Timer(); + doorMachineCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + DoorMachineBackInfo mDoorMachineBackInfo = new DoorMachineBackInfo(); + mDoorMachineBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new DoorMachineFeedBackEvent(mDoorMachineBackInfo, false)); + } + } + }, mRequestTimeout); + + + } else { + HDLLog.I("闂ㄩ攣鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + + /** + * 闂ㄩ攣妯″潡 璁剧疆涓存椂瀵嗙爜 + * 2023-8-25 + * + * @param info + * @param tempPassword 涓存椂瀵嗙爜 + * @param startTime 寮�濮嬫椂闂存埑 + * @param endTime 缁撴潫鏃堕棿鎴� + */ + public static void doorMachineSettingPwd(final AppliancesInfo info, String tempPassword, String startTime, String endTime) { + if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { + byte[] sendbytes = DoorMachineParser.getDoorMachineSettingPwdByte(info, tempPassword, startTime, endTime); + cusSendCommand(Configuration.DOOR_MACHINE_MODULE_SETTING_PASSWORD_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes); + } else { + HDLLog.I("涓嶆槸闂ㄩ攣妯″潡" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } /** * 鑳屾櫙闊充箰鎺у埗 @@ -1341,40 +1844,25 @@ @Override public void run() { //2019-07 鎺у埗鍙戦�佹鏁� - if (sendDatas.count >= 4) { + if (sendDatas.count >= 3) { sendCycleTimer.cancel(); } else { sendDatas.count++; if (type == Configuration.STATE) { sendDatas.command = info.getStateCommand(); + HDLLog.I("---getDevice锛� " + info.getDeviceKey() + " ---getStateCommand锛� " + Integer.toHexString(info.getStateCommand()));//2019-8-2 sendDatas.isCtrlSuccess = HDLDeviceManager.isGetDeviceStateSuccess; } else if (type == Configuration.CONTROL) { sendDatas.command = info.getCtrlCommand(); - HDLLog.I("getDeviceKey锛� " + info.getDeviceKey());//2019-8-2 + HDLLog.I("---getDevice锛� " + info.getDeviceKey() + " ---getCtrlCommand锛� " + Integer.toHexString(info.getCtrlCommand()));//2019-8-2 sendDatas.isCtrlSuccess = HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info); - -// switch (info.getBigType()) { -// case Configuration.LIGTH_BIG_TYPE: -// sendDatas.isCtrlSuccess = HDLDeviceManager.isLightCtrlSuccess; -// break; -// case Configuration.CURTAIN_BIG_TYPE: -// sendDatas.isCtrlSuccess = HDLDeviceManager.isCurtainCtrlSuccess; -// break; -// case Configuration.AIR_BIG_TYPE: -// sendDatas.isCtrlSuccess = HDLDeviceManager.isACCtrlSuccess; -// break; -// case Configuration.LOGIC_BIG_TYPE: -// sendDatas.isCtrlSuccess = HDLDeviceManager.isSceneCtrlSuccess; -// break; -// case Configuration.SECURITY_BIG_TYPE: -// sendDatas.isCtrlSuccess = HDLDeviceManager.isSecurityCtrlSuccess; -// break; -// default: -// sendDatas.isCtrlSuccess = false; -// } } if (!sendDatas.isCtrlSuccess) { - HDLLog.I("鎺у埗鍙戦�佺" + sendDatas.count + "娆�"); + if (type == Configuration.STATE) { + HDLLog.I("璇诲彇鍙戦�佺" + sendDatas.count + "娆�"); + } else if (type == Configuration.CONTROL) { + HDLLog.I("鎺у埗鍙戦�佺" + sendDatas.count + "娆�"); + } cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes); } else { sendCycleTimer.cancel(); @@ -1383,10 +1871,44 @@ } }, 1, 500); - - } + /** + * 鍗曡澶囧彂閫佸懡浠� + * 鐩墠鎺у埗鍙戦�佹鏁颁负3娆� + * 鍙戜竴鏉�,琛ュ彂3鏉★紝闂撮殧500ms + * + * @param info + * @param addBytes + */ + private static void addCommandSendData(final AppliancesInfo info, byte[] addBytes, final int command) { + + final Crc sendDatas = new Crc(info.getStateCommand(), info.getDeviceSubnetID(), info.getDeviceDeviceID(), addBytes); + sendDatas.count = 0; + + final Timer sendCycleTimer = new Timer(); + sendCycleTimer.schedule(new TimerTask() { + @Override + public void run() { + //2019-07 鎺у埗鍙戦�佹鏁� + if (sendDatas.count >= 3) { + sendCycleTimer.cancel(); + } else { + sendDatas.count++; + sendDatas.command = command; + HDLLog.I("---getDevice锛� " + info.getDeviceKey() + " ---command锛� " + Integer.toHexString(command));//2019-8-2 + sendDatas.isCtrlSuccess = info.isGetDeviceStateSuccess(); + + if (!sendDatas.isCtrlSuccess) { + HDLLog.I("璇诲彇鍙戦�佺" + sendDatas.count + "娆�"); + cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes); + } else { + sendCycleTimer.cancel(); + } + } + } + }, 1, 500); + } /** * 鍙戦�佸箍鎾垨鐐瑰鐐瑰懡浠� @@ -1397,9 +1919,13 @@ * @param addBytes 闄勫姞鏁版嵁 */ public static void cusSendCommand(int command, int subnetID, int deviceID, byte[] addBytes) { - Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes); - HDLSerialPortCore.sendData(sendDatas); + if (HDLSerialPortCore.getIsModule()) { + Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes); + HDLSerialPortCore.sendData(sendDatas); + } else { + SendDatas.AddSendData(command, subnetID, deviceID, addBytes); + } } /** -- Gitblit v1.8.0