From d87400af518ebc9274f4447f06476959c3aa5102 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 14 七月 2020 16:29:42 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into dev-2020xm
---
ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 157 insertions(+), 23 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs
index d413616..e0c6eb5 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/AirConditionerModeForm.cs
@@ -16,6 +16,18 @@
/// 褰撳墠閫夋嫨鐨勭綉鍏�
/// </summary>
private AC deviceAc = null;
+ /// <summary>
+ /// 涓婃姤鐨勬暟鎹�(鐢ㄤ簩杩涘埗鏉ョ帺鑷畾涔夋ā寮� 0:鍒跺喎 1:鍒剁儹 2:閫侀 3:闄ゆ箍 4:鑷姩 5~7:澶囩敤)
+ /// </summary>
+ private string reportValue = null;
+ /// <summary>
+ /// 鏃х殑鏁版嵁
+ /// </summary>
+ private string oldReportValue = null;
+ /// <summary>
+ /// 鍥哄畾棰勭暀鐨勬暟鎹�
+ /// </summary>
+ private string fixValue = null;
#endregion
@@ -32,12 +44,15 @@
//璁剧疆澶撮儴淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAirConditionerMode));
+ //璇诲彇绌鸿皟鑷畾涔夋ā寮�
+ this.ReadAirConditionerModeSupport();
+
//鍒濆鍖栦腑閮ㄤ俊鎭�
this.InitMiddleFrame();
}
/// <summary>
- /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+ /// 鍒濆鍖栦腑閮ㄤ俊鎭� 鈽嗏槅鈽嗏槅鈽�
/// </summary>
private void InitMiddleFrame()
{
@@ -50,27 +65,71 @@
listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
bodyFrameLayout.AddChidren(listView);
- //鍒跺喎
- this.AddAirConditionerModeRow(listView, "AC/Mode_Cool2.png", Language.StringByID(R.MyInternationalizationString.uMode_Cool), 1);
- //鍒剁儹
- this.AddAirConditionerModeRow(listView, "AC/Mode_Heat2.png", Language.StringByID(R.MyInternationalizationString.uMode_Heat), 2);
- //鑷姩
- this.AddAirConditionerModeRow(listView, "AC/Mode_AutoSelected.png", Language.StringByID(R.MyInternationalizationString.uMode_Auto), 3);
- //閫侀
- this.AddAirConditionerModeRow(listView, "AC/Mode_Fan2.png", Language.StringByID(R.MyInternationalizationString.uMode_FanOnly), 4);
- //闄ゆ箍
- this.AddAirConditionerModeRow(listView, "AC/Mode_Dry2.png", Language.StringByID(R.MyInternationalizationString.uMode_Dry), 5);
-
- listView.AdjustRealHeight(Application.GetRealHeight(23));
-
- //淇濆瓨
- var btnOk = new BottomClickButton();
- btnOk.TextID = R.MyInternationalizationString.uSave;
- bodyFrameLayout.AddChidren(btnOk);
- btnOk.ButtonClickEvent += (sender, e) =>
+ HdlThreadLogic.Current.RunThread(() =>
{
- this.CloseForm();
- };
+ //寮�鍚繘搴︽潯
+ this.ShowProgressBar();
+ int timeOut = 0;
+ while (this.reportValue == null && timeOut <= 30)
+ {
+ System.Threading.Thread.Sleep(100);
+ timeOut++;
+ }
+ if (this.reportValue == null)
+ {
+ //鑾峰彇绌鸿皟妯″紡澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetAcModeFail);
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+ this.ShowMassage(ShowMsgType.Tip, msg);
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return;
+ }
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //鍒跺喎
+ this.AddAirConditionerModeRow(listView, "AC/Mode_Cool2.png", Language.StringByID(R.MyInternationalizationString.uMode_Cool), 0);
+ //鍒剁儹
+ this.AddAirConditionerModeRow(listView, "AC/Mode_Heat2.png", Language.StringByID(R.MyInternationalizationString.uMode_Heat), 1);
+ //鑷姩
+ this.AddAirConditionerModeRow(listView, "AC/Mode_AutoSelected.png", Language.StringByID(R.MyInternationalizationString.uMode_Auto), 4);
+ //閫侀
+ this.AddAirConditionerModeRow(listView, "AC/Mode_Fan2.png", Language.StringByID(R.MyInternationalizationString.uMode_FanOnly), 2);
+ //闄ゆ箍
+ this.AddAirConditionerModeRow(listView, "AC/Mode_Dry2.png", Language.StringByID(R.MyInternationalizationString.uMode_Dry), 3);
+
+ listView.AdjustRealHeight(Application.GetRealHeight(23));
+
+ //淇濆瓨
+ var btnOk = new BottomClickButton();
+ btnOk.TextID = R.MyInternationalizationString.uSave;
+ bodyFrameLayout.AddChidren(btnOk);
+ btnOk.ButtonClickEvent += (sender, e) =>
+ {
+ if (this.oldReportValue == this.reportValue)
+ {
+ //鏁版嵁鐩稿悓,涓嶉渶瑕佷慨鏀�
+ this.CloseForm();
+ return;
+ }
+ //灏嗕簩杩涘埗杞崲涓哄崄杩涘埗
+ var data = Convert.ToInt32(this.fixValue + this.reportValue, 2);
+ var result = HdlDeviceAirConditionerLogic.Current.SetAcModeSupport(deviceAc, data);
+ if (result == true)
+ {
+ //鏇存敼缂撳瓨
+ for (int i = 0; i < this.reportValue.Length; i++)
+ {
+ deviceAc.listSupportMode[i] = Convert.ToInt32(reportValue[i].ToString());
+ }
+ deviceAc.ReSave();
+ this.CloseForm();
+ }
+ };
+ });
+ });
}
/// <summary>
@@ -90,21 +149,96 @@
//鏄剧ず鏂囨湰
var btnText = rowFrame.AddLeftCaption(textValue, 400);
btnText.TextSize = 15;
- if (div != 5)
+ if (div != 3)
{
//搴曠嚎
rowFrame.AddBottomLine();
}
//閫夋嫨
var btnSelect = rowFrame.AddMostRightEmptyIcon(58, 58);
- btnSelect.Visible = false;
+ if (this.reportValue[div] == '0')
+ {
+ btnSelect.Visible = false;
+ }
btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
rowFrame.ButtonClickEvent += (sender, e) =>
{
btnSelect.Visible = !btnSelect.Visible;
+ //鍙樻洿鍊�
+ if (btnSelect.Visible == true)
+ {
+ this.reportValue = reportValue.Substring(0, div) + "1" + reportValue.Substring(div + 1);
+ }
+ else
+ {
+ this.reportValue = reportValue.Substring(0, div) + "0" + reportValue.Substring(div + 1);
+ }
};
}
#endregion
+
+ #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) =>
+ {
+ string checkKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
+ if (checkKeys != mainkeys || report.DeviceStatusReport.CluterID != 513)
+ {
+ return;
+ }
+ for (int i = 0; i < report.DeviceStatusReport.AttriBute.Count; i++)
+ {
+ var data = report.DeviceStatusReport.AttriBute[i];
+ if (data.AttributeId == 4099)
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
+ //杞崲涓轰簩杩涘埗
+ var value = Convert.ToString(data.AttriButeData, 2).PadLeft(16, '0');
+ //杩欎簲涓缃槸鏀惧湪鍚庨潰鐨�
+ this.fixValue = value.Substring(0, value.Length - 5);
+ this.reportValue = value.Substring(this.fixValue.Length);
+ oldReportValue = reportValue;
+ }
+ }
+ });
+ //鍙戦�佽鍙栫┖璋冭嚜瀹氫箟妯″紡
+ deviceAc.ReadModeSupport();
+ }
+
+ #endregion
+
+ #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+ /// <summary>
+ /// 鐣岄潰鍏抽棴
+ /// </summary>
+ public override void CloseFormBefore()
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("ReadAirConditionerModeSupport");
+
+ base.CloseFormBefore();
+ }
+
+ #endregion
}
}
--
Gitblit v1.8.0