package com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser;
|
|
import com.hdl.sdk.hdl_core.Config.Configuration;
|
import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig;
|
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
|
import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager;
|
|
/**
|
* Created by JLChen on 2019/7/10
|
*/
|
public class GeothermalParser {
|
|
public static final int fail = 0;
|
|
public static final int gSwich = 2;
|
public static final int gSwichOn = 1;//地热模块开
|
public static final int gSwichOff = 0;//地热模块关
|
|
|
public static final int gMode = 4; //模式
|
public static final int gModeNormal = 1;//普通模式
|
public static final int gModeDay = 2;//白天模式
|
public static final int gModeNight = 3;//夜间模式
|
public static final int gModeLeave = 4;//离开模式
|
public static final int gModeAuto = 5;//自动模式
|
|
public static final int gNormalTemp = 5;//普通模式温度
|
public static final int gDayTemp = 6;//白天模式温度
|
public static final int gNightTemp = 7;//夜间模式温度
|
public static final int gLeaveTemp = 8;//离开模式温度
|
|
// feedbackState [回路,开关状态,温度类型,模式,普通温度,白天温度,夜间温度,离开温度,自动温度,当前温度]
|
public static byte[] getGeothermalAddByte(AppliancesInfo appliancesInfo, int type, int state) {
|
try {
|
AppliancesInfo newInfo = null;
|
byte[] airBytes = null;
|
outter:
|
for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) {
|
if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID()
|
&& appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) {
|
for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) {
|
if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE
|
&& HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE
|
&& appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) {
|
newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j);
|
if (newInfo.getFeedbackState() == null) {
|
newInfo.setFeedbackState(new byte[10]);
|
}
|
airBytes = newInfo.getFeedbackState();
|
break outter;
|
}
|
|
}
|
}
|
}
|
|
byte[] addBytes = new byte[10];
|
if (airBytes != null && airBytes.length >= 10) {
|
addBytes[0] = (byte) newInfo.getChannelNum();
|
addBytes[1] = airBytes[1];
|
addBytes[2] = 0;
|
addBytes[3] = airBytes[3];
|
addBytes[4] = airBytes[4];
|
addBytes[5] = airBytes[5];
|
addBytes[6] = airBytes[6];
|
addBytes[7] = airBytes[7];
|
addBytes[8] = 0;
|
addBytes[9] = 0;
|
} else {
|
addBytes[0] = (byte) newInfo.getChannelNum();
|
addBytes[1] = 0;
|
addBytes[2] = 0;
|
addBytes[3] = 1;
|
addBytes[4] = 30;
|
addBytes[5] = 30;
|
addBytes[6] = 30;
|
addBytes[7] = 30;
|
addBytes[8] = 0;
|
addBytes[9] = 0;
|
}
|
|
switch (type) {
|
case gSwich:
|
if (state == gSwichOff) {
|
addBytes[1] = 0;
|
} else {
|
addBytes[1] = 1;
|
}
|
break;
|
case gMode:
|
addBytes[1] = 1;
|
addBytes[3] = (byte) state;
|
break;
|
case gNormalTemp:
|
addBytes[1] = 1;//打开
|
addBytes[4] = (byte) state;
|
break;
|
case gDayTemp:
|
addBytes[1] = 1;//打开
|
addBytes[5] = (byte) state;
|
break;
|
case gNightTemp:
|
addBytes[1] = 1;//打开
|
addBytes[6] = (byte) state;
|
break;
|
case gLeaveTemp:
|
addBytes[1] = 1;//打开
|
addBytes[7] = (byte) state;
|
break;
|
}
|
return addBytes;
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new byte[]{fail};
|
}
|
|
}
|
|
|
}
|