From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceImageInfoLogic.cs | 295 ++++++++++++++--------------------------------------------
1 files changed, 73 insertions(+), 222 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceImageInfoLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceImageInfoLogic.cs
old mode 100755
new mode 100644
index 6dd6b98..ea4fc4e
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceImageInfoLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceImageInfoLogic.cs
@@ -1,222 +1,73 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
-using ZigBee.Device;
-
-namespace Shared.Phone.UserCenter
-{
- /// <summary>
- /// 璁惧闀滃儚鐨勯�昏緫
- /// </summary>
- public class HdlDeviceImageInfoLogic
- {
- #region 鈻� 鍙橀噺澹版槑___________________________
-
- /// <summary>
- /// 璁惧闀滃儚鐨勯�昏緫
- /// </summary>
- private static HdlDeviceImageInfoLogic m_Current = null;
- /// <summary>
- /// 璁惧闀滃儚鐨勯�昏緫
- /// </summary>
- public static HdlDeviceImageInfoLogic Current
- {
- get
- {
- if (m_Current == null)
- {
- m_Current = new HdlDeviceImageInfoLogic();
- }
- return m_Current;
- }
- }
-
- /// <summary>
- /// OTA璁惧鑾峰彇闀滃儚鍚庣殑鍥炶皟鍑芥暟
- /// </summary>
- private Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>> dicOtaBackAction = new Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>>();
-
- #endregion
-
- #region 鈻� 涓诲叆鍙e嚱鏁癬________________________
-
- /// <summary>
- /// 璁剧疆璁惧鍏ㄩ儴鐨勯暅鍍忎俊鎭�
- /// </summary>
- /// <param name="tADevice"></param>
- /// <param name="backAction"></param>
- public void SetAllImageInfoToOtaDevice(OTADevice tADevice, Action<CommonDevice, CommonDevice.DeviceStatusReportData> backAction = null)
- {
- if (tADevice == null)
- {
- return;
- }
- lock (dicOtaBackAction)
- {
- //鍏堢Щ闄�
- this.RemoveDeviceFirmwareVersionThread(tADevice);
-
- if (backAction != null)
- {
- this.dicOtaBackAction[tADevice.DeviceAddr] = backAction;
- }
- //璁剧疆璁惧鐨勫浐浠剁増鏈彿(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼)
- this.SetFirmwareVersionToOtaDevice(tADevice);
- }
- }
-
- /// <summary>
- /// 璁剧疆璁惧鐨勫浐浠剁増鏈彿(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼)
- /// </summary>
- /// <param name="tADevice"></param>
- private void SetFirmwareVersionToOtaDevice(OTADevice tADevice)
- {
- if (HdlGatewayReceiveLogic.Current.IsEsixt("DeviceAutoGetFirmwareVersion") == false)
- {
- //娣诲姞浜嬩欢
- HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceAutoGetFirmwareVersion", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, this.SetFirmwareVersionByInterfaceResult);
- }
- //鍙戦�佸懡浠�
- this.SetFirmwareVersionComand(tADevice);
- }
-
- #endregion
-
- #region 鈻� 鍙戦�佸懡浠__________________________
-
- /// <summary>
- /// 鍙戦�佽幏鍙栧浐浠剁増鏈俊鎭殑鍛戒护
- /// </summary>
- /// <param name="device"></param>
- public void SetFirmwareVersionComand(OTADevice device)
- {
- var jObject = new Newtonsoft.Json.Linq.JObject
- {
- { "DeviceAddr",device.DeviceAddr },
- { "Epoint", device.DeviceEpoint },
- { "Cluster_ID", (int)Cluster_ID.Ota },
- { "Command", 108 }
- };
- var attriBute = new Newtonsoft.Json.Linq.JArray
- {
- new Newtonsoft.Json.Linq.JObject
- {
- { "AttriButeId", (int)AttriButeId.ImgVersion}
- },
- new Newtonsoft.Json.Linq.JObject
- {
- { "AttriButeId", (int)AttriButeId.mgHWversion}
- },
- new Newtonsoft.Json.Linq.JObject
- {
- { "AttriButeId", (int)AttriButeId.ImgTypeId}
- }
- };
- 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 SetFirmwareVersion(CommonDevice.DeviceStatusReportData report, CommonDevice device)
- {
- if (report == null)
- {
- return -1;
- }
-
- //鏄惁鏄纭殑鎺ㄩ�佹暟鎹�
- bool isRightData = false;
- foreach (var data in report.AttriBute)
- {
- //闀滃儚鐗堟湰
- if (data.AttributeId == (int)AttriButeId.ImgVersion)
- {
- isRightData = true;
- device.ImgVersion = data.AttriButeData;
- }
- //纭欢鐗堟湰
- if (data.AttributeId == (int)AttriButeId.mgHWversion)
- {
- isRightData = true;
- device.HwVersion = data.AttriButeData;
- }
- //闀滃儚ID
- if (data.AttributeId == (int)AttriButeId.ImgTypeId)
- {
- isRightData = true;
- device.ImgTypeId = data.AttriButeData;
- }
- }
- if (isRightData == false)
- {
- //杩欎釜涓嶆槸鍥轰欢淇℃伅鐨勬帹閫�
- return 0;
- }
- return 1;
- }
-
- #endregion
-
- #region 鈻� 鎺ュ彛鎺ㄩ�佸鐞哶______________________
-
- /// <summary>
- /// 鏍规嵁鎺ュ彛鎺ㄩ�佺殑淇℃伅锛岃缃浐浠剁増鏈彿
- /// </summary>
- /// <param name="device"></param>
- private void SetFirmwareVersionByInterfaceResult(CommonDevice device)
- {
- var otaDevice = Common.LocalDevice.Current.GetOTADevice(device.DeviceAddr, device.DeviceEpoint);
- if (otaDevice != null)
- {
- //璁剧疆鍥轰欢鐗堟湰淇℃伅
- this.SetFirmwareVersion(device.DeviceStatusReport, otaDevice);
- otaDevice.ReSave();
- }
- lock (dicOtaBackAction)
- {
- if (this.dicOtaBackAction.ContainsKey(device.DeviceAddr) == true)
- {
- var action = this.dicOtaBackAction[device.DeviceAddr];
- //璋冪敤鍥炶皟鍑芥暟
- action?.Invoke(device, device.DeviceStatusReport);
- //鐒跺悗绉婚櫎
- this.dicOtaBackAction.Remove(device.DeviceAddr);
- action = null;
- }
- }
- }
- #endregion
-
- #region 鈻� 绉婚櫎鐩戝惉绾跨▼_______________________
-
- /// <summary>
- /// 绉婚櫎鑾峰彇璁惧鍥轰欢淇℃伅鐨勭洃鍚嚎绋�
- /// </summary>
- /// <param name="device"></param>
- public void RemoveDeviceFirmwareVersionThread(CommonDevice device)
- {
- lock (dicOtaBackAction)
- {
- if (this.dicOtaBackAction.ContainsKey(device.DeviceAddr) == true)
- {
- var action = this.dicOtaBackAction[device.DeviceAddr];
- //鐒跺悗绉婚櫎
- this.dicOtaBackAction.Remove(device.DeviceAddr);
- action = null;
- }
- }
- }
-
- #endregion
- }
-}
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// 璁惧闀滃儚鐨勯�昏緫
+ /// </summary>
+ public class HdlDeviceImageInfoLogic
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 璁惧闀滃儚鐨勯�昏緫
+ /// </summary>
+ private static HdlDeviceImageInfoLogic m_Current = null;
+ /// <summary>
+ /// 璁惧闀滃儚鐨勯�昏緫
+ /// </summary>
+ public static HdlDeviceImageInfoLogic Current
+ {
+ get
+ {
+ if (m_Current == null)
+ {
+ m_Current = new HdlDeviceImageInfoLogic();
+ }
+ return m_Current;
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 鍙戦�佸懡浠__________________________
+
+ /// <summary>
+ /// 鍙戦�佽幏鍙栧浐浠剁増鏈俊鎭殑鍛戒护
+ /// </summary>
+ /// <param name="device"></param>
+ public void SetFirmwareVersionComand(OTADevice device)
+ {
+ var jObject = new Newtonsoft.Json.Linq.JObject
+ {
+ { "DeviceAddr",device.DeviceAddr },
+ { "Epoint", device.DeviceEpoint },
+ { "Cluster_ID", (int)Cluster_ID.Ota },
+ { "Command", 108 }
+ };
+ var attriBute = new Newtonsoft.Json.Linq.JArray
+ {
+ new Newtonsoft.Json.Linq.JObject
+ {
+ { "AttriButeId", (int)AttriButeId.ImgVersion}
+ },
+ new Newtonsoft.Json.Linq.JObject
+ {
+ { "AttriButeId", (int)AttriButeId.mgHWversion}
+ },
+ new Newtonsoft.Json.Linq.JObject
+ {
+ { "AttriButeId", (int)AttriButeId.ImgTypeId}
+ }
+ };
+ var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } };
+ jObject.Add("Data", data);
+ device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString());
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0