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 2019/7/9
|
*/
|
public class FreshAirParser {
|
// 附加数据: 新风通道号(1 - 200) + 开关(0,1) + 风速(0 关,1低,2中,3高) + 模式(0手动,1 自动,2 智能,3 定时)
|
public static final int fail = 0;
|
|
public static final int freshAirSwich = 0;
|
public static final int freshAirOn = 1;//新风开
|
public static final int freshAirOff = 0;//新风关
|
|
public static final int freshAirSpeed = 1;//风速
|
public static final int freshAirSpeedAuto = 0;//风速关
|
public static final int freshAirSpeedLow = 1;//风速低
|
public static final int freshAirSpeedMid = 2;//风速中
|
public static final int freshAirSpeedHigh = 3;//风速高
|
|
public static final int freshAirMode = 2;//模式
|
public static final int freshAirModeManual = 0;//手动
|
public static final int freshAirModeAuto = 1;//自动
|
public static final int freshAirModeIntelligent = 2;//智能
|
public static final int freshAirModeTiming = 3;//定时
|
|
public static byte[] getFreshAirAddByte(AppliancesInfo appliancesInfo, int type, int state) {
|
if (state > 3) {
|
return new byte[]{fail};
|
}
|
|
try {
|
AppliancesInfo newInfo = null;
|
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
|
&& appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) {
|
newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j);
|
if (newInfo.getArrCurState() == null) {
|
newInfo.setArrCurState(new byte[30]);
|
}
|
freshAirBytes = newInfo.getArrCurState();
|
break outter;
|
}
|
|
}
|
}
|
}
|
|
byte[] addBytes = new byte[4];
|
if (freshAirBytes != null && freshAirBytes.length >= 4) {
|
addBytes[0] = (byte) appliancesInfo.getChannelNum();
|
addBytes[1] = freshAirBytes[1];
|
addBytes[2] = freshAirBytes[2];
|
addBytes[3] = freshAirBytes[3];
|
|
} else {
|
addBytes[0] = (byte) appliancesInfo.getChannelNum();
|
addBytes[1] = 0;//发送默认参数
|
addBytes[2] = 0;
|
addBytes[3] = 0;
|
}
|
|
switch (type) {
|
case freshAirSwich:
|
if (state == freshAirOff) {
|
addBytes[1] = 0;
|
} else {
|
addBytes[1] = 1;
|
}
|
break;
|
case freshAirSpeed:
|
addBytes[1] = 1;//打开操作
|
addBytes[2] = (byte) state;
|
break;
|
case freshAirMode:
|
addBytes[1] = 1;//打开操作
|
addBytes[3] = (byte) state;
|
break;
|
}
|
return addBytes;
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new byte[]{fail};
|
}
|
|
}
|
|
}
|