From adb12dcdbb2ddaeac687c3aa9e57bb7ed459ab7e Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 24 六月 2020 15:26:46 +0800 Subject: [PATCH] 2020.06.24.01 --- ZigbeeApp/Shared/Common/Device.cs | 186 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 144 insertions(+), 42 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 8426b1a..bada159 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -123,12 +123,6 @@ 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; @@ -143,12 +137,6 @@ } 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; @@ -211,7 +199,7 @@ var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway(); foreach (var gateway in listGateway) { - string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway); + string gwId = gateway.GwId; if (listId.Contains(gwId) == false) { //杩欎釜缃戝叧瀵逛簬褰撳墠杩欎釜鎴愬憳鏉ヨ鏄潪娉曠殑 @@ -242,7 +230,7 @@ listDevice.AddRange(list); //鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶� - string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gwID = zbGateway.GwId; List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID); //鑾峰彇ota璁惧 foreach (var ota in this.dicOTADevice.Values) @@ -680,22 +668,26 @@ /// <param name="listdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param> public async Task<bool> DeleteDevice(List<CommonDevice> listdevice) { - var data = new CommonDevice.RemoveDeviceData(); - var info = new CommonDevice.RemoveDeviceListInfo(); - info.DeviceAddr = listdevice[0].DeviceAddr; - data.DeviceAddrList.Add(info); - - //鍒犱竴娆$殑鏃跺�欙紝瀹冧細鎶奙AC鍦板潃涓嬮潰鍏ㄩ儴鐨勮澶囬兘鍒犻櫎 - var result = await listdevice[0].DeleteDeviceAsync(data); - if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0) + //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕佸垹闄ょ綉鍏崇殑璁惧 + if (Config.Instance.Home.IsVirtually == false) { - //璁惧鍒犻櫎澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + var data = new CommonDevice.RemoveDeviceData(); + var info = new CommonDevice.RemoveDeviceListInfo(); + info.DeviceAddr = listdevice[0].DeviceAddr; + data.DeviceAddrList.Add(info); - this.ShowErrorMsg(msg); - return false; + //鍒犱竴娆$殑鏃跺�欙紝瀹冧細鎶奙AC鍦板潃涓嬮潰鍏ㄩ儴鐨勮澶囬兘鍒犻櫎 + var result = await listdevice[0].DeleteDeviceAsync(data); + if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0) + { + //璁惧鍒犻櫎澶辫触 + string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + + this.ShowErrorMsg(msg); + return false; + } } //鍒犻櫎缂撳瓨鐨凮ta璁惧 @@ -979,6 +971,47 @@ } /// <summary> + /// 鏍规嵁MAC鍦板潃,鑾峰彇绠�绾﹂潰鏉垮叏閮ㄥ洖璺殑璁惧瀵硅薄 + /// </summary> + /// <param name="listDevice"></param> + /// <returns></returns> + public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true) + { + //鍜屽姜鍝ャ�佽澶囧拰浜у搧閮ㄥ悓浜嬬‘璁わ細 + //绠�绾﹀鍔熻兘闈㈡澘[涓嶆樉绀哄浣欑殑鍥炶矾锛屽彧鏄剧ず鎼哄甫鐨�2涓户鐢靛櫒鍜�1涓俯婀垮害浼犳劅鍣� + var list = new List<CommonDevice>(); + foreach (var dev in listDevice) + { + if (dev.Type == DeviceType.TemperatureSensor) + { + if (dev.DeviceEpoint == 64) + { + list.Add(dev); + } + } + else if (dev.Type == DeviceType.OnOffOutput) + { + list.Add(dev); + } + } + + if (sort == false) + { + return list; + } + list.Sort((obj1, obj2) => + { + if (obj1.DeviceEpoint > obj2.DeviceEpoint) + { + return 1; + } + return -1; + }); + + return list; + } + + /// <summary> /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭) /// </summary> /// <param name="DeviceAddr">Mac鍦板潃</param> @@ -1107,6 +1140,12 @@ { return dName; } + if (this.IsMiniLight(device) == true) + { + //Mini澶滅伅 + return Language.StringByID(R.MyInternationalizationString.uMiniNightLight); + } + //濡傛灉杩欎釜璁惧鍙湁涓�涓洖璺殑璇�,杩斿洖Mac鍚嶅瓧缁欏畠 if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1) { @@ -1131,7 +1170,9 @@ } if (device.Type == DeviceType.OnOffOutput - || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight) + || device.Type == DeviceType.DimmableLight + || device.Type == DeviceType.ColorDimmableLight + || device.Type == DeviceType.ColorTemperatureLight) { //缁х數鍣�,鎺夊厜鍣ㄩ兘鍙洖璺� return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo; @@ -1195,6 +1236,11 @@ if (string.IsNullOrEmpty(dName) == false) { return dName; + } + if (this.IsMiniLight(device) == true) + { + //Mini澶滅伅 + return Language.StringByID(R.MyInternationalizationString.uMiniNightLight); } //鑾峰彇璁惧绫诲瀷 @@ -1945,6 +1991,14 @@ info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive; info.ObjectTypeNameId = 60000;//浼犳劅鍣� } + //16鑹叉俯鐏� + else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000; + info.BeloneType = DeviceBeloneType.A褰╃伅; + info.ConcreteType = DeviceConcreteType.ColorLight_Temperature; + info.ObjectTypeNameId = 60007;//璋冨厜妯″潡 + } int value = (int)info.BeloneType; if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true) @@ -2075,7 +2129,7 @@ { //2020.05.18杩藉姞:濡傛灉璁板綍鐨勬埧闂碔D鏄笉瀛樺湪鐨勮瘽,鍒欓噸鏂拌鐩� var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]); - if (room == null) + if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId) { this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; save = true; @@ -2329,7 +2383,8 @@ if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch) { //2020.03.23杩藉姞寮忔牱:鏈寚瀹氱被鍨嬬殑缁х數鍣�,涓嶆樉绀� - if (i_device.DfunctionType == DeviceFunctionType.A鏈畾涔�) + if (i_device.DfunctionType == DeviceFunctionType.A鏈畾涔� + || i_device.DfunctionType == DeviceFunctionType.A涓嶆寚瀹�) { return false; } @@ -2352,6 +2407,11 @@ return false; } } + else if (i_device.Type == DeviceType.FreshAirHumiditySensor) + { + //鏂伴鐨勬箍搴︿紶鎰熷櫒涓嶆樉绀� + return false; + } return true; } @@ -2363,6 +2423,16 @@ public bool IsHdlDevice(CommonDevice device) { return device.ManufacturerName == "HDL"; + } + + /// <summary> + /// 鏄惁鏄疢ini澶滅伅 + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public bool IsMiniLight(CommonDevice device) + { + return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight; } /// <summary> @@ -2409,16 +2479,22 @@ /// <returns></returns> public string AppendVersion(int versionValue) { + //10101 3涓猙yte 鏄剧ず涓猴細ver.1.01.01 + //涓棿閭d釜byte涓哄鏁版椂锛屼唬琛ㄦ槸娴嬭瘯鐗堟湰,鍦ㄦ樉绀烘渶鏂扮増鏈椂,涓嶉渶瑕佹樉绀猴紝浣嗘槸鍦ㄥ巻鍙茬増鏈偅閲屽彲浠ユ樉绀� + //涓棿閭d釜byte涓哄伓鏁版椂, 浠h〃鏄寮忕増鏈� + //鐩存帴鏄�10杩涘埗 - string txt10 = Convert.ToString(versionValue).PadLeft(4, '0'); - //杩欎釜鏄皬鏁扮偣鍓嶉潰鐨勫�� - int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2)); - //杩欎釜鏄皬鏁扮偣鍚庨潰鐨勫�� - int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2)); + string txt10 = Convert.ToString(versionValue).PadLeft(6, '0'); + //杩欎釜鏄涓�浣� + int value1 = Convert.ToInt32(txt10.Substring(0, 2)); + //杩欎釜鏄浜屼綅 + string value2 = txt10.Substring(2, 2); + //杩欎釜鏄涓変綅 + string value3 = txt10.Substring(4, 2); //Ver. string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation); - return ver + value1 + "." + value2.ToString().PadLeft(2, '0'); + return ver + value1 + "." + value2 + "." + value3; } /// <summary> @@ -2470,7 +2546,7 @@ { //涓嶆棤瑙嗘椂闂�,杩斿洖鏈湴璁惧鍒楄〃 statu = 1; - return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway)); + return this.GetDeviceByGatewayID(zbGateway.GwId); } } zbGateway.LastDateTime = DateTime.Now; @@ -2494,7 +2570,7 @@ //鏄惁杈炬垚涓柇鐨勬椂鏈� bool canBreak = false; //缃戝叧ID - string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gatewayID = zbGateway.GwId; //瓒呮椂鏃堕棿 int TimeOut = 0; //璁惧鎬绘暟 @@ -2631,7 +2707,7 @@ /// <returns></returns> private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway) { - string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gwId = zbGateway.GwId; //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚� CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType); @@ -2725,6 +2801,15 @@ mainDevice.IconPath = "Device/Light.png"; } } + //濡傛灉鏄壊娓╃伅 + else if (mainDevice.Type == DeviceType.ColorTemperatureLight) + { + mainDevice.DfunctionType = DeviceFunctionType.A鐏厜; + if (mainDevice.IsCustomizeImage == false) + { + mainDevice.IconPath = "Device/ColorLightTemperature.png"; + } + } //濡傛灉鏄笁璺户鐢靛櫒鐨勫洖璺殑璇�,榛樿涓虹伅鍏� else if (mainDevice.Type == DeviceType.OnOffOutput) { @@ -2790,6 +2875,8 @@ else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); } else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); } else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); } + else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); } + else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); } else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); } else { return null; } @@ -2872,6 +2959,9 @@ this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//鏂规偊鏂伴闈㈡澘 this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//鏂规偊鐜闈㈡澘 this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//绐楀笜闈㈡澘 + this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//绠�绾﹀鍔熻兘闈㈡澘 + this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//绠�绾︾幆澧冮潰鏉� + //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄========= this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir浼犳劅鍣�220 @@ -2891,10 +2981,10 @@ this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//绾㈠浼犳劅鍣� this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//姘存蹈浼犳劅鍣� this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//绱ф�ユ寜閿� - this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//鍚搁《鐕冩皵浼犳劅鍣� + this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//鍚搁《鐕冩皵浼犳劅鍣� //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� 銆愯璁惧灞炰簬绗笁鏂硅澶囷紝娌℃湁闀滃儚ID銆� - this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� + this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄========= this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3璺户鐢靛櫒灏忔ā鍧� @@ -3046,6 +3136,14 @@ /// 绐楀笜闈㈡澘 闀滃儚id锛�256 /// </summary> ButtonPanel_Curtain = 256, + /// <summary> + /// 绠�绾﹀鍔熻兘闈㈡澘 闀滃儚ID锛�212 + /// </summary> + ButtonPanel_SimpleMultifunction = 212, + /// <summary> + /// 绠�绾︾幆澧冮潰鏉� + /// </summary> + ButtonPanel_SimpleEnvironment = 230, //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄========= /// <summary> @@ -3155,6 +3253,10 @@ /// 褰╃伅 /// </summary> ColorLight = -10, + /// <summary> + /// 鑹叉俯鐏�(瀹冪殑闀滃儚ID鏈畾,鏆傚畾20000) + /// </summary> + ColorLight_Temperature = 20000, //=========鈽呪槄绌鸿皟(3600-3899)鈽呪槄========= /// <summary> -- Gitblit v1.8.0