From c4b015770e8a29f18e19cc44b3df46c20a4762f4 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 10 八月 2021 10:17:42 +0800 Subject: [PATCH] 2021-08-10 1.更新 --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 442 ++++++++++++++++++------------------------------------- 1 files changed, 144 insertions(+), 298 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 fdd542d..c253b8d 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 @@ -121,22 +121,59 @@ } /** - * 鐢熸垚榛樿鏁版嵁 + * 鐘舵�佹暟鎹紓甯哥殑鏃跺�欙紝鐢熸垚榛樿绌鸿皟鏁版嵁 + * @return + */ + public static byte[] getNewAcByte() { + byte[] airBytes = new byte[13]; + airBytes[0] = 0; + airBytes[1] = 0; + airBytes[2] = (byte) 28; + airBytes[3] = (byte) 28; + airBytes[4] = (byte) 28; + airBytes[5] = (byte) 28; + airBytes[6] = (byte) 28; + airBytes[7] = 0; + airBytes[8] = 1; + airBytes[9] = 0; + airBytes[10] = 0; + airBytes[11] = (byte) 28; + airBytes[12] = 0; + return airBytes; + } + + /** + * 绠�鏄撶紪绋嬫悳绱� 鐘舵�佹暟鎹産ytes鏍煎紡锛屽姣旀棫鐘舵�佹暟鎹慨鏀规洿鏂扮姸鎬佸鐞嗭紝涓嶇敤绠�鏄撶紪绋嬫悳绱㈠娉ㄦ帴鏀剁姸鎬佺殑璇濓紝璇ユ柟娉曞彲浠ュ拷鐣� * 0 寮�鍏崇姸鎬� * 1 妯″紡 * 2 娓╁害 * 3 椋庨�� - * 4 + * 4 褰撳墠瀹ゆ俯 + * 5 鏄惁鎽嗛 + * * @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; + public static byte[] getNewAcByteWithE44B(byte[] bytes, byte[] oldBytes) { + byte[] airBytes = getNewAcByte(); + if(oldBytes != null && oldBytes.length >= 13){ + airBytes = oldBytes; + } + + if (bytes.length > 5) { +// airBytes[0] = 0; +// airBytes[1] = 0; + airBytes[2] = bytes[4]; +// airBytes[3] = bytes[2]; +// airBytes[4] = bytes[2]; +// airBytes[5] = bytes[2]; +// airBytes[6] = bytes[2]; + airBytes[7] = (byte) ((airBytes[2] & 0xff) * 16 + (airBytes[3] & 0xff)); + airBytes[8] = bytes[0]; + airBytes[9] = bytes[1]; + airBytes[10] = bytes[3]; + airBytes[11] = bytes[2]; + airBytes[12] = bytes[5]; + } return airBytes; } @@ -154,7 +191,7 @@ && 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) { + if (newInfo.getArrCurState() == null || newInfo.getArrCurState().length != 13) { newInfo.setArrCurState(getNewAcByte()); } airBytes = newInfo.getArrCurState(); @@ -166,73 +203,27 @@ } byte[] addBytes = new byte[13]; - if (airBytes != null && airBytes.length >= 6) { + if (airBytes != null && airBytes.length >= 13) { //2020-05-28 濡傛灉娓╁害涓�0鑷姩淇敼涓�28 - if((airBytes[2] & 0xff) == 0){ - airBytes[2] = (byte)28; + if ((airBytes[11] & 0xff) == 0) { + airBytes[11] = (byte) 28; } 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]; + addBytes[2] = airBytes[2]; + addBytes[3] = airBytes[3]; + addBytes[4] = airBytes[4]; + addBytes[5] = airBytes[5]; + addBytes[6] = airBytes[6]; + addBytes[7] = (byte) ((airBytes[9] & 0xff) * 16 + (airBytes[10] & 0xff)); + addBytes[8] = airBytes[8]; + addBytes[9] = airBytes[9]; + addBytes[10] = airBytes[10]; + addBytes[11] = airBytes[11]; + addBytes[12] = airBytes[12]; - 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) ((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; @@ -247,53 +238,87 @@ 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; - } + } + + switch (type) { + case airSwich: + if (state == airOff) { + addBytes[8] = 0; + } else { + addBytes[8] = 1; + } + break; + case refTem: + addBytes[8] = 1; + addBytes[3] = (byte) state; + addBytes[11] = (byte) state; + break; + case heatTem: + addBytes[8] = 1; + addBytes[4] = (byte) state; + addBytes[11] = (byte) state; + break; + case autoTem: + addBytes[8] = 1; + addBytes[5] = (byte) state; + addBytes[11] = (byte) state; + break; + case dehumTem: + addBytes[8] = 1; + addBytes[6] = (byte) state; + addBytes[11] = (byte) state; + break; + case upTem: + addBytes[8] = 1; + byte tempByte = (byte) ((airBytes[11] & 0xff) + state); + //鍒ゆ柇褰撳墠妯″紡 + if(addBytes[9] == 0){//鍒跺喎 + tempByte = (byte) ((airBytes[3] & 0xff) + state); + addBytes[3] = tempByte; + }else if(addBytes[9] == 1){//鍒剁儹 + tempByte = (byte) ((airBytes[4] & 0xff) + state); + addBytes[4] = tempByte; + }else if(addBytes[9] == 3){//鑷姩 + tempByte = (byte) ((airBytes[5] & 0xff) + state); + addBytes[5] = tempByte; + }else if(addBytes[9] == 4){//鎶芥箍 + tempByte = (byte) ((airBytes[6] & 0xff) + state); + addBytes[6] = tempByte; + } + addBytes[11] = tempByte; + break; + case downTem: + addBytes[8] = 1; + byte tempByte2 = (byte) ((airBytes[11] & 0xff) - state); + //鍒ゆ柇褰撳墠妯″紡 + if(addBytes[9] == 0){//鍒跺喎 + tempByte2 = (byte) ((airBytes[3] & 0xff) - state); + addBytes[3] = tempByte2; + }else if(addBytes[9] == 1){//鍒剁儹 + tempByte2 = (byte) ((airBytes[4] & 0xff) - state); + addBytes[4] = tempByte2; + }else if(addBytes[9] == 3){//鑷姩 + tempByte2 = (byte) ((airBytes[5] & 0xff) - state); + addBytes[5] = tempByte2; + }else if(addBytes[9] == 4){//鎶芥箍 + tempByte2 = (byte) ((airBytes[6] & 0xff) - state); + addBytes[6] = tempByte2; + } + addBytes[11] = tempByte2; + break; + case airMode: + addBytes[8] = 1; + addBytes[7] = (byte) (state * 16 + (airBytes[10] & 0xff)); + addBytes[9] = (byte) state; + break; + case airSpeed: + addBytes[8] = 1; + addBytes[7] = (byte) ((airBytes[9] & 0xff) * 16 + state); + addBytes[10] = (byte) state; + break; + } + return addBytes; } catch (Exception e) { e.printStackTrace(); @@ -301,185 +326,6 @@ } -} + } -// public static byte[] getRcuAirAddByte(AppliancesInfo info,int type, int arg2){ -// byte[] addBytes = new byte[9]; -// addBytes[4] = 1; -// byte[] curAirInfo = info.getArrCurState(); -// switch (info.getChannelNum()){ -// case 1: -// curAirInfo = HDLDeviceManager.air1Info; -// break; -// case 2: -// curAirInfo = HDLDeviceManager.air2Info; -// break; -// case 3: -// curAirInfo = HDLDeviceManager.air3Info; -// break; -// case 4: -// curAirInfo = HDLDeviceManager.air4Info; -// break; -// } -// -// byte airSwitch = curAirInfo[0]; -// byte aircurMode = curAirInfo[1]; -// byte airTem = curAirInfo[2]; -// byte aircurSpeed = curAirInfo[3]; -// byte aircurTem = curAirInfo[4]; -// byte airBAIFENG = curAirInfo[5]; -// -// addBytes[0] = (byte) info.getChannelNum(); -// addBytes[1] = airSwitch; -// switch (aircurMode){ -// case 0: -// addBytes[2] = airTem; -// break; -// case 1: -// addBytes[5] = airTem; -// break; -// case 2: -// break; -// case 3: -// addBytes[6] = airTem; -// break; -// } -// addBytes[3] = (byte) ((aircurMode << 4) | aircurSpeed); -// addBytes[4] = 1; -// addBytes[8] = airBAIFENG; -// switch (type){ -// case airSwich: -// if(arg2 == airOff){ -// addBytes[1] = 0; -// }else if(arg2 == airOn){ -// addBytes[1] = 1; -// } -// break; -// case refTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case airSpeed : -// int modifyLow; -// int height = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -// switch (arg2){ -// case airSpeedAuto: -// modifyLow = 0; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedHigh: -// modifyLow = 1; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedMid: -// modifyLow = 2; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedLow: -// modifyLow = 3; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// break; -// case airMode: -// int modify; -// int low = (addBytes[3] & 0x0f);//鑾峰彇浣�4浣� -// switch (arg2){ -// case airModeRefTem: -// -// modify = 0; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeHeatTem: -// modify = 1; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeVen: -// modify = 2; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeAuto: -// modify = 3; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeDehum: -// modify = 4; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// break; -// case heatTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case autoTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case dehumTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case upTem: -//// int height2 = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -//// switch (height2){ -//// case 0: -//// addBytes[2] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 1: -//// addBytes[5] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 3: -//// addBytes[6] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 4: -//// addBytes[7] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// } -// addBytes[2] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[5] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[6] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[7] = (byte) (arg2 + (airTem & 0xFF)); -// break; -// case downTem: -//// int height3= ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -//// switch (height3){ -//// case 0: -//// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 1: -//// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 3: -//// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 4: -//// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// } -// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 ); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// return addBytes; -// } } -- Gitblit v1.8.0