From 52005ed57f3f7bc796fdd1a878e4f298a126f1e8 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 29 十月 2019 16:48:47 +0800
Subject: [PATCH] 2019.10.29-3
---
ZigbeeApp/Shared/Common/Device.cs | 673 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 544 insertions(+), 129 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index 3453f98..8f0dc65 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -44,9 +44,13 @@
get
{
var list = new List<CommonDevice>();
- foreach (var device in dicAllDevice.Values)
+ foreach (var listMac in this.dicDeviceSort.Values)
{
- list.Add(device);
+ foreach (var strMac in listMac)
+ {
+ var listTemp = this.GetDevicesByMac(strMac);
+ list.AddRange(listTemp);
+ }
}
return list;
}
@@ -81,13 +85,13 @@
/// </summary>
private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
/// <summary>
+ /// 璁惧Mac椤哄簭
+ /// </summary>
+ private Dictionary<string, List<string>> dicDeviceSort = null;
+ /// <summary>
/// 璁惧鏂囦欢鐨勫墠缂�鍚嶅瓧
/// </summary>
public const string deviceFirstName = "Device_";
- /// <summary>
- /// 閿�
- /// </summary>
- private object objLock = new object();
#endregion
@@ -99,7 +103,7 @@
public void ReFreshByLocal()
{
this.dicAllDevice.Clear();
- this.dicDeviceEpoint.Clear();
+ this.dicDeviceEpoint.Clear();
//鍒濆鍖朢鏂囦欢閲岄潰璁惧榛樿鍚嶅瓧鐨処D
this.InitDeviceDefultNameIDList();
@@ -171,7 +175,9 @@
}
}
//鎴愬憳韬唤鐨勬椂鍊�,鍒犻櫎鎺夐潪娉曠殑缃戝叧鏂囦欢
- this.DeleteGatewayFileByMemberModel();
+ this.DeleteGatewayFileByMemberModel();
+ //鍒濆鍖栬澶囬『搴�
+ this.InitDeviceSort();
}
/// <summary>
@@ -184,11 +190,15 @@
return;
}
var listId = new HashSet<string>();
- foreach (var device in this.dicAllDevice.Values)
+
+ lock (dicAllDevice)
{
- if (listId.Contains(device.CurrentGateWayId) == false)
+ foreach (var device in this.dicAllDevice.Values)
{
- listId.Add(device.CurrentGateWayId);
+ if (listId.Contains(device.CurrentGateWayId) == false)
+ {
+ listId.Add(device.CurrentGateWayId);
+ }
}
}
var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
@@ -217,7 +227,7 @@
{
//浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧
List<CommonDevice> listDevice = new List<CommonDevice>();
- List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, deviceComingAction);
+ List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
if (list == null)
{
@@ -279,11 +289,10 @@
dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
}
- new System.Threading.Thread(async () =>
- {
+ HdlThreadLogic.Current.RunThread(async () =>
+ {
await this.ReName(device, dName, ShowErrorMode.NO);
- })
- { IsBackground = true }.Start();
+ });
}
}
@@ -303,6 +312,16 @@
/// <param name="device">璁惧瀵硅薄(杩欎釜涓滆タ鏈夊彲鑳戒細琚洿鏀�)</param>
public void AddDeviceToMemory(ref CommonDevice device)
{
+ if (dicDeviceSort.ContainsKey(device.CurrentGateWayId) == false)
+ {
+ dicDeviceSort[device.CurrentGateWayId] = new List<string>();
+ }
+ if (dicDeviceSort[device.CurrentGateWayId].Contains(device.DeviceAddr) == false)
+ {
+ //淇濆瓨椤哄簭
+ dicDeviceSort[device.CurrentGateWayId].Add(device.DeviceAddr);
+ UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
+ }
string mainKeys = this.GetDeviceMainKeys(device);
//濡傛灉瀹冩槸鍗囩骇鐨勯《绔鐐�,鍒欎笉鑳借瀹冨姞鍏ュ埌缂撳瓨锛屼絾鏄彲浠ヨ浠栫敓鎴愭枃浠�
if (device is OTADevice)
@@ -330,17 +349,20 @@
return;
}
- if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ lock (dicAllDevice)
{
- //浜ゆ崲灞炴��
- var tempDevice = this.dicAllDevice[mainKeys];
- //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
- this.SetDeviceInfoToMain(tempDevice, device);
- device = tempDevice;
- }
- else
- {
- this.dicAllDevice[mainKeys] = device;
+ if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ {
+ //浜ゆ崲灞炴��
+ var tempDevice = this.dicAllDevice[mainKeys];
+ //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
+ this.SetDeviceInfoToMain(tempDevice, device);
+ device = tempDevice;
+ }
+ else
+ {
+ this.dicAllDevice[mainKeys] = device;
+ }
}
//璁惧鍥炶矾鏀堕泦
@@ -457,16 +479,19 @@
/// <param name="device"></param>
private void BackupDeviceAfterReName(CommonDevice device)
{
- string mainKeys = this.GetDeviceMainKeys(device);
- if (this.dicAllDevice.ContainsKey(mainKeys) == false)
+ lock (dicAllDevice)
{
- return;
- }
- this.dicAllDevice[mainKeys] = device;
- device.ReSave();
+ string mainKeys = this.GetDeviceMainKeys(device);
+ if (this.dicAllDevice.ContainsKey(mainKeys) == false)
+ {
+ return;
+ }
+ this.dicAllDevice[mainKeys] = device;
+ device.ReSave();
- //娣诲姞鑷姩澶囦唤
- HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+ //娣诲姞鑷姩澶囦唤
+ HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+ }
}
#endregion
@@ -496,6 +521,13 @@
this.ShowErrorMsg(msg);
return false;
}
+ if (dicDeviceSort.ContainsKey(listdevice[0].CurrentGateWayId) == true &&
+ dicDeviceSort[listdevice[0].CurrentGateWayId].Contains(info.DeviceAddr) == true)
+ {
+ //淇濆瓨椤哄簭
+ dicDeviceSort[listdevice[0].CurrentGateWayId].Remove(info.DeviceAddr);
+ UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
+ }
//鍒犻櫎鏂囦欢
foreach (CommonDevice device in listdevice)
@@ -514,9 +546,12 @@
{
//鍒犻櫎缂撳瓨
string mainKeys = this.GetDeviceMainKeys(device);
- if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ lock (dicAllDevice)
{
- this.dicAllDevice.Remove(mainKeys);
+ if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ {
+ this.dicAllDevice.Remove(mainKeys);
+ }
}
//鍒犻櫎璁惧鏂囦欢
@@ -646,13 +681,34 @@
public List<CommonDevice> GetDeviceByGatewayID(string gwId)
{
List<CommonDevice> list = new List<CommonDevice>();
- //鍚勭綉鍏崇殑鎵�鏈夎澶�
- foreach (CommonDevice device in this.dicAllDevice.Values)
+ lock (dicAllDevice)
{
- if (gwId == device.CurrentGateWayId)
+ List<string> listSort = null;
+ if (dicDeviceSort.ContainsKey(gwId) == false)
{
- list.Add(device);
+ dicDeviceSort[gwId] = new List<string>();
}
+ listSort = dicDeviceSort[gwId];
+
+ //鍚勭綉鍏崇殑鎵�鏈夎澶�
+ foreach (CommonDevice device in this.dicAllDevice.Values)
+ {
+ if (gwId == device.CurrentGateWayId)
+ {
+ if (listSort.Contains(device.DeviceAddr) == false)
+ {
+ listSort.Add(device.DeviceAddr);
+ }
+ }
+ }
+ //鎺掑簭
+ foreach (var strMac in listSort)
+ {
+ var listTemp = this.GetDevicesByMac(strMac);
+ list.AddRange(listTemp);
+ }
+ //淇濆瓨椤哄簭
+ UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
}
return list;
@@ -665,9 +721,12 @@
/// <returns></returns>
public CommonDevice GetDevice(string mainKeys)
{
- if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ lock (dicAllDevice)
{
- return this.dicAllDevice[mainKeys];
+ if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+ {
+ return this.dicAllDevice[mainKeys];
+ }
}
return null;
}
@@ -996,6 +1055,11 @@
return;
}
imageFilePath = "RealDevice/" + arry[0] + ".png";
+ //濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗�
+ if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+ {
+ imageFilePath = "RealDevice/CommonDevice.png";
+ }
}
btnIcon.UnSelectedImagePath = imageFilePath;
}
@@ -1289,7 +1353,7 @@
{
info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9;
info.BeloneType = DeviceBeloneType.A褰╃伅;
- info.ConcreteType = DeviceConcreteType.ColorDimmableLight;
+ info.ConcreteType = DeviceConcreteType.ColorLight;
}
//8绌鸿皟
else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
@@ -1319,13 +1383,57 @@
info.BeloneType = DeviceBeloneType.A鏅鸿兘闂ㄩ攣;
info.ConcreteType = DeviceConcreteType.IntelligentLocks;
}
- //2鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
+ //12鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
else if (dicType.ContainsKey(DeviceType.IASZone) == true)
{
//璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
this.SetSensorDeviceSpecificType(ref info, listdevice);
}
+ //13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇�
+ else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
+ {
+ bool temperatrue = false;
+ bool humidity = false;
+ foreach (var device in listdevice)
+ {
+ if (device is TemperatureSensor)
+ {
+ //娓╁害浼犳劅鍣�
+ if (((TemperatureSensor)device).SensorDiv == 1)
+ {
+ temperatrue = true;
+ }
+ //婀垮害浼犳劅鍣�
+ else if(((TemperatureSensor)device).SensorDiv == 2)
+ {
+ humidity = true;
+ }
+ }
+ }
+ if (temperatrue == true && humidity == true)
+ {
+ //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+ info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
+ info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
+ }
+ else if (temperatrue == true && humidity == false)
+ {
+ //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+ info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
+ info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
+ }
+ else if (temperatrue == false && humidity == true)
+ {
+ //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+ info.BeloneType = DeviceBeloneType.A婀垮害浼犳劅鍣�;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId12;
+ info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
+ }
+ }
+
int value = (int)info.BeloneType;
if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
{
@@ -1406,94 +1514,72 @@
#region 鈻� 璁惧鎺掑簭___________________________
/// <summary>
+ /// 鍒濆鍖栬澶囬『搴�
+ /// </summary>
+ private void InitDeviceSort()
+ {
+ //璇诲彇璁惧椤哄簭
+ this.dicDeviceSort = new Dictionary<string, List<string>>();
+ string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile);
+ var strData = UserCenterLogic.LoadFileContent(fullName);
+ if (strData != null)
+ {
+ this.dicDeviceSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData);
+ }
+ foreach (var device in dicAllDevice.Values)
+ {
+ if (dicDeviceSort.ContainsKey(device.CurrentGateWayId) == false)
+ {
+ dicDeviceSort[device.CurrentGateWayId] = new List<string>();
+ }
+ if (dicDeviceSort[device.CurrentGateWayId].Contains(device.DeviceAddr) == false)
+ {
+ //鏂版坊鍔犵殑璁惧
+ dicDeviceSort[device.CurrentGateWayId].Add(device.DeviceAddr);
+ }
+ }
+ foreach (var keys in dicDeviceSort.Keys)
+ {
+ var list = dicDeviceSort[keys];
+ for (int i = 0; i < list.Count; i++)
+ {
+ if (this.dicDeviceEpoint.ContainsKey(list[i]) == false)
+ {
+ //杩欎釜涓滆タ鑾悕鐨勪笉瑙佷簡锛熷拰璁惧鍒楄〃鍖归厤涓嶄笂?
+ list.RemoveAt(i);
+ i--;
+ }
+ }
+ }
+
+ //淇濆瓨椤哄簭
+ UserCenterLogic.SaveFileContent(fullName, dicDeviceEpoint);
+ }
+
+ /// <summary>
/// 璁惧鎺掑簭
/// </summary>
- /// <param name="listDevice">璁惧瀵硅薄</param>
+ /// <param name="listDevice">闇�瑕佹帓搴忕殑璁惧鍒楄〃</param>
/// <returns></returns>
- public List<CommonDevice> SortDeviceList(List<CommonDevice> listDevice)
+ public List<CommonDevice> SortDevice(List<CommonDevice> listDevice)
{
- List<CommonDevice> listSort = new List<CommonDevice>();
- var list = this.SortDeviceListByRule(listDevice);
- listSort.AddRange(list);
-
- return listSort;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="listDevice">璁惧瀵硅薄</param>
- /// <returns></returns>
- private List<CommonDevice> SortDeviceListByRule(List<CommonDevice> listDevice)
- {
- //璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType) value锛氬瓨鏀捐澶囩殑瀹瑰櫒)
- var dic = this.GetDeviceSortRule();
- foreach (CommonDevice device in listDevice)
+ var dic = new Dictionary<string, CommonDevice>();
+ for (int i = 0; i < listDevice.Count; i++)
{
- if (device is IASZone)
+ dic[(this.GetDeviceMainKeys(listDevice[i]))] = listDevice[i];
+ }
+ var list = new List<CommonDevice>();
+ foreach (var listSort in this.dicDeviceSort.Values)
+ {
+ for (int i = 0; i < listSort.Count; i++)
{
- //浼犳劅鍣ㄦ湁寰堝绉�
- var strType = ((IASZone)device).DeviceInfo.DeviceType.ToString();
- if (dic.ContainsKey(strType) == false || dic[strType] == null)
+ if (dic.ContainsKey(listSort[i]) == true)
{
- dic[strType] = new List<CommonDevice>();
+ list.Add(dic[listSort[i]]);
}
- dic[strType].Add(device);
- continue;
- }
- string checkKeys = device.Type.ToString();
- if (dic.ContainsKey(checkKeys) == false || dic[checkKeys] == null)
- {
- dic[checkKeys] = new List<CommonDevice>();
- }
- dic[checkKeys].Add(device);
- }
-
- List<CommonDevice> lstSort = new List<CommonDevice>();
- foreach (var list in dic.Values)
- {
- if (list != null && list.Count > 0)
- {
- lstSort.AddRange(list);
}
}
- return lstSort;
- }
-
- /// <summary>
- /// 鑾峰彇璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType) value锛氬瓨鏀捐澶囩殑瀹瑰櫒)
- /// </summary>
- /// <returns></returns>
- private Dictionary<string, List<CommonDevice>> GetDeviceSortRule()
- {
- var dic = new Dictionary<string, List<CommonDevice>>();
- //鎺у埗闈㈡澘
- dic[DeviceType.OnOffSwitch.ToString()] = null;
- //鍗峰笜
- dic[DeviceType.WindowCoveringDevice.ToString()] = null;
- //璋冨厜鐏�
- dic[DeviceType.ColorDimmableLight.ToString()] = null;
- //缁х數鍣�
- dic[DeviceType.OnOffOutput.ToString()] = null;
- //绌烘皵寮�鍏�
- dic[DeviceType.AirSwitch.ToString()] = null;
- //闂ㄧ獥纾佷紶鎰熷櫒
- dic["21"] = null;
- dic["22"] = null;
- //姘存蹈浼犳劅鍣�
- dic["42"] = null;
- //鐑熼浘浼犳劅鍣�
- dic["40"] = null;
- //绱ф�ユ寜閽�
- dic["44"] = null;
- //鐕冩皵浼犳劅鍣�
- dic["43"] = null;
- //杩愬姩浼犳劅鍣�
- dic["13"] = null;
- //閽ュ寵鎵�
- dic["277"] = null;
-
- return dic;
+ return list;
}
#endregion
@@ -1599,14 +1685,40 @@
#region 鈻� 鑾峰彇璁惧鍒楄〃鐨勬帴鍙________________
/// <summary>
- /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚鈽呪槄鈽呪槄鈽呪槄鈽�)
+ /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢鈽呪槄鈽呪槄鈽呪槄鈽�)
/// </summary>
/// <param name="zbGateway">缃戝叧瀵硅薄</param>
- /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param>
+ /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿,true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param>
+ /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�</param>
/// <param name="mode">鏄惁鏄剧ず閿欒</param>
/// <returns></returns>
- public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
+ public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
{
+ if (ignoreTime == false)
+ {
+ if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
+ {
+ //涓嶆棤瑙嗘椂闂�,杩斿洖鏈湴璁惧鍒楄〃
+ var listTemp = this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
+ if (deviceComingAction != null)
+ {
+ for (int i = 0; i < listTemp.Count; i++)
+ {
+ try
+ {
+ //鍥炶皟鍑芥暟
+ deviceComingAction.Invoke(listTemp[i]);
+ }
+ //Log鍑哄姏
+ catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
+ }
+ }
+ deviceComingAction = null;
+ return listTemp;
+ }
+ }
+ zbGateway.LastDateTime = DateTime.Now;
+
//濡傛灉鍒囨崲鍒颁簡鍒殑鐣岄潰锛屽垯涓嶆樉绀洪敊璇俊鎭�
string nowFormId = UserCenterResourse.NowActionFormID;
@@ -1663,8 +1775,13 @@
var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
if (device != null)
{
- //鍥炶皟鍑芥暟
- deviceComingAction?.Invoke(device);
+ try
+ {
+ //鍥炶皟鍑芥暟
+ deviceComingAction?.Invoke(device);
+ }
+ //Log鍑哄姏
+ catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
listDevice.Add(device);
}
@@ -1721,8 +1838,7 @@
}
}
- //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚)
- deviceComingAction?.Invoke(null);
+ //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚)
deviceComingAction = null;
return listDevice;
@@ -1789,6 +1905,7 @@
mainDevice.DriveCode = device.DeviceInfo.DriveCode;
mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
mainDevice.Profile = device.DeviceInfo.Profile;
+ mainDevice.Type = device.Type;
//鍥轰欢鐗堟湰
mainDevice.ImgVersion = device.DeviceInfo.ImgVersion;
@@ -1809,6 +1926,41 @@
mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
mainDevice.AttributeStatus.Clear();
mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
+
+ //濡傛灉鏄俯搴︿紶鎰熷櫒
+ if (mainDevice.Type == DeviceType.TemperatureSensor)
+ {
+ //杈撳嚭鏃� 1026:娓╁害浼犳劅鍣� 1029:婀垮害浼犳劅鍣�
+ foreach (var data in mainDevice.OutClusterList)
+ {
+ if (data.OutCluster == 1029)
+ {
+ ((TemperatureSensor)mainDevice).SensorDiv = 2;
+ }
+ else if (data.OutCluster == 1026)
+ {
+ ((TemperatureSensor)mainDevice).SensorDiv = 1;
+ }
+ }
+ }
+ //濡傛灉鏄皟鍏夊櫒
+ else if (mainDevice.Type == DeviceType.DimmableLight )
+ {
+ mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+ if (mainDevice.IsCustomizeImage == false)
+ {
+ mainDevice.IconPath = "Device/Light.png";
+ }
+ }
+ //濡傛灉鏄僵鐏殑璇�
+ else if ( mainDevice.Type == DeviceType.ColorDimmableLight)
+ {
+ mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+ if (mainDevice.IsCustomizeImage == false)
+ {
+ mainDevice.IconPath = "Device/ColorLight.png";
+ }
+ }
}
/// <summary>
@@ -1831,6 +1983,7 @@
else if (deviceType == DeviceType.Repeater) { device = new Repeater(); }
else if (deviceType == DeviceType.Thermostat) { device = new AC(); }
else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
+ else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
else { return null; }
@@ -1932,4 +2085,266 @@
#endregion
}
+
+ #region 鈻� 鑷畾涔夎澶囩被鍨媉________________________
+
+ /// <summary>
+ /// <para>浠呴檺搴曞眰浣跨敤锛氳澶囩殑鍏蜂綋銆愯澶囩被鍨嬨��,鑷畾涔変笌妯″潡id鍏宠仈鐨勬灇涓�(鍊间负LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��)</para>
+ /// <para>鍙橀噺鍚嶅彲浠ヤ綔涓恒�愯澶囩被鍨嬨�戝浘鐗�,杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para>
+ /// </summary>
+ public enum DeviceConcreteType
+ {
+ //瀹氫箟瑙勫垯锛氥�愯澶囩被鍨嬨�戝浘鐗囧悕瀛�=LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��
+
+ /// <summary>
+ /// 鏈煡璁惧
+ /// </summary>
+ UnKownDevice = -1,
+
+ //=========鈽呪槄绐楀笜绫�(100-199)鈽呪槄=========
+ /// <summary>
+ /// 绐楀笜
+ /// </summary>
+ Curtain = -100,
+ /// <summary>
+ /// 鏅鸿兘寮�鍚堝笜鐢垫満 闀滃儚id锛�100
+ /// </summary>
+ Curtain_AutoOpen = 100,
+ /// <summary>
+ /// 鏅鸿兘绠$姸鐢垫満 闀滃儚id锛�101
+ /// </summary>
+ Curtain_Siphonate = 101,
+
+ //=========鈽呪槄鎸夐敭闈㈡澘绫�(200-1199)鈽呪槄=========
+ /// <summary>
+ /// 鎸夐敭闈㈡澘
+ /// </summary>
+ ButtonPanel = -200,
+ /// <summary>
+ /// 4鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�4璺户鐢靛櫒搴曞骇) 闀滃儚id锛�200
+ /// </summary>
+ ButtonPanel_Four = 200,
+ /// <summary>
+ /// 3鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�3璺户鐢靛櫒搴曞骇) 闀滃儚id锛�201
+ /// </summary>
+ ButtonPanel_Three = 201,
+ /// <summary>
+ /// 2鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�2璺户鐢靛櫒搴曞骇) 闀滃儚id锛�202
+ /// </summary>
+ ButtonPanel_Two = 202,
+ /// <summary>
+ /// 12鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�1璺户鐢靛櫒搴曞骇) 闀滃儚id锛�203
+ /// </summary>
+ ButtonPanel_Twelve = 203,
+ /// <summary>
+ /// 4鎸夐敭澶氬姛鑳借Е鎽搁潰鏉匡紙鍙甫鐢垫簮搴曞骇锛� 闀滃儚id锛�210
+ /// </summary>
+ ButtonPanel_FourNotPower = 210,
+
+ //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
+ /// <summary>
+ /// 浼犳劅鍣�
+ /// </summary>
+ Sensor = -1200,
+ /// <summary>
+ /// pir浼犳劅鍣�220 闀滃儚id锛�1200
+ /// </summary>
+ Sensor_Pir = 1200,
+
+ //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫�(1300-2299)鈽呪槄=========
+ /// <summary>
+ /// 鐕冩皵浼犳劅鍣�
+ /// </summary>
+ Sensor_CarbonMonoxide = 1300,
+ /// <summary>
+ /// 闂ㄧ獥浼犳劅鍣�
+ /// </summary>
+ Sensor_DoorWindow = 1301,
+ /// <summary>
+ /// 鐑熼浘浼犳劅鍣�
+ /// </summary>
+ Sensor_Fire = 1302,
+ /// <summary>
+ /// 绾㈠浼犳劅鍣�
+ /// </summary>
+ Sensor_Infrared = 1303,
+ /// <summary>
+ /// 姘翠镜浼犳劅鍣�
+ /// </summary>
+ Sensor_Water = 1304,
+ /// <summary>
+ /// 绱ф�ユ寜閽�
+ /// </summary>
+ Sensor_EmergencyButton = 1305,
+ /// <summary>
+ /// 杩愬姩浼犳劅鍣�
+ /// </summary>
+ Sensor_Motion = -1306,
+ /// <summary>
+ /// 閽ュ寵鎵�
+ /// </summary>
+ Sensor_Keyfob = -1307,
+ /// <summary>
+ /// 娓╂箍搴︿紶鎰熷櫒
+ /// </summary>
+ Sensor_TemperatrueHumidity = -1308,
+ /// <summary>
+ /// 娓╁害浼犳劅鍣�
+ /// </summary>
+ Sensor_Temperatrue = -1309,
+ /// <summary>
+ /// 婀垮害浼犳劅鍣�
+ /// </summary>
+ Sensor_Humidity = -1310,
+
+ //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄=========
+ /// <summary>
+ /// 缁х數鍣�
+ /// </summary>
+ Relay = -2300,
+ /// <summary>
+ /// 涓夎矾缁х數鍣� 闀滃儚id锛�2300
+ /// </summary>
+ Relay_ThreeLoad = 2300,
+
+ //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄=========
+ /// <summary>
+ /// 璋冨厜鍣�
+ /// </summary>
+ DimmableLight = -2500,
+ /// <summary>
+ /// 1璺皟鍏夊櫒灏忔ā鍧�
+ /// </summary>
+ DimmableLight_OneLoad = 2500,
+
+ //=========鈽呪槄鏅鸿兘闂ㄩ攣绫�(2800-????)鈽呪槄=========
+ /// <summary>
+ /// 鏅鸿兘闂ㄩ攣
+ /// </summary>
+ IntelligentLocks = -2800,
+ /// <summary>
+ /// H06C
+ /// </summary>
+ IntelligentLocks_H06C = 2800,
+
+ //=========鈽呪槄褰╃伅绫�(????-????)鈽呪槄=========
+ /// <summary>
+ /// 褰╃伅
+ /// </summary>
+ ColorLight = -10,
+
+ //=========鈽呪槄绌鸿皟(3600-3899)鈽呪槄=========
+ /// <summary>
+ /// 绌鸿皟
+ /// </summary>
+ AirConditioner = -3600,
+ /// <summary>
+ /// zigbee绌鸿皟缃戝叧妯″潡
+ /// </summary>
+ AirConditioner_ZbGateway = 3600,
+
+ //=========鈽呪槄涓户鍣�(3900-3999)鈽呪槄=========
+ /// <summary>
+ /// 涓户鍣�
+ /// </summary>
+ Repeater = -3900,
+ /// <summary>
+ /// zigbee涓户鍣� 闀滃儚id锛�3900
+ /// </summary>
+ Repeater_Zigbee = 3900,
+
+ //=========鈽呪槄绌烘皵寮�鍏崇被(4100-????)鈽呪槄=========
+ /// <summary>
+ /// 鏅鸿兘绌烘皵寮�鍏�
+ /// </summary>
+ AirSwitch = -4100,
+ /// <summary>
+ /// 寰柇浜戞帶鍒跺櫒 闀滃儚id锛�4100
+ /// </summary>
+ AirSwitch_CloudContr = 4100,
+
+ //=========鈽呪槄杞崲鍣ㄧ被(4200-4699)鈽呪槄=========
+ /// <summary>
+ /// 杞崲鍣�
+ /// </summary>
+ Converter = -4200,
+ /// <summary>
+ /// zigbee杞�485鍗忚杞崲鍣�
+ /// </summary>
+ Converter_Zb485 = 4200,
+ /// <summary>
+ /// zigbee杞琤uspro鍗忚杞崲鍣�
+ /// </summary>
+ Converter_ZbBuspro = 4201,
+ }
+
+ /// <summary>
+ /// <para>浠呴檺搴曞眰浣跨敤锛氳澶囨墍灞炵殑銆愯澶囩绫汇��,鑷畾涔変笌妯″潡id鍏宠仈鐨勬灇涓�(鍊间负LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��)</para>
+ /// <para>杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para>
+ /// </summary>
+ public enum DeviceBeloneType
+ {
+ /// <summary>
+ /// 鏈煡璁惧
+ /// </summary>
+ A鏈煡璁惧 = 0,
+ /// <summary>
+ /// 绐楀笜(100-199)
+ /// </summary>
+ A绐楀笜 = 100,
+ /// <summary>
+ /// 鎸夐敭闈㈡澘(200-1199)
+ /// </summary>
+ A鎸夐敭闈㈡澘 = 200,
+ /// <summary>
+ /// 浼犳劅鍣�(1200-2299)
+ /// </summary>
+ A浼犳劅鍣� = 1200,
+ /// <summary>
+ /// 缁х數鍣�(2300-2499)
+ /// </summary>
+ A缁х數鍣� = 2300,
+ /// <summary>
+ /// 璋冨厜鍣�(2500-2799)
+ /// </summary>
+ A璋冨厜鍣� = 2500,
+ /// <summary>
+ /// 鏅鸿兘闂ㄩ攣(2800-????)
+ /// </summary>
+ A鏅鸿兘闂ㄩ攣 = 2800,
+ /// <summary>
+ /// 绌鸿皟(3600-3899)
+ /// </summary>
+ A绌鸿皟 = 3600,
+ /// <summary>
+ /// 涓户鍣�(3900-3999)
+ /// </summary>
+ A涓户鍣� = 3900,
+ /// <summary>
+ /// 绌烘皵寮�鍏�(4100-4199)
+ /// </summary>
+ A绌烘皵寮�鍏� = 4100,
+ /// <summary>
+ /// 杞崲鍣�(4200-4699)
+ /// </summary>
+ A杞崲鍣� = 4200,
+ /// <summary>
+ /// 褰╃伅
+ /// </summary>
+ A褰╃伅 = 9,
+ /// <summary>
+ /// 娓╂箍搴︿紶鎰熷櫒
+ /// </summary>
+ A娓╂箍搴︿紶鎰熷櫒 = 10,
+ /// <summary>
+ /// 娓╁害浼犳劅鍣�
+ /// </summary>
+ A娓╁害浼犳劅鍣� = 11,
+ /// <summary>
+ /// 婀垮害浼犳劅鍣�
+ /// </summary>
+ A婀垮害浼犳劅鍣� = 12
+ }
+
+ #endregion
}
--
Gitblit v1.8.0