From 3272ca5b51e19f7f8a827b0f68400570a547fe60 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 28 四月 2020 15:02:44 +0800 Subject: [PATCH] 2020-04-28-1 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 132 ++++++++++++++++++++++++++------------------ 1 files changed, 78 insertions(+), 54 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs index 725d5fa..de7b257 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,15 +99,51 @@ listView.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listView); - //娣诲姞鏂瑰悜琛� - this.AddDirectionRow(); - //娣诲姞闄愪綅琛� - this.AddLimitRow(); - //娣诲姞閲嶇疆鐢垫満琛� - this.AddElectricalMachineryRow(); + //瀵艰建闀垮害涓�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; + } + } - //闄愪綅鏁版嵁鎺ユ敹 - this.ReceiveLimitData(); + try + { + //娣诲姞鏂瑰悜琛� + this.AddDirectionRow(); + //娣诲姞闄愪綅琛� + this.AddLimitRow(); + //娣诲姞閲嶇疆鐢垫満琛� + this.AddElectricalMachineryRow(); + + //闄愪綅鏁版嵁鎺ユ敹 + this.ReceiveLimitData(); + } + catch (Exception ex) + { + //Log鍑哄姏 + string msg = "褰撳墠婵�娲荤殑鐣岄潰[" + UserCenterResourse.NowActionFormID + "]"; + HdlLogLogic.Current.WriteLog(ex, msg); + //鐢垫満鏁版嵁寮傚父,璇烽噸缃數鏈� + this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain)); + try + { + this.listView.RemoveAll(); + //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛� + this.AddElectricalMachineryRow(); + } + catch (Exception ex2) { HdlLogLogic.Current.WriteLog(ex2, "寮�鍚堝笜琛ユ晳寮傚父2"); } + } }); } @@ -216,6 +252,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; @@ -224,7 +262,7 @@ 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; @@ -334,17 +372,7 @@ } 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); @@ -362,12 +390,15 @@ string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg); this.ShowMassage(ShowMsgType.Confirm, msg, async () => { + 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); + (int)openValue, (int)closeValue); if (result == true) { - curtainData.DeleteOpenLimit = true; this.receiveOpenlimit = false; } }); @@ -393,6 +424,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; @@ -401,7 +434,7 @@ 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; @@ -457,7 +490,7 @@ frameBack.AddChidren(btnPlus); btnPlus.ButtonClickEvent += (sender, e) => { - if (closeSeekBar.Progress >=100) + if (closeSeekBar.Progress >= 100) { return; } @@ -511,16 +544,7 @@ } 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); @@ -538,12 +562,16 @@ string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg); this.ShowMassage(ShowMsgType.Confirm, msg, async () => { - //鎵ц纭鍙婅鐩栧悎闄愪綅鐐� + 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, - curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + (int)openValue, (int)closeValue); + if (result == true) { - curtainData.DeleteCloseLimit = true; this.receiveCloseLimit = false; } }); @@ -588,6 +616,10 @@ //姣�10鐨勯暱搴﹀ぇ姒傛槸2绉�,澶氶鐣�1娆″嚭鏉� int waitCount = ((curtainData.CurtainLength / 10) + 1) * 3; + if (waitCount < 12) + { + waitCount = 12; + } int timeCount = 0; while (timeCount <= waitCount) @@ -627,7 +659,7 @@ this.receiveCloseLimit = false; this.sendDiv = 0; - bool receiptData = false; + int receiptDataCount = 0; string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); HdlGatewayReceiveLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) => { @@ -651,23 +683,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++; } } }); @@ -675,7 +709,7 @@ HdlDeviceCurtainLogic.Current.SetGetCurtainLimitSettionComand(curtainDevice); int timeCount = 30; - while (receiptData == false && timeCount >= 0) + while (receiptDataCount != 4 && timeCount >= 0) { System.Threading.Thread.Sleep(100); timeCount--; @@ -696,7 +730,7 @@ HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); //澶囦唤绐楀笜鏁版嵁 - if (this.backupCurtainData == true) + if (this.backupCurtainData == true && curtainData.CurtainLength > 0) { this.backupCurtainData = false; HdlThreadLogic.Current.RunThread(async () => @@ -704,7 +738,7 @@ //鏂瑰悜澶囦唤 await HdlDeviceCurtainLogic.Current.BackupCurtainDirection(curtainDevice, curtainData.Direction); //闄愪綅澶囦唤 - int uplimit= (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100); + 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); }); @@ -766,8 +800,6 @@ HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData"); - UserView.HomePage.Instance.ScrollEnabled = true; - base.CloseFormBefore(); } @@ -784,14 +816,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