| | |
| | | } |
| | | |
| | | /** |
| | | * 生成默认数据 |
| | | * 状态数据异常的时候,生成默认空调数据 |
| | | * @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; |
| | | } |
| | | |
| | | /** |
| | | * 简易编程搜索 状态数据bytes格式,对比旧状态数据修改更新状态处理,不用简易编程搜索备注接收状态的话,该方法可以忽略 |
| | | * 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; |
| | | } |
| | | |
| | |
| | | && 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(); |
| | |
| | | } |
| | | |
| | | 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; |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | // 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; |
| | | // } |
| | | } |