From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 139 insertions(+), 11 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
index 561bff8..9a3120f 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -85,7 +85,6 @@
/// <para>鎸佺画鏁版嵁涓婃姤(MomentStatus=0 TriggerZoneStatus>=1锛滄姤璀︼紴 TriggerZoneStatus=0锛滃彇娑堟姤璀︼紴)</para>
/// <para>21: Door/Window 闂ㄧ獥浼犳劅鍣紙鏈�21鍜�22锛岃繖閲屾病鏈夊啓閿欙級</para>
/// <para>22:Door/Window 闂ㄧ獥浼犳劅鍣紙鏈�21鍜�22锛岃繖閲屾病鏈夊啓閿�</para>
- /// <para>541 鐞冨瀷绉诲姩浼犳劅鍣�</para>
/// </summary>
public int IasDeviceType;
/// <summary>
@@ -116,7 +115,7 @@
/// </summary>
public int ZigbeeType;
/// <summary>
- /// 褰撳墠杩愯绋嬪簭鐗堟湰淇℃伅銆� 鏈�澶�64瀛楄妭
+ /// 鍥轰欢鐗堟湰
/// </summary>
public int ImgVersion;
/// <summary>
@@ -158,7 +157,11 @@
/// <summary>
/// 杈撳嚭绨囧垪琛�
/// </summary>
- public List<OutClusterObj> OutClusterList = new List<OutClusterObj>();
+ public List<OutClusterObj> OutClusterList = new List<OutClusterObj>();
+ /// <summary>
+ /// 鐢ㄤ簬璁板綍璁惧鏈�鏂颁笂鎶ョ殑灞炴�х姸鎬佷俊鎭�
+ /// </summary>
+ public List<AttributeStatusObj> AttributeStatus = new List<AttributeStatusObj>();
[Newtonsoft.Json.JsonIgnore]
public DateTime LastDateTime = DateTime.MinValue;
@@ -166,7 +169,13 @@
/// 鏄惁宸茬粡璇诲彇浜嗚澶囩姸鎬�(姝ゅ睘鎬ф槸缁欎富椤典娇鐢ㄧ殑)
/// </summary>
[Newtonsoft.Json.JsonIgnore]
- public bool HadReadDeviceStatu = false;
+ public bool HadReadDeviceStatu = false;
+
+ /// <summary>
+ /// 鏄惁鏄綆鐢甸噺(杩欎釜鍙橀噺鐩墠鏄粰浼犳劅鍣ㄧ敤鐨�)
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public bool IsBatteryDown = false;
/// <summary>
/// 绛夊緟浠庣綉鍏虫帴鏀舵暟鎹殑鏃堕棿
@@ -311,17 +320,28 @@
}
else if (strDeviceType == ZigBee.Device.DeviceType.PMSensor.ToString())
{
- return Newtonsoft.Json.JsonConvert.DeserializeObject<PMSensor>(strDeviceByte);
+ device = Newtonsoft.Json.JsonConvert.DeserializeObject<PMSensor>(strDeviceByte);
}
else if (strDeviceType == ZigBee.Device.DeviceType.ColorTemperatureLight.ToString())
{
- return Newtonsoft.Json.JsonConvert.DeserializeObject<ColorTemperatureLight>(strDeviceByte);
+ device = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorTemperatureLight>(strDeviceByte);
}
else if (strDeviceType == ZigBee.Device.DeviceType.Buzzer.ToString())
{
- return Newtonsoft.Json.JsonConvert.DeserializeObject<Buzzer>(strDeviceByte);
+ device = Newtonsoft.Json.JsonConvert.DeserializeObject<Buzzer>(strDeviceByte);
}
- else { return null; }
+ else if (strDeviceType == ZigBee.Device.DeviceType.ColorDimmableLight.ToString())
+ {
+ device = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorDimmableLight>(strDeviceByte);
+ }
+ else if (strDeviceType == ZigBee.Device.DeviceType.DimmerSwitch.ToString())
+ {
+ device = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmerSwitch>(strDeviceByte);
+ }
+ else
+ {
+ return null;
+ }
//鑳藉皯瀛樹竴涓彉閲忓氨灏戝瓨涓�涓�
device.Type = (DeviceType)device.DeviceID;
@@ -360,6 +380,11 @@
/// </summary>
public void ReSave()
{
+ if (Shared.Common.Config.Instance.Home.IsShowTemplate == true)
+ {
+ //灞曠ず妯℃澘鏃�,涓嶅厑璁镐繚瀛樻枃浠�(闃叉灞炴�т笂鎶ョ敤鐨�)
+ return;
+ }
if (IconPath == string.Empty)
{
//淇濆瓨璁惧鍥炬爣(杩欓噷浼氫繚瀛樹竴娆�,涓嬮潰灏变笉鐢ㄤ繚瀛樹簡)
@@ -465,7 +490,7 @@
/// </summary>
public int AttributeId;
/// <summary>
- /// 灞炴�у�硷紝鏈�澶у崰鐢�4涓瓧鑺�
+ /// 灞炴�у�硷紝杩欎釜涓滆タ涓嶉渶瑕佷粈涔堥珮浣嶅湪鍚庝綆浣嶅湪鍓�,瀹冨凡缁忔槸杞负浜�10杩涘埗
/// </summary>
public int AttributeData;
/// <summary>
@@ -850,6 +875,109 @@
}
#endregion
+ #region 涓�閿洿鏂板洓瀵稿睆鎸夐敭灞炴��
+ /// <summary>
+ /// 鍚屾璁惧鍔熻兘
+ /// </summary>
+ /// <returns></returns>
+ public async System.Threading.Tasks.Task<SynchronizationDeviceResponseAllData> SyncMsgToBindSource(string deviceAddr, int deviceEpoint)
+ {
+ if (Gateway == null)
+ {
+ return null;
+ }
+
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ SynchronizationDeviceResponseAllData resContent = 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)
+ {
+ resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+ else
+ {
+ resContent = new SynchronizationDeviceResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+
+ if (topic == gatewayID + "/" + "Bind/SyncMsgToBindSourceRespon")
+ {
+ var res = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString());
+ if (res == null)
+ {
+ resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ resContent = new SynchronizationDeviceResponseAllData { result = res };
+ System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+ }
+ }
+ };
+ Gateway.Actions = action;
+ DebugPrintLog("Bind/SyncMsgToBindSourceRespon_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5010 } };
+ Gateway.Send("Bind/SyncMsgToBindSource", jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (resContent != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ {
+ resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("Bind/SyncMsgToBindSource_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return resContent;
+ });
+
+ }
+
+ /// <summary>
+ /// 鍚屾璁惧,缃戝叧鍙嶉鍏蜂綋淇℃伅
+ /// </summary>
+ [System.Serializable]
+ public class SynchronizationDeviceResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 鍚屾缁撴灉
+ /// 0:鎴愬姛锛氱綉鍏冲唴閮ㄨ嚜鍔ㄥ啓鍏ヨ澶囩洰鏍囧悕瀛椼�佽澶囩洰鏍囧姛鑳界被鍨嬨�佸満鏅洰鏍囧悕瀛椼�乽tc鏃堕棿鍐欏叆4瀵稿睆
+ /// 1:澶辫触
+ /// </summary>
+ public int result;
+ }
+ #endregion
+
#region 鍒犻櫎璁惧锛堜娇璁惧绂荤綉锛�
/// <summary>
/// 鍒犻櫎璁惧锛堜娇璁惧绂荤綉锛�
@@ -900,7 +1028,7 @@
}
};
Gateway.Actions += action;
- System.Console.WriteLine("RemoveDevice_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
+ DebugPrintLog("RemoveDevice_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
try
{
@@ -938,7 +1066,7 @@
d = new RemoveDeviceResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
Gateway.Actions -= action;
- System.Console.WriteLine("RemoveDevice_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+ DebugPrintLog("RemoveDevice_Actions 閫�鍑�" + System.DateTime.Now.ToString());
return d;
});
--
Gitblit v1.8.0