From e747e6d8524e3146bb48dc304a713f309966b1c6 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期二, 19 五月 2020 13:10:03 +0800 Subject: [PATCH] 新版本 --- ZigbeeApp/GateWay.Droid/Assets/Language.ini | 15 ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs | 603 ----- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs | 404 +++ ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs | 19 ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs | 18 ZigbeeApp/Shared/Common/CommonPage.cs | 2 ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs | 13 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs | 24 ZigbeeApp/Shared/Phone/Device/Logic/Send.cs | 2 ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs | 14 ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs | 16 ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs | 177 - ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs | 16 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs | 88 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs | 23 ZigbeeApp/Shared/Phone/ZigBee/Device/IASZone.cs | 406 --- ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs | 12 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs | 55 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs | 21 ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs | 4 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 46 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs | 8 ZigbeeApp/Shared/Phone/ZigBee/Device/Scene.cs | 203 - ZigbeeApp/Home.Ios/Resources/Language.ini | 15 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs | 2 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs | 756 ++++-- ZigbeeApp/Shared/R.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs | 18 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs | 276 ++ ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs | 202 + ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs | 10 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs | 4 ZigbeeApp/Shared/Common/Device.cs | 115 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs | 56 ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorWorkModeMenuForm.cs | 6 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs | 3 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLighWithSensorForm.cs | 12 ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 79 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirBackLightSettionForm.cs | 12 ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs | 1200 ---------- ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs | 40 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs | 8 ZigbeeApp/Shared/Shared.projitems | 4 ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs | 4 ZigbeeApp/Shared/Phone/ModelData/DeviceModelDataLogic.cs | 789 ++++++ ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs | 1 /dev/null | 69 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs | 20 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs | 259 ++ ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs | 8 ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs | 148 - ZigbeeApp/Shared/Phone/ModelData/ModelDataCommon.cs | 399 +++ ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs | 8 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs | 12 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs | 31 58 files changed, 3,300 insertions(+), 3,485 deletions(-) diff --git a/ZigbeeApp/GateWay.Droid/Assets/Language.ini b/ZigbeeApp/GateWay.Droid/Assets/Language.ini index 9916bc8..cd9328d 100755 --- a/ZigbeeApp/GateWay.Droid/Assets/Language.ini +++ b/ZigbeeApp/GateWay.Droid/Assets/Language.ini @@ -317,6 +317,12 @@ 314=鑷姩妯″紡涓嶆敮鎸佹搷浣� 315=绌烘皵璐ㄩ噺 316=绌烘皵璐ㄩ噺浼犳劅鍣� +317=浼� +318=鑹� +319=杞诲害姹℃煋 +320=涓害姹℃煋 +321=閲嶅害姹℃煋 +322=涓ラ噸姹℃煋 5097=鍙栨秷 5098=纭畾 @@ -594,8 +600,11 @@ 5399=鍏抽棴澶辫触 5400=寮�鍚父寮�妯″紡澶辫触 5401=娣诲姞鏃舵晥鎬у父寮�璁剧疆澶辫触 -5402=鏃舵晥鎬у父寮�璁剧疆 -5403=鏃跺叧闂� +5402=鏃舵晥鎬у父寮�灏嗚 +5403=鍒嗗叧闂� +5404=鏃� + + 10000=HDL Home 10001=甯哥敤 @@ -1849,6 +1858,8 @@ 16117=鏅鸿兘鏀瑰彉鐢熸椿 | Enjoy smart life 16118=缃戠粶涓嶇ǔ瀹氾紝鍦烘櫙鍒楄〃淇℃伅缂烘崯 16119=DATA缁胯壊鎸囩ず鐏棯鐑� +16120=鑱旂郴鏂瑰紡 +16121=璇疯緭鍏ユ偍鐨勮仈绯绘柟寮� ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄帴鍙g殑杩斿洖淇℃伅缈昏瘧,浠�18000寮�濮嬧槄鈽呪槄鈽� 18004=鎸囧畾缃戝叧宸茬粡琚粦瀹� diff --git a/ZigbeeApp/Home.Ios/Resources/Language.ini b/ZigbeeApp/Home.Ios/Resources/Language.ini index 9916bc8..cd9328d 100755 --- a/ZigbeeApp/Home.Ios/Resources/Language.ini +++ b/ZigbeeApp/Home.Ios/Resources/Language.ini @@ -317,6 +317,12 @@ 314=鑷姩妯″紡涓嶆敮鎸佹搷浣� 315=绌烘皵璐ㄩ噺 316=绌烘皵璐ㄩ噺浼犳劅鍣� +317=浼� +318=鑹� +319=杞诲害姹℃煋 +320=涓害姹℃煋 +321=閲嶅害姹℃煋 +322=涓ラ噸姹℃煋 5097=鍙栨秷 5098=纭畾 @@ -594,8 +600,11 @@ 5399=鍏抽棴澶辫触 5400=寮�鍚父寮�妯″紡澶辫触 5401=娣诲姞鏃舵晥鎬у父寮�璁剧疆澶辫触 -5402=鏃舵晥鎬у父寮�璁剧疆 -5403=鏃跺叧闂� +5402=鏃舵晥鎬у父寮�灏嗚 +5403=鍒嗗叧闂� +5404=鏃� + + 10000=HDL Home 10001=甯哥敤 @@ -1849,6 +1858,8 @@ 16117=鏅鸿兘鏀瑰彉鐢熸椿 | Enjoy smart life 16118=缃戠粶涓嶇ǔ瀹氾紝鍦烘櫙鍒楄〃淇℃伅缂烘崯 16119=DATA缁胯壊鎸囩ず鐏棯鐑� +16120=鑱旂郴鏂瑰紡 +16121=璇疯緭鍏ユ偍鐨勮仈绯绘柟寮� ;鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄帴鍙g殑杩斿洖淇℃伅缈昏瘧,浠�18000寮�濮嬧槄鈽呪槄鈽� 18004=鎸囧畾缃戝叧宸茬粡琚粦瀹� diff --git a/ZigbeeApp/Shared/Common/CommonPage.cs b/ZigbeeApp/Shared/Common/CommonPage.cs index 83a2602..da9f199 100755 --- a/ZigbeeApp/Shared/Common/CommonPage.cs +++ b/ZigbeeApp/Shared/Common/CommonPage.cs @@ -50,7 +50,7 @@ /// <summary> /// 鐗堟湰鍙� /// </summary> - public static string CodeIDString = "1.0.20051801"; + public static string CodeIDString = "1.0.20051901"; /// <summary> /// 娉ㄥ唽鏉ユ簮(0:HDL On 1:Zigbee) /// </summary> diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 00c334c..8426b1a 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -292,9 +292,9 @@ //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍� dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")"; - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { - await this.ReName(device, dName, ShowErrorMode.NO); + this.ReName(device, dName, ShowErrorMode.NO); }); } } @@ -431,7 +431,7 @@ /// <param name="device">璁惧瀵硅薄</param> /// <param name="newName">鏂板悕瀛�</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> - public async Task<bool> ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES) + public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES) { //鍏堝埆绠¢偅涔堝锛屾洿鏀瑰悕瀛楀悗锛屽埛鏂拌澶囩紦瀛� this.SetEpointName(device, newName); @@ -450,7 +450,7 @@ //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛� if (UserCenterResourse.UserInfo.AuthorityNo != 3) { - var result = await device.RenameDeviceNameAsync(device.DeviceAddr, device.DeviceEpoint, newName); + var result = this.RenameDeviceNameAsync(device, newName); if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1) { //璁惧鍚嶇О淇敼澶辫触 @@ -464,8 +464,6 @@ } return false; } - //澶囦唤鏁版嵁 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绔偣鍚嶇О, newName); } //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� Phone.UserView.UserPage.Instance.RefreshForm = true; @@ -478,7 +476,7 @@ /// <param name="listDevice">璁惧瀵硅薄</param> /// <param name="newMacName">鏂板悕瀛�</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> - public async Task<bool> ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES) + public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES) { if (listDevice.Count == 0) { @@ -506,7 +504,7 @@ if (UserCenterResourse.UserInfo.AuthorityNo != 3) { //淇敼鐗╃悊鍚嶅瓧 - var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName); + var result = this.RenameDeviceMacNameAsync(device, newMacName); if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0) { //璁惧鍚嶇О淇敼澶辫触 @@ -519,15 +517,13 @@ } return false; } - //澶囦唤鏁版嵁 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName); //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛� if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true) { //鍙湁涓�涓鐐� if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1) { - return await this.ReName(device, newMacName); + return this.ReName(device, newMacName); } //濡傛灉瀹冩湁涓や釜绔偣鏃�,pir浼犳劅鍣ㄧ壒娈婂鐞� else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2) @@ -539,7 +535,7 @@ { if (myDevice.Type == DeviceType.IASZone) { - return await this.ReName(myDevice, newMacName); + return this.ReName(myDevice, newMacName); } } } @@ -547,6 +543,100 @@ } } return true; + } + + ///<summary > + /// 淇敼璁惧mac鍚嶇О + /// <para>macName:璁惧鍚嶇О</para> + /// </summary> + private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + } + + //鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗� + var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + //鍔犵紦瀛� + Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData); + return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData }; + } + + /// <summary> + /// 淇敼璁惧绔彛锛堟寜閿級鍚嶇О + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="deviceName">璁惧绔偣鍚嶅瓧</param> + /// <returns></returns> + private CommonDevice.DeviceRenameAllData RenameDeviceNameAsync(CommonDevice device, string deviceName) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + } + //鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗� + var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + //鍔犵紦瀛� + Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData); + return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData }; + } + + /// <summary> + /// 鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="deviceAddr"></param> + /// <param name="deviceEpoint"></param> + /// <param name="deviceName"></param> + /// <returns></returns> + public string GetReDeviceMacNameCommandText(string deviceAddr, int deviceEpoint, string deviceName) + { + var bytes = new byte[64]; + var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName); + System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); + deviceName = Encoding.UTF8.GetString(bytes); + + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "MacName", deviceName } }; + jObject.Add("Data", data); + return jObject.ToString(); + } + + /// <summary> + /// 鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="deviceAddr"></param> + /// <param name="deviceEpoint"></param> + /// <param name="deviceName"></param> + /// <returns></returns> + public string GetReDeviceEpointNameCommandText(string deviceAddr, int deviceEpoint, string deviceName) + { + var bytes = new byte[64]; + var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName); + System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); + deviceName = Encoding.UTF8.GetString(bytes); + + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "DeviceName", deviceName } }; + jObject.Add("Data", data); + + return jObject.ToString(); } /// <summary> @@ -1441,7 +1531,6 @@ unSelectPath = imageFilePath; selectPath = imageSelectFilePath; } - #endregion diff --git a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs index aeccb00..0828d24 100755 --- a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs +++ b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs @@ -605,6 +605,20 @@ //涓嬫媺鍒锋柊 listview1.BeginHeaderRefreshingAction += () => { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�,鍒欏彧缁欎釜鐗规晥 + if (Common.Config.Instance.Home.IsVirtually == true) + { + HdlThreadLogic.Current.RunThread(() => + { + System.Threading.Thread.Sleep(1500); + HdlThreadLogic.Current.RunMain(() => + { + listview1.EndHeaderRefreshing(); + }); + }); + return; + } + HdlThreadLogic.Current.RunThread(() => { //浠庣綉鍏冲埛鏂板満鏅垪琛� diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs index bb8de80..e33ecd0 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs @@ -533,7 +533,7 @@ var accounts1 = new JObject(); if (dictionary.ContainsKey("Type")) { - accounts1.Add("Type", dictionary["Type"]); + accounts1.Add("Type", int.Parse(dictionary["Type"])); } if (dictionary.ContainsKey("Option4")) { diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs index 852b7dc..db1cadf 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs @@ -716,9 +716,16 @@ timeConditionsInfo.Add("EnDelay", "0"); timeConditionsInfo.Add("DelayTime", "0"); timeConditionsInfo.Add("StartHour", h); - timeConditionsInfo.Add("StartMin", m); - timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue*60*60).ToString()); - //timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 3600).ToString()); + timeConditionsInfo.Add("StartMin", m); + if (UserCenter.UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode == 1) + { + //寮哄埗鍙樻洿鏃堕棿妯″紡涓哄垎閽� + timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 60).ToString()); + } + else + { + timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 3600).ToString()); + } Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); actionsInfo.Add("LinkType", 8); actionsInfo.Add("DeviceAddr", common.DeviceAddr); diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs index a81b5a1..cbe8716 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs @@ -79,8 +79,14 @@ try { //杩涙潵鏇存柊涓�娆″�� - logicId = logic.LogicId; + logicId = logic.LogicId; timeValue = int.Parse(logic.Conditions[0]["DoorLockOpenDelayTime"]); + if (UserCenter.UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode == 1) + { + //寮哄埗鍙樻洿鏃堕棿妯″紡涓哄垎閽� + timeValue = timeValue / 60; + } + timeLong = int.Parse(logic.Conditions[0]["TriggerTime"]); } diff --git a/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs index 0a03bdf..8ae60cd 100755 --- a/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs +++ b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs @@ -314,11 +314,11 @@ /// 璁惧閲嶅懡鍚� /// </summary> /// <param name="i_deviceName">deviceName.</param> - private async void DeviceReName(string i_deviceName, bool closeForm) + private void DeviceReName(string i_deviceName, bool closeForm) { //淇敼MAC鍚� string deviceName = i_deviceName.Trim(); - var result = await LocalDevice.Current.ReName(this.device, deviceName); + var result = LocalDevice.Current.ReName(this.device, deviceName); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/ModelData/DeviceModelDataLogic.cs b/ZigbeeApp/Shared/Phone/ModelData/DeviceModelDataLogic.cs new file mode 100755 index 0000000..9070abe --- /dev/null +++ b/ZigbeeApp/Shared/Phone/ModelData/DeviceModelDataLogic.cs @@ -0,0 +1,789 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.ModelData +{ + /// <summary> + /// 璁惧妯℃澘鏁版嵁鐨勯�昏緫 + /// </summary> + public class DeviceModelDataLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧妯℃澘鏁版嵁鐨勯�昏緫 + /// </summary> + private static DeviceModelDataLogic m_Current = null; + /// <summary> + /// 璁惧妯℃澘鏁版嵁鐨勯�昏緫 + /// </summary> + public static DeviceModelDataLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new DeviceModelDataLogic(); + } + return m_Current; + } + } + /// <summary> + /// 妯℃澘鏁版嵁 + /// </summary> + private ModelMemoryData modelData = new ModelMemoryData(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍒濆鍖栧叏閮ㄦ暟鎹� + /// </summary> + public void InitAllData() + { + } + + #endregion + + #region 鈻� 绐楀笜鎵嬫媺鎺у埗_______________________ + + /// <summary> + /// 娣诲姞绐楀笜鎵嬫媺鎺у埗缂撳瓨 + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="bolStatu">鎵嬫媺鎺у埗鐘舵��</param> + /// <param name="topic">涓婚</param> + public void SetCurtainHandPullControl(CommonDevice device, bool bolStatu, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelCurtainHandPullControl(); + classData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绐楀笜鎵嬫媺鎺у埗, classData); + + classData.Statu = bolStatu; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁灞炴��; + classData.TopicName = topic; + //淇濆瓨鏁版嵁 + this.SaveData(device); + } + + /// <summary> + /// 鑾峰彇绐楀笜鎵嬫媺鎺у埗鐘舵��(铏氭嫙浣跨敤) + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public bool GetCurtainHandPullControl(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelCurtainHandPullControl(); + classData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绐楀笜鎵嬫媺鎺у埗, classData); + + return classData.Statu; + } + + #endregion + + #region 鈻� 绐楀笜鏂瑰悜___________________________ + + /// <summary> + /// 璁剧疆绐楀笜鐨勬柟鍚� + /// </summary> + /// <param name="device"></param> + /// <param name="isDirectionReversed"></param> + /// <param name="topic"></param> + /// <returns></returns> + public CommonDevice.SetWritableValueResponAllData SetCurtainDirection(CommonDevice device, bool isDirectionReversed, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelCurtainDirectionAndLimite(); + classData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绐楀笜鏂瑰悜鍙婇檺浣�, classData); + + classData.Direction = isDirectionReversed; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁灞炴��; + classData.TopicName = topic; + //淇濆瓨鏁版嵁 + this.SaveData(device); + + return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 } }; + } + + #endregion + + #region 鈻� 绐楀笜闄愪綅___________________________ + + /// <summary> + /// 鑾峰彇寮�鍚堝笜鐨勯檺浣� + /// </summary> + /// <param name="rollershade"></param> + /// <param name="upLimit"></param> + /// <param name="downLimit"></param> + /// <param name="curtainLength"></param> + /// <param name="topic"></param> + /// <returns></returns> + public bool SetCurtainLimitPoint(CommonDevice rollershade,int upLimit, int downLimit, int curtainLength, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelCurtainDirectionAndLimite(); + classData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade, ModelDeviceSaveEnum.A绐楀笜鏂瑰悜鍙婇檺浣�, classData); + classData.curtainLength = curtainLength; + classData.downLimit = downLimit; + classData.upLimit = upLimit; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁灞炴��; + classData.TopicName = topic; + + return true; + } + + /// <summary> + /// 鑾峰彇寮�鍚堝笜鐨勯檺浣� + /// </summary> + /// <param name="rollershade"></param> + /// <returns></returns> + public ModelCurtainDirectionAndLimite GetCurtainLimitPoint(CommonDevice rollershade) + { + //鑾峰彇瀵硅薄 + var classData = new ModelCurtainDirectionAndLimite(); + classData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade, ModelDeviceSaveEnum.A绐楀笜鏂瑰悜鍙婇檺浣�, classData); + + return classData; + } + + #endregion + + #region 鈻� 绌鸿皟鑷畾涔夋ā寮廮____________________ + + /// <summary> + /// 娣诲姞绌鸿皟鑷畾涔夋ā寮忕紦瀛� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="data">鍊�</param> + public void SetAcModeSupport(CommonDevice device, int data, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelAcModeSupport(); + classData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绌鸿皟鑷畾涔夋ā寮�, classData); + + classData.data = data; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁灞炴��; + classData.TopicName = topic; + //淇濆瓨鏁版嵁 + this.SaveData(device); + } + + /// <summary> + /// 鑾峰彇绌鸿皟鑷畾涔夋ā寮�(铏氭嫙浣跨敤) + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public int GetAcModeSupport(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelAcModeSupport(); + classData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绌鸿皟鑷畾涔夋ā寮�, classData); + + return classData.data; + } + + #endregion + + #region 鈻� 绌鸿皟鎽嗛妯″紡_______________________ + + /// <summary> + /// 娣诲姞绌鸿皟鎽嗛妯″紡缂撳瓨 + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="data">鍊�</param> + public void SetAcSwingModeSupport(CommonDevice device, int data, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelAcSwingModeSupport(); + classData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绌鸿皟鎽嗛鍔熻兘, classData); + + classData.data = data; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁灞炴��; + classData.TopicName = topic; + //淇濆瓨鏁版嵁 + this.SaveData(device); + } + + /// <summary> + /// 鑾峰彇绌鸿皟鎽嗛妯″紡(铏氭嫙浣跨敤) + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public int GetAcSwingModeSupport(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelAcSwingModeSupport(); + classData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绌鸿皟鎽嗛鍔熻兘, classData); + + return classData.data; + } + + #endregion + + #region 鈻� 璁惧缁戝畾___________________________ + + /// <summary> + /// 鑾峰彇璁惧缁戝畾鍒楄〃鐨勭紦瀛� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <returns></returns> + public List<BindObj.BindListResponseObj> GetDeviceBindList(CommonDevice device, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceBindData(); + classData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧缁戝畾鍒楄〃, classData); + + return classData.BindList; + } + + /// <summary> + /// 娣诲姞璁惧缁戝畾鍒楄〃鐨勭紦瀛� + /// </summary> + /// <param name="addBindData"></param> + /// <param name="topic">涓婚</param> + /// <returns></returns> + public BindObj.AddedDeviceBindResponseAllData AddDeviceBindList(BindObj.AddBindData addBindData, string topic) + { + var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceBindData(); + classData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧缁戝畾鍒楄〃, classData); + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁鍗忚; + classData.TopicName = topic; + + var reData = new BindObj.AddedDeviceBindResponseAllData(); + reData.addedDeviceBindResponseData = new BindObj.AddedDeviceBindResponseData(); + reData.addedDeviceBindResponseData.Result = 0; + + foreach (var data in addBindData.BindList) + { + bool canAdd = true; + for (int i = 0; i < classData.BindList.Count; i++) + { + var bindData = classData.BindList[i]; + //濡傛灉鏄澶� + if (bindData.BindType == 0 && data.BindType == 0 + && bindData.BindMacAddr == data.BindMacAddr + && bindData.BindEpoint == data.BindEpoint + && bindData.BindCluster == data.BindCluster) + { + //鍚屼竴涓笢瑗夸笉闇�瑕佹浛鎹� + canAdd = false; + reData.addedDeviceBindResponseData.BindList.Add(bindData); + break; + } + //濡傛灉鏄満鏅� + if (bindData.BindType == 2 && data.BindType == 1 + && bindData.BindScenesId == data.BindScenesId + && bindData.BindCluster == data.BindCluster) + { + //鍚屼竴涓笢瑗夸笉闇�瑕佹浛鎹� + canAdd = false; + reData.addedDeviceBindResponseData.BindList.Add(bindData); + break; + } + } + if (canAdd == true) + { + //娣诲姞鏂扮殑缂撳瓨 + var newData = new BindObj.BindListResponseObj(); + classData.BindList.Add(newData); + newData.BindCluster = data.BindCluster; + newData.BindEpoint = data.BindEpoint; + newData.BindMacAddr = data.BindMacAddr; + newData.BindScenesId = data.BindScenesId; + newData.BindType = data.BindType == 0 ? 0 : 2; + reData.addedDeviceBindResponseData.BindList.Add(newData); + } + } + //淇濆瓨鏁版嵁 + this.SaveData(device); + + return reData; + } + + /// <summary> + /// 鍒犻櫎璁惧缁戝畾鍒楄〃鐨勭紦瀛� + /// </summary> + /// <param name="delDeviceBindData"></param> + /// <returns></returns> + public BindObj.DelDeviceBindResponseAllData DeleteDeviceBindList(BindObj.DelDeviceBindData delDeviceBindData) + { + var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint); + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceBindData(); + classData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧缁戝畾鍒楄〃, classData); + + //杩斿洖鍊� + var reData = new BindObj.DelDeviceBindResponseAllData(); + reData.removeBindResultResponseData = new BindObj.RemoveBindResultResponseData(); + reData.removeBindResultResponseData.Result = 0; + + reData.delDeviceBindResponseData = new BindObj.DelDeviceBindResponseData(); + + foreach (var data in delDeviceBindData.RemoveBindList) + { + for (int i = 0; i < classData.BindList.Count; i++) + { + var bindData = classData.BindList[i]; + //濡傛灉鏄澶� + if (bindData.BindType == 0 && data.BindType == 0 + && bindData.BindMacAddr == data.BindMacAddr + && bindData.BindEpoint == data.BindEpoint + && bindData.BindCluster == data.BindCluster) + { + //绉婚櫎缂撳瓨 + classData.BindList.RemoveAt(i); + break; + } + //濡傛灉鏄満鏅� + if (bindData.BindType == 2 && data.BindType == 1 + && bindData.BindScenesId == data.BindScenesId + && bindData.BindCluster == data.BindCluster) + { + //绉婚櫎缂撳瓨 + classData.BindList.RemoveAt(i); + break; + } + } + var removeData = new BindObj.RemoveBindListResponseObj(); + reData.delDeviceBindResponseData.RemoveBindList.Add(removeData); + removeData.BindCluster = data.BindCluster; + removeData.BindEpoint = data.BindEpoint; + removeData.BindMacAddr = data.BindMacAddr; + removeData.BindScenesId = data.BindScenesId; + removeData.BindType = data.BindType == 0 ? 0 : 2; + removeData.Result = 0; + } + //淇濆瓨鏁版嵁 + this.SaveData(device); + return reData; + } + + /// <summary> + /// 鍒犻櫎鎸囧畾璁惧鐨勫叏閮ㄧ粦瀹� + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public BindObj.ClearBindInfoResponseAllData ClearDeviceAllBind(CommonDevice device) + { + string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device); + if (this.modelData.dicAllData.ContainsKey(mainkey) == true) + { + //鍒涘缓瀛樺偍绌洪棿 + this.modelData.dicAllData.Remove(mainkey); + } + this.SaveData(device); + + return new BindObj.ClearBindInfoResponseAllData + { + clearBindInfoResponseData = new BindObj.ClearBindInfoResponseData { Result = 0 } + }; + } + + /// <summary> + /// 閰嶇疆鎸夐敭鐨勫姛鑳芥ā寮� + /// </summary> + /// <param name="device"></param> + /// <param name="value"></param> + /// <param name="clusterID"></param> + /// <returns></returns> + public CommonDevice.SetWritableValueResponAllData ConfigurePanelKeyModel(CommonDevice device, Panel.KeyMode value, int clusterID, string topic) + { + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceBindData(); + classData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧缁戝畾鍒楄〃, classData); + classData.TopicName2 = topic; + classData.keyMode = value; + classData.keyModeClusterID = clusterID; + + this.SaveData(device); + + return new CommonDevice.SetWritableValueResponAllData + { + setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 } + }; + } + + /// <summary> + /// 鑾峰彇鎸夐敭鐨勫姛鑳芥ā寮� + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureKeyModel(CommonDevice device) + { + var classData = new ModelDeviceBindData(); + classData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧缁戝畾鍒楄〃, classData); + + var data = new Panel.PanelConfigureInfoResponAllData(); + data.deviceStatusReportData = new CommonDevice.DeviceStatusReportData { CluterID = classData.keyModeClusterID }; + + var dataAttri = new CommonDevice.AttributeDataObj(); + dataAttri.AttriButeData = (int)classData.keyMode; + + return data; + } + + #endregion + + #region 鈻� Pir浼犳劅鍣╛_________________________ + + /// <summary> + /// 鑾峰彇Pir浼犳劅鍣ㄧ殑閰嶇疆 + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public IASZone.ParamatesInfo GetPirSensorLightSettion(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPirSensorSettion(); + classData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.APir閰嶇疆, classData); + + var localData = new IASZone.ParamatesInfo(); + localData.configureParamates = new IASZone.ConfigureParamates(); + localData.configureParamates.controlDevEnable = classData.pirConfigure.controlDevEnable; + localData.configureParamates.dimmerLevel = classData.pirConfigure.dimmerLevel; + localData.configureParamates.dimmerOffTime = classData.pirConfigure.dimmerOffTime; + localData.configureParamates.dimmerOnTime = classData.pirConfigure.dimmerOnTime; + localData.configureParamates.iasReportPeriod = classData.pirConfigure.iasReportPeriod; + localData.configureParamates.levelEnable = classData.pirConfigure.levelEnable; + localData.configureParamates.levelSize = classData.pirConfigure.levelSize; + localData.configureParamates.mode = classData.pirConfigure.mode; + localData.configureParamates.transitionTime = classData.pirConfigure.transitionTime; + localData.configureParamates.type = classData.pirConfigure.type; + + return localData; + } + + /// <summary> + /// 璁剧疆Pir浼犳劅鍣ㄧ殑閰嶇疆 + /// </summary> + /// <param name="device"></param> + /// <param name="configureParamates"></param> + /// <returns></returns> + public IASZone.ResponseAllData SetPirSensorLightSettion(CommonDevice device, IASZone.ConfigureParamates configureParamates, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPirSensorSettion(); + classData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.APir閰嶇疆, classData); + + classData.pirConfigure = configureParamates; + classData.DataSendDiv = ModelDataSendEnum.A閫忎紶鏁版嵁; + classData.TopicName = topicName; + + this.SaveData(device); + + return new CommonDevice.ResponseAllData { responseData = new CommonDevice.ResponseData { status = 0 } }; + } + + #endregion + + #region 鈻� 闈㈡澘闇囧姩鍔熻兘_______________________ + + /// <summary> + /// 鑾峰彇闈㈡澘闇囧姩鍔熻兘 + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public UserCenter.HdlDevicePanelLogic.PanelVibrationInfo GetPanelVibrationInfo(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelVibrationInfo(); + classData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘闇囧姩鍔熻兘, classData); + + var data = new UserCenter.HdlDevicePanelLogic.PanelVibrationInfo(); + data.A闇囧姩浣胯兘 = classData.vibrationInfo.A闇囧姩浣胯兘; + data.A闇囧姩寮哄害 = classData.vibrationInfo.A闇囧姩寮哄害; + data.A闇囧姩鏃堕棿 = classData.vibrationInfo.A闇囧姩鏃堕棿; + + return data; + } + + /// <summary> + /// 璁剧疆闈㈡澘闇囧姩鍔熻兘 + /// </summary> + /// <param name="device"></param> + /// <param name="datainfo"></param> + /// <param name="topicName"></param> + /// <returns></returns> + public bool SetPanelVibrationInfo(CommonDevice device, UserCenter.HdlDevicePanelLogic.PanelVibrationInfo datainfo, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelVibrationInfo(); + classData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘闇囧姩鍔熻兘, classData); + classData.TopicName = topicName; + classData.vibrationInfo = datainfo; + classData.DataSendDiv = ModelDataSendEnum.A閫忎紶鏁版嵁; + + this.SaveData(device); + + return true; + } + #endregion + + #region 鈻� 璁惧鍚嶇О___________________________ + + /// <summary> + /// 淇敼璁惧Mac鍚嶇О + /// </summary> + /// <param name="device"></param> + /// <param name="macName"></param> + /// <returns></returns> + public CommonDevice.RenameDeviceMacNameAllData ReDeviceMacName(CommonDevice device, string macName, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceMacNameInfo(); + classData = (ModelDeviceMacNameInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A璁惧鍚嶇О, classData); + classData.deviceMacName = macName; + classData.TopicName = topicName; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁鍗忚; + + this.SaveData(device); + + return new CommonDevice.RenameDeviceMacNameAllData + { + renameDeviceMacNameData = new CommonDevice.RenameDeviceMacNameData + { + Result = 0, + MacName = macName + } + }; + } + + /// <summary> + /// 淇敼璁惧绔偣鍚嶇О + /// </summary> + /// <param name="device"></param> + /// <param name="macName"></param> + /// <returns></returns> + public CommonDevice.DeviceRenameAllData ReDeviceEpointName(CommonDevice device, string deviceName, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelDeviceEpointNameInfo(); + classData = (ModelDeviceEpointNameInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A绔偣鍚嶇О, classData); + classData.deviceEpointName = deviceName; + classData.TopicName = topicName; + classData.DataSendDiv = ModelDataSendEnum.A绉佹湁鍗忚; + + this.SaveData(device); + + return new CommonDevice.DeviceRenameAllData + { + deviceRenameData = new CommonDevice.DeviceRenameResponseData + { + Result = 0, + DeviceName = deviceName + } + }; + } + + #endregion + + #region 鈻� 闈㈡澘鑳屽厜鐏缃甠____________________ + + /// <summary> + /// 鑾峰彇璁惧浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛� + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + + var data = new Panel.PanelSwitchLevelInfo(); + data.panelBacklightLevel = classData.linghtLevelInfo.panelBacklightLevel == -1 ? 0 : classData.linghtLevelInfo.panelBacklightLevel; + data.panelDirectionsLevel = classData.linghtLevelInfo.panelDirectionsLevel == -1 ? 0 : classData.linghtLevelInfo.panelDirectionsLevel; + return data; + } + + /// <summary> + /// 璁剧疆璁惧浜害锛坲i鍙寒搴﹁皟鑺傦級 + /// </summary> + /// <param name="panel">璁惧瀵硅薄</param> + /// <param name="directionsLevel">0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</param> + /// <param name="backlightLevel">0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</param> + /// <returns></returns> + public bool SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + classData.TopicName = topicName; + classData.linghtLevelInfo.panelBacklightLevel = backlightLevel; + classData.linghtLevelInfo.panelDirectionsLevel = directionsLevel; + classData.DataSendDiv = ModelDataSendEnum.A閫忎紶鏁版嵁; + + this.SaveData(device); + + return true; + } + + /// <summary> + /// 鑾峰彇璁惧鑺傝兘妯″紡鐨勯厤缃姸鎬�(ui鍙妭鑳芥ā寮�) + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public Panel.PanelSaveEnergyModeInfo GetDeviceEnergyConservationMode(CommonDevice device) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + + var data = new Panel.PanelSaveEnergyModeInfo(); + data.enable = classData.energyModeInfo.enable; + data.level = classData.energyModeInfo.level == -1 ? 0 : classData.energyModeInfo.level; + data.time = classData.energyModeInfo.time == -1 ? 0 : classData.energyModeInfo.time; + return data; + } + + /// <summary> + /// 璁剧疆璁惧鐨勮妭鑳芥ā寮�(ui鍙妭鑳芥ā寮�) + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="modeEnable">鑺傝兘妯″紡鏄惁鏈夋晥</param> + /// <param name="modeTime">鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-255</param> + /// <param name="level">鑺傝兘妯″紡浜害:0-100</param> + /// <returns></returns> + public bool SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level,string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + classData.TopicName = topicName; + classData.DataSendDiv = ModelDataSendEnum.A閫忎紶鏁版嵁; + classData.energyModeInfo.enable = modeEnable; + classData.energyModeInfo.time = modeTime; + classData.energyModeInfo.level = level; + + this.SaveData(device); + + return true; + } + + /// <summary> + /// 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�. + /// </summary> + /// <param name="device"></param> + /// <param name="keyNum"></param> + /// <returns></returns> + public Panel.KeyColorDataResponseAllData GetPanelColorInfo(CommonDevice device, Panel.KeyNum keyNum) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + + var data = new Panel.KeyColorDataResponseAllData(); + data.keyColorData = new Panel.KeyColorData(); + data.keyColorData.CloseColorB = string.IsNullOrEmpty(classData.keyColorData.CloseColorB) == true ? "0" : classData.keyColorData.CloseColorB; + data.keyColorData.CloseColorG = string.IsNullOrEmpty(classData.keyColorData.CloseColorG) == true ? "0" : classData.keyColorData.CloseColorG; + data.keyColorData.CloseColorR = string.IsNullOrEmpty(classData.keyColorData.CloseColorR) == true ? "0" : classData.keyColorData.CloseColorR; + data.keyColorData.OpenColorB = string.IsNullOrEmpty(classData.keyColorData.OpenColorB) == true ? "0" : classData.keyColorData.OpenColorB; + data.keyColorData.OpenColorG = string.IsNullOrEmpty(classData.keyColorData.OpenColorG) == true ? "0" : classData.keyColorData.OpenColorG; + data.keyColorData.OpenColorR = string.IsNullOrEmpty(classData.keyColorData.OpenColorR) == true ? "0" : classData.keyColorData.OpenColorR; + data.keyColorData.keyNum = keyNum; + + return data; + } + + ///<summary > + ///閰嶇疆鎸夐敭鎸囩ず鐏鑹� + /// </summary> + public CommonDevice.ResponseAllData SetPanelColorInfo(CommonDevice device, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus, string topicName) + { + //鑾峰彇瀵硅薄 + var classData = new ModelPanelBackLightInfo(); + classData = (ModelPanelBackLightInfo)this.GetDeviceModelDataClass(device, ModelDeviceSaveEnum.A闈㈡澘鑳屽厜鐏�, classData); + classData.TopicName = topicName; + classData.DataSendDiv = ModelDataSendEnum.A閫忎紶鏁版嵁; + + classData.keyColorData.keyNum = keyColorData.keyNum; + classData.keyColorData.OpenColorB = keyColorData.OpenColorB; + classData.keyColorData.OpenColorG = keyColorData.OpenColorG; + classData.keyColorData.OpenColorR = keyColorData.OpenColorR; + classData.keyColorData.CloseColorB = keyColorData.CloseColorB; + classData.keyColorData.CloseColorG = keyColorData.CloseColorG; + classData.keyColorData.CloseColorR = keyColorData.CloseColorR; + + classData.KeyNum.Key1 = keyNumStatus.Key1; + classData.KeyNum.Key2 = keyNumStatus.Key2; + classData.KeyNum.Key3 = keyNumStatus.Key3; + classData.KeyNum.Key4 = keyNumStatus.Key4; + classData.KeyNum.Key5 = keyNumStatus.Key5; + classData.KeyNum.Key6 = keyNumStatus.Key6; + classData.KeyNum.Key7 = keyNumStatus.Key7; + classData.KeyNum.Key8 = keyNumStatus.Key8; + classData.KeyNum.Key9 = keyNumStatus.Key9; + classData.KeyNum.Key10 = keyNumStatus.Key10; + classData.KeyNum.Key11 = keyNumStatus.Key11; + classData.KeyNum.Key12 = keyNumStatus.Key12; + classData.KeyNum.Key13 = keyNumStatus.Key13; + classData.KeyNum.Key14 = keyNumStatus.Key14; + classData.KeyNum.Key15 = keyNumStatus.Key15; + classData.KeyNum.Key16 = keyNumStatus.Key16; + + this.SaveData(device); + + return new CommonDevice.ResponseAllData + { + responseData = new CommonDevice.ResponseData + { status = 0 } + }; + } + + #endregion + + #region 鈻� 淇濆瓨鏁版嵁___________________________ + + /// <summary> + /// 淇濆瓨缂撳瓨鏁版嵁 + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + private void SaveData(CommonDevice device) + { + //闇�瑕佸垽鏂�,濡傛灉涓嶅瓨鍦ㄤ簡,闇�瑕佸垹闄ゆ枃浠� + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鑾峰彇璁惧淇濆瓨鐨勬ā鏉垮璞� + /// </summary> + /// <param name="device"></param> + /// <param name="saveEnum"></param> + /// <returns></returns> + private ModelDeviceDataCommon GetDeviceModelDataClass(CommonDevice device, ModelDeviceSaveEnum saveEnum, ModelDeviceDataCommon newClass) + { + string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device); + if (this.modelData.dicAllData.ContainsKey(mainkey) == false) + { + //鍒涘缓瀛樺偍绌洪棿 + this.modelData.dicAllData[mainkey] = new List<ModelDeviceDataCommon>(); + } + foreach (var data in this.modelData.dicAllData[mainkey]) + { + //濡傛灉鏄凡缁忓瓨鍦ㄤ簡鐨� + if (data.DataSaveDiv == saveEnum) + { + return data; + } + } + //鏂板缓涓�涓柊鐨勫璞� + newClass.DataSaveDiv = saveEnum; + newClass.DeviceEpoint = device.DeviceEpoint; + newClass.DeviceMac = device.DeviceAddr; + this.modelData.dicAllData[mainkey].Add(newClass); + + return newClass; + } + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/ModelData/ModelDataCommon.cs b/ZigbeeApp/Shared/Phone/ModelData/ModelDataCommon.cs new file mode 100755 index 0000000..cd2caa5 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/ModelData/ModelDataCommon.cs @@ -0,0 +1,399 @@ +锘縰sing Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.ModelData +{ + #region 鈻� 鍏遍�氭ā鏉挎暟鎹畾涔塤__________________ + + /// <summary> + /// 妯℃澘缂撳瓨鏁版嵁 + /// </summary> + public class ModelMemoryData + { + /// <summary> + /// 鍏ㄩ儴鐨勭紦瀛樻暟鎹� + /// </summary> + public Dictionary<string, List<ModelDeviceDataCommon>> dicAllData = new Dictionary<string, List<ModelDeviceDataCommon>>(); + } + + /// <summary> + /// 涓�涓澶囩殑妯℃澘鏁版嵁鐨勫叡閫� + /// </summary> + public class ModelDeviceDataCommon + { + /// <summary> + /// 璁惧Mac鍦板潃 + /// </summary> + public string DeviceMac = string.Empty; + /// <summary> + /// 璁惧绔偣 + /// </summary> + public int DeviceEpoint = -1; + /// <summary> + /// 鏁版嵁淇濆瓨鐨勫尯鍒�(涓嶉渶瑕佸啀娆¤缃�) + /// </summary> + public ModelDeviceSaveEnum DataSaveDiv = ModelDeviceSaveEnum.A鏈畾涔�; + /// <summary> + /// 鍙戦�佹ā鏉挎暟鎹殑鍖哄垎,鐢ㄤ互鏍囪瘑鏄互浠�涔堟柟寮忓彂閫佺粰缃戝叧(闇�瑕佸啀娆℃寚瀹�) + /// </summary> + public ModelDataSendEnum DataSendDiv = ModelDataSendEnum.A鏈畾涔�; + /// <summary> + /// 鏁版嵁鍙戦�佹垚鍔熺殑杩斿洖鏍囪瘑(姝ゅ彉閲忔槸缁欍�愰�忎紶鏁版嵁銆戜娇鐢�,鍊熶互璁╃綉鍏崇煡閬撻�忎紶涔嬪悗,鎬庝箞鍒ゆ柇鎴愬姛) + /// </summary> + public string SuccessFlage = string.Empty; + /// <summary> + /// 涓婚鍚嶅瓧(闇�瑕佸啀娆℃寚瀹�) + /// </summary> + public string TopicName = string.Empty; + + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗�(鍥犱负鏈変簺涓滆タ闇�瑕佽�冭檻闀濱D,鎵�浠ユ湁鍙兘浼氬嚭鐜板鏉″懡浠�) + /// </summary> + /// <returns></returns> + public virtual List<string> GetSendGatewayValue() + { + return new List<string>(); + } + } + + #endregion + + #region 鈻� 绐楀笜妯℃澘鏁版嵁瀹氫箟___________________ + + /// <summary> + /// 绐楀笜鎵嬫媺鎺у埗妯℃澘瀹氫箟 + /// </summary> + public class ModelCurtainHandPullControl : ModelDeviceDataCommon + { + /// <summary> + /// 鐘舵�� + /// </summary> + public bool Statu = false; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = HdlDeviceCurtainLogic.Current.GetHandPullControlText(DeviceMac, DeviceEpoint, Statu); + return new List<string>() { command }; + } + } + + /// <summary> + /// 绐楀笜鎵嬫媺鎺у埗妯℃澘瀹氫箟 + /// </summary> + public class ModelCurtainDirectionAndLimite : ModelDeviceDataCommon + { + /// <summary> + /// false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜 + /// </summary> + public bool Direction = false; + /// <summary> + /// 寮�闄愪綅 + /// </summary> + public int upLimit = 2; + /// <summary> + /// 鍚堥檺浣� + /// </summary> + public int downLimit = 98; + /// <summary> + /// 瀵艰建闀垮害 + /// </summary> + public int curtainLength = 100; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + //鏂瑰悜 + var command1 = HdlDeviceCurtainLogic.Current.GetCurtainDirectionCommadText(DeviceMac, DeviceEpoint, Direction); + //闄愪綅 + var command2 = HdlDeviceCurtainLogic.Current.GetAutoOpenCurtainLimitPointCommandText(DeviceMac, DeviceEpoint, upLimit, downLimit); + return new List<string>() { command1, command2 }; + } + } + + #endregion + + #region 鈻� 绌鸿皟妯℃澘鏁版嵁瀹氫箟___________________ + + /// <summary> + /// 绌鸿皟鑷畾涔夋ā寮忔ā鏉挎暟鎹畾涔� + /// </summary> + public class ModelAcModeSupport : ModelDeviceDataCommon + { + /// <summary> + /// 鍊� + /// </summary> + public int data = 0; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(DeviceMac, DeviceEpoint, 513, 4099, 25, data); + return new List<string>() { command }; + } + } + + /// <summary> + /// 绌鸿皟鎽嗛妯″紡妯℃澘鏁版嵁瀹氫箟 + /// </summary> + public class ModelAcSwingModeSupport : ModelDeviceDataCommon + { + /// <summary> + /// 鍊� + /// </summary> + public int data = 0; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(DeviceMac, DeviceEpoint, 513, 4099, 25, data); + return new List<string>() { command }; + } + } + + #endregion + + #region 鈻� 璁惧缁戝畾妯℃澘鏁版嵁瀹氫箟_______________ + + /// <summary> + /// 璁惧缁戝畾妯℃澘鏁版嵁瀹氫箟 + /// </summary> + public class ModelDeviceBindData : ModelDeviceDataCommon + { + /// <summary> + /// 鎸夐敭鐨勫姛鑳芥ā寮� + /// </summary> + public ZigBee.Device.Panel.KeyMode keyMode = ZigBee.Device.Panel.KeyMode.Default; + /// <summary> + /// 鎸夐敭鐨勫姛鑳芥ā寮忕殑闀濱D + /// </summary> + public int keyModeClusterID = 0; + /// <summary> + /// 鎸夐敭鐨勫姛鑳芥ā寮忕殑涓婚 + /// </summary> + public string TopicName2 = string.Empty; + /// <summary> + /// 缁戝畾鍒楄〃 + /// </summary> + public List<ZigBee.Device.BindObj.BindListResponseObj> BindList = new List<ZigBee.Device.BindObj.BindListResponseObj>(); + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var addBindData = new ZigBee.Device.BindObj.AddBindData(); + addBindData.DeviceAddr = this.DeviceMac; + addBindData.Epoint = this.DeviceEpoint; + + foreach (var data in BindList) + { + var addData = new ZigBee.Device.BindObj.AddBindListObj(); + addBindData.BindList.Add(addData); + addData.BindCluster = data.BindCluster; + addData.BindEpoint = data.BindEpoint; + addData.BindMacAddr = data.BindMacAddr; + addData.BindScenesId = data.BindScenesId; + addData.BindType = data.BindType == 0 ? 0 : 1; + } + //鍔熻兘閰嶇疆 + var command1 = HdlDeviceBindLogic.Current.GetConfigureHdlKeyCommandText(this.DeviceMac, this.DeviceEpoint, keyMode, keyModeClusterID); + //缁戝畾鍒楄〃 + var command2 = HdlDeviceBindLogic.Current.GetAddDeviceListBindCommandText(addBindData); + return new List<string>() { command1, command2 }; + } + } + + #endregion + + #region 鈻� Pir浼犳劅鍣ㄦā鏉挎暟鎹畾涔塤_____________ + + /// <summary> + /// Pir浼犳劅鍣ㄦā鏉挎暟鎹畾涔� + /// </summary> + public class ModelPirSensorSettion : ModelDeviceDataCommon + { + /// <summary> + /// pir鐨勯厤缃俊鎭� + /// </summary> + public ZigBee.Device.IASZone.ConfigureParamates pirConfigure = new ZigBee.Device.IASZone.ConfigureParamates(); + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = HdlDevicePirSensorLogic.Current.GetPirSensorSettionCommandText(DeviceMac, pirConfigure); + return new List<string>() { command }; + } + } + + #endregion + + #region 鈻� 闈㈡澘妯℃澘鏁版嵁瀹氫箟___________________ + + /// <summary> + /// 闈㈡澘闇囧姩鍔熻兘妯℃澘鏁版嵁瀹氫箟 + /// </summary> + public class ModelPanelVibrationInfo : ModelDeviceDataCommon + { + /// <summary> + /// 闇囧姩鍔熻兘 + /// </summary> + public HdlDevicePanelLogic.PanelVibrationInfo vibrationInfo = new HdlDevicePanelLogic.PanelVibrationInfo(); + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = HdlDevicePanelLogic.Current.GetPanelVibrationCommandText(DeviceMac, vibrationInfo); + return new List<string>() { command }; + } + } + + /// <summary> + /// 闈㈡澘鑳屽厜鐏ā鏉挎暟鎹畾涔� + /// </summary> + public class ModelPanelBackLightInfo : ModelDeviceDataCommon + { + /// <summary> + /// 浜害璋冭妭鐨勪俊鎭� + /// </summary> + public ModelPanelSwitchLevelInfo linghtLevelInfo = new ModelPanelSwitchLevelInfo(); + /// <summary> + /// 鑺傝兘妯″紡 + /// </summary> + public ZigBee.Device.Panel.PanelSaveEnergyModeInfo energyModeInfo = new ZigBee.Device.Panel.PanelSaveEnergyModeInfo(); + /// <summary> + /// 鎸夐敭鐨勯鑹叉暟鎹� + /// </summary> + public ZigBee.Device.Panel.KeyColorData keyColorData = new ZigBee.Device.Panel.KeyColorData(); + /// <summary> + /// 鍜宬eyColorData涓�璧风敤鐨勪笢瑗� + /// </summary> + public ZigBee.Device.Panel.KeyNumStatus KeyNum = new ZigBee.Device.Panel.KeyNumStatus(); + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + //浜害璋冭妭 + var command1 = HdlDevicePanelLogic.Current.GetPanelLevelCommadText(DeviceMac, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); + //鑺傝兘妯″紡 + var command2 = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationModeCommandText(DeviceMac, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); + return new List<string>() { command1, command2 }; + } + } + + /// <summary> + /// 鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃洖澶� + /// </summary> + public class ModelPanelSwitchLevelInfo + { + /// <summary> + ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��) + /// </summary> + public int panelDirectionsLevel = -1; + + /// <summary> + /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��) + /// </summary> + public int panelBacklightLevel = -1; + } + + #endregion + + #region 鈻� 璁惧鍚嶇О妯℃澘鏁版嵁瀹氫箟_______________ + + /// <summary> + /// 璁惧绔偣鍚嶇О妯℃澘鏁版嵁瀹氫箟 + /// </summary> + public class ModelDeviceEpointNameInfo : ModelDeviceDataCommon + { + /// <summary> + /// 璁惧绔偣鍚嶇О + /// </summary> + public string deviceEpointName = string.Empty; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = Common.LocalDevice.Current.GetReDeviceEpointNameCommandText(DeviceMac, DeviceEpoint, deviceEpointName); + return new List<string>() { command }; + } + } + + /// <summary> + /// 璁惧Mac鍚嶇О妯℃澘鏁版嵁瀹氫箟 + /// </summary> + public class ModelDeviceMacNameInfo : ModelDeviceDataCommon + { + /// <summary> + /// 璁惧Mac鍚嶇О + /// </summary> + public string deviceMacName = string.Empty; + /// <summary> + /// 鑾峰彇鏇存敼璁惧閰嶇疆鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <returns></returns> + public override List<string> GetSendGatewayValue() + { + var command = Common.LocalDevice.Current.GetReDeviceMacNameCommandText(DeviceMac, DeviceEpoint, deviceMacName); + return new List<string>() { command }; + } + } + + #endregion + + #region 鈻� 鑷畾涔夋灇涓綺________________________ + + /// <summary> + /// 妯℃澘璁惧淇濆瓨鐨勫尯鍒� + /// </summary> + public enum ModelDeviceSaveEnum + { + A鏈畾涔� = -1, + A璁惧鍚嶇О = 1, + A绔偣鍚嶇О = 2, + APir閰嶇疆 = 3, + A骞叉帴鐐归鑹茶皟鑺� = 4, + A骞叉帴鐐逛寒搴﹁皟鑺� = 5, + A骞叉帴鐐硅妭鑳芥ā寮� = 6, + A骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬� = 7, + A绐楀笜鏂瑰悜鍙婇檺浣� = 8, + A绐楀笜鎵嬫媺鎺у埗 = 9, + A绌鸿皟鑷畾涔夋ā寮� = 10, + A闈㈡澘闇囧姩鍔熻兘 = 11, + A绌鸿皟鎽嗛鍔熻兘 = 12, + A闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘 = 13, + A璁惧缁戝畾鍒楄〃 = 14, + A闈㈡澘鑳屽厜鐏� = 15 + } + + /// <summary> + /// 鍙戦�佹ā鏉挎暟鎹殑鍖哄垎 + /// </summary> + public enum ModelDataSendEnum + { + A鏈畾涔� = -1, + A绉佹湁灞炴�� = 1, + A绉佹湁鍗忚 = 2, + A閫忎紶鏁版嵁 = 3 + } + + #endregion +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/GatewayBackupEnum.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/GatewayBackupEnum.cs deleted file mode 100755 index a49de58..0000000 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/GatewayBackupEnum.cs +++ /dev/null @@ -1,69 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 缃戝叧澶囦唤鐨勬灇涓�(鏈�楂樺彧鑳借缃埌5浣嶆暟->99999) - /// </summary> - public enum GatewayBackupEnum - { - /// <summary> - /// 淇敼Mac鍚嶇О - /// </summary> - AMac鍚嶇О = 1, - /// <summary> - /// 淇敼绔偣鍚嶇О - /// </summary> - A绔偣鍚嶇О = 2, - /// <summary> - /// 璁剧疆PIR浼犳劅鍣ㄧ殑銆愮伅鍏夐厤缃�� - /// </summary> - APir鐏厜閰嶇疆 = 3, - /// <summary> - /// 骞叉帴鐐归鑹茶皟鑺� - /// </summary> - A骞叉帴鐐归鑹茶皟鑺� = 4, - /// <summary> - /// 骞叉帴鐐逛寒搴﹁皟鑺� - /// </summary> - A骞叉帴鐐逛寒搴﹁皟鑺� = 5, - /// <summary> - /// 骞叉帴鐐硅妭鑳芥ā寮� - /// </summary> - A骞叉帴鐐硅妭鑳芥ā寮� = 6, - /// <summary> - /// 骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬� - /// </summary> - A骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬� = 7, - /// <summary> - /// 绐楀笜涓婁笅闄愪綅(杩欎釜涓滆タ闇�瑕佸湪绗竴) - /// </summary> - A绐楀笜涓婁笅闄愪綅 = 8, - /// <summary> - /// 绐楀笜鎵嬫媺鎺у埗 - /// </summary> - A绐楀笜鎵嬫媺鎺у埗 = 9, - /// <summary> - /// 绐楀笜鏂瑰悜 - /// </summary> - A绐楀笜鏂瑰悜 = 10, - /// <summary> - /// 绌鸿皟鑷畾涔夋ā寮� - /// </summary> - A绌鸿皟鑷畾涔夋ā寮� = 11, - /// <summary> - /// 绠�绾﹂潰鏉块渿鍔ㄥ姛鑳� - /// </summary> - A绠�绾﹂潰鏉块渿鍔ㄥ姛鑳� = 12, - /// <summary> - /// 绌鸿皟鎽嗛鍔熻兘 - /// </summary> - A绌鸿皟鎽嗛鍔熻兘 = 13, - /// <summary> - /// 闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘 - /// </summary> - A闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘 = 14, - } -} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs index 7c602f5..a294679 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/UserCenterCommon.cs @@ -1292,6 +1292,10 @@ /// 寮哄埗璺宠浆缃戝叧浜у搧鐣岄潰 1->缃戝叧鍒楄〃寮哄埗璺宠浆 /// </summary> public int GotoGatewayProductInfoForm = 0; + /// <summary> + /// 鑷姩鍖栧父寮�鏃堕棿鍙樻洿涓哄垎閽�,鑰屼笉鏄皬鏃� 1->寮哄埗鍙樻洿涓哄垎閽� + /// </summary> + public int DoorLockNomallyOpenTimeMode = 0; } #endregion @@ -1363,4 +1367,31 @@ } #endregion + + #region 鈻� 缃戝叧鍥炲鎺ユ敹绫籣_____________________ + + /// <summary> + /// 缃戝叧鍥炲鎺ユ敹绫� + /// </summary> + public class ReceiptGatewayResult + { + /// <summary> + /// 閿欒娑堟伅,濡傛灉娌℃湁閿欒,鍒欎负null(缃戝叧瓒呮椂涔熶负null) + /// </summary> + public string ErrorMsg = null; + /// <summary> + /// 閿欒娑堟伅鐨勭被鍨� -1:缃戝叧瀵硅薄涓㈠け 0:瓒呮椂缃戝叧娌℃湁鍥炲 1:姝e父 + /// </summary> + public int ErrorMsgDiv = 1; + /// <summary> + /// 鎺ユ敹鐨勬暟鎹� + /// </summary> + public string ReceiptData = null; + /// <summary> + /// 鎺ユ敹鐨勬暟鎹�(澶氫釜杩斿洖涓婚涓撶敤) + /// </summary> + public string[] listReceiptData = null; + } + + #endregion } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs index c221ffc..8ff084f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAirConditionerLogic.cs @@ -114,22 +114,29 @@ #region 鈻� 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡_______________ /// <summary> - /// 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡 + /// 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡 鈽嗏槅鈽嗏槅鈽� /// </summary> /// <param name="device">绌鸿皟瀵硅薄</param> /// <param name="data">浠庝簩杩涘埗杞崲鐨勫崄杩涘埗鍊�</param> /// <returns></returns> - public async Task<bool> SetAcModeSupport(AC device, int data) + public bool SetAcModeSupport(AC device, int data) { - var result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(device, 513, 4099, 25, data); - //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜 - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowTipMsg(error); + //鐩存帴娣诲姞缂撳瓨 + ModelData.DeviceModelDataLogic.Current.SetAcModeSupport(device, data, "SetWritableValue"); + return true; + } + //鍙戦�佹暟鎹� + string sendData = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(device.DeviceAddr, device.DeviceEpoint, 513, 4099, 25, data); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return false; } - if (result == null || result.setWritableValueResponData == null) + if (result.ErrorMsgDiv == 0) { //璁剧疆绌鸿皟妯″紡澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetAcModeFail); @@ -138,14 +145,15 @@ this.ShowTipMsg(msg); ; return false; } - if (result.setWritableValueResponData.Status != 0) + + var responeData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + if (responeData.Status != 0) { //璁剧疆绌鸿皟妯″紡澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetAcModeFail); this.ShowTipMsg(msg); return false; } - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绌鸿皟鑷畾涔夋ā寮�, data); return true; } @@ -155,22 +163,29 @@ #region 鈻� 璁剧疆鍚敤绌鸿皟鐨勬憜椋庡姛鑳絖____________ /// <summary> - /// 璁剧疆鍚敤绌鸿皟鐨勬憜椋庡姛鑳� + /// 璁剧疆鍚敤绌鸿皟鐨勬憜椋庡姛鑳� 鈽嗏槅鈽嗏槅鈽� /// </summary> /// <param name="device">绌鸿皟瀵硅薄</param> /// <param name="data">浠庝簩杩涘埗杞崲鐨勫崄杩涘埗鍊�</param> /// <returns></returns> - public async Task<bool> SetUseAcSwingFunctionStatu(AC device, int data) + public bool SetUseAcSwingFunctionStatu(AC device, int data) { - var result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(device, 514, 4097, 25, data); - //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜 - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowTipMsg(error); + //鐩存帴娣诲姞缂撳瓨 + ModelData.DeviceModelDataLogic.Current.SetAcSwingModeSupport(device, data, "SetWritableValue"); + return true; + } + //鍙戦�佹暟鎹� + string sendData = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(device.DeviceAddr, device.DeviceEpoint, 514, 4097, 25, data); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return false; } - if (result == null || result.setWritableValueResponData == null) + if (result.ErrorMsgDiv == 0) { //璁剧疆绌鸿皟鎽嗛澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetAirConditionerSwingFunctionFail); @@ -179,14 +194,15 @@ this.ShowTipMsg(msg); return false; } - if (result.setWritableValueResponData.Status != 0) + + var responeData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + if (responeData.Status != 0) { //璁剧疆绌鸿皟鎽嗛澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetAirConditionerSwingFunctionFail); this.ShowTipMsg(msg); return false; } - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绌鸿皟鎽嗛鍔熻兘, data); return true; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs index 01ce670..20854f6 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs @@ -41,88 +41,28 @@ #region 鈻� 鍐欏叆璁惧灞炴�______________________ /// <summary> - /// 璁剧疆绌鸿皟鐨勮嚜瀹氫箟妯″紡 + /// 鑾峰彇鏇存敼璁惧绉佹湁灞炴�х殑鍛戒护 /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="clusterId">闀濱D</param> - /// <param name="attributeId">灞炴�D</param> - /// <param name="attributeDataType">鏁版嵁绫诲瀷</param> - /// <param name="attributeData">闇�瑕佸啓鍏ョ殑鏁版嵁(鏁板�兼垨鑰呭瓧绗︿覆)</param> + /// <param name="clusterId"></param> + /// <param name="attributeId"></param> + /// <param name="attributeDataType"></param> + /// <param name="attributeData"></param> /// <returns></returns> - public async System.Threading.Tasks.Task<CommonDevice.SetWritableValueResponAllData> WriteDeviceAttribute(CommonDevice device, int clusterId, int attributeId, int attributeDataType, object attributeData) + public string GetWriteDeviceAttributeText(string DeviceAddr, int DeviceEpoint, int clusterId, int attributeId, int attributeDataType, object attributeData) { - var MyGateway = device.Gateway; - if (MyGateway == null) + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterId }, { "Command", 120 } }; + Newtonsoft.Json.Linq.JObject data = null; + if (attributeData is int) { - return null; + data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", Convert.ToInt32(attributeData) } }; } - - CommonDevice.SetWritableValueResponAllData d = null; - Action<string, string> action = (topic, message) => + else { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - if (temp == null) - { - d = new CommonDevice.SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new CommonDevice.SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "SetWritableValue_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(jobject["Data"].ToString()); - if (tempData == null) - { - d = new CommonDevice.SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData }; - } - } - }; - MyGateway.Actions += action; - try - { - var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", clusterId }, { "Command", 120 } }; - Newtonsoft.Json.Linq.JObject data = null; - if (attributeData is int) - { - data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", Convert.ToInt32(attributeData) } }; - } - else - { - data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData.ToString() } }; - } - jObject.Add("Data", data); - MyGateway.Send("SetWritableValue", jObject.ToString()); + data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData.ToString() } }; } - catch { } + jObject.Add("Data", data); - var timeOut = 0; - while (timeOut <= 30) - { - await System.Threading.Tasks.Task.Delay(100); - if (d != null) - { - break; - } - timeOut++; - } - if (timeOut > 30 && d == null) - { - d = new CommonDevice.SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - MyGateway.Actions -= action; - return d; + return jObject.ToString(); } #endregion diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs index de95fbe..97a36c8 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs @@ -3,6 +3,7 @@ using System.Text; using ZigBee.Device; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Shared.Phone.UserCenter { @@ -37,13 +38,13 @@ #region 鈻� 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶嘷____________ /// <summary> - /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull) + /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull),杩欎釜鏄粰pir浼犳劅鍣ㄧ敤鐨� /// </summary> /// <param name="mainDevice">璁惧瀵硅薄</param> /// <returns></returns> - public async Task<List<CommonDevice>> GetBindTargetDevice(CommonDevice mainDevice) + public List<CommonDevice> GetBindTargetDevice(CommonDevice mainDevice) { - var result = (BindObj.GetDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "GetDeviceBindAsync"); + var result = this.GetDeviceBindAsync(mainDevice); if (result == null || result.getAllBindResponseData == null) { //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐� @@ -67,6 +68,37 @@ return listDevice; } + /// <summary> + ///鑾峰彇鎵�鏈夌粦瀹� + /// </summary> + public BindObj.GetDeviceBindResponseAllData GetDeviceBindAsync(CommonDevice device) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind"); + return new BindObj.GetDeviceBindResponseAllData() + { + getAllBindResponseData = new BindObj.GetDeviceBindResponseData + { + Result = 0, + BindList = listBind + } + }; + } + + var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } }; + string sendData = jObject.ToString(); + //鍙戦�� + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/GetDeviceBind", sendData, "Bind/GetDeviceBind_Respon", 6); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.GetDeviceBindResponseData>(result.ReceiptData); + return new BindObj.GetDeviceBindResponseAllData() { getAllBindResponseData = tempData }; + } + #endregion #region 鈻� 鎵ц缁戝畾璁惧鐩爣___________________ @@ -78,7 +110,7 @@ /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param> /// <param name="BindCluster">BindCluster</param> /// <returns></returns> - public async Task<List<CommonDevice>> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6) + public List<CommonDevice> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6) { if (listDevice.Count == 0) { @@ -105,8 +137,8 @@ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); dicDevice[mainkeys] = device; } - - var result = (BindObj.AddedDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "AddDeviceBindAsync", addData); + //鎵ц缁戝畾 + var result = this.AddDeviceBindAsync(addData); if (result == null || result.addedDeviceBindResponseData == null) { //缁戝畾鐩爣璁剧疆澶辫触 @@ -137,6 +169,63 @@ return listSuccess; } + /// <summary> + ///璁惧缁戝畾 + /// </summary> + public BindObj.AddedDeviceBindResponseAllData AddDeviceBindAsync(BindObj.AddBindData addBindData) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind"); + } + + var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); + //鑾峰彇鍙戦�佺殑鍛戒护瀛楃 + var sendData = this.GetAddDeviceListBindCommandText(addBindData); + //鍙戦�� + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetBind", sendData, "Bind/SetBind_Respon", 20); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData); + return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData }; + } + + /// <summary> + /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="addBindData"></param> + /// <returns></returns> + public string GetAddDeviceListBindCommandText(BindObj.AddBindData addBindData) + { + var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } }; + var bindList = new JArray { }; + foreach (var bindInfo in addBindData.BindList) + { + if (bindInfo.BindType == 0) + { + var dInfo = new JObject{{ "BindMacAddr",bindInfo.BindMacAddr},{ "BindEpoint", bindInfo.BindEpoint} , + { "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}}; + bindList.Add(dInfo); + } + else if (bindInfo.BindType == 1) + { + var dInfo = new JObject{{ "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}, + { "BindScenesId", bindInfo.BindScenesId}}; + bindList.Add(dInfo); + } + } + var data = new JObject { { "BindName", addBindData.BindName }, { "BindList", bindList } }; + jObject.Add("Data", data); + return jObject.ToString(); + } + #endregion #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________ @@ -148,7 +237,7 @@ /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param> /// <param name="BindCluster">BindCluster</param> /// <returns></returns> - public async Task<bool> DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6) + public bool DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6) { //缁勮鏁版嵁 var deleteData = new IASZone.DelDeviceBindData(); @@ -163,7 +252,8 @@ deleteData.RemoveBindList.Add(info); - var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData); + //鎵ц鍒犻櫎 + var result = this.DelDeviceBindAsync(deleteData); if (result == null || result.delDeviceBindResponseData == null) { //鍒犻櫎缁戝畾鐩爣澶辫触 @@ -233,7 +323,7 @@ /// <param name="listDeleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param> /// <param name="BindCluster">BindCluster</param> /// <returns>杩斿洖鐨勬槸鎴愬姛鍒犻櫎鐨勮澶�</returns> - public async Task<List<CommonDevice>> DeleteDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDeleteDevice, int BindCluster = 6) + public List<CommonDevice> DeleteDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDeleteDevice, int BindCluster = 6) { //缁勮鏁版嵁 var deleteData = new IASZone.DelDeviceBindData(); @@ -256,7 +346,7 @@ } var listSuccess = new List<CommonDevice>(); - var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData); + var result = this.DelDeviceBindAsync(deleteData); if (result == null || result.delDeviceBindResponseData == null) { //鍒犻櫎缁戝畾鐩爣澶辫触 @@ -320,25 +410,289 @@ return listSuccess; } + /// <summary> + /// 鍒犻櫎璁惧鐨勭粦瀹氱洰鏍� + /// </summary> + /// <param name="delDeviceBindData"></param> + /// <returns></returns> + public BindObj.DelDeviceBindResponseAllData DelDeviceBindAsync(BindObj.DelDeviceBindData delDeviceBindData) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); + } + var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint); + //鑾峰彇闇�瑕佸彂閫佺殑鏁版嵁 + var sendData = this.GetDeleteDeviceBindCommandText(delDeviceBindData); + //鍙戦�佸懡浠� + var result = this.SendDeleteBindJobjectDataToGateway(device, "Bind/RemoveBind", + sendData, new List<string>() { "Bind/RemoveBind_Respon", "Bind/RemoveBindResult" }, 6); + + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + var responseData = new BindObj.DelDeviceBindResponseAllData(); + if (result.listReceiptData[0] != null) + { + var tempData1 = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.DelDeviceBindResponseData>(result.listReceiptData[0]); + responseData.delDeviceBindResponseData = tempData1; + } + + if (result.listReceiptData[1] != null) + { + var tempData2 = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.RemoveBindResultResponseData>(result.listReceiptData[1]); + responseData.removeBindResultResponseData = tempData2; + } + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); + + return responseData; + } + + /// <summary> + ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭� + /// </summary> + public BindObj.ClearBindInfoResponseAllData ClearBindInfoAsync(CommonDevice device) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device); + } + + var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } }; + var sendData = jObject.ToString(); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/ClearBindInfo", sendData, "Bind/ClearBindInfo_Respon", 25); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.ClearBindInfoResponseData>(result.ReceiptData); + return new BindObj.ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData }; + } + + + /// <summary> + /// 鑾峰彇鍒犻櫎璁惧缁戝畾鍒楄〃鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="delDeviceBindData"></param> + /// <returns></returns> + public string GetDeleteDeviceBindCommandText(BindObj.DelDeviceBindData delDeviceBindData) + { + var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } }; + var removeBindList = new JArray { }; + foreach (var removeBindInfo in delDeviceBindData.RemoveBindList) + { + //鍒犻櫎璁惧 + if (removeBindInfo.BindType == 0) + { + var dInfo = new JObject{{ "BindMacAddr",removeBindInfo.BindMacAddr},{ "BindEpoint", removeBindInfo.BindEpoint} , + { "BindCluster", removeBindInfo.BindCluster} ,{ "BindType",removeBindInfo.BindType}}; + removeBindList.Add(dInfo); + } + //鍒犻櫎鍦烘櫙 + else if (removeBindInfo.BindType == 1) + { + var dInfo = new JObject{{ "BindCluster", removeBindInfo.BindCluster} ,{ "BindType",removeBindInfo.BindType}, + { "BindScenesId", removeBindInfo.BindScenesId}}; + removeBindList.Add(dInfo); + } + } + var data = new JObject { { "RemoveBindList", removeBindList } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + /// <summary> + /// 鍙戦�佸垹闄ょ粦瀹氱殑鏁版嵁鍒扮綉鍏筹紝骞舵帴鍙楃綉鍏宠繑鍥炵殑鏁版嵁,listReceiptData涓鸿繑鍥炲��(鍒犻櫎缁戝畾鐨勬帴鍙e緢鐗规畩,闇�瑕佺嫭绔嬪嚭鏉�) + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="sendTopic">鍙戦�佺殑涓婚</param> + /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁 JObject.ToString()鐨勪笢瑗�</param> + /// <param name="listReceiptTopic">鎸囧畾鎺ユ敹鍝簺涓婚</param> + /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param> + /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns> + private ReceiptGatewayResult SendDeleteBindJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, List<string> listReceiptTopic, int waitTime = 3) + { + var reResult = new ReceiptGatewayResult(); + reResult.listReceiptData = new string[listReceiptTopic.Count]; + var myGateway = device.Gateway; + if (myGateway == null) + { + //鑾峰彇缃戝叧瀵硅薄澶辫触 + reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail); + reResult.ErrorMsgDiv = -1; + return reResult; + } + //缃戝叧ID + string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway); + //閿欒涓婚 + string errorTopic = gatewayID + "/" + "Error_Respon"; + //妫�娴嬪璞$殑涓婚 + for (int i = 0; i < listReceiptTopic.Count; i++) + { + listReceiptTopic[i] = gatewayID + "/" + listReceiptTopic[i]; + } + + bool canbreak = false; + Action<string, string> receiptAction = (topic, message) => + { + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + //缃戝叧鍥炲閿欒 + if (topic == errorTopic) + { + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); + reResult.ErrorMsg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error); + } + //濡傛灉鏄寚瀹氱殑涓婚 + for (int i = 0; i < listReceiptTopic.Count; i++) + { + if (topic == listReceiptTopic[i]) + { + string deviceMac = jobject["DeviceAddr"].ToString(); + int deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString()); + if (device.DeviceAddr != deviceMac) + { + //涓嶆槸鍚屼竴涓笢瑗縈ac + return; + } + if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200) + { + //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣 + return; + } + reResult.listReceiptData[i] = jobject["Data"].ToString(); + if (i == 0) + { + //鍙湁鏄疊ind/RemoveBind_Respon涓婚,鎵嶈兘涓柇 + canbreak = true; + } + } + } + + }; + myGateway.Actions += receiptAction; + //鍙戦�佹暟鎹� + myGateway.Send(sendTopic, sendData); + + //瓒呮椂鏃堕棿 + int TimeOut = 0; + waitTime = 20 * waitTime; + while (canbreak == false && TimeOut < waitTime) + { + //鍏ㄩ儴鎺ユ敹鎵嶉��鍑� + System.Threading.Thread.Sleep(50); + TimeOut++; + } + myGateway.Actions -= receiptAction; + receiptAction = null; + if (canbreak == false) + { + //瓒呮椂 + reResult.ErrorMsgDiv = 0; + } + else + { + //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁 + if (reResult.listReceiptData.Length == 1) + { + //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲� + reResult.ReceiptData = reResult.listReceiptData[0]; + reResult.listReceiptData = null; + } + } + + return reResult; + } + + + #endregion + + #region 鈻� 閰嶇疆闈㈡澘鍔熻兘_______________________ + + ///<summary > + ///閰嶇疆闈㈡澘鍔熻兘 + ///<para>value:缁欓潰鏉块厤缃殑妯″紡</para> + /// </summary> + public CommonDevice.SetWritableValueResponAllData ConfigureHdlKeyValueAsync(CommonDevice device, Panel.KeyMode value, int clusterID = 6) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue"); + } + //鑾峰彇鍙戦�佹暟鎹� + var sendData = this.GetConfigureHdlKeyCommandText(device.DeviceAddr, device.DeviceEpoint, value, clusterID); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData }; + } + + /// <summary> + /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭� + /// </summary> + public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureInfoAsync(CommonDevice device) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device); + } + + var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.HdlKey },{ "Command", 108 }}; + var attriBute = new JArray { new JObject { { "AttriButeId", (int)AttriButeId.HdlKey } } }; + var data = new JObject { { "AttriBute", attriBute } }; + JObject.Add("Data", data); + + //鍙戦�佹暟鎹� + var sendData = JObject.ToString(); + string receiptTopic = "DeviceStatusReport/" + device.DeviceAddr + "/" + device.DeviceEpoint + "/" + (int)Cluster_ID.HdlKey + "/" + (int)AttriButeId.HdlKey; + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetDeviceStatus", sendData, receiptTopic); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(result.ReceiptData); + return new Panel.PanelConfigureInfoResponAllData { deviceStatusReportData = tempData }; + } + + /// <summary> + /// 鑾峰彇閰嶇疆闈㈡澘鍔熻兘鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="value">閿��</param> + /// <param name="clusterID">闀濱D</param> + /// <returns></returns> + public string GetConfigureHdlKeyCommandText(string DeviceAddr, int DeviceEpoint, Panel.KeyMode value, int clusterID = 6) + { + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } }; + var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } }; + jObject.Add("Data", data); + return jObject.ToString(); + } #endregion #region 鈻� 涓�鑸柟娉昣__________________________ - - /// <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; - } /// <summary> /// 鏄剧ず閿欒淇℃伅绐楀彛 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs new file mode 100755 index 0000000..f3aa1f4 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs @@ -0,0 +1,259 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 璁惧鐨勫叡閫氶�昏緫 + /// </summary> + public class HdlDeviceCommonLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧鐨勫叡閫氶�昏緫 + /// </summary> + private static HdlDeviceCommonLogic m_Current = null; + /// <summary> + /// 璁惧鐨勫叡閫氶�昏緫 + /// </summary> + public static HdlDeviceCommonLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlDeviceCommonLogic(); + } + return m_Current; + } + set + { + m_Current = value; + } + } + + #endregion + + #region 鈻� 鍙戦�佹暟鎹甠__________________________ + + /// <summary> + /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶,ReceiptData涓鸿繑鍥炲��) + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="sendTopic">鍙戦�佺殑涓婚</param> + /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁 JObject.ToString()鐨勪笢瑗�</param> + /// <param name="receiptTopic">鎸囧畾鎺ユ敹鍝釜涓婚</param> + /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param> + /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns> + public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, string receiptTopic, int waitTime = 5) + { + //鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹� + return this.SendJobjectDataToGateway(device, sendTopic, sendData, new List<string>() { receiptTopic }, waitTime); + } + + /// <summary> + /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶),listReceiptData涓鸿繑鍥炲��(鍏ㄩ儴涓婚鍏ㄩ儴鎺ユ敹寰楀埌,鎵嶄細杩斿洖,涓嶇劧浼氳繑鍥炶秴鏃�) + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="sendTopic">鍙戦�佺殑涓婚</param> + /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁 JObject.ToString()鐨勪笢瑗�</param> + /// <param name="listReceiptTopic">鎸囧畾鎺ユ敹鍝簺涓婚</param> + /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param> + /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns> + public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, List<string> listReceiptTopic, int waitTime = 5) + { + var reResult = new ReceiptGatewayResult(); + reResult.listReceiptData = new string[listReceiptTopic.Count]; + var myGateway = device.Gateway; + if (myGateway == null) + { + //鑾峰彇缃戝叧瀵硅薄澶辫触 + reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail); + reResult.ErrorMsgDiv = -1; + return reResult; + } + //缃戝叧ID + string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway); + //閿欒涓婚 + string errorTopic = gatewayID + "/" + "Error_Respon"; + //妫�娴嬪璞$殑涓婚 + for (int i = 0; i < listReceiptTopic.Count; i++) + { + listReceiptTopic[i] = gatewayID + "/" + listReceiptTopic[i]; + } + + //鎺ユ敹鏁� + int receiptCount = 0; + Action<string, string> receiptAction = (topic, message) => + { + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + //缃戝叧鍥炲閿欒 + if (topic == errorTopic) + { + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); + reResult.ErrorMsg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error); + } + //濡傛灉鏄寚瀹氱殑涓婚 + for (int i = 0; i < listReceiptTopic.Count; i++) + { + if (topic == listReceiptTopic[i]) + { + string deviceMac = jobject["DeviceAddr"].ToString(); + int deviceEpoint = 200; + if (jobject.Property("Epoint") != null) + { + //鎷ユ湁姝ら敭鍊� + deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString()); + } + if (device.DeviceAddr != deviceMac) + { + //涓嶆槸鍚屼竴涓笢瑗縈ac + return; + } + if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200) + { + //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣 + return; + } + reResult.listReceiptData[i] = jobject["Data"].ToString(); + receiptCount++; + } + } + + }; + myGateway.Actions += receiptAction; + //鍙戦�佹暟鎹� + myGateway.Send(sendTopic, sendData); + + //瓒呮椂鏃堕棿 + int TimeOut = 0; + waitTime = 20 * waitTime; + while (receiptCount != listReceiptTopic.Count && TimeOut < waitTime) + { + //鍏ㄩ儴鎺ユ敹鎵嶉��鍑� + System.Threading.Thread.Sleep(50); + TimeOut++; + } + myGateway.Actions -= receiptAction; + receiptAction = null; + if (receiptCount != listReceiptTopic.Count) + { + reResult.ErrorMsgDiv = 0; + } + else + { + //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁 + if (reResult.listReceiptData.Length == 1) + { + //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲� + reResult.ReceiptData = reResult.listReceiptData[0]; + reResult.listReceiptData = null; + } + } + + return reResult; + } + + /// <summary> + /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(閫忎紶涓撶敤) + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁 JObject.ToString()鐨勪笢瑗�</param> + /// <param name="receiptCommand">鎸囧畾鎺ユ敹鍛戒护绗�</param> + /// <param name="receiptDataLength">鎸囧畾鎺ユ敹鏁版嵁鐨勯暱搴�</param> + /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param> + /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns> + public ReceiptGatewayResult SendJobjectDataToGateway2(CommonDevice device, string sendData, string receiptCommand, int receiptDataLength, int waitTime = 5) + { + var reResult = new ReceiptGatewayResult(); + var myGateway = device.Gateway; + if (myGateway == null) + { + //鑾峰彇缃戝叧瀵硅薄澶辫触 + reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail); + reResult.ErrorMsgDiv = -1; + return reResult; + } + //缃戝叧ID + string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway); + //閿欒涓婚 + string errorTopic = gatewayID + "/" + "Error_Respon"; + //妫�娴嬪璞$殑涓婚 + string checkTopic = gatewayID + "/ZbDataPassthrough"; + + Action<string, string> receiptAction = (topic, message) => + { + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + //缃戝叧鍥炲閿欒 + if (topic == errorTopic) + { + var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); + reResult.ErrorMsg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error); + } + //濡傛灉鏄寚瀹氱殑涓婚 + if (topic == checkTopic) + { + string deviceMac = jobject["DeviceAddr"].ToString(); + int deviceEpoint = 200; + if (jobject.Property("Epoint") != null) + { + //鎷ユ湁姝ら敭鍊� + deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString()); + } + if (device.DeviceAddr != deviceMac) + { + //涓嶆槸鍚屼竴涓笢瑗縈ac + return; + } + if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200) + { + //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣 + return; + } + + var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClientDataPassthroughResponseData>(jobject["Data"].ToString()); + //闀垮害涓�鑷� + if (responseData.PassData.Length == receiptDataLength) + { + var command = responseData.PassData[4].ToString() + + responseData.PassData[5].ToString() + + responseData.PassData[2].ToString() + + responseData.PassData[3].ToString(); + //骞朵笖鏄繖涓懡浠� + if (command == receiptCommand) + { + reResult.ReceiptData = responseData.PassData; + } + } + } + }; + myGateway.Actions += receiptAction; + //鍙戦�佹暟鎹� + myGateway.Send("ClientDataPassthrough", sendData); + + //瓒呮椂鏃堕棿 + int TimeOut = 0; + waitTime = 20 * waitTime; + while (reResult.ReceiptData == null && TimeOut < waitTime) + { + System.Threading.Thread.Sleep(50); + TimeOut++; + } + myGateway.Actions -= receiptAction; + receiptAction = null; + if (reResult.ReceiptData == null) + { + //瓒呮椂 + reResult.ErrorMsgDiv = 0; + } + return reResult; + } + + #endregion + } +} diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs index 2f7a1b2..8a29182 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCurtainLogic.cs @@ -1,4 +1,7 @@ -锘縰sing System; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Shared.Phone.ModelData; +using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; @@ -37,22 +40,30 @@ #region 鈻� 鎵嬫媺鎺у埗___________________________ /// <summary> - /// 璁剧疆鎵嬫媺鎺у埗鐘舵�佸�� + /// 璁剧疆鎵嬫媺鎺у埗鐘舵�佸�� 鈽嗏槅鈽嗏槅鈽� /// </summary> - /// <param name="rollershade">绐楀笜瀵硅薄</param> + /// <param name="device">绐楀笜瀵硅薄</param> /// <param name="bolStatu">鎵嬫媺鎺у埗鐘舵�佸��</param> /// <returns></returns> - public async Task<bool> SetHandPullControl(Rollershade rollershade, bool bolStatu) + public bool SetHandPullControl(CommonDevice device, bool bolStatu) { - var result = await rollershade.SetCurtianMaintenanceAsync(bolStatu); - //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜 - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowTipMsg(error); + //娣诲姞缂撳瓨 + DeviceModelDataLogic.Current.SetCurtainHandPullControl(device, bolStatu, "SetWritableValue"); + return true; + } + //鑾峰彇鍙戦�佺殑鍛戒护瀛楃 + var sendData = this.GetHandPullControlText(device.DeviceAddr, device.DeviceEpoint, bolStatu); + //鍙戦�佺粰缃戝叧 + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return false; } - if (result == null || result.setWritableValueResponData == null) + if (result.ErrorMsgDiv == 0) { //鍒囨崲鎵嬫媺鎺у埗澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uChangeHandPullControlFail); @@ -61,16 +72,33 @@ this.ShowTipMsg(msg); return false; } - if (result.setWritableValueResponData.Status != 0) + + var data = JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + if (data.Status != 0) { //鍒囨崲鎵嬫媺鎺у埗澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uChangeHandPullControlFail); this.ShowTipMsg(msg); return false; } - //澶囦唤灞炴�� - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(rollershade, GatewayBackupEnum.A绐楀笜鎵嬫媺鎺у埗, bolStatu); return true; + } + + /// <summary> + /// 鑾峰彇鏇存敼鎵嬫媺鎺у埗鐘舵�佺殑瀛楃涓插懡浠� 鈽嗏槅鈽嗏槅鈽� + /// </summary> + /// <param name="DeviceAddr">DeviceAddr</param> + /// <param name="DeviceEpoint">DeviceEpoint</param> + /// <param name="bolStatu">鎵嬫媺鎺у埗鐘舵�佸��</param> + /// <returns></returns> + public string GetHandPullControlText(string DeviceAddr, int DeviceEpoint, bool bolStatu) + { + int bit2 = bolStatu == true ? 1 : 0; + int attributeData = bit2 * 4; + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } }; + var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } }; + jObject.Add("Data", data); + return jObject.ToString(); } #endregion @@ -83,9 +111,9 @@ /// <param name="rollershade">绐楀笜瀵硅薄</param> /// <param name="bolStatu">false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜</param> /// <returns></returns> - public async Task<bool> SetCurtainDirection(Rollershade rollershade, bool bolStatu) + public bool SetCurtainDirection(CommonDevice rollershade, bool bolStatu) { - var result = await rollershade.SetCurtainDirectionAsync(bolStatu); + var result = this.SetCurtainDirectionAsync(rollershade, bolStatu); //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜 string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); if (error != null) @@ -109,22 +137,121 @@ this.ShowTipMsg(msg); return false; } - //澶囦唤璁惧 - await this.BackupCurtainDirection(rollershade, bolStatu); return true; } /// <summary> - /// 澶囦唤绐楀笜鏂瑰悜 + /// 璁剧疆寮�鍚堝笜鐢垫満鏂瑰悜 + /// <para>isDirectionReversed (false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜锛�)</para> . /// </summary> - /// <param name="rollershade">绐楀笜瀵硅薄</param> - /// <param name="bolStatu">false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜</param> - /// <returns></returns> - public async Task<bool> BackupCurtainDirection(Rollershade rollershade, bool bolStatu) + private CommonDevice.SetWritableValueResponAllData SetCurtainDirectionAsync(CommonDevice device, bool isDirectionReversed) { - //澶囦唤璁惧 - return await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(rollershade, GatewayBackupEnum.A绐楀笜鏂瑰悜, bolStatu); + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.SetCurtainDirection(device, isDirectionReversed, "SetWritableValue"); + } + //鑾峰彇缂栬緫绐楀笜鏂瑰悜鐨勫懡浠ゅ瓧绗� + var sendData = this.GetCurtainDirectionCommadText(device.DeviceAddr, device.DeviceEpoint, isDirectionReversed); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + + var tempData = JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData }; + } + + /// <summary> + /// 鑾峰彇缂栬緫绐楀笜鏂瑰悜鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="DeviceEpoint"></param> + /// <param name="isDirectionReversed"></param> + /// <returns></returns> + public string GetCurtainDirectionCommadText(string DeviceAddr,int DeviceEpoint, bool isDirectionReversed) + { + int bit0 = isDirectionReversed == true ? 1 : 0; + int attributeData = bit0 * 1; + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } }; + var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + #endregion + + #region 鈻� 寮�鍚堝笜闄愪綅閰嶇疆_____________________ + + /// <summary> + /// 璁剧疆寮�鍚堝笜闄愪綅 + /// </summary> + /// <param name="rollershade"></param> + /// <param name="upLimit">寮�闄愪綅</param> + /// <param name="downLimit">鍚堥檺浣�</param> + /// <param name="curtainLength">瀵艰建闀垮害(杩欎釜鏄粰铏氭嫙璁惧鐢ㄧ殑)</param> + /// <returns></returns> + public bool SetAutoOpenCurtainLimitPoint(CommonDevice rollershade, int upLimit, int downLimit, int curtainLength) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.SetCurtainLimitPoint(rollershade, upLimit, downLimit, curtainLength, "SetWritableValue"); + } + //鑾峰彇缂栬緫寮�鍚堝笜闄愪綅鐨勫懡浠ゅ瓧绗� + var sendData = this.GetAutoOpenCurtainLimitPointCommandText(rollershade.DeviceAddr, rollershade.DeviceEpoint, upLimit, downLimit); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(rollershade, "SetWritableValue", sendData, "SetWritableValue_Respon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + //璁剧疆绐楀笜闄愪綅鐐瑰け璐� + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainLimitFail); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + this.ShowTipMsg(msg); + return false; + } + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); + if (tempData.Status != 0) + { + //璁剧疆绐楀笜闄愪綅鐐瑰け璐� + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainLimitFail); + this.ShowTipMsg(msg); + return false; + } + + return true; + } + + + /// <summary> + /// 鑾峰彇缂栬緫寮�鍚堝笜闄愪綅鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="DeviceEpoint"></param> + /// <param name="upLimit"></param> + /// <param name="downLimit"></param> + /// <returns></returns> + public string GetAutoOpenCurtainLimitPointCommandText(string DeviceAddr, int DeviceEpoint, int upLimit, int downLimit) + { + //杩欎釜鏄紑鍚堝笜 "2,0x00ff,0x00ff"鏍煎紡 鍚堥檺浣嶅湪鍓嶏紝寮�闄愪綅鍦ㄥ悗 + string convertData = "\"2,0x" + Convert.ToString(downLimit, 16).PadLeft(4, '0'); + convertData += ",0x" + Convert.ToString(upLimit, 16).PadLeft(4, '0') + "\""; + //鐒跺悗灏嗗畠浠浆涓篈SK鐮佹暟鍊�,鐒跺悗鍐嶈浆涓�16杩涘埗 + //鎬昏闀垮害涓�17(杩欓噷鏄�16杩涘埗) + string sendData = "11"; + foreach (char c in convertData) + { + sendData += Convert.ToString((int)c, 16).PadLeft(2, '0'); + } + + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } }; + var data = new JObject { { "Undivided", 0 }, { "AttributeId", 24 }, { "AttributeDataType", 65 }, { "AttributeData", sendData } }; + jObject.Add("Data", data); + + return jObject.ToString(); } #endregion @@ -159,7 +286,7 @@ { sendData += Convert.ToString((int)c, 16).PadLeft(2, '0'); } - result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(rollershade, 258, 24, 65, sendData); + //result = await HdlDeviceAttributeLogic.Current.WriteDeviceAttribute(rollershade, 258, 24, 65, sendData); } //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜 string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); @@ -183,12 +310,6 @@ string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainLimitFail); this.ShowTipMsg(msg); return false; - } - - if (upLimit != -1 && downLimit != -1) - { - //澶囦唤璁惧 - await this.BackupCurtainLimitPoint(rollershade, upLimit, downLimit); } return true; @@ -227,25 +348,6 @@ return false; } return true; - } - - /// <summary> - /// 澶囦唤绐楀笜闄愪綅鐐� - /// </summary> - /// <param name="rollershade">绐楀笜瀵硅薄</param> - /// <param name="upLimit">涓婇檺浣嶇殑鍊�,鐧惧垎姣�(澶囦唤鐢�)</param> - /// <param name="downLimit">涓嬮檺浣嶇殑鍊�,鐧惧垎姣�(澶囦唤鐢�)</param> - /// <returns></returns> - public async Task<bool> BackupCurtainLimitPoint(Rollershade rollershade, int upLimit, int downLimit) - { - //澶囦唤璁惧 - var backData = new Newtonsoft.Json.Linq.JObject - { - { "upLimit",upLimit }, - { "downLimit", downLimit } - }; - //澶囦唤璁惧 - return await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(rollershade, GatewayBackupEnum.A绐楀笜涓婁笅闄愪綅, backData); } #endregion diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs index 7975fd9..e662761 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs @@ -3,6 +3,7 @@ using System.Text; using ZigBee.Device; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Shared.Phone.UserCenter { @@ -59,10 +60,10 @@ /// </summary> /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> /// <returns></returns> - public async Task<Panel.KeyColorData> GetPanelEpointColorInfo(Panel panel) + public Panel.KeyColorData GetPanelEpointColorInfo(CommonDevice panel) { Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint; - var result = await panel.GetPanelColorInfoAsync(keyNum); + var result = this.GetPanelColorInfoAsync(panel, keyNum); //鍏遍�氶敊璇娴� string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); if (error != null) @@ -86,11 +87,11 @@ /// </summary> /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> /// <returns></returns> - public async Task<Panel.KeyColorData> GetPanelColorInfo(Panel panel) + public Panel.KeyColorData GetPanelColorInfo(CommonDevice panel) { panel.DeviceEpoint = 1; Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint; - var result = await panel.GetPanelColorInfoAsync(keyNum); + var result = this.GetPanelColorInfoAsync(panel, keyNum); //鍏遍�氶敊璇娴� string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); if (error != null) @@ -109,19 +110,57 @@ return result.keyColorData; } + ///<summary > + ///鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�. + /// </summary> + public Panel.KeyColorDataResponseAllData GetPanelColorInfoAsync(CommonDevice device, Panel.KeyNum keyNum) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.GetPanelColorInfo(device, keyNum); + } + //鍙戦�佹暟鎹� keyNum杞负16杩涘埗 鑼冨洿锛�01~10 + var passData = "0504040101" + Convert.ToString((int)keyNum, 16).ToUpper().PadLeft(2, '0'); + var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var dataObject = new JObject { { "PassData", passData } }; + jObject.Add("Data", dataObject); + + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, jObject.ToString(), "0405", 24, 9); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + string data = result.ReceiptData; + + var tempR = new Panel.KeyColorData(); + tempR.OpenColorR = data[12].ToString() + data[13].ToString(); + tempR.OpenColorG = data[14].ToString() + data[15].ToString(); + tempR.OpenColorB = data[16].ToString() + data[17].ToString(); + tempR.CloseColorR = data[18].ToString() + data[19].ToString(); + tempR.CloseColorG = data[20].ToString() + data[21].ToString(); + tempR.CloseColorB = data[22].ToString() + data[23].ToString(); + + var key = data[10].ToString() + data[11].ToString(); + int keyEnum1 = Convert.ToInt32(key, 16); + tempR.keyNum = (Panel.KeyNum)keyEnum1; + + return new Panel.KeyColorDataResponseAllData { keyColorData = tempR }; + } + /// <summary> /// 璁剧疆鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅 /// </summary> /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param> /// <param name="colorData">寮�鍜屽叧鐨勯鑹查兘闇�瑕佷竴璧疯缃�</param> /// <returns></returns> - public async Task<bool> SetPanelEpointColorInfo(Panel panel, Panel.KeyColorData colorData) + public bool SetPanelEpointColorInfo(CommonDevice 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); + var result = this.SetPanelColorInfoAsync(panel, colorData, keyNum); if (result == null || result.responseData == null) { //璁剧疆鎸夐敭闈㈡澘鎸囩ず鐏鑹插け璐� @@ -136,8 +175,6 @@ this.ShowErrorMsg(msg); return false; } - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐归鑹茶皟鑺�, colorData); return true; } @@ -147,12 +184,12 @@ /// <param name="panel">鎸夐敭闈㈡澘鐨�</param> /// <param name="colorData">鍙缃紑鐨勯鑹�</param> /// <returns></returns> - public async Task<bool> SetPanelColorInfo(Panel panel, Panel.KeyColorData colorData) + public bool SetPanelColorInfo(CommonDevice panel, Panel.KeyColorData colorData) { var keyNum = new Panel.KeyNumStatus(); //榛樿绗竴涓敤闈㈡澘绗竴涓寜閿鑹蹭綔涓烘暣涓潰鏉跨殑棰滆壊 keyNum.Key1 = true; - var result = await panel.SetPanelColorInfoAsync(colorData, keyNum); + var result = this.SetPanelColorInfoAsync(panel, colorData, keyNum); if (result == null || result.responseData == null) { //璁剧疆鎸夐敭闈㈡澘鎸囩ず鐏鑹插け璐� @@ -167,45 +204,210 @@ this.ShowErrorMsg(msg); return false; } - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐归鑹茶皟鑺�, colorData); return true; + } + + ///<summary > + ///閰嶇疆鎸夐敭鎸囩ず鐏鑹� + /// </summary> + public CommonDevice.ResponseAllData SetPanelColorInfoAsync(CommonDevice device, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.SetPanelColorInfo(device, keyColorData, keyNumStatus, "ZbDataPassthrough"); + } + //鑾峰彇閰嶇疆鎸夐敭鎸囩ず鐏鑹茬殑鍛戒护瀛楃 + var sendData = this.GetPanelColorCommandText(device.DeviceAddr, keyColorData, keyNumStatus); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + var data = result.ReceiptData; + var tempD = new CommonDevice.ResponseData(); + tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); + return new CommonDevice.ResponseAllData { responseData = tempD }; + } + + /// <summary> + /// 鑾峰彇閰嶇疆鎸夐敭鎸囩ず鐏鑹茬殑鍛戒护瀛楃 + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="keyColorData"></param> + /// <param name="keyNumStatus"></param> + /// <returns></returns> + public string GetPanelColorCommandText(string DeviceAddr, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus) + { + var passData = this.GetPanelColorPassData(keyColorData, keyNumStatus); + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + /// <summary> + /// 閰嶇疆鎸夐敭鎸囩ず鐏鑹叉暟鎹� + /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para> + /// </summary> + /// <returns>The passthorugh data.</returns> + /// <param name="keyColorData">Key color data.</param> + /// <param name="keyNum">Key number.</param> + private string GetPanelColorPassData(Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus) + { + string data = ""; + string dataLength = "0c"; + string dataComand1 = "01"; + string dataComand2 = "04"; + string dataSerialNum = "01"; + string addDataLength = "08"; + int attributeData = 0; + + try + { + for (int i = 1; i <= 16; i++) + { + Type type = keyNumStatus.GetType(); + var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null); + int value0 = 0; + if (Convert.ToBoolean(obj) == true) + { + value0 = 1; + } + int v = (int)Math.Pow(2, i - 1); + attributeData += value0 * v; + } + + string td = attributeData.ToString("X4"); + char[] td1 = td.ToCharArray(); + string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); + string temp = ""; + var tempColor1 = keyColorData.OpenColorR.ToString(); + var sbString1 = new System.Text.StringBuilder(); + switch (tempColor1.Length) + { + case 1: + temp = "0" + tempColor1; + break; + case 2: + temp = tempColor1; + break; + } + sbString1.Append(temp.ToUpper()); + + var tempColor2 = keyColorData.OpenColorG.ToString(); + var sbString2 = new System.Text.StringBuilder(); + switch (tempColor2.Length) + { + case 1: + temp = "0" + tempColor2; + break; + case 2: + temp = tempColor2; + break; + } + sbString2.Append(temp.ToUpper()); + + var tempColor3 = keyColorData.OpenColorB.ToString(); + var sbString3 = new System.Text.StringBuilder(); + switch (tempColor3.Length) + { + case 1: + temp = "0" + tempColor3; + break; + case 2: + temp = tempColor3; + break; + } + sbString3.Append(temp.ToUpper()); + + var tempColor4 = keyColorData.CloseColorR.ToString(); + var sbString4 = new System.Text.StringBuilder(); + switch (tempColor3.Length) + { + case 1: + temp = "0" + tempColor4; + break; + case 2: + temp = tempColor4; + break; + } + sbString4.Append(temp.ToUpper()); + + var tempColor5 = keyColorData.CloseColorG.ToString(); + var sbString5 = new System.Text.StringBuilder(); + switch (tempColor5.Length) + { + case 1: + temp = "0" + tempColor5; + break; + case 2: + temp = tempColor5; + break; + } + sbString5.Append(temp.ToUpper()); + + var tempColor6 = keyColorData.CloseColorB.ToString(); + var sbString6 = new System.Text.StringBuilder(); + switch (tempColor6.Length) + { + case 1: + temp = "0" + tempColor6; + break; + case 2: + temp = tempColor6; + break; + } + sbString6.Append(temp.ToUpper()); + + if (keyColorData != null) + { + data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + tempAttributeData + sbString1 + sbString2 + sbString3 + + sbString4 + sbString5 + sbString6; + } + } + catch { }; + + return data; } #endregion #region 鈻� 浜害璋冭妭___________________________ - /// <summary> - /// 鑾峰彇璁惧浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛� + + ///<summary > + ///鑾峰彇璁惧浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛� /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <returns></returns> - public async Task<Panel.PanelSwitchLevelInfo> GetDeviceLightSettion(CommonDevice device) + public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(CommonDevice device) { - //鍊熺敤瀹冪殑鍑芥暟 - var panel = new Panel(); - panel.DeviceAddr = device.DeviceAddr; - panel.DeviceEpoint = device.DeviceEpoint; - panel.CurrentGateWayId = device.CurrentGateWayId; - - var result = await panel.GetPanelSwitchLevelAsync(); - panel = null; - //鍏遍�氶敊璇娴� - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowErrorMsg(error); - return null; + return ModelData.DeviceModelDataLogic.Current.GetDeviceLightSettion(device); } + //鑾峰彇鍙戦�佺殑鍛戒护瀛楃 + var passData = "050604010101"; + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } }; + jObject.Add("Data", data); + var sendData = jObject.ToString(); - if (result == null || string.IsNullOrEmpty(result.errorMessageBase) == false) + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0407", 14, 9); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) { //鑾峰彇鎸夐敭闈㈡澘浜害璋冭妭淇℃伅澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelLightRegulationInfoFail); this.ShowErrorMsg(msg); return null; } - return result; + var receiptData = result.ReceiptData; + var level1 = Convert.ToInt32(receiptData[10].ToString() + receiptData[11].ToString(), 16); + var level2 = Convert.ToInt32(receiptData[12].ToString() + receiptData[13].ToString(), 16); + + return new Panel.PanelSwitchLevelInfo { panelDirectionsLevel = level1, panelBacklightLevel = level2 }; } /// <summary> @@ -215,25 +417,22 @@ /// <param name="directionsLevel">0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</param> /// <param name="backlightLevel">0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</param> /// <returns></returns> - public async Task<bool> SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel) + public bool SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel) { - //鍊熺敤瀹冪殑鍑芥暟 - var panel = new Panel(); - panel.DeviceAddr = device.DeviceAddr; - panel.DeviceEpoint = device.DeviceEpoint; - panel.CurrentGateWayId = device.CurrentGateWayId; - - var result = await panel.SetKeyLevelAsync(directionsLevel, backlightLevel); - panel = null; - //鍏遍�氶敊璇娴� - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowTipMsg(error); + return ModelData.DeviceModelDataLogic.Current.SetDeviceLightSettion(device, directionsLevel, backlightLevel, "ZbDataPassthrough"); + } + //鑾峰彇淇敼闈㈡澘鐨勪寒搴﹁皟鑺傜殑鍛戒护瀛楃 + var sendData = this.GetPanelLevelCommadText(device.DeviceAddr, directionsLevel, backlightLevel); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return false; } - - if (result == null || result.responseData == null) + if (result.ErrorMsgDiv == 0) { //璁剧疆浜害璋冭妭澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail); @@ -244,24 +443,88 @@ return false; } - if (result.responseData.status != 0) + //杩欓噷杩樻湁涓�涓� 0402 + //tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + + var status = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString(), 16); + if (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(device, GatewayBackupEnum.A骞叉帴鐐逛寒搴﹁皟鑺�, backData); + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.SetDeviceLightSettion(device, directionsLevel, backlightLevel, "ZbDataPassthrough"); + return true; } + /// <summary> + /// 鑾峰彇淇敼闈㈡澘鐨勪寒搴﹁皟鑺傜殑鍛戒护瀛楃 + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="directionsLevel">0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</param> + /// <param name="backlightLevel">0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</param> + /// <returns></returns> + public string GetPanelLevelCommadText(string DeviceAddr, int directionsLevel, int backlightLevel) + { + var passData = this.GetSetPanelLevelPassData(directionsLevel, backlightLevel); + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + /// <summary> + /// 鑾峰彇閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴︾殑鍛戒护瀛楃 + /// </summary> + private string GetSetPanelLevelPassData(int level1, int level2) + { + string data = ""; + string dataLength = "06"; + string dataComand1 = "02"; + string dataComand2 = "04"; + string dataSerialNum = "01"; + string addDataLength = "02"; + string l1 = ""; + string l2 = ""; + try + { + var sbString1 = new System.Text.StringBuilder(); + var sbString2 = new System.Text.StringBuilder(); + string temp1 = Convert.ToString(level1, 16); + string temp2 = Convert.ToString(level2, 16); + + switch (temp1.Length) + { + case 1: + l1 = "0" + temp1; + break; + case 2: + l1 = temp1; + break; + } + switch (temp2.Length) + { + case 1: + l2 = "0" + temp2; + break; + case 2: + l2 = temp2; + break; + } + sbString1.Append(l1.ToString().ToUpper()); + sbString2.Append(l2.ToString().ToUpper()); + data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + sbString1 + sbString2; + } + catch { }; + + return data; + } #endregion #region 鈻� 鎺ヨ繎鎰熷簲___________________________ @@ -333,14 +596,6 @@ this.ShowTipMsg(msg); return false; } - - // 澶囦唤璁惧 - var backData = new Newtonsoft.Json.Linq.JObject - { - { "sensorEnable",sensorEnable } - }; - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘, backData); return true; } #endregion @@ -351,26 +606,25 @@ /// </summary> /// <param name="device">璁惧瀵硅薄</param> /// <returns></returns> - public async Task<Panel.PanelSaveEnergyModeInfo> GetDeviceEnergyConservationMode(CommonDevice device) + public Panel.PanelSaveEnergyModeInfo GetDeviceEnergyConservationMode(CommonDevice device) { - //鍊熺敤瀹冪殑鍑芥暟 - var panel = new Panel(); - panel.DeviceAddr = device.DeviceAddr; - panel.DeviceEpoint = device.DeviceEpoint; - panel.CurrentGateWayId = device.CurrentGateWayId; - - var result = await panel.GetPanelSaveEnergyModeAsync(); - panel = null; - - //鍏遍�氶敊璇娴� - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowErrorMsg(error); + return ModelData.DeviceModelDataLogic.Current.GetDeviceEnergyConservationMode(device); + } + //鍙戦�佸懡浠� + string passData = "050804010101"; + var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, jObject.ToString(), "0409", 18, 9); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return null; } - - if (result == null || result.panelSaveEnergyModeInfo == null) + if (result.ErrorMsgDiv == 0) { //鑾峰彇鎸夐敭闈㈡澘鑺傝兘妯″紡淇℃伅澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelEnergyConservationInfoFail); @@ -380,7 +634,20 @@ this.ShowErrorMsg(msg); return null; } - return result.panelSaveEnergyModeInfo; + + var energyInfo = new Panel.PanelSaveEnergyModeInfo(); + + if (result.ReceiptData[10].ToString() + result.ReceiptData[11].ToString() == "01") + { + energyInfo.enable = true; + } + else + { + energyInfo.enable = false; + } + energyInfo.time = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString() + result.ReceiptData[12].ToString() + result.ReceiptData[13].ToString(), 16); + energyInfo.level = Convert.ToInt32(result.ReceiptData[16].ToString() + result.ReceiptData[17].ToString(), 16); + return energyInfo; } /// <summary> @@ -391,25 +658,22 @@ /// <param name="modeTime">鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-255</param> /// <param name="level">鑺傝兘妯″紡浜害:0-100</param> /// <returns></returns> - public async Task<bool> SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level) + public bool SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level) { - //鍊熺敤瀹冪殑鍑芥暟 - var panel = new Panel(); - panel.DeviceAddr = device.DeviceAddr; - panel.DeviceEpoint = device.DeviceEpoint; - panel.CurrentGateWayId = device.CurrentGateWayId; - - var result = await panel.SetKeyModeAsync(modeEnable, modeTime, level); - panel = null; - //鍏遍�氶敊璇娴� - string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); - if (error != null) + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - this.ShowErrorMsg(error); + return ModelData.DeviceModelDataLogic.Current.SetDeviceEnergyConservationMode(device, modeEnable, modeTime, level, "ZbDataPassthrough"); + } + //鑾峰彇璁剧疆璁惧鐨勮妭鑳芥ā寮忕殑鍛戒护瀛楃 + var sendData = this.GetDeviceEnergyConservationModeCommandText(device.DeviceAddr, modeEnable, modeTime, level); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9); + if (result.ErrorMsg != null) + { + this.ShowTipMsg(result.ErrorMsg); return false; } - - if (result == null || result.responseData == null) + if (result.ErrorMsgDiv == 0) { //鑺傝兘妯″紡閰嶇疆澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail); @@ -419,25 +683,109 @@ this.ShowTipMsg(msg); return false; } - - if (result.responseData.status != 0) + var status = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString(), 16); + if (status != 0) { //鑺傝兘妯″紡閰嶇疆澶辫触 string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail); this.ShowTipMsg(msg); return false; } - //澶囦唤璁惧 - var backData = new Newtonsoft.Json.Linq.JObject - { - { "modeEnable",modeEnable }, - { "modeTime", modeTime }, - { "level", level } - }; - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A骞叉帴鐐硅妭鑳芥ā寮�, backData); + + //淇敼缂撳瓨 + ModelData.DeviceModelDataLogic.Current.SetDeviceEnergyConservationMode(device, modeEnable, modeTime, level, "ZbDataPassthrough"); + return true; } + + /// <summary> + /// 鑾峰彇璁剧疆璁惧鐨勮妭鑳芥ā寮忕殑鍛戒护瀛楃 + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="modeEnable"></param> + /// <param name="modeTime"></param> + /// <param name="level"></param> + /// <returns></returns> + public string GetDeviceEnergyConservationModeCommandText(string DeviceAddr, bool modeEnable, int modeTime, int level) + { + var passData = this.GetPanelModeModePassData(modeEnable, modeTime, level); + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + /// <summary> + /// 鑾峰彇璁剧疆璁惧鐨勮妭鑳芥ā寮忕殑鍛戒护瀛楃 + /// </summary> + private string GetPanelModeModePassData(bool modeEnable, int modeTime, int modelevel) + { + string data = ""; + string dataLength = "08"; + string dataComand1 = "03"; + string dataComand2 = "04"; + string dataSerialNum = "01"; + string addDataLength = "04"; + string mode = ""; + string time = ""; + string level = ""; + try + { + if (modeEnable) + { + mode = "01"; + } + else + { + mode = "00"; + } + + if (modeTime == -1) + { + //褰撹妭鑳芥ā寮忔病鏈夌粰鏃堕棿锛岄粯璁ょ粰60绉� + modeTime = 60; + } + + var tempBytes = new byte[2]; + for (int i = 0; i < 2; i++) + { + tempBytes[i] = (byte)(modeTime >> (i * 8) & 0xff); + } + var time1 = Convert.ToString(tempBytes[0], 16); + var time2 = Convert.ToString(tempBytes[1], 16); + if (time1.Length == 1) + { + time1 = "0" + time1; + } + if (time2.Length == 1) + { + time2 = "0" + time2; + } + + time = (time1 + time2).ToUpper(); + + var sbString2 = new System.Text.StringBuilder(); + string temp2 = Convert.ToString(modelevel, 16); + switch (temp2.Length) + { + case 1: + level = "0" + temp2; + break; + case 2: + level = temp2; + break; + } + + sbString2.Append(level.ToUpper()); + data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + mode + time + sbString2; + } + catch { }; + + return data; + } + #endregion @@ -456,7 +804,7 @@ panel.DeviceEpoint = device.DeviceEpoint; panel.CurrentGateWayId = device.CurrentGateWayId; - var result = await panel.ReadPanelConfigureInfoAsync(); + var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(panel); panel = null; //鍏遍�氶敊璇娴� @@ -624,9 +972,9 @@ /// <param name="panel">骞叉帴鐐瑰璞�</param> /// <param name="i_value">骞叉帴鐐圭殑绗笁绾у埆灞炴�х殑鍊�,鍏蜂綋璇峰弬鐓х涓夌骇鍒睘鎬�</param> /// <returns></returns> - public async Task<bool> EditorDryContactThirdFunction(Panel panel, int i_value) + public bool EditorDryContactThirdFunction(Panel panel, int i_value) { - var result = await panel.ConfigureHdlKeyValueAsync((Panel.KeyMode)i_value); + var result = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(panel, (Panel.KeyMode)i_value); //鍏遍�氶敊璇娴� string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); if (error != null) @@ -676,9 +1024,6 @@ this.ShowErrorMsg(msg); return false; } - //澶囦唤璁惧 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬�, i_value); - return true; } @@ -691,64 +1036,20 @@ /// </summary> /// <param name="device">鏌愪竴鍥炶矾</param> /// <returns></returns> - public VibrationInfo GetPanelVibrationData(CommonDevice device) + public PanelVibrationInfo GetPanelVibrationData(CommonDevice device) { - var returnData = new VibrationInfo(); - var gateway = device.Gateway; - if (gateway == null) + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - //閿欒:缃戝叧瀵硅薄涓㈠け - this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg)); - return null; + return ModelData.DeviceModelDataLogic.Current.GetPanelVibrationInfo(device); } - string checkTopic = HdlGatewayLogic.Current.GetGatewayId(gateway) + "/" + "ZbDataPassthrough"; - bool canBreak = false; - - Action<string, string> action = (topic, message) => - { - if (topic == checkTopic) - { - try - { - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - string PassData = jobject["Data"]["PassData"].ToString(); - if (PassData.Length != 18) - { - return; - } - string mytopic = PassData[4].ToString() + PassData[5].ToString() + PassData[2].ToString() + PassData[3].ToString(); - if (mytopic != "0802") - { - return; - } - returnData.A闇囧姩浣胯兘 = PassData.Substring(10, 2) == "01" ? true : false; - returnData.A闇囧姩寮哄害 = Convert.ToInt32(PassData.Substring(12, 2), 16); - returnData.A闇囧姩鏃堕棿 = Convert.ToInt32(PassData.Substring(14, 4), 16); - - canBreak = true; - } - catch { } - } - }; - gateway.Actions += action; - try - { - var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new Newtonsoft.Json.Linq.JObject { { "PassData", "050108110101" } }; - jObject.Add("Data", data); - gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - int TimeOut = 0; - while (canBreak == false && TimeOut < 60) - { - System.Threading.Thread.Sleep(100); - TimeOut++; - } - gateway.Actions -= action; - - if (TimeOut >= 60) + //鍙戦�佹暟鎹� + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "PassData", "050108110101" } }; + jObject.Add("Data", data); + var sendData = jObject.ToString(); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0802", 18, 6); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) { //鑾峰彇闇囧姩鍙嶉閰嶇疆淇℃伅澶辫触 string errorMsg = Language.StringByID(R.MyInternationalizationString.uGetVibrationFeedbackSettionFail); @@ -756,6 +1057,11 @@ this.ShowTipMsg(errorMsg); return null; } + var returnData = new PanelVibrationInfo(); + returnData.A闇囧姩浣胯兘 = result.ReceiptData.Substring(10, 2) == "01" ? true : false; + returnData.A闇囧姩寮哄害 = Convert.ToInt32(result.ReceiptData.Substring(12, 2), 16); + returnData.A闇囧姩鏃堕棿 = Convert.ToInt32(result.ReceiptData.Substring(14, 4), 16); + return returnData; } @@ -765,103 +1071,53 @@ /// <param name="device">鏌愪竴鍥炶矾</param> /// <param name="datainfo">璁剧疆鐨勪俊鎭�</param> /// <returns></returns> - public bool SetPanelVibrationData(CommonDevice device, VibrationInfo datainfo) + public bool SetPanelVibrationData(CommonDevice device, PanelVibrationInfo datainfo) { - var gateway = device.Gateway; - if (gateway == null) + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) { - //閿欒:缃戝叧瀵硅薄涓㈠け - this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg)); - return false; + return ModelData.DeviceModelDataLogic.Current.SetPanelVibrationInfo(device, datainfo, "ClientDataPassthrough"); } - string checkTopic = HdlGatewayLogic.Current.GetGatewayId(gateway) + "/" + "ZbDataPassthrough"; - bool canBreak = false; - - bool success = false; - Action<string, string> action = (topic, message) => - { - if (topic == checkTopic) - { - try - { - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - if (jobject["DeviceAddr"].ToString() != device.DeviceAddr) - { - //涓嶆槸鍚屼竴涓笢瑗� - return; - } - string PassData = jobject["Data"]["PassData"].ToString(); - if (PassData.Length != 16) - { - return; - } - string mytopic = PassData[4].ToString() + PassData[5].ToString() + PassData[2].ToString() + PassData[3].ToString(); - if (mytopic != "0002") - { - return; - } - int command = Convert.ToInt32(PassData[10].ToString() + PassData[11].ToString() + PassData[12].ToString() + PassData[13].ToString(), 16); - int status = Convert.ToInt32(PassData[14].ToString() + PassData[15].ToString(), 16); - if (status == 0) - { - //鎴愬姛 - success = true; - } - canBreak = true; - } - catch { } - } - }; - gateway.Actions += action; - try - { - string passData = "0800081104"; - passData += datainfo.A闇囧姩浣胯兘 ? "01" : "00"; - passData += Convert.ToString(datainfo.A闇囧姩寮哄害, 16).PadLeft(2, '0'); - string time = Convert.ToString(datainfo.A闇囧姩鏃堕棿, 16).PadLeft(4, '0'); - //浣庝綅鍦ㄥ墠锛岄珮浣嶅湪鍚� - passData += time.Substring(2, 2); - passData += time.Substring(0, 2); - - var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } }; - jObject.Add("Data", data); - gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - int TimeOut = 0; - while (canBreak == false && TimeOut < 60) - { - System.Threading.Thread.Sleep(100); - TimeOut++; - } - gateway.Actions -= action; - - if (success == false) + //鑾峰彇缂栬緫闈㈡澘闇囧姩鍔熻兘鐨勫懡浠ゅ瓧绗� + var sendData = this.GetPanelVibrationCommandText(device.DeviceAddr, datainfo); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 6); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) { //璁剧疆闇囧姩鍙嶉閰嶇疆淇℃伅澶辫触 string errorMsg = Language.StringByID(R.MyInternationalizationString.uSetVibrationFeedbackSettionFail); - if (TimeOut >= 60) - { - errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false); - } + errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false); this.ShowTipMsg(errorMsg); return false; } - //澶囦唤璁惧 - HdlThreadLogic.Current.RunThread(async () => - { - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绠�绾﹂潰鏉块渿鍔ㄥ姛鑳�, datainfo); - }, ShowErrorMode.NO); + return true; + } - return success; + /// <summary> + /// 鑾峰彇缂栬緫闈㈡澘闇囧姩鍔熻兘鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="datainfo"></param> + /// <returns></returns> + public string GetPanelVibrationCommandText(string DeviceAddr, PanelVibrationInfo datainfo) + { + string passData = "0800081104"; + passData += datainfo.A闇囧姩浣胯兘 ? "01" : "00"; + passData += Convert.ToString(datainfo.A闇囧姩寮哄害, 16).PadLeft(2, '0'); + string time = Convert.ToString(datainfo.A闇囧姩鏃堕棿, 16).PadLeft(4, '0'); + //浣庝綅鍦ㄥ墠锛岄珮浣嶅湪鍚� + passData += time.Substring(2, 2); + passData += time.Substring(0, 2); + + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } }; + jObject.Add("Data", data); + return jObject.ToString(); } /// <summary> /// 绠�绾﹂潰鏉块渿鍔ㄥ姛鑳戒俊鎭� /// </summary> - public class VibrationInfo + public class PanelVibrationInfo { /// <summary> /// 闇囧姩浣胯兘 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs index d30b259..ab171e6 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePirSensorLogic.cs @@ -3,6 +3,7 @@ using System.Text; using ZigBee.Device; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Shared.Phone.UserCenter { @@ -42,6 +43,11 @@ /// <returns></returns> public async Task<int> GetPirLightAbilitySize(IASZone iASZone) { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return 100; + } var data = await iASZone.GetPIRLightAbilitySizeAsync(); //鍏遍�氶敊璇娴� string error = HdlCheckLogic.Current.CheckCommonErrorCode(data); @@ -74,9 +80,9 @@ /// </summary> /// <param name="iASZone"></param> /// <returns></returns> - public async Task<IASZone.ConfigureParamates> GetPirSensorLightSettion(IASZone iASZone) + public IASZone.ConfigureParamates GetPirSensorLightSettion(IASZone iASZone) { - var data = await iASZone.GetPIRSensorParamateAsync(); + var data = this.GetPIRSensorParamateAsync(iASZone); if (data == null || data.configureParamates == null) { //鑾峰彇浼犳劅鍣ㄨ缃俊鎭け璐� @@ -98,6 +104,11 @@ /// <returns></returns> public async Task<int> GetPirSensorLux(IASZone iASZone, ShowErrorMode mode = ShowErrorMode.YES) { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return 70; + } var data = await iASZone.GetPirLuxAbilitySizeAsync(); if (data == null || data.pirLux == -1) { @@ -114,6 +125,61 @@ return data.pirLux; } + ///<summary > + ///PIR浼犳劅鍣ㄥ弬鏁伴厤缃� + /// </summary> + public IASZone.ParamatesInfo GetPIRSensorParamateAsync(CommonDevice device) + { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.GetPirSensorLightSettion(device); + } + var sendData = this.GetPirSensorParamateCommadText(device.DeviceAddr); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0302", 34, 9); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + var data = result.ReceiptData; + + var tempD = new IASZone.ConfigureParamates(); + + var le = data[10].ToString() + data[11].ToString(); + tempD.levelEnable = le == "01"; + + var size = data[12].ToString() + data[13].ToString(); + tempD.levelSize = Convert.ToInt32(size, 16); + + var cdl = data[14].ToString() + data[15].ToString(); + tempD.controlDevEnable = cdl == "01"; + + tempD.transitionTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16); + tempD.iasReportPeriod = Convert.ToInt32(data[22].ToString() + data[23].ToString() + data[20].ToString() + data[21].ToString(), 16); + tempD.mode = Convert.ToInt32(data[24].ToString() + data[25].ToString(), 16); + tempD.type = Convert.ToInt32(data[26].ToString() + data[27].ToString(), 16); + tempD.dimmerOnTime = Convert.ToInt32(data[28].ToString() + data[29].ToString(), 16); + tempD.dimmerOffTime = Convert.ToInt32(data[30].ToString() + data[31].ToString(), 16); + tempD.dimmerLevel = Convert.ToInt32(data[32].ToString() + data[33].ToString(), 16); + + return new IASZone.ParamatesInfo { configureParamates = tempD }; + } + + /// <summary> + /// 鑾峰彇PIR浼犳劅鍣ㄥ弬鏁伴厤缃殑鍛戒护瀛楃 + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + private string GetPirSensorParamateCommadText(string DeviceAddr) + { + var passData = "050103010101"; + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + #endregion #region 鈻� 璁剧疆閰嶇疆淇℃伅_______________________ @@ -121,12 +187,12 @@ /// <summary> /// 璁剧疆PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭�� /// </summary> - /// <param name="iASZone">浼犳劅鍣ㄥ璞�</param> + /// <param name="device">浼犳劅鍣ㄥ璞�</param> /// <param name="configure">鐏厜閰嶇疆</param> /// <returns></returns> - public async Task<bool> SetPirSensorSettion(IASZone iASZone, IASZone.ConfigureParamates configure) + public bool SetPirSensorSettion(CommonDevice device, IASZone.ConfigureParamates configure) { - var result = await iASZone.SetPIRSensorParamateAsync(configure); + var result = this.SetPIRSensorParamateAsync(device, configure); if (result == null || result.responseData == null) { //璁剧疆浼犳劅鍣ㄩ厤缃俊鎭け璐� @@ -144,12 +210,208 @@ this.ShowErrorMsg(msg); return false; } - //澶囦唤璁剧疆 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(iASZone, GatewayBackupEnum.APir鐏厜閰嶇疆, configure); return true; } + /// <summary> + /// PIR浼犳劅鍣ㄥ弬鏁伴厤缃� + /// </summary> + /// <param name="device"></param> + /// <param name="configureParamates"></param> + /// <returns></returns> + public IASZone.ResponseAllData SetPIRSensorParamateAsync(CommonDevice device, IASZone.ConfigureParamates configureParamates) + { + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return ModelData.DeviceModelDataLogic.Current.SetPirSensorLightSettion(device, configureParamates, "ClientDataPassthrough"); + } + //鍙戦�佹暟鎹� + var sendData = this.GetPirSensorSettionCommandText(device.DeviceAddr, configureParamates); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + string data = result.ReceiptData; + var tempD = new IASZone.ResponseData(); + tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); + + return new CommonDevice.ResponseAllData { responseData = tempD }; + } + + /// <summary> + /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃 + /// </summary> + /// <param name="DeviceAddr"></param> + /// <param name="configureParamates"></param> + /// <returns></returns> + public string GetPirSensorSettionCommandText(string DeviceAddr, IASZone.ConfigureParamates configureParamates) + { + var passData = this.GetPIRSensorSettionPassData(configureParamates); + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + var data = new JObject { { "PassData", passData } }; + jObject.Add("Data", data); + + return jObject.ToString(); + } + + /// <summary> + /// 鑾峰彇淇敼PIR浼犳劅鍣ㄩ厤缃殑鍛戒护瀛楃 + /// </summary> + private string GetPIRSensorSettionPassData(IASZone.ConfigureParamates configureParamates) + { + string data = ""; + string dataLength = "10"; + string dataComand1 = "00"; + string dataComand2 = "03"; + string dataSerialNum = "01"; + string addDataLength = "0C"; + string levelEnable = ""; + string levelSize = ""; + string controlDevEnable = ""; + string transitionTime = ""; + string iasReportPeriod = ""; + string mode = ""; + string type = ""; + string dimmerOnTime = ""; + string dimmerOffTime = ""; + try + { + if (configureParamates != null) + { + //levelEnable + if (configureParamates.levelEnable) + { + levelEnable = "01"; + } + else + { + levelEnable = "00"; + } + //鍏夌収绛夌骇 + if (configureParamates.levelSize > 0) + { + var tempLevelEnable = Convert.ToString(configureParamates.levelSize, 16); + levelSize = tempLevelEnable.ToString().PadLeft(2, '0'); + } + else + { + levelSize = "00"; + } + //controlDevEnable + if (configureParamates.controlDevEnable) + { + controlDevEnable = "01"; + } + else + { + controlDevEnable = "00"; + } + //transitionTime,iasReportPeriod + for (int j = 0; j < 2; j++) + { + var tempBytes = new byte[2]; + if (j == 0) + { + for (int i = 0; i < 2; i++) + { + tempBytes[i] = (byte)(configureParamates.transitionTime >> (i * 8) & 0xff); + } + } + else + { + for (int i = 0; i < 2; i++) + { + tempBytes[i] = (byte)(configureParamates.iasReportPeriod >> (i * 8) & 0xff); + } + } + var time1 = Convert.ToString(tempBytes[0], 16); + var time2 = Convert.ToString(tempBytes[1], 16); + if (time1.Length == 1) + { + time1 = "0" + time1; + } + if (time2.Length == 1) + { + time2 = "0" + time2; + } + if (j == 0) + { + transitionTime = (time1 + time2).ToUpper(); + + } + else + { + iasReportPeriod = (time1 + time2).ToUpper(); + } + } + //mode + if (configureParamates.mode == 1) + { + mode = "01"; + } + else + { + mode = "00"; + } + //type + if (configureParamates.type == 1) + { + type = "01"; + } + else + { + type = "00"; + } + //dimmerOnTime + if (configureParamates.dimmerOnTime > 0) + { + var tempDimmerOnTime = Convert.ToString(configureParamates.dimmerOnTime, 16); + dimmerOnTime = tempDimmerOnTime.ToString().PadLeft(2, '0'); + } + else + { + dimmerOnTime = "00"; + } + dimmerOnTime = dimmerOnTime.ToUpper(); + if (configureParamates.dimmerOffTime > 0) + { + var tempDimmerOffTime = Convert.ToString(configureParamates.dimmerOffTime, 16); + dimmerOffTime = tempDimmerOffTime.ToString().PadLeft(2, '0'); + } + else + { + dimmerOffTime = "00"; + } + dimmerOffTime = dimmerOffTime.ToUpper(); + //dimmerLevel + string temp = ""; + var sbString = new System.Text.StringBuilder(); + string temp2 = Convert.ToString(configureParamates.dimmerLevel, 16); + switch (temp2.Length) + { + case 1: + temp = "0" + temp2; + break; + case 2: + temp = temp2; + break; + } + sbString.Append(temp.ToUpper()); + + data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + levelEnable + levelSize + controlDevEnable + transitionTime + iasReportPeriod + + mode + type + dimmerOnTime + dimmerOffTime + sbString; + } + } + catch { }; + + return data; + } + #endregion #region 鈻� 涓�鑸柟娉昣__________________________ diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs index 1e792df..50c8582 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlExperienceAccountLogic.cs @@ -914,10 +914,24 @@ device.ModelIdentifier = ModelIdentifier; device.CurrentGateWayId = string.Empty; - //榛樿姣忎釜璁惧閮藉彲浠ュ畾浣� + //榛樿姣忎釜璁惧閮藉彲浠ュ畾浣�,鎷ユ湁寮�鍏冲姛鑳� device.InClusterList.Add(new CommonDevice.InClusterObj { InCluster = 3 }); device.OutClusterList.Add(new CommonDevice.OutClusterObj { OutCluster = 3 }); - + if (device.Type == DeviceType.AirSwitch || device.Type == DeviceType.OnOffOutput + || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight) + { + device.InClusterList.Add(new CommonDevice.InClusterObj { InCluster = 6 }); + device.OutClusterList.Add(new CommonDevice.OutClusterObj { OutCluster = 6 }); + } + if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight + || device.Type == DeviceType.ColorDimmableLight) + { + device.InClusterList.Add(new CommonDevice.InClusterObj { InCluster = 8 }); + } + if (device.Type == DeviceType.WindowCoveringDevice) + { + device.InClusterList.Add(new CommonDevice.InClusterObj { InCluster = 258 }); + } //娣诲姞铏氭嫙璁惧 LocalDevice.Current.AddVirtualDeviceToMemory(device); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs index 18ffe33..672bc3f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs @@ -2152,35 +2152,35 @@ #region 鈻� 涓婁紶璁惧澶囦唤鍒扮綉鍏砡________________ /// <summary> - /// 涓婁紶璁惧澶囦唤鍒扮綉鍏�(鏈�濂戒笉瑕佸幓鐞嗗畠鐨勮繑鍥炵粨鏋�) + /// 涓婁紶璁惧澶囦唤鍒扮綉鍏�(搴熷純) /// </summary> /// <param name="device">璁惧瀵硅薄</param> /// <param name="backupEnum">澶囦唤绫诲瀷</param> /// <param name="upLaodData">澶囦唤鐨勬暟鎹�</param> /// <returns></returns> - public async Task<bool> UpLoadDeviceBackupDataToGateway(CommonDevice device, GatewayBackupEnum backupEnum, object upLaodData) + public async Task<bool> UpLoadDeviceBackupDataToGateway(CommonDevice device, object upLaodData) { - ZbGateway realWay = null; - if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, device.CurrentGateWayId) == false) - { - //娌℃湁鎵惧埌鐪熷疄鐗╃悊缃戝叧 - return false; - } - string fileName = device.FilePath + ((int)backupEnum).ToString().PadLeft(5, '0'); - //鍒涘缓鏂囦欢瀵硅薄 - var result = await realWay.CreateFileAsync(fileName); - if (result == null || result.Result != 0) - { - return false; - } - //鍙戦�佹暟鎹祦 - var data = Newtonsoft.Json.JsonConvert.SerializeObject(upLaodData); - var byteData = System.Text.Encoding.UTF8.GetBytes(data); - var result2 = await realWay.SendFileAsync(byteData); - if (result2 == null || result2.Result != 0) - { - return false; - } + //ZbGateway realWay = null; + //if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, device.CurrentGateWayId) == false) + //{ + // //娌℃湁鎵惧埌鐪熷疄鐗╃悊缃戝叧 + // return false; + //} + //string fileName = device.FilePath + ((int)backupEnum).ToString().PadLeft(5, '0'); + ////鍒涘缓鏂囦欢瀵硅薄 + //var result = await realWay.CreateFileAsync(fileName); + //if (result == null || result.Result != 0) + //{ + // return false; + //} + ////鍙戦�佹暟鎹祦 + //var data = Newtonsoft.Json.JsonConvert.SerializeObject(upLaodData); + //var byteData = System.Text.Encoding.UTF8.GetBytes(data); + //var result2 = await realWay.SendFileAsync(byteData); + //if (result2 == null || result2.Result != 0) + //{ + // return false; + //} return true; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs index cace472..2f3c31e 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs @@ -640,6 +640,9 @@ //濡傛灉鏄櫄鎷熶綇瀹� HdlThreadLogic.Current.RunMain(() => { + //璁惧畾涓�涓椂闂� + Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); + Config.Instance.Save(); //鏀惰捣宸﹁彍鍗� CommonPage.Instance.CloseLeftMenu(); //鍏抽棴鎵�鏈夋墦寮�浜嗙殑鐣岄潰 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs index 1cdb3cf..e0c6eb5 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs @@ -52,7 +52,7 @@ } /// <summary> - /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// 鍒濆鍖栦腑閮ㄤ俊鎭� 鈽嗏槅鈽嗏槅鈽� /// </summary> private void InitMiddleFrame() { @@ -106,7 +106,7 @@ var btnOk = new BottomClickButton(); btnOk.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnOk); - btnOk.ButtonClickEvent += async (sender, e) => + btnOk.ButtonClickEvent += (sender, e) => { if (this.oldReportValue == this.reportValue) { @@ -116,7 +116,7 @@ } //灏嗕簩杩涘埗杞崲涓哄崄杩涘埗 var data = Convert.ToInt32(this.fixValue + this.reportValue, 2); - var result = await HdlDeviceAirConditionerLogic.Current.SetAcModeSupport(deviceAc, data); + var result = HdlDeviceAirConditionerLogic.Current.SetAcModeSupport(deviceAc, data); if (result == true) { //鏇存敼缂撳瓨 @@ -181,10 +181,23 @@ #region 鈻� 璇诲彇绌鸿皟鑷畾涔夋ā寮廮________________ /// <summary> - /// 璇诲彇绌鸿皟鑷畾涔夋ā寮� + /// 璇诲彇绌鸿皟鑷畾涔夋ā寮� 鈽嗏槅鈽嗏槅鈽� /// </summary> private void ReadAirConditionerModeSupport() { + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + var data = ModelData.DeviceModelDataLogic.Current.GetAcModeSupport(deviceAc); + //杞崲涓轰簩杩涘埗 + var value = Convert.ToString(data, 2).PadLeft(16, '0'); + //杩欎簲涓缃槸鏀惧湪鍚庨潰鐨� + this.fixValue = value.Substring(0, value.Length - 5); + this.reportValue = value.Substring(this.fixValue.Length); + oldReportValue = reportValue; + return; + } + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceAc); HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs index 8c174d1..1875cda 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs @@ -101,7 +101,7 @@ btnNote.InitControl(); //鍒掔嚎 btnNote.AddBottomLine(); - btnNote.txtInput.FinishInputEvent += async () => + btnNote.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc); if (btnNote.Text.Trim() == string.Empty) @@ -112,7 +112,7 @@ if (oldName != btnNote.Text) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); + var result = Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); if (result == false) { return; @@ -174,9 +174,9 @@ string statu = btnSwingSwitch.IsSelected == true ? "0" : "1"; //灏嗕簩杩涘埗杞崲涓哄崄杩涘埗 int sendData = Convert.ToInt32(this.fixValue + statu, 2); - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { - var result = await HdlDeviceAirConditionerLogic.Current.SetUseAcSwingFunctionStatu(deviceAc, sendData); + var result = HdlDeviceAirConditionerLogic.Current.SetUseAcSwingFunctionStatu(deviceAc, sendData); if (result == true) { HdlThreadLogic.Current.RunMain(() => @@ -201,13 +201,13 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc); if (oldName != btnNote.Text) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); + var result = Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); if (result == false) { return; @@ -267,6 +267,18 @@ /// </summary> private bool ReadAirConditionerSwingModeSupport() { + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + var data = ModelData.DeviceModelDataLogic.Current.GetAcSwingModeSupport(deviceAc); + //杞崲涓轰簩杩涘埗 + var value = Convert.ToString(data, 2).PadLeft(16, '0'); + //杩欎釜璁剧疆鏄斁鍦ㄥ悗闈㈢殑 + this.fixValue = value.Substring(0, value.Length - 1); + this.swingMode = Convert.ToInt32(value.Substring(this.fixValue.Length)); + return true; + } + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceAc); HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs index 29cdfe9..647af1d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs @@ -14,10 +14,9 @@ /// 鏋勯�犲嚱鏁� /// </summary> /// <param name="doorLock"></param> - public AddScenePage(ZigBee.Device.Panel key, List<ScenesListInfo> gwScenesList) + public AddScenePage(ZigBee.Device.Panel key) { this.currentKey = key; - gwCurScenesList = gwScenesList; } #region 鍙橀噺鐢虫槑 @@ -62,10 +61,7 @@ /// </summary> Dictionary<string, string> dicFloor; List<SceneUI> currentKeyAllRoomSceneList = new List<SceneUI>(); - /// <summary> - /// 缃戝叧涓殑鍦烘櫙鍒楄〃 - /// </summary> - public List<ScenesListInfo> gwCurScenesList = new List<ScenesListInfo>(); + #endregion /// <summary> @@ -279,7 +275,7 @@ Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); if (currentKey.bindList.Count != 0) { - var bindResult = await currentKey.ClearBindInfoAsync(); + var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey); if (bindResult != null && bindResult.clearBindInfoResponseData != null) { if (bindResult.clearBindInfoResponseData.Result != 0) @@ -315,7 +311,7 @@ } } - var temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Scene_Trigger); + var temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Scene_Trigger); if (temp == null || temp.setWritableValueResponData == null) { Application.RunOnMainThread(() => @@ -374,7 +370,7 @@ } var dev = new AddedDeviceBindResponseAllData(); - dev = await currentKey.AddDeviceBindAsync(addBindeDev); + dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev); if (dev != null && dev.addedDeviceBindResponseData != null) { if (dev.addedDeviceBindResponseData.Result == 0) @@ -989,11 +985,7 @@ { continue; } - var gwSc = gwCurScenesList.Find(obj => (obj.ScenesId == sceneId)); - if (gwSc != null) - { - tempSceneUIList.Add(scene); - } + tempSceneUIList.Add(scene); } return tempSceneUIList; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs index e4d680a..b6b4a78 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs @@ -67,10 +67,6 @@ /// </summary> List<int> typeModeList; /// <summary> - /// 缃戝叧涓殑鍦烘櫙鍒楄〃 - /// </summary> - public List<ScenesListInfo> gwScenesList = new List<ScenesListInfo>(); - /// <summary> /// 鏄惁鏀寔璇诲彇 /// </summary> bool IsRead = false; @@ -95,21 +91,12 @@ } //鑾峰彇鏈湴鍦烘櫙鍒楄〃 scList = HdlSceneLogic.Current.GetAllRoomSceneList(); - //鑾峰彇缃戝叧鍦烘櫙琛� - if (gwScenesList.Count == 0) - { - var gwSceneObj = await currentKey.GetSceneInfoAsync(); - if (gwSceneObj != null && gwSceneObj.getSceneInfo != null) - { - gwScenesList = gwSceneObj.getSceneInfo.ScenesList; - } - } //鍔ㄦ�佽幏鍙栨寜閿敮鎸佺殑澶х被 typeModeList = await GetTypeMode(); #region 璇诲彇闈㈡澘褰撳墠妯″紡 //璇诲彇鎸夐敭褰撳墠妯″紡 - var tempDeata = await currentKey.ReadPanelConfigureInfoAsync(); + var tempDeata = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(currentKey); if (tempDeata != null && tempDeata.deviceStatusReportData != null) { foreach (var attr in tempDeata.deviceStatusReportData.AttriBute) @@ -136,7 +123,7 @@ GetDeviceBindResponseAllData getBindList = null; if (IsRead) { - getBindList = await currentKey.GetDeviceBindAsync(); + getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey); var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { }; var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { }; if (getBindList != null && getBindList.getAllBindResponseData != null) @@ -270,7 +257,7 @@ { currentClusterID = 6; currentKey.panelMode = 1; - var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList); + var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey); Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addScenePage.Show(); @@ -647,7 +634,7 @@ try { CommonPage.Loading.Start(""); - var bindResult = await currentKey.ClearBindInfoAsync(); + var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey); if (bindResult != null && bindResult.clearBindInfoResponseData != null) { if (bindResult.clearBindInfoResponseData.Result != 0) @@ -658,10 +645,10 @@ } else { - var temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default); + var temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default); if (temp != null && temp.setWritableValueResponData?.Status != 0) { - var temp1 = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default); + var temp1 = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default); if (temp1 != null && temp1.setWritableValueResponData?.Status != 0) { new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel); @@ -902,7 +889,7 @@ var result = await RemoveTargets(bindSc, line2); if (result == 0) { - var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList); + var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey); Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addScenePage.Show(); @@ -925,7 +912,7 @@ } else { - var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList); + var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey); Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addScenePage.Show(); @@ -1129,6 +1116,13 @@ /// <returns></returns> private async System.Threading.Tasks.Task<List<int>> GetTypeMode() { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + //鍒欓粯璁ゅ叏閮ㄥ姛鑳介兘缁欏畠 + typeModeList = new List<int>() { 1, 100, 200, 300, 0, 101, 102 }; + return typeModeList; + } if (typeModeList != null) { typeModeList.Clear(); @@ -1184,7 +1178,7 @@ { CommonPage.Loading.Start(""); var delResult = new DelDeviceBindResponseAllData(); - delResult = await currentKey.DelDeviceBindAsync(delDevice); + delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); if (delResult != null && delResult.delDeviceBindResponseData != null) { if (delResult.delDeviceBindResponseData?.RemoveBindList != null) @@ -1210,7 +1204,7 @@ { CommonPage.Loading.Start(""); - var getBindList = await currentKey.GetDeviceBindAsync(); + var getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey); var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { }; var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { }; if (getBindList != null) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs index 919a812..730ce66 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs @@ -127,7 +127,7 @@ //1銆佹竻绌烘墍鏈夌洰鏍� if (currentKey.bindList != null) { - var bindResult = await currentKey.ClearBindInfoAsync(); + var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey); if (bindResult != null && bindResult.clearBindInfoResponseData != null) { if (bindResult.clearBindInfoResponseData.Result != 0) @@ -164,43 +164,43 @@ switch (currentModeID) { case 100: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_On); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_On); break; case 101: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_oFF); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_oFF); break; case 102: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_OnOff); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_OnOff); break; case 200: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Up); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Up); break; case 201: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Down); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Down); break; case 203: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up); break; case 204: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Down); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Down); break; case 205: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up_Down); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up_Down); break; case 300: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up); break; case 301: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down); break; case 302: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Stop); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Stop); break; case 303: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up_Stop); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up_Stop); break; case 304: - temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down_Stop); + temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down_Stop); break; } if (temp != null && temp.setWritableValueResponData != null) @@ -243,7 +243,7 @@ } var dev = new AddedDeviceBindResponseAllData(); - dev = await currentKey.AddDeviceBindAsync(addBindeDev); + dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev); if (dev != null && dev.addedDeviceBindResponseData != null) { if (dev.addedDeviceBindResponseData.Result == 0) @@ -410,6 +410,13 @@ { return System.Threading.Tasks.Task.Run(async () => { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + typeDetailModeList.Clear(); + return new List<int>() { 100, 101, 102 }; + } + Application.RunOnMainThread(() => { CommonPage.Loading.Start(); @@ -466,6 +473,13 @@ { return System.Threading.Tasks.Task.Run(async () => { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + typeDetailModeList.Clear(); + return new List<int>() { 200, 201, 203, 204, 205 }; + } + Application.RunOnMainThread(() => { CommonPage.Loading.Start(); @@ -537,6 +551,17 @@ return System.Threading.Tasks.Task.Run(async () => { typeDetailModeList.Clear(); + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Hide(); + }); + typeDetailModeList.Clear(); + return new List<int>() { 300, 301, 302, 303, 304 }; + } + List<int> result3 = new List<int> { }; try { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs index de7b257..2bc736f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs @@ -177,10 +177,10 @@ var form = new BottomItemSelectForm(); form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo); - form.FinishSelectEvent += async (index) => + form.FinishSelectEvent += (index) => { //鍙樻洿鏂瑰悜 - var result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true); + var result = HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true); if (result == false) { return; @@ -336,7 +336,8 @@ frameBack.AddChidren(btnSave); btnSave.ButtonClickEvent += (sender, e) => { - if (this.receiveOpenlimit == true) + //2020.05.17:杩藉姞铏氭嫙浣忓畢鍙互鐩存帴鐐瑰嚮 + if (this.receiveOpenlimit == true || Common.Config.Instance.Home.IsVirtually == true) { //纭寮�闄愪綅鐐� this.SaveOpenLimit(); @@ -356,27 +357,28 @@ //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.OpenLimitPersent = value; }; + //铏氭嫙浣忓畢涓嶉渶瑕佺洃鍚� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return; + } HdlThreadLogic.Current.RunThread(async () => { - //澶勭悊涓� - bool checking = false; while (openSeekBar.Parent != null) { int nowValue = curtainData.OpenLimitPersent; - if (oldProValue == nowValue || checking == true) + if (oldProValue == nowValue) { //鍊间笉绛夋墠澶勭悊 await Task.Delay(500); continue; } oldProValue = nowValue; - checking = true; //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� this.sendDiv = 1; curtainDevice.WcdGoToTiltValue(nowValue); - checking = false; } }); } @@ -388,15 +390,14 @@ { //纭褰撳墠浣嶇疆涓哄紑闄愪綅? string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg); - this.ShowMassage(ShowMsgType.Confirm, msg, async () => + this.ShowMassage(ShowMsgType.Confirm, msg, () => { decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength; decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength; if (openValue < 0) { openValue = 0; } if (closeValue < 0) { closeValue = curtainData.CurtainLength; } //鎵ц纭鍙婅鐩栦笂闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, - (int)openValue, (int)closeValue); + var result = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength); if (result == true) { this.receiveOpenlimit = false; @@ -508,7 +509,8 @@ frameBack.AddChidren(btnSave); btnSave.ButtonClickEvent += (sender, e) => { - if (this.receiveCloseLimit == true) + //2020.05.17:杩藉姞铏氭嫙浣忓畢鍙互鐩存帴鐐瑰嚮 + if (this.receiveCloseLimit == true || Common.Config.Instance.Home.IsVirtually == true) { //淇濆瓨鍚堥檺浣嶇偣 this.SaveCloseLimit(); @@ -528,27 +530,28 @@ //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.CloseLimitPersent = value; }; + //铏氭嫙浣忓畢涓嶉渶瑕佺洃鍚� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return; + } HdlThreadLogic.Current.RunThread(async () => { - //澶勭悊涓� - bool checking = false; while (closeSeekBar.Parent != null) { int nowValue = curtainData.CloseLimitPersent; - if (oldProValue == nowValue || checking == true) + if (oldProValue == nowValue) { //鍊间笉绛夋墠澶勭悊 await Task.Delay(500); continue; } - checking = true; oldProValue = nowValue; //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� this.sendDiv = 2; curtainDevice.WcdGoToTiltValue(nowValue); - checking = false; } }); } @@ -560,15 +563,14 @@ { //纭褰撳墠浣嶇疆涓哄悎闄愪綅? string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg); - this.ShowMassage(ShowMsgType.Confirm, msg, async () => + this.ShowMassage(ShowMsgType.Confirm, msg, () => { decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength; decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength; if (openValue < 0) { openValue = 0; } if (closeValue < 0) { closeValue = curtainData.CurtainLength; } //鎵ц纭鍙婅鐩栦笂闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, - (int)openValue, (int)closeValue); + var result = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength); if (result == true) { @@ -594,6 +596,11 @@ rowReset.AddBottomLine(); rowReset.ButtonClickEvent += (sender, e) => { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return; + } //閲嶇疆鐢垫満灏嗗垵濮嬪寲{0}鏂瑰悜涓庨檺浣嶈缃紝纭缁х画锛� string msg = Language.StringByID(R.MyInternationalizationString.uResetElectricalMachineryMsg); msg = msg.Replace("{0}", "\r\n"); @@ -651,13 +658,24 @@ /// <returns></returns> private bool InitCurtainDefultData() { - //寮�鍚繘搴︽潯 - this.ShowProgressBar(); - this.curtainData = new CurtainData(); this.receiveOpenlimit = false; this.receiveCloseLimit = false; this.sendDiv = 0; + + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + var data = ModelData.DeviceModelDataLogic.Current.GetCurtainLimitPoint(curtainDevice); + curtainData.Direction = data.Direction; + curtainData.CurtainLength = data.curtainLength; + curtainData.OpenLimitValue = data.upLimit; + curtainData.CloseLimitValue = data.downLimit; + return true; + } + + //寮�鍚繘搴︽潯 + this.ShowProgressBar(); int receiptDataCount = 0; string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); @@ -728,21 +746,6 @@ } //绉婚櫎鐩戝惉 HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); - - //澶囦唤绐楀笜鏁版嵁 - if (this.backupCurtainData == true && curtainData.CurtainLength > 0) - { - this.backupCurtainData = false; - HdlThreadLogic.Current.RunThread(async () => - { - //鏂瑰悜澶囦唤 - await HdlDeviceCurtainLogic.Current.BackupCurtainDirection(curtainDevice, curtainData.Direction); - //闄愪綅澶囦唤 - int uplimit = (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100); - int downlimit = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100); - await HdlDeviceCurtainLogic.Current.BackupCurtainLimitPoint(curtainDevice, uplimit, downlimit); - }); - } return true; } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs index 49d8a27..b63e2c3 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs @@ -121,10 +121,10 @@ var form = new BottomItemSelectForm(); form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo); - form.FinishSelectEvent += async (index) => + form.FinishSelectEvent += (index) => { //鍙樻洿鏂瑰悜 - var result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true); + var result = HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs index 0ae952d..5080f98 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs @@ -262,11 +262,11 @@ /// </summary> /// <param name="i_deviceName">deviceName.</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> - private async void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES) + private void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES) { //淇敼MAC鍚� string deviceName = i_deviceName.Trim(); - var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode); + var result = Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode); if (result == false) { return; @@ -278,7 +278,7 @@ /// <summary> /// 璁剧疆鍏ㄩ儴鍥炶矾鐨勯粯璁ゅ悕瀛� /// </summary> - private async void SetAllEpointName() + private void SetAllEpointName() { foreach (var device in this.listNewDevice) { @@ -289,7 +289,7 @@ } //鑾峰彇绔偣鍚嶅瓧 var epointName = Common.LocalDevice.Current.GetDeviceEpointName(device); - await Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO); + Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO); } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs index be1e0ef..3f9f949 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs @@ -95,7 +95,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -114,7 +114,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { //鍏抽棴 @@ -148,7 +148,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -159,7 +159,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; @@ -325,7 +325,7 @@ var form = new BottomItemSelectForm(); form.AddForm(title, listText, nowSelectNo); - form.FinishSelectEvent += async (selectNo) => + form.FinishSelectEvent += (selectNo) => { if (selectNo == nowSelectNo) { @@ -339,7 +339,7 @@ //閫夋嫨鐨勬槸浼犳劅鍣ㄨ緭鍏� value = 65535; } - var result = await HdlDevicePanelLogic.Current.EditorDryContactThirdFunction((Panel)nowSelectDevice, value); + var result = HdlDevicePanelLogic.Current.EditorDryContactThirdFunction((Panel)nowSelectDevice, value); if (result == true) { //閲嶆柊鍒濆鍖栬彍鍗曡,闅愯棌鎴栬�呭紑鏀剧粦瀹氱洰鏍囪彍鍗� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs index b5ade0c..7edae6d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceFunctionSettionForm.cs @@ -100,7 +100,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -117,7 +117,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { return; @@ -148,7 +148,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -159,7 +159,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs index 0996841..8082a1b 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs @@ -845,23 +845,24 @@ btnFunction.AddLeftCaption(caption, 600); //寮�鍏冲浘鏍� var btnSwitch = btnFunction.AddMostRightSwitchIcon(); - //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹呯殑璇�,璁╂墍鏈夎彍鍗曢兘涓嶈兘鐐瑰嚮 - if (Common.Config.Instance.Home.IsVirtually == true) - { - btnSwitch.CanClick = false; - } //搴曠嚎 btnFunction.AddBottomLine(); - btnSwitch.ButtonClickEvent += async (sender, e) => + btnSwitch.ButtonClickEvent += (sender, e) => { //鍒囨崲妯″紡 bool statu = !btnSwitch.IsSelected; - var result = await HdlDeviceCurtainLogic.Current.SetHandPullControl(deviceCurtain, statu); + var result = HdlDeviceCurtainLogic.Current.SetHandPullControl(deviceCurtain, statu); if (result == true) { btnSwitch.IsSelected = statu; } }; + //濡傛灉鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + btnSwitch.IsSelected = ModelData.DeviceModelDataLogic.Current.GetCurtainHandPullControl(deviceCurtain); + return; + } //娣诲姞灞炴�т笂鎶ョ洃鍚� string mainkeys = LocalDevice.Current.GetDeviceMainKeys(this.listNewDevice[0]); @@ -1117,11 +1118,11 @@ /// 璁惧閲嶅懡鍚� /// </summary> /// <param name="i_deviceName">deviceName.</param> - private async void DeviceReName(string i_deviceName, bool closeForm) + private void DeviceReName(string i_deviceName, bool closeForm) { //淇敼MAC鍚� string deviceName = i_deviceName.Trim(); - var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName); + var result = Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLighWithSensorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLighWithSensorForm.cs index dc81c80..74c6a61 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLighWithSensorForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLighWithSensorForm.cs @@ -544,7 +544,7 @@ //寮�鍚繘搴︽潯 this.ShowProgressBar(); //浜害璋冭妭(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - linghtLevelInfo = await HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); + linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); if (linghtLevelInfo == null) { //鍏抽棴杩涘害鏉� @@ -560,14 +560,14 @@ return false; } //鑺傝兘妯″紡(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - energyModeInfo = await HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); + energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); if (energyModeInfo == null) { //鍏抽棴杩涘害鏉� this.CloseProgressBar(ShowReLoadMode.YES); return false; } - keyColorData = await HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice); + keyColorData = HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice); if (this.keyColorData == null) { //鍏抽棴杩涘害鏉� @@ -591,7 +591,7 @@ { this.ShowProgressBar(); //浜害璋冭妭鏇存敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - var result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); + var result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); if (result == false) { this.CloseProgressBar(); @@ -601,7 +601,7 @@ //鑺傝兘妯″紡淇敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) //鑲栧織璞粰鎸夐敭鎺у埗闈㈡澘锛堝洓寮�鍏帶锛夎澶囷紝璇撮粯璁�15绉掓椂闂达紝杩欐牱鎺ヨ繎鎰熷簲鍔熻兘鎵嶅悎鐞� energyModeInfo.time = 15; - result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); + result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); if (result == false) { this.CloseProgressBar(); @@ -615,7 +615,7 @@ return; } //璁剧疆鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅 - result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData); + result = HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData); this.CloseProgressBar(); if (result == false) { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs index 26f4c3a..4613059 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs @@ -57,10 +57,10 @@ /// <summary> /// 鍒濆鍖栦腑閮ㄤ俊鎭� /// </summary> - private async void InitMiddleFrame() + private void InitMiddleFrame() { //鑾峰彇璁惧鍒濆鏁版嵁 - var result = await this.GetDeviceDefultData(); + var result = this.GetDeviceDefultData(); if (result == false) { return; @@ -496,12 +496,12 @@ /// 鑾峰彇璁惧鍒濆鏁版嵁 /// </summary> /// <returns></returns> - private async Task<bool> GetDeviceDefultData() + private bool GetDeviceDefultData() { //寮�鍚繘搴︽潯 this.ShowProgressBar(); //浜害璋冭妭(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - linghtLevelInfo = await HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); + linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); if (linghtLevelInfo == null) { //鍏抽棴杩涘害鏉� @@ -509,14 +509,14 @@ return false; } //鑺傝兘妯″紡(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - energyModeInfo = await HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); + energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); if (energyModeInfo == null) { //鍏抽棴杩涘害鏉� this.CloseProgressBar(ShowReLoadMode.YES); return false; } - keyColorData = await HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice); + keyColorData = HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice); if (this.keyColorData == null) { //鍏抽棴杩涘害鏉� @@ -536,26 +536,23 @@ /// <summary> /// 淇濆瓨闈㈡澘鏁版嵁 /// </summary> - private async void SavePanelData() + private void SavePanelData() { - this.ShowProgressBar(); //浜害璋冭妭鏇存敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - var result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); + var result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); if (result == false) { this.CloseProgressBar(); return; } //鑺傝兘妯″紡淇敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); + result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); if (result == false) { - this.CloseProgressBar(); return; } //璁剧疆鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅 - result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData); - this.CloseProgressBar(); + result = HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs index 428d2c0..7f2f4d4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs @@ -39,7 +39,7 @@ /// <summary> /// 绠�绾﹂潰鏉跨殑闇囧姩鏁版嵁 /// </summary> - private HdlDevicePanelLogic.VibrationInfo vibrationInfo = null; + private HdlDevicePanelLogic.PanelVibrationInfo vibrationInfo = null; /// <summary> /// 鏄惁宸茬粡璇诲彇浜嗛渿鍔ㄦ暟鎹� /// </summary> @@ -94,7 +94,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -113,7 +113,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { //鍏抽棴 @@ -147,7 +147,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -158,7 +158,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs index be3f331..fee7e2a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueButtonSettionForm.cs @@ -87,7 +87,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -106,7 +106,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { //鍏抽棴 @@ -140,7 +140,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -151,7 +151,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirBackLightSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirBackLightSettionForm.cs index eef9e14..643fcd0 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirBackLightSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirBackLightSettionForm.cs @@ -512,7 +512,7 @@ //寮�鍚繘搴︽潯 this.ShowProgressBar(); //浜害璋冭妭(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - linghtLevelInfo = await HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); + linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice); if (linghtLevelInfo == null) { //鍏抽棴杩涘害鏉� @@ -528,14 +528,14 @@ return false; } //鑺傝兘妯″紡(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - energyModeInfo = await HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); + energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice); if (energyModeInfo == null) { //鍏抽棴杩涘害鏉� this.CloseProgressBar(ShowReLoadMode.YES); return false; } - keyColorData = await HdlDevicePanelLogic.Current.GetPanelColorInfo(panelDevice); + keyColorData = HdlDevicePanelLogic.Current.GetPanelColorInfo(panelDevice); if (this.keyColorData == null) { //鍏抽棴杩涘害鏉� @@ -562,7 +562,7 @@ //鑺傝兘妯″紡淇敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) //璁惧鍚屼簨璇存柊椋庨潰鏉块粯璁�60绉掓椂闂达紝杩欐牱鎺ヨ繎鎰熷簲鍔熻兘鎵嶅悎鐞� energyModeInfo.time = 60; - var result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); + var result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); if (result == false) { this.CloseProgressBar(); @@ -577,7 +577,7 @@ } //浜害璋冭妭鏇存敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); + result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); if (result == false) { this.CloseProgressBar(); @@ -585,7 +585,7 @@ } //璁剧疆鎸夐敭闈㈡澘棰滆壊鐨勪俊鎭� - result = await HdlDevicePanelLogic.Current.SetPanelColorInfo(panelDevice, this.keyColorData); + result = HdlDevicePanelLogic.Current.SetPanelColorInfo(panelDevice, this.keyColorData); this.CloseProgressBar(); if (result == false) { diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs index 9e91845..2832b5d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs @@ -242,7 +242,7 @@ bool result = false; //鑾峰彇闈㈡澘涓瓨鍦ㄧ殑缁戝畾鐩爣 FreshAir curControlDev = curDev as FreshAir; - var panelBindListRes = await curControlDev.GetDeviceBindAsync(); + var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev); if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) { bindList = panelBindListRes.getAllBindResponseData.BindList; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs index 1540752..f0a3123 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs @@ -727,8 +727,8 @@ //鑾峰彇鎵�鏈夋埧闂翠腑鍖归厤鐨勮兘缁戠殑鐩爣 currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList(); - //鑾峰彇闈㈡澘涓瓨鍦ㄧ殑缁戝畾鐩爣 - var panelBindListRes = await this.curControlDev.GetDeviceBindAsync(); + //鑾峰彇闈㈡澘涓瓨鍦ㄧ殑缁戝畾鐩爣 + var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev); if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) { curControlDev.bindList.Clear(); @@ -953,7 +953,7 @@ delDevice.RemoveBindList.Add(removeDevice); var delResult = new DelDeviceBindResponseAllData(); - delResult = await curControlDev.DelDeviceBindAsync(delDevice); + delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); if (delResult != null && delResult.removeBindResultResponseData != null) { if (delResult.removeBindResultResponseData.Result == 0) @@ -1079,7 +1079,7 @@ { var delDevice = DelBindDevice(bd); var delResult = new DelDeviceBindResponseAllData(); - delResult = await curControlDev.DelDeviceBindAsync(delDevice); + delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); if (delResult == null || delResult.removeBindResultResponseData == null) { Application.RunOnMainThread(() => @@ -1115,7 +1115,7 @@ { var delDevice = DelBindDevice(curBindDevice); var delResult = new DelDeviceBindResponseAllData(); - delResult = await curControlDev.DelDeviceBindAsync(delDevice); + delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); if (delResult == null || delResult.removeBindResultResponseData == null) { Application.RunOnMainThread(() => @@ -1191,7 +1191,7 @@ } var dev = new AddedDeviceBindResponseAllData(); - dev = await curControlDev.AddDeviceBindAsync(addBindeDev); + dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev); if (dev == null || dev.addedDeviceBindResponseData == null) { Application.RunOnMainThread(() => diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs index 5896288..f646435 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs @@ -92,7 +92,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -109,7 +109,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { return; @@ -140,7 +140,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -151,7 +151,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs index 7f44d16..b15ad79 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs @@ -86,7 +86,7 @@ var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnFinish); - btnFinish.ButtonClickEvent += async (sender, e) => + btnFinish.ButtonClickEvent += (sender, e) => { //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); @@ -103,7 +103,7 @@ if (oldName != newName) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(device, newName); + var result = Common.LocalDevice.Current.ReName(device, newName); if (result == false) { return; @@ -134,7 +134,7 @@ listview.AddChidren(btnDeviceName); btnDeviceName.InitControl(); btnDeviceName.AddBottomLine(); - btnDeviceName.txtInput.FinishInputEvent += async () => + btnDeviceName.txtInput.FinishInputEvent += () => { string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice); if (btnDeviceName.Text.Trim() == string.Empty) @@ -145,7 +145,7 @@ if (oldName != btnDeviceName.Text.Trim()) { //璁惧鍚嶇О淇敼 - var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); + var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim()); if (result == false) { return; diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs index 7c3b7e4..55dbad5 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs @@ -418,7 +418,7 @@ this.ShowProgressBar(); //鑾峰彇缁戝畾鐩爣璁惧 - List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone); + List<CommonDevice> listDevice = HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone); if (listDevice == null) { //鍏抽棴杩涘害鏉� @@ -448,7 +448,7 @@ } //鑾峰彇pir鐨勯厤缃俊鎭� - this.pirConfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone); + this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone); if (pirConfigure == null) { //鍏抽棴杩涘害鏉� @@ -520,7 +520,7 @@ PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) => { - btnTime.Text = listfirst[value1] + listSecond[value1][value2]; + btnTime.Text = listfirst[value1].TrimStart('0') + listSecond[value1][value2]; int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2)); int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2)); int delaySecond = minute * 60 + second; @@ -541,7 +541,7 @@ /// <summary> /// 淇濆瓨Pir浼犳劅鍣ㄦ暟鎹� /// </summary> - private async void SavePirSensorData() + private void SavePirSensorData() { if (this.isDataChanged == false) { @@ -577,7 +577,7 @@ if (listDelDevice.Count > 0) { //鍒犻櫎鐩爣 - var listSucess = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice); + var listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice); if (listSucess == null || listSucess.Count == 0) { //鍏抽棴杩涘害鏉� @@ -587,7 +587,7 @@ if (listLightDevice.Count > 0) { //鍒犻櫎璋冨厜鍣ㄩ暈 - listSucess = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8); + listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8); if (listSucess == null || listSucess.Count == 0) { //鍏抽棴杩涘害鏉� @@ -612,7 +612,7 @@ if (listSaveDevice.Count > 0) { //缁戝畾鐩爣 - var listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind); + var listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind); if (listSucess == null || listSucess.Count == 0) { //鍏抽棴杩涘害鏉� @@ -622,7 +622,7 @@ if (listLightDevice.Count > 0) { //缁戝畾璋冨厜闀� - listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8); + listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8); if (listSucess == null || listSucess.Count == 0) { //鍏抽棴杩涘害鏉� @@ -633,7 +633,7 @@ } } //淇濆瓨pir閰嶇疆淇℃伅 - var result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure); + var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure); if (result == false) { //鍏抽棴杩涘害鏉� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorWorkModeMenuForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorWorkModeMenuForm.cs index c4fca7a..0964bf2 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorWorkModeMenuForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorWorkModeMenuForm.cs @@ -243,7 +243,7 @@ this.ShowProgressBar(); //鑾峰彇PIR浼犳劅鍣ㄧ殑銆愰厤缃俊鎭�� - this.pirConfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(this.iASZone); + this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(this.iASZone); if (pirConfigure == null) { //鍏抽棴杩涘害鏉� @@ -263,12 +263,12 @@ /// <summary> /// 淇濆瓨Pir浼犳劅鍣ㄦ暟鎹� /// </summary> - private async void SavePirSensorData() + private void SavePirSensorData() { //鎵撳紑杩涘害鏉� this.ShowProgressBar(); //淇濆瓨閰嶇疆淇℃伅 - var result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.iASZone, this.pirConfigure); + var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.iASZone, this.pirConfigure); //鍏抽棴杩涘害鏉� this.CloseProgressBar(); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs index f81d8a3..3b8d198 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs @@ -58,10 +58,10 @@ /// <summary> /// 鍒濆鍖栦腑閮ㄤ俊鎭� /// </summary> - private async void InitMiddleFrame() + private void InitMiddleFrame() { //鑾峰彇璁惧鍒濆鏁版嵁 - var result = await this.GetDeviceDefultData(); + var result = this.GetDeviceDefultData(); if (result == false) { return; @@ -96,20 +96,20 @@ var btnSave = new BottomClickButton(); btnSave.TextID = R.MyInternationalizationString.uSave; bodyFrameLayout.AddChidren(btnSave); - btnSave.ButtonClickEvent += async (sender, e) => + btnSave.ButtonClickEvent += (sender, e) => { if (valueChanged == true) { this.ShowProgressBar(); //浜害璋冭妭鏇存敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion(listDevice[0], linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); + result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(listDevice[0], linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel); if (result == false) { this.CloseProgressBar(); return; } //鑺傝兘妯″紡淇敼(浠栦滑璇撮殢渚夸竴涓洖璺氨琛�) - result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(listDevice[0], energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); + result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(listDevice[0], energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level); this.CloseProgressBar(); if (result == false) { @@ -373,12 +373,12 @@ /// 鑾峰彇璁惧鍒濆鏁版嵁 /// </summary> /// <returns></returns> - private async Task<bool> GetDeviceDefultData() + private bool GetDeviceDefultData() { //寮�鍚繘搴︽潯 this.ShowProgressBar(); //浜害璋冭妭(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - linghtLevelInfo = await HdlDevicePanelLogic.Current.GetDeviceLightSettion(listDevice[0]); + linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(listDevice[0]); if (linghtLevelInfo == null) { //鍏抽棴杩涘害鏉� @@ -386,7 +386,7 @@ return false; } //鑺傝兘妯″紡(浠栦滑璇撮殢渚挎嬁涓�璺洖璺氨琛屼簡) - energyModeInfo = await HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(listDevice[0]); + energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(listDevice[0]); if (energyModeInfo == null) { //鍏抽棴杩涘害鏉� diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs index 2364376..b9b2672 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs @@ -432,14 +432,14 @@ /// 璁惧閲嶅懡鍚� /// </summary> /// <param name="i_deviceName">deviceName.</param> - private async void DeviceReName(string i_deviceName, bool closeForm) + private void DeviceReName(string i_deviceName, bool closeForm) { //寮�鍚繘搴︽潯 this.ShowProgressBar(); //淇敼MAC鍚� string deviceName = i_deviceName.Trim(); - var result = await Common.LocalDevice.Current.ReMacName(listNewDevice, deviceName); + var result = Common.LocalDevice.Current.ReMacName(listNewDevice, deviceName); //鍏抽棴杩涘害鏉� this.CloseProgressBar(); diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs index 0dd08fd..f50091f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs @@ -513,6 +513,7 @@ House.EditorHouseByHouseId(info.Id, ResidenceName); //鏇存敼鏄剧ず鐨勫悕瀛� btnHome.Text = ResidenceName; + info.Name = ResidenceName; } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs index 1f4abf5..6969e15 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs @@ -214,16 +214,16 @@ frameEmail.BackgroundColor = UserCenterColor.Current.White; frameEmail.Y = framType.Bottom + Application.GetRealHeight(23); bodyFrameLayout.AddChidren(frameEmail); - //閭鍦板潃 - var btnEmail = new NormalViewControl(220, 60, true); - btnEmail.X = ControlCommonResourse.XXLeft; - btnEmail.Gravity = Gravity.CenterVertical; - btnEmail.TextID = R.MyInternationalizationString.uEmailAddress; - frameEmail.AddChidren(btnEmail); - var txtEmail = new TextInputControl(500, 60, true); + //鑱旂郴鏂瑰紡 + var btnContact = new NormalViewControl(220, 60, true); + btnContact.X = ControlCommonResourse.XXLeft; + btnContact.Gravity = Gravity.CenterVertical; + btnContact.TextID = R.MyInternationalizationString.uContactInformation; + frameEmail.AddChidren(btnContact); + var txtEmail = new TextInputControl(720, 60, true); txtEmail.X = Application.GetRealWidth(314); txtEmail.Gravity = Gravity.CenterVertical; - txtEmail.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputYouEmailAddress); + txtEmail.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputYourContactInformation); frameEmail.AddChidren(txtEmail); //鎻愪氦 diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs index 4fa2c8c..9a4ac4b 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs @@ -428,6 +428,12 @@ //寮哄埗璺宠浆缃戝叧鐣岄潰 UserCenterResourse.HideOption.GotoGatewayProductInfoForm = 1; } + if (textValue == "abcdef1") + { + //寮哄埗鍙樻洿甯稿紑妯″紡鐨勬椂闂翠负鍒嗛挓 + UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode = 1; + } + this.ShowMassage(ShowMsgType.Tip, "Ok!"); }); } diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs index 562405e..5b956bf 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs @@ -8,112 +8,6 @@ public class BindObj : CommonDevice { #region 璁惧缁戝畾 - /// <summary> - ///璁惧缁戝畾 - /// </summary> - public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData) - { - return await System.Threading.Tasks.Task.Run(async () => - { - AddedDeviceBindResponseAllData result = null; - var mainGateway = ZbGateway.MainGateWay; - if (mainGateway == null) - { - result = new AddedDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - return result; - } - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - } - else - { - result.errorResponData = temp; - result.errorMessageBase = ErrorMess(temp.Error); - } - } - else if (topic == gatewayID + "/" + "Bind/SetBind_Respon") - { - var tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AddedDeviceBindResponseData>(jobject["Data"].ToString()); - if (tempResult == null) - { - result = new AddedDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - result = new AddedDeviceBindResponseAllData { addedDeviceBindResponseData = tempResult }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}"); - } - } - }; - mainGateway.Actions += action; - DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond); - try - { - if (addBindData != null) - { - var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } }; - var bindList = new JArray { }; - foreach (var bindInfo in addBindData.BindList) - { - if (bindInfo.BindType == 0) - { - var dInfo = new JObject{ - { "BindMacAddr",bindInfo.BindMacAddr}, - { "BindEpoint", bindInfo.BindEpoint} , - { "BindCluster", bindInfo.BindCluster} , - { "BindType",bindInfo.BindType} - }; - bindList.Add(dInfo); - } - else if (bindInfo.BindType == 1) - { - var dInfo = new JObject{ - { "BindCluster", bindInfo.BindCluster} , - { "BindType",bindInfo.BindType}, - { "BindScenesId", bindInfo.BindScenesId} - }; - bindList.Add(dInfo); - } - } - var data = new JObject{ - {"BindName",addBindData.BindName}, - { "BindList", bindList } - }; - jObject.Add("Data", data); - mainGateway.Send("Bind/SetBind", jObject.ToString()); - } - } - catch - { - } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 20 * 1000) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > 20 * 1000) - { - result = new AddedDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - mainGateway.Actions -= action; - System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� { System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond}"); - return result; - }); - } [System.Serializable] public class AddedDeviceBindResponseAllData : ErrorResponCommon @@ -122,10 +16,6 @@ /// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅 /// </summary> public AddedDeviceBindResponseData addedDeviceBindResponseData; - /// <summary> - /// 鎸夐敭璁惧鐨勭‘璁ゅ弽棣堢粦瀹氳澶囦俊鎭� - /// </summary> - public AddBindResultResponseData addBindResultResponseData; } [System.Serializable] @@ -253,267 +143,7 @@ #endregion #region 瑙i櫎缁戝畾 - /// <summary> - /// 瑙i櫎缁戝畾 - /// </summary> - //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData) - //{ - // return await System.Threading.Tasks.Task.Run(async () => - // { - // DelDeviceBindResponseAllData responseData = null; - // var mainGateway = ZbGateway.MainGateWay; - // if (mainGateway == null) - // { - // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - // } - - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - // } - // else - // { - // responseData = new DelDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - // } - // } - // //鍦烘櫙绉婚櫎 - // if (topic == gatewayID + "/" + "Bind/RemoveBind_Respon") - // { - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<DelDeviceBindResponseData>(jobject["Data"].ToString()); - - // if (tempData == null) - // { - // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - // } - // else - // { - // responseData = new DelDeviceBindResponseAllData { delDeviceBindResponseData = tempData }; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // //璁惧绉婚櫎 - // if (topic == gatewayID + "/" + "Bind/RemoveBindResult") - // { - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString()); - - // if (tempData != null) - // { - // responseData = new DelDeviceBindResponseAllData { removeBindResultResponseData = tempData }; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // }; - // mainGateway.Actions += action; - // System.Console.WriteLine("DeviceBind/DelBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - // try - // { - // if (delDeviceBindData != null) - // { - // var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } }; - // var removeBindList = new JArray { }; - // foreach (var removeBindInfo in delDeviceBindData.RemoveBindList) - // { - // if (removeBindInfo.BindType == 0) - // { - // var dInfo = new JObject{ - // { "BindMacAddr",removeBindInfo.BindMacAddr}, - // { "BindEpoint", removeBindInfo.BindEpoint} , - // { "BindCluster", removeBindInfo.BindCluster} , - // { "BindType",removeBindInfo.BindType} - // }; - // removeBindList.Add(dInfo); - // } - // else if (removeBindInfo.BindType == 1) - // { - // var dInfo = new JObject{ - // { "BindCluster", removeBindInfo.BindCluster} , - // { "BindType",removeBindInfo.BindType}, - // { "BindScenesId", removeBindInfo.BindScenesId} - // }; - // removeBindList.Add(dInfo); - // } - // } - // var data = new JObject { - // {"RemoveBindList",removeBindList} - // }; - // jObject.Add("Data", data); - // mainGateway.Send("Bind/RemoveBind", jObject.ToString()); - // } - // } - // catch { } - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (responseData != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // responseData = new DelDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - // } - // mainGateway.Actions -= action; - // System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - // return responseData; - // }); - //} - - //涔嬪墠2绉嶆柟寮忓弽棣堢粨鏋� - public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData) - { - return await System.Threading.Tasks.Task.Run(async () => - { - var responseData = new DelDeviceBindResponseAllData(); - var mainGateway = ZbGateway.MainGateWay; - if (mainGateway == null) - { - responseData.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�"; - return responseData; - } - - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - responseData.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - } - else - { - responseData.errorResponData = temp; - responseData.errorMessageBase = ErrorMess(temp.Error); - } - } - - if (topic == gatewayID + "/" + "Bind/RemoveBind_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<DelDeviceBindResponseData>(jobject["Data"].ToString()); - - if (tempData == null) - { - responseData.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�"; - - } - else - { - responseData.delDeviceBindResponseData = tempData; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - - if (topic == gatewayID + "/" + "Bind/RemoveBindResult") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString()); - - if (tempData != null) - { - responseData.removeBindResultResponseData = tempData; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - mainGateway.Actions += action; - System.Console.WriteLine("DeviceBind/DelBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - if (delDeviceBindData != null) - { - var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } }; - var removeBindList = new JArray { }; - foreach (var removeBindInfo in delDeviceBindData.RemoveBindList) - { - if (removeBindInfo.BindType == 0) - { - var dInfo = new JObject{ - { "BindMacAddr",removeBindInfo.BindMacAddr}, - { "BindEpoint", removeBindInfo.BindEpoint} , - { "BindCluster", removeBindInfo.BindCluster} , - { "BindType",removeBindInfo.BindType} - }; - removeBindList.Add(dInfo); - } - else if (removeBindInfo.BindType == 1) - { - var dInfo = new JObject{ - { "BindCluster", removeBindInfo.BindCluster} , - { "BindType",removeBindInfo.BindType}, - { "BindScenesId", removeBindInfo.BindScenesId} - }; - removeBindList.Add(dInfo); - } - } - var data = new JObject { - {"RemoveBindList",removeBindList} - }; - jObject.Add("Data", data); - //ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID; - mainGateway.Send("Bind/RemoveBind", jObject.ToString()); - } - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(100); - if (responseData == null || responseData.delDeviceBindResponseData == null) - { - continue; - } - if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 1).Count) - { - if (responseData.removeBindResultResponseData != null) - { - break; - } - } - else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count) - { - if (responseData.removeBindResultResponseData != null) - { - break; - } - } - else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count) - { - if (responseData.removeBindResultResponseData != null) - { - break; - } - } - else - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - responseData.errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔"; - } - mainGateway.Actions -= action; - System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - return responseData; - }); - } - + /// <summary> ///瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅 /// </summary> @@ -644,84 +274,6 @@ #endregion #region 锛堜粠缃戝叧涓級鑾峰彇鎵�鏈夌粦瀹� - /// <summary> - ///鑾峰彇鎵�鏈夌粦瀹� - /// </summary> - public async System.Threading.Tasks.Task<GetDeviceBindResponseAllData> GetDeviceBindAsync() - { - return await System.Threading.Tasks.Task.Run(async () => - { - GetDeviceBindResponseAllData d = null; - var mainGateway = ZbGateway.MainGateWay; - if (mainGateway == null) - { - d = new GetDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - return d; - } - - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new GetDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "Bind/GetDeviceBind_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceBindResponseData>(jobject["Data"].ToString()); - //var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString()); - if (tempData == null) - { - d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new GetDeviceBindResponseAllData { getAllBindResponseData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - mainGateway.Actions += action; - - try - { - System.Console.WriteLine("Bind/GetDeviceBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } }; - mainGateway.Send("Bind/GetDeviceBind", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new GetDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - mainGateway.Actions -= action; - System.Console.WriteLine("Bind/GetDeviceBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } /// <summary> ///鑾峰彇鎵�鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅 @@ -788,84 +340,6 @@ #endregion #region 浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭� - /// <summary> - ///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭� - /// </summary> - public async System.Threading.Tasks.Task<GetDeviceLocalBindResponseAllData> GetDeviceLocalBindAsync(int startIndex = 0) - { - return await System.Threading.Tasks.Task.Run(async () => - { - GetDeviceLocalBindResponseAllData d = null; - var mainGateway = ZbGateway.MainGateWay; - if (mainGateway == null) - { - d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - return d; - } - - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new GetDeviceLocalBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "Bind/GetDeviceLocalBind_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceLocalBindResponseData>(jobject["Data"].ToString()); - if (tempData == null) - { - d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new GetDeviceLocalBindResponseAllData { getDeviceLocalBindResponseData = tempData }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - mainGateway.Actions += action; - - try - { - DebugPrintLog("Bind/GetDeviceLocalBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Cluster_ID", 0 }, { "Command", 5008 } }; - var data = new JObject { { "StartIndex", startIndex } }; - mainGateway.Send("Bind/GetDeviceLocalBind", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new GetDeviceLocalBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - mainGateway.Actions -= action; - DebugPrintLog("Bind/GetDeviceLocalBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } /// <summary> ///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭洖澶嶇殑鏁版嵁,缃戝叧鍙嶉淇℃伅 @@ -943,81 +417,6 @@ #endregion #region 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭� - /// <summary> - ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭� - /// </summary> - public async System.Threading.Tasks.Task<ClearBindInfoResponseAllData> ClearBindInfoAsync() - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - ClearBindInfoResponseAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new ClearBindInfoResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "Bind/ClearBindInfo_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClearBindInfoResponseData>(jobject["Data"].ToString()); - if (tempData == null) - { - d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - Gateway.Actions += action; - DebugPrintLog("Bind/ClearBindInfo_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - - try - { - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } }; - Gateway.Send("Bind/ClearBindInfo", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 25 * 1000) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - //涓�閿竻闄ょ洰鏍囷紝浼氬洜涓虹洰鏍囨暟閲忓鑰屽姞闀挎椂闂达紝鐩墠鏆傚畾20绉� - if ((DateTime.Now - dateTime).TotalMilliseconds > 25 * 1000) - { - d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - DebugPrintLog("Bind/ClearBindInfo_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } /// <summary> ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅 diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs index 1c52a82..cda2d6e 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs @@ -748,80 +748,6 @@ #endregion #region 淇敼璁惧绔彛鍚嶇О - ///<summary > - /// 淇敼璁惧绔彛锛堟寜閿級鍚嶇О - /// <para>Gateway:璁惧鎵�灞炵綉鍏筹紙璋冪敤鏂规硶锛歞evice.Gateway)</para> - /// <para>deviceName:鎸夐敭鍚嶇О</para> - /// </summary> - public async System.Threading.Tasks.Task<DeviceRenameAllData> RenameDeviceNameAsync(string deviceAddr, int deviceEpoint, string deviceName) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - DeviceRenameAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new DeviceRenameAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "DeviceRenameRespon") - { - var receiptData = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceRenameResponseData>(jobject["Data"].ToString()); - d = new DeviceRenameAllData { deviceRenameData = receiptData }; - } - }; - Gateway.Actions += action; - System.Console.WriteLine("DeviceRename_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - var bytes = new byte[64]; - var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName); - System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); - deviceName = Encoding.UTF8.GetString(bytes); - - var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } }; - var data = new JObject { { "DeviceName", deviceName } }; - jObject.Add("Data", data); - Gateway?.Send(("DeviceRename"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new DeviceRenameAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - - Gateway.Actions -= action; - System.Console.WriteLine("DeviceRename_Actions閫�鍑�" + System.DateTime.Now.ToString()); - return d; - }); - } /// <summary> /// 閲嶅懡鍚嶈澶�,缃戝叧鍙嶉鍏蜂綋淇℃伅 @@ -863,80 +789,6 @@ #endregion #region 淇敼璁惧mac鍚嶇О - ///<summary > - /// 淇敼璁惧mac鍚嶇О - /// <para>macName:璁惧鍚嶇О</para> - /// </summary> - public async System.Threading.Tasks.Task<RenameDeviceMacNameAllData> RenameDeviceMacNameAsync(string deviceAddr, int deviceEpoint, string macName) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - RenameDeviceMacNameAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new RenameDeviceMacNameAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "MacRename_Respon") - { - var deviceID = jobject.Value<int>("Device_ID"); - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) }; - } - }; - Gateway.Actions += action; - System.Console.WriteLine("MacRename_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - var bytes = new byte[64]; - var reamarkGwBytes = Encoding.UTF8.GetBytes(macName); - System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); - macName = Encoding.UTF8.GetString(bytes); - - var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } }; - var data = new JObject { { "MacName", macName } }; - jObject.Add("Data", data); - Gateway?.Send(("MacRename"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - - Gateway.Actions -= action; - System.Console.WriteLine("MacRename_Action閫�鍑�" + System.DateTime.Now.ToString()); - return d; - }); - } /// <summary> /// 淇敼璁惧mac鍚嶇О鏁版嵁,缃戝叧鍙嶉鍏蜂綋淇℃伅 diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/IASZone.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/IASZone.cs index 726efe2..38aaeca 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/IASZone.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/IASZone.cs @@ -235,104 +235,6 @@ #endregion #region PIR浼犳劅鍣ㄥ弬鏁伴厤缃� - ///<summary > - ///PIR浼犳劅鍣ㄥ弬鏁伴厤缃� - /// </summary> - public async System.Threading.Tasks.Task<ResponseAllData> SetPIRSensorParamateAsync(ConfigureParamates configureParamates) - { - ResponseAllData result = null; - if (Gateway == null) - { - result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 16) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0002") - { - var tempD = new ResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); - tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); - if (tempD.command == "0300") - { - result = new ResponseAllData { responseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0300_{ topic}"); - } - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SetPIRSensorData(configureParamates); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } /// <summary> /// PIR閰嶇疆鍙傛暟鍥炲 @@ -408,314 +310,6 @@ public int dimmerLevel = 0; } - /// <summary> - /// 閰嶇疆PIR閰嶇疆鍙傛暟 - /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para> - /// </summary> - string SetPIRSensorData(ConfigureParamates configureParamates) - { - string data = ""; - string dataLength = "10"; - string dataComand1 = "00"; - string dataComand2 = "03"; - string dataSerialNum = "01"; - string addDataLength = "0C"; - string levelEnable = ""; - string levelSize = ""; - string controlDevEnable = ""; - string transitionTime = ""; - string iasReportPeriod = ""; - string mode = ""; - string type = ""; - string dimmerOnTime = ""; - string dimmerOffTime = ""; - string dimmerLevel = ""; - try - { - if (configureParamates != null) - { - //levelEnable - if (configureParamates.levelEnable) - { - levelEnable = "01"; - } - else - { - levelEnable = "00"; - } - //鍏夌収绛夌骇 - if (configureParamates.levelSize > 0) - { - var tempLevelEnable = Convert.ToString(configureParamates.levelSize, 16); - levelSize = tempLevelEnable.ToString().PadLeft(2, '0'); - } - else - { - levelSize = "00"; - } - //controlDevEnable - if (configureParamates.controlDevEnable) - { - controlDevEnable = "01"; - } - else - { - controlDevEnable = "00"; - } - //transitionTime,iasReportPeriod - for (int j = 0; j < 2; j++) - { - var tempBytes = new byte[2]; - if (j == 0) - { - for (int i = 0; i < 2; i++) - { - tempBytes[i] = (byte)(configureParamates.transitionTime >> (i * 8) & 0xff); - } - } - else - { - for (int i = 0; i < 2; i++) - { - tempBytes[i] = (byte)(configureParamates.iasReportPeriod >> (i * 8) & 0xff); - } - } - var time1 = Convert.ToString(tempBytes[0], 16); - var time2 = Convert.ToString(tempBytes[1], 16); - if (time1.Length == 1) - { - time1 = "0" + time1; - } - if (time2.Length == 1) - { - time2 = "0" + time2; - } - if (j == 0) - { - transitionTime = (time1 + time2).ToUpper(); - - } - else - { - iasReportPeriod = (time1 + time2).ToUpper(); - } - } - //mode - if (configureParamates.mode == 1) - { - mode = "01"; - } - else - { - mode = "00"; - } - //type - if (configureParamates.type == 1) - { - type = "01"; - } - else - { - type = "00"; - } - //dimmerOnTime - if (configureParamates.dimmerOnTime > 0) - { - var tempDimmerOnTime = Convert.ToString(configureParamates.dimmerOnTime, 16); - dimmerOnTime = tempDimmerOnTime.ToString().PadLeft(2, '0'); - } - else - { - dimmerOnTime = "00"; - } - dimmerOnTime = dimmerOnTime.ToUpper(); - if (configureParamates.dimmerOffTime > 0) - { - var tempDimmerOffTime = Convert.ToString(configureParamates.dimmerOffTime, 16); - dimmerOffTime = tempDimmerOffTime.ToString().PadLeft(2, '0'); - } - else - { - dimmerOffTime = "00"; - } - dimmerOffTime = dimmerOffTime.ToUpper(); - //dimmerLevel - string temp = ""; - var sbString = new System.Text.StringBuilder(); - string temp2 = Convert.ToString(configureParamates.dimmerLevel, 16); - switch (temp2.Length) - { - case 1: - temp = "0" + temp2; - break; - case 2: - temp = temp2; - break; - } - sbString.Append(temp.ToUpper()); - - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - levelEnable + levelSize + controlDevEnable + transitionTime + iasReportPeriod - + mode + type + dimmerOnTime + dimmerOffTime + sbString; - } - } - catch { }; - - return data; - } - #endregion - - #region 鑾峰彇PIR閰嶇疆鏁版嵁 - ///<summary > - ///PIR浼犳劅鍣ㄥ弬鏁伴厤缃� - /// <para>reserve:0-ff</para> - /// </summary> - public async System.Threading.Tasks.Task<ParamatesInfo> GetPIRSensorParamateAsync(string reserve = "01") - { - ParamatesInfo result = null; - if (Gateway == null) - { - result = new ParamatesInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new ParamatesInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new ParamatesInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new ParamatesInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 34) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0302") - { - var le = data[10].ToString() + data[11].ToString(); - var tempD = new ConfigureParamates(); - - if (le == "01") - { - tempD.levelEnable = true; - } - else - { - tempD.levelEnable = false; - } - - var size = data[12].ToString() + data[13].ToString(); - tempD.levelSize = Convert.ToInt32(size, 16); - - var cdl = data[14].ToString() + data[15].ToString(); - if (cdl == "01") - { - tempD.controlDevEnable = true; - } - else - { - tempD.controlDevEnable = false; - } - tempD.transitionTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16); - tempD.iasReportPeriod = Convert.ToInt32(data[22].ToString() + data[23].ToString() + data[20].ToString() + data[21].ToString(), 16); - tempD.mode = Convert.ToInt32(data[24].ToString() + data[25].ToString(), 16); - tempD.type = Convert.ToInt32(data[26].ToString() + data[27].ToString(), 16); - tempD.dimmerOnTime = Convert.ToInt32(data[28].ToString() + data[29].ToString(), 16); - tempD.dimmerOffTime = Convert.ToInt32(data[30].ToString() + data[31].ToString(), 16); - tempD.dimmerLevel = Convert.ToInt32(data[32].ToString() + data[33].ToString(), 16); - - result = new ParamatesInfo { configureParamates = tempD }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0301_{ topic}"); - - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = GetPIRSensorData(reserve); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new ParamatesInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - ///PIR鍏夌収鑳藉姏鍊� - /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para> - /// </summary> - string GetPIRSensorData(string reserve) - { - string data = ""; - string dataLength = "05"; - string dataComand1 = "01"; - string dataComand2 = "03"; - string dataSerialNum = "01"; - string addDataLength = "01"; - string reserveData = reserve; - - try - { - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - reserveData; - } - catch { }; - - return data; - } #endregion #region 鑾峰彇PIR lux鍊硷紙Lux鍊硷級 diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs index 360323a..d9fc339 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs @@ -819,103 +819,6 @@ #endregion #region 閰嶇疆鎸夐敭鎸囩ず鐏鑹�. - ///<summary > - ///閰嶇疆鎸夐敭鎸囩ず鐏鑹� - /// </summary> - public async System.Threading.Tasks.Task<ResponseAllData> SetPanelColorInfoAsync(KeyColorData keyColorData, KeyNumStatus keyNumStatus) - { - ResponseAllData result = null; - if (Gateway == null) - { - result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 16) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0002") - { - var tempD = new ResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); - tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); - if (tempD.command == "0401") - { - result = new ResponseAllData { responseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0401_{ topic}"); - } - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SetPanelColorData(keyColorData, keyNumStatus); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } /// <summary> /// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 @@ -936,132 +839,6 @@ /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭� /// </summary> public KeyColorData keyColorData; - } - - /// <summary> - /// 閰嶇疆鎸夐敭鎸囩ず鐏鑹叉暟鎹� - /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para> - /// </summary> - /// <returns>The passthorugh data.</returns> - /// <param name="keyColorData">Key color data.</param> - /// <param name="keyNum">Key number.</param> - string SetPanelColorData(KeyColorData keyColorData, KeyNumStatus keyNumStatus) - { - string data = ""; - string dataLength = "0c"; - string dataComand1 = "01"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "08"; - int attributeData = 0; - - try - { - for (int i = 1; i <= 16; i++) - { - Type type = keyNumStatus.GetType(); - var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null); - int value0 = 0; - if (Convert.ToBoolean(obj) == true) - { - value0 = 1; - } - int v = (int)Math.Pow(2, i - 1); - attributeData += value0 * v; - } - - string td = attributeData.ToString("X4"); - char[] td1 = td.ToCharArray(); - string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); - string temp = ""; - var tempColor1 = keyColorData.OpenColorR.ToString(); - var sbString1 = new System.Text.StringBuilder(); - switch (tempColor1.Length) - { - case 1: - temp = "0" + tempColor1; - break; - case 2: - temp = tempColor1; - break; - } - sbString1.Append(temp.ToUpper()); - - var tempColor2 = keyColorData.OpenColorG.ToString(); - var sbString2 = new System.Text.StringBuilder(); - switch (tempColor2.Length) - { - case 1: - temp = "0" + tempColor2; - break; - case 2: - temp = tempColor2; - break; - } - sbString2.Append(temp.ToUpper()); - - var tempColor3 = keyColorData.OpenColorB.ToString(); - var sbString3 = new System.Text.StringBuilder(); - switch (tempColor3.Length) - { - case 1: - temp = "0" + tempColor3; - break; - case 2: - temp = tempColor3; - break; - } - sbString3.Append(temp.ToUpper()); - - var tempColor4 = keyColorData.CloseColorR.ToString(); - var sbString4 = new System.Text.StringBuilder(); - switch (tempColor3.Length) - { - case 1: - temp = "0" + tempColor4; - break; - case 2: - temp = tempColor4; - break; - } - sbString4.Append(temp.ToUpper()); - - var tempColor5 = keyColorData.CloseColorG.ToString(); - var sbString5 = new System.Text.StringBuilder(); - switch (tempColor5.Length) - { - case 1: - temp = "0" + tempColor5; - break; - case 2: - temp = tempColor5; - break; - } - sbString5.Append(temp.ToUpper()); - - var tempColor6 = keyColorData.CloseColorB.ToString(); - var sbString6 = new System.Text.StringBuilder(); - switch (tempColor6.Length) - { - case 1: - temp = "0" + tempColor6; - break; - case 2: - temp = tempColor6; - break; - } - sbString6.Append(temp.ToUpper()); - - if (keyColorData != null) - { - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - tempAttributeData + sbString1 + sbString2 + sbString3 + - sbString4 + sbString5 + sbString6; - } - } - catch { }; - - return data; } // <summary> @@ -1185,330 +962,6 @@ /// true:寮� /// </summary> public bool Key16; - } - #endregion - - #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�. - ///<summary > - ///閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬� - /// <para>directionsLevel:鎸囩ず鐏寒搴� 0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</para> - /// <para>backlightLevel:鑳屽厜鐏寒搴� 0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</para> - /// </summary> - public async System.Threading.Tasks.Task<ResponseAllData> SetKeyLevelAsync(int directionsLevel, int backlightLevel) - { - ResponseAllData result = null; - if (Gateway == null) - { - result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 16) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0002") - { - var tempD = new ResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); - tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); - if (tempD.command == "0402") - { - result = new ResponseAllData { responseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}"); - } - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SetPanelLevelData(directionsLevel, backlightLevel); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - /// 鎺у埗鎸夐敭鎸囩ず鐏� - /// </summary> - string SetPanelLevelData(int level1, int level2) - { - string data = ""; - string dataLength = "06"; - string dataComand1 = "02"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "02"; - string l1 = ""; - string l2 = ""; - try - { - var sbString1 = new System.Text.StringBuilder(); - var sbString2 = new System.Text.StringBuilder(); - string temp1 = Convert.ToString(level1, 16); - string temp2 = Convert.ToString(level2, 16); - - switch (temp1.Length) - { - case 1: - l1 = "0" + temp1; - break; - case 2: - l1 = temp1; - break; - } - switch (temp2.Length) - { - case 1: - l2 = "0" + temp2; - break; - case 2: - l2 = temp2; - break; - } - sbString1.Append(l1.ToString().ToUpper()); - sbString2.Append(l2.ToString().ToUpper()); - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - sbString1 + sbString2; - } - catch { }; - - return data; - } - #endregion - - #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�. - ///<summary > - /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮� - /// <para>modeEnable:鑺傝兘妯″紡浣胯兘</para> - /// <para>modeTime:鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-ffff</para> - /// <para>鑺傝兘妯″紡浜害:0-100</para> - /// </summary> - public async System.Threading.Tasks.Task<ResponseAllData> SetKeyModeAsync(bool modeEnable, int modeTime, int level) - { - ResponseAllData result = null; - if (Gateway == null) - { - result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 16) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0002") - { - var tempD = new ResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); - tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); - if (tempD.command == "0403") - { - result = new ResponseAllData { responseData = tempD }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0403_{ topic}"); - } - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SetPanelModeModeData(modeEnable, modeTime, level); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮� - /// </summary> - string SetPanelModeModeData(bool modeEnable, int modeTime, int modelevel) - { - string data = ""; - string dataLength = "08"; - string dataComand1 = "03"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "04"; - string mode = ""; - string time = ""; - string level = ""; - try - { - if (modeEnable) - { - mode = "01"; - } - else - { - mode = "00"; - } - - if (modeTime == -1) - { - //褰撹妭鑳芥ā寮忔病鏈夌粰鏃堕棿锛岄粯璁ょ粰60绉� - modeTime = 60; - } - - var tempBytes = new byte[2]; - for (int i = 0; i < 2; i++) - { - tempBytes[i] = (byte)(modeTime >> (i * 8) & 0xff); - } - var time1 = Convert.ToString(tempBytes[0], 16); - var time2 = Convert.ToString(tempBytes[1], 16); - if (time1.Length == 1) - { - time1 = "0" + time1; - } - if (time2.Length == 1) - { - time2 = "0" + time2; - } - - time = (time1 + time2).ToUpper(); - - var sbString2 = new System.Text.StringBuilder(); - string temp2 = Convert.ToString(modelevel, 16); - switch (temp2.Length) - { - case 1: - level = "0" + temp2; - break; - case 2: - level = temp2; - break; - } - - sbString2.Append(level.ToUpper()); - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - mode + time + sbString2; - } - catch { }; - - return data; } #endregion @@ -1649,230 +1102,6 @@ #endregion #region 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�. - ///<summary > - ///鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�. - /// </summary> - public async System.Threading.Tasks.Task<KeyColorDataResponseAllData> GetPanelColorInfoAsync(KeyNum keyNum) - { - KeyColorDataResponseAllData result = null; - if (Gateway == null) - { - result = new KeyColorDataResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new KeyColorDataResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new KeyColorDataResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new KeyColorDataResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 24) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0405") - { - var key1 = data[10] + data[11]; - var key = data[10].ToString() + data[11].ToString(); - var tempR = new KeyColorData(); - tempR.OpenColorR = data[12].ToString() + data[13].ToString(); ; - tempR.OpenColorG = data[14].ToString() + data[15].ToString(); ; - tempR.OpenColorB = data[16].ToString() + data[17].ToString(); ; - tempR.CloseColorR = data[18].ToString() + data[19].ToString(); ; - tempR.CloseColorG = data[20].ToString() + data[21].ToString(); ; - tempR.CloseColorB = data[22].ToString() + data[23].ToString(); ; - - switch (key) - { - case "01": - tempR.keyNum = KeyNum.Key1; - break; - case "02": - tempR.keyNum = KeyNum.Key2; - break; - case "03": - tempR.keyNum = KeyNum.Key3; - break; - case "04": - tempR.keyNum = KeyNum.Key4; - break; - case "05": - tempR.keyNum = KeyNum.Key5; - break; - case "06": - tempR.keyNum = KeyNum.Key6; - break; - case "07": - tempR.keyNum = KeyNum.Key7; - break; - case "08": - tempR.keyNum = KeyNum.Key8; - break; - case "09": - tempR.keyNum = KeyNum.Key9; - break; - case "0a": - tempR.keyNum = KeyNum.Key10; - break; - case "0b": - tempR.keyNum = KeyNum.Key11; - break; - case "0c": - tempR.keyNum = KeyNum.Key12; - break; - case "0d": - tempR.keyNum = KeyNum.Key13; - break; - case "0e": - tempR.keyNum = KeyNum.Key14; - break; - case "0f": - tempR.keyNum = KeyNum.Key15; - break; - } - result = new KeyColorDataResponseAllData { keyColorData = tempR }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0404_{ topic}"); - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = GetkeyColorData(keyNum); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new KeyColorDataResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - /// 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹� - /// </summary> - string GetkeyColorData(KeyNum keyNum) - { - string data = ""; - string dataLength = "05"; - string dataComand1 = "04"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "01"; - string kNum = ""; - - try - { - switch (keyNum) - { - case KeyNum.Key1: - kNum = "01"; - break; - case KeyNum.Key2: - kNum = "02"; - break; - case KeyNum.Key3: - kNum = "03"; - break; - case KeyNum.Key4: - kNum = "04"; - break; - case KeyNum.Key5: - kNum = "05"; - break; - case KeyNum.Key6: - kNum = "06"; - break; - case KeyNum.Key7: - kNum = "07"; - break; - case KeyNum.Key8: - kNum = "08"; - break; - case KeyNum.Key9: - kNum = "09"; - break; - case KeyNum.Key10: - kNum = "0A"; - break; - case KeyNum.Key11: - kNum = "0B"; - break; - case KeyNum.Key12: - kNum = "0C"; - break; - case KeyNum.Key13: - kNum = "0D"; - break; - case KeyNum.Key14: - kNum = "0E"; - break; - case KeyNum.Key15: - kNum = "0F"; - break; - case KeyNum.Key16: - kNum = "10"; - break; - } - - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + kNum; - } - catch { }; - - return data; - } /// <summary> /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭搴旈『搴忓彿(鐫$湢缁勫彿) @@ -1899,124 +1128,6 @@ #endregion #region 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃�. - ///<summary > - ///鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃� - /// </summary> - public async System.Threading.Tasks.Task<PanelSwitchLevelInfo> GetPanelSwitchLevelAsync(string reserve = "01") - { - PanelSwitchLevelInfo result = null; - if (Gateway == null) - { - result = new PanelSwitchLevelInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new PanelSwitchLevelInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new PanelSwitchLevelInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new PanelSwitchLevelInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 14) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0407") - { - var level1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16); - var level2 = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16); - result = new PanelSwitchLevelInfo { panelDirectionsLevel = level1, panelBacklightLevel = level2 }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0406_{ topic}"); - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SendPanelSwitchLevelData(reserve); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - result = new PanelSwitchLevelInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - /// 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃暟鎹� - /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para> - /// </summary> - string SendPanelSwitchLevelData(string reserve) - { - string data = ""; - string dataLength = "05"; - string dataComand1 = "06"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "01"; - string reserveData = reserve; - - try - { - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - reserveData; - } - catch { }; - - return data; - } /// <summary> /// 鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃洖澶� @@ -2046,132 +1157,6 @@ #endregion #region 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵��. - ///<summary > - ///鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�� - /// </summary> - public async System.Threading.Tasks.Task<PanelSwitchLevelResponInfo> GetPanelSaveEnergyModeAsync(string reserve = "01") - { - PanelSwitchLevelResponInfo result = null; - if (Gateway == null) - { - result = new PanelSwitchLevelResponInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - return result; - } - return await System.Threading.Tasks.Task.Run(async () => - { - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - result = new PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - - else - { - result = new PanelSwitchLevelResponInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "ZbDataPassthrough") - { - var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - if (clientDataPassthroughResponseData == null) - { - result = new PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - if (clientDataPassthroughResponseData?.PassData != null) - { - var data = clientDataPassthroughResponseData.PassData; - if (data.Length == 18) - { - var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString(); - if (command == "0409") - { - var tempR = new PanelSaveEnergyModeInfo(); - if (data[10].ToString() + data[11].ToString() == "01") - { - tempR.enable = true; - } - else - { - tempR.enable = false; - } - tempR.time = Convert.ToInt32(data[14].ToString() + data[15].ToString() + data[12].ToString() + data[13].ToString(), 16); - tempR.level = Convert.ToInt32(data[16].ToString() + data[17].ToString(), 16); - result = new PanelSwitchLevelResponInfo { panelSaveEnergyModeInfo = tempR }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0408_{ topic}"); - } - } - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var passData = SendPanelSaveEnergyModeData(reserve); - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); - Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (result != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)// WaitReceiveDataTime) - { - result = new PanelSwitchLevelResponInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return result; - }); - } - - /// <summary> - /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹� - /// </summary> - string SendPanelSaveEnergyModeData(string reserve) - { - string data = ""; - string dataLength = "05"; - string dataComand1 = "08"; - string dataComand2 = "04"; - string dataSerialNum = "01"; - string addDataLength = "01"; - string reserveData = reserve; - - try - { - data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - reserveData; - } - catch { }; - - return data; - } /// <summary> /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹洖澶� @@ -2781,82 +1766,6 @@ #endregion #region 閰嶇疆闈㈡澘鍔熻兘 - ///<summary > - ///閰嶇疆闈㈡澘鍔熻兘 - ///<para>value:缁欓潰鏉块厤缃殑妯″紡</para> - /// </summary> - public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value, int clusterID = 6) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - SetWritableValueResponAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "SetWritableValue_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); - - if (tempData == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - Gateway.Actions += action; - System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } }; - var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } }; - jObject.Add("Data", data); - Gateway.Send("SetWritableValue", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - return d; - }); - } /// <summary> /// 閰嶇疆闈㈡澘鐨勫姛鑳芥ā寮� @@ -2939,115 +1848,6 @@ } #region 璇诲彇闈㈡澘鐨勯厤缃俊鎭� - /// <summary> - /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭� - /// </summary> - public async System.Threading.Tasks.Task<PanelConfigureInfoResponAllData> ReadPanelConfigureInfoAsync(params int[] args) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - PanelConfigureInfoResponAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0];//缃戝叧杩斿洖鐨勭綉鍏矷D - var reportStatus = topic.Split('/')[1];//涓婚涓鸿澶囦笂鎶ョ殑涓婚 - string addr = "";//涓婃姤鐨勮澶嘺ddr - string epoint = "";//涓婃姤鐨勮澶噀point - string cluID = "";//涓婃姤鐨勮澶嘽luID - string attrId = "";//涓婃姤鐨勮澶嘺ttrId - if (reportStatus == "DeviceStatusReport") - { - addr = topic.Split('/')[2]; - epoint = topic.Split('/')[3]; - cluID = topic.Split('/')[4]; - attrId = topic.Split('/')[5]; - } - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new PanelConfigureInfoResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - else if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + addr + "/" + epoint + "/" + cluID + "/" + attrId) - { - var deviceID = jobject.Value<int>("Device_ID"); - var deviceAddr = jobject.Value<string>("DeviceAddr"); - var tempEpoint = jobject.Value<int>("Epoint"); - var dataId = jobject.Value<int>("Data_ID"); - - if ((DeviceType)(deviceID) == DeviceType.OnOffSwitch) - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString()); - if (tempData == null) - { - d = new PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new PanelConfigureInfoResponAllData { deviceStatusReportData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - } - }; - - Gateway.Actions += action; - System.Console.WriteLine("GetDeviceStatus_Actions 鍚姩" + System.DateTime.Now.ToString()); - - try - { - var JObject = new JObject { - { "DeviceAddr",DeviceAddr }, - { "Epoint", DeviceEpoint }, - { "Cluster_ID", (int)Device.Cluster_ID.HdlKey }, - { "Command", 108 } - }; - var attriBute = new JArray{ - new JObject { - { "AttriButeId", (int)AttriButeId.HdlKey} - } - }; - var data = new JObject { { "AttriBute", attriBute } }; - JObject.Add("Data", data); - Gateway?.Send(("GetDeviceStatus"), JObject.ToString()); - } - catch - { - } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new PanelConfigureInfoResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("GetDeviceStatus_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } /// <summary> /// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁 diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs index 7a88bfd..c716216 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Rollershade.cs @@ -243,183 +243,6 @@ Gateway?.Send("DeviceControl", jObject.ToString()); } - #region 璁剧疆寮�鍚堝笜鐢垫満鏂瑰悜. - /// <summary> - /// 璁剧疆寮�鍚堝笜鐢垫満鏂瑰悜 - /// <para>isDirectionReversed (false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜锛�)</para> . - /// </summary> - public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetCurtainDirectionAsync(bool isDirectionReversed) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - SetWritableValueResponAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "SetWritableValue_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); - - if (tempData == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - Gateway.Actions += action; - System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - - try - { - int attributeData = 0; - int bit0 = 0; - if (isDirectionReversed) - { - bit0 = 1; - } - attributeData = bit0 * 1; - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } }; - var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } }; - jObject.Add("Data", data); - Gateway.Send("SetWritableValue", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } - #endregion - - #region 璁剧疆寮�鍚堝笜缁存姢妯″紡 - /// <summary> - /// 璁剧疆寮�鍚堝笜缁存姢妯″紡 - /// <para>isMotorMaintenance (fasle:鐢垫満杩愯浆姝e父锛泃rue:鐢垫満鍦ㄧ淮淇ā寮忎笅杩愯锛�)</para> - /// </summary> - public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetCurtianMaintenanceAsync(bool isMotorMaintenance) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - SetWritableValueResponAllData d = null; - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Error_Respon") - { - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); - - if (temp == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "SetWritableValue_Respon") - { - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); - - if (tempData == null) - { - d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - } - }; - Gateway.Actions += action; - System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - - try - { - int attributeData = 0; - int bit2 = 0; - - if (isMotorMaintenance) - { - bit2 = 1; - } - attributeData = bit2 * 4; - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 258 }, { "Command", 120 } }; - var data = new JObject { { "Undivided", 0 }, { "AttributeId", 23 }, { "AttributeDataType", 24 }, { "AttributeData", attributeData } }; - jObject.Add("Data", data); - Gateway.Send("SetWritableValue", jObject.ToString()); - } - catch { } - - var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - { - await System.Threading.Tasks.Task.Delay(10); - if (d != null) - { - break; - } - } - if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - { - d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - Gateway.Actions -= action; - System.Console.WriteLine("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return d; - }); - } - #endregion - #region 璁剧疆寮�鍚堝笜闄愪綅鍙傛暟. /// <summary> /// 璁剧疆寮�鍚堝笜涓婁笅闄愪綅 diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Scene.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Scene.cs index ad523d5..baa735d 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Scene.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Scene.cs @@ -330,7 +330,7 @@ /// 鑾峰彇鎵�鏈夊満鏅殑鎵�鏈変俊鎭� /// </summary> [System.Serializable] - public class GetSceneAllInfo:CommonDevice + public class GetSceneAllInfo { /// <summary> ///鍦烘櫙鎬绘暟 @@ -412,59 +412,6 @@ public int MemberNumber; } - #endregion - - #region 鑾峰彇鍦烘櫙鍒楄〃 - ///<summary > - ///鑾峰彇鍦烘櫙鍒楄〃 - ///</summary> - public static async System.Threading.Tasks.Task<List<GetSceneAllInfo>> GetSceneListAsync() - { - return await System.Threading.Tasks.Task.Run(async () => { - var dateTime = DateTime.Now; - GetSceneAllData d = null; - var mainGateway = ZbGateway.MainGateWay; - if (mainGateway == null) - { - d = new GetSceneAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - return null; - } - - var listScene = new List<GetSceneAllInfo>(); - Action<string, string> action = (topic, message) => - { - var gatewayID = topic.Split('/')[0]; - var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - if (topic == gatewayID + "/" + "Scene/GetAllInfo_Respon") - { - dateTime = DateTime.Now; - var sceneGetAllInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneAllInfo>(jobject["Data"].ToString()); - listScene.Add(sceneGetAllInfo); - - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - } - }; - mainGateway.Actions += action; - System.Console.WriteLine("Scene/GetAllInfo_Actions 鍚姩" + System.DateTime.Now.ToString()); - try - { - var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 807 } }; - mainGateway.Send(("Scene/GetAllInfo"),System.Text.Encoding.UTF8.GetBytes(jObject.ToString())); - } - catch { } - - while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) - { - await System.Threading.Tasks.Task.Delay(10); - } - - mainGateway.Actions -= action; - System.Console.WriteLine("Scene/GetAllInfo_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - return listScene; - }); - } #endregion #region 鍙兘鑾峰彇鍦烘櫙淇℃伅锛屾病鏈夊満鏅腑鐨勮澶囦俊鎭� @@ -1815,153 +1762,5 @@ public int ScenesId; } - - //public static string SceneFilePath = "SceneFile"; - - //static Scene() - //{ - // if (null == Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(SceneFilePath)))) - // { - // //鍒濆鍖栧満鏅垪琛� - // Shared.IO.FileUtils.WriteFileByBytes(SceneFilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(new List<string>()))); - // } - //} - - ///// <summary> - ///// 淇濆瓨褰撳墠鍦烘櫙 - ///// </summary> - ///// <param name="scenceFilePath">Scence file path.</param> - //public void Save(string scenceFilePath) - //{ - // Shared.IO.FileUtils.WriteFileByBytes(scenceFilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); - //} - - /// <summary> - /// 鏍规嵁鍦烘櫙璺緞鎭㈠鍦烘櫙瀵硅薄 - /// </summary> - /// <returns>The by file path.</returns> - /// <param name="sceneFilePath">Room file path.</param> - //public static Scene GetSceneByFilePath(string sceneFilePath) - //{ - // try - // { - // return Newtonsoft.Json.JsonConvert.DeserializeObject<Scene>(System.Text.Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(sceneFilePath))); - // } - // catch - // { - // return new Scene(); - // } - //} - - /// <summary> - /// 鍦烘櫙鏍囪瘑 - /// </summary> - //public bool SceneLabel = false; - - /// <summary> - /// 鎺у埗鐩爣鐨勬枃浠惰矾寰�,鏍煎紡濡傦細RoomScene_+DeviceID_Mac_Epoint - /// </summary> - //public readonly List<string> DeviceFilePathList = new List<string>(); - - /// <summary> - /// 鍦烘櫙鐨勮儗鏅浘 - /// </summary> - //public string BackgroundImagePath = "Scene/s1.png"; - - /// <summary> - /// 鍦烘櫙涓殑璁惧鍒楄〃 - /// </summary> - //[Newtonsoft.Json.JsonIgnore] - //public List<Scene> sceneDeviceList = new List<Scene>(); - - //[Newtonsoft.Json.JsonIgnore] - //public List<Scene> LocalSceneList = new List<Scene>(); - - //public SceneId SceneID; - - ///<summary > - /// 浠庣綉鍏崇殑鍦烘櫙涓Щ闄よ澶� - /// </summary> - //public static void SceneRemoveMember1(ZigBee.Device.ZbGateway gateway, int ScenesId, string DeviceAddr, int Epoint) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 802 } }; - // var DeviceList = new JArray - // { - // new JObject { - // { "Type", 0}, - // { "DeviceAddr",DeviceAddr}, - // { "Epoint",Epoint} - // } - // }; - // var data = new JObject { - // {"ScenesId",ScenesId}, - // { "DeviceList", DeviceList } - // }; - // jobject.Add("Data", data); - // gateway.Send(("Scene/RemoveMember"), Common.SecuritySet.Encryption((jobject.ToString()))); - - //} - - ///<summary > - /// 鍒犻櫎鍦烘櫙 - /// </summary> - //public static void SceneRemove1(ZigBee.Device.ZbGateway gateway, int scenesId) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 803 } }; - // var data = new JObject { { "ScenesId", scenesId } }; - // jobject.Add("Data", data); - // gateway.Send(("Scene/Remove"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} - - ///<summary > - /// 淇敼鍦烘櫙鍚嶇О - /// </summary> - //public static void SceneRename1(ZigBee.Device.ZbGateway gateway, int scenesId, string scenesName) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 804 } }; - // var data = new JObject { { "ScenesId", scenesId }, { "ScenesName", scenesName } }; - // jobject.Add("Data", data); - // gateway.Send(("Scene/Rename"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} - - ///<summary > - /// 鑾峰彇缃戝叧涓満鏅俊鎭� - /// </summary> - //public static void SceneGetInfo1(ZigBee.Device.ZbGateway gateway) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } }; - // gateway.Send(("Scene/GetInfo"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} - - ///<summary > - ///鑾峰彇缃戝叧涓満鏅殑璁惧鍒楄〃 - /// </summary> - //public static void SceneGetDeviceList1(ZigBee.Device.ZbGateway gateway, int ScenesId) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 806 } }; - // var data = new JObject { { "ScenesId", ScenesId } }; - // jobject.Add("Data", data); - // gateway.Send(("Scene/GetDeviceList"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} - - ///<summary > - /// 鑾峰彇鎵�鏈夊満鏅俊鎭紙鍖呮嫭鍦烘櫙璁惧鍒楄〃锛� - /// </summary> - //public static void SceneGetAllInfo1(ZigBee.Device.ZbGateway gateway) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 807 } }; - // gateway.Send(("Scene/GetAllInfo"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} - - ///<summary > - ///璋冪敤鍦烘櫙 - /// </summary> - //public static void SceneOpen1(ZigBee.Device.ZbGateway gateway, int ScenesId) - //{ - // var jobject = new JObject { { "Cluster_ID", 0 }, { "Command", 808 } }; - // var data = new JObject { { "ScenesId", ScenesId } }; - // jobject.Add("Data", data); - // gateway.Send(("Scene/Open"), Common.SecuritySet.Encryption((jobject.ToString()))); - //} } } diff --git a/ZigbeeApp/Shared/R.cs b/ZigbeeApp/Shared/R.cs index 952dad1..a78715a 100755 --- a/ZigbeeApp/Shared/R.cs +++ b/ZigbeeApp/Shared/R.cs @@ -5807,6 +5807,14 @@ /// DATA缁胯壊鎸囩ず鐏棯鐑� /// </summary> public const int uDataGreanPilotLampLinght = 16119; + /// <summary> + /// 鑱旂郴鏂瑰紡 + /// </summary> + public const int uContactInformation = 16120; + /// <summary> + /// 璇疯緭鍏ユ偍鐨勮仈绯绘柟寮� + /// </summary> + public const int uPleaseInputYourContactInformation = 16121; //鈽呪槄鈽呪槄涓嬮潰杩欎簺鏄帴鍙g殑杩斿洖淇℃伅缈昏瘧,浠�18000寮�濮嬧槄鈽呪槄鈽� diff --git a/ZigbeeApp/Shared/Shared.projitems b/ZigbeeApp/Shared/Shared.projitems index f55d5c5..f6b91c0 100755 --- a/ZigbeeApp/Shared/Shared.projitems +++ b/ZigbeeApp/Shared/Shared.projitems @@ -118,6 +118,8 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\Controls\SafetyShortcutControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\Controls\SceneCardControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\HomeMainPageForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\ModelData\DeviceModelDataLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\ModelData\ModelDataCommon.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Abount\AbountForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Abount\SLAForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Common\AccountOption.cs" /> @@ -151,6 +153,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlCheckLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlControlLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceAirConditionerLogic.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceCommonLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceCurtainLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceDoorLockLogic.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceOtherLogic.cs" /> @@ -284,7 +287,6 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\NormalSelectControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\NormalControls\DateSelectControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Logic\HdlDeviceUpdateLogic.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Common\GatewayBackupEnum.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\ClickButtonControls\NormalClickButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\DeviceInformationListControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\PswNumberInputControl.cs" /> -- Gitblit v1.8.0