From a4924de3136289d10cabbf2f61a228387d44ded7 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 07 十一月 2019 13:48:36 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC --- ZigbeeApp/Shared/Common/Device.cs | 2820 ++++++++++++++++++++++++----------------------------------- 1 files changed, 1,138 insertions(+), 1,682 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs old mode 100755 new mode 100644 index 0d5c065..4f4bcf7 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -37,61 +37,56 @@ } } /// <summary> - /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨 + /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨(鎺掑簭) /// </summary> public List<CommonDevice> listAllDevice { get { - var list = new List<CommonDevice>(); - foreach (var device in dicAllDevice.Values) + lock (dicAllDevice) { - list.Add(device); + var list = new List<CommonDevice>(); + foreach (var device in dicAllDevice.Values) + { + list.Add(device); + } + return list; } - return list; } } /// <summary> - /// R鏂囦欢閲岄潰璁惧榛樿鍚嶅瓧鐨処D鐨勫墠缂� + /// R鏂囦欢閲岄潰璁惧妯″潡ID鐨勭炕璇戝悕瀛楃殑鍓嶇紑 /// </summary> - public const string deviceDefultNameFlag = "uDeviceDefultName"; + public const string deviceModelIdName = "uDeviceModelId"; /// <summary> /// R鏂囦欢閲岄潰璁惧榛樿鍚嶅瓧鐨処D /// </summary> public Dictionary<string, int> dicDeviceDefultNameID = null; /// <summary> - /// 璁惧鐨勬ā鍧桰D鐨勬灇涓�(keys:妯″潡ID(宸茬炕璇�),value:璁惧鍏蜂綋绫诲瀷鍊�-璁惧鎵�灞炵被鍨嬪��(鑷畾涔夌殑鍊�,鍢�,鍙涓嶉噸澶嶅氨鍙互) + /// 璁惧鐨勬ā鍧桰D鐨勬灇涓�(keys:妯″潡ID value:璁惧鍏蜂綋绫诲瀷鍊�-璁惧鎵�灞炵被鍨嬪��(鑷畾涔夌殑鍊�,鍢�,鍙涓嶉噸澶嶅氨鍙互) /// </summary> private Dictionary<string, string> dicDeviceModelIdEnum = null; + /// <summary> + /// 闇�瑕佽浆鎹㈢殑璁惧鐨勬ā鍧桰D(keys:鏃фā鍧桰D,value:鏂版ā鍧桰D) + /// </summary> + private Dictionary<string, string> dicDeviceModelIdChanged = null; /// <summary> /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨(闈炲叕寮�) /// </summary> private Dictionary<string, CommonDevice> dicAllDevice = new Dictionary<string, CommonDevice>(); /// <summary> - /// 鏈湴鎵�鏈夎澶嘦I鐨勭紦瀛�(闈炲叕寮�) - /// </summary> - private Dictionary<string, DeviceUI> dicAllDeviceUI = new Dictionary<string, DeviceUI>(); - /// <summary> /// 鏈湴鎵�鏈夌殑椤剁偣鍗囩骇璁惧(闈炲叕寮�锛屼富閿槸MAC+200绔彛) /// </summary> private Dictionary<string, OTADevice> dicOTADevice = new Dictionary<string, OTADevice>(); /// <summary> - /// 璁惧璁℃暟 + /// 璁惧鐨勬�诲洖璺�(keys:Mac鍦板潃 value:鍏ㄩ儴绔彛鍙�) /// </summary> - private Dictionary<string, DeviceCountInfo> dicDeviceCount = new Dictionary<string, DeviceCountInfo>(); + private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>(); /// <summary> - /// 璁惧鏂囦欢鐨勫墠缂�鍚嶅瓧 + /// 鐗╃悊璁惧灞炰簬鍝釜鎴块棿鐨勮褰� /// </summary> - public const string deviceFirstName = "Device_"; - /// <summary> - /// 澶囩敤璁惧鏂囦欢鐨勫墠缂�鏍囪瘑鍚嶅瓧(涓鸿澶囧垹闄ゆ墍鐢�,杩欎釜鏂囦欢涓�鏃﹁澶囧垹闄ゅ悗灏变細涓�鐩村瓨鍦�) - /// </summary> - private string deviceBackupName = "Backup"; - /// <summary> - /// 閿� - /// </summary> - private object objLock = new object(); + private Dictionary<string, string> dicDeviceRoomId = null; #endregion @@ -103,8 +98,7 @@ public void ReFreshByLocal() { this.dicAllDevice.Clear(); - this.dicAllDeviceUI.Clear(); - this.dicDeviceCount.Clear(); + this.dicDeviceEpoint.Clear(); //鍒濆鍖朢鏂囦欢閲岄潰璁惧榛樿鍚嶅瓧鐨処D this.InitDeviceDefultNameIDList(); @@ -117,20 +111,32 @@ var device = ZigBee.Device.CommonDevice.CommonDeviceByFilePath(file); if (device == null || device.CurrentGateWayId == null) { +#if DEBUG + //璋冩煡,涓轰粈涔堝畠浼氭妸鍏ㄩ儴璁惧鍒犳帀锛� + string file1 = UserCenterLogic.CombinePath(file); + string file2 = UserCenterLogic.CombinePath("Back_" + file); + System.IO.File.Copy(file1, file2, true); +#endif //澶辨晥鐨勬枃浠讹紝娌℃湁缃戝叧id鐨勯兘鍒犻櫎鎺� Global.DeleteFilebyHomeId(file); continue; } //濡傛灉杩欎釜璁惧鐨勭綉鍏矷D涓嶅瓨鍦ㄧ殑璇� - if (Common.LocalGateway.Current.IsGatewayExist(device.CurrentGateWayId) == false) + if (HdlGatewayLogic.Current.IsGatewayExist(device.CurrentGateWayId) == false) { if (UserCenterResourse.UserInfo.AuthorityNo == 3) { //濡傛灉浠栨槸鎴愬憳鐨勮瘽,甯粬鏂板缓涓�涓綉鍏� - Common.LocalGateway.Current.AddVirtualGateway(device.CurrentGateWayId); + HdlGatewayLogic.Current.AddVirtualGateway(device.CurrentGateWayId); } else { +#if DEBUG + //璋冩煡,涓轰粈涔堝畠浼氭妸鍏ㄩ儴璁惧鍒犳帀锛� + string file1 = UserCenterLogic.CombinePath(file); + string file2 = UserCenterLogic.CombinePath("Back_" + file); + System.IO.File.Copy(file1, file2, true); +#endif //濡傛灉鏄富浜�,鎴栬�呯鐞嗗憳,閭d箞杩欎釜鏂囦欢鏄潪娉曠殑,鐩存帴鍒犻櫎 Global.DeleteFilebyHomeId(file); continue; @@ -147,39 +153,26 @@ //娣诲姞缂撳瓨 this.dicAllDevice[mainKey] = device; - //鍥炶矾璁℃暟 - if (this.dicDeviceCount.ContainsKey(device.DeviceAddr) == false) + //鍥炶矾鏀堕泦 + if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false) { - this.dicDeviceCount[device.DeviceAddr] = new DeviceCountInfo(); + this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>(); } - this.dicDeviceCount[device.DeviceAddr].Count += 1; - this.dicDeviceCount[device.DeviceAddr].hsEpoint.Add(device.DeviceEpoint); + this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint); - //妫�娴婾i鍥剧墖鏄惁姝g‘ - var deviceUi = this.GetDeviceUIFromLocalFile(device); - if (deviceUi == null) + //妫�娴婾i鍥剧墖鏄惁姝g‘,杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� + if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(device.IconPath)) == true) { - deviceUi = new DeviceUI(); - deviceUi.DeviceFileName = device.FilePath; - deviceUi.Save(); - HdlAutoBackupLogic.AddOrEditorFile(deviceUi.FileName); + //涓嶅瓨鍦ㄧ殑璇濓紝閲嶆柊鐢熸垚 + device.IconPath = string.Empty; + device.ReSave(); + HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); } - else - { - //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� - if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(deviceUi.IconPath)) == true) - { - //涓嶅瓨鍦ㄧ殑璇濓紝閲嶆柊鐢熸垚 - deviceUi.IconPath = string.Empty; - deviceUi.ReSave(); - HdlAutoBackupLogic.AddOrEditorFile(deviceUi.FileName); - } - } - //娣诲姞缂撳瓨 - this.dicAllDeviceUI[deviceUi.FileName] = deviceUi; } //鎴愬憳韬唤鐨勬椂鍊�,鍒犻櫎鎺夐潪娉曠殑缃戝叧鏂囦欢 this.DeleteGatewayFileByMemberModel(); + //鍒濆鍖栫墿鐞嗚澶囨墍灞炴埧闂寸殑璁板綍 + this.InitRealDeviceRoomId(); } /// <summary> @@ -192,21 +185,25 @@ 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 = Common.LocalGateway.Current.GetAllLocalGateway(); + var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway(); foreach (var gateway in listGateway) { - string gwId = Common.LocalGateway.Current.GetGatewayId(gateway); + string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway); if (listId.Contains(gwId) == false) { //杩欎釜缃戝叧瀵逛簬褰撳墠杩欎釜鎴愬憳鏉ヨ鏄潪娉曠殑 - Common.LocalGateway.Current.DeleteGatewayFile(gwId); + HdlGatewayLogic.Current.DeleteGatewayFile(gwId); } } } @@ -221,11 +218,11 @@ /// <param name="zbGateway">缃戝叧瀵硅薄</param> /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param> /// <returns>涓�鐩磋繑鍥瀟rue</returns> - public async Task<bool> SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null) + public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null) { //浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧 List<CommonDevice> listDevice = new List<CommonDevice>(); - List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, deviceComingAction); + List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction); if (list == null) { @@ -234,7 +231,7 @@ listDevice.AddRange(list); //鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶� - string gwID = Common.LocalGateway.Current.GetGatewayId(zbGateway); + string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID); Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>(); foreach (var device in listLocalDevices) @@ -260,6 +257,38 @@ { dicExist.Remove(maikey); } + //鑾峰彇璁惧鐨勫浐瀹氬睘鎬� + HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device); + } + + for (int i = 0; i < listDevice.Count; i++) + { + var device = listDevice[i]; + //瀵规湭鍛藉悕鐨勮澶囬噸鏂板懡鍚� + if (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) + ")"; + } + + HdlThreadLogic.Current.RunThread(async () => + { + await this.ReName(device, dName, ShowErrorMode.NO); + }); + } } //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鏆傛椂鍒犻櫎鏈湴鐨勮澶� @@ -269,26 +298,6 @@ this.DeleteMemmoryDevice(device, false); } - if (listDevice.Count > 0) - { - //绛夊緟涓�涓嬭澶囩殑纭欢淇℃伅 - await Task.Delay(1500); - //閲嶆柊鍙樻洿UI - foreach (var device in listDevice) - { - if (device == null || device.DeviceAddr == null || (device is OTADevice)) - { - continue; - } - var ui = this.GetDeviceUI(device); - if (ui.IsCustomizeImage == false) - { - ui.IconPath = string.Empty; - ui.ReSave(); - } - } - } - return true; } @@ -296,18 +305,13 @@ /// 娣诲姞璁惧鍒扮紦瀛�,瀛樺湪鏃惰鐩� /// </summary> /// <param name="device">璁惧瀵硅薄(杩欎釜涓滆タ鏈夊彲鑳戒細琚洿鏀�)</param> - /// <param name="ResetImageType">鏄惁閲嶇疆闀滃儚绫诲瀷</param> - public void AddDeviceToMemory(ref CommonDevice device, bool ResetImageType = false) + public void AddDeviceToMemory(ref CommonDevice device) { - //灏濊瘯鎭㈠鍒犻櫎浜嗙殑鏂囦欢 - bool backFile = this.RecoverBackupDeviceFile(ref device); - string mainKeys = this.GetDeviceMainKeys(device); //濡傛灉瀹冩槸鍗囩骇鐨勯《绔鐐�,鍒欎笉鑳借瀹冨姞鍏ュ埌缂撳瓨锛屼絾鏄彲浠ヨ浠栫敓鎴愭枃浠� if (device is OTADevice) { - //灏濊瘯鎭㈠鏂囦欢鎴愬姛,鎴栬�呮湰鍦伴兘娌℃湁杩欎釜璁惧 - if (backFile == true || this.dicOTADevice.ContainsKey(mainKeys) == false) + if (this.dicOTADevice.ContainsKey(mainKeys) == false) { this.dicOTADevice[mainKeys] = (OTADevice)device; } @@ -320,124 +324,49 @@ device = tempDevice; } - if (ResetImageType == true) - { - //ota璁惧鐨勯暅鍍忕被鍨嬪垵濮嬪�艰缃负-1 - device.ImgTypeId = -1; - device.ImgVersion = -1; - } - bool exists = Global.IsExistsByHomeId(device.FilePath); device.ReSave(); - if (exists == false) { //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); } - - //璁剧疆璁惧鍏ㄩ儴鐨勯暅鍍忎俊鎭� - this.SetAllImageInfoToOtaDevice((OTADevice)device); - 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; - } - //鑾峰彇璁惧鐨勭‖浠朵俊鎭� - this.SetAllHardFirmwareInfoToDevice(device); - - //铏氭嫙璁惧鐨勮瘽锛岄檮鍔犲洖璺彿 - if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty) - { - //鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О - var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false); - //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍� - dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")"; - this.SetEpointName(device, dName); - new System.Threading.Thread(async () => + if (this.dicAllDevice.ContainsKey(mainKeys) == true) { - //鍥犱负铏氭嫙璁惧涓嶄細缁忚繃璁惧鍏ョ綉杩欎竴姝ワ紝鎵�浠ョ洿鎺ョ粰瀹冧竴涓粯璁ゅ悕瀛� - await this.ReName(this.dicAllDevice[mainKeys], dName, ShowErrorMode.NO); - }) - { IsBackground = true }.Start(); + //浜ゆ崲灞炴�� + var tempDevice = this.dicAllDevice[mainKeys]; + //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑 + this.SetDeviceInfoToMain(tempDevice, device); + device = tempDevice; + } + else + { + this.dicAllDevice[mainKeys] = device; + } } - //璁惧璁℃暟 - if (this.dicDeviceCount.ContainsKey(device.DeviceAddr) == false) + //璁惧鍥炶矾鏀堕泦 + if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false) { - this.dicDeviceCount[device.DeviceAddr] = new DeviceCountInfo(); + this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>(); } - if (this.dicDeviceCount[device.DeviceAddr].hsEpoint.Contains(device.DeviceEpoint) == false) + if (this.dicDeviceEpoint[device.DeviceAddr].Contains(device.DeviceEpoint) == false) { - this.dicDeviceCount[device.DeviceAddr].Count += 1; - this.dicDeviceCount[device.DeviceAddr].hsEpoint.Add(device.DeviceEpoint); + this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint); } - //娣诲姞璁惧鐨勬椂鍊欙紝鐩存帴鍒涘缓璁惧鐨刄I鍥� - DeviceUI deviceUI = new DeviceUI(); - deviceUI.DeviceFileName = device.FilePath; - - bool exists2 = Global.IsExistsByHomeId(deviceUI.FileName); - deviceUI.Save(); - if (exists2 == false) - { - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(deviceUI.FileName); - this.dicAllDeviceUI[deviceUI.FileName] = deviceUI; - } - - exists2 = Global.IsExistsByHomeId(device.FilePath); + bool exists2 = Global.IsExistsByHomeId(device.FilePath); device.ReSave(); if (exists2 == false) { //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); } - } - - /// <summary> - /// 鎭㈠鍒犻櫎浜嗙殑鏂囦欢(浠呴檺娣诲姞璁惧鐨勬椂鍊�) - /// </summary> - /// <param name="device"></param> - private bool RecoverBackupDeviceFile(ref CommonDevice device) - { - //濡傛灉鏈湴瀛樺湪澶囩敤鐨勬枃浠跺す鐨勮瘽,鍒欎娇鐢ㄥ浠界殑鏂囦欢澶逛綔涓哄璞� - string backFile = deviceBackupName + device.FilePath; - if (Global.IsExistsByHomeId(device.FilePath) == true || Global.IsExistsByHomeId(backFile) == false) - { - //鍙湁鍦ㄦ湰鍦扮洰鏍囪澶囨枃浠朵笉瀛樺湪锛屽苟涓斿浠芥枃浠跺瓨鍦ㄧ殑鏃跺�欐墠澶勭悊 - return false; - } - - //鍙嶅簭鍒楀寲涓烘寚瀹氱殑绫伙紝涓嶇劧鏁版嵁浼氫涪澶辫�屽鑷存棤娉曞己杞�(鈽呰繖涓笢瑗夸繚瀛樼潃浠ュ墠鐨勭綉鍏冲浠芥暟鎹槄) - var tempDevice = ZigBee.Device.CommonDevice.CommonDeviceByFilePath(backFile); - if (tempDevice == null) - { - return false; - } - //涓嶆部鐢ㄥ悕瀛�,鍏堣繖鏍峰惂 - this.SetMacName(tempDevice, string.Empty); - this.SetEpointName(tempDevice, string.Empty); - - //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑 - this.SetDeviceInfoToMain(tempDevice, device); - //鏇挎崲瀵硅薄 - device = tempDevice; - - //杩欓噷缁х画淇濈暀鐫�閭d釜澶囦唤鏂囦欢锛屽ソ鍍忎篃娌′粈涔堥棶棰樼殑鏍峰瓙 - - return true; } #endregion @@ -452,6 +381,11 @@ /// <param name="mode">鏄惁鏄剧ず閿欒</param> public async Task<bool> ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES) { + //鍏堝埆绠¢偅涔堝锛屾洿鏀瑰悕瀛楀悗锛屽埛鏂拌澶囩紦瀛� + this.SetEpointName(device, newName); + + this.BackupDeviceAfterReName(device); + //涓嶅啀妫�娴嬪悕瀛楁槸鍚︿竴鏍� //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛� if (UserCenterResourse.UserInfo.AuthorityNo != 3) @@ -462,7 +396,7 @@ //璁惧鍚嶇О淇敼澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail); //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); if (mode == ShowErrorMode.YES) { @@ -473,12 +407,6 @@ //澶囦唤鏁版嵁 await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绔偣鍚嶇О, newName); } - - //鏇存敼鍚嶅瓧鍚庯紝鍒锋柊璁惧缂撳瓨 - this.SetEpointName(device, newName); - - this.BackupDeviceAfterReName(device); - return true; } @@ -494,31 +422,7 @@ { return true; } - CommonDevice device = listDevice[0]; - - //涓嶅啀妫�娴嬪悕瀛楁槸鍚︿竴鏍� - //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛� - if (UserCenterResourse.UserInfo.AuthorityNo != 3) - { - //淇敼鐗╃悊鍚嶅瓧 - var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName); - if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result == 1) - { - //璁惧鍚嶇О淇敼澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - if (mode == ShowErrorMode.YES) - { - this.ShowErrorMsg(msg); - } - return false; - } - //澶囦唤鏁版嵁 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName); - } - - //淇敼缂撳瓨 + //鍏堝埆绠¢偅涔堝锛屽厛淇敼缂撳瓨 for (int i = 0; i < listDevice.Count; i++) { var device2 = listDevice[i]; @@ -527,6 +431,29 @@ //鏇存敼鍚嶅瓧鍚庯紝鍒锋柊璁惧缂撳瓨 this.BackupDeviceAfterReName(device2); + } + + CommonDevice device = listDevice[0]; + //涓嶅啀妫�娴嬪悕瀛楁槸鍚︿竴鏍� + //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛� + if (UserCenterResourse.UserInfo.AuthorityNo != 3) + { + //淇敼鐗╃悊鍚嶅瓧 + var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName); + if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0) + { + //璁惧鍚嶇О淇敼澶辫触 + string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + if (mode == ShowErrorMode.YES) + { + this.ShowErrorMsg(msg); + } + return false; + } + //澶囦唤鏁版嵁 + await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName); } return true; } @@ -537,16 +464,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 @@ -571,7 +501,7 @@ //璁惧鍒犻櫎澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail); //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); this.ShowErrorMsg(msg); return false; @@ -581,6 +511,12 @@ foreach (CommonDevice device in listdevice) { this.DeleteMemmoryDevice(device); + } + if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true) + { + //绉婚櫎鐪熷疄璁惧鐨勬埧闂寸储寮� + this.dicDeviceRoomId.Remove(listdevice[0].DeviceAddr); + this.SaveRealDeviceRoomId(null, null); } return true; } @@ -594,9 +530,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); + } } //鍒犻櫎璁惧鏂囦欢 @@ -610,10 +549,8 @@ } else { - //涓嶅垹闄ゆ枃浠讹紝鐩存帴鏀瑰悕瀛� - string oldFile = UserCenterLogic.CombinePath(filePath); - string newFile = UserCenterLogic.CombinePath(deviceBackupName + filePath); - Global.MoveFileToDirectory(oldFile, newFile); + //鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜� + Global.DeleteFilebyHomeId(filePath); //鍒犻櫎鑷姩澶囦唤 HdlAutoBackupLogic.DeleteFile(device.FilePath); } @@ -633,10 +570,8 @@ } else { - //涓嶅垹闄ゆ枃浠讹紝鐩存帴鏀瑰悕瀛� - string oldFile = UserCenterLogic.CombinePath(otaFile); - string newFile = UserCenterLogic.CombinePath(deviceBackupName + otaFile); - Global.MoveFileToDirectory(oldFile, newFile); + //鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜� + Global.DeleteFilebyHomeId(filePath); //鍒犻櫎鑷姩澶囦唤 HdlAutoBackupLogic.DeleteFile(otaFile); } @@ -651,39 +586,25 @@ } } - /// <summary> - /// 鍒犻櫎璁惧鐨勫浠芥枃浠�(搴旇鍙湁鍦ㄥ垹闄ょ綉鍏崇殑鏃跺�欎娇鐢ㄥ惂) - /// </summary> - /// <param name="device"></param> - public void DeleteDeviceBackupFile(CommonDevice device) - { - string backFile = deviceBackupName + device.FilePath; - if (Global.IsExistsByHomeId(backFile) == true) - { - Global.DeleteFilebyHomeId(backFile); - HdlAutoBackupLogic.DeleteFile(backFile); - } - } - #endregion #region 鈻� 娴嬭瘯璁惧___________________________ /// <summary> - /// 鍙戦�佹祴璇曟寚浠ゅ埌璁惧 + /// 鍙戦�佸畾浣嶆寚浠ゅ埌璁惧 /// </summary> /// <param name="device"></param> - public void SetTestCommand(CommonDevice device) + public void SetFixedPositionCommand(CommonDevice device) { device.IdentifyControl(device.DeviceAddr, device.DeviceEpoint, 5); } /// <summary> - /// 妫�娴嬭澶囨槸鍚︽嫢鏈夋祴璇曠殑鍔熻兘 + /// 妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘 /// </summary> /// <param name="device"></param> /// <returns></returns> - public bool DeviceIsCanTest(CommonDevice device) + public bool DeviceIsCanFixedPosition(CommonDevice device) { foreach (var data in device.InClusterList) { @@ -744,12 +665,15 @@ 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) + //鍚勭綉鍏崇殑鎵�鏈夎澶� + foreach (CommonDevice device in this.dicAllDevice.Values) { - list.Add(device); + if (gwId == device.CurrentGateWayId) + { + list.Add(device); + } } } @@ -763,9 +687,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; } @@ -783,6 +710,38 @@ } /// <summary> + /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(宸茬粡鎺掑簭) + /// </summary> + /// <param name="DeviceAddr">Mac鍦板潃</param> + /// <returns></returns> + public List<CommonDevice> GetDevicesByMac(string DeviceAddr) + { + var list = new List<CommonDevice>(); + if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false) + { + return list; + } + foreach (var point in dicDeviceEpoint[DeviceAddr]) + { + var device = this.GetDevice(DeviceAddr, point); + if (device != null) + { + list.Add(device); + } + } + //鎺掑簭 + list.Sort((obj1, obj2) => + { + if (obj1.DeviceEpoint > obj2.DeviceEpoint) + { + return 1; + } + return -1; + }); + return list; + } + + /// <summary> /// 鑾峰彇鏈湴鍏ㄩ儴鐨勮澶囨枃浠� /// </summary> /// <returns></returns> @@ -790,9 +749,10 @@ { List<string> listDeviceFile = new List<string>(); List<string> listAllFile = Global.FileListByHomeId(); + foreach (string file in listAllFile) { - if (file.StartsWith(deviceFirstName) == false) + if (file.StartsWith("Device_") == false) { //濡傛灉涓嶆槸璁惧鏂囦欢 continue; @@ -803,715 +763,19 @@ } /// <summary> - /// 闄勫姞璁惧鐨勭増鏈唬鍙�(杩斿洖Ver.XXX) - /// </summary> - /// <param name="versionValue">鐗堟湰鍙�</param> - /// <returns></returns> - public string AppendVersion(int versionValue) - { - //杞负16杩涘埗 - string txt64 = Convert.ToString(versionValue, 16).PadLeft(4, '0'); - //杩欎釜鏄皬鏁扮偣鍓嶉潰鐨勫�� - int value1 = Convert.ToInt32(txt64.Substring(0, 2), 16); - //杩欎釜鏄皬鏁扮偣鍚庨潰鐨勫�� - int value2 = Convert.ToInt32(txt64.Substring(2, 2), 16); - - //Ver. - string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation); - return ver + value1 + "." + value2.ToString().PadLeft(3, '0'); - } - - /// <summary> /// 鑾峰彇OTA璁惧(200绔彛鐨�) /// </summary> /// <param name="macAdrr"></param> + /// <param name="ePoint"></param> /// <returns></returns> - public OTADevice GetOTADevice(string macAdrr) + public OTADevice GetOTADevice(string macAdrr, int ePoint = 200) { - string mainkeys = this.GetDeviceMainKeys(macAdrr, 200); + string mainkeys = this.GetDeviceMainKeys(macAdrr, ePoint); if (this.dicOTADevice.ContainsKey(mainkeys) == false) { return null; } return this.dicOTADevice[mainkeys]; - } - - #endregion - - #region 鈻� 璁惧闀滃儚(绉佹湁绫诲瀷)_________________ - - /// <summary> - /// OTA璁惧鑾峰彇闀滃儚鍚庣殑鍥炶皟鍑芥暟 - /// </summary> - private Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>> dicOtaBackAction = new Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>>(); - - /// <summary> - /// 璁剧疆璁惧鍏ㄩ儴鐨勯暅鍍忎俊鎭�(鍙嶅璋冪敤璇蜂娇鐢ㄣ�怐eviceAttributeLogic.Current.SetFirmwareVersionComand銆戝嚱鏁�) - /// </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 (objLock) - { - if (backAction != null) - { - this.dicOtaBackAction[tADevice.DeviceAddr] = backAction; - } - //璁剧疆璁惧鐨勫浐浠剁増鏈彿(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼) - this.SetFirmwareVersionToOtaDevice(tADevice); - } - } - - /// <summary> - /// 璁剧疆璁惧鐨勫浐浠剁増鏈彿(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼) - /// </summary> - /// <param name="tADevice"></param> - private void SetFirmwareVersionToOtaDevice(OTADevice tADevice) - { - if (DeviceAttributeLogic.Current.IsEsixt("DeviceAutoGetFirmwareVersion") == false) - { - //娣诲姞浜嬩欢 - DeviceAttributeLogic.Current.AddFirmwareVersionEvent("DeviceAutoGetFirmwareVersion", this.SetFirmwareVersionByInterfaceResult); - } - //鍙戦�佸懡浠� - DeviceAttributeLogic.Current.SetFirmwareVersionComand(tADevice); - } - - /// <summary> - /// 鏍规嵁鎺ュ彛鎺ㄩ�佺殑淇℃伅锛岃缃浐浠剁増鏈彿 - /// </summary> - /// <param name="device"></param> - private void SetFirmwareVersionByInterfaceResult(CommonDevice device) - { - string mainKeys = this.GetDeviceMainKeys(device); - if (this.dicOTADevice.ContainsKey(mainKeys) == false) - { - return; - } - - //璁剧疆鍥轰欢鐗堟湰淇℃伅 - DeviceAttributeLogic.Current.SetFirmwareVersion(device.DeviceStatusReport, this.dicOTADevice[mainKeys]); - this.dicOTADevice[mainKeys].ReSave(); - - lock (objLock) - { - if (this.dicOtaBackAction.ContainsKey(device.DeviceAddr) == true) - { - //璋冪敤鍥炶皟鍑芥暟 - this.dicOtaBackAction[device.DeviceAddr](device, device.DeviceStatusReport); - //鐒跺悗绉婚櫎 - this.dicOtaBackAction.Remove(device.DeviceAddr); - } - } - } - - #endregion - - #region 鈻� 璇诲彇浠ュ強璁剧疆璁惧纭欢淇℃伅___________ - - /// <summary> - /// 璁惧鑾峰彇纭欢淇℃伅鍚庣殑鍥炶皟鍑芥暟 - /// </summary> - private Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>> dicDeviceHardInfoBackAction = new Dictionary<string, Action<CommonDevice, CommonDevice.DeviceStatusReportData>>(); - /// 鑾峰彇纭欢淇℃伅鐨勫璞¤澶� - /// </summary> - private HashSet<string> hsGetHardInfoDevice = new HashSet<string>(); - - /// <summary> - /// 璇诲彇浠ュ強璁剧疆璁惧纭欢淇℃伅 - /// </summary> - /// <param name="device">璁惧鍥炶矾</param> - /// <param name="Reset">鏄惁閲嶇疆(涓嶉噸缃殑鎯呭喌鏃讹紝濡傛灉宸茬粡鏈夊�间簡锛屽垯涓嶅啀鑾峰彇)</param> - /// <param name="backAction">鍥炶皟鍑芥暟</param> - public void SetAllHardFirmwareInfoToDevice(CommonDevice device, bool Reset = false, Action<CommonDevice, CommonDevice.DeviceStatusReportData> backAction = null) - { - if (device == null) - { - return; - } - if (Reset == false) - { - if (device.ModelIdentifier != string.Empty) - { - return; - } - } - - lock (objLock) - { - string mainkeys = this.GetDeviceMainKeys(device); - this.hsGetHardInfoDevice.Add(mainkeys); - - if (backAction != null) - { - this.dicDeviceHardInfoBackAction[mainkeys] = backAction; - } - //璁剧疆璁惧鐨勭‖浠朵俊鎭�(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼) - this.SetHardFirmwareInfoToDevice(device); - } - } - - /// <summary> - /// 璁剧疆璁惧鐨勭‖浠朵俊鎭�(闇�瑕佺瓑寰呮帹閫佸悗鎵嶄細鏇存敼) - /// </summary> - /// <param name="device"></param> - private void SetHardFirmwareInfoToDevice(CommonDevice device) - { - if (DeviceAttributeLogic.Current.IsEsixt("DeviceGetHardFirmwareInfo") == false) - { - //娣诲姞浜嬩欢 - DeviceAttributeLogic.Current.AddFirmwareVersionEvent("DeviceGetHardFirmwareInfo", this.SetHardFirmwareInfoByInterfaceResult); - } - //鍙戦�佸懡浠� - DeviceAttributeLogic.Current.SetHardFirmwareInfoComand(device); - } - - /// <summary> - /// 鏍规嵁鎺ュ彛鎺ㄩ�佺殑淇℃伅锛岃缃澶囩‖浠朵俊鎭� - /// </summary> - /// <param name="device"></param> - private void SetHardFirmwareInfoByInterfaceResult(CommonDevice device) - { - string mainKeys = this.GetDeviceMainKeys(device); - if (this.hsGetHardInfoDevice.Contains(mainKeys) == false) - { - return; - } - //璁剧疆璁惧纭欢淇℃伅 - var localDevice = this.GetDevice(mainKeys); - if (localDevice == null) - { - return; - } - lock (objLock) - { - DeviceAttributeLogic.Current.SetHardFirmwareInfo(device.DeviceStatusReport, localDevice); - localDevice.ReSave(); - - this.hsGetHardInfoDevice.Remove(mainKeys); - if (this.dicDeviceHardInfoBackAction.ContainsKey(mainKeys) == true) - { - //璋冪敤鍥炶皟鍑芥暟 - this.dicDeviceHardInfoBackAction[mainKeys](device, device.DeviceStatusReport); - //鐒跺悗绉婚櫎 - this.dicDeviceHardInfoBackAction.Remove(mainKeys); - } - } - } - - /// <summary> - /// 绉婚櫎鑾峰彇璁惧纭欢淇℃伅鐨勭洃鍚嚎绋� - /// </summary> - /// <param name="device"></param> - public void RemoveDeviceHardInfoThread(CommonDevice device) - { - lock (objLock) - { - string mainKeys = this.GetDeviceMainKeys(device); - this.hsGetHardInfoDevice.Remove(mainKeys); - if (this.dicDeviceHardInfoBackAction.ContainsKey(mainKeys) == true) - { - //鐒跺悗绉婚櫎 - this.dicDeviceHardInfoBackAction.Remove(mainKeys); - } - } - } - - #endregion - - #region 鈻� 璁剧疆鍥炬爣___________________________ - - /// <summary> - /// 鍙樻洿璁惧鐨勫浘鏍� - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="unSelPath">鍥剧墖鍦板潃(闈為�夋嫨)</param> - public void ChangedDeviceIcon(CommonDevice device, string unSelPath) - { - if (unSelPath == string.Empty) - { - return; - } - DeviceUI deviceUI = this.GetDeviceUI(device); - deviceUI.IconPath = unSelPath; - deviceUI.IsCustomizeImage = true; - deviceUI.ReSave(); - - HdlAutoBackupLogic.AddOrEditorFile(deviceUI.FileName); - } - - /// <summary> - /// 璁剧疆璁惧銆愬浘鏍囥�戝埌鎸囧畾鐨勬帶浠� - /// </summary> - /// <param name="btnIcon">鎺т欢瀵硅薄</param> - /// <param name="device">璁惧瀵硅薄</param> - /// <returns></returns> - public void SetDeviceIconToControl(ButtonCommon btnIcon, CommonDevice device) - { - //鑾峰彇杩欎釜璁惧鐨刄I鏂囦欢 - DeviceUI deviceUI = this.GetDeviceUI(device); - if (deviceUI == null) - { - return; - } - if (string.IsNullOrEmpty(deviceUI.IconPath) == true) - { - return; - } - btnIcon.UnSelectedImagePath = deviceUI.IconPath; - - string selPath = deviceUI.OnlineIconPath; - if (string.IsNullOrEmpty(selPath) == false) - { - btnIcon.SelectedImagePath = selPath; - } - } - - /// <summary> - /// 璁剧疆璁惧鐨勩�愬ぇ鍥炬爣銆戝埌鎸囧畾鐨勬帶浠� - /// </summary> - /// <param name="btnIcon">鎺т欢瀵硅薄</param> - /// <param name="device">璁惧瀵硅薄</param> - public void SetDeviceBigIconToControl(ButtonCommon btnIcon, CommonDevice device) - { - //鑾峰彇杩欎釜璁惧鐨刄I鏂囦欢 - DeviceUI deviceUI = this.GetDeviceUI(device); - if (deviceUI == null) - { - return; - } - string deviceIcon = deviceUI.OnlineIconPath; - if (string.IsNullOrEmpty(deviceIcon) == true) - { - return; - } - - //鎸夐敭闈㈡澘鐨勫洖璺浘鏍� - if (deviceIcon == "Device/DryContactSelected.png") - { - //鍥犱负鎸夐敭闈㈡澘鏄竴涓偣锛屾墍浠ラ渶瑕佺壒娈婂鐞� - this.SetDeviceBeloneIconToControl(btnIcon, new List<CommonDevice>() { device }); - btnIcon.UnSelectedImagePath = btnIcon.SelectedImagePath; - btnIcon.SelectedImagePath = null; - } - else - { - //杩欓噷鏄嚜瀹氫箟鍥炬爣 - btnIcon.UnSelectedImagePath = deviceIcon; - } - } - - /// <summary> - /// 璁剧疆璁惧鐨勭湡瀹炲浘鐗囧埌鎸囧畾鐨勬帶浠� - /// </summary> - /// <param name="btnIcon">鎺т欢瀵硅薄</param> - /// <param name="listdevice">璁惧瀵硅薄</param> - public void SetRealDeviceIconToControl(ButtonCommon btnIcon, List<CommonDevice> listdevice) - { - //鑾峰彇瀹冨睘浜庝粈涔堢被鍨嬬殑璁惧 - var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); - string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType); - string strType = strConcrete.Replace("_", string.Empty); - //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧� - string imageFilePath = "RealDevice/" + strType + ".png"; - //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� - if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) - { - //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗� - string[] arry = strConcrete.Split(new string[] { "_" }, StringSplitOptions.None); - if (arry.Length == 1) - { - //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 - return; - } - imageFilePath = "RealDevice/" + arry[1] + ".png"; - } - btnIcon.UnSelectedImagePath = imageFilePath; - } - - /// <summary> - /// 璁剧疆銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢 - /// </summary> - /// <param name="btnIcon">鎺т欢瀵硅薄</param> - /// <param name="listdevice">璁惧瀵硅薄</param> - /// <returns></returns> - public void SetDeviceBeloneIconToControl(ButtonCommon btnIcon, List<CommonDevice> listdevice) - { - //鑾峰彇鑷畾涔夎澶囩被鍨� - var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); - - string imageUnSelectFilePath = string.Empty; - string imageSelectFilePath = string.Empty; - - //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 - this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath); - - //璁剧疆鍥剧墖 - btnIcon.UnSelectedImagePath = imageUnSelectFilePath; - btnIcon.SelectedImagePath = imageSelectFilePath; - } - - /// <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) - { - //鑾峰彇鑷畾涔夎澶囩被鍨� - var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); - - //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 - this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath); - } - - /// <summary> - /// 鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 - /// </summary> - /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param> - /// <param name="unSelectPath">鍥剧墖鍦板潃</param> - /// <param name="selectPath">鍥剧墖鍦板潃</param> - /// <returns></returns> - private void GetDeviceBeloneIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) - { - //灏嗗叿浣撶被鍨嬭浆瀛楃涓� - string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType); - string strType = strSpecific.Replace("_", string.Empty); - //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧� - string imageFilePath = "Device/" + strType + ".png"; - string imageSelectFilePath = "Device/" + strType + "Selected.png"; - - //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� - if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) - { - //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗� - string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None); - if (arry.Length == 1) - { - //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 - return; - } - imageFilePath = "Device/" + arry[1] + ".png"; - imageSelectFilePath = "Device/" + arry[1] + "Selected.png"; - } - //璁剧疆鍥剧墖 - unSelectPath = imageFilePath; - selectPath = imageSelectFilePath; - } - - #endregion - - #region 鈻� 璁惧UI鐩稿叧_________________________ - - /// <summary> - /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 - /// </summary> - /// <param name="device"></param> - /// <returns></returns> - public DeviceUI GetDeviceUI(CommonDevice device) - { - return this.GetDeviceUI("DeviceUI_" + device.FilePath); - } - - /// <summary> - /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 - /// </summary> - /// <param name="filePath"></param> - /// <returns></returns> - public DeviceUI GetDeviceUI(string filePath) - { - if (this.dicAllDeviceUI.ContainsKey(filePath) == true) - { - return this.dicAllDeviceUI[filePath]; - } - - var deviceUi = new DeviceUI(); - deviceUi.DeviceFileName = filePath.Replace("DeviceUI_", string.Empty); - deviceUi.ReSave(); - this.dicAllDeviceUI[filePath] = deviceUi; - return deviceUi; - } - - /// <summary> - /// 浠庢枃浠朵腑鑾峰彇鎸囧畾璁惧鐨刄I瀵硅薄(鏈夊彲鑳借繑鍥瀗ull) - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <returns></returns> - private DeviceUI GetDeviceUIFromLocalFile(CommonDevice device) - { - DeviceUI deviceUI = new DeviceUI(); - deviceUI.DeviceFileName = device.FilePath; - - if (Global.IsExistsByHomeId(deviceUI.FileName) == false) - { - return null; - } - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceUI.FileName)); - var tempCommon = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo); - return tempCommon; - } - - #endregion - - #region 鈻� 鑾峰彇鑷畾涔夌殑璁惧绫诲瀷_______________ - - /// <summary> - /// 鑾峰彇銆愯嚜瀹氫箟鐨勮澶囩被鍨嬨��,涓ょ绫诲瀷閮借缃簡 - /// </summary> - /// <param name="listdevice">璁惧瀵硅薄</param> - /// <returns></returns> - public DeviceEnumInfo GetMyDeviceEnumInfo(List<CommonDevice> listdevice) - { - //鑾峰彇娌充笢璁惧鐨勮澶囩被鍨� - DeviceEnumInfo info = this.GetHdlMyDeviceEnumInfo(listdevice[0]); - if (info != null) - { - return info; - } - //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - return this.GetNotHdlMyDeviceEnumInfo(listdevice); - } - - /// <summary> - /// 鑾峰彇璁惧鐨勩�愯澶囩被鍨嬨�戠殑缈昏瘧鏂囨湰(浼樺厛闀滃儚) - /// </summary> - /// <param name="listDevice"></param> - /// <param name="ApendFalge">绗笁鏂规垨鑰呰櫄鎷熻澶囩殑鏃跺�欙紝鏄惁娣诲姞鏍囪瘑</param> - /// <returns></returns> - public string GetDeviceObjectText(List<CommonDevice> listDevice, bool ApendFalge = true) - { - string strName = string.Empty; - if (this.dicDeviceModelIdEnum.ContainsKey(listDevice[0].ModelIdentifier) == true) - { - //鏍规嵁妯″潡ID锛岃幏鍙栬澶囧悕瀛� - strName = this.GetNameByModelId(listDevice[0]); - } - else - { - //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice); - strName = Language.StringByID(myDeviceType.TextId); - } - if (ApendFalge == true && listDevice[0].DriveCode > 0) - { - //铏氭嫙璁惧鍔犱釜鏍囪瘑 - strName += "鉁�"; - } - else if (ApendFalge == true && this.IsHdlDevice(listDevice[0]) == false) - { - //绗笁鏂硅澶囧姞涓爣璇� - strName += "鈽�"; - } - return strName; - } - - #endregion - - #region 鈻� 鑾峰彇娌充笢璁惧鐨勮澶囩被鍨媉____________ - - /// <summary> - /// 鑾峰彇Hdl璁惧鐨勩�愯嚜瀹氫箟鐨勮澶囩被鍨嬨�� - /// </summary> - /// <param name="device">闅忎究鏌愪竴鍥炶矾</param> - /// <returns></returns> - private DeviceEnumInfo GetHdlMyDeviceEnumInfo(CommonDevice device) - { - //璁惧鍏蜂綋绫诲瀷 - var info = new DeviceEnumInfo(); - info.IsHdlDevice = this.IsHdlDevice(device); - if (device.ModelIdentifier == string.Empty) - { - return null; - } - string modelKeys = device.ModelIdentifier; - if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false) - { - //娌℃湁鍖归厤鍒版ā鍧桰D锛屽垯鐩存帴璧扮涓夋柟璁惧鐨勫垽鏂� - return null; - } - - string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); - int ConcreteValue = Convert.ToInt32(strValue[0]); - int BeloneValue = Convert.ToInt32(strValue[1]); - - //璁惧鍏蜂綋绫诲瀷 - info.ConcreteType = (DeviceConcreteType)ConcreteValue; - if (info.ConcreteType.ToString() == ConcreteValue.ToString()) - { - info.ConcreteType = DeviceConcreteType.UnKownDevice; - return info; - } - - //璁剧疆璁惧鐨勩�愯澶囨墍灞炵被鍨嬨�� - info.BeloneType = (DeviceBeloneType)BeloneValue; - - return info; - } - - #endregion - - #region 鈻� 鑾峰彇绗笁鏂硅澶囩殑璁惧绫诲瀷___________ - - /// <summary> - /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - /// </summary> - /// <param name="listdevice"></param> - /// <returns></returns> - private DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice) - { - var dicType = new Dictionary<DeviceType, CommonDevice>(); - foreach (CommonDevice device in listdevice) - { - if (dicType.ContainsKey(device.Type) == false) - { - dicType[device.Type] = device; - } - } - var info = new DeviceEnumInfo(); - info.IsHdlDevice = false; - //1鍖呭惈闈㈡澘鐨勮瘽,褰撻潰鏉垮鐞� - if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true) - { - info.TextId = R.MyInternationalizationString.uButtonControl; - info.BeloneType = DeviceBeloneType.A鎸夐敭闈㈡澘; - info.ConcreteType = DeviceConcreteType.ButtonPanel; - } - //2鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊 - else if (dicType.ContainsKey(DeviceType.IASZone) == true) - { - //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 - info.BeloneType = DeviceBeloneType.A浼犳劅鍣�; - this.SetSensorDeviceSpecificType(ref info, listdevice); - } - //3鍖呭惈绐楀笜鐨勮瘽,褰撶獥甯樺鐞� - else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true) - { - info.TextId = R.MyInternationalizationString.uCurtain; - info.BeloneType = DeviceBeloneType.A绐楀笜; - info.ConcreteType = DeviceConcreteType.Curtain; - } - //4绌烘皵寮�鍏� - else if (dicType.ContainsKey(DeviceType.AirSwitch) == true) - { - info.TextId = R.MyInternationalizationString.uAirSwitch; - info.BeloneType = DeviceBeloneType.A绌烘皵寮�鍏�; - info.ConcreteType = DeviceConcreteType.AirSwitch; - } - //5缁х數鍣� - else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true) - { - info.TextId = R.MyInternationalizationString.uRelay; - info.BeloneType = DeviceBeloneType.A缁х數鍣�; - info.ConcreteType = DeviceConcreteType.Relay; - } - //6璋冨厜鍣� - else if (dicType.ContainsKey(DeviceType.DimmableLight) == true) - { - info.TextId = R.MyInternationalizationString.uDimmableLight; - info.BeloneType = DeviceBeloneType.A璋冨厜鍣�; - info.ConcreteType = DeviceConcreteType.DimmableLight; - } - //7褰╃伅 - else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true) - { - info.TextId = R.MyInternationalizationString.uColorDimmableLight; - info.BeloneType = DeviceBeloneType.A褰╃伅; - info.ConcreteType = DeviceConcreteType.ColorDimmableLight; - } - //8绌鸿皟 - else if (dicType.ContainsKey(DeviceType.Thermostat) == true) - { - info.TextId = R.MyInternationalizationString.Thermostat; - info.BeloneType = DeviceBeloneType.A绌鸿皟; - info.ConcreteType = DeviceConcreteType.AirConditioner; - } - //9涓户鍣� - else if (dicType.ContainsKey(DeviceType.Repeater) == true) - { - info.TextId = R.MyInternationalizationString.Repeater; - info.BeloneType = DeviceBeloneType.A涓户鍣�; - info.ConcreteType = DeviceConcreteType.Repeater; - } - //10杞崲鍣� - else if (dicType.ContainsKey(DeviceType.Transverter) == true) - { - info.TextId = R.MyInternationalizationString.uConverter; - info.BeloneType = DeviceBeloneType.A杞崲鍣�; - info.ConcreteType = DeviceConcreteType.Converter; - } - return info; - } - - #endregion - - #region 鈻� 浼犳劅鍣ㄥ叿浣撶殑绫诲瀷___________________ - - /// <summary> - /// 璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 - /// </summary> - /// <param name="info">鑷畾涔夎澶囨灇涓句俊鎭�</param> - /// <param name="listdevice">璁惧瀵硅薄</param> - private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice) - { - //榛樿鍚嶅瓧:浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.Sensor; - info.TextId = R.MyInternationalizationString.uSensor; - - //濡傛灉杩欎釜璁惧鎷ユ湁澶氫釜鍥炶矾鐨勮瘽,鎴戜篃涓嶇煡閬撴�庝箞鍛藉悕,鍙兘缁欎釜榛樿鍚嶅瓧 - if (listdevice.Count > 1) - { - return; - } - var iasZone = (IASZone)listdevice[0]; - if (iasZone.IasDeviceType == 13) - { - //杩愬姩浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.Motion_Sensor; - info.TextId = R.MyInternationalizationString.uMotionSensor; - } - else if (iasZone.IasDeviceType == 40) - { - //鐑熼浘浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.Fire_Sensor; - info.TextId = R.MyInternationalizationString.uDeviceDefultName1302; - } - else if (iasZone.IasDeviceType == 42) - { - //姘翠镜浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.Water_Sensor; - info.TextId = R.MyInternationalizationString.uDeviceDefultName1304; - } - else if (iasZone.IasDeviceType == 43) - { - //鐕冩皵浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.CarbonMonoxide_Sensor; - info.TextId = R.MyInternationalizationString.uDeviceDefultName1300; - } - else if (iasZone.IasDeviceType == 44) - { - //绱ф�ユ寜閽� - info.ConcreteType = DeviceConcreteType.EmergencyButton_Sensor; - info.TextId = R.MyInternationalizationString.uDeviceDefultName1305; - } - else if (iasZone.IasDeviceType == 277) - { - //閽ュ寵鎵� - info.ConcreteType = DeviceConcreteType.Keyfob_Sensor; - info.TextId = R.MyInternationalizationString.uKeyfob; - } - else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22) - { - //闂ㄧ獥浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.DoorWindowSensor_Sensor; - info.TextId = R.MyInternationalizationString.uDeviceDefultName1301; - } } #endregion @@ -1534,7 +798,7 @@ dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false); //濡傛灉鏄櫄鎷熻澶� if (device.DriveCode > 0 - || (this.dicDeviceCount.ContainsKey(device.DeviceAddr) == true && this.dicDeviceCount[device.DeviceAddr].Count > 1)) + || (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1)) { var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries); dName = arry[0].Trim(); @@ -1567,31 +831,8 @@ { //鑾峰彇绗笁鏂硅澶囩殑缈昏瘧鍚嶅瓧 var myDeviceType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); - return Language.StringByID(myDeviceType.TextId); + return Language.StringByID(myDeviceType.ConcreteTextId); } - } - - /// <summary> - /// 鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�,杩斿洖鏍煎紡锛歑XXX(NN鍥炶矾),濡傛灉娌℃湁鍚嶅瓧锛屽垯杩斿洖锛歂N鍥炶矾 - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <returns></returns> - public string AppendRoadTextToEpointName(CommonDevice device) - { - string pName = this.GetSimpleEpointName(device); - //鍥炶矾 - string txtValue = Language.StringByID(R.MyInternationalizationString.uDeviceCircuit); - if (string.IsNullOrEmpty(pName) == true) - { - //NN鍥炶矾 - return device.DeviceEpoint + txtValue; - } - else if (pName.Trim().EndsWith(txtValue) == true) - { - return pName; - } - //XXXX(NN鍥炶矾) - return pName + "(" + device.DeviceEpoint + txtValue + ")"; } /// <summary> @@ -1599,7 +840,7 @@ /// </summary> /// <param name="device"></param> /// <returns></returns> - public string GetNameByModelId(CommonDevice device) + private string GetNameByModelId(CommonDevice device) { if (device.ModelIdentifier == string.Empty) { @@ -1617,7 +858,7 @@ string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); int ConcreteValue = Convert.ToInt32(strValue[0]); - string keyName = deviceDefultNameFlag + ConcreteValue; + string keyName = deviceModelIdName + ConcreteValue; if (this.dicDeviceDefultNameID.ContainsKey(keyName) == true) { //R鏂囦欢閲岄潰璁剧疆鐨勫悕瀛� @@ -1685,7 +926,8 @@ var PropertyList = type.GetFields(); foreach (var item in PropertyList) { - if (item.Name.StartsWith(deviceDefultNameFlag) == true) + if (item.Name.StartsWith(deviceModelIdName) == true + || item.Name.StartsWith("uDeviceBelongId") == true) { this.dicDeviceDefultNameID[item.Name] = Convert.ToInt32(item.GetValue(null)); } @@ -1697,794 +939,620 @@ #endregion - #region 鈻� 璁惧鎺掑簭___________________________ + #region 鈻� 璁剧疆鍥炬爣___________________________ /// <summary> - /// 璁惧鎺掑簭 + /// 鍙樻洿璁惧鐨勫浘鏍� /// </summary> - /// <param name="listDevice">璁惧瀵硅薄</param> - /// <returns></returns> - public List<CommonDevice> SortDeviceList(List<CommonDevice> listDevice) + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="unSelPath">鍥剧墖鍦板潃(闈為�夋嫨)</param> + public void ChangedDeviceIcon(CommonDevice device, string unSelPath) { - List<CommonDevice> listSort = new List<CommonDevice>(); - var list = this.SortDeviceListByRule(listDevice); - listSort.AddRange(list); + if (unSelPath == string.Empty) + { + return; + } + device.IconPath = unSelPath; + device.IsCustomizeImage = true; + device.ReSave(); - return listSort; + HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); } /// <summary> - /// + /// 璁剧疆璁惧銆愬浘鏍囥�戝埌鎸囧畾鐨勬帶浠� /// </summary> - /// <param name="listDevice">璁惧瀵硅薄</param> + /// <param name="btnIcon">鎺т欢瀵硅薄</param> + /// <param name="device">璁惧瀵硅薄</param> /// <returns></returns> - private List<CommonDevice> SortDeviceListByRule(List<CommonDevice> listDevice) + public void SetDeviceIconToControl(Button btnIcon, CommonDevice device) { - //璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType) value锛氬瓨鏀捐澶囩殑瀹瑰櫒) - var dic = this.GetDeviceSortRule(); - dic["瀵硅薄澶�"] = new List<CommonDevice>(); - foreach (CommonDevice device in listDevice) + if (device == null) { - if (device is IASZone) - { - var iasZone = (IASZone)device; - //杩愬姩浼犳劅鍣� - if (iasZone.DeviceInfo.DeviceType == 13) - { - dic["杩愬姩浼犳劅鍣�"].Add(device); - } - //涓�姘у寲纰充紶鎰熷櫒 - else if (iasZone.DeviceInfo.DeviceType == 43) - { - dic["涓�姘у寲纰充紶鎰熷櫒"].Add(device); - } - //绱ф�ユ寜閽� - else if (iasZone.DeviceInfo.DeviceType == 44) - { - dic["绱ф�ユ寜閽�"].Add(device); - } - else - { - dic[DeviceType.IASZone.ToString()].Add(device); - } - continue; - } + btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png"; + return; + } + string unSelectFilePath = string.Empty; + string selectFilePath = string.Empty; - string checkKeys = device.Type.ToString(); - if (dic.ContainsKey(checkKeys) == true) - { - dic[checkKeys].Add(device); - } - else - { - dic["瀵硅薄澶�"].Add(device); - } - } - List<CommonDevice> lstSort = new List<CommonDevice>(); - foreach (var list in dic.Values) - { - lstSort.AddRange(list); - } - return lstSort; + //鑾峰彇璁惧銆愬浘鏍囥�� + this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath); + + btnIcon.UnSelectedImagePath = unSelectFilePath; + btnIcon.SelectedImagePath = selectFilePath; } /// <summary> - /// 鑾峰彇璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType) value锛氬瓨鏀捐澶囩殑瀹瑰櫒) + /// 鑾峰彇璁惧銆愬浘鏍囥�� /// </summary> + /// <param name="listdevice">璁惧瀵硅薄</param> + /// <param name="unSelectPath">鍥剧墖鍦板潃</param> + /// <param name="selectPath">鍥剧墖鍦板潃</param> /// <returns></returns> - private Dictionary<string, List<CommonDevice>> GetDeviceSortRule() + public void GetDeviceIcon(CommonDevice device, ref string unSelectPath, ref string selectPath) { - var dic = new Dictionary<string, List<CommonDevice>>(); - //涓�姘у寲纰充紶鎰熷櫒 - dic["涓�姘у寲纰充紶鎰熷櫒"] = new List<CommonDevice>(); - //绱ф�ユ寜閽� - dic["绱ф�ユ寜閽�"] = new List<CommonDevice>(); - //杩愬姩浼犳劅鍣� - dic["杩愬姩浼犳劅鍣�"] = new List<CommonDevice>(); - //浼犳劅鍣� - dic[DeviceType.IASZone.ToString()] = new List<CommonDevice>(); - //鎺у埗闈㈡澘 - dic[DeviceType.OnOffSwitch.ToString()] = new List<CommonDevice>(); - //缁х數鍣� - dic[DeviceType.OnOffOutput.ToString()] = new List<CommonDevice>(); - //鍗峰笜 - dic[DeviceType.WindowCoveringDevice.ToString()] = new List<CommonDevice>(); - //璋冨厜鐏� - dic[DeviceType.ColorDimmableLight.ToString()] = new List<CommonDevice>(); - //绌烘皵寮�鍏� - dic[DeviceType.AirSwitch.ToString()] = new List<CommonDevice>(); + if (string.IsNullOrEmpty(device.IconPath) == true) + { + return; + } + unSelectPath = device.IconPath; - return dic; + string selPath = device.OnlineIconPath; + if (string.IsNullOrEmpty(selPath) == false) + { + selectPath = selPath; + } + } + + /// <summary> + /// 璁剧疆璁惧鐨勭湡瀹炲浘鐗囧埌鎸囧畾鐨勬帶浠� + /// </summary> + /// <param name="btnIcon">鎺т欢瀵硅薄</param> + /// <param name="listdevice">璁惧瀵硅薄</param> + public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice) + { + //鑾峰彇瀹冨睘浜庝粈涔堢被鍨嬬殑璁惧 + var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); + string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType); + string strType = strConcrete.Replace("_", string.Empty); + //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧� + string imageFilePath = "RealDevice/" + strType + ".png"; + //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� + if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) + { + //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗� + string[] arry = strConcrete.Split(new string[] { "_" }, StringSplitOptions.None); + if (arry.Length == 1) + { + //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 + return; + } + imageFilePath = "RealDevice/" + arry[0] + ".png"; + //濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗� + if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) + { + imageFilePath = "RealDevice/CommonDevice.png"; + } + } + btnIcon.UnSelectedImagePath = imageFilePath; + } + + /// <summary> + /// 璁剧疆銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢 + /// </summary> + /// <param name="btnIcon">鎺т欢瀵硅薄</param> + /// <param name="listdevice">璁惧瀵硅薄</param> + /// <returns></returns> + public void SetDeviceBeloneIconToControl(Button btnIcon, List<CommonDevice> listdevice) + { + //鑾峰彇鑷畾涔夎澶囩被鍨� + var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); + + string imageUnSelectFilePath = string.Empty; + string imageSelectFilePath = string.Empty; + + //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 + this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath); + + //璁剧疆鍥剧墖 + btnIcon.UnSelectedImagePath = imageUnSelectFilePath; + btnIcon.SelectedImagePath = imageSelectFilePath; + } + + /// <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) + { + //鑾峰彇鑷畾涔夎澶囩被鍨� + var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); + + //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 + this.GetDeviceBeloneIcon(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) + { + //灏嗗叿浣撶被鍨嬭浆瀛楃涓� + string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType); + string strType = strSpecific.Replace("_", string.Empty); + //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧� + string imageFilePath = "Device/" + strType + ".png"; + string imageSelectFilePath = "Device/" + strType + "Selected.png"; + + //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛� + if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true) + { + //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗� + string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None); + if (arry.Length == 1) + { + //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 + return; + } + imageFilePath = "Device/" + arry[0] + ".png"; + imageSelectFilePath = "Device/" + arry[0] + "Selected.png"; + } + //璁剧疆鍥剧墖 + unSelectPath = imageFilePath; + selectPath = imageSelectFilePath; } #endregion - #region 鈻� 璁惧鐩爣缁戝畾_______________________ + #region 鈻� 璁惧UI鐩稿叧_________________________ /// <summary> - /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull) + /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> + /// <param name="device"></param> /// <returns></returns> - public async Task<List<CommonDevice>> GetBindTargetDevice(CommonDevice mainDevice) + public DeviceUI GetDeviceUI(CommonDevice device) { - var result = (BindObj.GetDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "GetDeviceBindAsync"); - if (result == null || result.getAllBindResponseData == null) - { - //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceBindTargetFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); + //鍒涘缓涓�涓柊鐨勪笢瑗跨粰杩囧幓 + var deviceUi = new DeviceUI(); + deviceUi.DeviceAddr = device.DeviceAddr; + deviceUi.DeviceEpoint = device.DeviceEpoint; + return deviceUi; + } - this.ShowErrorMsg(msg); + /// <summary> + /// 鑾峰彇璁惧鎵�鍖归厤鐨勮澶嘦I瀵硅薄 + /// </summary> + /// <param name="filePath"></param> + /// <returns></returns> + public DeviceUI GetDeviceUI(string filePath) + { + string[] arry = filePath.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); + if (arry.Length != 4) + { return null; } - var listDevice = new List<CommonDevice>(); - foreach (var data in result.getAllBindResponseData.BindList) - { - CommonDevice deviceTemp = this.GetDevice(data.BindMacAddr, data.BindEpoint); - if (deviceTemp == null) - { - continue; - } - listDevice.Add(deviceTemp); - } - return listDevice; - } - - /// <summary> - /// 缁戝畾璁惧鐨勭洰鏍�(杩斿洖鎴愬姛璁剧疆鐨勮澶�,閿欒鏃讹紝杩斿洖null) - /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> - /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param> - /// <param name="BindCluster">瑕佺粦瀹氱殑鐩爣璁惧</param> - /// <returns></returns> - public async Task<List<CommonDevice>> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6) - { - if (listDevice.Count == 0) - { - return new List<CommonDevice>(); - } - - var dicDevice = new Dictionary<string, CommonDevice>(); - - //缁勮鏁版嵁 - var addData = new IASZone.AddBindData(); - addData.DeviceAddr = mainDevice.DeviceAddr; - addData.Epoint = mainDevice.DeviceEpoint; - foreach (var device in listDevice) - { - var info = new IASZone.AddBindListObj(); - info.BindCluster = BindCluster; - info.BindMacAddr = device.DeviceAddr; - info.BindEpoint = device.DeviceEpoint; - info.BindType = 0; - - addData.BindList.Add(info); - - //杩斿洖鎴愬姛璁惧鐨勬椂鍊欎娇鐢� - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); - dicDevice[mainkeys] = device; - } - - var result = (BindObj.AddedDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "AddDeviceBindAsync", addData); - if (result == null || result.addedDeviceBindResponseData == null) - { - //缁戝畾鐩爣璁剧疆澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowErrorMsg(msg); - return null; - } - - var listSuccess = new List<CommonDevice>(); - foreach (var data in result.addedDeviceBindResponseData.BindList) - { - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); - //0:娣诲姞鎴愬姛 3:宸茬粡瀛樺湪锛屼篃鍙互浠h〃鎴愬姛 - if (data.Result == 0 || data.Result == 3) - { - if (dicDevice.ContainsKey(mainkeys) == true) - { - listSuccess.Add(dicDevice[mainkeys]); - } - } - //1锛氬け璐ワ紝鑺傜偣璁惧鎴栧満鏅笉瀛樺湪 - else if (data.Result == 1) - { - if (dicDevice.ContainsKey(mainkeys) == true) - { - //璁惧鍚嶇О 缁戝畾澶辫触 - string msg = this.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; - msg += Language.StringByID(R.MyInternationalizationString.BindFailed); - this.ShowTipMsg(msg); - } - } - //2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔� - else if (data.Result == 2) - { - if (result.addBindResultResponseData == null) - { - //璁惧鍚嶇О 缁戝畾澶辫触 - string msg = this.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; - msg += Language.StringByID(R.MyInternationalizationString.BindFailed); - this.ShowTipMsg(msg); - } - else - { - //娣诲姞鎴愬姛 - if (result.addBindResultResponseData.Result == 0) - { - if (dicDevice.ContainsKey(mainkeys) == true) - { - listSuccess.Add(dicDevice[mainkeys]); - } - } - //璁惧鍚嶇О 缁戝畾鍒楄〃宸叉弧 - else if (result.addBindResultResponseData.Result == 140) - { - string msg = this.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; - msg += Language.StringByID(R.MyInternationalizationString.uBindListIsFull); - this.ShowTipMsg(msg); - } - else - { - //璁惧鍚嶇О 缁戝畾澶辫触 - string msg = this.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; - msg += Language.StringByID(R.MyInternationalizationString.BindFailed); - this.ShowTipMsg(msg); - } - } - } - } - - return listSuccess; - } - - /// <summary> - /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍� - /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> - /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param> - /// <param name="BindCluster">瑕佺粦瀹氱殑鐩爣璁惧</param> - /// <returns></returns> - public async Task<bool> DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6) - { - //缁勮鏁版嵁 - var deleteData = new IASZone.DelDeviceBindData(); - deleteData.DeviceAddr = mainDevice.DeviceAddr; - deleteData.Epoint = mainDevice.DeviceEpoint; - - var info = new IASZone.RemoveBindListObj(); - info.BindCluster = 6; - info.BindMacAddr = deleteDevice.DeviceAddr; - info.BindEpoint = deleteDevice.DeviceEpoint; - info.BindType = 0; - - deleteData.RemoveBindList.Add(info); - - var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData); - if (result == null || result.delDeviceBindResponseData == null) - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowErrorMsg(msg); - return false; - } - - foreach (var data in result.delDeviceBindResponseData.RemoveBindList) - { - //0:鎴愬姛 1:璁惧涓嶅湪缁戝畾鍒楄〃涓� 锛屼篃鍙互浠h〃鎴愬姛 - if (data.Result == 0 || data.Result == 1) - { - return true; - } - //3:澶辫触锛屽湪绛夊緟鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛 - else if (data.Result == 3) - { - //鍏朵粬缁戝畾鐩爣姝e湪鍒犻櫎涓紝璇风◢鍚庡啀璇� - string msg = Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait); - this.ShowErrorMsg(msg); - return false; - } - //4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔� - else if (data.Result == 4) - { - if (result.removeBindResultResponseData == null) - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - this.ShowErrorMsg(msg); - return false; - } - else - { - //鎴愬姛 - if (result.removeBindResultResponseData.Result == 0) - { - return true; - } - //136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾 - else if (result.removeBindResultResponseData.Result == 136) - { - //杩欎釜鍙互褰撳仛鎴愬姛 - return true; - } - else - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - this.ShowErrorMsg(msg); - return false; - } - } - } - } - return false; - } - - /// <summary> - /// 鎵ц鎸囧畾璁惧瀵硅薄绫婚噷闈㈢殑鏂规硶(娉ㄦ剰锛氳繖涓槸涓撻棬璋冪敤寮傛锛屽苟涓旂瓑寰呭紓姝ュ畬鎴愮殑楂樼鎶�鍑芥暟,涓嶈皟鐢ㄥ紓姝ョ殑鎯呭喌锛屽埆浣跨敤姝ゅ嚱鏁�) - /// </summary> - /// <param name="device">闇�瑕佹墽琛岀殑璁惧鐨勮澶囧璞�</param> - /// <param name="method">鎸囧畾瑕佸姞杞界殑鏂规硶鍚�</param> - /// <param name="parameter">鍚姩鍙傛暟</param> - private async Task<object> LoadDeviceMethodByNameAsync(CommonDevice device, string method, params object[] parameter) - { - var task = device.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, device, parameter) as Task; - await task; - - var result = task.GetType().GetProperty("Result").GetValue(task, null); - return result; + //鍒涘缓涓�涓柊鐨勪笢瑗跨粰杩囧幓 + var deviceUi = new DeviceUI(); + deviceUi.DeviceAddr = arry[2]; + deviceUi.DeviceEpoint = Convert.ToInt32(arry[3]); + return deviceUi; } #endregion - #region 鈻� PIR浼犳劅鍣╛_________________________ + #region 鈻� 鑾峰彇鑷畾涔夌殑璁惧绫诲瀷_______________ /// <summary> - /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺�戯紝閿欒鏃惰繑鍥�-1 + /// 鑾峰彇銆愯嚜瀹氫箟鐨勮澶囩被鍨嬨��,涓ょ绫诲瀷閮借缃簡 /// </summary> - /// <param name="iASZone"></param> + /// <param name="listdevice">璁惧瀵硅薄</param> /// <returns></returns> - public async Task<int> GetPirLightAbilitySize(IASZone iASZone) + public DeviceEnumInfo GetMyDeviceEnumInfo(List<CommonDevice> listdevice) { - var data = await iASZone.GetPIRLightAbilitySizeAsync(); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(data); - if (error != null) + CommonDevice checkDevice = listdevice[0]; + foreach (var temp in listdevice) { - this.ShowErrorMsg(error); - return -1; + //鎷挎嫢鏈夋ā鍧桰D鐨勯偅涓洖璺潵鍒ゆ柇 + if (temp.ModelIdentifier != string.Empty) + { + checkDevice = temp; + } } - if (data == null || data.errorMessageBase != null || data.LightLevelCount == -1) + //鑾峰彇娌充笢璁惧鐨勮澶囩被鍨� + DeviceEnumInfo info = this.GetHdlMyDeviceEnumInfo(checkDevice); + if (info != null) { - //鑾峰彇浼犳劅鍣ㄥ厜鎰熺瓑绾уけ璐� - string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLightPerceptionRegulationFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data.errorMessageBase); - - this.ShowErrorMsg(msg); - return -1; + return info; } - - return data.LightLevelCount; + //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� + return this.GetNotHdlMyDeviceEnumInfo(listdevice); } /// <summary> - /// 鑾峰彇PIR浼犳劅鍣ㄧ殑銆愮伅鍏夐厤缃�戯紝閿欒鏃惰繑鍥瀗ull + /// 鑾峰彇璁惧鐨勩�愯澶囩被鍨嬨�戠殑缈昏瘧鏂囨湰(浼樺厛闀滃儚) /// </summary> - /// <param name="iASZone"></param> + /// <param name="listDevice"></param> + /// <param name="ApendFalge">绗笁鏂规垨鑰呰櫄鎷熻澶囩殑鏃跺�欙紝鏄惁娣诲姞鏍囪瘑</param> /// <returns></returns> - public async Task<IASZone.ConfigureParamates> GetPirSensorLightSettion(IASZone iASZone) + public string GetDeviceObjectText(List<CommonDevice> listDevice, bool ApendFalge = true) { - var data = await iASZone.GetPIRSensorParamateAsync(); - if (data == null || data.configureParamates == null) + CommonDevice checkDevice = listDevice[0]; + foreach (var temp in listDevice) { - //鑾峰彇浼犳劅鍣ㄧ伅鍏夎缃俊鎭け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uGetPirSensorLightSettionFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, data.errorMessageBase); - - this.ShowErrorMsg(msg); - return null; + //鎷挎嫢鏈夋ā鍧桰D鐨勯偅涓洖璺潵鍒ゆ柇 + if (temp.ModelIdentifier != string.Empty) + { + checkDevice = temp; + } } - return data.configureParamates; - } - /// <summary> - /// 璁剧疆PIR浼犳劅鍣ㄧ殑銆愮伅鍏夐厤缃�� - /// </summary> - /// <param name="iASZone">浼犳劅鍣ㄥ璞�</param> - /// <param name="configure">鐏厜閰嶇疆</param> - /// <returns></returns> - public async Task<bool> SetPirSensorLightSettion(IASZone iASZone, IASZone.ConfigureParamates configure) - { - var result = await iASZone.SetPIRSensorParamateAsync(configure); - if (result == null || result.responseData == null) + string strName = string.Empty; + if (this.dicDeviceModelIdEnum.ContainsKey(checkDevice.ModelIdentifier) == true) { - //璁剧疆浼犳劅鍣ㄧ伅鍏夐厤缃け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorLightSettionFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowErrorMsg(msg); - return false; + //鏍规嵁妯″潡ID锛岃幏鍙栬澶囧悕瀛� + strName = this.GetNameByModelId(checkDevice); } - if (result.responseData.status != 0) + else { - //璁剧疆浼犳劅鍣ㄧ伅鍏夐厤缃け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uSetPirSensorLightSettionFail); - this.ShowErrorMsg(msg); - return false; + //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� + var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice); + strName = Language.StringByID(myDeviceType.ConcreteTextId); } - //澶囦唤璁剧疆 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(iASZone, GatewayBackupEnum.APir鐏厜閰嶇疆, configure); - - return true; + if (ApendFalge == true && listDevice[0].DriveCode > 0) + { + //铏氭嫙璁惧鍔犱釜鏍囪瘑 + strName += "鉁�"; + } + else if (ApendFalge == true && this.IsHdlDevice(checkDevice) == false) + { + //绗笁鏂硅澶囧姞涓爣璇� + strName += "鈽�"; + } + return strName; } #endregion - #region 鈻� 鎸夐敭闈㈡澘鍔熻兘绯籣____________________ - - #region 棰滆壊璋冭妭 + #region 鈻� 鑾峰彇娌充笢璁惧鐨勮澶囩被鍨媉____________ /// <summary> - /// 鑾峰彇鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅(鍑洪敊浼氳繑鍥瀗ull) + /// 鑾峰彇Hdl璁惧鐨勩�愯嚜瀹氫箟鐨勮澶囩被鍨嬨�� /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> + /// <param name="device">闅忎究鏌愪竴鍥炶矾</param> /// <returns></returns> - public async Task<Panel.KeyColorData> GetPanelEpointColorInfo(Panel panel) + private DeviceEnumInfo GetHdlMyDeviceEnumInfo(CommonDevice device) { - Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint; - var result = await panel.GetPanelColorInfoAsync(keyNum); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) + //璁惧鍏蜂綋绫诲瀷 + var info = new DeviceEnumInfo(); + info.IsHdlDevice = this.IsHdlDevice(device); + if (device.ModelIdentifier == string.Empty) { - this.ShowErrorMsg(error); + return null; + } + string modelKeys = device.ModelIdentifier; + if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false) + { + //娌℃湁鍖归厤鍒版ā鍧桰D锛屽垯鐩存帴璧扮涓夋柟璁惧鐨勫垽鏂� return null; } - if (result == null || result.keyColorData == null) + string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); + int ConcreteValue = Convert.ToInt32(strValue[0]); + int BeloneValue = Convert.ToInt32(strValue[1]); + //璁剧疆璁惧鐨勩�愯澶囨墍灞炵被鍨嬨�� + info.BeloneType = (DeviceBeloneType)BeloneValue; + if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + BeloneValue) == true) { - //鑾峰彇鎸夐敭闈㈡澘棰滆壊璋冭妭淇℃伅澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelColorRegulationInfoFail); - this.ShowErrorMsg(msg); - return null; + //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧 + info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + BeloneValue]; } - return result.keyColorData; - } - /// <summary> - /// 璁剧疆鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅 - /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <param name="colorData">寮�鍜屽叧鐨勯鑹查兘闇�瑕佷竴璧疯缃�</param> - /// <returns></returns> - public async Task<bool> SetPanelEpointColorInfo(Panel panel, Panel.KeyColorData colorData) - { - var keyNum = new Panel.KeyNumStatus(); - Type type = keyNum.GetType(); - type.InvokeMember("Key" + panel.DeviceEpoint, System.Reflection.BindingFlags.SetField, null, keyNum, new object[] { true }); - - var result = await panel.SetPanelColorInfoAsync(colorData, keyNum); - if (result == null || result.responseData == null) + //璁惧鍏蜂綋绫诲瀷 + info.ConcreteType = (DeviceConcreteType)ConcreteValue; + if (info.ConcreteType.ToString() == ConcreteValue.ToString()) { - //璁剧疆鎸夐敭闈㈡澘鎸囩ず鐏鑹插け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uSetPanelPilolightSettionFail); - this.ShowErrorMsg(msg); - return false; + info.ConcreteType = DeviceConcreteType.UnKownDevice; } - if (result.responseData.status != 0) - { - //璁剧疆鎸夐敭闈㈡澘鎸囩ず鐏鑹插け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uSetPanelPilolightSettionFail); - this.ShowErrorMsg(msg); - return false; - } - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A鎸夐敭闈㈡澘棰滆壊璋冭妭, colorData); - return true; + return info; } #endregion - #region 浜害璋冭妭 - /// <summary> - /// 鑾峰彇鎸夐敭闈㈡澘浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛� - /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <returns></returns> - public async Task<Panel.PanelSwitchLevelInfo> GetPanelSwitchLightSettion(Panel panel) - { - var result = await panel.GetPanelSwitchLevelAsync(); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) - { - this.ShowErrorMsg(error); - return null; - } - - if (result == null || string.IsNullOrEmpty(result.errorMessageBase) == false) - { - //鑾峰彇鎸夐敭闈㈡澘浜害璋冭妭淇℃伅澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelLightRegulationInfoFail); - this.ShowErrorMsg(msg); - return null; - } - return result; - } + #region 鈻� 鑾峰彇绗笁鏂硅澶囩殑璁惧绫诲瀷___________ /// <summary> - /// 璁剧疆鎸夐敭闈㈡澘浜害锛坲i鍙寒搴﹁皟鑺傦級 + /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <param name="directionsLevel">鎸囩ず鐏寒搴� 0-100(鐜伴樁娈典笉鐢ㄨ繖涓�)</param> - /// <param name="backlightLevel">鑳屽厜鐏寒搴� 0-100(ui鍙寒搴﹁皟鑺�)</param> + /// <param name="listdevice"></param> /// <returns></returns> - public async Task<bool> SetPanelSwitchLightSettion(Panel panel, int directionsLevel, int backlightLevel) + public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice) { - var result = await panel.SetKeyLevelAsync(directionsLevel, backlightLevel); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) + var dicType = new Dictionary<DeviceType, CommonDevice>(); + foreach (CommonDevice device in listdevice) { - this.ShowTipMsg(error); - return false; + if (dicType.ContainsKey(device.Type) == false) + { + dicType[device.Type] = device; + } + } + var info = new DeviceEnumInfo(); + info.IsHdlDevice = false; + //1鍖呭惈闈㈡澘鐨勮瘽,褰撻潰鏉垮鐞� + if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200; + info.BeloneType = DeviceBeloneType.A鎸夐敭闈㈡澘; + info.ConcreteType = DeviceConcreteType.ButtonPanel; + } + //3鍖呭惈绐楀笜鐨勮瘽,褰撶獥甯樺鐞� + else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId100; + info.BeloneType = DeviceBeloneType.A绐楀笜; + info.ConcreteType = DeviceConcreteType.Curtain; + } + //4绌烘皵寮�鍏� + else if (dicType.ContainsKey(DeviceType.AirSwitch) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100; + info.BeloneType = DeviceBeloneType.A绌烘皵寮�鍏�; + info.ConcreteType = DeviceConcreteType.AirSwitch; + } + //5缁х數鍣� + else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300; + info.BeloneType = DeviceBeloneType.A缁х數鍣�; + info.ConcreteType = DeviceConcreteType.Relay; + } + //6璋冨厜鍣� + else if (dicType.ContainsKey(DeviceType.DimmableLight) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2500; + info.BeloneType = DeviceBeloneType.A璋冨厜鍣�; + info.ConcreteType = DeviceConcreteType.DimmableLight; + } + //7褰╃伅 + else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9; + info.BeloneType = DeviceBeloneType.A褰╃伅; + info.ConcreteType = DeviceConcreteType.ColorLight; + } + //8绌鸿皟 + else if (dicType.ContainsKey(DeviceType.Thermostat) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3600; + info.BeloneType = DeviceBeloneType.A绌鸿皟; + info.ConcreteType = DeviceConcreteType.AirConditioner; + } + //9涓户鍣� + else if (dicType.ContainsKey(DeviceType.Repeater) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3900; + info.BeloneType = DeviceBeloneType.A涓户鍣�; + info.ConcreteType = DeviceConcreteType.Repeater; + } + //10杞崲鍣� + else if (dicType.ContainsKey(DeviceType.Transverter) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4200; + info.BeloneType = DeviceBeloneType.A杞崲鍣�; + info.ConcreteType = DeviceConcreteType.Converter; + } + //11鏅鸿兘闂ㄩ攣 + else if (dicType.ContainsKey(DeviceType.DoorLock) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2800; + info.BeloneType = DeviceBeloneType.A鏅鸿兘闂ㄩ攣; + info.ConcreteType = DeviceConcreteType.IntelligentLocks; + } + //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; + } } - if (result == null || result.responseData == null) + int value = (int)info.BeloneType; + if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true) { - //璁剧疆浜害璋冭妭澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowTipMsg(msg); - return false; + //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧 + info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value]; } - if (result.responseData.status != 0) - { - //璁剧疆浜害璋冭妭澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail); - this.ShowTipMsg(msg); - return false; - } - //澶囦唤璁惧 - var backData = new Newtonsoft.Json.Linq.JObject - { - { "directionsLevel",directionsLevel }, - { "backlightLevel", backlightLevel } - }; - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A鎸夐敭闈㈡澘浜害璋冭妭, backData); - return true; + return info; } #endregion - #region 鑺傝兘妯″紡 - /// <summary> - /// 鑾峰彇鎸夐敭闈㈡澘鑺傝兘妯″紡鐨勯厤缃姸鎬�(ui鍙妭鑳芥ā寮�) - /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <returns></returns> - public async Task<Panel.PanelSaveEnergyModeInfo> GetPanelEnergyConservationMode(Panel panel) - { - var result = await panel.GetPanelSaveEnergyModeAsync(); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) - { - this.ShowErrorMsg(error); - return null; - } - - if (result == null || result.panelSaveEnergyModeInfo == null) - { - //鑾峰彇鎸夐敭闈㈡澘鑺傝兘妯″紡淇℃伅澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelEnergyConservationInfoFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowErrorMsg(msg); - return null; - } - return result.panelSaveEnergyModeInfo; - } + #region 鈻� 浼犳劅鍣ㄥ叿浣撶殑绫诲瀷___________________ /// <summary> - /// 璁剧疆鎸夐敭闈㈡澘鐨勮妭鑳芥ā寮�(ui鍙妭鑳芥ā寮�) + /// 璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <param name="modeEnable">鑺傝兘妯″紡鏄惁鏈夋晥</param> - /// <param name="modeTime">鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-255</param> - /// <param name="level">鑺傝兘妯″紡浜害:0-100</param> - /// <returns></returns> - public async Task<bool> SetPanelEnergyConservationMode(Panel panel, bool modeEnable, int modeTime, int level) + /// <param name="info">鑷畾涔夎澶囨灇涓句俊鎭�</param> + /// <param name="listdevice">璁惧瀵硅薄</param> + private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice) { - var result = await panel.SetKeyModeAsync(modeEnable, modeTime, level); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) + //榛樿鍚嶅瓧:浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200; + + //濡傛灉杩欎釜璁惧鎷ユ湁澶氫釜鍥炶矾鐨勮瘽,鎴戜篃涓嶇煡閬撴�庝箞鍛藉悕,鍙兘缁欎釜榛樿鍚嶅瓧 + if (listdevice.Count > 1) { - this.ShowErrorMsg(error); - return false; + return; } - - if (result == null || result.responseData == null) + var iasZone = (IASZone)listdevice[0]; + if (iasZone.IasDeviceType == 13) { - //鑺傝兘妯″紡閰嶇疆澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowTipMsg(msg); - return false; + //杩愬姩浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor_Motion; + info.ConcreteTextId = R.MyInternationalizationString.uMotionSensor; } - - if (result.responseData.status != 0) + else if (iasZone.IasDeviceType == 40) { - //鑺傝兘妯″紡閰嶇疆澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail); - this.ShowTipMsg(msg); - return false; + //鐑熼浘浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor_Fire; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1302; } - //澶囦唤璁惧 - var backData = new Newtonsoft.Json.Linq.JObject + else if (iasZone.IasDeviceType == 42) { - { "modeEnable",modeEnable }, - { "modeTime", modeTime }, - { "level", level } - }; - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A鎸夐敭闈㈡澘鑺傝兘妯″紡, backData); - - return true; + //姘翠镜浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor_Water; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1304; + } + else if (iasZone.IasDeviceType == 43) + { + //鐕冩皵浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor_CarbonMonoxide; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1300; + } + else if (iasZone.IasDeviceType == 44) + { + //绱ф�ユ寜閽� + info.ConcreteType = DeviceConcreteType.Sensor_EmergencyButton; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1305; + } + else if (iasZone.IasDeviceType == 277) + { + //閽ュ寵鎵� + info.ConcreteType = DeviceConcreteType.Sensor_Keyfob; + info.ConcreteTextId = R.MyInternationalizationString.uKeyfob; + } + else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22) + { + //闂ㄧ獥浼犳劅鍣� + info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1301; + } } #endregion + #region 鈻� 鐗╃悊璁惧鎵�灞炴埧闂確__________________ + /// <summary> - /// 妫�娴嬫帶鍒堕潰鏉�(鐏被)鎵�鎷ユ湁鐨勫姛鑳�,鐜版敮鎸佺殑鏈変互涓嬪嚑绉�(蹇呭畾瀛樺湪閿��,鍑洪敊浼氳繑鍥瀗ull) - /// <para>閿��1:浜害璋冭妭(ui鍙寒搴﹁皟鑺�,閽堝鏁翠釜璁惧) -> true:鎷ユ湁姝ゅ姛鑳� false:鏃犳鍔熻兘</para> - /// <para>閿��2:鑺傝兘妯″紡(ui鍙妭鑳芥ā寮�,閽堝鏁翠釜璁惧) -> true:鎷ユ湁姝ゅ姛鑳� false:鏃犳鍔熻兘</para> - /// <para>閿��3:棰滆壊璋冭妭(ui鍙鑹茶皟鑺�,鍙兘鍗曞洖璺厤缃�) -> true:鎷ユ湁姝ゅ姛鑳� false:鏃犳鍔熻兘</para> + /// 鍒濆鍖栫墿鐞嗚澶囨墍灞炴埧闂寸殑璁板綍 /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <returns></returns> - public async Task<Dictionary<string, bool>> CheckPanelLightFunctionLevel2(Panel panel) + private void InitRealDeviceRoomId() { - var dicCheck = new Dictionary<string, bool>(); - dicCheck["浜害璋冭妭"] = false; - dicCheck["鑺傝兘妯″紡"] = false; - dicCheck["棰滆壊璋冭妭"] = false; - - //鑾峰彇绗竴绾у姛鑳� - var result = await this.GetPanelDeviceFunctionLevel1(panel); - if (result == null) + this.dicDeviceRoomId = new Dictionary<string, string>(); + string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) { - return null; + this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData); } - - if (result.Contains(1024) == false) - { - //姝ゆ帶鍒堕潰鏉挎病鏈夌伅杩欎釜涓滆タ - return dicCheck; - } - - //鑾峰彇绗簩绾у姛鑳� - result = await this.GetPanelDeviceFunctionLevel2(panel, 1024); - if (result == null) - { - return null; - } - - if (result.Contains(102) == true) - { - //浜害璋冭妭锛�102 - dicCheck["浜害璋冭妭"] = true; - } - if (result.Contains(101) == true) - { - //棰滆壊璋冭妭锛�101 - dicCheck["棰滆壊璋冭妭"] = true; - } - if (result.Contains(0) == true) - { - //鑺傝兘妯″紡锛�0 - dicCheck["鑺傝兘妯″紡"] = true; - } - return dicCheck; } /// <summary> - /// 鑾峰彇鎸夐敭闈㈡澘鐨勭涓�绾у埆鍔熻兘鍔熻兘绯�(1024:鐏被锛�256:鎸夐敭绫伙紝768:PIR绫�) + /// 淇濆瓨鐗╃悊璁惧鎵�灞炴埧闂寸殑璁板綍 /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <returns></returns> - public async Task<List<int>> GetPanelDeviceFunctionLevel1(Panel panel) + /// <param name="listDevice">闇�瑕佷繚瀛樼殑璁惧瀵硅薄</param> + /// <param name="roomId">闇�瑕佷繚瀛樼殑鍝釜璁惧鐨勬埧闂碔D</param> + public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId) { - var result = await this.GetPanelDeviceFunction(panel); - if (result == null) + this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; + + //淇濆瓨璁板綍 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); + UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); + + //濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜� + if (listDevice.Count == 1) { - return null; + Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId); } - return result.privateFuncTypeLevelFirstList; } /// <summary> - /// <para>鑾峰彇鎸夐敭闈㈡澘鐨勭浜岀骇鍒姛鑳藉姛鑳界郴(浠ヤ笅涓鸿繑鍥炲��)</para> - /// <para>100:Switch,寮�鍏筹紙鎸夐敭绫伙級</para> - /// <para>200:Dimmer,璋冨厜锛堟寜閿被锛�</para> - /// <para>300:Curtain,绐楀笜锛堟寜閿被锛�</para> - /// <para>0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級</para> - /// <para>1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級</para> - /// <para>100:WhiteBalance,鐧藉钩琛★紙鐏被锛�</para> - /// <para>101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�</para> - /// <para>102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para> + /// 鑾峰彇鐪熷疄鐗╃悊璁惧鐨勬埧闂村悕瀛� /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <param name="levelNo">绗竴绾у埆鐨処D(1024:鐏被锛�256:鎸夐敭绫伙紝768:PIR绫�)</param> + /// <param name="device">璁惧鐨勬煇涓�涓洖璺�</param> /// <returns></returns> - public async Task<List<int>> GetPanelDeviceFunctionLevel2(Panel panel, int levelNo) + public string GeteRealDeviceRoomName(CommonDevice device) { - var result = await this.GetPanelDeviceFunction(panel, new int[] { levelNo }); - if (result == null) + if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false) { - return null; + //鏈垎閰嶅尯鍩� + return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } - return result.privateFuncTypeLevelSecondList; + var room = Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); + if (room != null) + { + return room.Name; + } + //鏈垎閰嶅尯鍩� + return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } /// <summary> - /// 鑾峰彇鎸夐敭闈㈡澘鐨勫姛鑳� + /// 鑾峰彇鐪熷疄鐗╃悊璁惧灞炰簬鍝釜鎴块棿 /// </summary> - /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> - /// <param name="parameter"> - /// <para>鏂规硶1锛氬綋int[]浼犵┖锛岃繑鍥炲�兼槸鈥滈潰鏉垮叿鏈夌殑鍔熻兘澶х被,鍗宠繑鍥炩�滅涓�绾у埆銆�1024:鐏被锛�256:鎸夐敭绫伙紝768:PIR绫�</para> - /// <para>鏂规硶2锛氥�佸綋int[]鍊间负绗竴绾у埆PrivateFuncTypeFir涓�夋嫨涓�涓��</para> - /// <para>杩斿洖鍊兼槸鈥滈潰鎸夐敭鍙戦�佸姛鑳界被鈥濓紝鍗宠繑鍥炩�滅浜岀骇鍒��</para> - /// <para>100:Switch,寮�鍏筹紙鎸夐敭绫伙級;200:Dimmer,璋冨厜锛堟寜閿被锛�;300:Curtain,绐楀笜锛堟寜閿被锛�</para> - /// <para>0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級;1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級;100:WhiteBalance,鐧藉钩琛★紙鐏被锛�;101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�;102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para> - /// <para>鏂规硶3锛氬綋int[]鍊间负绗竴绾у埆PrivateFuncTypeFir涓�夋嫨涓�涓紝鎺ョ潃鍐嶉�夌浜岀骇鍒玃rivateFunTypeSec涓�夋嫨涓�涓� </para> - /// <para>杩斿洖鍊兼槸鈥滈潰鎸夐敭鍏蜂綋鍔熻兘閰嶇疆鈥濓紝鍗宠繑鍥炩�滅浜岀骇鍒��</para> - /// <para>100:SwitchOpen,寮�鍏冲紑锛堟寜閿被锛�;101:SwitchClose,寮�鍏冲叧锛堟寜閿被锛�;102:SwitchChange,寮�鍏冲垏鎹紙鎸夐敭绫伙級</para> - /// <para>200:DimmerStepUp,澧炲ぇ璋冨厜锛堟寜閿被锛�;201:DimmerStepDown,闄嶄綆璋冨厜锛堟寜閿被锛�;202:DimmerStepChange,璋冨厜鍒囨崲锛堟寜閿被锛�</para> - /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛�;301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級;302:CurtainStop,绐楀笜鍋�;303:CurtainUpStop,绐楀笜涓婂崌鍋�;304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para> - /// </param> + /// <param name="device">璁惧鐨勬煇涓�涓洖璺�</param> /// <returns></returns> - private async Task<Panel.PanelPrivateFunctionsResponseInfo> GetPanelDeviceFunction(Panel panel, params int[] parameter) + public Room GeteRealDeviceRoom(CommonDevice device) { - var result = await panel.GetPanelPrivateFunctionsAsync(parameter); - //鍏遍�氶敊璇娴� - string error = UserCenterLogic.CheckCommonErrorCode(result); - if (error != null) + if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false) { - this.ShowErrorMsg(error); return null; } - - if (result == null || result.panelPrivateFunctionsResponseInfo == null) - { - //鑾峰彇鎸夐敭闈㈡澘鍔熻兘绫讳俊鎭け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelFunctionInfoFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result.errorMessageBase); - - this.ShowErrorMsg(msg); - return null; - } - - return result.panelPrivateFunctionsResponseInfo; + return Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); } #endregion @@ -2523,6 +1591,41 @@ } /// <summary> + /// 浜ゆ崲璁惧鐨勬ā鍧桰D + /// </summary> + /// <param name="modeId">妯″潡ID</param> + /// <returns></returns> + public bool ChangedDeviceModeId(ref string modeId) + { + if (this.dicDeviceModelIdChanged.ContainsKey(modeId) == false) + { + return false; + } + modeId = this.dicDeviceModelIdChanged[modeId]; + + return true; + } + + /// <summary> + /// 闄勫姞璁惧鐨勭増鏈唬鍙�(杩斿洖Ver.XXX) + /// </summary> + /// <param name="versionValue">鐗堟湰鍙�</param> + /// <returns></returns> + public string AppendVersion(int versionValue) + { + //杞负16杩涘埗 + string txt64 = Convert.ToString(versionValue, 16).PadLeft(4, '0'); + //杩欎釜鏄皬鏁扮偣鍓嶉潰鐨勫�� + int value1 = Convert.ToInt32(txt64.Substring(0, 2), 16); + //杩欎釜鏄皬鏁扮偣鍚庨潰鐨勫�� + int value2 = Convert.ToInt32(txt64.Substring(2, 2), 16); + + //Ver. + string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation); + return ver + value1 + "." + value2.ToString().PadLeft(3, '0'); + } + + /// <summary> /// 鏄剧ず閿欒淇℃伅绐楀彛 /// </summary> /// <param name="msg"></param> @@ -2530,7 +1633,7 @@ { Application.RunOnMainThread(() => { - var contr = new Phone.UserCenter.ErrorMsgControl(msg); + var contr = new ShowMsgControl(ShowMsgType.Error, msg); contr.Show(); }); } @@ -2543,28 +1646,9 @@ { Application.RunOnMainThread(() => { - var contr = new Phone.UserCenter.TipViewControl(msg); - contr.ShowView(); + var contr = new ShowMsgControl(ShowMsgType.Tip, msg); + contr.Show(); }); - } - - #endregion - - #region 鈻� 缁撴瀯浣揰____________________________ - - /// <summary> - /// 璁惧璁℃暟鐨勪俊鎭� - /// </summary> - private class DeviceCountInfo - { - /// <summary> - /// 璁℃暟 - /// </summary> - public int Count = 0; - /// <summary> - /// 绔彛鍙� - /// </summary> - public HashSet<int> hsEpoint = new HashSet<int>(); } #endregion @@ -2574,19 +1658,45 @@ #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 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; ZbGateway realWay = null; - if (Common.LocalGateway.Current.GetRealGateway(ref realWay, zbGateway) == false) + if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, zbGateway) == false) { if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES) { @@ -2599,11 +1709,14 @@ //鏄惁杈炬垚涓柇鐨勬椂鏈� bool canBreak = false; - //缃戝叧ID - string gatewayID = Common.LocalGateway.Current.GetGatewayId(zbGateway); + string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); //瓒呮椂鏃堕棿 int TimeOut = 0; + //璁惧鎬绘暟 + int deviceCount = -1; + //鎺ユ敹鏁� + int receiveCount = 0; //璁惧鍒楄〃 var listDevice = new List<CommonDevice>(); @@ -2622,20 +1735,34 @@ canBreak = true; return; } + if (deviceCount == -1) + { + //璁剧疆闇�瑕佹帴鏀跺灏戜釜璁惧 + deviceCount = totalNum; + } + //璁惧鎺ユ敹鏁� + receiveCount++; + var deviceID = (DeviceType)jobject.Value<int>("Device_ID"); //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚� 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); } - } - else if (topic == gatewayID + "/" + "DeviceInfoResponEnd") - { - canBreak = true; + if (deviceCount == receiveCount) + { + //璁惧鍏ㄩ儴鎺ユ敹瀹屾垚 + canBreak = true; + } } } catch { } @@ -2645,17 +1772,19 @@ try { var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } }; - await realWay.Send("GetDeviceInfo", jObject.ToString()); + realWay.Send("GetDeviceInfo", jObject.ToString()); } catch { canBreak = true; } while (canBreak == false && TimeOut < 60) { - await Task.Delay(100); + System.Threading.Thread.Sleep(100); TimeOut++; } realWay.Actions -= getDeviceAction; + getDeviceAction = null; + if (TimeOut >= 60) { if (listDevice.Count == 0) @@ -2665,9 +1794,9 @@ //鑾峰彇璁惧鍒楄〃澶辫触 //[XXXX]缃戝叧鍥炲瓒呮椂,璇风◢鍚庡啀璇� string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail); - msg += "\r\n[" + Common.LocalGateway.Current.GetGatewayName(zbGateway).ToString() + "]"; - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, "鍥炲瓒呮椂", false); - this.ShowErrorMsg(msg); + msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(zbGateway).ToString() + "]"; + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂", false); + this.ShowTipMsg(msg); } return null; } @@ -2683,7 +1812,7 @@ } //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚) - deviceComingAction?.Invoke(null); + deviceComingAction = null; return listDevice; } @@ -2701,7 +1830,7 @@ /// <returns></returns> private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway) { - string gwId = Common.LocalGateway.Current.GetGatewayId(zbGateway); + string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway); //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚� CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType); @@ -2745,16 +1874,66 @@ mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName; } mainDevice.CurrentGateWayId = device.CurrentGateWayId; - mainDevice.ImgVersion = device.DeviceInfo.ImgVersion; - mainDevice.HwVersion = device.DeviceInfo.HwVersion; mainDevice.IsOnline = device.DeviceInfo.IsOnline; mainDevice.DriveCode = device.DeviceInfo.DriveCode; mainDevice.IasDeviceType = device.DeviceInfo.DeviceType; mainDevice.Profile = device.DeviceInfo.Profile; + mainDevice.Type = device.Type; + + //鍥轰欢鐗堟湰 + mainDevice.ImgVersion = device.DeviceInfo.ImgVersion; + //纭欢鐗堟湰 + mainDevice.HwVersion = device.DeviceInfo.HwVersion; + //闀滃儚ID mainDevice.ImgTypeId = device.DeviceInfo.ImgTypeId; - mainDevice.InClusterList = device.DeviceInfo.InClusterList; - mainDevice.OutClusterList = device.DeviceInfo.OutClusterList; - mainDevice.AttributeStatus = device.DeviceInfo.AttributeStatus; + //鍘傚晢鍚嶇О + mainDevice.ManufacturerName = device.DeviceInfo.ManufacturerName; + //妯″潡ID + mainDevice.ModelIdentifier = device.DeviceInfo.ModelIdentifier; + //搴忓垪鍙� + mainDevice.SerialNumber = device.DeviceInfo.ProductCode; + + mainDevice.InClusterList.Clear(); + mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList); + mainDevice.OutClusterList.Clear(); + 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> @@ -2776,6 +1955,8 @@ else if (deviceType == DeviceType.IASZone) { device = new IASZone(); } 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; } @@ -2848,8 +2029,11 @@ //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄========= this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500";//1璺皟鍏夊櫒灏忔ā鍧� + //=========鈽呪槄鏅鸿兘闂ㄩ攣绫�(2800-????)鈽呪槄========= + this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//鏅鸿兘闂ㄩ攣(H06C) + //=========鈽呪槄绌鸿皟绫�(3600-3899)鈽呪槄========= - this.dicDeviceModelIdEnum["MAC/GW-ZB.431"] = "3600-3600";//zigbee绌鸿皟缃戝叧妯″潡 + this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee绌鸿皟缃戝叧妯″潡 //=========鈽呪槄涓户鍣ㄧ被(3900-3999)鈽呪槄========= this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900"; //zigbee涓户鍣� @@ -2858,10 +2042,282 @@ this.dicDeviceModelIdEnum["MBCI01-ZB.10"] = "4100-4100";//zigbee寰柇浜戞帶鍒跺櫒 //=========鈽呪槄杞崲鍣ㄧ被(4200-4699)鈽呪槄========= - this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200";//zigbee杞�485鍗忚杞崲鍣� - this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200";//zigbee杞琤uspro鍗忚杞崲鍣� + 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>(); + //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫烩槄鈽�========= + this.dicDeviceModelIdChanged["MULTI-GASE--EA07"] = "MSG01/M-ZB.10";//鐕冩皵浼犳劅鍣� + this.dicDeviceModelIdChanged["MULTI-MECI--EA01"] = "MSDC01/M-ZB.10";//闂ㄧ獥纾佷紶鎰熷櫒 + this.dicDeviceModelIdChanged["MULTI-FIRE--EA05"] = "MSS01/M-ZB.10";//鐑熼浘浼犳劅鍣� + 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";//绱ф�ユ寜閿� } #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 } \ No newline at end of file -- Gitblit v1.8.0