package com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.Parser; import com.hdl.sdk.ttl.Config.Configuration; import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo; import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager; /** * Created by JLChen on 2020-07-20 * 附加数据: * 编号 备注 值域 * 0 新风编号 1~200 * 1 类型 第三方类型 0:金茂新风 * 2 开关 0-关机,1-开机 * 3 运行模式 1-通风,2-加湿 * 4 节能舒适选择 1-舒适,2-节能 * 5 风速档位 0-自动,1-1档,2-2档,3-3档 * 6 湿度设定 % * 7 室内温度值 ℃ * 8 室内湿度值 ℃ * 9 过滤网剩余 % * 10 过滤网使用超时 */ public class FreshAirJinMaoParser { public static final int fail = 0; public static final int SetSwich = 0;//设置开关状态 public static final int freshAirOn = 1;//新风开 public static final int freshAirOff = 0;//新风关 public static final int SetSpeed = 1;//设置风速 public static final int freshAirSpeedAuto = 0;//风速 自动 public static final int freshAirSpeed1 = 1;//风速 1档 public static final int freshAirSpeed2 = 2;//风速 2档 public static final int freshAirSpeed3 = 3;//风速 3档 public static final int SetMode = 2;//设置运行模式 public static final int freshAirModeVentilation = 1;//通风模式 public static final int freshAirModeHumidify= 2;//加湿模式 public static final int SetEnergySavingMode = 3;//设置节能模式 public static final int energySavingModeComfortable = 1;//舒适 public static final int energySavingModeEs= 2;//节能 public static final int SetHumidty= 4;//设置湿度 public static byte[] getFreshAirAddByte(AppliancesInfo appliancesInfo, int type, int state) { try { AppliancesInfo newInfo = appliancesInfo; byte[] freshAirBytes = null; outter: for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getDeviceSubnetID() && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getDeviceDeviceID()) { for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) { if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR_JINMAO && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); if (newInfo.getArrCurState() == null) { newInfo.setArrCurState(GetNewData(newInfo.getChannelNum())); } freshAirBytes = newInfo.getArrCurState(); break outter; } } } } byte[] addBytes = new byte[11]; if (freshAirBytes != null && freshAirBytes.length >= 11) { System.arraycopy(freshAirBytes, 0, addBytes, 0, freshAirBytes.length); addBytes[0] = (byte) newInfo.getChannelNum(); }else { addBytes = GetNewData(newInfo.getChannelNum()); } switch (type) { case SetSwich://设置开关状态 if (state == freshAirOn) { addBytes[2] = 1; } else { addBytes[2] = 0; } break; case SetMode://设置运行模式 addBytes[2] = 1; addBytes[3] = (byte) state; break; case SetEnergySavingMode://设置节能模式 addBytes[2] = 1; addBytes[4] = (byte) state; break; case SetSpeed://设置风速 addBytes[2] = 1; addBytes[5] = (byte) state; break; case SetHumidty://设置湿度 addBytes[2] = 1; addBytes[6] = (byte) state; break; } return addBytes; } catch (Exception e) { e.printStackTrace(); return new byte[]{fail}; } } public static byte[] GetNewData(int mChannelNum){ byte[] addBytes = new byte[11]; addBytes[0] = (byte) mChannelNum; addBytes[1] = 0; addBytes[2] = 0;//开关 addBytes[3] = (byte)1; addBytes[4] = (byte)1; addBytes[5] = (byte)0; addBytes[6] = (byte)0; addBytes[7] = (byte)28; addBytes[8] = (byte)0; addBytes[9] = (byte)100; addBytes[10] = (byte)1; return addBytes; } }