From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs | 189 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 183 insertions(+), 6 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs index d9fc339..aed8f7a 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs @@ -15,10 +15,20 @@ this.Type = DeviceType.OnOffSwitch; } /// <summary> + /// 澶氬姛鑳介潰鏉夸腑琚粦瀹氱殑鐩爣 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public System.Collections.Generic.Dictionary<string, List<BindListAllInfo>> bindTargetsFromMutilfunctionPanelList = new System.Collections.Generic.Dictionary<string, List<BindListAllInfo>>(); + /// <summary> /// 鎸夐敭妯″紡锛堢鏈夊姛鑳斤級 /// </summary> public int panelMode = 65535; - + /// <summary> + ///褰撳墠閫夋嫨鐨勭畝绾﹀鍔熻兘闈㈡澘鐨勭被鍨嬨�愮畝绾﹀鍔熻兘闈㈡澘銆� + /// 0:鍦烘櫙 1:寮�鍏� 2:鎻掑骇 3:鐏厜 4:閬槼 5:绌鸿皟 6:鏂伴 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int currentMutilfunctionBindType = 0; /// <summary> /// 褰撳墠閫夋嫨妯″紡 /// </summary> @@ -318,7 +328,7 @@ /// PIR閰嶇疆鍙傛暟鍥炲 /// </summary> [System.Serializable] - public class PanelPrivateFunctionsResponseAllInfo:ErrorResponCommon + public class PanelPrivateFunctionsResponseAllInfo : ErrorResponCommon { /// <summary> /// 鍏夋劅绛夌骇涓暟锛圠ux鑳藉姏锛� @@ -773,7 +783,6 @@ string dataSerialNum = "01"; string addDataLength = "03"; string kStatus = ""; - string kNum = ""; int attributeData = 0; try @@ -1101,6 +1110,174 @@ } #endregion + #region 鏍℃娓╁害 + ///<summary > + /// 鏍℃娓╁害 + /// </summary> + public async System.Threading.Tasks.Task<ResponseAllData> CorrectTemperature(double correctValue, int direction = 0, int type = 0) + { + ResponseAllData result = null; + if (Gateway == null) + { + result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; + return result; + } + return await System.Threading.Tasks.Task.Run(async () => + { + Action<string, string> action = (topic, message) => + { + var gatewayID = topic.Split('/')[0]; + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + if (topic == gatewayID + "/" + "Error_Respon") + { + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); + + if (temp == null) + { + result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + } + + else + { + result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; + } + } + + if (topic == gatewayID + "/" + "ZbDataPassthrough") + { + var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); + + if (clientDataPassthroughResponseData == null) + { + result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; + } + else + { + if (clientDataPassthroughResponseData?.PassData != null) + { + var data = clientDataPassthroughResponseData.PassData; + if (data.Length == 16) + { + var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); + if (command == "0002") + { + var tempD = new ResponseData(); + tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); + if (tempD.command == "0503") + { + result = new ResponseAllData { responseData = tempD }; + DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0500_{ topic}"); + } + } + } + } + } + } + }; + + Gateway.Actions += action; + System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); + + try + { + var passData = CorrectTemperatureData(correctValue,direction, type); + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); + } + catch { } + + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) + { + await System.Threading.Tasks.Task.Delay(10); + if (result != null) + { + break; + } + } + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) + { + result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + } + Gateway.Actions -= action; + System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); + + return result; + }); + } + + /// <summary> + /// 鏍℃娓╁害 + /// [璇ユ潯鍗忚鍙﹀2涓弬鏁癠I鍜岃澶囬兘涓嶉渶瑕侊紝璁惧閮藉悓浜嬭姹備紶鎰熷櫒璺濈鍜屼紶鎰熷櫒瑙﹀彂寤惰繜鏃堕棿閮介粯璁ゆ槸FFFF] + /// </summary> + /// <param name="correctValue">鏍℃娓╁害鍊�</param> + /// <returns></returns> + string CorrectTemperatureData(double correctValue,int direction=0, int type = 0) + { + string data = ""; + string dataLength = "09"; + string dataComand1 = "03"; + string dataComand2 = "05"; + string dataSerialNum = "01"; + string addDataLength = "05"; + string typeString = ""; + string directString = ""; + string correctValueString = ""; + try + { + if (type == 1) + { + typeString = "0100"; + } + else + { + typeString = "0000"; + } + + if (direction == 1) + { + directString = "01"; + } + else if (direction == 2) + { + directString = "02"; + } + else + { + directString = "00"; + } + + int curV = (int)(correctValue * 100); + var tempBytes = new byte[2]; + for (int i = 0; i < 2; i++) + { + tempBytes[i] = (byte)(curV >> (i * 8) & 0xff); + } + var curV1 = Convert.ToString(tempBytes[0], 16); + var curV2 = Convert.ToString(tempBytes[1], 16); + if (curV1.Length == 1) + { + curV1 = "0" + curV1; + } + if (curV2.Length == 1) + { + curV2 = "0" + curV2; + } + + correctValueString = (curV1 + curV2).ToUpper(); + data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + typeString + directString + correctValueString; + } + catch { }; + + return data; + } + #endregion + #region 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�. /// <summary> @@ -1145,12 +1322,12 @@ /// </summary> public ErrorResponData errorResponData; /// <summary> - ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��) + ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��,鎴栬�� 1-6骞叉帴鐐圭殑鑳屽厜鐏�) /// </summary> public int panelDirectionsLevel = -1; /// <summary> - /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��) + /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��,鎴栬�� 绗竷骞叉帴鐐圭殑鑳屽厜鐏�) /// </summary> public int panelBacklightLevel = -1; } @@ -1361,7 +1538,7 @@ /// 浼犳劅鍣ㄤ娇鑳� ///false-disable true-enable /// </summary> - public bool enable; + public bool enable= false; /// <summary> ///浼犳劅鍣ㄨ窛绂� -- Gitblit v1.8.0