From 4f841eac608f6f22a573b4f7ed713679e89c2e5b Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 30 九月 2019 13:47:49 +0800 Subject: [PATCH] 2019-9-30 1.修改方案,解决不支持控制5台以上空调问题。 --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 253 +++++++++++++++++++++++++++++++------------------ 1 files changed, 159 insertions(+), 94 deletions(-) diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java index b2f4f1c..b31e4db 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java @@ -120,114 +120,179 @@ return addBytes; } + /** + * 鐢熸垚榛樿鏁版嵁 + * + * @return + */ + public static byte[] getNewAcByte() { + byte[] airBytes = new byte[6]; + airBytes[0] = (byte) 0; + airBytes[1] = (byte) 0; + airBytes[2] = (byte) 28; + airBytes[3] = (byte) 0; + airBytes[4] = (byte) 28; + airBytes[5] = (byte) 0; + return airBytes; + } + public static byte[] getAcAddByte(AppliancesInfo appliancesInfo, int type, int state) { - 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.AIR_BIG_TYPE - && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() != HDLApConfig.TYPE_AC_PANEL - && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { - newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); - switch (newInfo.getChannelNum()) { - case 1: - airBytes = HDLDeviceManager.air1Info; - break; - case 2: - airBytes = HDLDeviceManager.air2Info; - break; - case 3: - airBytes = HDLDeviceManager.air3Info; - break; - case 4: - airBytes = HDLDeviceManager.air4Info; - break; - default: - airBytes = new byte[6]; - break; + 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.AIR_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() != HDLApConfig.TYPE_AC_PANEL + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getArrCurState() == null || newInfo.getArrCurState().length != 6) { + newInfo.setArrCurState(getNewAcByte()); + } + airBytes = newInfo.getArrCurState(); + break outter; } - if (newInfo.getArrCurState() == null) { - newInfo.setArrCurState(new byte[6]); - } - break outter; + } - } } - } - if (airBytes != null && airBytes.length >= 6) { byte[] addBytes = new byte[13]; - addBytes[0] = (byte) newInfo.getChannelNum(); - addBytes[1] = 0; - addBytes[2] = airBytes[4]; - addBytes[3] = airBytes[2]; - addBytes[4] = airBytes[2]; - addBytes[5] = airBytes[2]; - addBytes[6] = airBytes[2]; - addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + (airBytes[3] & 0xff)); - addBytes[8] = airBytes[0]; - addBytes[9] = airBytes[1]; - addBytes[10] = airBytes[3]; - addBytes[11] = airBytes[2]; - addBytes[12] = airBytes[5]; + if (airBytes != null && airBytes.length >= 6) { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = airBytes[4]; + addBytes[3] = airBytes[2]; + addBytes[4] = airBytes[2]; + addBytes[5] = airBytes[2]; + addBytes[6] = airBytes[2]; + addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + (airBytes[3] & 0xff)); + addBytes[8] = airBytes[0]; + addBytes[9] = airBytes[1]; + addBytes[10] = airBytes[3]; + addBytes[11] = airBytes[2]; + addBytes[12] = airBytes[5]; - switch (type) { - case airSwich: - if (state == airOff) { - addBytes[8] = 0; - } else { + switch (type) { + case airSwich: + if (state == airOff) { + addBytes[8] = 0; + } else { + addBytes[8] = 1; + } + break; + case refTem: + case heatTem: + case autoTem: + case dehumTem: addBytes[8] = 1; - } - break; - case refTem: - case heatTem: - case autoTem: - case dehumTem: - addBytes[8] = 1; - addBytes[3] = (byte) state; - addBytes[4] = (byte) state; - addBytes[5] = (byte) state; - addBytes[6] = (byte) state; - addBytes[11] = (byte) state; - break; - case upTem: - addBytes[8] = 1; - addBytes[3] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[4] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[5] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[6] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[11] = (byte) ((airBytes[2] & 0xff) + state); - break; - case downTem: - addBytes[8] = 1; - addBytes[3] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[4] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[5] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[6] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[11] = (byte) ((airBytes[2] & 0xff) - state); - break; - case airMode: - addBytes[8] = 1; - addBytes[7] = (byte) (state * 16 + (airBytes[3] & 0xff)); - addBytes[9] = (byte) state; - break; - case airSpeed: - addBytes[8] = 1; - addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + state); - addBytes[10] = (byte) state; - break; + addBytes[3] = (byte) state; + addBytes[4] = (byte) state; + addBytes[5] = (byte) state; + addBytes[6] = (byte) state; + addBytes[11] = (byte) state; + break; + case upTem: + addBytes[8] = 1; + addBytes[3] = (byte) ((airBytes[2] & 0xff) + state); + addBytes[4] = (byte) ((airBytes[2] & 0xff) + state); + addBytes[5] = (byte) ((airBytes[2] & 0xff) + state); + addBytes[6] = (byte) ((airBytes[2] & 0xff) + state); + addBytes[11] = (byte) ((airBytes[2] & 0xff) + state); + break; + case downTem: + addBytes[8] = 1; + addBytes[3] = (byte) ((airBytes[2] & 0xff) - state); + addBytes[4] = (byte) ((airBytes[2] & 0xff) - state); + addBytes[5] = (byte) ((airBytes[2] & 0xff) - state); + addBytes[6] = (byte) ((airBytes[2] & 0xff) - state); + addBytes[11] = (byte) ((airBytes[2] & 0xff) - state); + break; + case airMode: + addBytes[8] = 1; + addBytes[7] = (byte) (state * 16 + (airBytes[3] & 0xff)); + addBytes[9] = (byte) state; + break; + case airSpeed: + addBytes[8] = 1; + addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + state); + addBytes[10] = (byte) state; + break; + } + return addBytes; + } else { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = (byte) 28; + addBytes[3] = (byte) 28; + addBytes[4] = (byte) 28; + addBytes[5] = (byte) 28; + addBytes[6] = (byte) 28; + addBytes[7] = 0; + addBytes[8] = 1; + addBytes[9] = 0; + addBytes[10] = 0; + addBytes[11] = (byte) 28; + addBytes[12] = 0; + switch (type) { + case airSwich://璁剧疆寮�鍏崇姸鎬� + if (state == airOff) { + addBytes[8] = 0; + } else { + addBytes[8] = 1; + } + break; + case refTem: + case heatTem: + case autoTem: + case dehumTem://璁剧疆娓╁害 + addBytes[8] = 1; + addBytes[3] = (byte) state; + addBytes[4] = (byte) state; + addBytes[5] = (byte) state; + addBytes[6] = (byte) state; + addBytes[11] = (byte) state; + break; + case upTem://鍗囨俯 + addBytes[8] = 1; + addBytes[3] = (byte) (28 + state); + addBytes[4] = (byte) (28 + state); + addBytes[5] = (byte) (28 + state); + addBytes[6] = (byte) (28 + state); + addBytes[11] = (byte) (28 + state); + break; + case downTem://闄嶆俯 + addBytes[8] = 1; + addBytes[3] = (byte) (28 - state); + addBytes[4] = (byte) (28 - state); + addBytes[5] = (byte) (28 - state); + addBytes[6] = (byte) (28 - state); + addBytes[11] = (byte) (28 - state); + break; + case airMode://璁剧疆绌鸿皟妯″紡 + addBytes[8] = 1; + addBytes[7] = (byte) (state * 16); + addBytes[9] = (byte) state; + break; + case airSpeed://璁剧疆椋庨�� + addBytes[8] = 1; + addBytes[7] = (byte) (state); + addBytes[10] = (byte) state; + break; + } } return addBytes; - } else { - return null; + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; } - } + +} // public static byte[] getRcuAirAddByte(AppliancesInfo info,int type, int arg2){ // byte[] addBytes = new byte[9]; -- Gitblit v1.8.0