package com.hdl.sdk.ttl.HDLDeviceManger.Core; import android.content.Context; import android.content.Intent; import android.text.TextUtils; import android.util.Log; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; 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.AirHVACBackInfo; 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.DoorMachineFristBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLDoorMachine.DoorMachineWaringBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirJinMaoBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLGeothermal.GeothermalBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLLight.ColourLightCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicMode; import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.SceneCtrlBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.DryContactSensorBackEvent; import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.SensorStateBackInfo; import com.hdl.sdk.ttl.HDLAppliances.HDLWarning.WarningType; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ListRemarks; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ListSceneRemarks; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUConfigurationBean; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RcuCurtain; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RcuLight; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ScenesData; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.UdpDataBean; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirHVACFeedBackEvent; 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.CommonSwitchStateBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainDeviceStateEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DiscoverNewDevicesEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DoorMachineFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DoorMachineFeedFristBackEvent; 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.SecurityAlarmFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.UpdateRemarkFeedBackEvent; import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.WarningInfoEvent; import com.hdl.sdk.ttl.HDLDeviceManger.Parser.DeviceParser; import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils; import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis; import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog; import com.hdl.sdk.ttl.Utils.SPUtils.SPUtils; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; //import static com.hdl.sdk.ttl.Utils.TransformUtils.HDLStringUtils.byte2String; //import static com.hdl.sdk.ttl.Utils.TransformUtils.HDLStringUtils.byte2String; /** * Created by djl on 2017/3/27. * 设备管理类 * 此类事设备所有信息的管理类,作为一个中控, * 包括搜索,读取,控制等所有操作的管理 */ public class HDLDeviceManager { public static List rcuIpList = new ArrayList<>();//统计Rcu ip地址列表 public static List devicesDataList = new ArrayList<>();//统计设备搜索列表 public static List realDevicesDataList = new ArrayList<>();//统计设备搜索列表 public static int totalDeviceSize = 0; public static List scenesDataList = new ArrayList<>();//统计场景搜索列表 private static Context viewContext; public static List listRemarks = new ArrayList<>(); public static List listSceneRemarks = new ArrayList<>(); public static List rcuLightList = new ArrayList<>(); public static List rcuCurtainList = new ArrayList<>(); public static boolean isLogicCtrl = false; public static ConcurrentHashMap ctrlSuccessStateHashMap = new ConcurrentHashMap<>();//2019-8-2 public static boolean isGetDeviceStateSuccess = false; //判断获取设备状态是否读取成功 public static boolean isUpdateRemarkSuccess = false; //判断修改设备名是否成功 public static boolean isMCUCtrlSuccess = false; //判断是否与MCU通信成功 // public static boolean isGetRcuIpSuccess = false; // public static boolean isLightCtrlSuccess = false; //判断灯光是否控制成功 // public static boolean isCurtainCtrlSuccess = false; //判断窗帘是否控制成功 // public static boolean isACCtrlSuccess = false; //判断空调是否控制成功 // public static boolean isSecurityCtrlSuccess = false; //判断安防模块是否通信成功 public static boolean isGetBusLightState = false; public static boolean isGetSceneRemarkSuccess = false; //判断获取场景详情成功 public static boolean isSceneCtrlSuccess = false; //判断场景是否控制成功 /** * 初始化 SDK HDLDeviceManager初始化 * * @param context 上下文 */ public static void init(Context context) { viewContext = context.getApplicationContext(); Crc.localSubnetID = (int) SPUtils.getParam(viewContext, SPUtils.KEY_SUB_ID, SPUtils.DEFAULT_SUB_ID); Crc.localDeviceID = (int) SPUtils.getParam(viewContext, SPUtils.KEY_DEVICE_ID, SPUtils.DEFAULT_DEVICE_ID); /*** 子网号设备号 Error correction*/ if (!HDLCommand.getIfValueInScope(Crc.localSubnetID)) { Crc.localSubnetID = SPUtils.DEFAULT_SUB_ID; SPUtils.setParam(viewContext, SPUtils.KEY_SUB_ID, SPUtils.DEFAULT_SUB_ID); } if (!HDLCommand.getIfValueInScope(Crc.localDeviceID)) { Crc.localSubnetID = SPUtils.DEFAULT_DEVICE_ID; SPUtils.setParam(viewContext, SPUtils.KEY_DEVICE_ID, SPUtils.DEFAULT_DEVICE_ID); } } public static boolean getIsGetBusLightState() { return isGetBusLightState; } public static void setIsGetBusLightState(boolean isGetBusLightState) { HDLDeviceManager.isGetBusLightState = isGetBusLightState; } /** * 释放关闭串口 */ public static void release() { HDLSerialPortCore.closeSerialPort(); } /** * 处理CommandData并返回搜索或控制的有用信息 * * @param getDatas * @param commandType 命令类型 */ public static void handle(UdpDataBean getDatas, int commandType) { Log.e("panlili", "commandType=" + Integer.toHexString(commandType) + " sourceSubnetID=" + getDatas.sourceSubnetID + " sourceDeviceID=" + getDatas.sourceDeviceID); switch (commandType) { case Configuration.SEARCH_GATEWAY_BACK_COMMAND: break; case Configuration.DEVICES_SEARCH_FROM_GATEWAY_BACK_COMMAND://读取网关已配置功能 handleSearchData(getDatas); break; case Configuration.DEVICES_READ_FROM_GATEWAY_BACK_COMMAND://依次读取设备信息 if (isLogicCtrl) { isLogicCtrl = false; handleLogicAir(getDatas); } else { handleRemarkCurStateData(getDatas); } break; case Configuration.SCENE_SEARCH_FROM_GATEWAY_BACK_COMMAND: handleSearchSceneData(getDatas); break; case Configuration.SCENE_READ_FROM_GATEWAY_BACK_COMMAND: handleSceneCurStateData(getDatas); break; /***2020-07-20 新增新风设备**/ case Configuration.FRESH_AIR_STATE_BACK_COMMAND: handleFreshAirStateData(getDatas); break; case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: handleFreshAirCtrlBackData(getDatas); break; /***2020-07-20 金茂新风设备**/ case Configuration.FRESH_AIR_JINMAO_STATE_BACK_COMMAND: handleFreshAirJINMAOStateData(getDatas); break; case Configuration.FRESH_AIR_JINMAO_CTRL_BACK_COMMAND: handleFreshAirJINMAOCtrlBackData(getDatas); break; /***2020-07-20 地热模块**/ case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND: handleGeothermalStateData(getDatas); break; case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND: handleGeothermalCtrlData(getDatas); break; /***2023-08-22 门锁模块**/ case Configuration.DOOR_MACHINE_MODULE_STATE_BACK_COMMAND: handleDoorMachineStateData(getDatas); break; case Configuration.DOOR_MACHINE_MODULE_CTRL_FRIST_BACK_COMMAND: handleDoorMachineCtrlFristBackData(getDatas); break; case Configuration.DOOR_MACHINE_MODULE_CTRL_BACK_COMMAND: handleDoorMachineCtrlBackData(getDatas); break; case Configuration.DOOR_MACHINE_BROADCAST_STATE_BACK_COMMAND: handleDoorMachineBroadcastStateData(getDatas); break; /***2020-04-01 新增通用开关**/ case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND: handleCommonSwitchCtrlData(getDatas); break; case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND: handleCommonSwitchStateData(getDatas); break; // 控制设备 case Configuration.LIGHT_CTRL_BACK_COMMAND: case Configuration.CURTAIN_CTRL_BACK_COMMAND: case Configuration.AIR_CTRL_BACK_COMMAND: handleCtrlData(getDatas); break; case Configuration.LOGIC_CTRL_BACK_COMMAND: handleLogicCtrlData(getDatas);//逻辑模块控制 handleSceneCtrlData(getDatas);//场景控制 break; case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: handleColourLightStateData(getDatas); break; case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: handleHVACCtrlData(getDatas); handleTechSysCtrlData(getDatas);//2023-08-21 break; case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729新增 case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://报警设置反馈 handleSecurityCtrlData(getDatas); break; // 获取设备状态 case Configuration.AIR_STATE_BACK_COMMAND: handleAirStateData(getDatas); break; case Configuration.SENSOR_STATE_BACK_COMMAND: case Configuration.SENSOR_BROADCAST_STATE_BACK_COMMAND: handleSensorBroadcastStateData(getDatas); handleKNXTechSysStateData(getDatas); break; case Configuration.DRY_CONTACT_STATE_BACK_COMMAND: case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND: handleDryContactBroadcastStateData(getDatas); break; case Configuration.LIGHT_STATE_BACK_COMMAND: handleLightStateData(getDatas); break; case Configuration.LIGHT_RGB_STATE_BACK_COMMAND: handleColourLightStateData(getDatas);//2023-08-22 break; case Configuration.CURTAIN_STATE_BACK_COMMAND: handleCurtainStateData(getDatas); break; case Configuration.CURTAIN_STATE_BROADCAST_BACK_COMMAND: handleCurtainBroadcastStateData(getDatas); break; case Configuration.SECURITY_STATE_BACK_COMMAND: handleSecurityStateData(getDatas); break; case Configuration.AIR_HVAC_STATE_BACK_COMMAND: // handleRcuAirCastData(getDatas); handleHVACStateData(getDatas);//2019-06-27 handleTechSysStateData(getDatas);//2023-08-21 break; case Configuration.LOGIC_STATE_BACK_COMMAND: // handleRcuAirCastData(getDatas); handleLOGICStateData(getDatas);//2019-06-27 break; // case Configuration.RCU_ROOM_CAST_COMMAND: // handleRcuLightCastData(getDatas); // break; // case Configuration.RCU_CURTAIN_CAST_COMMAND: // handleRcuCurtainCastData(getDatas); // break; case Configuration.WARNING_COMMAND: handleWarningData(getDatas); break; case Configuration.AUDIO_CTRL_READ_BACK_COMMAND: case Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND: handleAudioData(getDatas); break; // case Configuration.RCU_SEARCH_COMMAND: // handleRcuSearchData(getDatas); // break; // case Configuration.RCU_READ_SDK_INFO_COMMAND: // handleRcuReadInfo(getDatas); // break; case Configuration.MANUAL_ADD_DEVICE_COMMAND: boolean isExit = false; for (DevicesData value : realDevicesDataList) { if (value.getSourceSubnetID() == getDatas.sourceSubnetID && value.getSourceDeviceID() == getDatas.sourceDeviceID && value.getDeviceSubnetID() == (getDatas.addBytes[6] & 0xFF) && value.getDeviceDeviceID() == (getDatas.addBytes[7] & 0xFF)) { isExit = true; break; } } if (!isExit) { handleSearchData(getDatas); HandleSearch.OnDeviceListGetSuccessCallBack();//手动添加设备成功立刻返回 HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND, Crc.localSubnetID, Crc.localDeviceID, new byte[]{1}); } else { //添加失败,已经存在了相同的子网id、设备id HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND, Crc.localSubnetID, Crc.localDeviceID, new byte[]{0}); } break; case Configuration.MANUAL_ADD_REMARK_COMMAND: handleRemarkCurStateData(getDatas); HandleSearch.OnDeviceListGetSuccessCallBack();//手动添加备注成功立刻返回 HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_REMARK_BACK_COMMAND, Crc.localSubnetID, Crc.localDeviceID, new byte[]{1}); break; case Configuration.DEVICES_MODIFY_BACK_COMMAND: HDLLog.I("GET DEVICES_MODIFY_BACK_COMMAND"); break; case Configuration.MODULE_UPDATE_REMARK_BACK_COMMAND: // HDLLog.I("GET MODULE_UPDATE_REMARK_BACK_COMMAND"); handleModuleUpdateRemarkData(getDatas);//修改模块备注 break; // 控制和尔泰设备 // case Configuration.HET_DEVICES: // Log.d("djlHet", "Configuration.HET_DEVICES send"); // EventBus.getDefault().post(new HetDevicesCtrlEvent(getDatas.addBytes)); // break; // 控制美的设备 // case Configuration.Midea_DEVICES: // Log.d("djlMidea", "Configuration.Midea_DEVICES send"); // EventBus.getDefault().post(new MideaDevicesCtrlEvent(getDatas.addBytes)); // break; // 控制Jav设备 // case Configuration.JAV_DEVICES: // Log.d("djlJav", "Configuration.Jav_DEVICES send"); // Intent javIntent = new Intent(); // javIntent.setAction("com.hdl.jav.hdljavlib.action"); // javIntent.putExtra("HdlJav", getDatas.addBytes); // viewContext.sendBroadcast(javIntent); // break; // case Configuration.GET_LOGIC_INFO: // 处理逻辑模块信息 // handleLogicData(getDatas); // break; default: break; } } /** * 处理搜索设备数据 * 发现新设备处理 * * @param getDatas */ private static synchronized void handleSearchData(UdpDataBean getDatas) { DevicesData devicesData = new DevicesData(); devicesData.setSourceSubnetID(getDatas.sourceSubnetID); devicesData.setSourceDeviceID(getDatas.sourceDeviceID); devicesData.setAddByte(getDatas.addBytes); int size = (getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF); int index = (getDatas.addBytes[4] & 0xFF) * 256 + (getDatas.addBytes[5] & 0xFF); devicesData.setDeviceSize(size); totalDeviceSize = size; devicesData.setDeviceIndex(index); byte[] remarkByte = new byte[getDatas.addBytes.length]; String remarkStr = HDLStringUtils.byte2String(remarkByte); devicesData.setRemark(remarkStr); boolean isExitData = DeviceParser.parse(getDatas.addBytes, devicesData, remarkStr); boolean isExist = false; for (DevicesData value : realDevicesDataList) { if (value.getSourceSubnetID() == getDatas.sourceSubnetID && value.getSourceDeviceID() == getDatas.sourceDeviceID && value.getDeviceSubnetID() == (getDatas.addBytes[6] & 0xFF) && value.getDeviceDeviceID() == (getDatas.addBytes[7] & 0xFF)) { HDLLog.I("Device is isExist " + value.getRemark()); isExist = true; break; } } if (!isExist) { realDevicesDataList.add(devicesData);//记录所有的接收到设备,包括SDK不支持的设备种类。作用:作为发送第二次搜索命令时用到 HDLLog.I("---totalDeviceSize=" + totalDeviceSize + " realDevicesDataList=" + realDevicesDataList.size()); } /********************辅助调试打印*******************/ String addData = ""; for (int i = 0, len = getDatas.addBytes.length; i < len; i++) { addData += " arr" + i + " = " + (getDatas.addBytes[i] & 0xFF) + ","; } HDLLog.I("所有设备列表 第 " + realDevicesDataList.size() + " 个模块 " + " \n源子网号 = " + (getDatas.sourceSubnetID) + " \n源设备号 = " + (getDatas.sourceDeviceID) + " \n模块备注 = " + devicesData.getRemark() + " \n附加数据 = " + addData + " \nisExitData = " + (isExitData ? "符合" : "不符合") ); /********************辅助调试打印*******************/ // 判断是否符合要求的大类小类 if (!isExist && isExitData) { devicesDataList.add(devicesData);//记录所有的接收到设备,不包括SDK不支持的设备种类 /**2019-07-03 发现新设备,这里可以发送通知事件,并传递新的设备数据*/ EventBus.getDefault().post(new DiscoverNewDevicesEvent(devicesData)); //过滤掉背景音乐,背景音乐没有备注返回 if (devicesData.getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) { for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) { ListRemarks listRemarksTemp = new ListRemarks(); listRemarksTemp.setCallBack(false); AppliancesInfo appliancesInfo = devicesData.getAppliancesInfoList().get(i); Log.d("panlili", "HDLDeviceManager.java:handleSearchData----->getChannelNum= " + appliancesInfo.getChannelNum() + " getDeviceKey=" + appliancesInfo.getDeviceKey()); listRemarksTemp.setAppliancesInfo(appliancesInfo); listRemarks.add(listRemarksTemp); } } /********************辅助调试打印*******************/ String deviceName = ""; for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) { deviceName += " " + devicesData.getAppliancesInfoList().get(i).getDeviceName() + " "; } HDLLog.I("\n --------> HDL SDK支持的设备列表 第 " + devicesDataList.size() + " 个模块 " + " \n源子网号 = " + (getDatas.sourceSubnetID) + " \n源设备号 = " + (getDatas.sourceDeviceID) + " \n目标子网号 = " + (getDatas.desSubnetID) + " \n目标设备号 = " + (getDatas.desDeviceID) + " \n源模块各回路类型 = " + deviceName + " \n模块备注 = " + devicesData.getRemark() ); /********************辅助调试打印*******************/ } } /** * 处理搜索场景数据 * * @param getDatas */ private static void handleSearchSceneData(UdpDataBean getDatas) { int size = getDatas.addBytes[0] * 256 + getDatas.addBytes[1]; /********************辅助调试打印*******************/ for (int i = 0, len = size; i < len; i++) { ScenesData scenesData = new ScenesData(); scenesData.setSourceSubnetID(getDatas.sourceSubnetID); scenesData.setSourceDeviceID(getDatas.sourceDeviceID); scenesData.setAddByte(getDatas.addBytes); scenesData.setIndex(i + 1); scenesDataList.add(scenesData); HDLLog.I("所有场景列表 第 " + scenesDataList.size() + " 个模块 " + " \n源子网号 = " + (getDatas.sourceSubnetID) + " \n源设备号 = " + (getDatas.sourceDeviceID) + " \n场景索引 = " + scenesData.getIndex() ); } /********************辅助调试打印*******************/ } /** * 处理灯光返回 * 2020-1-18 * 修复混合调光混合开关 类模块问题 * * @param getDatas */ private static void handleLightCtrlData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF); AppliancesInfo lightInfo1 = infos.get(j); lightInfo1.setCurState(getDatas.addBytes[2] & 0xFF); LightCtrlBackInfo info1 = new LightCtrlBackInfo(); info1.setParentRemarks(lightInfo1.getParentRemarks()); info1.setAppliancesInfo(lightInfo1); info1.setRemarks(lightInfo1.getRemarks()); info1.setChannelNum(lightInfo1.getChannelNum()); info1.setPhysicsChannelNum(lightInfo1.getPhysicsChannelNum()); info1.setBrightness(getDatas.addBytes[2] & 0xFF); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LightFeedBackEvent(info1, true)); break outter; } } else { if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { AppliancesInfo lightInfo = infos.get(j); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF); LightCtrlBackInfo info = new LightCtrlBackInfo(); info.setParentRemarks(lightInfo.getParentRemarks()); info.setAppliancesInfo(lightInfo); info.setRemarks(lightInfo.getRemarks()); info.setChannelNum(getDatas.addBytes[0] & 0xFF); // info.setIsSuccess(getDatas.AddBytes[1] & 0xFF); info.setBrightness(getDatas.addBytes[2] & 0xFF); // info.setChannelCount(getDatas.AddBytes[3] & 0xFF); // info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF); // isLightCtrlSuccess = true; setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LightFeedBackEvent(info, true)); break outter; } } } } } } /** * 处理CCT OR RGB灯光返回 * 2023-8-22 * * @param getDatas */ private static void handleColourLightCtrlData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { AppliancesInfo lightInfo = infos.get(j); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF); LightCtrlBackInfo info = new LightCtrlBackInfo(); info.setParentRemarks(lightInfo.getParentRemarks()); info.setAppliancesInfo(lightInfo); info.setRemarks(lightInfo.getRemarks()); info.setChannelNum(getDatas.addBytes[0] & 0xFF); info.setBrightness(getDatas.addBytes[1] & 0xFF); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LightFeedBackEvent(info, true)); break outter; } } } } } /** * 处理设备控制数据 * * @param getDatas */ private static void handleCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { case Configuration.LIGHT_CTRL_BACK_COMMAND: handleLightCtrlData(getDatas); if (!HDLDeviceManager.isGetBusLightState) { isGetDeviceStateSuccess = true; } break; case Configuration.CURTAIN_CTRL_BACK_COMMAND: outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); inner: for (int j = 0, len2 = infos.size(); j < len2; j++) { AppliancesInfo curtainInfo; if ((getDatas.addBytes[0] & 0xFF) >= 17) { if (((getDatas.addBytes[0] & 0xFF) - 16) == infos.get(j).getChannelNum()) { curtainInfo = infos.get(j); } else { continue inner; } } else { if ((getDatas.addBytes[0] & 0xFF) == infos.get(j).getChannelNum()) { curtainInfo = infos.get(j); } else { continue inner; } } CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo(); curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks()); curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks()); curtainCtrlBackInfo.setAppliancesInfo(curtainInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO || curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER || curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_SHANGRILA) { if ((getDatas.addBytes[0] & 0xFF) >= 17) { int curState = getDatas.addBytes[1] & 0xFF;//V1.0百分比 if (curState == 1) { //这个判断很傻,窗帘关到百分比为0,会跳到1返回回来,只能强制改为0 curState = 0; } if (curState == 99) { curState = 100; } curtainCtrlBackInfo.setState(curState); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(curState); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); curtainCtrlBackInfo.setNum((getDatas.addBytes[0] & 0xFF) - 16); EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true)); } else { if (getDatas.addBytes.length >= 3) { curtainCtrlBackInfo = new CurtainCtrlBackInfo(devicesDataList.get(i).getAppliancesInfoList().get(j)); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); curtainCtrlBackInfo.setNum(getDatas.addBytes[0] & 0xFF); EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true)); } } } else if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { if ((getDatas.addBytes[0] & 0xFF) < 17) { int state = getDatas.addBytes[1] & 0xFF; switch (state) {//这里也应该改成0,1,2 case 0: state = CurtainCtrlParser.curtainPause; break; case 1: state = CurtainCtrlParser.curtainOn; break; case 2: state = CurtainCtrlParser.curtainOff; break; default: state = 0; break; } curtainCtrlBackInfo.setState(state); curtainCtrlBackInfo.setNum(getDatas.addBytes[0] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(state); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true)); } } break outter; } } } break; case Configuration.AIR_CTRL_BACK_COMMAND: outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_PANEL) { // airInfo = infos.get(j);//一般只有一个面板 // 如果有多个空调面板,这将会出错 AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(infos.get(j)); // isACCtrlSuccess = true; setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); if ((getDatas.addBytes[0] & 0xFF) == AirCtrlParser.airMode) { airCtrlBackInfo.setCurState(new byte[]{getDatas.addBytes[0], getDatas.addBytes[1]}); byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); switch (getDatas.addBytes[0] & 0xff) { case 3: //开关 airCurState[0] = getDatas.addBytes[1]; break; case 4: //制冷温度 airCurState[2] = getDatas.addBytes[1]; break; case 5: //风速 airCurState[3] = getDatas.addBytes[1]; break; case 6: //模式 airCurState[1] = getDatas.addBytes[1]; break; case 7: //制热温度 airCurState[2] = getDatas.addBytes[1]; break; case 8: //自动温度 airCurState[2] = getDatas.addBytes[1]; break; case 9: //上升温度 airCurState[2] = (byte) ((airCurState[2] & 0xff) + (getDatas.addBytes[1] & 0xff)); break; case 10: //下降温度 airCurState[2] = (byte) ((airCurState[2] & 0xff) - (getDatas.addBytes[1] & 0xff)); break; default: break; } devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airCurState); } else { airCtrlBackInfo.setCurState(getDatas.addBytes); byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); switch (getDatas.addBytes[0] & 0xff) { case 3: //开关 airCurState[0] = getDatas.addBytes[1]; break; case 4: //制冷温度 airCurState[2] = getDatas.addBytes[1]; break; case 5: //风速 airCurState[3] = getDatas.addBytes[1]; break; case 6: //模式 airCurState[1] = getDatas.addBytes[1]; break; case 7: //制热温度 airCurState[2] = getDatas.addBytes[1]; break; case 8: //自动温度 airCurState[2] = getDatas.addBytes[1]; break; case 9: //上升温度 airCurState[2] = (byte) ((airCurState[2] & 0xff) + (getDatas.addBytes[1] & 0xff)); break; case 10: //下降温度 airCurState[2] = (byte) ((airCurState[2] & 0xff) - (getDatas.addBytes[1] & 0xff)); break; default: break; } devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airCurState); } //上升温度、下降温度不返回。 if ((airCtrlBackInfo.getCurState()[0] & 0xff) != 9 && (airCtrlBackInfo.getCurState()[0] & 0xff) != 10) { EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } break outter; } } } } break; } } /** * 处理逻辑 控制回调 * 2024-1-19 * * @param getDatas */ private static void handleLogicCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { case Configuration.LOGIC_CTRL_BACK_COMMAND: outter: if (devicesDataList != null && devicesDataList.size() != 0) { for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if ((infos.get(j).getBigType() == Configuration.LOGIC_BIG_TYPE || infos.get(j).getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE) && infos.get(j).getLogicMode().getAreaNum() == (getDatas.addBytes[0] & 0xFF) && infos.get(j).getLogicMode().getAreaSceneNum() == (getDatas.addBytes[1] & 0xFF)) { AppliancesInfo sceneInfo = infos.get(j); LogicMode logicMode = new LogicMode(); logicMode.setAreaNum(getDatas.addBytes[0] & 0xFF); logicMode.setAreaSceneNum(getDatas.addBytes[1] & 0xFF); sceneInfo.setLogicMode(logicMode); LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); logicCtrlBackInfo.setAppliancesInfo(sceneInfo); logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF); logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF); // isSceneCtrlSuccess = true; setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true)); break outter; } } } } } break; } } /** * 处理场景 控制回调 * 2024-1-19 * * @param getDatas */ private static void handleSceneCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { case Configuration.LOGIC_CTRL_BACK_COMMAND: outter: if (scenesDataList != null && scenesDataList.size() != 0) { for (int i = 0, len = scenesDataList.size(); i < len; i++) { if (scenesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID && scenesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID && scenesDataList.get(i).getAreaCodeID() == (getDatas.addBytes[0] & 0xFF) && scenesDataList.get(i).getSceneID() == (getDatas.addBytes[1] & 0xFF)) { SceneCtrlBackInfo sceneCtrlBackInfo = new SceneCtrlBackInfo(); sceneCtrlBackInfo.setAreaCodeID(getDatas.addBytes[0] & 0xFF); sceneCtrlBackInfo.setSceneID(getDatas.addBytes[1] & 0xFF); sceneCtrlBackInfo.setLoopNum(getDatas.addBytes[2] & 0xFF); setSceneCtrlSuccess(true); EventBus.getDefault().post(new SceneFeedBackEvent(sceneCtrlBackInfo, true)); break outter; } } } break; } } /** * 处理安防设备 * 20190729 * * @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).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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; } } /** * 处理HVAC 控制回调 * 2019-8-6 * * @param getDatas */ private static void handleHVACCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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.AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); AirHVACBackInfo info = new AirHVACBackInfo(mHvacAirInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new AirHVACFeedBackEvent(info, true)); break outter; } break outter; } } } } break; } } /** * 处理科技系统 控制回调 * 2023-8-21 * * @param getDatas */ private static void handleTechSysCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID) { List 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.AIR_BIG_TYPE && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_TECHSYS || infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_KNXTECHSYS) && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo mTechSysAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); AirTechSysBackInfo info = new AirTechSysBackInfo(mTechSysAirInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new AirTechSysFeedBackEvent(info, true)); break outter; } } } break outter; } } break; } } // private static void getAirInfo(final AppliancesInfo hvacInfo) { // // isLogicCtrl = true; // timerAir = new Timer(); // timerAir.schedule(new TimerTask() { // @Override // public void run() { // if (isLogicCtrl) { // HDLCommand.HDLgetAirInfo(hvacInfo); // } else { // timerAir.cancel(); // } // // } // }, 100, 500); // } /** * 处理逻辑空调数据 * * @param getDatas */ private static void handleLogicAir(UdpDataBean getDatas) { AppliancesInfo newInfo1 = null; for (int devPos = 0, len = devicesDataList.size(); devPos < len; devPos++) { if (devicesDataList.get(devPos).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(devPos).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(devPos).getAppliancesInfoList(); for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) { switch (infos.get(appPos).getBigType()) { case Configuration.AIR_BIG_TYPE: switch (infos.get(appPos).getLittleType()) { case 0: byte[] airInfo = new byte[6]; System.arraycopy(getDatas.addBytes, 23, airInfo, 0, airInfo.length); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(airInfo); newInfo1 = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos); break; } break; } } } } // getAppInfo(newInfo); final AppliancesInfo newInfo = newInfo1; final byte[] airCurInfo; if (newInfo == null) { return; } airCurInfo = newInfo.getArrCurState(); new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airSwich, airCurInfo[0]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 1000); new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airMode, airCurInfo[1]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 2000); switch (airCurInfo[1] & 0xFF) { case 0: new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.refTem, airCurInfo[2]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 3000); new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 4000); break; case 1: new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.heatTem, airCurInfo[2]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 3000); new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 4000); break; case 2: // 通风模式无温度 new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 3000); break; case 3: new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.autoTem, airCurInfo[2]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 3000); new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 4000); break; case 4: //抽湿模式无风速 new Timer().schedule(new TimerTask() { @Override public void run() { newInfo.setArrCurState(new byte[]{AirCtrlParser.dehumTem, airCurInfo[2]}); EventBus.getDefault().post(new DeviceStateEvent(newInfo, true)); } }, 3000); break; } } /** * 处理所有备注数据、设置当前设备状态 * * @param getDatas */ private static void handleRemarkCurStateData(UdpDataBean getDatas) { outter: for (int devPos = 0, len = devicesDataList.size(); devPos < len; devPos++) { if (devicesDataList.get(devPos).getSourceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(devPos).getSourceDeviceID() == getDatas.sourceDeviceID) { List infos = devicesDataList.get(devPos).getAppliancesInfoList(); for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) { if ((infos.get(appPos).getDeviceSubnetID()) == (getDatas.addBytes[0] & 0xFF) && (infos.get(appPos).getDeviceDeviceID()) == (getDatas.addBytes[1] & 0xFF) && ((infos.get(appPos).getDeviceIndex()) == (getDatas.addBytes[2] & 0xFF))//序号 && (infos.get(appPos).getBigType()) == (getDatas.addBytes[3] & 0xFF) && ((infos.get(appPos).getLittleType()) == (getDatas.addBytes[4] & 0xFF))) { //2023-11-30 byte[] remarkByte; if (getDatas.addBytes.length >= 26) { remarkByte = new byte[20]; System.arraycopy(getDatas.addBytes, 6, remarkByte, 0, remarkByte.length); } else { remarkByte = new byte[getDatas.addBytes.length - 3]; System.arraycopy(getDatas.addBytes, 6, remarkByte, 0, getDatas.addBytes.length - 3); } String remarkStr = HDLStringUtils.byte2String(remarkByte); HDLLog.I("remarkStr获取的备注名为:" + remarkStr); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setChannelNum(getDatas.addBytes[5] & 0xFF); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setRemarks(remarkStr); // HDLLog.I("getRemarks():" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getRemarks()); String key = "K" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getBigType() + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getLittleType() + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getDeviceSubnetID() + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getDeviceDeviceID() + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum(); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setDeviceKey(key); listRemarksOutter: for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) { //找到F44B对应的设备回路,判断是否已经拿到了数据。 if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == (getDatas.addBytes[0] & 0xFF) && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == (getDatas.addBytes[1] & 0xFF) && listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() == (getDatas.addBytes[2] & 0xFF) && listRemarks.get(lRPos).getAppliancesInfo().getBigType() == (getDatas.addBytes[3] & 0xFF) && listRemarks.get(lRPos).getAppliancesInfo().getLittleType() == (getDatas.addBytes[4] & 0xFF)) { //若没拿到数据,则拿数据;若已经拿到数据,需要判断listRemarks全部条目是否拿到备注。 if (listRemarks.get(lRPos).isCallBack()) { for (int lR2Pos = 0, len4 = listRemarks.size(); lR2Pos < len4; lR2Pos++) { if (listRemarks.get(lR2Pos).isCallBack()) { if (lR2Pos == (len4 - 1)) { HDLLog.I("收到备注命令,已存在此设备备注,过滤"); break listRemarksOutter; } } else { HDLLog.I("不存在的设备备注,再次搜索备注。设备:子网号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() + "设备号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() + "序列号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() + "备注:" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks()); HandleSearch.getDevRemarks(); break listRemarksOutter; } } } else { HDLLog.I("返回备注设备:子网号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() + ",设备号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() + ",序列号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() + ",备注:" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks()); listRemarks.get(lRPos).setCallBack(true); HandleSearch.getDevRemarks(); break listRemarksOutter; } } } break outter; } } } } } /** * 处理所有场景详情数据、设置当前场景状态 * * @param getDatas */ private static void handleSceneCurStateData(UdpDataBean getDatas) { outter: for (int devPos = 0, len = scenesDataList.size(); devPos < len; devPos++) { if (scenesDataList.get(devPos).getSourceSubnetID() == getDatas.sourceSubnetID && scenesDataList.get(devPos).getSourceDeviceID() == getDatas.sourceDeviceID && scenesDataList.get(devPos).getIndex() == (getDatas.addBytes[0] * 256 + getDatas.addBytes[1])) { //2024-01-18 byte[] remarkByte; String remarkStr = ""; if (getDatas.addBytes.length >= 36) { remarkByte = new byte[32]; System.arraycopy(getDatas.addBytes, 4, remarkByte, 0, remarkByte.length); remarkStr = HDLStringUtils.byte2String(remarkByte); } HDLLog.I("remarkStr获取的场景备注名为:" + remarkStr); scenesDataList.get(devPos).setAreaCodeID(getDatas.addBytes[2] & 0xFF); scenesDataList.get(devPos).setSceneID(getDatas.addBytes[3] & 0xFF); scenesDataList.get(devPos).setRemark(remarkStr); listRemarksOutter: for (int lRPos = 0, len3 = scenesDataList.size(); lRPos < len3; lRPos++) { //找到F44B对应的设备回路,判断是否已经拿到了数据。 if (scenesDataList.get(lRPos).getAreaCodeID() == (getDatas.addBytes[2] & 0xFF) && scenesDataList.get(lRPos).getSceneID() == (getDatas.addBytes[3] & 0xFF)) { //若没拿到数据,则拿数据;若已经拿到数据,需要判断listRemarks全部条目是否拿到备注。 if (scenesDataList.get(lRPos).isCallBack()) { for (int lR2Pos = 0, len4 = scenesDataList.size(); lR2Pos < len4; lR2Pos++) { if (scenesDataList.get(lR2Pos).isCallBack()) { if (lR2Pos == (len4 - 1)) { HDLLog.I("收到备注命令,已存在此场景备注,过滤"); break listRemarksOutter; } } else { HDLLog.I("不存在的场景备注,再次搜索备注。区号:" + scenesDataList.get(lRPos).getAreaCodeID() + ",场景号:" + scenesDataList.get(lRPos).getSceneID()); HandleSearch.getSceneDetails(); break listRemarksOutter; } } } else { HDLLog.I("返回备注场景:区号:" + scenesDataList.get(lRPos).getAreaCodeID() + ",场景号:" + scenesDataList.get(lRPos).getSceneID()); scenesDataList.get(lRPos).setCallBack(true); HandleSearch.getSceneDetails(); break listRemarksOutter; } } } break outter; } } } /** * 处理修改设备备注后的回调 * * @param getDatas */ private static void handleModuleUpdateRemarkData(UdpDataBean getDatas) { if (getDatas.desSubnetID == Crc.localSubnetID && getDatas.desDeviceID == Crc.localDeviceID) { isUpdateRemarkSuccess = true; EventBus.getDefault().post(new UpdateRemarkFeedBackEvent(true)); } } /** * 处理设备状态数据 * * @param getDatas */ private static void handleStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) { case Configuration.SENSOR_BIG_TYPE://2019-07-03 屏蔽 isGetDeviceStateSuccess = true; AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); float value = HDLUtlis.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8)); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value); sensorInfo.setCurState(value); String unite = ""; switch (sensorInfo.getDeviceType()) { case HDLApConfig.TYPE_SENSOR_DRY_CONTACT: unite = ""; break; case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: unite = ""; break; case HDLApConfig.TYPE_SENSOR_TEMP: if ((getDatas.addBytes[4] & 0xff) == 0) { unite = "°C"; } else { unite = "°F"; } break; case HDLApConfig.TYPE_SENSOR_HUMIDITY: unite = "%"; break; case HDLApConfig.TYPE_SENSOR_ILLUMINACE: unite = "LUX"; break; case HDLApConfig.TYPE_SENSOR_VOC: unite = ""; break; case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: case HDLApConfig.TYPE_SENSOR_PM_10: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "mg/m3"; break; case 1: unite = "ppm"; break; case 2: unite = "μm"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_C02: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "mg/m3"; break; case 1: unite = "ppm"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_LPG: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_CO_H2: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_CH4: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_SMOG: unite = ""; break; case HDLApConfig.TYPE_SENSOR_WIND_SPEED: unite = "m/s"; break; case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE: unite = "Pa"; break; case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW: unite = ""; break; case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE: unite = "Pa"; break; case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_RAIN_FALL: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "无雨"; break; case 1: unite = "小雨"; break; case 2: unite = "大雨"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_WEIGHT: unite = "KG"; break; case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED: unite = "m/s"; break; case HDLApConfig.TYPE_SENSOR_SHAKE: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_VOLTAGE: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "V"; break; case 1: unite = "μV"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_ELECTRICITY: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "A"; break; case 1: unite = "μA"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_POWER: unite = "W"; break; case HDLApConfig.TYPE_SENSOR_FLOODING://水浸 unite = ""; break; case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET://门磁 unite = ""; break; case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON://紧急按钮 unite = ""; break; default: unite = "未知单位"; break; } // EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true)); HDLLog.I("发送传感器通知更新"); EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite)); break; default: HDLLog.I("handle state 没有找到匹配类型"); break; } } break outter; } } } /** * 处理传感器 状态读取、广播数据 * 2024-2-2 新支持 * * @param getDatas */ private static void handleSensorBroadcastStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.SENSOR_BIG_TYPE && infos.get(j).getLittleType() == (getDatas.addBytes[1] & 0xFF) && infos.get(j).getChannelNum() == (getDatas.addBytes[2] & 0xFF)) {//2019-07-29 isGetDeviceStateSuccess = true; AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); float value = 0; if ((getDatas.addBytes[3] & 0xFF) == 1 || (getDatas.addBytes[3] & 0xFF) == 2) {//整型 value = HDLUtlis.getInt(Arrays.copyOfRange(getDatas.addBytes, 5, 9)); } else if ((getDatas.addBytes[3] & 0xFF) == 3) {//浮点型 value = HDLUtlis.byteToFloat(getDatas.addBytes[5], getDatas.addBytes[6], getDatas.addBytes[7], getDatas.addBytes[8]); } Log.d("panlili", "HDLDeviceManager.java:handleSensorBroadcastStateData----->value= " + value); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value); sensorInfo.setCurState(value); String unite = ""; switch (sensorInfo.getDeviceType()) { case HDLApConfig.TYPE_SENSOR_DRY_CONTACT: unite = ""; break; case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: unite = ""; break; case HDLApConfig.TYPE_SENSOR_TEMP: if ((getDatas.addBytes[4] & 0xff) == 0) { unite = "°C"; } else { unite = "°F"; } break; case HDLApConfig.TYPE_SENSOR_HUMIDITY: unite = "%"; break; case HDLApConfig.TYPE_SENSOR_ILLUMINACE: unite = "LUX"; break; case HDLApConfig.TYPE_SENSOR_VOC: unite = ""; break; case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: case HDLApConfig.TYPE_SENSOR_PM_10: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "mg/m3"; break; case 1: unite = "ppm"; break; case 2: unite = "μm"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_C02: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "mg/m3"; break; case 1: unite = "ppm"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_LPG: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_CO_H2: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_CH4: unite = "ppm"; break; case HDLApConfig.TYPE_SENSOR_SMOG: unite = ""; break; case HDLApConfig.TYPE_SENSOR_WIND_SPEED: unite = "m/s"; break; case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE: unite = "Pa"; break; case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW: unite = ""; break; case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE: unite = "Pa"; break; case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_RAIN_FALL: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "无雨"; break; case 1: unite = "小雨"; break; case 2: unite = "大雨"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_WEIGHT: unite = "KG"; break; case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED: unite = "m/s"; break; case HDLApConfig.TYPE_SENSOR_SHAKE: unite = "mm"; break; case HDLApConfig.TYPE_SENSOR_VOLTAGE: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "V"; break; case 1: unite = "μV"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_ELECTRICITY: switch (getDatas.addBytes[4] & 0xff) { case 0: unite = "A"; break; case 1: unite = "μA"; break; default: unite = ""; break; } break; case HDLApConfig.TYPE_SENSOR_POWER: unite = "W"; break; case HDLApConfig.TYPE_SENSOR_FLOODING: unite = ""; break; case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET: unite = ""; break; case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON: unite = ""; break; default: unite = "未知单位"; break; } // EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true)); HDLLog.I("发送传感器通知更新"); EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite)); break outter; } else { HDLLog.I("handle state 没有找到匹配类型"); } } break outter; } } } /** * 处理KNX科技希桐 状态读取、广播数据 * 2024-5-28 新支持 * * @param getDatas */ private static void handleKNXTechSysStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE && infos.get(j).getLittleType() == 101 && infos.get(j).getChannelNum() == (getDatas.addBytes[2] & 0xFF)) { AppliancesInfo info = devicesDataList.get(i).getAppliancesInfoList().get(j); info.setGetDeviceStateSuccess(true); float value = 0; //00014 2024年5月29日9:44:03:806: 14 64 C8 11 F7 35 3A FF FF 05 03 01 03 00 00 00 00 36 53 81 if ((getDatas.addBytes[3] & 0xFF) == 1 || (getDatas.addBytes[3] & 0xFF) == 2) {//整型 value = HDLUtlis.getInt(Arrays.copyOfRange(getDatas.addBytes, 5, 9)); } else if ((getDatas.addBytes[3] & 0xFF) == 3) {//浮点型 // value = HDLUtlis.byteToFloat(getDatas.addBytes[8], getDatas.addBytes[7], getDatas.addBytes[6], getDatas.addBytes[5]); value = HDLUtlis.getInt(Arrays.copyOfRange(getDatas.addBytes, 5, 9)); } Log.d("panlili", "HDLDeviceManager.java:handleKNXTechSysStateData----->value= " + value); AirTechSysBackInfo mAirTechSysBackInfo = new AirTechSysBackInfo(info); mAirTechSysBackInfo.setIndoorHumidity(value + "");//设置湿度 EventBus.getDefault().post(new AirTechSysFeedBackEvent(mAirTechSysBackInfo, true)); HDLLog.I("发送科技系统湿度通知更新"); break outter; } else { HDLLog.I("handle state 没有找到匹配类型"); } } break outter; } } } /** * panlili * 处理门锁状态和报警 广播数据 * * @param getDatas */ private static void handleDoorMachineBroadcastStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_DOOR_MACHINE) { String type = ""; /*开锁: 0x*1:指纹开锁 0x*2:密码开锁 0x*3:感应卡开锁 0x*4:机械钥匙开锁 0x*5:远程授权开锁 0x*6:临时密码开锁 0x*7-0x*f:(预留) 报警: 0x1*:密码验证错误报警(密码连续3次次错误) 0x2*:门未锁好报警(门锁未关好, 当门锁好时上报解除报警) 0x3*:劫持报警(输入防劫持密码或者防劫持指纹开锁时报警) 0x4*:防撬报警(门锁被撬开时报警) 0x5*:电量不足报警(电量不足时报警) 0x6*:指纹验证错误报警(开门验证输入指纹连续错误次数达到门锁规定3次时报警) 0x7*:卡片验证错误报警(开门验证输入卡片连续错误次数达到门锁规定3次报警) 0x8*:门锁恢复出厂设置 0x9*-0xf*:(预留)*/ switch (getDatas.addBytes[2] & 0xFF) { case 1: type = "指纹开锁"; break; case 2: type = "密码开锁"; break; case 3: type = "感应卡开锁"; break; case 4: type = "机械钥匙开锁"; break; case 5: type = "远程授权开锁"; break; case 6: type = "临时密码开锁"; break; case 10: type = "密码验证错误报警"; break; case 20: type = "门未锁好报警"; break; case 30: type = "劫持报警"; break; case 40: type = "防撬报警"; break; case 50: type = "电量不足报警"; break; case 60: type = "指纹验证错误报警"; break; case 70: type = "卡片验证错误报警"; break; case 80: type = "门锁恢复出厂设置"; break; default: break; } devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[j] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[j] & 0xFF); AppliancesInfo doorMachineInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); int state = getDatas.addBytes[2] & 0xFF; doorMachineInfo.setCurState(state); HDLLog.I("发送门锁状态和报警通知"); EventBus.getDefault().post(new DoorMachineWaringBackInfo(doorMachineInfo, true, type)); } else { HDLLog.I("handleDoorMachineBroadcastStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理灯光模块回调 * 20190726新增 * * @param getDatas */ private static void handleLightStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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).getDeviceType() != HDLApConfig.TYPE_LIGHT_RGB && infos.get(j).getDeviceType() != HDLApConfig.TYPE_LIGHT_DALI && infos.get(j).getDeviceType() != HDLApConfig.TYPE_LIGHT_DMX)) { //2019-07-26因为查灯光状态是查询所以回路,所以要把所有回路灯光状态都推送一次 isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[j + 1] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[j + 1] & 0xFF); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); // HDLLog.I("HDLlightState" + devicesDataList.get(i).getAppliancesInfoList().get(j).toString()); } else { HDLLog.I("handleLightStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理CCT OR RGB灯光模块回调 * 20230822新增 * * @param getDatas */ private static void handleColourLightStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB || infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_DALI || infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_DMX)) { isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo appliancesInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); ColourLightCtrlBackInfo colourLightCtrlBackInfo = new ColourLightCtrlBackInfo(appliancesInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new ColourLightFeedBackEvent(colourLightCtrlBackInfo, true)); } else { HDLLog.I("handleColourLightStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理窗帘模块 E3E4广播回调 * 2019-12-16 新增 * * @param getDatas */ private static void handleCurtainBroadcastStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { //把所有窗帘状态都推送一次 if (getDatas.addBytes.length - 1 < j) return; int state = 0; switch (getDatas.addBytes[j] & 0xFF) {//这里也应该改成0,1,2 case 0: state = CurtainCtrlParser.curtainPause; break; case 1: state = CurtainCtrlParser.curtainOn; break; case 2: state = CurtainCtrlParser.curtainOff; break; default: state = 0; break; } devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[j] & 0xFF); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[j] & 0xFF); AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); curtainInfo.setCurState(state); EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true)); // HDLLog.I("CurtainBroadcastState" + curtainInfo.toString()); } else { HDLLog.I("CurtainBroadcastState 没有找到匹配类型"); } } break outter; } } } /** * 处理窗帘 * 20190726新增 * * @param getDatas */ private static void handleCurtainStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE) { int state = 0; if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE//窗帘模块 && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 switch (getDatas.addBytes[1] & 0xFF) {//这里也应该改成0,1,2 case 0: state = CurtainCtrlParser.curtainPause; break; case 1: state = CurtainCtrlParser.curtainOn; break; case 2: state = CurtainCtrlParser.curtainOff; break; default: state = 0; break; } 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 curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); curtainInfo.setCurState(state); EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true)); break outter; } else if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_SHANGRILA) { if (getDatas.addBytes.length >= 3) {//新协议拓展字段 if ((getDatas.addBytes[0] & 0xFF) >= 17 && ((getDatas.addBytes[0] & 0xFF) - 16) == infos.get(j).getChannelNum()) {//窗帘号大于等于17 减 16 = 当前窗帘回路号 state = getDatas.addBytes[1] & 0xFF; if (state == 1) { state = 0;//这个判断是将百分比为1,强制改为0. } if (state == 99) { state = 100;//这个判断是将百分比为99,强制改为100. } isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(state); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo(); curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks()); curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks()); curtainCtrlBackInfo.setAppliancesInfo(curtainInfo); curtainInfo.setCurState(state); curtainCtrlBackInfo.setState(state); devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(state); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); curtainCtrlBackInfo.setNum((getDatas.addBytes[0] & 0xFF) - 16); EventBus.getDefault().post(new CurtainDeviceStateEvent(curtainCtrlBackInfo, true)); break outter; } else { if ((getDatas.addBytes[0] & 0xFF) == infos.get(j).getChannelNum()) { isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes); devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo appliancesInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); CurtainCtrlBackInfo info = new CurtainCtrlBackInfo(appliancesInfo); EventBus.getDefault().post(new CurtainDeviceStateEvent(info, true)); } } } else {//兼容旧协议 if ((getDatas.addBytes[0] & 0xFF) >= 17 && ((getDatas.addBytes[0] & 0xFF) - 16) == infos.get(j).getChannelNum()) {//窗帘号大于等于17 减 16 = 当前窗帘回路号 state = getDatas.addBytes[1] & 0xFF; if (state == 1) { state = 0;//这个判断是将百分比为1,强制改为0. } if (state == 99) { state = 100;//这个判断是将百分比为99,强制改为100. } 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 curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); curtainInfo.setCurState(state); EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true)); break outter; } else { if ((getDatas.addBytes[0] & 0xFF) == infos.get(j).getChannelNum()) { switch (getDatas.addBytes[1] & 0xFF) {//这里也应该改成0,1,2 case 0: state = CurtainCtrlParser.curtainPause; break; case 1: state = CurtainCtrlParser.curtainOn; break; case 2: state = CurtainCtrlParser.curtainOff; break; default: state = 0; break; } 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 curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); curtainInfo.setCurState(state); EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true)); break outter; } } } } } else { HDLLog.I("handleCurtainStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理空调设备状态数据 * 20190726新增 * * @param getDatas */ private static void handleAirStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_PANEL) {//2019-07-26 isGetDeviceStateSuccess = true; AppliancesInfo appliancesInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); appliancesInfo.setArrCurState(getDatas.addBytes); byte[] airBytes = appliancesInfo.getArrCurState(); switch (getDatas.addBytes[0] & 0xff) { case AirCtrlParser.airSwich: airBytes[0] = getDatas.addBytes[1]; break; case AirCtrlParser.airMode: airBytes[1] = getDatas.addBytes[1]; break; case AirCtrlParser.refTem: case AirCtrlParser.heatTem: case AirCtrlParser.autoTem: case AirCtrlParser.dehumTem: airBytes[2] = getDatas.addBytes[1]; break; case AirCtrlParser.airSpeed: airBytes[3] = getDatas.addBytes[1]; break; default: break; } devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airBytes); //上升、下降温度不返回 if ((getDatas.addBytes[0] & 0xff) != 9 && (getDatas.addBytes[0] & 0xff) != 10) { EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); } } else { HDLLog.I("handleAirStateData 没有找到匹配类型"); } } break outter; } } } /** * 读取场景号反馈 * * @param getDatas */ private static void handleLOGICStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if ((infos.get(j).getBigType() == Configuration.LOGIC_BIG_TYPE || infos.get(j).getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE) && infos.get(j).getLogicMode().getAreaNum() == (getDatas.addBytes[0] & 0xFF) ) { AppliancesInfo sceneInfo = infos.get(j); LogicMode logicMode = new LogicMode(); logicMode.setAreaNum(getDatas.addBytes[0] & 0xFF); logicMode.setAreaSceneNum(getDatas.addBytes[1] & 0xFF); sceneInfo.setLogicMode(logicMode); LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); logicCtrlBackInfo.setAppliancesInfo(sceneInfo); logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF); logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF); isGetDeviceStateSuccess = true; EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true)); break outter; } else { HDLLog.I("handleLOGICStateData 没有找到匹配类型"); } } break outter; } } } /** * 读取安防设置反馈 * 20190729新增 * * @param getDatas */ private static void handleSecurityStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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.I("handleSecurityStateData 返回addBytes数据异常"); } break outter; } else { HDLLog.I("handleSecurityStateData 没有找到匹配类型"); } } break outter; } } } /** * 读取HVAC状态反馈 * * @param getDatas */ private static void handleHVACStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-8-6 isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; } else { HDLLog.I("handleHVACStateData 没有找到匹配类型"); } } break outter; } } } /** * 读取科技系统状态反馈 * * @param getDatas */ private static void handleTechSysStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_TECHSYS || infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_KNXTECHSYS) && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-8-6 isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; } else { HDLLog.I("handleTechSysStateData 没有找到匹配类型"); } } break outter; } } } /** * 干接点广播状态反馈反馈 * 20191105新增 * * @param getDatas */ private static void handleDryContactBroadcastStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.SENSOR_BIG_TYPE && infos.get(j).getChannelNum() == (getDatas.addBytes[1] & 0xFF)) { if (getDatas.addBytes.length >= 3) { isGetDeviceStateSuccess = true; int state = getDatas.addBytes[2] & 0xFF; devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(state); // devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true, state)); } else { isGetDeviceStateSuccess = true; EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false)); HDLLog.I("DryContac 返回addBytes数据异常"); } break outter; } else { // HDLLog.I("DryContac 没有找到匹配类型"); } } break outter; } } } /** * 通用开关控制反馈 * * @param getDatas */ private static void handleCommonSwitchCtrlData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID) { List 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;//跳出循环 } } } /** * 通用开关读状态反馈反馈 * * @param getDatas */ private static void handleCommonSwitchStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID) { List 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;//跳出循环 } } } /** * 此方法基本没用到,逻辑模块的控制信息已经在handleCtrlData中处理过了 *

