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/AirConditioner/IndoorUnitListForm.cs | 215 ++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 152 insertions(+), 63 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
index b61a0b0..5dadc7f 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
@@ -20,6 +20,14 @@
/// 鎺т欢淇℃伅
/// </summary>
private Dictionary<string, RowControlInfo> dicControl = new Dictionary<string, RowControlInfo>();
+ /// <summary>
+ /// 婵�娲荤殑璁惧鍦板潃
+ /// </summary>
+ private string actionDeviceKeys = null;
+ /// <summary>
+ /// 鎺ユ敹鍥炲鐨勭鐐�
+ /// </summary>
+ private HashSet<int> listReceivePoint = new HashSet<int>();
#endregion
@@ -31,7 +39,12 @@
/// <param name="i_diviceMac">璁惧Mac鍦板潃</param>
public void ShowForm(string i_diviceMac)
{
- this.listDevice = Common.LocalDevice.Current.GetDevicesByMac(i_diviceMac);
+ this.listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(i_diviceMac);
+ //鏀堕泦鍏ㄩ儴绔偣
+ foreach (var device in this.listDevice)
+ {
+ listReceivePoint.Add(device.DeviceEpoint);
+ }
//璁剧疆澶撮儴淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion));
@@ -53,7 +66,7 @@
var frameTemp = new FrameLayout();
frameTemp.Height = Application.GetRealHeight(69);
- listView.AddChidrenFrame(frameTemp);
+ listView.AddChidren(frameTemp);
HdlThreadLogic.Current.RunMainInThread(() =>
{
@@ -64,7 +77,7 @@
}
var frameTemp2 = new FrameLayout();
frameTemp2.Height = Application.GetRealHeight(29);
- listView.AddChidrenFrame(frameTemp2);
+ listView.AddChidren(frameTemp2);
//鏁版嵁鎺ユ敹
this.StartReceiveDataEvent();
@@ -82,54 +95,66 @@
{
var rowInfo = new RowControlInfo();
- var frameTable = new FrameLayoutControl();
+ var frameTable = new FrameLayoutStatuControl();
frameTable.UseClickStatu = false;
frameTable.Width = Application.GetRealWidth(994);
frameTable.Height = Application.GetRealHeight(337);
frameTable.BackgroundImagePath = "Item/IndoorUnitGround.png";
frameTable.Gravity = Gravity.CenterHorizontal;
- listView.AddChidrenFrame(frameTable);
+ listView.AddChidren(frameTable);
//璁惧鍥炬爣
var btnIconBack = new FrameLayout();
btnIconBack.X = Application.GetRealWidth(46);
btnIconBack.Y = Application.GetRealHeight(43);
- btnIconBack.Height = Application.GetMinRealAverage(112);
- btnIconBack.Width = Application.GetMinRealAverage(112);
- btnIconBack.Radius = (uint)Application.GetMinRealAverage(112) / 2;
+ btnIconBack.Height = this.GetPictrueRealSize(112);
+ btnIconBack.Width = this.GetPictrueRealSize(112);
+ btnIconBack.Radius = (uint)this.GetPictrueRealSize(112) / 2;
btnIconBack.BackgroundColor = 0xfff5f6fa;
frameTable.AddChidren(btnIconBack, ChidrenBindMode.NotBind);
rowInfo.btnIconBack = btnIconBack;
var btnIcon = new IconViewControl(78);
btnIcon.Gravity = Gravity.Center;
- Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
+ HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnIcon, device);
btnIconBack.AddChidren(btnIcon);
- frameTable.ChangedChidrenBindMode(btnIconBack, ChidrenBindMode.BindEventOnly);
+ frameTable.ChangedChidrenBindMode(btnIconBack, ChidrenBindMode.BindEvent);
rowInfo.btnIcon = btnIcon;
//璁惧鍚嶇О
- var btnDeviceName = new NormalViewControl(400, 60, true);
- btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+ var btnDeviceName = new NormalViewControl(700, 60, true);
+ btnDeviceName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
btnDeviceName.X = Application.GetRealWidth(193);
btnDeviceName.Y = Application.GetRealHeight(45);
- frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
+ frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
+ rowInfo.btnDeviceName = btnDeviceName;
//鎴块棿
var btnRoom = new NormalViewControl(400, 50, true);
btnRoom.X = btnDeviceName.X;
btnRoom.Y = btnDeviceName.Bottom + Application.GetRealHeight(12);
btnRoom.TextSize = 12;
btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
- btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
- frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly);
+ btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device);
+ frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEvent);
+ rowInfo.btnRoom = btnRoom;
//鎽勬皬搴�
var btnValue = new NormalViewControl(300, 60, true);
btnValue.Y = Application.GetRealHeight(58);
btnValue.X = frameTable.Width - Application.GetRealWidth(300 + 58);
btnValue.TextAlignment = TextAlignment.CenterRight;
- btnValue.TextID = R.MyInternationalizationString.uGetting;
- frameTable.AddChidren(btnValue, ChidrenBindMode.BindEventOnly);
+ frameTable.AddChidren(btnValue, ChidrenBindMode.BindEvent);
rowInfo.btnValue = btnValue;
+ //瀹ゅ唴娓╁害
+ if (device.currentLocalTemperature == 0)
+ {
+ //0鈩�
+ btnValue.Text = "0.0鈩�";
+ }
+ else
+ {
+ btnValue.Text = device.currentLocalTemperature + ".0鈩�";
+ }
+
//璀﹀憡鍥炬爣
var btnWarningIcon = new IconViewControl(69);
btnWarningIcon.X = btnIconBack.X;
@@ -158,36 +183,56 @@
{
if (btnSwitch.IsSelected == false)
{
- //鎵撳紑绌鸿皟
- var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
- if (result == false)
+ //濡傛灉涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+ if (Common.Config.Instance.Home.IsVirtually == false)
{
- return;
+ //鎵撳紑绌鸿皟
+ var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
+ if (result == false)
+ {
+ return;
+ }
}
btnIcon.IsSelected = true;
btnIconBack.BackgroundColor = 0xfffef1ed;
}
else
{
- //鍏抽棴绌鸿皟
- var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
- if (result == false)
+ //濡傛灉涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+ if (Common.Config.Instance.Home.IsVirtually == false)
{
- return;
+ //鍏抽棴绌鸿皟
+ var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
+ if (result == false)
+ {
+ return;
+ }
}
btnIcon.IsSelected = false;
btnIconBack.BackgroundColor = 0xfff5f6fa;
}
btnSwitch.IsSelected = !btnSwitch.IsSelected;
+ //濡傛灉鏄櫄鎷熶綇瀹呯殑璇�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ device.currentSystemMode = btnSwitch.IsSelected == true ? 3 : 0;
+ }
};
+ //濡傛灉鏄睍绀烘ā鏉跨殑璇�
+ if (Common.Config.Instance.Home.IsShowTemplate == true)
+ {
+ btnSwitch.CanClick = false;
+ }
frameTable.ButtonClickEvent += (sender, e) =>
{
+ this.actionDeviceKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+
var form = new IndoorUnitSettionForm();
form.AddForm(device);
};
- dicControl[Common.LocalDevice.Current.GetDeviceMainKeys(device)] = rowInfo;
+ dicControl[HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device)] = rowInfo;
}
#endregion
@@ -199,25 +244,31 @@
/// </summary>
private void SetReadAttributeComand()
{
+ //濡傛灉鏄櫄鎷熶綇瀹呮垨鑰呭睍绀烘ā鏉跨殑璇�
+ if (Common.Config.Instance.Home.IsShowTemplate == true || Common.Config.Instance.Home.IsVirtually == true)
+ {
+ return;
+ }
HdlThreadLogic.Current.RunThread(() =>
{
- for (int i = 0; i < listDevice.Count; i++)
+ while (this.listReceivePoint.Count > 0 && this.Parent != null)
{
- if (i != 0 && i % 5 == 0)
+ for (int i = 0; i < listDevice.Count; i++)
{
- //璇诲彇5涓悗锛岄棿闅斾竴娈垫椂闂�
- System.Threading.Thread.Sleep(200);
if (this.Parent == null)
{
return;
}
+ //宸茬粡鍙戦�佽繃浜�,灏变笉鐢ㄥ啀鍙戦��
+ if (this.listReceivePoint.Contains(listDevice[i].DeviceEpoint) == true)
+ {
+ //璇诲彇鐘舵��
+ HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
+ System.Threading.Thread.Sleep(200);
+ }
}
- //鑾峰彇褰撳墠瀹ゆ俯
- ((AC)listDevice[i]).ReadLocalTemperature();
- //鑾峰彇寮�鍏崇姸鎬�(澶勪簬鏌愮宸ヤ綔鐘舵��,鍗充负鎵撳紑鐘舵��)
- ((AC)listDevice[i]).ReadSystemMode();
- //娓呮礂婊ょ綉
- listDevice[i].ReadAttri(Cluster_ID.Thermostat, AttriButeId.FilterCleaningStatus);
+ //3绉掑悗鍐嶆寰幆
+ System.Threading.Thread.Sleep(3000);
}
});
}
@@ -233,11 +284,18 @@
{
HdlGatewayReceiveLogic.Current.AddAttributeEvent("IndoorUnitListFormEvent", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) =>
{
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+ string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
if (dicControl.ContainsKey(mainkeys) == false || device.DeviceStatusReport.CluterID != 513)
{
return;
}
+ var localDevice = HdlDeviceCommonLogic.Current.GetDevice(mainkeys);
+ if (localDevice == null)
+ {
+ return;
+ }
+ //宸茬粡鎺ユ敹鍒版暟鎹�,鍒欑Щ闄ょ鐐�
+ this.listReceivePoint.Remove(device.DeviceEpoint);
var rowInfo = dicControl[mainkeys];
for (int i = 0; i < device.DeviceStatusReport.AttriBute.Count; i++)
@@ -245,27 +303,19 @@
var data = device.DeviceStatusReport.AttriBute[i];
if (data.AttributeId == 0)
{
- //瀹ゅ唴娓╁害
- if (data.AttriButeData == 0)
+ HdlThreadLogic.Current.RunMain(() =>
{
- //0鈩�
- rowInfo.btnValue.Text = "0.0鈩�";
- }
- else if (data.AttriButeData > 32767)
- {
- //璐熸暟(鐗规畩澶勭悊)
- string strValue = (data.AttriButeData - 65536).ToString();
- //灏忔暟鐐归渶瑕佷竴浣�
- strValue = strValue.Substring(0, strValue.Length - 1);
- rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
- }
- else
- {
- //灏忔暟鐐归渶瑕佷竴浣�
- string strValue = data.AttriButeData.ToString();
- strValue = strValue.Substring(0, strValue.Length - 1);
- rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
- }
+ //瀹ゅ唴娓╁害
+ if (((AC)localDevice).currentLocalTemperature == 0)
+ {
+ //0鈩�
+ rowInfo.btnValue.Text = "0.0鈩�";
+ }
+ else
+ {
+ rowInfo.btnValue.Text = ((AC)localDevice).currentLocalTemperature + ".0鈩�";
+ }
+ });
}
else if (data.AttributeId == 28)
{
@@ -273,9 +323,12 @@
//Off = 0 Auto = 1 Cool = 3 Heat = 4 FanOnly = 7 Dry = 8
if (data.AttriButeData != 0)
{
- rowInfo.btnSwitch.IsSelected = true;
- rowInfo.btnIcon.IsSelected = true;
- rowInfo.btnIconBack.BackgroundColor = 0xfffef1ed;
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ rowInfo.btnSwitch.IsSelected = true;
+ rowInfo.btnIcon.IsSelected = true;
+ rowInfo.btnIconBack.BackgroundColor = 0xfffef1ed;
+ });
}
}
else if (data.AttributeId == 4097)
@@ -283,9 +336,12 @@
//42:闇�瑕佹竻娲楁护缃�
if (data.AttriButeData == 42)
{
- rowInfo.btnWarningIcon.Visible = true;
- //璇锋敞鎰忔竻娲楁护缃戝摝
- rowInfo.btnWarningMsg.TextID = R.MyInternationalizationString.uPleaseClreanACfilter;
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ rowInfo.btnWarningIcon.Visible = true;
+ //璇锋敞鎰忔竻娲楁护缃戝摝
+ rowInfo.btnWarningMsg.TextID = R.MyInternationalizationString.uPleaseClreanACfilter;
+ });
}
}
}
@@ -308,6 +364,31 @@
#endregion
+ #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+ /// <summary>
+ /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
+ /// </summary>
+ public override int FormActionAgainEvent()
+ {
+ if (this.actionDeviceKeys != null && dicControl.ContainsKey(this.actionDeviceKeys) == true)
+ {
+ //鍒锋柊璁惧淇℃伅
+ var device = HdlDeviceCommonLogic.Current.GetDevice(this.actionDeviceKeys);
+ if (device != null)
+ {
+ var contr = dicControl[this.actionDeviceKeys];
+ contr.btnDeviceName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
+ contr.btnRoom.Text = HdlRoomLogic.Current.GetRoomNameByDevice(device);
+ }
+ }
+ this.actionDeviceKeys = null;
+
+ return 1;
+ }
+
+ #endregion
+
#region 鈻� 缁撴瀯浣揰____________________________
/// <summary>
@@ -316,6 +397,14 @@
private class RowControlInfo
{
/// <summary>
+ /// 璁惧鍚嶅瓧
+ /// </summary>
+ public NormalViewControl btnDeviceName = null;
+ /// <summary>
+ /// 璁惧鎴块棿
+ /// </summary>
+ public NormalViewControl btnRoom = null;
+ /// <summary>
/// 璁惧鍥炬爣鑳屾櫙
/// </summary>
public FrameLayout btnIconBack = null;
--
Gitblit v1.8.0