From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 13 十一月 2019 15:36:28 +0800 Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了 --- ZigbeeApp/Shared/Phone/ZigBee/Device/AC.cs | 129 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 129 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/AC.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/AC.cs index b8477ee..bcaec98 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/AC.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/AC.cs @@ -71,6 +71,17 @@ public int currentFanMode = 0; /// <summary> + /// 椋庢墖zz鎵褰撳墠妯″紡 + /// <para>0:1鎸� </para> + /// <para>1:2</para> + /// <para>2:3</para> + /// <para>3:4 </para> + /// <para>4:5 </para> + /// <para>7:Auto </para> + /// </summary> + public int currentFanSwingMode = 0; + + /// <summary> /// 鏀寔鐨勬帶鍒舵ā寮� /// </summary> public List<AcMode> acModes = new List<AcMode> { }; @@ -167,6 +178,124 @@ ReadAttri(Device.Cluster_ID.Thermostat, AttriButeId.AcModeSupport); } + /// <summary> + /// 鎵妯″紡 + /// </summary> + public enum FanSwingMode + { + /// <summary> + /// 涓�妗� + /// </summary> + First = 0, + /// <summary> + /// 浜屾尅 + /// </summary> + Second = 1, + /// <summary> + /// 涓夋尅 + /// </summary> + Thrid = 2, + /// <summary> + /// 鍥涙尅 + /// </summary> + Fourth = 3, + /// <summary> + /// 浜旀。 + /// </summary> + Fifth = 4, + /// <summary> + /// 鑷姩 + /// </summary> + Auto = 7 + } + /// <summary> + /// 鑾峰彇鎵妯″紡 + /// </summary> + public void ReadSystemFansSwingMode() + { + ReadAttri(Device.Cluster_ID.FanSwing, AttriButeId.FanSwing); + } + /// <summary> + /// 璁剧疆鎵妯″紡 + /// </summary> + /// <param name="fanSwing"></param> + /// <returns></returns> + public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetFanSwingAsyncMode(FanSwingMode fanSwing) + { + if (Gateway == null) + { + return null; + } + return await System.Threading.Tasks.Task.Run(async () => + { + SetWritableValueResponAllData d = null; + 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 gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); + + if (temp == null) + { + d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + } + else + { + d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; + } + } + + if (topic == gatewayID + "/" + "SetWritableValue_Respon") + { + var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); + + if (tempData == null) + { + d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; + } + else + { + d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; + DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); + } + } + }; + Gateway.Actions += action; + DebugPrintLog("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); + try + { + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 514 }, { "Command", 120 } }; + var data = new JObject { { "Undivided", 0 }, { "AttributeId", 4096 }, { "AttributeDataType", 48 }, { "AttributeData", (int)fanSwing } }; + jObject.Add("Data", data); + Gateway.Send("SetWritableValue", jObject.ToString()); + } + catch { } + + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) + { + await System.Threading.Tasks.Task.Delay(10); + if (d != null) + { + break; + } + } + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) + { + d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + } + Gateway.Actions -= action; + DebugPrintLog("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString()); + return d; + }); + } + + ///<summary > ///璁剧疆鍒跺喎搴︽暟. /// </summary> -- Gitblit v1.8.0