From 071a8328823a2861f93ce556a4da3e4119cab1a3 Mon Sep 17 00:00:00 2001
From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com>
Date: 星期四, 19 九月 2024 16:24:28 +0800
Subject: [PATCH] 完成金茂定制功能

---
 HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java |  350 ++++++++++++++++++++++++++-------------------------------
 1 files changed, 159 insertions(+), 191 deletions(-)

diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
index 3827c58..6b0ec25 100644
--- a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
@@ -1,6 +1,8 @@
 package com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser;
 
 
+import android.util.Log;
+
 import com.hdl.sdk.ttl.Config.Configuration;
 import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
 import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
@@ -127,15 +129,15 @@
             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()) {
+                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.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.setArrCurState(new byte[13]);
+                                newInfo.setArrCurState(new byte[19]);
                             }
                             airBytes = newInfo.getArrCurState();
                             break outter;
@@ -144,8 +146,8 @@
                     }
                 }
             }
-            byte[] addBytes = new byte[13];
-            if (airBytes != null && airBytes.length >= 13) {
+            byte[] addBytes = new byte[19];
+            if (airBytes != null && airBytes.length >= 19) {
                 System.arraycopy(airBytes, 0, addBytes, 0, airBytes.length);
                 addBytes[0] = (byte) newInfo.getChannelNum();
 
@@ -195,19 +197,19 @@
                         addBytes[10] = (byte) state;
                         break;
                 }
-            }else {
+            } 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[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[11] = (byte) 28;
                 addBytes[12] = 0;
                 switch (type) {
                     case airSwich://璁剧疆寮�鍏崇姸鎬�
@@ -266,183 +268,149 @@
 
     }
 
-//    public static byte[] getRcuAirAddByte(AppliancesInfo I,int type, int arg2){
-//        byte[] addBytes = new byte[9];
-//        addBytes[4] = 1;
-//        byte[] curAirInfo = I.getArrCurState();
-//        switch (I.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) I.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;
-//    }
+    public static byte[] getAirTechAddByte(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).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.AIR_BIG_TYPE
+                                && (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_AC_TECHSYS
+                                || HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_AC_KNXTECHSYS)
+                                && 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[19]);
+                            }
+                            airBytes = newInfo.getArrCurState();
+                            break outter;
+                        }
+
+                    }
+                }
+            }
+            byte[] addBytes = new byte[19];
+            if (airBytes != null && airBytes.length >= 19) {
+                System.arraycopy(airBytes, 0, addBytes, 0, airBytes.length);
+                addBytes[0] = (byte) newInfo.getChannelNum();
+
+                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;
+                }
+            } 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;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new byte[]{fail};
+        }
+
+    }
 }

--
Gitblit v1.8.0