From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 17 十二月 2020 09:07:13 +0800 Subject: [PATCH] 新云端Ver1.3 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 236 ++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 136 insertions(+), 100 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs index 4f509d2..665f4c4 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs @@ -61,7 +61,7 @@ /// <param name="i_listdevice">绐楀笜鐨勫洖璺�</param> public void ShowForm(Rollershade i_CurtainDevice) { - UserView.HomePage.Instance.ScrollEnabled = false; + this.ScrollEnabled = false; this.curtainDevice = i_CurtainDevice; @@ -99,6 +99,24 @@ listView.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listView); + //瀵艰建闀垮害涓�0鏃� + if (curtainData.CurtainLength <= 0) + { + //鐢垫満鏁版嵁寮傚父,纭宸茬粡瀹夎瀵艰建鍚�,璇烽噸缃數鏈� + this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain)); + try + { + //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛� + this.AddElectricalMachineryRow(); + return; + } + catch (Exception ex2) + { + HdlLogLogic.Current.WriteLog(ex2, "寮�鍚堝笜琛ユ晳寮傚父1"); + return; + } + } + try { //娣诲姞鏂瑰悜琛� @@ -114,13 +132,17 @@ catch (Exception ex) { //Log鍑哄姏 - string msg = "褰撳墠婵�娲荤殑鐣岄潰[" + UserCenterResourse.NowActionFormID + "]"; + string msg = "褰撳墠婵�娲荤殑鐣岄潰[" + HdlFormLogic.Current.NowActionFormID + "]"; HdlLogLogic.Current.WriteLog(ex, msg); - //鍑虹幇鏈煡閿欒 - this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError)); - this.listView.RemoveAll(); - //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛� - this.AddElectricalMachineryRow(); + //鐢垫満鏁版嵁寮傚父,纭宸茬粡瀹夎瀵艰建鍚�,璇烽噸缃數鏈� + this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain)); + try + { + this.listView.RemoveAll(); + //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛� + this.AddElectricalMachineryRow(); + } + catch (Exception ex2) { HdlLogLogic.Current.WriteLog(ex2, "寮�鍚堝笜琛ユ晳寮傚父2"); } } }); } @@ -154,11 +176,11 @@ listText.Add(Language.StringByID(R.MyInternationalizationString.uReverseDirection));//鍙嶅悜 var form = new BottomItemSelectForm(); - form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo); - form.FinishSelectEvent += async (index) => + form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, null, nowSelectNo); + 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; @@ -168,6 +190,11 @@ curtainData.Direction = index == 0 ? false : true; }; }; + //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + rowDirection.CanClick = false; + } } #endregion @@ -222,7 +249,7 @@ { //寮�闄愪綅 var btnProgressView = new NormalViewControl(200, 50, true); - btnProgressView.X = ControlCommonResourse.XXLeft; + btnProgressView.X = HdlControlResourse.XXLeft; btnProgressView.Y = Application.GetRealHeight(78); btnProgressView.TextSize = 12; btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; @@ -230,6 +257,8 @@ frameBack.AddChidren(btnProgressView); int progressValue = (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100); + //璁剧疆鐧惧垎姣旂殑鍒濆鍊� + curtainData.OpenLimitPersent = progressValue; var btnProgress1 = new NormalViewControl(200, 50, true); btnProgress1.X = Application.GetRealWidth(200); btnProgress1.Y = btnProgressView.Y; @@ -238,14 +267,14 @@ btnProgress1.Text = progressValue + "%"; frameBack.AddChidren(btnProgress1); //杩涘害鏉� - this.openSeekBar = new SeekBarControl(965); + this.openSeekBar = new SeekBarControl(965); openSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46); openSeekBar.ProgressBarColor = 0xff288bfd; openSeekBar.Progress = progressValue; frameBack.AddChidren(openSeekBar); var btnTemp1 = new NormalViewControl(200, 50, true); - btnTemp1.X = ControlCommonResourse.XXLeft; + btnTemp1.X = HdlControlResourse.XXLeft; btnTemp1.Y = btnProgressView.Bottom + Application.GetRealHeight(115); btnTemp1.TextSize = 12; btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3; @@ -260,8 +289,8 @@ btnTemp2.Text = "100%"; frameBack.AddChidren(btnTemp2); //绾� - var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); - btnLine.X = ControlCommonResourse.XXLeft; + var btnLine = new NormalViewControl(frameBack.Width - HdlControlResourse.XXLeft * 2, HdlControlResourse.BottomLineHeight, false); + btnLine.X = HdlControlResourse.XXLeft; btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156); btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; frameBack.AddChidren(btnLine); @@ -312,7 +341,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(); @@ -332,37 +362,37 @@ //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.OpenLimitPersent = value; }; + //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + openSeekBar.Enable = false; + btnMinus.CanClick = false; + btnPlus.CanClick = false; + btnSave.CanClick = false; + } + + //铏氭嫙浣忓畢涓嶉渶瑕佺洃鍚� + 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; - if (curtainData.DeleteOpenLimit == true) - { - //閲嶇疆寮�闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit); - if (result == false) - { - checking = false; - continue; - } - curtainData.DeleteOpenLimit = false; - } + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� this.sendDiv = 1; curtainDevice.WcdGoToTiltValue(nowValue); - checking = false; } }); } @@ -374,14 +404,16 @@ { //纭褰撳墠浣嶇疆涓哄紑闄愪綅? 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, - curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + var result = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength); if (result == true) { - curtainData.DeleteOpenLimit = true; this.receiveOpenlimit = false; } }); @@ -399,7 +431,7 @@ { //鍚堥檺浣� var btnProgressView = new NormalViewControl(200, 50, true); - btnProgressView.X = ControlCommonResourse.XXLeft; + btnProgressView.X = HdlControlResourse.XXLeft; btnProgressView.Y = Application.GetRealHeight(536); btnProgressView.TextSize = 12; btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; @@ -407,6 +439,8 @@ frameBack.AddChidren(btnProgressView); int progressValue = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100); + //璁剧疆鐧惧垎姣旂殑鍒濆鍊� + curtainData.CloseLimitPersent = progressValue; var btnProgress1 = new NormalViewControl(200, 50, true); btnProgress1.X = Application.GetRealWidth(200); btnProgress1.Y = btnProgressView.Y; @@ -415,14 +449,14 @@ btnProgress1.Text = progressValue + "%"; frameBack.AddChidren(btnProgress1); //杩涘害鏉� - this.closeSeekBar = new SeekBarControl(965); + this.closeSeekBar = new SeekBarControl(965); closeSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46); closeSeekBar.ProgressBarColor = 0xff288bfd; closeSeekBar.Progress = progressValue; frameBack.AddChidren(closeSeekBar); var btnTemp1 = new NormalViewControl(200, 50, true); - btnTemp1.X = ControlCommonResourse.XXLeft; + btnTemp1.X = HdlControlResourse.XXLeft; btnTemp1.Y = btnProgressView.Bottom + Application.GetRealHeight(115); btnTemp1.TextSize = 12; btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3; @@ -437,8 +471,8 @@ btnTemp2.Text = "100%"; frameBack.AddChidren(btnTemp2); //绾� - var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); - btnLine.X = ControlCommonResourse.XXLeft; + var btnLine = new NormalViewControl(frameBack.Width - HdlControlResourse.XXLeft * 2, HdlControlResourse.BottomLineHeight, false); + btnLine.X = HdlControlResourse.XXLeft; btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156); btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; frameBack.AddChidren(btnLine); @@ -471,7 +505,7 @@ frameBack.AddChidren(btnPlus); btnPlus.ButtonClickEvent += (sender, e) => { - if (closeSeekBar.Progress >=100) + if (closeSeekBar.Progress >= 100) { return; } @@ -489,7 +523,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(); @@ -509,36 +544,36 @@ //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.CloseLimitPersent = value; }; + //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + closeSeekBar.Enable = false; + btnMinus.CanClick = false; + btnPlus.CanClick = false; + btnSave.CanClick = false; + } + //铏氭嫙浣忓畢涓嶉渶瑕佺洃鍚� + 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; - if (curtainData.DeleteCloseLimit == true) - { - //閲嶇疆鍚堥檺浣嶇偣 - var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit); - if (result == false) - { - continue; - } - curtainData.DeleteCloseLimit = false; - } + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� this.sendDiv = 2; curtainDevice.WcdGoToTiltValue(nowValue); - checking = false; } }); } @@ -550,14 +585,17 @@ { //纭褰撳墠浣嶇疆涓哄悎闄愪綅? string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg); - this.ShowMassage(ShowMsgType.Confirm, msg, async () => + this.ShowMassage(ShowMsgType.Confirm, msg, () => { - //鎵ц纭鍙婅鐩栧悎闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, - curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + 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 = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength); + if (result == true) { - curtainData.DeleteCloseLimit = true; this.receiveCloseLimit = false; } }); @@ -580,6 +618,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"); @@ -637,19 +680,30 @@ /// <returns></returns> private bool InitCurtainDefultData() { - //寮�鍚繘搴︽潯 - this.ShowProgressBar(); - this.curtainData = new CurtainData(); this.receiveOpenlimit = false; this.receiveCloseLimit = false; this.sendDiv = 0; - bool receiptData = false; - string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + var data = HdlTemplateDeviceDataLogic.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 = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(curtainDevice); HdlGatewayReceiveLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) => { - string checkKey = LocalDevice.Current.GetDeviceMainKeys(device); + string checkKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258) { return; @@ -669,23 +723,25 @@ //姝e悜 curtainData.Direction = false; } + receiptDataCount++; } else if (attriBute.AttributeId == 1) { //绐楀笜鎬婚暱 curtainData.CurtainLength = attriBute.AttriButeData; + receiptDataCount++; } else if (attriBute.AttributeId == 16) { //寮�闄愪綅 curtainData.OpenLimitValue = attriBute.AttriButeData; + receiptDataCount++; } else if (attriBute.AttributeId == 17) { //鍚堥檺浣� curtainData.CloseLimitValue = attriBute.AttriButeData; - //鏁版嵁鎺ユ敹缁撴潫 - receiptData = true; + receiptDataCount++; } } }); @@ -693,7 +749,7 @@ HdlDeviceCurtainLogic.Current.SetGetCurtainLimitSettionComand(curtainDevice); int timeCount = 30; - while (receiptData == false && timeCount >= 0) + while (receiptDataCount != 4 && timeCount >= 0) { System.Threading.Thread.Sleep(100); timeCount--; @@ -706,27 +762,12 @@ //鑾峰彇绐楀笜鏂瑰悜涓庨檺浣嶈缃け璐� string msg = Language.StringByID(R.MyInternationalizationString.uGetCurtainDirectionAndLimitSettionFail); //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); this.ShowMassage(ShowMsgType.Tip, msg); return false; } //绉婚櫎鐩戝惉 HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); - - //澶囦唤绐楀笜鏁版嵁 - if (this.backupCurtainData == true) - { - 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; } @@ -740,14 +781,19 @@ /// </summary> private void ReceiveLimitData() { + //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欓渶瑕佸鐞� + if (Common.Config.Instance.Home.IsShowTemplate == true) + { + return; + } if (HdlGatewayReceiveLogic.Current.IsEsixt("ReceiveLimitData") == true) { HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData"); } - string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); + string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(curtainDevice); HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReceiveLimitData", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) => { - string checkKey = LocalDevice.Current.GetDeviceMainKeys(device); + string checkKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258) { return; @@ -784,8 +830,6 @@ HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData"); - UserView.HomePage.Instance.ScrollEnabled = true; - base.CloseFormBefore(); } @@ -802,14 +846,6 @@ /// false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜 /// </summary> public bool Direction = false; - /// <summary> - /// 鏄惁閲嶇疆寮�闄愪綅鐐� - /// </summary> - public bool DeleteOpenLimit = true; - /// <summary> - /// 鏄惁閲嶇疆鍚堥檺浣嶇偣 - /// </summary> - public bool DeleteCloseLimit = true; /// <summary> /// 寮�闄愪綅鐨勫�� /// </summary> -- Gitblit v1.8.0