From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 18 九月 2020 13:58:19 +0800
Subject: [PATCH] 新版本
---
ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs | 137 ++++++++++++++++++++++++---------------------
1 files changed, 74 insertions(+), 63 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs
index e879acf..c34be8b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs
@@ -19,7 +19,11 @@
/// <summary>
/// 妗屽竷鎺т欢
/// </summary>
- private FrameLayout frameTable = null;
+ private NormalFrameLayout frameTable = null;
+ /// <summary>
+ /// 璁惧鍒楄〃
+ /// </summary>
+ private List<CommonDevice> listDevice = new List<CommonDevice>();
#endregion
@@ -49,7 +53,7 @@
this.ClearBodyFrame();
//鍒濆鍖栨甯冩帶浠�
- this.frameTable = new FrameLayout();
+ this.frameTable = new NormalFrameLayout();
frameTable.Y = Application.GetRealHeight(187);
frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
bodyFrameLayout.AddChidren(frameTable);
@@ -68,7 +72,7 @@
bodyFrameLayout.AddChidren(tabControl);
tabControl.SelectTabEvent += (tabIndex) =>
{
- if (tabIndex == 1)
+ if (tabIndex == 0)
{
//鏄剧ず鍦烘櫙鍒楄〃
this.ShowSceneList();
@@ -79,7 +83,11 @@
this.ShowFunctionList();
}
};
- tabControl.InitControl();
+ var listTitle = new List<string>();
+ //鍦烘櫙,鍔熻兘
+ listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
+ listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
+ tabControl.InitControl(listTitle);
}
#endregion
@@ -95,21 +103,26 @@
this.frameTable.RemoveAll();
HdlThreadLogic.Current.RunMainInThread(() =>
{
- if (lookRoom.SceneUIList.Count == 0)
+ if (lookRoom.ListSceneId.Count == 0)
{
//杩樻病鏈夋坊鍔犲満鏅摝
this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddScenceMsg));
return;
}
- var listView = new VerticalFrameControl(29);
+ var listView = new VerticalFrameControl(3);
listView.Height = frameTable.Height;
frameTable.AddChidren(listView);
- foreach (var data in lookRoom.SceneUIList)
+ foreach (var dataId in lookRoom.ListSceneId)
{
+ var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId);
+ if (data == null)
+ {
+ continue;
+ }
//鍦烘櫙鎺т欢
var frameContr = new ScenePictrueControl();
- listView.AddChidrenFrame(frameContr);
+ listView.AddChidren(frameContr);
frameContr.InitControl(data);
}
});
@@ -152,26 +165,24 @@
frameBack.AddChidren(listView);
var dicData = new Dictionary<string, DeviceRowInfo>();
- var listGwId = new List<string>();
- foreach (var textId in dicGroupDevice.Keys)
+ foreach (var strText in dicGroupDevice.Keys)
{
//娣诲姞璁惧琛�
- this.AddDeviceRow(dicGroupDevice[textId], textId, listView);
- foreach (var deviceKey in dicGroupDevice[textId].listDeviceKeys)
+ this.AddDeviceRow(dicGroupDevice[strText], strText, listView);
+ foreach (var deviceKey in dicGroupDevice[strText].listDeviceKeys)
{
var device = Common.LocalDevice.Current.GetDevice(deviceKey);
- if (listGwId.Contains(device.CurrentGateWayId) == false)
- {
- //缃戝叧ID
- listGwId.Add(device.CurrentGateWayId);
- }
//浠ュ洖璺綔涓虹储寮曞幓鎸囧畾瀵硅薄
- dicData[deviceKey] = dicGroupDevice[textId];
+ dicData[deviceKey] = dicGroupDevice[strText];
}
}
listView.AdjustRealHeight(Application.GetRealHeight(23));
- //寮�鍚澶囧湪绾跨洃娴�
- this.StartCheckDeviceOnline(listView, listGwId, dicData);
+ //濡傛灉涓嶆槸铏氭嫙浣忓畢
+ if (Common.Config.Instance.Home.IsVirtually == false)
+ {
+ //寮�鍚澶囧湪绾跨洃娴�
+ this.StartCheckDeviceOnline(listView, dicData);
+ }
});
}
@@ -183,9 +194,9 @@
/// 娣诲姞璁惧琛�
/// </summary>
/// <param name="rowInfo"></param>
- /// <param name="TextId"></param>
+ /// <param name="strText"></param>
/// <param name="listView"></param>
- private void AddDeviceRow(DeviceRowInfo rowInfo, int TextId, VerticalListControl listView)
+ private void AddDeviceRow(DeviceRowInfo rowInfo, string strText, VerticalListControl listView)
{
var frameRow = new FrameRowControl(listView.rowSpace / 2);
frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft;
@@ -196,7 +207,7 @@
btnIcon.UnSelectedImagePath = rowInfo.IconPath;
//鍚嶇О
var btnView = frameRow.AddLeftCaption(string.Empty, 600);
- btnView.TextID = TextId;
+ btnView.Text = strText;
btnView.TextSize = 15;
//鍙崇澶�
frameRow.AddRightArrow();
@@ -208,7 +219,7 @@
frameRow.ButtonClickEvent += (sender, e) =>
{
var form = new LookRoomDeviceListForm();
- form.AddForm(lookRoom.Name, Language.StringByID(TextId), rowInfo.listDeviceKeys);
+ form.AddForm(lookRoom.Name, strText, rowInfo.listDeviceKeys);
};
}
@@ -220,25 +231,25 @@
/// 鑾峰彇鍒嗙粍鍚庣殑璁惧
/// </summary>
/// <returns></returns>
- private Dictionary<int, DeviceRowInfo> GetAllGroupDevice()
+ private Dictionary<string, DeviceRowInfo> GetAllGroupDevice()
{
//鍏ㄩ儴鐨勮澶�
- var listDevice = lookRoom.GetRoomListDevice();
- var dic = new Dictionary<int, DeviceRowInfo>();
+ this.listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom);
+ var dic = new Dictionary<string, DeviceRowInfo>();
foreach (var device in listDevice)
{
var typeInfo = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device);
//鎸夋墍灞濱D鍒嗙粍
- if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
+ if (dic.ContainsKey(typeInfo.BeloneText) == false)
{
- dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
+ dic[typeInfo.BeloneText] = new DeviceRowInfo();
string path1 = string.Empty;
string path2 = string.Empty;
//鑾峰彇鍥剧墖
- Common.LocalDevice.Current.GetDeviceObjectIcon(typeInfo.ConcreteType, ref path1, ref path2);
- dic[typeInfo.BeloneTextId].IconPath = path1;
+ Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
+ dic[typeInfo.BeloneText].IconPath = path1;
}
- dic[typeInfo.BeloneTextId].listDeviceKeys.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
+ dic[typeInfo.BeloneText].listDeviceKeys.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
}
return dic;
}
@@ -251,48 +262,48 @@
/// 寮�鍚澶囧湪绾跨洃娴�
/// </summary>
/// <param name="listView">鍒ゆ柇閫�鍑烘椂浣跨敤</param>
- /// <param name="listGwId">缃戝叧ID</param>
/// <param name="dicData">浠ュ洖璺綔涓虹储寮曞幓鎸囧畾瀵硅薄</param>
- private void StartCheckDeviceOnline(VerticalListControl listView, List<string> listGwId, Dictionary<string, DeviceRowInfo> dicData)
+ private void StartCheckDeviceOnline(VerticalListControl listView, Dictionary<string, DeviceRowInfo> dicData)
{
HdlThreadLogic.Current.RunThread(() =>
{
- var listCheck = new HashSet<string>();
- for (int i = 0; i < listGwId.Count; i++)
+ var dicCheck = new Dictionary<string, bool>();
+ for (int i = 0; i < this.listDevice.Count; i++)
{
if (listView.Parent == null)
{
return;
}
- //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵��
- var zbway = HdlGatewayLogic.Current.GetLocalGateway(listGwId[i]);
- var result = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, (device) =>
- {
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
- if (listView.Parent == null || dicData.ContainsKey(mainkeys) == false || listCheck.Contains(mainkeys) == true)
- {
- return;
- }
- listCheck.Add(mainkeys);
+ var localDevice = this.listDevice[i];
+ if (dicCheck.ContainsKey(localDevice.DeviceAddr) == false)
+ {
+ //鍙渶瑕佹娴嬩竴璺�
+ var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(localDevice);
+ if (deviceInfo != null)
+ {
+ localDevice.IsOnline = deviceInfo.IsOnline;
+ dicCheck[localDevice.DeviceAddr] = Common.LocalDevice.Current.CheckDeviceIsOnline(localDevice, false);
+ }
+ }
+ if (dicCheck.ContainsKey(localDevice.DeviceAddr) == false
+ || dicCheck[localDevice.DeviceAddr] == false)
+ {
+ //缃戝叧娌℃湁鍥炲,鎴栬�呬笉鍦ㄧ嚎
+ continue;
+ }
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(localDevice);
+ if (dicData.ContainsKey(mainkeys) == true)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ dicData[mainkeys].OnlineCount += 1;
+ dicData[mainkeys].btnOnline.Text = dicData[mainkeys].OnlineCount + "/" + dicData[mainkeys].listDeviceKeys.Count;
- var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
- if (localDevice != null && localDevice.IsOnline != device.IsOnline)
- {
- //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
- localDevice.IsOnline = device.IsOnline;
- localDevice.ReSave();
- }
- if (device.IsOnline == 1)
- {
- HdlThreadLogic.Current.RunMain(() =>
- {
- dicData[mainkeys].OnlineCount += 1;
- dicData[mainkeys].btnOnline.Text = dicData[mainkeys].OnlineCount + "/" + dicData[mainkeys].listDeviceKeys.Count;
- });
- }
- }, ShowErrorMode.NO);
+ }, ShowErrorMode.NO);
+ }
+ System.Threading.Thread.Sleep(30);
}
- });
+ }, ShowErrorMode.NO);
}
#endregion
--
Gitblit v1.8.0