| | |
| | | import com.hdl.sdk.hdl_core.Config.Configuration; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirHVACBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuLight; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirHVACFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; |
| | |
| | | import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; |
| | | import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; |
| | | import com.hdl.sdk.hdl_core.Util.TransformUtil.DataConverseUtil; |
| | | import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; |
| | | import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | case Configuration.CURTAIN_CTRL_BACK_COMMAND: |
| | | case Configuration.AIR_CTRL_BACK_COMMAND: |
| | | case Configuration.LOGIC_CTRL_BACK_COMMAND: |
| | | case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: |
| | | // case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: |
| | | case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709新增 |
| | | handleCtrlData(getDatas); |
| | | break; |
| | | case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: |
| | | handleHVACCtrlData(getDatas); |
| | | break; |
| | | case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: //2020-10-19新增 |
| | | handleRGBCCTCtrlData(getDatas); |
| | |
| | | case Configuration.SENSOR_STATE_BACK_COMMAND: |
| | | handleSensorAnalogStateData(getDatas, true); |
| | | break; |
| | | case Configuration.SENSOR_BROADCAST_COMMAND://传感器模拟量广播 |
| | | case Configuration.SENSOR_BROADCAST_COMMAND://2021-08-10 传感器模拟量广播 |
| | | handleSensorAnalogStateData(getDatas, false); |
| | | break; |
| | | //获取新风设备状态 20190709新增 |
| | |
| | | break; |
| | | |
| | | case Configuration.AIR_HVAC_STATE_BACK_COMMAND: |
| | | handleRcuAirCastData(getDatas); |
| | | // handleRcuAirCastData(getDatas); |
| | | handleHVACStateData(getDatas);//2019-06-27 |
| | | break; |
| | | case Configuration.RCU_ROOM_CAST_COMMAND: |
| | | handleRcuLightCastData(getDatas); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理RCU空调广播消息 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleRcuAirCastData(UdpDataBean getDatas) { |
| | | int count = getDatas.addBytes.length / 11; |
| | | |
| | | for (int airIndex = 0; airIndex < count; airIndex++) { |
| | | outter: |
| | | for (int indexI = 0, len = devicesDataList.size(); indexI < len; indexI++) { |
| | | if (devicesDataList.get(indexI).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(indexI).getSourceDeviceID() == getDatas.sourceDeviceID |
| | | ) { |
| | | List<AppliancesInfo> infos = devicesDataList.get(indexI).getAppliancesInfoList(); |
| | | for (int indexJ = 0, len2 = infos.size(); indexJ < len2; indexJ++) { |
| | | if (infos.get(indexJ).getBigType() == Configuration.AIR_BIG_TYPE |
| | | && infos.get(indexJ).getDeviceType() != HDLApConfig.TYPE_AC_PANEL |
| | | && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) { |
| | | AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ); |
| | | if (appliancesInfo.getPort() != 0) { |
| | | byte[] oldAirInfo = appliancesInfo.getArrCurState(); |
| | | |
| | | if (oldAirInfo == null || oldAirInfo.length == 0) { |
| | | oldAirInfo = AirCtrlParser.getNewAcByte(); |
| | | } |
| | | |
| | | |
| | | handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo); |
| | | |
| | | oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11]; |
| | | |
| | | oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); |
| | | |
| | | |
| | | switch (oldAirInfo[0] & 0xff) { |
| | | case 0: |
| | | oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11]; |
| | | break; |
| | | case 1: |
| | | oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11]; |
| | | break; |
| | | case 3: |
| | | oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11]; |
| | | break; |
| | | case 4: |
| | | oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11]; |
| | | break; |
| | | |
| | | } |
| | | |
| | | oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); |
| | | oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11]; |
| | | oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11]; |
| | | devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); |
| | | |
| | | |
| | | // switch (getDatas.addBytes[airIndex * 11] & 0xff) { |
| | | // case 1: |
| | | // handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo); |
| | | // air1Info[0] = getDatas.addBytes[1 + 0 * 11]; |
| | | // /** |
| | | // * 处理RCU空调广播消息 |
| | | // * |
| | | // * @param getDatas |
| | | // */ |
| | | // private static void handleRcuAirCastData(UdpDataBean getDatas) { |
| | | // int count = getDatas.addBytes.length / 11; |
| | | // |
| | | // for (int airIndex = 0; airIndex < count; airIndex++) { |
| | | // outter: |
| | | // for (int indexI = 0, len = devicesDataList.size(); indexI < len; indexI++) { |
| | | // if (devicesDataList.get(indexI).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | // && devicesDataList.get(indexI).getSourceDeviceID() == getDatas.sourceDeviceID |
| | | // ) { |
| | | // List<AppliancesInfo> infos = devicesDataList.get(indexI).getAppliancesInfoList(); |
| | | // for (int indexJ = 0, len2 = infos.size(); indexJ < len2; indexJ++) { |
| | | // if (infos.get(indexJ).getBigType() == Configuration.AIR_BIG_TYPE |
| | | // && infos.get(indexJ).getDeviceType() != HDLApConfig.TYPE_AC_PANEL |
| | | // && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) { |
| | | // AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ); |
| | | // if (appliancesInfo.getPort() != 0) { |
| | | // byte[] oldAirInfo = appliancesInfo.getArrCurState(); |
| | | // |
| | | // if (oldAirInfo == null || oldAirInfo.length == 0) { |
| | | // oldAirInfo = AirCtrlParser.getNewAcByte(); |
| | | // } |
| | | // |
| | | // |
| | | // air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); |
| | | // handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo); |
| | | // |
| | | // oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11]; |
| | | // |
| | | // oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); |
| | | // |
| | | // |
| | | // switch (air1Info[0] & 0xff) { |
| | | // case 0: |
| | | // air1Info[2] = getDatas.addBytes[2 + 0 * 11]; |
| | | // break; |
| | | // case 1: |
| | | // air1Info[2] = getDatas.addBytes[6 + 0 * 11]; |
| | | // break; |
| | | // case 3: |
| | | // air1Info[2] = getDatas.addBytes[8 + 0 * 11]; |
| | | // break; |
| | | // case 4: |
| | | // air1Info[2] = getDatas.addBytes[9 + 0 * 11]; |
| | | // break; |
| | | // |
| | | // } |
| | | // |
| | | // air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); |
| | | // air1Info[4] = getDatas.addBytes[5 + 0 * 11]; |
| | | // air1Info[5] = getDatas.addBytes[10 + 0 * 11]; |
| | | //// HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]); |
| | | //// String arrString = "209a 附加数据:"; |
| | | //// for (int i = 0; i < getDatas.addBytes.length; i++) { |
| | | //// arrString += (getDatas.addBytes[i] & 0xff) + ","; |
| | | //// } |
| | | //// HDLLog.info( arrString); |
| | | // devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info); |
| | | // switch (oldAirInfo[0] & 0xff) { |
| | | // case 0: |
| | | // oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11]; |
| | | // break; |
| | | // case 2: |
| | | // handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo); |
| | | // air2Info[0] = getDatas.addBytes[1 + 1 * 11]; |
| | | // air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4); |
| | | // switch (air2Info[0] & 0xff) { |
| | | // case 0: |
| | | // air2Info[2] = getDatas.addBytes[2 + 1 * 11]; |
| | | // break; |
| | | // case 1: |
| | | // air2Info[2] = getDatas.addBytes[6 + 1 * 11]; |
| | | // break; |
| | | // case 3: |
| | | // air2Info[2] = getDatas.addBytes[8 + 1 * 11]; |
| | | // break; |
| | | // case 4: |
| | | // air2Info[2] = getDatas.addBytes[9 + 1 * 11]; |
| | | // break; |
| | | // |
| | | // } |
| | | // air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f); |
| | | // air2Info[4] = getDatas.addBytes[5 + 1 * 11]; |
| | | // air2Info[5] = getDatas.addBytes[10 + 1 * 11]; |
| | | // devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info); |
| | | // case 1: |
| | | // oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11]; |
| | | // break; |
| | | // case 3: |
| | | // handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo); |
| | | // air3Info[0] = getDatas.addBytes[1 + 2 * 11]; |
| | | // air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4); |
| | | // switch (air3Info[0] & 0xff) { |
| | | // case 0: |
| | | // air3Info[2] = getDatas.addBytes[2 + 2 * 11]; |
| | | // break; |
| | | // case 1: |
| | | // air3Info[2] = getDatas.addBytes[6 + 2 * 11]; |
| | | // break; |
| | | // case 3: |
| | | // air3Info[2] = getDatas.addBytes[8 + 2 * 11]; |
| | | // break; |
| | | // case 4: |
| | | // air3Info[2] = getDatas.addBytes[9 + 2 * 11]; |
| | | // break; |
| | | // } |
| | | // air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f); |
| | | // air3Info[4] = getDatas.addBytes[5 + 2 * 11]; |
| | | // air3Info[5] = getDatas.addBytes[10 + 2 * 11]; |
| | | // devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info); |
| | | // oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11]; |
| | | // break; |
| | | // case 4: |
| | | // handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo); |
| | | // air4Info[0] = getDatas.addBytes[1 + 3 * 11]; |
| | | // air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4); |
| | | // switch (air4Info[0] & 0xff) { |
| | | // case 0: |
| | | // air4Info[2] = getDatas.addBytes[2 + 3 * 11]; |
| | | // break; |
| | | // case 1: |
| | | // air4Info[2] = getDatas.addBytes[6 + 3 * 11]; |
| | | // break; |
| | | // case 3: |
| | | // air4Info[2] = getDatas.addBytes[8 + 3 * 11]; |
| | | // break; |
| | | // case 4: |
| | | // air4Info[2] = getDatas.addBytes[9 + 3 * 11]; |
| | | // break; |
| | | // } |
| | | // air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f); |
| | | // air4Info[4] = getDatas.addBytes[5 + 3 * 11]; |
| | | // air4Info[5] = getDatas.addBytes[10 + 3 * 11]; |
| | | // devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info); |
| | | // oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11]; |
| | | // break; |
| | | // |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | // |
| | | // oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); |
| | | // oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11]; |
| | | // oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11]; |
| | | // devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); |
| | | // |
| | | // |
| | | //// switch (getDatas.addBytes[airIndex * 11] & 0xff) { |
| | | //// case 1: |
| | | //// handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo); |
| | | //// air1Info[0] = getDatas.addBytes[1 + 0 * 11]; |
| | | //// |
| | | //// |
| | | //// air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); |
| | | //// |
| | | //// |
| | | //// switch (air1Info[0] & 0xff) { |
| | | //// case 0: |
| | | //// air1Info[2] = getDatas.addBytes[2 + 0 * 11]; |
| | | //// break; |
| | | //// case 1: |
| | | //// air1Info[2] = getDatas.addBytes[6 + 0 * 11]; |
| | | //// break; |
| | | //// case 3: |
| | | //// air1Info[2] = getDatas.addBytes[8 + 0 * 11]; |
| | | //// break; |
| | | //// case 4: |
| | | //// air1Info[2] = getDatas.addBytes[9 + 0 * 11]; |
| | | //// break; |
| | | //// |
| | | //// } |
| | | //// |
| | | //// air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); |
| | | //// air1Info[4] = getDatas.addBytes[5 + 0 * 11]; |
| | | //// air1Info[5] = getDatas.addBytes[10 + 0 * 11]; |
| | | ////// HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]); |
| | | ////// String arrString = "209a 附加数据:"; |
| | | ////// for (int i = 0; i < getDatas.addBytes.length; i++) { |
| | | ////// arrString += (getDatas.addBytes[i] & 0xff) + ","; |
| | | ////// } |
| | | ////// HDLLog.info( arrString); |
| | | //// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info); |
| | | //// break; |
| | | //// case 2: |
| | | //// handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo); |
| | | //// air2Info[0] = getDatas.addBytes[1 + 1 * 11]; |
| | | //// air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4); |
| | | //// switch (air2Info[0] & 0xff) { |
| | | //// case 0: |
| | | //// air2Info[2] = getDatas.addBytes[2 + 1 * 11]; |
| | | //// break; |
| | | //// case 1: |
| | | //// air2Info[2] = getDatas.addBytes[6 + 1 * 11]; |
| | | //// break; |
| | | //// case 3: |
| | | //// air2Info[2] = getDatas.addBytes[8 + 1 * 11]; |
| | | //// break; |
| | | //// case 4: |
| | | //// air2Info[2] = getDatas.addBytes[9 + 1 * 11]; |
| | | //// break; |
| | | //// |
| | | //// } |
| | | //// air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f); |
| | | //// air2Info[4] = getDatas.addBytes[5 + 1 * 11]; |
| | | //// air2Info[5] = getDatas.addBytes[10 + 1 * 11]; |
| | | //// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info); |
| | | //// break; |
| | | //// case 3: |
| | | //// handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo); |
| | | //// air3Info[0] = getDatas.addBytes[1 + 2 * 11]; |
| | | //// air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4); |
| | | //// switch (air3Info[0] & 0xff) { |
| | | //// case 0: |
| | | //// air3Info[2] = getDatas.addBytes[2 + 2 * 11]; |
| | | //// break; |
| | | //// case 1: |
| | | //// air3Info[2] = getDatas.addBytes[6 + 2 * 11]; |
| | | //// break; |
| | | //// case 3: |
| | | //// air3Info[2] = getDatas.addBytes[8 + 2 * 11]; |
| | | //// break; |
| | | //// case 4: |
| | | //// air3Info[2] = getDatas.addBytes[9 + 2 * 11]; |
| | | //// break; |
| | | //// } |
| | | //// air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f); |
| | | //// air3Info[4] = getDatas.addBytes[5 + 2 * 11]; |
| | | //// air3Info[5] = getDatas.addBytes[10 + 2 * 11]; |
| | | //// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info); |
| | | //// break; |
| | | //// case 4: |
| | | //// handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo); |
| | | //// air4Info[0] = getDatas.addBytes[1 + 3 * 11]; |
| | | //// air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4); |
| | | //// switch (air4Info[0] & 0xff) { |
| | | //// case 0: |
| | | //// air4Info[2] = getDatas.addBytes[2 + 3 * 11]; |
| | | //// break; |
| | | //// case 1: |
| | | //// air4Info[2] = getDatas.addBytes[6 + 3 * 11]; |
| | | //// break; |
| | | //// case 3: |
| | | //// air4Info[2] = getDatas.addBytes[8 + 3 * 11]; |
| | | //// break; |
| | | //// case 4: |
| | | //// air4Info[2] = getDatas.addBytes[9 + 3 * 11]; |
| | | //// break; |
| | | //// } |
| | | //// air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f); |
| | | //// air4Info[4] = getDatas.addBytes[5 + 3 * 11]; |
| | | //// air4Info[5] = getDatas.addBytes[10 + 3 * 11]; |
| | | //// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info); |
| | | //// break; |
| | | //// |
| | | //// } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | // } |
| | | // |
| | | // |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | case Configuration.AIR_BIG_TYPE: |
| | | switch (infos.get(appPos).getLittleType()) { |
| | | case 0: |
| | | |
| | | byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; |
| | | for (int i = 23; i < getDatas.addBytes.length; i++) { |
| | | hvacBytes[i - 23] = getDatas.addBytes[i]; |
| | | } |
| | | |
| | | HDLLog.info("获取备注Configuration.AIR_BIG_TYPE: " + StringUtil.ByteArrToHex(hvacBytes, 0, hvacBytes.length)); |
| | | |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes); |
| | | // hvacBytes * 简易编程搜索 状态数据bytes格式 |
| | | // * 0 开关状态 |
| | | // * 1 模式 |
| | | // * 2 温度 |
| | | // * 3 风速 |
| | | // * 4 当前室温 |
| | | // * 5 是否摆风 |
| | | byte[] oldHvacBytes = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getArrCurState(); |
| | | //为了不改变原来其他模式的温度数据,需要获取原来的状态修改处理 |
| | | byte[] newHvacBytes = AirCtrlParser.getNewAcByteWithE44B(hvacBytes, oldHvacBytes); |
| | | // HDLLog.info("获取备注Configuration.AIR_BIG_TYPE: " + StringUtil.ByteArrToHex(hvacBytes, 0, hvacBytes.length)); |
| | | // HDLLog.info("获取备注Configuration.AIR_BIG_TYPEnewhvacBytes: " + StringUtil.ByteArrToHex(newHvacBytes, 0, newHvacBytes.length)); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(newHvacBytes); |
| | | // switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) { |
| | | // case 1: |
| | | // if (air1Info == null) { |
| | |
| | | // } |
| | | // break; |
| | | // |
| | | // } |
| | | // |
| | | break; |
| | | case 3: |
| | | byte[] newBytes = new byte[getDatas.addBytes.length - 24 + 1]; |
| | |
| | | } |
| | | break; |
| | | case Configuration.SENSOR_BIG_TYPE: |
| | | // String aa = "传感器备注:"; |
| | | // for (int i = 0; i < getDatas.addBytes.length; i++) { |
| | | // aa += (getDatas.addBytes[i] & 0xff) + ","; |
| | | // } |
| | | // HDLLog.info( aa); |
| | | |
| | | //使用干节点指令的传感器 |
| | | if (DeviceParser.getIfDryContactSensor(infos.get(appPos).getLittleType())) { |
| | | //干节点传感器,要特殊处理修改回路号 |
| | |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState); |
| | | } else { |
| | | //标准模拟量传感器 |
| | | //标准模拟量传感器 2021-08-09 |
| | | float curState; |
| | | if (getDatas.addBytes.length >= 28) { |
| | | curState = DataConverseUtil.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 24, 27)); |
| | | |
| | | if (getDatas.addBytes.length >= 26) { |
| | | curState = (float) ((getDatas.addBytes[24] & 0xff) * 256 + (getDatas.addBytes[25] & 0xff)); |
| | | //TVOC 和温度传感器要特殊处理 |
| | | if (infos.get(appPos).getLittleType() == 5) {//TVOC |
| | | //TVOC固定:2(10 ug/m3)所以要乘以10 才是ug/m3 |
| | | curState = curState * 10; |
| | | HDLLog.info("curStatecurState TVOC:" + curState); |
| | | } else if (infos.get(appPos).getLittleType() == 2) {//温度 |
| | | //转为Float |
| | | if (getDatas.addBytes.length >= 28) { |
| | | curState = HDLUtlis.byteArrayToFloatWithSign((byte) 3, getDatas.addBytes[24], getDatas.addBytes[25], getDatas.addBytes[26], getDatas.addBytes[27]); |
| | | HDLLog.info("curStatecurState temp:" + curState); |
| | | } |
| | | } |
| | | } else { |
| | | curState = (float) (getDatas.addBytes[getDatas.addBytes.length - 1] & 0xff); |
| | | //格式不对,赋值状态为0 |
| | | curState = 0; |
| | | } |
| | | |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState); |
| | | } |
| | | |
| | | |
| | | break; |
| | | case Configuration.FRESH_AIR_BIG_TYPE://20190711新增 |
| | |
| | | /** |
| | | * 处理各种传感器模拟量状态数据 |
| | | * 2021-08-05 |
| | | * 小类 |
| | | * 2:温度 |
| | | * 3:湿度 |
| | | * 5:TVOC |
| | | * 6:PM2.5 |
| | | * 7:CO2 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | |
| | | isGetDeviceStateSuccess = true; |
| | | } |
| | | AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | float value = DataConverseUtil.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8)); |
| | | // float value = HDLUtlis.byteArrayToFloat(Arrays.copyOfRange(getDatas.addBytes, 5, 8)); |
| | | float value = HDLUtlis.byteArrayToFloatWithSign(getDatas.addBytes[3], getDatas.addBytes[5], getDatas.addBytes[6], getDatas.addBytes[7], getDatas.addBytes[8]); |
| | | if (devicesDataList.get(i).getAppliancesInfoList().get(j).getLittleType() == 5) { |
| | | //TVOC固定:2(0.01ug/m3)所以要除以100 才是微克/m3 |
| | | value = value / 100; |
| | | } |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value); |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value); |
| | | |
| | | HDLLog.info("curStatecurState ug:" + value); |
| | | sensorInfo.setCurState(value); |
| | | |
| | | String unite = ""; |
| | |
| | | unite = "LUX"; |
| | | break; |
| | | case HDLApConfig.TYPE_SENSOR_VOC: |
| | | unite = ""; |
| | | unite = "ug/m3"; |
| | | break; |
| | | case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: |
| | | switch (getDatas.addBytes[4] & 0xff) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 处理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).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID |
| | | ) { |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (getDatas.addBytes.length > 0) { |
| | | if (infos.get(j).getBigType() == Configuration.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; |
| | | } |
| | | // else { |
| | | // HDLLog.E("控制HVAC状态反馈数据异常"); |
| | | // } |
| | | } |
| | | } |
| | | |
| | | break outter; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 读取HVAC状态反馈 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleHVACStateData(UdpDataBean getDatas) { |
| | | outter: |
| | | for (int i = 0, len = devicesDataList.size(); i < len; i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID |
| | | ) { |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (infos.get(j).getBigType() == Configuration.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.info("handleHVACStateData 没有找到匹配类型"); |
| | | } |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |