From 27e6f7742991170672feba0f4fd8d693b333ba0e Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期三, 15 一月 2020 17:08:06 +0800
Subject: [PATCH] 2020.1.15
---
ZigbeeApp/Shared/Common/Device.cs | 387 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 258 insertions(+), 129 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index a22b9e3..32b497d 100644
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -37,7 +37,7 @@
}
}
/// <summary>
- /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨(鎺掑簭)
+ /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨
/// </summary>
public List<CommonDevice> listAllDevice
{
@@ -113,7 +113,7 @@
{
CommonDevice device = null;
//鍙嶅簭鍒楀寲涓烘寚瀹氱殑绫伙紝涓嶇劧鏁版嵁浼氫涪澶辫�屽鑷存棤娉曞己杞�
- try
+ try
{
device = CommonDevice.CommonDeviceByFilePath(file);
}
@@ -223,26 +223,25 @@
#region 鈻� 娣诲姞璁惧___________________________
/// <summary>
- /// 灏嗘寚瀹氱綉鍏崇殑璁惧瀛樺叆缂撳瓨涓�(浠庢柊鑾峰彇闀滃儚)
+ /// <para>灏嗘寚瀹氱綉鍏崇殑璁惧瀛樺叆缂撳瓨涓�(浠庢柊鑾峰彇闀滃儚)</para>
+ /// <para>-1:寮傚父 1:姝e父 2:璁惧淇℃伅缂烘崯</para>
/// </summary>
/// <param name="zbGateway">缃戝叧瀵硅薄</param>
- /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param>
- /// <returns>涓�鐩磋繑鍥瀟rue</returns>
- public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
+ public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
{
//浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧
+ int statu = 0;
List<CommonDevice> listDevice = new List<CommonDevice>();
- List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
-
+ List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
if (list == null)
{
- return false;
+ return -1;
}
listDevice.AddRange(list);
//鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶�
string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
- List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
+ List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID, true);
Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
foreach (var device in listLocalDevices)
{
@@ -261,7 +260,7 @@
//娣诲姞缂撳瓨
this.AddDeviceToMemory(ref device);
- //绉婚櫎瀛樺湪鐨勮澶囧唴瀛�
+ //绉婚櫎瀛樺湪鐨勮澶囧唴瀛�
string maikey = this.GetDeviceMainKeys(device);
if (dicExist.ContainsKey(maikey) == true)
{
@@ -274,25 +273,13 @@
for (int i = 0; i < listDevice.Count; i++)
{
var device = listDevice[i];
- //瀵规湭鍛藉悕鐨勮澶囬噸鏂板懡鍚�
- if (this.GetSimpleEpointName(device) == string.Empty)
+ //瀵规湭鍛藉悕鐨勮櫄鎷熻澶囬噸鏂板懡鍚�
+ if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
{
//鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О
var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
- //铏氭嫙璁惧鐨勮瘽锛岄檮鍔犲洖璺彿
- if (device.DriveCode > 0)
- {
- //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
- dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
- }
- //澶氬洖璺澶囩殑璇濓紝闄勫姞鍥炶矾鍙�
- else if (dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && dicDeviceEpoint[device.DeviceAddr].Count > 1)
- {
- var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
- dName = arry[0].Trim();
- //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
- dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
- }
+ //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
+ dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
HdlThreadLogic.Current.RunThread(async () =>
{
@@ -301,14 +288,26 @@
}
}
- //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鏆傛椂鍒犻櫎鏈湴鐨勮澶�
- //娉ㄦ剰锛氬彧鏄垹闄よ澶囨枃浠讹紝鎴块棿鍐呭浠�涔堢殑杩樺瓨鍦ㄧ潃
- foreach (var device in dicExist.Values)
+ //鍙湁瀹屽叏鑾峰彇鐨勬椂鍊�,鎵嶄細鍘诲鐞嗗垹闄ょ殑闂
+ if (statu != 1)
{
- this.DeleteMemmoryDevice(device, false);
+ return statu;
}
- return true;
+ //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鍒犻櫎鏈湴鐨勮澶�
+ foreach (var device in dicExist.Values)
+ {
+ if (device is OTADevice)
+ {
+ this.DeleteMemmoryOtaDevice(device.DeviceAddr);
+ }
+ else
+ {
+ this.DeleteMemmoryDevice(device, true);
+ }
+ }
+
+ return statu;
}
/// <summary>
@@ -482,15 +481,25 @@
lock (dicAllDevice)
{
string mainKeys = this.GetDeviceMainKeys(device);
- if (this.dicAllDevice.ContainsKey(mainKeys) == false)
+ if (this.dicAllDevice.ContainsKey(mainKeys) == true)
{
- return;
- }
- this.dicAllDevice[mainKeys] = device;
- device.ReSave();
+ //涓�鑸澶�
+ this.dicAllDevice[mainKeys] = device;
+ device.ReSave();
- //娣诲姞鑷姩澶囦唤
- HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+ //娣诲姞鑷姩澶囦唤
+ HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+ }
+ else if (this.dicOTADevice.ContainsKey(mainKeys) == true)
+ {
+ //Ota璁惧
+ this.dicOTADevice[mainKeys] = (OTADevice)device;
+ device.ReSave();
+
+ //娣诲姞鑷姩澶囦唤
+ HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+
+ }
}
}
@@ -522,11 +531,14 @@
return false;
}
- //鍒犻櫎鏂囦欢
+ //鍒犻櫎缂撳瓨鐨凮ta璁惧
+ this.DeleteMemmoryOtaDevice(listdevice[0].DeviceAddr);
+ //鍒犻櫎涓�鑸澶囨枃浠�
foreach (CommonDevice device in listdevice)
{
this.DeleteMemmoryDevice(device);
}
+
if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true)
{
//绉婚櫎鐪熷疄璁惧鐨勬埧闂寸储寮�
@@ -537,7 +549,7 @@
}
/// <summary>
- /// 鍒犻櫎缂撳瓨鐨勮澶�
+ /// 鍒犻櫎缂撳瓨鐨勪竴鑸澶�
/// </summary>
/// <param name="device">璁惧瀵硅薄</param>
/// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param>
@@ -547,6 +559,8 @@
{
//浠庢埧闂翠腑鍒犻櫎
Room.CurrentRoom.DeleteDevice(device);
+ //鍒犻櫎鎴戠殑鍠滅埍鐨勮澶�
+ Room.CurrentRoom.DeleteLoveDevice(device);
}
//鍒犻櫎缂撳瓨
@@ -556,6 +570,11 @@
if (this.dicAllDevice.ContainsKey(mainKeys) == true)
{
this.dicAllDevice.Remove(mainKeys);
+ }
+ if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
+ {
+ //鍙樻洿绔偣鏁�
+ this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
}
}
@@ -576,9 +595,17 @@
HdlAutoBackupLogic.DeleteFile(device.FilePath);
}
}
+ }
+ /// <summary>
+ /// 鍒犻櫎缂撳瓨鐨凮ta璁惧
+ /// </summary>
+ /// <param name="macAdrr"></param>
+ /// <param name="ePoint"></param>
+ public void DeleteMemmoryOtaDevice(string macAdrr, int ePoint = 200)
+ {
//鍒犻櫎200绔彛鏂囦欢
- string otaKeys = this.GetDeviceMainKeys(device.DeviceAddr, 200);
+ string otaKeys = this.GetDeviceMainKeys(macAdrr, ePoint);
if (this.dicOTADevice.ContainsKey(otaKeys) == true)
{
string otaFile = this.dicOTADevice[otaKeys].FilePath;
@@ -587,12 +614,12 @@
if (UserCenterResourse.UserInfo.AuthorityNo == 3)
{
//鎴愬憳鐨勮瘽,鐩存帴鍒犻櫎,娌℃湁鍟嗛噺鐨勪綑鍦�
- Global.DeleteFilebyHomeId(filePath);
+ Global.DeleteFilebyHomeId(otaFile);
}
else
{
//鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜�
- Global.DeleteFilebyHomeId(filePath);
+ Global.DeleteFilebyHomeId(otaFile);
//鍒犻櫎鑷姩澶囦唤
HdlAutoBackupLogic.DeleteFile(otaFile);
}
@@ -676,8 +703,9 @@
/// 鏍规嵁缃戝叧ID鑾峰彇鎵�鏈夌殑璁惧
/// </summary>
/// <param name="gwId">缃戝叧ID</param>
+ /// <param name="getOtaDevice">鏄惁鑾峰彇ota璁惧</param>
/// <returns></returns>
- public List<CommonDevice> GetDeviceByGatewayID(string gwId)
+ public List<CommonDevice> GetDeviceByGatewayID(string gwId, bool getOtaDevice = false)
{
List<CommonDevice> list = new List<CommonDevice>();
lock (dicAllDevice)
@@ -688,6 +716,17 @@
if (gwId == device.CurrentGateWayId)
{
list.Add(device);
+ }
+ }
+ if (getOtaDevice == true)
+ {
+ //鑾峰彇ota璁惧
+ foreach (var ota in this.dicOTADevice.Values)
+ {
+ if (ota.CurrentGateWayId == gwId)
+ {
+ list.Add(ota);
+ }
}
}
}
@@ -813,6 +852,30 @@
return this.dicOTADevice[mainkeys];
}
+ /// <summary>
+ /// 鑾峰彇鐗规畩鐨�,娌℃湁鍏朵粬鍥炶矾,鍗曠函鍙湁200绔偣鐨凮TA璁惧
+ /// </summary>
+ /// <param name="gwId">缃戝叧ID</param>
+ /// <returns></returns>
+ public List<OTADevice> GetSpecialOtaDevice(string gwId)
+ {
+ var list = new List<OTADevice>();
+ foreach (var ota in this.dicOTADevice.Values)
+ {
+ if (ota.CurrentGateWayId != gwId)
+ {
+ //涓嶆槸鍚屼竴涓綉鍏�
+ continue;
+ }
+ if (dicDeviceEpoint.ContainsKey(ota.DeviceAddr) == false
+ || dicDeviceEpoint[ota.DeviceAddr].Count == 0)
+ {
+ list.Add(ota);
+ }
+ }
+ return list;
+ }
+
#endregion
#region 鈻� 鑾峰彇璁惧鍚嶇О_______________________
@@ -830,16 +893,39 @@
return dName;
}
//鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О
- dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
+ var tempValue = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
+ var arry = tempValue.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
+ dName = arry[0].Trim();
+
//濡傛灉鏄櫄鎷熻澶�
- if (device.DriveCode > 0
- || (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1))
+ if (device.DriveCode > 0)
{
- var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
- dName = arry[0].Trim();
//鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
+ return dName;
}
+
+ //鑾峰彇璁惧绫诲瀷
+ var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+ if (deviceInfoType.BeloneType == Common.DeviceBeloneType.A鎸夐敭闈㈡澘 && device.Type == DeviceType.TemperatureSensor)
+ {
+ //闈㈡澘鐨勬渶鍚庝竴涓洖璺槸娓╁害浼犳劅鍣�
+ dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId11);
+ }
+ else if (deviceInfoType.ConcreteType == Common.DeviceConcreteType.Sensor_Pir)
+ {
+ //pir浼犳劅鍣�,瀹冨張鎼炵壒娈婁笢瑗�,浼犳劅鍣ㄨ嚜韬敤鑷繁鐨勫悕瀛�,缁х數鍣ㄥ洖璺殑璇濃�︹��
+ if (device.Type == DeviceType.OnOffOutput)
+ {
+ dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2300);
+ }
+ }
+ else if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1)
+ {
+ //XXXXX(N鍥炶矾)
+ dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
+ }
+
return dName;
}
@@ -1046,11 +1132,22 @@
/// <param name="listdevice">璁惧瀵硅薄</param>
public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice)
{
+ //鑾峰彇璁惧鐨勭湡瀹炲浘鐗�
+ string imagePath = this.GetRealDeviceIcon(listdevice);
+ btnIcon.UnSelectedImagePath = imagePath;
+ }
+
+ /// <summary>
+ /// 鑾峰彇璁惧鐨勭湡瀹炲浘鐗�
+ /// </summary>
+ /// <param name="listdevice">璁惧瀵硅薄</param>
+ public string GetRealDeviceIcon(List<CommonDevice> listdevice)
+ {
//鑾峰彇瀹冨睘浜庝粈涔堢被鍨嬬殑璁惧
var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
- string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType);
-
- //鍥剧墖鍏辨湁
+ string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType);
+
+ //鍥剧墖鍏辨湁
if (this.dicPictrueShard.ContainsKey(strConcrete) == true)
{
strConcrete = this.dicPictrueShard[strConcrete];
@@ -1067,7 +1164,7 @@
if (arry.Length == 1)
{
//濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊
- return;
+ return "RealDevice/CommonDevice.png";
}
imageFilePath = "RealDevice/" + arry[0] + ".png";
//濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗�
@@ -1076,16 +1173,16 @@
imageFilePath = "RealDevice/CommonDevice.png";
}
}
- btnIcon.UnSelectedImagePath = imageFilePath;
+ return imageFilePath;
}
/// <summary>
- /// 璁剧疆銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢
+ /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢
/// </summary>
/// <param name="btnIcon">鎺т欢瀵硅薄</param>
/// <param name="listdevice">璁惧瀵硅薄</param>
/// <returns></returns>
- public void SetDeviceBeloneIconToControl(Button btnIcon, List<CommonDevice> listdevice)
+ public void SetDeviceObjectIconToControl(Button btnIcon, List<CommonDevice> listdevice)
{
//鑾峰彇鑷畾涔夎澶囩被鍨�
var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
@@ -1093,8 +1190,8 @@
string imageUnSelectFilePath = string.Empty;
string imageSelectFilePath = string.Empty;
- //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣
- this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
+ //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+ this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
//璁剧疆鍥剧墖
btnIcon.UnSelectedImagePath = imageUnSelectFilePath;
@@ -1102,29 +1199,29 @@
}
/// <summary>
- /// 鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣
+ /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
/// </summary>
/// <param name="listdevice">璁惧瀵硅薄</param>
/// <param name="unSelectPath">鍥剧墖鍦板潃</param>
/// <param name="selectPath">鍥剧墖鍦板潃</param>
/// <returns></returns>
- public void GetDeviceBeloneIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
+ public void GetDeviceObjectIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
{
//鑾峰彇鑷畾涔夎澶囩被鍨�
var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
- //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣
- this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
+ //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+ this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
}
/// <summary>
- /// 鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣
+ /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
/// </summary>
/// <param name="specificType">鑷畾涔夎澶囩被鍨�</param>
/// <param name="unSelectPath">鍥剧墖鍦板潃</param>
/// <param name="selectPath">鍥剧墖鍦板潃</param>
/// <returns></returns>
- public void GetDeviceBeloneIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
+ public void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
{
//灏嗗叿浣撶被鍨嬭浆瀛楃涓�
string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType);
@@ -1144,13 +1241,18 @@
{
//涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗�
string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None);
- if (arry.Length == 1)
+ //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊
+ if (arry.Length > 1)
{
- //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊
- return;
+ imageFilePath = "Device/" + arry[0] + ".png";
+ imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
}
- imageFilePath = "Device/" + arry[0] + ".png";
- imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
+ }
+ //濡傛灉閭f璁惧杩炲叡閫氬浘鐗囬兘娌℃湁鐨勮瘽
+ if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+ {
+ imageFilePath = "Device/ThirdPartyDevice.png";
+ imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png";
}
//璁剧疆鍥剧墖
unSelectPath = imageFilePath;
@@ -1318,14 +1420,51 @@
#region 鈻� 鑾峰彇绗笁鏂硅澶囩殑璁惧绫诲瀷___________
/// <summary>
- /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
+ /// 鑾峰彇璁惧鐨勩�愭墍灞炵被鍨嬩俊鎭��,姝ゆ柟娉曚細鎶婃墍鏈夌殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�(鍖呮嫭娓╂箍搴︿紶鎰熷櫒)
/// </summary>
/// <param name="device">璁惧鍥炶矾</param>
- /// <param name="margeSensor">
- /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para>
- /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para>
- /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para>
- /// </param>
+ /// <returns></returns>
+ public DeviceEnumInfo GetDeviceBelongEnumInfo(CommonDevice device)
+ {
+ var info = this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device });
+ if (info.BeloneType == DeviceBeloneType.A璋冨厜鍣�
+ || info.BeloneType == DeviceBeloneType.A褰╃伅)
+ {
+ //褰掍负鐏厜
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
+ info.BeloneType = DeviceBeloneType.A鐏厜;
+ info.ConcreteType = DeviceConcreteType.Light;
+
+ int value = (int)info.BeloneType;
+ if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
+ {
+ //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧
+ info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value];
+ }
+ }
+ else if (info.BeloneType == DeviceBeloneType.A浼犳劅鍣�
+ || device.Type == DeviceType.TemperatureSensor)
+ {
+ //浼犳劅鍣ㄥ悎骞�
+ info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
+ info.ConcreteType = DeviceConcreteType.Sensor;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
+
+ int value = (int)info.BeloneType;
+ if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
+ {
+ //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧
+ info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value];
+ }
+ }
+
+ return info;
+ }
+
+ /// <summary>
+ /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��(涓嶅缓璁娇鐢�)
+ /// </summary>
+ /// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
/// <returns></returns>
public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(CommonDevice device, bool margeSensor = true)
{
@@ -1337,9 +1476,9 @@
/// </summary>
/// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
/// <param name="margeSensor">
- /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para>
- /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para>
- /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para>
+ /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para>
+ /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para>
+ /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para>
/// </param>
/// <returns></returns>
public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice, bool margeSensor = true)
@@ -1365,7 +1504,7 @@
}
else
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
info.BeloneType = DeviceBeloneType.A骞叉帴鐐�;
info.ConcreteType = DeviceConcreteType.DryContact;
}
@@ -1387,19 +1526,19 @@
if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A寮�鍏�)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
info.BeloneType = DeviceBeloneType.A寮�鍏�;
info.ConcreteType = DeviceConcreteType.Switch;
}
else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鎻掑骇)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
info.BeloneType = DeviceBeloneType.A鎻掑骇;
info.ConcreteType = DeviceConcreteType.Socket1;
}
else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鐏厜)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
info.BeloneType = DeviceBeloneType.A鐏厜;
info.ConcreteType = DeviceConcreteType.Light;
}
@@ -1414,19 +1553,19 @@
if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A寮�鍏�)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
info.BeloneType = DeviceBeloneType.A寮�鍏�;
info.ConcreteType = DeviceConcreteType.Switch;
}
else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鎻掑骇)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
info.BeloneType = DeviceBeloneType.A鎻掑骇;
info.ConcreteType = DeviceConcreteType.Socket1;
}
else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鐏厜)
{
- //info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
+ info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
info.BeloneType = DeviceBeloneType.A鐏厜;
info.ConcreteType = DeviceConcreteType.Light;
}
@@ -1479,11 +1618,8 @@
info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
info.ConcreteType = DeviceConcreteType.Sensor;
info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
- if (margeSensor == false)
- {
- //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
- this.SetSensorDeviceSpecificType(ref info, listdevice);
- }
+ //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+ this.SetSensorDeviceSpecificType(ref info, listdevice);
}
//13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇�
else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
@@ -1513,14 +1649,14 @@
//璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒;
info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
- info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
+ info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
}
else if (temperatrue == true && humidity == false)
{
//璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�;
info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
- info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
+ info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
}
else if (temperatrue == false && humidity == true)
{
@@ -1643,6 +1779,11 @@
//濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜�
if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
{
+ if (listDevice[0] is OTADevice)
+ {
+ //鍗曠函鍙槸Ota璁惧鍒欎笉澶勭悊
+ return;
+ }
Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false);
}
}
@@ -1785,36 +1926,23 @@
#region 鈻� 鑾峰彇璁惧鍒楄〃鐨勬帴鍙________________
/// <summary>
- /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢鈽呪槄鈽呪槄鈽呪槄鈽�)
+ /// <para>浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(杩斿洖鐨勮澶囦负铏氭嫙鍑烘潵鐨�)</para>
+ /// <para>statu鐘舵�� -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</para>
/// </summary>
/// <param name="zbGateway">缃戝叧瀵硅薄</param>
- /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿,true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param>
- /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�</param>
+ /// <param name="statu">鐘舵��-> -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</param>
+ /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿(姝ゅ彉閲忔槸缁欒幏鍙栧湪绾跨姸鎬佺敤鐨�),true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param>
/// <param name="mode">鏄惁鏄剧ず閿欒</param>
/// <returns></returns>
- public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
+ public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, 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;
+ statu = 1;
+ return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
}
}
zbGateway.LastDateTime = DateTime.Now;
@@ -1831,6 +1959,7 @@
string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
this.ShowTipMsg(msg);
}
+ statu = -1;
return null;
}
@@ -1883,8 +2012,6 @@
//缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾
if (listCheck.Contains(mainkeys) == false)
{
- //鍥炶皟鍑芥暟
- deviceComingAction?.Invoke(device);
listDevice.Add(device);
listCheck.Add(mainkeys);
@@ -1933,6 +2060,7 @@
msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂", false);
this.ShowTipMsg(msg);
}
+ statu = -1;
return null;
}
else
@@ -1943,12 +2071,9 @@
string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
this.ShowTipMsg(msg);
}
+ statu = 2;
}
- }
-
- //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚)
- deviceComingAction = null;
-
+ }
return listDevice;
}
@@ -2154,9 +2279,9 @@
this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200";//2鎸夐敭瑙︽懜闈㈡澘
this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200";//12鎸夐敭瑙︽懜闈㈡澘
this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200";//4鎸夐敭瑙︽懜闈㈡澘(鍙甫鐢垫簮搴曞骇)
- this.dicDeviceModelIdEnum["MPT4R4L/S-ZB1.8"] = "220-200";//绠�绾�4鎸夐敭闈㈡澘
- this.dicDeviceModelIdEnum["MPT3R3L/S-ZB1.8"] = "221-200";//绠�绾�3鎸夐敭闈㈡澘
- this.dicDeviceModelIdEnum["MPT2R2L/S-ZB1.8"] = "222-200";//绠�绾�2鎸夐敭闈㈡澘
+ this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//绠�绾�4鎸夐敭闈㈡澘
+ this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//绠�绾�3鎸夐敭闈㈡澘
+ this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//绠�绾�2鎸夐敭闈㈡澘
//=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir浼犳劅鍣�220
@@ -2191,6 +2316,8 @@
this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200";//zigbee杞琤uspro鍗忚杞崲鍣�
this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200";//zigbee杞�485鍗忚杞崲鍣�
+
+
//鉁┾湬鉁┾湬鉁╅渶瑕佷氦鎹㈢殑妯″潡ID鉁┾湬鉁┾湬鉁�
this.dicDeviceModelIdChanged = new Dictionary<string, string>();
//=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫烩槄鈽�=========
@@ -2200,6 +2327,8 @@
this.dicDeviceModelIdChanged["MULTI-MOTI--EA04"] = "MSPIR01/M-ZB.10";//绾㈠浼犳劅鍣�
this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//姘存蹈浼犳劅鍣�
this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//绱ф�ユ寜閿�
+
+
//鉁┾湬鉁┾湬鉁╅渶瑕佸叡鏈夌殑鍥剧墖瀵硅薄鉁┾湬鉁┾湬鉁�
this.dicPictrueShard = new Dictionary<string, string>();
@@ -2324,11 +2453,11 @@
/// <summary>
/// 娓╂箍搴︿紶鎰熷櫒
/// </summary>
- Sensor_TemperatrueHumidity = -1308,
+ Sensor_TemperatureHumidity = -1308,
/// <summary>
/// 娓╁害浼犳劅鍣�
/// </summary>
- Sensor_Temperatrue = -1309,
+ Sensor_Temperature = -1309,
/// <summary>
/// 婀垮害浼犳劅鍣�
/// </summary>
@@ -2416,19 +2545,19 @@
//=========鈽呪槄鍏朵粬绫�(????-????)鈽呪槄=========
/// <summary>
- /// 骞叉帴鐐�
+ /// 骞叉帴鐐�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
DryContact = -10000,
/// <summary>
- /// 鐏厜(娉ㄦ剰,瀹冭緭鍏ュ叾浠栫被,涓嶆槸璁惧绫诲瀷)
+ /// 鐏厜(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Light = -10001,
/// <summary>
- /// 鎻掑骇
+ /// 鎻掑骇(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Socket1 = -10002,
/// <summary>
- /// 寮�鍏�
+ /// 寮�鍏�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Switch = -10003,
}
--
Gitblit v1.8.0