From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 02 四月 2020 13:56:39 +0800
Subject: [PATCH] 2020-04-02-2

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs |   76 +++++++++++++++++++++++++-------------
 1 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs
index 7c6d30a..78f02ed 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs
@@ -16,7 +16,7 @@
         /// WcdType=4锛氬紑鍚堝笜
         /// WcdType=0锛氬嵎甯�
         /// </summary>
-        public int WcdType = 0;
+        public int WcdType = -1;
 
         /// <summary>
         ///绐楀笜褰撳墠楂樺害锛屽崟浣嶏細cm.
@@ -44,7 +44,7 @@
         //        return 0;
         //    }
         //}
-
+
         /// <summary>
         /// 绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑瑙掑害锛屽崟浣嶏細0.1掳
         /// </summary>
@@ -91,6 +91,30 @@
         public void ReadWcdType()
         {
             ReadAttri(Device.Cluster_ID.WindowCovering, AttriButeId.WindowCoveringType);
+        }
+
+        /// <summary>
+        /// 璇诲彇褰撳墠绐楀笜妯″紡
+        /// </summary>
+        /// <param name="commonDevice"></param>
+        /// <param name="action"></param>
+        public static void ReadWcdTypeAction(CommonDevice commonDevice, Action action)
+        {
+            new System.Threading.Thread(() =>
+            {
+                (commonDevice as Rollershade).ReadWcdType();
+                var dateTime = DateTime.Now;
+                while ((DateTime.Now - dateTime).TotalSeconds < 10)
+                {
+                    System.Threading.Thread.Sleep(100);
+                    if ((commonDevice as Rollershade).WcdType != -1)
+                    {
+                        break;
+                    }
+                }
+                action?.Invoke();
+            })
+            { IsBackground = true }.Start();
         }
 
         /// <summary>
@@ -209,7 +233,7 @@
             var data = new JObject {
                     { "Value", value }
                  };
-            jObject.Add("Data", data);
+            jObject.Add("Data", data);
             Gateway?.Send("DeviceControl", jObject.ToString());
         }
 
@@ -231,7 +255,7 @@
             var data = new JObject {
                     { "Value", value }
                  };
-            jObject.Add("Data", data);
+            jObject.Add("Data", data);
             Gateway?.Send("DeviceControl", jObject.ToString());
         }
 
@@ -253,7 +277,7 @@
             var data = new JObject {
                     { "Value", value }
                 };
-            jObject.Add("Data", data);
+            jObject.Add("Data", data);
             Gateway?.Send("DeviceControl", jObject.ToString());
         }
 
@@ -276,7 +300,7 @@
             var data = new JObject {
                     { "Value", value }
                  };
-            jObject.Add("Data", data);
+            jObject.Add("Data", data);
             Gateway?.Send("DeviceControl", jObject.ToString());
         }
 
@@ -336,15 +360,15 @@
                 try
                 {
                     int attributeData = 0;
-                    int bit0 = 0;
+                    int bit0 = 0;
                     if (isDirectionReversed)
                     {
                         bit0 = 1;
-                    }
+                    }
                     attributeData = bit0 * 1;
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } };
                     var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } };
-                    jObject.Add("Data", data);
+                    jObject.Add("Data", data);
                     Gateway.Send("SetWritableValue", jObject.ToString());
                 }
                 catch { }
@@ -425,9 +449,9 @@
 
                 try
                 {
-                    int attributeData = 0;
-                    int bit2 = 0;
-
+                    int attributeData = 0;
+                    int bit2 = 0;
+
                     if (isMotorMaintenance)
                     {
                         bit2 = 1;
@@ -435,7 +459,7 @@
                     attributeData = bit2 * 4;
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } };
                     var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } };
-                    jObject.Add("Data", data);
+                    jObject.Add("Data", data);
                     Gateway.Send("SetWritableValue", jObject.ToString());
                 }
                 catch { }
@@ -519,15 +543,15 @@
                     switch (installedLimit)
                     {
                         case CurtainPrivateInstalledLimi.UpLimit:
-                            tempLimit = 1;
+                            tempLimit = 2;
                             break;
                         case CurtainPrivateInstalledLimi.DownLimit:
-                            tempLimit = 2;
+                            tempLimit = 1;
                             break;
                     }
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } };
                     var data = new JObject { { "Undivided", 0 }, { "AttributeId", 0xea01 }, { "AttributeDataType", 32 }, { "AttributeData", tempLimit } };
-                    jObject.Add("Data", data);
+                    jObject.Add("Data", data);
                     Gateway.Send("SetWritableValue", jObject.ToString());
                 }
                 catch { }
@@ -560,11 +584,11 @@
             /// <summary>
             /// 绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑浣嶇疆(涓婇檺浣�)
             /// </summary>
-            UpLimit = 1,
+            UpLimit = 2,
             /// <summary>
             /// 绐楀笜鍏ㄥ叧鎵�鍦ㄧ殑浣嶇疆(涓嬮檺浣�)
             /// </summary>
-            DownLimit = 2,
+            DownLimit = 1,
 
         }
         #endregion
@@ -622,11 +646,11 @@
                 System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
 
                 try
-                {
-
+                {
+
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } };
                     var data = new JObject { { "Undivided", 0 }, { "AttributeId", 0xea02 }, { "AttributeDataType", 32 }, { "AttributeData", 1 } };
-                    jObject.Add("Data", data);
+                    jObject.Add("Data", data);
                     Gateway.Send("SetWritableValue", jObject.ToString());
                 }
                 catch { }
@@ -726,10 +750,10 @@
                     switch (limiType)
                     {
                         case LimiType.DownLimit:
-                            tempLimit = 8;
+                            tempLimit = 2;
                             break;
                         case LimiType.UpLimit:
-                            tempLimit = 2;
+                            tempLimit = 8;
                             break;
                     }
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } };
@@ -767,13 +791,13 @@
             /// <summary>
             /// 鍒犻櫎绐楀笜涓婇檺浣�
             /// </summary>
-            UpLimit = 0x02,
+            UpLimit = 0x08,
             /// <summary>
             /// 鍒犻櫎绐楀笜涓嬮檺浣�
             /// </summary>
-            DownLimit = 0x08,
+            DownLimit = 0x02,
 
-        }
+        }
         #endregion
     }
 }

--
Gitblit v1.8.0