From e79b65b97a8ae1eae5ee172dea1b52d041006599 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 02 九月 2020 17:24:32 +0800
Subject: [PATCH] 2020-09-02-3
---
ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 600 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 368 insertions(+), 232 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
index 9200520..9b337e2 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
@@ -23,13 +23,17 @@
/// </summary>
private CurtainData curtainData = null;
/// <summary>
- /// 鍏佽鎺ユ敹涓婇檺浣�(0:涓嶅厑璁� 1:鍏佽)
+ /// 鎺ユ敹寮�闄愪綅 false:娌℃湁鎺ユ敹鍒� true:宸茬粡鎺ユ敹鍒�
/// </summary>
- private string receiveUplimit = "0";
+ private bool receiveOpenlimit = false;
/// <summary>
- /// 鍏佽鎺ユ敹涓嬮檺浣�(0:涓嶅厑璁� 1:鍏佽)
+ /// 鎺ユ敹鍚堥檺浣� false:娌℃湁鎺ユ敹鍒� true:宸茬粡鎺ユ敹鍒�
/// </summary>
- private string receiveDownLimit = "0";
+ private bool receiveCloseLimit = false;
+ /// <summary>
+ /// 鍙戦�佸尯鍒� 1:寮�闄愪綅 2:鍚堥檺浣�
+ /// </summary>
+ private int sendDiv = 0;
/// <summary>
/// 鏄惁澶囦唤绐楀笜鏁版嵁
/// </summary>
@@ -41,11 +45,11 @@
/// <summary>
/// 寮�闄愪綅鐨勮繘搴︽潯
/// </summary>
- private HorizontalSeekBar openSeekBar = null;
+ private SeekBarControl openSeekBar = null;
/// <summary>
/// 鍚堥檺浣嶇殑杩涘害鏉�
/// </summary>
- private HorizontalSeekBar closeSeekBar = null;
+ private SeekBarControl closeSeekBar = null;
#endregion
@@ -57,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;
@@ -95,23 +99,51 @@
listView.Height = bodyFrameLayout.Height;
bodyFrameLayout.AddChidren(listView);
- //娣诲姞鏂瑰悜琛�
- this.AddDirectionRow();
- //娣诲姞闄愪綅琛�
- this.AddLimitRow();
- //娣诲姞閲嶇疆鐢垫満琛�
- this.AddElectricalMachineryRow();
- //淇濆瓨
- var btnSave = new BottomClickButton();
- btnSave.TextID = R.MyInternationalizationString.uSave;
- bodyFrameLayout.AddChidren(btnSave);
- btnSave.ButtonClickEvent += (sender, e) =>
+ //瀵艰建闀垮害涓�0鏃�
+ if (curtainData.CurtainLength <= 0)
{
- //杩欎釜淇濆瓨娌″暐鎰忎箟
- this.CloseForm();
- };
- //闄愪綅鏁版嵁鎺ユ敹
- this.ReceiveLimitData();
+ //鐢垫満鏁版嵁寮傚父,纭宸茬粡瀹夎瀵艰建鍚�,璇烽噸缃數鏈�
+ this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain));
+ try
+ {
+ //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛�
+ this.AddElectricalMachineryRow();
+ return;
+ }
+ catch (Exception ex2)
+ {
+ HdlLogLogic.Current.WriteLog(ex2, "寮�鍚堝笜琛ユ晳寮傚父1");
+ return;
+ }
+ }
+
+ 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"); }
+ }
});
}
@@ -144,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;
@@ -158,6 +190,11 @@
curtainData.Direction = index == 0 ? false : true;
};
};
+ //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈�
+ if (Common.Config.Instance.Home.IsShowTemplate == true)
+ {
+ rowDirection.CanClick = false;
+ }
}
#endregion
@@ -170,7 +207,7 @@
private void AddLimitRow()
{
var frameBack = new FrameLayout();
- frameBack.Height = Application.GetRealHeight(679);
+ frameBack.Height = Application.GetRealHeight(956);
var rowLimit = new FrameRowControl(listView.rowSpace / 2);
rowLimit.UseClickStatu = false;
@@ -181,14 +218,14 @@
var btnRinght = rowLimit.AddMostRightEmptyIcon(58, 58);
rowLimit.ChangedChidrenBindMode(btnRinght, ChidrenBindMode.NotBind);
btnRinght.UseClickStatu = false;
- btnRinght.UnSelectedImagePath = "Item/Next.png";
+ btnRinght.UnSelectedImagePath = "Item/RightNext.png";
btnRinght.SelectedImagePath = "Item/Down.png";
btnRinght.IsSelected = true;
btnRinght.ButtonClickEvent += (sender, e) =>
{
btnRinght.IsSelected = !btnRinght.IsSelected;
//灞曞紑鎶樺彔
- frameBack.Height = frameBack.Height > 10 ? 0 : Application.GetRealHeight(679);
+ frameBack.Height = frameBack.Height > 10 ? 0 : Application.GetRealHeight(956);
};
//搴曠嚎
rowLimit.AddBottomLine();
@@ -200,6 +237,10 @@
this.AddCloseLimitProgress(frameBack);
}
+ #endregion
+
+ #region 鈻� 寮�闄愪綅琛宊__________________________
+
/// <summary>
/// 娣诲姞寮�闄愪綅杩涘害鏉�
/// </summary>
@@ -209,13 +250,15 @@
//寮�闄愪綅
var btnProgressView = new NormalViewControl(200, 50, true);
btnProgressView.X = ControlCommonResourse.XXLeft;
- btnProgressView.Y = Application.GetRealHeight(60);
+ btnProgressView.Y = Application.GetRealHeight(78);
btnProgressView.TextSize = 12;
btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1;
btnProgressView.TextID = R.MyInternationalizationString.uOpenLimit;
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,15 +267,9 @@
btnProgress1.Text = progressValue + "%";
frameBack.AddChidren(btnProgress1);
//杩涘害鏉�
- this.openSeekBar = new HorizontalSeekBar();
+ this.openSeekBar = new SeekBarControl(965);
openSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
- openSeekBar.Gravity = Gravity.CenterHorizontal;
- openSeekBar.Width = Application.GetRealWidth(962);
- openSeekBar.Height = Application.GetRealHeight(84);
- openSeekBar.Max = 100;
- openSeekBar.BackgroundColor = 0xfff5f5f5;
- openSeekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
- openSeekBar.ProgressColor = 0xff288bfd;
+ openSeekBar.ProgressBarColor = 0xff288bfd;
openSeekBar.Progress = progressValue;
frameBack.AddChidren(openSeekBar);
@@ -254,78 +291,137 @@
//绾�
var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false);
btnLine.X = ControlCommonResourse.XXLeft;
- btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69);
+ btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156);
btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
frameBack.AddChidren(btnLine);
- int oldValue = progressValue;
- int waitTime = 4;//500姣涓哄崟浣�
- bool startWait = false;
- bool checking = false;
- openSeekBar.ProgressChanged += (sender, value) =>
+ //鍑忓彿
+ var btnMinus = new IconViewControl(104);
+ btnMinus.UseClickStatu = true;
+ btnMinus.X = Application.GetRealWidth(847);
+ btnMinus.Y = Application.GetRealHeight(46);
+ btnMinus.UnSelectedImagePath = "Item/MinusSign2.png";
+ btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png";
+ frameBack.AddChidren(btnMinus);
+ btnMinus.ButtonClickEvent += (sender, e) =>
{
- //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘�
- waitTime = 4;
+ if (openSeekBar.Progress <= 0)
+ {
+ return;
+ }
+ openSeekBar.Progress -= 5;
+ openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress);
+ };
+
+ //鍔犲彿
+ var btnPlus = new IconViewControl(104);
+ btnPlus.UseClickStatu = true;
+ btnPlus.X = btnMinus.Right;
+ btnPlus.Y = btnMinus.Y;
+ btnPlus.UnSelectedImagePath = "Item/PlusSign2.png";
+ btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png";
+ frameBack.AddChidren(btnPlus);
+ btnPlus.ButtonClickEvent += (sender, e) =>
+ {
+ if (openSeekBar.Progress >= 100)
+ {
+ return;
+ }
+ openSeekBar.Progress += 5;
+ openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress);
+ };
+
+ //淇濆瓨
+ var btnSave = new NormalViewControl(150, 60, true);
+ btnSave.X = Application.GetRealWidth(906);
+ btnSave.Y = btnTemp1.Bottom + Application.GetRealHeight(68);
+ btnSave.TextAlignment = TextAlignment.Center;
+ btnSave.TextID = R.MyInternationalizationString.uSave;
+ btnSave.TextColor = UserCenterColor.Current.TextOrangeColor;
+ frameBack.AddChidren(btnSave);
+ btnSave.ButtonClickEvent += (sender, e) =>
+ {
+ //2020.05.17:杩藉姞铏氭嫙浣忓畢鍙互鐩存帴鐐瑰嚮
+ if (this.receiveOpenlimit == true || Common.Config.Instance.Home.IsVirtually == true)
+ {
+ //纭寮�闄愪綅鐐�
+ this.SaveOpenLimit();
+ }
+ };
+
+ int oldProValue = curtainData.OpenLimitPersent;
+ openSeekBar.ProgressChangedEvent += (div, value) =>
+ {
//寮�闄愪綅涓嶈兘澶т簬鍚堥檺浣�
if (value > closeSeekBar.Progress)
{
openSeekBar.Progress = closeSeekBar.Progress;
return;
}
- if (checking == false)
- {
- startWait = true;
- }
-
btnProgress1.Text = value + "%";
//鏁版嵁鍙樻洿,鐧惧垎姣�
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 () =>
{
while (openSeekBar.Parent != null)
{
- if (startWait == false)
+ int nowValue = curtainData.OpenLimitPersent;
+ if (oldProValue == nowValue)
{
- await Task.Delay(200);
+ //鍊间笉绛夋墠澶勭悊
+ await Task.Delay(500);
continue;
}
- //寮�鍚�兼敼鍙樼瓑寰�
- await Task.Delay(500);
- waitTime--;
- if (waitTime <= 0)
- {
- //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂�
- startWait = false;
- checking = true;
+ oldProValue = nowValue;
- var value = curtainData.OpenLimitPersent;
- if (oldValue == value)
- {
- //鐩稿悓鏁板��
- checking = false;
- continue;
- }
- oldValue = value;
- if (curtainData.DeleteOpenLimit == true)
- {
- //閲嶇疆寮�闄愪綅鐐�
- var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit);
- if (result == false)
- {
- checking = false;
- continue;
- }
- curtainData.DeleteOpenLimit = false;
- }
- receiveUplimit = "1";
- //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
- curtainDevice.WcdGoToTiltValue(value);
- checking = false;
- }
+ //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
+ this.sendDiv = 1;
+ curtainDevice.WcdGoToTiltValue(nowValue);
}
});
}
+
+ /// <summary>
+ /// 纭寮�闄愪綅鐐�
+ /// </summary>
+ private void SaveOpenLimit()
+ {
+ //纭褰撳墠浣嶇疆涓哄紑闄愪綅?
+ string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg);
+ 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 = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength);
+ if (result == true)
+ {
+ this.receiveOpenlimit = false;
+ }
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鍚堥檺浣嶈___________________________
/// <summary>
/// 娣诲姞鍚堥檺浣嶈繘搴︽潯
@@ -336,13 +432,15 @@
//鍚堥檺浣�
var btnProgressView = new NormalViewControl(200, 50, true);
btnProgressView.X = ControlCommonResourse.XXLeft;
- btnProgressView.Y = Application.GetRealHeight(397);
+ btnProgressView.Y = Application.GetRealHeight(536);
btnProgressView.TextSize = 12;
btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1;
btnProgressView.TextID = R.MyInternationalizationString.uCloseLimit;
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;
@@ -351,15 +449,9 @@
btnProgress1.Text = progressValue + "%";
frameBack.AddChidren(btnProgress1);
//杩涘害鏉�
- this.closeSeekBar = new HorizontalSeekBar();
+ this.closeSeekBar = new SeekBarControl(965);
closeSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
- closeSeekBar.Gravity = Gravity.CenterHorizontal;
- closeSeekBar.Width = Application.GetRealWidth(962);
- closeSeekBar.Height = Application.GetRealHeight(84);
- closeSeekBar.Max = 100;
- closeSeekBar.BackgroundColor = 0xfff5f5f5;
- closeSeekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
- closeSeekBar.ProgressColor = 0xff288bfd;
+ closeSeekBar.ProgressBarColor = 0xff288bfd;
closeSeekBar.Progress = progressValue;
frameBack.AddChidren(closeSeekBar);
@@ -381,75 +473,130 @@
//绾�
var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false);
btnLine.X = ControlCommonResourse.XXLeft;
- btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69);
+ btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156);
btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
frameBack.AddChidren(btnLine);
- int oldValue = progressValue;
- int waitTime = 4;//500姣涓哄崟浣�
- bool startWait = false;
- bool checking = false;
- closeSeekBar.ProgressChanged += (sender, value) =>
+ //鍑忓彿
+ var btnMinus = new IconViewControl(104);
+ btnMinus.UseClickStatu = true;
+ btnMinus.X = Application.GetRealWidth(847);
+ btnMinus.Y = Application.GetRealHeight(504);
+ btnMinus.UnSelectedImagePath = "Item/MinusSign2.png";
+ btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png";
+ frameBack.AddChidren(btnMinus);
+ btnMinus.ButtonClickEvent += (sender, e) =>
{
- //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘�
- waitTime = 4;
- //鍚堥檺浣嶄笉鑳藉皬浜庡悎闄愪綅
- if (value < openSeekBar.Progress)
+ if (closeSeekBar.Progress <= 0)
{
+ return;
+ }
+ closeSeekBar.Progress -= 5;
+ closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress);
+ };
+
+ //鍔犲彿
+ var btnPlus = new IconViewControl(104);
+ btnPlus.UseClickStatu = true;
+ btnPlus.X = btnMinus.Right;
+ btnPlus.Y = btnMinus.Y;
+ btnPlus.UnSelectedImagePath = "Item/PlusSign2.png";
+ btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png";
+ frameBack.AddChidren(btnPlus);
+ btnPlus.ButtonClickEvent += (sender, e) =>
+ {
+ if (closeSeekBar.Progress >= 100)
+ {
+ return;
+ }
+ closeSeekBar.Progress += 5;
+ closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress);
+ };
+
+ //淇濆瓨
+ var btnSave = new NormalViewControl(150, 60, true);
+ btnSave.X = Application.GetRealWidth(906);
+ btnSave.Y = btnTemp1.Bottom + Application.GetRealHeight(68);
+ btnSave.TextAlignment = TextAlignment.Center;
+ btnSave.TextID = R.MyInternationalizationString.uSave;
+ btnSave.TextColor = UserCenterColor.Current.TextOrangeColor;
+ frameBack.AddChidren(btnSave);
+ btnSave.ButtonClickEvent += (sender, e) =>
+ {
+ //2020.05.17:杩藉姞铏氭嫙浣忓畢鍙互鐩存帴鐐瑰嚮
+ if (this.receiveCloseLimit == true || Common.Config.Instance.Home.IsVirtually == true)
+ {
+ //淇濆瓨鍚堥檺浣嶇偣
+ this.SaveCloseLimit();
+ }
+ };
+
+ int oldProValue = curtainData.CloseLimitPersent;
+ closeSeekBar.ProgressChangedEvent += (div, value) =>
+ {
+ if (value < curtainData.OpenLimitPersent)
+ {
+ //鍚堥檺浣嶄笉鑳藉皬浜庡悎闄愪綅
closeSeekBar.Progress = openSeekBar.Progress;
return;
}
- if (checking == false)
- {
- startWait = true;
- }
-
btnProgress1.Text = value + "%";
//鏁版嵁鍙樻洿,鐧惧垎姣�
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 () =>
{
while (closeSeekBar.Parent != null)
{
- if (startWait == false)
+ int nowValue = curtainData.CloseLimitPersent;
+ if (oldProValue == nowValue)
{
- await Task.Delay(200);
+ //鍊间笉绛夋墠澶勭悊
+ await Task.Delay(500);
continue;
}
- //寮�鍚�兼敼鍙樼瓑寰�
- await Task.Delay(500);
- waitTime--;
- if (waitTime <= 0)
- {
- //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂�
- startWait = false;
- checking = true;
+ oldProValue = nowValue;
- var value = curtainData.CloseLimitPersent;
- if (oldValue == value)
- {
- //鐩稿悓鏁板��
- checking = false;
- continue;
- }
- oldValue = value;
- if (curtainData.DeleteCloseLimit == true)
- {
- //閲嶇疆鍚堥檺浣嶇偣
- var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit);
- if (result == false)
- {
- checking = false;
- continue;
- }
- curtainData.DeleteCloseLimit = false;
- }
- receiveDownLimit = "1";
- //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
- curtainDevice.WcdGoToTiltValue(value);
- checking = false;
- }
+ //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
+ this.sendDiv = 2;
+ curtainDevice.WcdGoToTiltValue(nowValue);
+ }
+ });
+ }
+
+ /// <summary>
+ /// 淇濆瓨鍚堥檺浣嶇偣
+ /// </summary>
+ private void SaveCloseLimit()
+ {
+ //纭褰撳墠浣嶇疆涓哄悎闄愪綅?
+ string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg);
+ 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 = HdlDeviceCurtainLogic.Current.SetAutoOpenCurtainLimitPoint(curtainDevice, (int)openValue, (int)closeValue, curtainData.CurtainLength);
+
+ if (result == true)
+ {
+ this.receiveCloseLimit = false;
}
});
}
@@ -471,19 +618,49 @@
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");
this.ShowMassage(ShowMsgType.Confirm, msg, () =>
{
+ //寮�鍚繘搴︽潯
+ ProgressFormBar.Current.Start();
+ //姝e湪閲嶇疆鐢垫満
+ ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uElectricalMachineryResetting));
+ //閲嶇疆绐楀笜
HdlThreadLogic.Current.RunThread(async () =>
{
- //閲嶇疆绐楀笜
var result = await HdlDeviceCurtainLogic.Current.RestoreCurtain(curtainDevice);
if (result == false)
{
+ //鍏抽棴杩涘害鏉�
+ ProgressFormBar.Current.Close();
return;
}
+
+ //姣�10鐨勯暱搴﹀ぇ姒傛槸2绉�,澶氶鐣�1娆″嚭鏉�
+ int waitCount = ((curtainData.CurtainLength / 10) + 1) * 3;
+ if (waitCount < 12)
+ {
+ waitCount = 12;
+ }
+
+ int timeCount = 0;
+ while (timeCount <= waitCount)
+ {
+ //杩涘害鏉″��
+ ProgressFormBar.Current.SetValue(timeCount, waitCount);
+ timeCount++;
+ System.Threading.Thread.Sleep(1000);
+ }
+ //鍏抽棴杩涘害鏉�
+ ProgressFormBar.Current.Close();
+
//鑾峰彇鏁版嵁鍚�,澶囦唤绐楀笜鏁版嵁
this.backupCurtainData = true;
//閲嶆柊鍒濆鍖栫晫闈�
@@ -503,16 +680,28 @@
/// <returns></returns>
private bool InitCurtainDefultData()
{
+ this.curtainData = new CurtainData();
+ this.receiveOpenlimit = false;
+ this.receiveCloseLimit = false;
+ this.sendDiv = 0;
+
+ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ var data = TemplateData.TemplateDeviceDataLogic.Current.GetCurtainLimitPoint(curtainDevice);
+ curtainData.Direction = data.Direction;
+ curtainData.CurtainLength = data.curtainLength;
+ curtainData.OpenLimitValue = data.upLimit;
+ curtainData.CloseLimitValue = data.downLimit;
+ return true;
+ }
+
//寮�鍚繘搴︽潯
this.ShowProgressBar();
- this.curtainData = new CurtainData();
- this.receiveUplimit = "0";
- this.receiveDownLimit = "0";
-
- bool receiptData = false;
+ int receiptDataCount = 0;
string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice);
- HdlDeviceAttributeLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", "DeviceStatusReport", (device) =>
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) =>
{
string checkKey = LocalDevice.Current.GetDeviceMainKeys(device);
if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258)
@@ -534,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++;
}
}
});
@@ -558,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--;
@@ -576,22 +767,7 @@
return false;
}
//绉婚櫎鐩戝惉
- HdlDeviceAttributeLogic.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);
- });
- }
+ HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute");
return true;
}
@@ -605,67 +781,37 @@
/// </summary>
private void ReceiveLimitData()
{
- if (HdlDeviceAttributeLogic.Current.IsEsixt("ReceiveLimitData") == true)
+ //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欓渶瑕佸鐞�
+ if (Common.Config.Instance.Home.IsShowTemplate == true)
{
- HdlDeviceAttributeLogic.Current.RemoveEvent("ReceiveLimitData");
+ return;
+ }
+ if (HdlGatewayReceiveLogic.Current.IsEsixt("ReceiveLimitData") == true)
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData");
}
string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice);
- HdlDeviceAttributeLogic.Current.AddAttributeEvent("ReceiveLimitData", "DeviceStatusReport", (device) =>
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReceiveLimitData", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) =>
{
string checkKey = LocalDevice.Current.GetDeviceMainKeys(device);
if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258)
{
return;
}
- lock (receiveUplimit)
+ foreach (var attriBute in device.DeviceStatusReport.AttriBute)
{
- if (receiveUplimit == "0" && receiveDownLimit == "0")
+ //绐楀笜鐧惧垎姣旀帹閫�
+ if (attriBute.AttributeId == 8)
{
- return;
- }
- foreach (var attriBute in device.DeviceStatusReport.AttriBute)
- {
- //绐楀笜鐧惧垎姣旀帹閫�
- if (attriBute.AttributeId == 8)
+ //寮�闄愪綅
+ if (sendDiv == 1)
{
- //涓婇檺浣�
- if (receiveUplimit == "1")
- {
- receiveUplimit = "0";
- openSeekBar.Progress = curtainData.OpenLimitPersent;
- //纭褰撳墠浣嶇疆{0}涓哄紑闄愪綅?
- string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg);
- msg = msg.Replace("{0}", curtainData.OpenLimitPersent + "%");
- this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
- {
- //鎵ц纭鍙婅鐩栦笂闄愪綅鐐�
- var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit,
- curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
- if (result == true)
- {
- curtainData.DeleteOpenLimit = true;
- }
- });
- }
- //鍚堥檺浣�
- else if (receiveDownLimit == "1")
- {
- receiveDownLimit = "0";
- closeSeekBar.Progress = curtainData.CloseLimitPersent;
- //纭褰撳墠浣嶇疆{0}涓哄悎闄愪綅?
- string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg);
- msg = msg.Replace("{0}", curtainData.CloseLimitPersent + "%");
- this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
- {
- //鎵ц纭鍙婅鐩栧悎闄愪綅鐐�
- var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit,
- curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
- if (result == true)
- {
- curtainData.DeleteCloseLimit = true;
- }
- });
- }
+ receiveOpenlimit = true;
+ }
+ //鍚堥檺浣�
+ else if (sendDiv == 2)
+ {
+ receiveCloseLimit = true;
}
}
}
@@ -679,14 +825,12 @@
/// <summary>
/// 鐣岄潰鍏抽棴
/// </summary>
- public override void CloseForm()
+ public override void CloseFormBefore()
{
- HdlDeviceAttributeLogic.Current.RemoveEvent("CurtainDeviceAttribute");
- HdlDeviceAttributeLogic.Current.RemoveEvent("ReceiveLimitData");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData");
- UserView.HomePage.Instance.ScrollEnabled = true;
-
- base.CloseForm();
+ base.CloseFormBefore();
}
#endregion
@@ -702,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