From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码
---
ZigbeeApp/Shared/Phone/ZigBee/Device/FreshAir.cs | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 231 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/FreshAir.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/FreshAir.cs
new file mode 100755
index 0000000..15d44e8
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/FreshAir.cs
@@ -0,0 +1,231 @@
+锘縰sing System;
+using Newtonsoft.Json.Linq;
+
+namespace ZigBee.Device
+{
+ [System.Serializable]
+ public class FreshAir : CommonDevice
+ {
+ /// <summary>
+ /// 璇ョ被锛堟柊椋庡璞★級鍖呭惈鏂伴璁惧鍜屾柊椋庨潰鏉�
+ /// </summary>
+ public FreshAir()
+ {
+ this.Type = DeviceType.FreshAir;
+ }
+
+ /// <summary>
+ /// 椋庨�熸ā寮�
+ /// <para>5:鑷姩</para>
+ /// <para>6:Smart</para>
+ /// <para>15:鎵嬪姩</para>
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public int currentFanMode = 0;
+ /// <summary>
+ /// 椋庨�熸。浣�
+ /// <para>1:浣庨</para>
+ /// <para>2:涓</para>
+ /// <para>3:楂橀 </para>
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public int currentFanSpeed = 0;
+ /// <summary>
+ /// 椋庢墖鐘舵��
+ /// <para>0:鍏抽棴 </para>
+ /// <para>4:鎵撳紑 </para>
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public int currentFanStatus = 0;
+
+ /// <summary>
+ /// 鍏抽棴
+ /// </summary>
+ /// <returns>The close.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Close()
+ {
+ return await SetFanModeAsync(FanMode.Off);
+ }
+
+ /// <summary>
+ /// 寮�鍚�
+ /// </summary>
+ /// <returns>The open.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Open()
+ {
+ return await SetFanModeAsync(FanMode.On);
+ }
+
+ /// <summary>
+ /// 楂橀
+ /// </summary>
+ /// <returns>The close.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetHighSpeed()
+ {
+ return await SetFanModeAsync(FanMode.High);
+ }
+
+ /// <summary>
+ /// 浣庨
+ /// </summary>
+ /// <returns>The open.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetLowSpeed()
+ {
+ return await SetFanModeAsync(FanMode.Low);
+ }
+
+
+ /// <summary>
+ /// 鎵嬪姩
+ /// </summary>
+ /// <returns>The close.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetManual()
+ {
+ return await SetFanModeAsync(FanMode.Manual);
+ }
+
+ /// <summary>
+ /// 鑷姩
+ /// </summary>
+ /// <returns>The open.</returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetAuto()
+ {
+ return await SetFanModeAsync(FanMode.Auto);
+ }
+
+ ///<summary >
+ ///璁剧疆鎭掓俯鍣ㄨ澶囧綋鍓嶉閫�.
+ /// </summary>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetFanModeAsync(FanMode fanMode)
+ {
+ 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 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", 0 }, { "AttributeDataType", 48 }, { "AttributeData", (int)fanMode } };
+ 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;
+ });
+ }
+
+
+ #region 鈼� 褰撳墠鏂伴寮�鍏崇姸鎬乢___________________
+
+ /// <summary>
+ /// 褰撳墠鏂伴寮�鍏崇姸鎬�
+ /// </summary>
+ /// <param name="freshAir"></param>
+ /// <returns></returns>
+ public bool IsOpen(FreshAir freshAir)
+ {
+ if (freshAir.currentFanStatus == 4)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ #endregion
+
+
+ /// <summary>
+ /// 椋庨�熸。浣�
+ /// </summary>
+ public enum FanMode
+ {
+ /// <summary>
+ /// 鍏抽棴
+ /// </summary>
+ Off = 0,
+ /// <summary>
+ /// 浣庨
+ /// </summary>
+ Low = 1,
+ /// <summary>
+ /// 涓
+ /// </summary>
+ Medium = 2,
+ /// <summary>
+ /// 楂橀
+ /// </summary>
+ High = 3,
+ /// <summary>
+ /// 鎵撳紑
+ /// </summary>
+ On = 4,
+ /// <summary>
+ /// 鑷姩
+ /// </summary>
+ Auto = 5,
+ /// <summary>
+ /// Smart
+ /// </summary>
+ Smart = 6,
+ /// <summary>
+ /// 鎵嬪姩
+ /// </summary>
+ Manual = 15,
+ }
+ }
+}
--
Gitblit v1.8.0