From 69afac92a320033297d71e901e3c5b65e690f0b2 Mon Sep 17 00:00:00 2001
From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com>
Date: 星期二, 12 十一月 2024 11:42:15 +0800
Subject: [PATCH] 增加knx科技系统温度0.5支持

---
 HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java |   87 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 78 insertions(+), 9 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 29eab72..bada758 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();
 
@@ -273,11 +275,12 @@
             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_TECHSYS
+                                && (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) {
@@ -410,4 +413,70 @@
         }
 
     }
-}
+
+    public static byte[] getAirKNXTechAddByte(AppliancesInfo appliancesInfo, int type, float temp) {
+
+        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_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();
+
+                Log.d("panlili", "---temp=" + temp);
+                String tempStr = String.valueOf(temp).trim();
+                String[] strByte = tempStr.split("\\.");
+                int tempInt = Integer.parseInt(strByte[0]);
+                int tempFloat = Integer.parseInt(strByte[1]);
+
+                switch (type) {
+                    case refTem:
+                    case heatTem:
+                    case autoTem:
+                    case dehumTem://璁剧疆娓╁害
+                        addBytes[8] = 1;
+
+                        addBytes[3] = (byte) tempInt;
+                        addBytes[4] = (byte) tempInt;
+                        addBytes[5] = (byte) tempInt;
+                        addBytes[6] = (byte) tempInt;
+                        addBytes[11] = (byte) tempInt;
+
+                        addBytes[14] = (byte) tempFloat;
+                        addBytes[15] = (byte) tempFloat;
+                        addBytes[16] = (byte) tempFloat;
+                        addBytes[17] = (byte) tempFloat;
+                        addBytes[18] = (byte) tempFloat;
+
+                        break;
+                }
+            }
+
+            return addBytes;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new byte[]{fail};
+        }
+
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0