From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码
---
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 536 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 385 insertions(+), 151 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
index 04fb935..1c30f0e 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -1,4 +1,5 @@
锘縰sing Shared.Common;
+using Shared.Phone.UserCenter.SmartSound;
using System;
using System.Collections.Generic;
using System.Text;
@@ -12,7 +13,10 @@
public class DeviceListMainForm : EditorCommonForm
{
#region 鈻� 鍙橀噺澹版槑___________________________
-
+ /// <summary>
+ /// 鏅鸿兘闊崇
+ /// </summary>
+ private MySmartSoundControl smmartSoundView = null;
/// <summary>
/// 缃戝叧鎺т欢
/// </summary>
@@ -29,10 +33,6 @@
/// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃)
/// </summary>
private Dictionary<string, DeviceObjRowInfo> dicRowInfo = new Dictionary<string, DeviceObjRowInfo>();
- /// <summary>
- /// 閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬�
- /// </summary>
- private bool reGetDeviceOnlineStatu = false;
/// <summary>
/// 褰撳墠姝e湪鎿嶄綔鐨勮澶囧璞ac鍦板潃(璁惧淇℃伅缂栬緫鐣岄潰鐢�)
/// </summary>
@@ -59,41 +59,53 @@
btnAddDeviceIcon.InitControl();
btnAddDeviceIcon.ButtonClickEvent += (sender, e) =>
{
- ZbGateway realWay = null;
- if (GatewayResourse.NowSelectGateway == null || HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == false)
- {
- //缃戝叧瀵硅薄寮傚父,璇烽噸鏂伴�夋嫨缃戝叧
- string msg = Language.StringByID(R.MyInternationalizationString.uGatewayIsErrorAndReSelect);
- this.ShowMassage(ShowMsgType.Error, msg, () =>
- {
- var form2 = new GatewayManage.GatewayListForm();
- form2.AddForm();
- });
- return;
- }
- GatewayResourse.NowSelectGateway = realWay;
-
var form = new DeviceDirection.AddDeviceTypeListForm();
form.AddForm();
};
//鍒濆鍖栦腑閮ㄦ帶浠�
this.InitMiddleFrame();
+
+ //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
+ this.StartCheckDeviceAlarm();
+ //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚�
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) =>
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //鎺ュ彈璁惧鐘舵��
+ this.ReceiveDeviceStatu(report);
+
+ }, ShowErrorMode.NO);
+ });
+ //寮�鍚娴嬬綉鍏冲湪绾跨姸鎬佺殑绾跨▼
+ HdlGatewayLogic.Current.StartCheckGatewayOnlineThread(this);
}
/// <summary>
/// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤)
/// </summary>
- /// <param name="i_reGetDeviceOnlineStatu">閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬�</param>
- public void InitMiddleFrame(bool i_reGetDeviceOnlineStatu = true)
+ public void InitMiddleFrame()
{
- this.reGetDeviceOnlineStatu = i_reGetDeviceOnlineStatu;
//娓呯┖bodyFrame
this.ClearBodyFrame();
+ smmartSoundView = new MySmartSoundControl();
+ bodyFrameLayout.AddChidren(smmartSoundView);
+ smmartSoundView.InitControl();
+ //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+ if (Config.Instance.Home.IsVirtually == false)
+ {
+ smmartSoundView.ButtonClickEvent += (sernder, e) =>
+ {
+ var form = new SmartSoundListForm();
+ form.AddForm();
+ };
+ }
//鍒濆鍖栫綉鍏宠鎺т欢
- GatewayResourse.NowSelectGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId);
- this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway);
+ GatewayResourse.NowSelectGatewayId = GatewayResourse.AppOldSelectGatewayId;
+ var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId);
+ this.gatewayViewRow = new MyGatewayControl(nowGateway);
bodyFrameLayout.AddChidren(gatewayViewRow);
gatewayViewRow.InitControl();
@@ -138,6 +150,9 @@
frame.AddChidren(listView);
listView.BeginHeaderRefreshingAction += () =>
{
+ //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+ UserView.UserPage.Instance.RefreshAllForm = true;
+
HdlThreadLogic.Current.RunThread(() =>
{
//涓嬫媺鍒锋柊
@@ -156,9 +171,8 @@
private void InitDeviceListControl()
{
//鑾峰彇璁惧鍒楄〃
- string gwID = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
- var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwID);
- var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(gwID);
+ var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(GatewayResourse.NowSelectGatewayId);
+ var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(GatewayResourse.NowSelectGatewayId);
listDevice.AddRange(listSpecialOta);
this.dicRowInfo.Clear();
@@ -190,11 +204,14 @@
//娣诲姞璁惧鐨勮彍鍗曡
this.AddDeviceMenuRow(macAddress);
}
-
- //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
- this.StartGatewayOnlieCheckThread();
- //妫�娴嬭澶囨柊鐗堟湰
- this.CheckDeviceNewVersion(listOta);
+ //濡傛灉褰撳墠涓嶆槸铏氭嫙浣忓畢
+ if (Common.Config.Instance.Home.IsVirtually == false)
+ {
+ //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
+ this.StartGatewayOnlieCheckThread();
+ //妫�娴嬭澶囨柊鐗堟湰
+ this.CheckDeviceNewVersion(listOta);
+ }
});
}
@@ -231,7 +248,7 @@
//鎻愮ず鏂扮増鏈�
var btnNew = new InformationTipView(rowMenu.btnIcon);
btnNew.Visible = false;
- rowMenu.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly);
+ rowMenu.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEvent);
rowMenu.AddTag("btnNew", btnNew);
//妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘
@@ -239,13 +256,8 @@
if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true)
{
//瀹氫綅
- var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowMenu.Height, false);
+ var btnPosition = rowMenu.AddEditorControl(false);
btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
- btnPosition.TextAlignment = TextAlignment.Center;
- btnPosition.TextSize = 12;
- btnPosition.TextColor = UserCenterColor.Current.White;
- btnPosition.BackgroundColor = 0xff4a4a4a;
- rowMenu.AddRightView(btnPosition);
btnPosition.ButtonClickEvent += (sender, e) =>
{
//瀹氫綅
@@ -275,6 +287,15 @@
rowMenu.frameTable.ButtonClickEvent += (sender, e) =>
{
+ //闅愯棌鑿滃崟
+ rowMenu.HideMenu();
+ //寮哄埗璺宠浆鐪熷疄璁惧鐣岄潰
+ if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1)
+ {
+ var form2 = new DeviceAddSuccessForm();
+ form2.AddForm(deviceMac);
+ return;
+ }
btnNew.Visible = false;
var form = new DeviceMacInfoEditorForm();
form.AddForm(deviceMac);
@@ -312,17 +333,52 @@
var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
if (isShow == true)
{
- //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠�
- heightValue = (listDevice.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace);
- //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢
- if (rowInfo.frameTable.ChildrenCount == 1)
+ //澶囨敞锛氶潰鏉夸腑鍙樉绀虹湡瀹炵殑璁惧锛屽叾浠栧睘浜庣粦瀹氱殑鍥炶矾涓嶆樉绀�
+ //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑
+ var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
+ if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
{
- //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑
- var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
- foreach (CommonDevice info in listDevice)
+ var listTemp = Common.LocalDevice.Current.GetMutilfunctionPanelByMac(listDevice);
+ //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠�
+ heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace);
+ //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢
+ if (rowInfo.frameTable.ChildrenCount == 1)
{
- //鍔犺浇瀹冪殑鍒楄〃
- this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
+ foreach (CommonDevice info in listTemp)
+ {
+ //鍔犺浇瀹冪殑鍒楄〃
+ this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
+ }
+ }
+ }
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
+ || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
+ {
+ var listTemp = Common.LocalDevice.Current.GetPanelMatchEpointByMac(listDevice);
+ //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠�
+ heightValue = (listTemp.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace);
+ //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢
+ if (rowInfo.frameTable.ChildrenCount == 1)
+ {
+ foreach (CommonDevice info in listTemp)
+ {
+ //鍔犺浇瀹冪殑鍒楄〃
+ this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
+ }
+ }
+ }
+ else
+ {
+ //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠�
+ heightValue = (listDevice.Count + 1) * (ControlCommonResourse.ListViewRowHeight + rowInfo.frameTable.rowSpace);
+ //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢
+ if (rowInfo.frameTable.ChildrenCount == 1)
+ {
+ foreach (CommonDevice info in listDevice)
+ {
+ //鍔犺浇瀹冪殑鍒楄〃
+ this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
+ }
}
}
}
@@ -355,8 +411,7 @@
//鍙崇澶�
rowDevice.frameTable.AddRightArrow();
//鍦ㄧ嚎鐘舵��
- rowDevice.isOnline = device.IsOnline == 1;
-
+ rowDevice.IsOnline = rowInfo.MenuRow.IsOnline;
//淇濆瓨鎺т欢
string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
rowInfo.dicDetailRow[maikey] = rowDevice;
@@ -365,13 +420,8 @@
if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(device) == true)
{
//瀹氫綅
- var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowDevice.Height, false);
+ var btnPosition = rowDevice.AddEditorControl(false);
btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
- btnPosition.TextAlignment = TextAlignment.Center;
- btnPosition.TextSize = 12;
- btnPosition.TextColor = UserCenterColor.Current.White;
- btnPosition.BackgroundColor = 0xff4a4a4a;
- rowDevice.AddRightView(btnPosition);
btnPosition.ButtonClickEvent += (sender, e) =>
{
//瀹氫綅
@@ -381,10 +431,16 @@
rowDevice.frameTable.ButtonClickEvent += (sender, e) =>
{
+ //闅愯棌鑿滃崟
+ rowDevice.HideMenu();
//鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
this.nowActionDeviceMac = device.DeviceAddr;
- //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰
- this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo);
+ //濡傛灉褰撳墠浣忓畢涓嶆槸铏氭嫙浣忓畢
+ if (Common.Config.Instance.Home.IsVirtually == false)
+ {
+ //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰
+ this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo);
+ }
};
//宸︽粦鑿滃崟浜嬩欢
rowDevice.OpenMenuAction += () =>
@@ -446,6 +502,37 @@
//鏂伴闈㈡澘
else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
{
+ //鏂规偊鏂伴闈㈡澘鐨勬寜閿厤缃�
+ //骞叉帴鐐�
+ if (device.Type == DeviceType.FreshAir)
+ {
+ var form = new DevicePanel.PanelFangyueFreshAirButtonSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
+ {
+
+ if (device.Type == DeviceType.FreshAir || device.Type == DeviceType.Thermostat)
+ {
+ var form = new DevicePanel.PanelSimpleEnvironmentButtonSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+ {
var form = new DeviceFunctionSettionForm();
form.AddForm(device, true);
}
@@ -466,7 +553,7 @@
{
//鏂规偊闈㈡澘鐨勫姛鑳介厤缃�
var form = new DevicePanel.PanelFangyueFunctionSettionForm();
- form.AddForm(device);
+ form.AddForm(device, deviceEnumInfo);
}
else
{
@@ -589,15 +676,28 @@
/// </summary>
private async void ListViewBeginHeaderRefreshing()
{
+ //濡傛灉褰撳墠浣忓畢鏄櫄鎷熺殑
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ //灏辨樉绀轰竴涓壒鏁堣�屽凡
+ System.Threading.Thread.Sleep(2000);
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //闅愯棌涓嬫媺鍒锋柊鐗规晥
+ listView.EndHeaderRefreshing();
+ });
+ return;
+ }
//濡傛灉鏄湪绾跨殑
- if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(GatewayResourse.NowSelectGateway) == true)
+ var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.NowSelectGatewayId);
+ if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(nowGateway) == true)
{
//妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D
ZbGateway realWay = null;
- if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == true)
+ if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, nowGateway) == true)
{
//閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆)
- if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
+ if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.HomeId) == true)
{
//鏄剧ず杩涘害鏉�
ProgressBar.Show();
@@ -617,7 +717,7 @@
}
//鑾峰彇鍏ㄩ儴璁惧
- int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway);
+ int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway);
if (this.Parent == null)
{
return;
@@ -629,7 +729,7 @@
if (result != -1)
{
//閲嶆柊鍒锋柊鐣岄潰
- this.InitMiddleFrame(false);
+ this.InitMiddleFrame();
}
});
}
@@ -643,12 +743,7 @@
/// </summary>
private void StartGatewayOnlieCheckThread()
{
- if (GatewayResourse.NowSelectGateway == null)
- {
- return;
- }
-
- string selectGwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
+ string selectGwId = GatewayResourse.NowSelectGatewayId;
HdlThreadLogic.Current.RunThread(() =>
{
ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId);
@@ -664,9 +759,10 @@
if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId)
{
bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbGateway);
- this.gatewayViewRow.RefreshControl();
- //寮�鍚澶囧湪绾跨嚎绋�
- this.StartDeviceListControlThread(online);
+ //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵��
+ this.gatewayViewRow?.RefreshOnlineStatu();
+ //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬�
+ this.RefreshDeviceOnlineStatuByGatewayOnline(online);
}
});
});
@@ -677,17 +773,25 @@
/// </summary>
/// <param name="gateWay">缃戝叧瀵硅薄</param>
/// <param name="online">鍦ㄧ嚎鐘舵�佸彉鏇村悗鐨勭姸鎬�</param>
- public override void GatewayOnlinePush(ZbGateway gateWay, bool online)
+ /// <param name="hadGwOnline">2020.05.25杩藉姞:姝や綇瀹呮槸鍚︽嫢鏈夌綉鍏冲湪绾�</param>
+ public override void GatewayOnlinePush(ZbGateway gateWay, bool online, bool hadGwOnline)
{
if (this.gatewayViewRow == null)
{
return;
}
- if (HdlGatewayLogic.Current.GetGatewayId(gateWay) == this.gatewayViewRow.zbGatewayId)
+ if (gateWay.GwId == this.gatewayViewRow.zbGatewayId)
{
Application.RunOnMainThread(() =>
{
- this.gatewayViewRow?.RefreshControl();
+ //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂�
+ if (this.gatewayViewRow.isOnline != online)
+ {
+ //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬�
+ this.RefreshDeviceOnlineStatuByGatewayOnline(online);
+ }
+ //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵��
+ this.gatewayViewRow?.RefreshOnlineStatu();
});
}
}
@@ -697,50 +801,54 @@
#region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________
/// <summary>
- /// 寮�鍚澶囧湪绾跨嚎绋�
+ /// 鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬�
/// </summary>
/// <param name="gatewayOnline">缃戝叧鐨勫湪绾跨姸鎬�</param>
- private void StartDeviceListControlThread(bool gatewayOnline)
+ private void RefreshDeviceOnlineStatuByGatewayOnline(bool gatewayOnline)
{
if (gatewayOnline == false)
{
//璁剧疆鍏ㄩ儴璁惧绂荤嚎
this.SetAllDeviceOffLine();
- return;
}
- //寮�鍚紶鎰熷櫒鎶ヨ鐩戣
- this.StartCheckDeviceAlarm();
- //寮�鍚澶囧湪绾跨洃娴�
- this.StartCheckDeviceOnline();
+ else
+ {
+ //鍒锋柊璁惧鍦ㄧ嚎鐘舵��
+ this.RefreshDeviceOnlineStatu();
+ }
}
/// <summary>
- /// 寮�鍚澶囧湪绾跨洃娴�
+ /// 鍒锋柊璁惧鍦ㄧ嚎鐘舵��
/// </summary>
- private void StartCheckDeviceOnline()
+ private void RefreshDeviceOnlineStatu()
{
- //澶栭儴璋冪敤鐨勮瘽,涓嶅啀閲嶆柊鑾峰彇璁惧鐘舵��
- if (GatewayResourse.NowSelectGateway == null || this.reGetDeviceOnlineStatu == false)
- {
- return;
- }
-
- //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚�
- HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu);
-
- string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
+ string gwId = GatewayResourse.NowSelectGatewayId;
HdlThreadLogic.Current.RunThread(() =>
{
- //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵��
- var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
- int statu = 0;
- var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
- if (statu != -1)
+ if (this.Parent == null) { return; }
+ //鑾峰彇璁惧鍒楄〃
+ var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwId);
+ var listCheck = new List<string>();
+ foreach (var device in listDevice)
{
- for (int i = 0; i < list.Count; i++)
+ if (this.Parent == null) { return; }
+ if (listCheck.Contains(device.DeviceAddr) == false)
{
- //璁剧疆璁惧鍦ㄧ嚎鐘舵��
- this.ReceiveDeviceStatu(list[i]);
+ //鍙涓�涓洖璺嵆鍙�
+ listCheck.Add(device.DeviceAddr);
+ var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
+ if (deviceInfo != null)
+ {
+ //鍙樻洿鍦ㄧ嚎鐘舵��
+ device.IsOnline = deviceInfo.IsOnline;
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //璁剧疆璁惧鍦ㄧ嚎鐘舵��
+ this.ReceiveDeviceStatu(device);
+ }, ShowErrorMode.NO);
+ }
+ System.Threading.Thread.Sleep(30);
}
}
});
@@ -766,30 +874,18 @@
var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
if (localDevice != null)
{
- //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
- if (localDevice.IsOnline == device.IsOnline)
- {
- return;
- }
//淇濆瓨鐘舵��
localDevice.IsOnline = device.IsOnline;
- localDevice.ReSave();
}
- HdlThreadLogic.Current.RunMain(() =>
+ rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
+ if (rowInfo.dicDetailRow != null)
{
- if (rowInfo != null)
+ foreach (var detailRow in rowInfo.dicDetailRow.Values)
{
- rowInfo.MenuRow.isOnline = device.IsOnline == 1;
- if (rowInfo.dicDetailRow != null)
- {
- foreach (var detailRow in rowInfo.dicDetailRow.Values)
- {
- detailRow.isOnline = rowInfo.MenuRow.isOnline;
- }
- }
+ detailRow.IsOnline = rowInfo.MenuRow.IsOnline;
}
- });
+ }
}
/// <summary>
@@ -797,17 +893,20 @@
/// </summary>
private void SetAllDeviceOffLine()
{
- lock (dicRowInfo)
+ foreach (var rowInfo in this.dicRowInfo.Values)
{
- foreach (var rowInfo in this.dicRowInfo.Values)
+ //鑿滃崟
+ if (rowInfo.MenuRow != null)
{
- Application.RunOnMainThread(() =>
+ rowInfo.MenuRow.IsOnline = false;
+ }
+ //鏄庣粏
+ if (rowInfo.dicDetailRow != null)
+ {
+ foreach (var detailRow in rowInfo.dicDetailRow.Values)
{
- if (rowInfo.MenuRow != null)
- {
- rowInfo.MenuRow.isOnline = false;
- }
- });
+ detailRow.IsOnline = false;
+ }
}
}
}
@@ -845,9 +944,9 @@
/// <param name="list">ota璁惧</param>
private void CheckDeviceNewVersion(List<OTADevice> list)
{
- HdlThreadLogic.Current.RunThread(async () =>
+ HdlThreadLogic.Current.RunThread(() =>
{
- await System.Threading.Tasks.Task.Delay(2000);
+ System.Threading.Thread.Sleep(2000);
foreach (var ota in list)
{
if (this.Parent == null)
@@ -855,7 +954,7 @@
return;
}
//娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�)
- var result = await HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
+ var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
//鑾峰彇璁惧鏈�鏂扮増鏈�
var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
@@ -869,7 +968,7 @@
}
//鎷ユ湁鏂扮増鏈�
- Application.RunOnMainThread(() =>
+ HdlThreadLogic.Current.RunMain(() =>
{
if (this.dicRowInfo.ContainsKey(ota.DeviceAddr) == true)
{
@@ -893,7 +992,7 @@
#region 鈻� 瀹炵幇澶栭儴璋冪敤_______________________
/// <summary>
- /// 娣诲姞鏂扮殑璁惧鍒扮晫闈㈡甯冧腑
+ /// 娣诲姞鏂扮殑璁惧鍒扮晫闈㈡甯冧腑(澶栭儴璋冪敤)
/// </summary>
/// <param name="deviceAddr">璁惧Mac鍦板潃</param>
public void AddDeviceToFormTable(string deviceAddr)
@@ -921,6 +1020,30 @@
//鍒涘缓鏂扮殑琛�
this.AddDeviceMenuRow(deviceAddr);
+
+ //璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
+ this.nowActionDeviceMac = deviceAddr;
+ }
+ }
+
+ /// <summary>
+ /// 鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅(澶栭儴璋冪敤)
+ /// </summary>
+ /// <param name="deviceAddr">璁惧Mac鍦板潃</param>
+ public void RefreshDeviceRow(string deviceAddr)
+ {
+ if (this.dicRowInfo.ContainsKey(deviceAddr) == true)
+ {
+ var row = this.dicRowInfo[deviceAddr];
+ row.MenuRow?.RefreshControlInfo(true);
+ //鏄庣粏
+ if (row.dicDetailRow != null)
+ {
+ foreach (var detailRow in row.dicDetailRow.Values)
+ {
+ detailRow.RefreshControlInfo();
+ }
+ }
}
}
@@ -941,6 +1064,20 @@
if (device == null || device.DeviceAddr == null)
{
continue;
+ }
+
+ //鑾峰彇璁惧绫诲瀷鐨�
+ var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+ if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleEnvironment)
+ {
+ foreach (var outClu in device.OutClusterList)
+ {
+ //鍘绘帀绠�绾︾幆澧冮潰鏉跨被鐨勫悇绉嶆湇鍔$璁惧锛屽鍐呮満涓嶆樉绀�
+ if (outClu.OutCluster == 513)
+ {
+ continue;
+ }
+ }
}
if (dic.ContainsKey(device.DeviceAddr) == false)
{
@@ -1015,8 +1152,6 @@
HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor");
HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline");
- GatewayResourse.NowSelectGateway = null;
-
base.CloseFormBefore();
}
@@ -1072,6 +1207,10 @@
/// 缃戝叧鍚嶅瓧鎺т欢
/// </summary>
private NormalViewControl btnName = null;
+ /// <summary>
+ /// 鍦ㄧ嚎鐘舵��
+ /// </summary>
+ public bool isOnline = false;
/// <summary>
/// 鑷畾涔夌綉鍏虫帶浠�
@@ -1080,8 +1219,12 @@
public MyGatewayControl(ZbGateway i_zbGateway)
{
this.UseClickStatu = false;
- this.zbGatewayId = HdlGatewayLogic.Current.GetGatewayId(i_zbGateway);
+ if (i_zbGateway != null)
+ {
+ this.zbGatewayId = i_zbGateway.GwId;
+ }
this.BackgroundColor = UserCenterColor.Current.White;
+ this.Y = Application.GetRealHeight(174);
this.Height = Application.GetRealHeight(173);
}
@@ -1094,16 +1237,34 @@
ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
//鍥炬爣
var btnIcon = this.AddLeftIcon(81);
- HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway);
+ if (zbway != null)
+ {
+ HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, zbway);
+ }
+ else
+ {
+ btnIcon.UnSelectedImagePath = "Gateway/GatewayIcon1.png";
+ }
//鏄剧ず鏂囨湰
- btnName = this.AddLeftCaption(HdlGatewayLogic.Current.GetGatewayName(zbway), 700);
+ btnName = this.AddLeftCaption(string.Empty, 700);
btnName.Height = Application.GetRealHeight(60);
btnName.TextSize = 15;
btnName.Y = Application.GetRealHeight(35);
- if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false)
+ if (zbway != null)
{
- btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
+ btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
+ //鍦ㄧ嚎鐘舵��
+ this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway);
+ if (this.isOnline == false)
+ {
+ btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
+ }
+ }
+ else
+ {
+ //铏氭嫙缃戝叧
+ btnName.Text = Language.StringByID(R.MyInternationalizationString.uVirtualGateway);
}
//褰撳墠缃戝叧
@@ -1120,15 +1281,19 @@
var btnMament = this.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGatewayManagement), 300);
btnMament.Name = "btnMament";
- this.ButtonClickEvent += (sernder, e) =>
+ //褰撳墠涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+ if (Common.Config.Instance.Home.IsVirtually == false)
{
- if (string.IsNullOrEmpty(((View)sernder).Name) == false)
+ this.ButtonClickEvent += (sernder, e) =>
{
- //鎵撳紑缃戝叧鍒楄〃鐣岄潰
- var form = new GatewayManage.GatewayListForm();
- form.AddForm();
- }
- };
+ if (string.IsNullOrEmpty(((View)sernder).Name) == false)
+ {
+ //鎵撳紑缃戝叧鍒楄〃鐣岄潰
+ var form = new GatewayManage.GatewayListForm();
+ form.AddForm();
+ }
+ };
+ }
}
/// <summary>
@@ -1143,17 +1308,86 @@
return;
}
btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
- if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false)
+ //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵��
+ this.RefreshOnlineStatu();
+ }
+
+ /// <summary>
+ /// 鍒锋柊鎺т欢鍦ㄧ嚎鐘舵��
+ /// </summary>
+ public void RefreshOnlineStatu()
+ {
+ //鑾峰彇鏈湴缃戝叧瀵硅薄
+ ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
+ if (zbway == null)
{
- btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
+ return;
}
- else
+ //鍦ㄧ嚎鐘舵��
+ bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway);
+ if (this.isOnline != statu)
{
- btnName.TextColor = UserCenterColor.Current.TextColor1;
+ this.isOnline = statu;
+ if (this.isOnline == false)
+ {
+ btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
+ }
+ else
+ {
+ btnName.TextColor = UserCenterColor.Current.TextColor1;
+ }
}
}
}
+ #endregion
+ #region 鈻� 鑷畾涔夋櫤鑳介煶绠辨帶浠禵________________
+
+ /// <summary>
+ /// 鑷畾涔夌綉鍏虫帶浠�
+ /// </summary>
+ private class MySmartSoundControl : FrameRowControl
+ {
+
+ /// <summary>
+ /// 缃戝叧鍚嶅瓧鎺т欢
+ /// </summary>
+ private NormalViewControl btnName = null;
+
+ /// <summary>
+ /// 鑷畾闊崇鍏虫帶浠�
+ /// </summary>
+ public MySmartSoundControl()
+ {
+ this.UseClickStatu = false;
+ this.BackgroundColor = UserCenterColor.Current.White;
+ this.Height = Application.GetRealHeight(173);
+
+ //this.InitControl();
+ }
+
+
+ /// <summary>
+ /// 鍒濆鍖栨帶浠�
+ /// </summary>
+ public void InitControl()
+ {
+ //鍥炬爣
+ var btnIcon = this.AddLeftIcon(81);
+ btnIcon.UnSelectedImagePath = "SmartSound/SoundIcon.png";
+
+ //鏄剧ず鏂囨湰
+ btnName = this.AddLeftCaption(string.Empty, 700);
+ btnName.Height = Application.GetRealHeight(60);
+ btnName.TextSize = 15;
+ btnName.Y = Application.GetRealHeight(57);
+ btnName.Text = "灏忓害灏忓害";
+
+ this.AddRightArrow();
+ this.AddMostRightView("", 300, false).Name = "smartSoundLayout";
+ this.AddBottomLine();
+ }
+ }
#endregion
}
}
--
Gitblit v1.8.0