From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001 From: chenqiyang <1406175257@qq.com> Date: 星期三, 22 六月 2022 11:22:18 +0800 Subject: [PATCH] 修改引用路径 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs | 403 ++++++++++++--------------------------------------------- 1 files changed, 87 insertions(+), 316 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs old mode 100755 new mode 100644 index b741e66..b34358e --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceHardInfoLogic.cs @@ -1,316 +1,87 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; -using ZigBee.Device; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 璁惧纭欢淇℃伅鐨勯�昏緫 - /// </summary> - public class HdlDeviceHardInfoLogic - { - #region 鈻� 鍙橀噺澹版槑___________________________ - - /// <summary> - /// 璁惧纭欢淇℃伅鐨勯�昏緫 - /// </summary> - private static HdlDeviceHardInfoLogic m_Current = null; - /// <summary> - /// 璁惧纭欢淇℃伅鐨勯�昏緫 - /// </summary> - public static HdlDeviceHardInfoLogic Current - { - get - { - if (m_Current == null) - { - m_Current = new HdlDeviceHardInfoLogic(); - } - return m_Current; - } - } - - /// <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嚱鏁癬________________________ - - /// <summary> - /// 璇诲彇浠ュ強璁剧疆璁惧纭欢淇℃伅 - /// </summary> - /// <param name="device">璁惧鍥炶矾</param> - /// <param name="backAction">鍥炶皟鍑芥暟</param> - public void SetAllHardFirmwareInfoToDevice(CommonDevice device, Action<CommonDevice, CommonDevice.DeviceStatusReportData> backAction = null) - { - 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 }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.Basic }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", 4} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", 5} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", 6} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", 7} - }, - new Newtonsoft.Json.Linq.JObject - { - { "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) - { - var 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 - } -} +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 璁惧纭欢淇℃伅鐨勯�昏緫 + /// </summary> + public class HdlDeviceHardInfoLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧纭欢淇℃伅鐨勯�昏緫 + /// </summary> + private static HdlDeviceHardInfoLogic m_Current = null; + /// <summary> + /// 璁惧纭欢淇℃伅鐨勯�昏緫 + /// </summary> + public static HdlDeviceHardInfoLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlDeviceHardInfoLogic(); + } + return m_Current; + } + } + + #endregion + + #region 鈻� 涓诲叆鍙e嚱鏁癬________________________ + + /// <summary> + /// 璇诲彇浠ュ強璁剧疆璁惧纭欢淇℃伅 + /// </summary> + /// <param name="device">璁惧鍥炶矾</param> + /// <param name="backAction">鍥炶皟鍑芥暟</param> + public void SetAllHardFirmwareInfoToDevice(CommonDevice device) + { + if (device == null) + { + return; + } + + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.Basic }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 4}//鐢熶骇鍟嗗悕瀛� + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 5}//鍨嬪彿鐮�(涔熷彨妯″潡ID) + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 6}//鐢熶骇鏃ユ湡 + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 7}//鐢垫簮 + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 13}//搴忓垪鍙� + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + } + + #endregion + } +} -- Gitblit v1.8.0