From ce062b3c62d283fa364f92853d1b53221b94a3bc Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 24 六月 2020 09:30:32 +0800 Subject: [PATCH] 2020-06-24 1.增加手动添加生成设备接口方法。 2.增加通用开关和安防模块支持。 --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 212 insertions(+), 1 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 5d5b0fc..db59326 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 @@ -12,6 +12,7 @@ import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; @@ -19,6 +20,7 @@ import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; 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; import com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor.SensorStateBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLWarning.WarningType; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; @@ -28,6 +30,8 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuLight; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; @@ -35,6 +39,8 @@ 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.SecurityAlarmFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.Parser.DeviceParser; import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; @@ -177,7 +183,20 @@ case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709鏂板 handleGeothermalCtrlData(getDatas); break; - + /***2020-06-23 鏂板閫氱敤寮�鍏�**/ + case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND: + handleCommonSwitchCtrlData(getDatas); + break; + case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND: + handleCommonSwitchStateData(getDatas); + break; + case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729鏂板 + case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://鎶ヨ璁剧疆鍙嶉 + handleSecurityCtrlData(getDatas); + break; + case Configuration.SECURITY_STATE_BACK_COMMAND: + handleSecurityStateData(getDatas); + break; // 鑾峰彇璁惧澶囨敞 case Configuration.DEVICES_READ_BACK_COMMAND: @@ -2619,7 +2638,199 @@ } } + /** + * 閫氱敤寮�鍏虫帶鍒跺弽棣� + * + * @param getDatas + */ + private static void handleCommonSwitchCtrlData(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.COMMON_SWITCH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) { + + if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + //澶х被銆佸皬绫汇�佸洖璺彿閮藉尮閰� + devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF); + devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF); + AppliancesInfo mSwitchInfo = infos.get(j); + CommonSwitchBackInfo info = new CommonSwitchBackInfo(); + info.setAppliancesInfo(mSwitchInfo); + info.setSwitchNum(getDatas.addBytes[0] & 0xFF); + info.setSwitchState(getDatas.addBytes[1] & 0xFF); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new CommonSwitchCtrlBackEvent(info, true)); + break outter;//璺冲嚭寰幆 + } + } + } + + break outter;//璺冲嚭寰幆 + } + } + } + + + /**************************************2020-06-23鏂板***************************************/ + /** + * 閫氱敤寮�鍏宠鐘舵�佸弽棣堝弽棣� + * + * @param getDatas + */ + private static void handleCommonSwitchStateData(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.COMMON_SWITCH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) { + + if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + //澶х被銆佸皬绫汇�佸洖璺彿閮藉尮閰� + if (getDatas.addBytes.length >= 2) { + isGetDeviceStateSuccess = true; + devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF); + devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF); + AppliancesInfo mSwitchInfo = infos.get(j); + CommonSwitchBackInfo info = new CommonSwitchBackInfo(); + info.setAppliancesInfo(mSwitchInfo); + info.setSwitchNum(getDatas.addBytes[0] & 0xFF); + info.setSwitchState(getDatas.addBytes[1] & 0xFF); + EventBus.getDefault().post(new CommonSwitchStateBackEvent(info, true)); + } + break outter;//璺冲嚭寰幆 + } + } + } + + break outter;//璺冲嚭寰幆 + } + } + } + + + /** + * 璇诲彇瀹夐槻璁剧疆鍙嶉 + * 2020-06-23 + * + * @param getDatas + */ + private static void handleSecurityStateData(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.SECURITY_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-29 + if (getDatas.addBytes.length >= 2) { + isGetDeviceStateSuccess = true; + devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + } else { + isGetDeviceStateSuccess = true; + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false)); + HDLLog.info("handleSecurityStateData 杩斿洖addBytes鏁版嵁寮傚父"); + } + break outter; + } else { + HDLLog.info("handleSecurityStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + } + + /** + * 澶勭悊瀹夐槻璁惧 + * 2020-06-23 + * + * @param getDatas + */ + private static void handleSecurityCtrlData(UdpDataBean getDatas) { + switch (getDatas.command) { + //Arming 甯冮槻璁剧疆鍙嶉 + case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND: + 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 (getDatas.addBytes.length > 0) { + if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 2) { + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); +// isSecurityCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(mInfo, true); + EventBus.getDefault().post(new SecurityArmingFeedBackEvent(mInfo, getDatas.addBytes[1] & 0xFF, true)); + } else { + HDLLog.E("甯冮槻璁剧疆 鍙嶉鏁版嵁寮傚父"); + } + break outter; + } + } + } + break outter; + } + } + + break; + + //ALARM 鎶ヨ璁剧疆鍙嶉 + case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND: + 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 (getDatas.addBytes.length > 0) { + if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 3) { + //byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); + + devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + + SecurityBackInfo info = new SecurityBackInfo(mInfo); +// isSecurityCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new SecurityAlarmFeedBackEvent(info, true)); + } else { + HDLLog.E("鎶ヨ璁剧疆鍙嶉 鍙嶉鏁版嵁寮傚父"); + } + + break outter; + } + } + } + break outter; + } + } + + break; + } + } } -- Gitblit v1.8.0