From b9cb076fe6127160c96c35bf9c8cebcffe1d5ccd Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 10 一月 2020 17:35:23 +0800
Subject: [PATCH] 2020.1.10
---
ZigbeeApp/Shared/Common/Device.cs | 198 +++++++++++++++++++++++++++++++++++++------------
1 files changed, 150 insertions(+), 48 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
old mode 100755
new mode 100644
index 4a805f6..32b497d
--- 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);
}
@@ -241,7 +241,7 @@
//鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶�
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)
{
@@ -260,7 +260,7 @@
//娣诲姞缂撳瓨
this.AddDeviceToMemory(ref device);
- //绉婚櫎瀛樺湪鐨勮澶囧唴瀛�
+ //绉婚櫎瀛樺湪鐨勮澶囧唴瀛�
string maikey = this.GetDeviceMainKeys(device);
if (dicExist.ContainsKey(maikey) == true)
{
@@ -273,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,10 +289,19 @@
}
//鍙湁瀹屽叏鑾峰彇鐨勬椂鍊�,鎵嶄細鍘诲鐞嗗垹闄ょ殑闂
- if (statu == 1)
+ if (statu != 1)
{
- //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鍒犻櫎鏈湴鐨勮澶�
- foreach (var device in dicExist.Values)
+ return statu;
+ }
+
+ //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鍒犻櫎鏈湴鐨勮澶�
+ foreach (var device in dicExist.Values)
+ {
+ if (device is OTADevice)
+ {
+ this.DeleteMemmoryOtaDevice(device.DeviceAddr);
+ }
+ else
{
this.DeleteMemmoryDevice(device, true);
}
@@ -484,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);
+
+ }
}
}
@@ -524,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)
{
//绉婚櫎鐪熷疄璁惧鐨勬埧闂寸储寮�
@@ -539,7 +549,7 @@
}
/// <summary>
- /// 鍒犻櫎缂撳瓨鐨勮澶�
+ /// 鍒犻櫎缂撳瓨鐨勪竴鑸澶�
/// </summary>
/// <param name="device">璁惧瀵硅薄</param>
/// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param>
@@ -561,6 +571,11 @@
{
this.dicAllDevice.Remove(mainKeys);
}
+ if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
+ {
+ //鍙樻洿绔偣鏁�
+ this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
+ }
}
//鍒犻櫎璁惧鏂囦欢
@@ -580,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;
@@ -591,12 +614,12 @@
if (UserCenterResourse.UserInfo.AuthorityNo == 3)
{
//鎴愬憳鐨勮瘽,鐩存帴鍒犻櫎,娌℃湁鍟嗛噺鐨勪綑鍦�
- Global.DeleteFilebyHomeId(filePath);
+ Global.DeleteFilebyHomeId(otaFile);
}
else
{
//鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜�
- Global.DeleteFilebyHomeId(filePath);
+ Global.DeleteFilebyHomeId(otaFile);
//鍒犻櫎鑷姩澶囦唤
HdlAutoBackupLogic.DeleteFile(otaFile);
}
@@ -680,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)
@@ -692,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);
+ }
}
}
}
@@ -817,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 鈻� 鑾峰彇璁惧鍚嶇О_______________________
@@ -834,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;
}
@@ -1242,7 +1324,7 @@
return info;
}
//鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
- return this.GetNotHdlMyDeviceEnumInfo(listdevice);
+ return this.GetNotHdlMyDeviceEnumInfo(listdevice, false);
}
/// <summary>
@@ -1272,7 +1354,7 @@
else
{
//鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
- var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice);
+ var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice, false);
strName = Language.StringByID(myDeviceType.ConcreteTextId);
}
if (ApendFalge == true && listDevice[0].DriveCode > 0)
@@ -1384,7 +1466,22 @@
/// </summary>
/// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
/// <returns></returns>
- public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice)
+ public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(CommonDevice device, bool margeSensor = true)
+ {
+ return this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device }, margeSensor);
+ }
+
+ /// <summary>
+ /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��(涓嶅缓璁娇鐢�)
+ /// </summary>
+ /// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
+ /// <param name="margeSensor">
+ /// <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)
{
var dicType = new Dictionary<DeviceType, CommonDevice>();
foreach (CommonDevice device in listdevice)
@@ -1682,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);
}
}
@@ -2443,19 +2545,19 @@
//=========鈽呪槄鍏朵粬绫�(????-????)鈽呪槄=========
/// <summary>
- /// 骞叉帴鐐�
+ /// 骞叉帴鐐�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
DryContact = -10000,
/// <summary>
- /// 鐏厜(娉ㄦ剰,瀹冭緭鍏ュ叾浠栫被,涓嶆槸璁惧绫诲瀷)
+ /// 鐏厜(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Light = -10001,
/// <summary>
- /// 鎻掑骇
+ /// 鎻掑骇(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Socket1 = -10002,
/// <summary>
- /// 寮�鍏�
+ /// 寮�鍏�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
/// </summary>
Switch = -10003,
}
--
Gitblit v1.8.0