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/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs | 251 +-------------------------------------------------
1 files changed, 6 insertions(+), 245 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs
index 03de7f2..ce0fe1a 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs
@@ -31,14 +31,6 @@
}
}
- /// <summary>
- /// 璁惧鑾峰彇纭欢淇℃伅鍚庣殑鍥炶皟鍑芥暟
- /// </summary>
- private Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>> dicDeviceHardInfoBackAction = new Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>>();
- /// 鑾峰彇纭欢淇℃伅鐨勫璞¤澶�
- /// </summary>
- private HashSet<string> hsGetHardInfoDevice = new HashSet<string>();
-
#endregion
#region 鈻� 涓诲叆鍙e嚱鏁癬________________________
@@ -48,55 +40,13 @@
/// </summary>
/// <param name="device">璁惧鍥炶矾</param>
/// <param name="backAction">鍥炶皟鍑芥暟</param>
- public void SetAllHardFirmwareInfoToDevice(CommonDevice device, Action<CommonDevice, CommonDevice.DeviceStatusReportData> backAction = null)
+ public void SetAllHardFirmwareInfoToDevice(CommonDevice device)
{
if (device == null)
{
return;
}
- lock (hsGetHardInfoDevice)
- {
- //鍏堢Щ闄�
- this.RemoveDeviceHardInfoThread(device);
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
- this.hsGetHardInfoDevice.Add(mainkeys);
-
- if (backAction != null)
- {
- //鍥炶皟鍑芥暟
- this.dicDeviceHardInfoBackAction[mainkeys] = backAction;
- }
- //璁剧疆璁惧鐨勭‖浠朵俊鎭�(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼)
- this.SetHardFirmwareInfoToDevice(device);
- }
- }
-
- /// <summary>
- /// 璁剧疆璁惧鐨勭‖浠朵俊鎭�(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼)
- /// </summary>
- /// <param name="device"></param>
- private void SetHardFirmwareInfoToDevice(CommonDevice device)
- {
- if (HdlGatewayReceiveLogic.Current.IsEsixt("DeviceGetHardFirmwareInfo") == false)
- {
- //娣诲姞浜嬩欢
- HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceGetHardFirmwareInfo", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, this.SetHardFirmwareInfoByInterfaceResult);
- }
- //鍙戦�佸懡浠�
- this.SetHardFirmwareInfoComand(device);
- }
-
- #endregion
-
- #region 鈻� 鍙戦�佸懡浠__________________________
-
- /// <summary>
- /// 鍙戦�佽幏鍙栫‖浠朵俊鎭殑鍛戒护
- /// </summary>
- /// <param name="device"></param>
- public void SetHardFirmwareInfoComand(CommonDevice device)
- {
var jObject = new Newtonsoft.Json.Linq.JObject
{
{ "DeviceAddr",device.DeviceAddr },
@@ -108,217 +58,28 @@
{
new Newtonsoft.Json.Linq.JObject
{
- { "AttriButeId", 4}
+ { "AttriButeId", 4}//鐢熶骇鍟嗗悕瀛�
},
new Newtonsoft.Json.Linq.JObject
{
- { "AttriButeId", 5}
+ { "AttriButeId", 5}//鍨嬪彿鐮�(涔熷彨妯″潡ID)
},
new Newtonsoft.Json.Linq.JObject
{
- { "AttriButeId", 6}
+ { "AttriButeId", 6}//鐢熶骇鏃ユ湡
},
new Newtonsoft.Json.Linq.JObject
{
- { "AttriButeId", 7}
+ { "AttriButeId", 7}//鐢垫簮
},
new Newtonsoft.Json.Linq.JObject
{
- { "AttriButeId", 13}
+ { "AttriButeId", 13}//搴忓垪鍙�
}
};
var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
jObject.Add("Data", data);
device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString());
- }
-
- #endregion
-
- #region 鈻� 璁剧疆灞炴�__________________________
-
- /// <summary>
- /// 璁剧疆璁惧鐨勭‖浠朵俊鎭� -1:寮傚父 0:鎺ㄩ�佺殑杩欎釜涓滆タ骞朵笉鏄‖浠朵俊鎭� 1:姝e父
- /// </summary>
- /// <param name="report">涓婃姤淇℃伅</param>
- /// <param name="device">璁惧瀵硅薄</param>
- /// <returns></returns>
- public int SetHardFirmwareInfo(CommonDevice.DeviceStatusReportData report, CommonDevice device)
- {
- if (report == null)
- {
- return -1;
- }
- //灞炴�ф槸鍚︽敼鍙�
- bool AttriButeChanged = false;
- //鏄惁鏄纭殑鎺ㄩ�佹暟鎹�
- bool isRightData = false;
- foreach (var data in report.AttriBute)
- {
- //鐢熶骇鍟嗗悕瀛�
- if (data.AttributeId == 4)
- {
- isRightData = true;
- if (data.AttriButeDataHex.Length > 2)
- {
- var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
- if (device.ManufacturerName != value)
- {
- //灞炴�у彉鏇翠簡
- AttriButeChanged = true;
- }
- device.ManufacturerName = value;
- }
- }
- //鍨嬪彿鐮�(涔熷彨妯″潡ID)
- if (data.AttributeId == 5)
- {
- isRightData = true;
- if (data.AttriButeDataHex.Length > 2)
- {
- var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
- if (device.ModelIdentifier != value)
- {
- //灞炴�у彉鏇翠簡
- AttriButeChanged = true;
- }
- device.ModelIdentifier = value;
- }
- }
- //鐢熶骇鏃ユ湡
- if (data.AttributeId == 6)
- {
- isRightData = true;
- if (data.AttriButeDataHex.Length > 2)
- {
- var value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
- if (device.ProductionDate != value)
- {
- //灞炴�у彉鏇翠簡
- AttriButeChanged = true;
- }
- device.ProductionDate = value;
- }
- }
- //鐢垫簮
- if (data.AttributeId == 7)
- {
- isRightData = true;
- device.PowerSource = data.AttriButeData;
- }
- //搴忓垪鍙�
- if (data.AttributeId == 13)
- {
- isRightData = true;
- if (data.AttriButeDataHex.Length > 2)
- {
- string value;
- if (Common.LocalDevice.Current.IsHdlDevice(device) == false)
- {
- //绗笁鏂硅澶�
- value = data.AttriButeDataHex.Substring(2);
- }
- else
- {
- //娌充笢璁惧
- value = UserCenterLogic.TranslateHexadecimalIntoText(data.AttriButeDataHex.Substring(2));
- }
- if (device.SerialNumber != value)
- {
- //灞炴�у彉鏇翠簡
- AttriButeChanged = true;
- }
- device.SerialNumber = value;
- }
- }
- }
- if (isRightData == false)
- {
- //杩欎釜涓嶆槸纭欢淇℃伅鐨勬帹閫�
- return 0;
- }
-
- //濡傛灉灞炴�у彉鏇翠簡
- if (AttriButeChanged == true)
- {
- if (device.IsCustomizeImage == false)
- {
- //UI閲嶆柊鐢熸垚
- device.IconPath = string.Empty;
- device.ReSave();
- }
- }
- return 1;
- }
-
- #endregion
-
- #region 鈻� 鎺ュ彛鎺ㄩ�佸鐞哶______________________
-
- /// <summary>
- /// 鏍规嵁鎺ュ彛鎺ㄩ�佺殑淇℃伅锛岃缃澶囩‖浠朵俊鎭�
- /// </summary>
- /// <param name="device"></param>
- private void SetHardFirmwareInfoByInterfaceResult(CommonDevice device)
- {
- string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
- if (this.hsGetHardInfoDevice.Contains(mainKeys) == false)
- {
- //鎺ㄩ�佺殑杩欎釜涓滆タ骞朵笉鏄寚瀹氱殑璁惧
- return;
- }
- //璁剧疆璁惧纭欢淇℃伅
- var localDevice = Common.LocalDevice.Current.GetDevice(mainKeys);
- if (localDevice == null)
- {
- return;
- }
- lock (hsGetHardInfoDevice)
- {
- //-1:寮傚父 0:鎺ㄩ�佺殑杩欎釜涓滆タ骞朵笉鏄‖浠朵俊鎭� 1:姝e父
- if (this.SetHardFirmwareInfo(device.DeviceStatusReport, localDevice) != 1)
- {
- return;
- }
- localDevice.ReSave();
-
- this.hsGetHardInfoDevice.Remove(mainKeys);
- if (this.dicDeviceHardInfoBackAction.ContainsKey(mainKeys) == true)
- {
- var action = this.dicDeviceHardInfoBackAction[mainKeys];
- //璋冪敤鍥炶皟鍑芥暟
- action?.Invoke(device, device.DeviceStatusReport);
- //鐒跺悗绉婚櫎
- this.dicDeviceHardInfoBackAction.Remove(mainKeys);
- action = null;
- }
- }
- }
-
- #endregion
-
- #region 鈻� 绉婚櫎鐩戝惉绾跨▼_______________________
-
- /// <summary>
- /// 绉婚櫎鑾峰彇璁惧纭欢淇℃伅鐨勭洃鍚嚎绋�
- /// </summary>
- /// <param name="device"></param>
- public void RemoveDeviceHardInfoThread(CommonDevice device)
- {
- lock (hsGetHardInfoDevice)
- {
- string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
- if (this.hsGetHardInfoDevice.Contains(mainKeys) == true)
- {
- this.hsGetHardInfoDevice.Remove(mainKeys);
- }
- if (this.dicDeviceHardInfoBackAction.ContainsKey(mainKeys) == true)
- {
- var action = this.dicDeviceHardInfoBackAction[mainKeys];
- //鐒跺悗绉婚櫎
- this.dicDeviceHardInfoBackAction.Remove(mainKeys);
- action = null;
- }
- }
}
#endregion
--
Gitblit v1.8.0