| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | 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; |
| | | 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.LightFeedBackEvent; |
| | |
| | | case Configuration.CURTAIN_STATE_BACK_COMMAND: |
| | | case Configuration.AIR_STATE_BACK_COMMAND: |
| | | case Configuration.SENSOR_STATE_BACK_COMMAND: |
| | | case Configuration.FRESH_AIR_STATE_BACK_COMMAND://20190709新增 |
| | | handleStateData(getDatas); |
| | | break; |
| | | //获取新风设备状态 20190709新增 |
| | | case Configuration.FRESH_AIR_STATE_BACK_COMMAND: |
| | | handleFreshAirStateData(getDatas); |
| | | break; |
| | | //获取地热设备状态 |
| | | case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND: |
| | |
| | | |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | if(getDatas.addBytes.length >= 8){ |
| | | byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); |
| | | if(getBytes.length < 10){ |
| | | getBytes = new byte[10]; |
| | | if(getDatas.addBytes.length > 0) { |
| | | if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | if (getDatas.addBytes.length >= 8) { |
| | | byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); |
| | | if (getBytes == null || getBytes.length < 10) { |
| | | getBytes = new byte[10]; |
| | | } |
| | | System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 8);//控制地热状态反馈,只取前8位数据 |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | |
| | | GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); |
| | | isGeothermalCtrlSuccess = true; |
| | | EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS)); |
| | | } else { |
| | | |
| | | // AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | // GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); |
| | | // isGeothermalCtrlSuccess = true; |
| | | // EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.DATAEMPTY)); |
| | | |
| | | HDLLog.E("控制地热状态反馈数据异常"); |
| | | } |
| | | System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 8);//控制地热状态反馈,只取前8位数据 |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | |
| | | GeothermalBackInfo info = new GeothermalBackInfo(mInfo , true); |
| | | isGeothermalCtrlSuccess = true; |
| | | EventBus.getDefault().post(new GeothermalFeedBackEvent(info, true)); |
| | | }else{ |
| | | HDLLog.E("控制地热状态反馈数据异常"); |
| | | break outter; |
| | | } |
| | | |
| | | break outter; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState); |
| | | break; |
| | | case Configuration.FRESH_AIR_BIG_TYPE://20190711新增 |
| | | switch (infos.get(appPos).getLittleType()) { |
| | | case Configuration.FRESH_AIR_LITTLE_TYPE_0: |
| | | byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; |
| | | for (int i = 23; i < getDatas.addBytes.length; i++) { |
| | | hvacBytes[i - 23] = getDatas.addBytes[i]; |
| | | } |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setFeedbackState(hvacBytes); |
| | | break; |
| | | } |
| | | break; |
| | | case Configuration.GEOTHERMAL_BIG_TYPE://20190711新增 |
| | | switch (infos.get(appPos).getLittleType()) { |
| | | case Configuration.GEOTHERMAL_LITTLE_TYPE_0: |
| | | byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; |
| | | for (int i = 23; i < getDatas.addBytes.length; i++) { |
| | | hvacBytes[i - 23] = getDatas.addBytes[i]; |
| | | } |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setFeedbackState(hvacBytes); |
| | | break; |
| | | } |
| | | break; |
| | | default: |
| | | HDLLog.info("未找到此类型设备:" + infos.get(appPos).getBigType()); |
| | | break; |
| | |
| | | ) { |
| | | 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()); |
| | | switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) { |
| | | case Configuration.LIGTH_BIG_TYPE: |
| | | isGetDeviceStateSuccess = true; |
| | |
| | | HDLLog.info("发送传感器通知更新"); |
| | | EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite)); |
| | | break; |
| | | case Configuration.FRESH_AIR_BIG_TYPE://20190709新增 |
| | | isGetDeviceStateSuccess = true; |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); |
| | | |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); |
| | | |
| | | break; |
| | | default: |
| | | HDLLog.info("handle state 没有找到匹配类型"); |
| | | break; |
| | | } |
| | | break outter; |
| | | // break outter; |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理新风设备状态数据 |
| | | * 20190710新增 |
| | | * @param getDatas |
| | | */ |
| | | private static void handleFreshAirStateData(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++) { |
| | | switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType()) { |
| | | case HDLApConfig.TYPE_FRESH_AIR: |
| | | isGetDeviceStateSuccess = true; |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); |
| | | |
| | | break; |
| | | default: |
| | | HDLLog.info("handleFreshAirStateData 没有找到匹配类型"); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理地热设备状态数据 |
| | |
| | | |
| | | if(getDatas.addBytes.length >= 10) { |
| | | byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); |
| | | if (getBytes.length < 10) { |
| | | if (getBytes == null || getBytes.length < 10) { |
| | | getBytes = new byte[10]; |
| | | } |
| | | System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710查询地热状态反馈,只取前10位数据 |
| | |
| | | |
| | | break; |
| | | default: |
| | | HDLLog.info("handle state 没有找到匹配类型"); |
| | | HDLLog.info("handleGeothermalStateData 没有找到匹配类型"); |
| | | break; |
| | | } |
| | | break outter; |
| | | |
| | | } |
| | | break outter; |
| | | } |