* 处理逻辑模块数据 * * @param getDatas */ private static void handleLogicData(UdpDataBean getDatas) { for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum() == ((byte) (getDatas.addBytes[2] & 0xFF) & 0xFF)) { LogicMode logicMode = new LogicMode(); logicMode.setAreaNum((byte) (getDatas.addBytes[23] & 0xFF) & 0xFF); logicMode.setAreaSceneNum((byte) (getDatas.addBytes[24] & 0xFF) & 0xFF); byte[] remark = new byte[20]; System.arraycopy(getDatas.addBytes, 3, remark, 0, remark.length); devicesDataList.get(i).getAppliancesInfoList().get(j).setRemarks(HDLStringUtils.byte2String(remark)); devicesDataList.get(i).getAppliancesInfoList().get(j).setLogicMode(logicMode); break; } } } } } /** * 处理警报数据 * * @param getDatas */ private static void handleWarningData(UdpDataBean getDatas) { int warningTypeId = 0; if (getDatas.addBytes.length == 4) { warningTypeId = (getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF); EventBus.getDefault().post(new WarningInfoEvent(warningTypeId)); Intent warningIntent = new Intent(); warningIntent.setAction("com.hdl.action.WARNING"); warningIntent.putExtra("HdlWarning", warningTypeId); viewContext.sendBroadcast(warningIntent); } else { warningTypeId = getDatas.addBytes[2] & 0xFF; EventBus.getDefault().post(new WarningInfoEvent(warningTypeId)); Intent warningIntent = new Intent(); warningIntent.setAction("com.hdl.action.WARNING"); warningIntent.putExtra("HdlWarning", warningTypeId);//2019-07 viewContext.sendBroadcast(warningIntent); } Intent warningIntent = new Intent(); warningIntent.setAction("com.hdl.devices.warning"); warningIntent.putExtra("HdlWarning", WarningType.getWarningType((getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF))); viewContext.sendBroadcast(warningIntent); } /** * 处理HDL音乐协议 * * @param getDatas */ private static void handleAudioData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.AUDIO_BIG_TYPE) { //暂时只支持旧版背景音乐 if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_MUSIC_MODULE) { HDLAudio.parseAudioData(getDatas, infos.get(j)); } break outter; } } } } } /** * 保存设备数据列表 * 根据需要,实时保存当前数据 * * @return boolean */ public static boolean saveDevicesDataList() { try { Gson gson = new Gson(); String jsonStr = gson.toJson(devicesDataList); //将List转换成Json // HDLLog.I("saveDevicesDataList: \n" + jsonStr); SPUtils.setParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, jsonStr); return true; } catch (Exception e) { e.printStackTrace(); return false; } } /** * 加载本地设备数据列表 * * @return devicesDataList */ public static List getLocalDevicesDataList() { try { String getJsonStr = SPUtils.getParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, "").toString(); // HDLLog.I("getJsonStr: \n" + getJsonStr); if (!TextUtils.isEmpty(getJsonStr)) //防空判断 { Gson gson = new Gson(); devicesDataList = gson.fromJson(getJsonStr, new TypeToken>() { }.getType()); //将json字符串转换成List集合 } } catch (JsonSyntaxException e) { e.printStackTrace(); } if (devicesDataList == null) devicesDataList = new ArrayList<>(); List devicesDataList2 = devicesDataList; setRemarkList();//加载备注list return devicesDataList2; } 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) { for (int i = 0, len = devicesDataList.get(j).getAppliancesInfoList().size(); i < len; i++) { ListRemarks listRemarksTemp = new ListRemarks(); listRemarksTemp.setCallBack(false); listRemarksTemp.setAppliancesInfo(devicesDataList.get(j).getAppliancesInfoList().get(i)); listRemarks.add(listRemarksTemp); } } } } /** * 处理MCU返回的命令数据 * * @param mMCUDataBean */ public static void HandleMCUData(MCUDataBean mMCUDataBean) { isMCUCtrlSuccess = true; switch (mMCUDataBean.command) { case MCUConstants.MCU_COMMAND_SEND_BACK: //0x80 上报数据 透传的话直接返回 case MCUConstants.MCU_DETECT_PACKET_LOSS_STATUS_BACK://0x81 检测丢包状态返回 case MCUConstants.MCU_REQUEST_UPGRADE_BACK: //0x84 请求升级返回 //上面3种返回数据直接返回,先不处理 EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS)); break; case MCUConstants.MCU_READ_CONFIGURATION_BACK: //0x82 读配置返回 case MCUConstants.MCU_WRITE_CONFIGURATION_BACK: //0x83 写配置信息返回 if (mMCUDataBean.receiveBytes.length > 5) { MCUConfigurationBean mcuConfigurationBean = new MCUConfigurationBean(); mcuConfigurationBean.setMcuAgreementType(mMCUDataBean.receiveBytes[0] & 0xFF); mcuConfigurationBean.setMcuBaudrate(mMCUDataBean.receiveBytes[1] & 0xFF); mcuConfigurationBean.setMcuStartBit(mMCUDataBean.receiveBytes[2] & 0xFF); mcuConfigurationBean.setMcuDataBit(mMCUDataBean.receiveBytes[3] & 0xFF); mcuConfigurationBean.setMcuCheckBit(mMCUDataBean.receiveBytes[4] & 0xFF); mcuConfigurationBean.setMcuStopBit(mMCUDataBean.receiveBytes[5] & 0xFF); mMCUDataBean.setMCUConfigurationBean(mcuConfigurationBean); EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS)); } else { EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.FAILURE_DATA_ERROR, "数据异常")); } break; case MCUConstants.MCU_RESTART_BACK: //0x86 重启返回 if (mMCUDataBean.receiveBytes.length > 0) { if ((mMCUDataBean.receiveBytes[0] & 0xFF) == 0xF8) { //重启成功或者升级成功后重启成功 EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS)); } // else { //// 重启失败 // EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.FAILURE_TIMEOUT, "重启失败")); // } } break; default: break; } } /** * 设置控制是否成功状态 * * @param info * @param success */ public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success) { // if(info.getDeviceKey() == null) return; ctrlSuccessStateHashMap.put(info.getDeviceKey(), success); } /** * 获取是否控制成功 * * @param info * @return 结果 */ public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info) { // if(info.getDeviceKey() == null) return false; Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); if (success == null) success = false; return success; } public static boolean isSceneCtrlSuccess() { return isSceneCtrlSuccess; } public static void setSceneCtrlSuccess(boolean isSceneCtrlSuccess) { HDLDeviceManager.isSceneCtrlSuccess = isSceneCtrlSuccess; } /** * 手动添加一个安防模块 * * @param mSubnetID 子网号 * @param mDeviceID 设备号 * @param mChannelNum 区号 * @param mRemarks 备注 * @return Boolean */ public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); } /** * 手动添加一个音乐播放器模块 * * @param mSubnetID 子网号 * @param mDeviceID 设备号 * @param mChannelNum 区号 * @param mRemarks 备注 * @return Boolean */ public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); } /** * 手动添加不支持简易编程搜索的设备 * 添加子网号 设备号 不存在 * * @param mBigType * @param mLittleType * @param mSubnetID * @param mDeviceID * @param mChannelNum * @param mRemarks * @return */ public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { try { DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); if (mDevicesData != null) { devicesDataList.add(mDevicesData); HandleSearch.OnDeviceListGetSuccessCallBack(); HDLLog.I("支持的设备,允许添加"); return true; } else { HDLLog.I("不支持的设备,不允许添加"); return false; } } catch (Exception e) { e.printStackTrace(); // HDLLog.I("不支持的设备,不允许添加"); return false; } } /** * 手动添加不支持简易编程搜索的设备 * * @param mBigType * @param mLittleType * @param mSubnetID * @param mDeviceID * @param mChannelNum * @param mRemarks * @return */ public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { try { if (!DeviceParser.isWantData(mBigType, mLittleType)) {//判断是否支持的大类小类 return false;//不支持返回失败 } boolean bExistSubnetID = false; boolean bCanAdd = false; outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == mSubnetID && devicesDataList.get(i).getDeviceDeviceID() == mDeviceID ) { bExistSubnetID = true; DevicesData mDevicesData = devicesDataList.get(i); bCanAdd = getIfCanAddDevice(mDevicesData.getAppliancesInfoList(), mBigType, mLittleType, mChannelNum); if (bCanAdd) {//添加子网号 设备号 已存在,并且没有相同的子网号设备号 AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mIndex, mRemarks, mRemarks); devicesDataList.get(i).getAppliancesInfoList().add(mAppliancesInfo); HandleSearch.OnDeviceListGetSuccessCallBack(); HDLLog.I("支持的设备,允许添加"); } break outter; } } if (!bExistSubnetID) { return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); } return bCanAdd; } catch (Exception e) { e.printStackTrace(); // HDLLog.I("不支持的设备,不允许添加"); return false; } } /** * 判断是否存在 相同大类、小类、回路的设备 * * @param appliancesInfoList * @param mBigType * @param mLittleType * @param mChannelNum * @return */ private static boolean getIfCanAddDevice(List appliancesInfoList, int mBigType, int mLittleType, int mChannelNum) { boolean bCanAddN = true; for (int i = 0, len = appliancesInfoList.size(); i < len; i++) { if (appliancesInfoList.get(i).getBigType() == mBigType && appliancesInfoList.get(i).getLittleType() == mLittleType && appliancesInfoList.get(i).getChannelNum() == mChannelNum ) { bCanAddN = false; } } return bCanAddN; } /** * 清空设备列表 * 2019-8-6 */ public static void clearAllDeviceList() { devicesDataList.clear(); realDevicesDataList.clear(); listRemarks.clear(); HandleSearch.OnDeviceListGetSuccessCallBack(); } /** * 处理新风设备状态数据 * 2020-07-20 新增 * * @param getDatas */ private static void handleFreshAirStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; } else { HDLLog.I("handleFreshAirStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理新风控制成功状态数据 * 2020-07-20 新增 * * @param getDatas */ private static void handleFreshAirCtrlBackData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); FreshAirBackInfo info = new FreshAirBackInfo(mFreshAirInfo); // isFreshAirCtrlSuccess = true; setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new FreshAirFeedBackEvent(info, true)); break outter; } } } } } /** * 处理金茂新风设备状态数据 * 2020-07-20 新增 * * @param getDatas */ private static void handleFreshAirJINMAOStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR_JINMAO && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; } else { HDLLog.I("handleFreshAirStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理金茂新风控制成功状态数据 * 2020-07-20 新增 * * @param getDatas */ private static void handleFreshAirJINMAOCtrlBackData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR_JINMAO && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); FreshAirJinMaoBackInfo info = new FreshAirJinMaoBackInfo(mFreshAirInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new FreshAirJinMaoFeedBackEvent(info, true)); break outter; } } } } } /** * 处理地热设备状态数据 * 2020-07-20 新增 * * @param getDatas */ private static void handleGeothermalStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE || infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_JINMAO) && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 if (getDatas.addBytes.length >= 10) { byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); if (getBytes == null || getBytes.length < 10) { getBytes = new byte[10]; } System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710查询地热状态反馈,只取前10位数据 devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getBytes); isGetDeviceStateSuccess = true; EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); } else { HDLLog.E("地热状态反馈数据异常"); } break outter; } else { HDLLog.I("handleFreshAirStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理地热设备控制数据 * 2020-07-20 * * @param getDatas */ private static void handleGeothermalCtrlData(UdpDataBean getDatas) { switch (getDatas.command) { //2019-07-09 地热模块 case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND: outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List 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.GEOTHERMAL_BIG_TYPE && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE || infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_JINMAO) && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { if (getDatas.addBytes.length >= 8) { byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); 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).setArrCurState(getBytes); AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); // isGeothermalCtrlSuccess = true; setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS)); } else { HDLLog.E("控制地热状态反馈数据异常"); } break outter; } } } } } break; } } /** * 处理门锁设备状态数据 * 2023-08-22 新增 * * @param getDatas */ private static void handleDoorMachineStateData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_DOOR_MACHINE && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { isGetDeviceStateSuccess = true; devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; } else { HDLLog.I("handleDoorMachineStateData 没有找到匹配类型"); } } break outter; } } } /** * 处理门锁远程开锁连接控制成功状态数据 * 2023-08-22 新增 * * @param getDatas */ private static void handleDoorMachineCtrlFristBackData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_DOOR_MACHINE && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo mDoorMachineInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); DoorMachineFristBackInfo info = new DoorMachineFristBackInfo(mDoorMachineInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new DoorMachineFeedFristBackEvent(info, true)); break outter; } } } } } /** * 处理门锁远程开锁控制成功状态数据 * 2023-08-22 新增 * * @param getDatas */ private static void handleDoorMachineCtrlBackData(UdpDataBean getDatas) { outter: for (int i = 0, len = devicesDataList.size(); i < len; i++) { if (devicesDataList.get(i).getDeviceSubnetID() == getDatas.sourceSubnetID && devicesDataList.get(i).getDeviceDeviceID() == getDatas.sourceDeviceID ) { List infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { if (infos.get(j).getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE && infos.get(j).getDeviceType() == HDLApConfig.TYPE_DOOR_MACHINE && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); AppliancesInfo appliancesInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); DoorMachineBackInfo doorMachineBackInfo = new DoorMachineBackInfo(appliancesInfo); setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new DoorMachineFeedBackEvent(doorMachineBackInfo, true)); break outter; } } } } } }