From 9d61367c1fd278f58f721d4c0e69999f89e4485d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 12 十二月 2019 14:14:30 +0800
Subject: [PATCH] 添加最新绑定机制
---
ZigbeeApp/Shared/Common/Device.cs | 46 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
old mode 100755
new mode 100644
index 5e8b4ad..1362810
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -454,6 +454,11 @@
}
//澶囦唤鏁版嵁
await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName);
+ //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛�
+ if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
+ {
+ return await this.ReName(device, newMacName);
+ }
}
return true;
}
@@ -739,6 +744,20 @@
return -1;
});
return list;
+ }
+
+ /// <summary>
+ /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勬暟閲�
+ /// </summary>
+ /// <param name="DeviceAddr">Mac鍦板潃</param>
+ /// <returns></returns>
+ public int GetDevicesCountByMac(string DeviceAddr)
+ {
+ if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
+ {
+ return 0;
+ }
+ return dicDeviceEpoint[DeviceAddr].Count;
}
/// <summary>
@@ -1505,18 +1524,25 @@
/// </summary>
/// <param name="listDevice">闇�瑕佷繚瀛樼殑璁惧瀵硅薄</param>
/// <param name="roomId">闇�瑕佷繚瀛樼殑鍝釜璁惧鐨勬埧闂碔D</param>
- public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId)
+ /// <param name="saveRoadDevice">濡傛灉鍙湁涓�涓洖璺�,鏄惁鎶婂洖璺殑鎴块棿涓�璧蜂慨鏀�</param>
+ public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
{
- this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
+ if (listDevice != null)
+ {
+ this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
+ }
//淇濆瓨璁板綍
string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
+ //娣诲姞鑷姩澶囦唤
+ HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
+
//濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜�
- if (listDevice.Count == 1)
+ if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
{
- Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId);
+ Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false);
}
}
@@ -1613,16 +1639,16 @@
/// <returns></returns>
public string AppendVersion(int versionValue)
{
- //杞负16杩涘埗
- string txt64 = Convert.ToString(versionValue, 16).PadLeft(4, '0');
+ //鐩存帴鏄�10杩涘埗
+ string txt10 = Convert.ToString(versionValue).PadLeft(4, '0');
//杩欎釜鏄皬鏁扮偣鍓嶉潰鐨勫��
- int value1 = Convert.ToInt32(txt64.Substring(0, 2), 16);
+ int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2));
//杩欎釜鏄皬鏁扮偣鍚庨潰鐨勫��
- int value2 = Convert.ToInt32(txt64.Substring(2, 2), 16);
+ int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2));
//Ver.
string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
- return ver + value1 + "." + value2.ToString().PadLeft(3, '0');
+ return ver + value1 + "." + value2.ToString().PadLeft(2, '0');
}
/// <summary>
@@ -1796,7 +1822,7 @@
string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail);
msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(zbGateway).ToString() + "]";
msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂", false);
- this.ShowErrorMsg(msg);
+ this.ShowTipMsg(msg);
}
return null;
}
--
Gitblit v1.8.0