From 627093aca723d4bfb971b97c828e8b3a22dbda78 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 17 七月 2020 17:26:19 +0800
Subject: [PATCH] 2020-07-17-1
---
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs | 827 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 644 insertions(+), 183 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
index f45da8c..b996092 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -16,27 +16,29 @@
/// 鏋勯�犲嚱鏁�
/// </summary>
/// <param name="device"></param>
- /// <param name="deviceBindType">1:鏂伴;2:娓╁害浼犳劅鍣�;3:婀垮害浼犳劅鍣�</param>
- public PanelFangyueFreshAirTargetsForm(CommonDevice device, int deviceBindType)
+ /// <param name="deviceBindType">1:鏂伴;2:娓╁害浼犳劅鍣�;3:婀垮害浼犳劅鍣�;4:PM2.5浼犳劅鍣�</param>
+ /// <param name="bindDev">缁戝畾鐩爣 </param>
+ public PanelFangyueFreshAirTargetsForm(CommonDevice device, CommonDevice bindDev, int deviceBindType)
{
this.curControlDev = device as FreshAir;
+ this.curBindDevice = bindDev;
this.curDeviceBindType = deviceBindType;
}
#endregion
- #region 鍙橀噺鐢虫槑
- /// <summary>
- /// 褰撳墠鎺у埗璁惧
- /// </summary>
- //CommonDevice currentControlDevice;
+ #region 鍙橀噺鐢虫槑
/// <summary>
/// 褰撳墠鏂伴闈㈡澘銆愭帶鍒惰澶囥��
/// </summary>
FreshAir curControlDev;
/// <summary>
+ /// 褰撳墠琚粦璁惧
+ /// </summary>
+ CommonDevice curBindDevice;
+ /// <summary>
/// 鏄剧ず琚粦瀹氳澶囨垨鍦烘櫙鐨剉iew
/// </summary>
- VerticalFrameRefreshControl midVerticalScrolViewLayout;
+ VerticalRefreshLayout midVerticalScrolViewLayout;
/// <summary>
/// 鏄剧ず鎴块棿鐨剉iew
/// </summary>
@@ -101,6 +103,7 @@
/// PM缁戝畾鐩爣鍥炶皟
/// </summary>
public Action<string> actionPMTarget = null;
+
#endregion
#region UI璁捐
@@ -218,7 +221,7 @@
btnMidTopLayout.AddChidren(btnHorizontalScrolViewLayout);
//璁惧鏍�
- midVerticalScrolViewLayout = new VerticalFrameRefreshControl()
+ midVerticalScrolViewLayout = new VerticalRefreshLayout()
{
Y = btnMidTopLayout.Bottom,
Height = Application.GetRealHeight(1145),
@@ -274,9 +277,17 @@
FrameLayout curentOldRoomFrameLayout = null;
int index = 0;
var roomTempList = GetSupportRoomList();
+ Room slectedRoom = null;
+
for (int i = 0; i < roomTempList.Count; i++)
{
var room = roomTempList[i];
+ bool canSelect = false;
+ if (curControlDev.currentSelectRoomId == room.Id)
+ {
+ slectedRoom = room;
+ canSelect = true;
+ }
//鎴块棿
var btnRoomFrameLayout = new FrameLayout
{
@@ -303,13 +314,39 @@
btnRoomFrameLayout.AddChidren(btnRoom);
btnRoom.IsSelected = false;
- if (index == 0)
+ if (canSelect)
{
btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
curentOldRoom = btnRoom;
curentOldRoomFrameLayout = btnRoomFrameLayout;
}
+
+ //琚粦瀹氱殑鐩爣杩樻湭鍒嗛厤鍖哄煙锛岄粯璁ゆ槸绗竴涓�
+ if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId))
+ {
+ if (index == 0)
+ {
+ btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+ btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+ curentOldRoom = btnRoom;
+ curentOldRoomFrameLayout = btnRoomFrameLayout;
+ }
+ }
+
+ if (index == roomTempList.Count - 1 && index > 3)
+ {
+ var btnRoomFrameLayoutEmpty = new FrameLayout
+ {
+ Height = Application.GetMinReal(159),
+ Width = Application.GetMinReal(50),
+ Y = Application.GetRealHeight(23),
+ X = Application.GetRealWidth(5),
+ BorderWidth = 1,
+ };
+ btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayoutEmpty);
+ }
+
EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) =>
{
if (!btnRoom.IsSelected)
@@ -335,7 +372,6 @@
curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
}
curRoom = room;
- curControlDev.RoomId = room.Id;
//鏂伴闈㈡澘淇濆瓨浣胯兘
btnFinifh.Enable = true;
@@ -349,13 +385,20 @@
}
BindInfo.FinishDisplay(roomTempList, btnFinifh);
- if (roomTempList.Count != 0)
+ if (roomTempList.Count == 0)
{
- curRoom = roomTempList[0];
+ curRoom = new Shared.Common.Room();
}
else
{
- curRoom = new Shared.Common.Room();
+ if (slectedRoom == null)
+ {
+ curRoom = roomTempList[0];
+ }
+ else
+ {
+ curRoom = slectedRoom;
+ }
}
RefreshDeviceList(curRoom);
@@ -435,6 +478,29 @@
line2.Visible = false;
}
+ switch (curDeviceBindType)
+ {
+ case 1:
+ devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png";
+ break;
+ case 2:
+ devicePic.UnSelectedImagePath = "Device/SensorTemperature.png";
+ if (device.Type == DeviceType.PMSensor)
+ {
+ btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+ }
+ break;
+ case 3:
+ devicePic.UnSelectedImagePath = "Device/SensorHumidity.png";
+ if (device.Type == DeviceType.PMSensor)
+ {
+ btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+ }
+ break;
+ case 4:
+ devicePic.UnSelectedImagePath = "Device/AirQualitySensorEpoint.png";
+ break;
+ }
#endregion
string mianKey = device.DeviceAddr + device.DeviceEpoint;
@@ -452,38 +518,38 @@
}
EventHandler<MouseEventArgs> hander = (sender, e) =>
- {
- btnChoose.IsSelected = !btnChoose.IsSelected;
- if (!btnChoose.IsSelected)
- {
- if (oldDevice != null)
- {
- oldDevice.IsSelected = false;
- oldDevice.Visible = false;
- }
- oldDevice = btnChoose;
- oldDevice.IsSelected = false;
- oldDevice.Visible = false;
- targetList.Clear();
- }
- else
- {
- if (oldDevice != null)
- {
- oldDevice.IsSelected = false;
- oldDevice.Visible = false;
- }
- oldDevice = btnChoose;
- oldDevice.IsSelected = true;
- oldDevice.Visible = true;
- targetList.Clear();
- targetList.Add(device);
- }
+ {
+ btnChoose.IsSelected = !btnChoose.IsSelected;
+ if (!btnChoose.IsSelected)
+ {
+ if (oldDevice != null)
+ {
+ oldDevice.IsSelected = false;
+ oldDevice.Visible = false;
+ }
+ oldDevice = btnChoose;
+ oldDevice.IsSelected = false;
+ oldDevice.Visible = false;
+ targetList.Clear();
+ }
+ else
+ {
+ if (oldDevice != null)
+ {
+ oldDevice.IsSelected = false;
+ oldDevice.Visible = false;
+ }
+ oldDevice = btnChoose;
+ oldDevice.IsSelected = true;
+ oldDevice.Visible = true;
+ targetList.Clear();
+ targetList.Add(device);
+ }
- //鏂伴闈㈡澘锛氱敱浜庣洰鏍囨病鏈夋彁渚涘垹闄ゆ帴鍙o紝鎵�浠ュ彲浠ュ彇娑堥�変腑鑳戒繚瀛�
- btnFinifh.Enable = true;
- btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
- };
+ //鏂伴闈㈡澘锛氱敱浜庣洰鏍囨病鏈夋彁渚涘垹闄ゆ帴鍙o紝鎵�浠ュ彲浠ュ彇娑堥�変腑鑳戒繚瀛�
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ };
rowLayout.MouseUpEventHandler += hander;
devicePic.MouseUpEventHandler += hander;
btnBindName.MouseUpEventHandler += hander;
@@ -650,30 +716,19 @@
{
CommonPage.Loading.Start("");
});
+ //鑾峰彇琚粦鐩爣绛変俊鎭�
+ BindDevInfo(curBindDevice);
//鑾峰彇妤煎眰
dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
- curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
- if (BindInfo.GetCurrentSelectFloorIdName() != null)
- {
- Application.RunOnMainThread(() =>
- {
- btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
- });
- }
-
//鑾峰彇妤煎眰涓埧闂村垪琛�
supportRoomList = GetFloorRoomList();
- if (supportRoomList.Count == 0)
- {
- return;
- }
//鑾峰彇鎵�鏈夋埧闂翠腑鍖归厤鐨勮兘缁戠殑鐩爣
currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList();
//鑾峰彇闈㈡澘涓瓨鍦ㄧ殑缁戝畾鐩爣
- var panelBindListRes = await this.curControlDev.GetDeviceBindAsync();
+ var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null)
{
curControlDev.bindList.Clear();
@@ -691,17 +746,18 @@
new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
});
}
+
targetList.Clear();
//閫変腑鐩爣鍒楄〃 targetList
if (currentPanelSupportBindDeviceList.Count != 0 && curControlDev.bindList.Count != 0)
{
- foreach (var bindDev in currentPanelSupportBindDeviceList)
+ foreach (var bindDev in curControlDev.bindList)
{
- var mainKey = bindDev.DeviceAddr + bindDev.DeviceEpoint;
- var dev = curControlDev.bindList.Find(obj => (obj != null) && (obj.BindMacAddr + obj.BindEpoint == mainKey));
+ var mainKey = bindDev.BindMacAddr + bindDev.BindEpoint;
+ var dev = currentPanelSupportBindDeviceList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey));
if (dev != null)
{
- var device = LocalDevice.Current.GetDevice(bindDev.DeviceAddr, bindDev.DeviceEpoint);
+ var device = LocalDevice.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
if (device != null)
{
switch (curDeviceBindType)
@@ -723,19 +779,56 @@
case 2:
if (device.Type == DeviceType.TemperatureSensor)
{
- targetList.Add(device);
- oldTargetList.Add(device);
+ var bDev = device as TemperatureSensor;
+ if (bDev.SensorDiv == 1)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
+ }
+ if (device.Type == DeviceType.PMSensor)
+ {
+ if (bindDev.BindCluster == 1026)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
}
break;
case 3:
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var bDev = device as TemperatureSensor;
+ if (bDev.SensorDiv == 2)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
+ }
if (device.Type == DeviceType.FreshAirHumiditySensor)
{
targetList.Add(device);
oldTargetList.Add(device);
}
+ if (device.Type == DeviceType.PMSensor)
+ {
+ if (bindDev.BindCluster == 1029)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
+ }
break;
case 4:
//PM2.5
+ if (device.Type == DeviceType.PMSensor)
+ {
+ if (bindDev.BindCluster == 1066)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
+ }
break;
}
@@ -752,21 +845,57 @@
{
Application.RunOnMainThread(() =>
{
- if (supportRoomList.Count != 0)
- {
- RefreshRoomList();
- }
//棣栨鏄惁鑳界偣鍑讳繚瀛�
if (targetList.Count == 0)
{
+ curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
+ curControlDev.currentSelectRoomId = null;
+ if (BindInfo.GetCurrentSelectFloorIdName() != null)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
+ });
+ }
btnFinifh.Enable = false;
btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
}
else
{
+ foreach (var dev in targetList)
+ {
+ //鑾峰彇鏈湴璁惧鍒楄〃
+ var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
+ var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == dev.DeviceAddr && obj.DeviceEpoint == dev.DeviceEpoint);
+ if (tempDev != null)
+ {
+ //鑾峰彇璁惧鎵�灞炴埧闂�
+ var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
+ if (tempDevRoom != null)
+ {
+ curControlDev.currentSelectRoomId = tempDevRoom.Id;
+ curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
+ }
+ }
+ }
+ if (!string.IsNullOrEmpty(curControlDev.currentSelectFloorId))
+ {
+ if (BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId) != null)
+ {
+ btnFloorText.Text = BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId);
+ }
+ }
+
btnFinifh.Enable = true;
btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ }
+
+
+ //鑾峰彇妤煎眰涓埧闂村垪琛�
+ if (supportRoomList.Count != 0)
+ {
+ RefreshRoomList();
}
CommonPage.Loading.Hide();
@@ -782,6 +911,7 @@
/// <param name="curControlDev"></param>
void SaveTarget()
{
+ btnFinifh.Enable = false;
if (targetList.Count == 0)
{
//绌虹洰鏍�
@@ -815,6 +945,7 @@
break;
case 4:
//PM2.5
+ removeDevice.BindCluster = 1066;
break;
}
removeDevice.BindMacAddr = bd.DeviceAddr;
@@ -822,56 +953,128 @@
delDevice.RemoveBindList.Add(removeDevice);
var delResult = new DelDeviceBindResponseAllData();
- delResult = await curControlDev.DelDeviceBindAsync(delDevice);
- if (delResult != null && delResult.removeBindResultResponseData != null)
+ delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
+ if (delResult == null)
{
- if (delResult.removeBindResultResponseData.Result == 0)
+ Application.RunOnMainThread(() =>
{
- switch (curDeviceBindType)
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ else
+ {
+ if (delResult.removeBindResultResponseData == null)
+ {
+ if (delResult.delDeviceBindResponseData != null)
{
- case 1:
- if (actionFreshAirTarget != null)
+ foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
+ {
+ if (d.Result == 1)
{
- actionFreshAirTarget("");
+ switch (curDeviceBindType)
+ {
+ case 1:
+ if (actionFreshAirTarget != null)
+ {
+ actionFreshAirTarget("");
+ }
+ break;
+ case 2:
+ if (actionTemperatureTarget != null)
+ {
+ actionTemperatureTarget("");
+ }
+ break;
+ case 3:
+ if (actionHumidityTarget != null)
+ {
+ actionHumidityTarget("");
+ }
+ break;
+ case 4:
+ if (actionPMTarget != null)
+ {
+ actionPMTarget("");
+ }
+ break;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ CommonPage.Loading.Hide();
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ this.RemoveFromParent();
+ });
}
- break;
- case 2:
- if (actionTemperatureTarget != null)
+ else
{
- actionTemperatureTarget("");
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
}
- break;
- case 3:
- if (actionHumidityTarget != null)
- {
- actionHumidityTarget("");
- }
- break;
- case 4:
- if (actionPMTarget != null)
- {
- actionPMTarget("");
- }
- break;
+ }
}
- Application.RunOnMainThread(() =>
- {
- CommonPage.Loading.Hide();
- btnFinifh.Enable = true;
- btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
- this.RemoveFromParent();
- });
}
else
{
- Application.RunOnMainThread(() =>
+ if (delResult.removeBindResultResponseData.Result == 0)
{
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
- btnFinifh.Enable = true;
- btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
- CommonPage.Loading.Hide();
- });
- return;
+ switch (curDeviceBindType)
+ {
+ case 1:
+ if (actionFreshAirTarget != null)
+ {
+ actionFreshAirTarget("");
+ }
+ break;
+ case 2:
+ if (actionTemperatureTarget != null)
+ {
+ actionTemperatureTarget("");
+ }
+ break;
+ case 3:
+ if (actionHumidityTarget != null)
+ {
+ actionHumidityTarget("");
+ }
+ break;
+ case 4:
+ if (actionPMTarget != null)
+ {
+ actionPMTarget("");
+ }
+ break;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ CommonPage.Loading.Hide();
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ this.RemoveFromParent();
+ });
+
+ }
+ else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
}
}
}
@@ -896,6 +1099,11 @@
catch (Exception ex)
{
var mess = ex.Message;
+ Application.RunOnMainThread(() =>
+ {
+ CommonPage.Loading.Hide();
+ });
+ btnFinifh.Enable = true;
}
});
}
@@ -929,33 +1137,104 @@
{
foreach (var bd in oldTargetList)
{
- var delDevice = new DelDeviceBindData();
- delDevice.DeviceAddr = curControlDev.DeviceAddr;
- delDevice.Epoint = curControlDev.DeviceEpoint;
-
- var removeDevice = new RemoveBindListObj();
- removeDevice.BindType = 0;
- switch (curDeviceBindType)
- {
- case 1:
- removeDevice.BindCluster = 514;
- break;
- case 2:
- removeDevice.BindCluster = 1026;
- break;
- case 3:
- removeDevice.BindCluster = 1029;
- break;
- case 4:
- //PM2.5
- break;
- }
- removeDevice.BindMacAddr = bd.DeviceAddr;
- removeDevice.BindEpoint = bd.DeviceEpoint;
- delDevice.RemoveBindList.Add(removeDevice);
-
+ var delDevice = DelBindDevice(bd);
var delResult = new DelDeviceBindResponseAllData();
- delResult = await curControlDev.DelDeviceBindAsync(delDevice);
+ delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
+
+ if (delResult == null)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ else
+ {
+ if (delResult.removeBindResultResponseData == null)
+ {
+ if (delResult.delDeviceBindResponseData != null)
+ {
+ foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
+ {
+ if (d.Result != 1)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ }
+ }
+ }
+ }
+ if (delResult != null && delResult.removeBindResultResponseData != null)
+ {
+ if (delResult.removeBindResultResponseData.Result != 0)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ //妫�娴嬪凡缁忕粦瀹氱殑鐩爣鏄惁涓嶅湪鏈湴鎴栬�呮病鏈夊垎閰嶅埌浠讳綍鎴块棿涓�
+ //姝ゆ椂闇�瑕佸垹闄ゅ凡缁忚缁戝畾鍒扮洰鏍囷紝鎵嶈兘缁х画缁戝畾鏂扮洰鏍�
+ if (curBindDevice != null)
+ {
+ var delDevice = DelBindDevice(curBindDevice);
+ var delResult = new DelDeviceBindResponseAllData();
+ delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
+
+ if (delResult == null)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ else
+ {
+ if (delResult.removeBindResultResponseData == null)
+ {
+ if (delResult.delDeviceBindResponseData != null)
+ {
+ foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
+ {
+ if (d.Result != 1)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ CommonPage.Loading.Hide();
+ });
+ return;
+ }
+ }
+ }
+ }
+ }
if (delResult != null && delResult.removeBindResultResponseData != null)
{
if (delResult.removeBindResultResponseData.Result != 0)
@@ -994,17 +1273,33 @@
break;
case 4:
//PM2.5
+ addBindInfo.BindCluster = 1066;
break;
}
addBindInfo.BindType = 0;
addBindInfo.BindMacAddr = de.DeviceAddr;
addBindInfo.BindEpoint = de.DeviceEpoint;
+ addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de);
+ switch (curDeviceBindType)
+ {
+ case 2:
+ if (de.Type == DeviceType.PMSensor)
+ {
+ addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+ }
+ break;
+ case 3:
+ if (de.Type == DeviceType.PMSensor)
+ {
+ addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+ }
+ break;
+ }
addBindeDev.BindList.Add(addBindInfo);
- bindName = de.DeviceEpointName;
}
var dev = new AddedDeviceBindResponseAllData();
- dev = await curControlDev.AddDeviceBindAsync(addBindeDev);
+ dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
if (dev == null || dev.addedDeviceBindResponseData == null)
{
Application.RunOnMainThread(() =>
@@ -1020,33 +1315,31 @@
{
if (dev.addedDeviceBindResponseData.Result == 0)
{
- curControlDev.bindList = dev.addedDeviceBindResponseData.BindList;
targetList.Clear();
-
switch (curDeviceBindType)
{
case 1:
if (actionFreshAirTarget != null)
{
- actionFreshAirTarget(bindName);
+ actionFreshAirTarget(addBindeDev.BindName);
}
break;
case 2:
if (actionTemperatureTarget != null)
{
- actionTemperatureTarget(bindName);
+ actionTemperatureTarget(addBindeDev.BindName);
}
break;
case 3:
if (actionHumidityTarget != null)
{
- actionHumidityTarget(bindName);
+ actionHumidityTarget(addBindeDev.BindName);
}
break;
case 4:
if (actionPMTarget != null)
{
- actionPMTarget(bindName);
+ actionPMTarget(addBindeDev.BindName);
}
break;
}
@@ -1097,9 +1390,39 @@
}
catch (Exception ex)
{
+ Application.RunOnMainThread(() =>
+ {
+ CommonPage.Loading.Hide();
+ });
+ btnFinifh.Enable = true;
var mess = ex.Message;
}
});
+ }
+ }
+
+ /// <summary>
+ /// 褰撳墠琚粦瀹氳澶囨墍灞炴ゼ灞傚拰鎴块棿
+ /// </summary>
+ /// <param name="bindDev"></param>
+ void BindDevInfo(CommonDevice bindDev)
+ {
+ if (bindDev == null)
+ {
+ return;
+ }
+ //鑾峰彇鏈湴璁惧鍒楄〃
+ var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
+ var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint);
+ if (tempDev != null)
+ {
+ //鑾峰彇璁惧鎵�灞炴埧闂�
+ var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
+ if (tempDevRoom != null)
+ {
+ curControlDev.currentSelectRoomId = tempDevRoom.Id;
+ curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
+ }
}
}
@@ -1124,6 +1447,40 @@
}
}
return exist;
+ }
+
+ /// <summary>
+ /// 妫�娴嬪凡缁忕粦瀹氱殑鐩爣鏄惁涓嶅湪鏈湴鎴栬�呮病鏈夊垎閰嶅埌浠讳綍鎴块棿涓�
+ /// </summary>
+ /// <returns></returns>
+ private DelDeviceBindData DelBindDevice(CommonDevice bd)
+ {
+ var delDevice = new DelDeviceBindData();
+ delDevice.DeviceAddr = curControlDev.DeviceAddr;
+ delDevice.Epoint = curControlDev.DeviceEpoint;
+
+ var removeDevice = new RemoveBindListObj();
+ removeDevice.BindType = 0;
+ switch (curDeviceBindType)
+ {
+ case 1:
+ removeDevice.BindCluster = 514;
+ break;
+ case 2:
+ removeDevice.BindCluster = 1026;
+ break;
+ case 3:
+ removeDevice.BindCluster = 1029;
+ break;
+ case 4:
+ //PM2.5
+ removeDevice.BindCluster = 1066;
+ break;
+ }
+ removeDevice.BindMacAddr = bd.DeviceAddr;
+ removeDevice.BindEpoint = bd.DeviceEpoint;
+ delDevice.RemoveBindList.Add(removeDevice);
+ return delDevice;
}
/// <summary>
@@ -1157,6 +1514,7 @@
foreach (var de in room.ListDevice)
{
var device = LocalDevice.Current.GetDevice(de);
+
if (device != null)
{
//鑾峰彇璁惧绫诲瀷鐨�
@@ -1174,19 +1532,10 @@
}
break;
case 2:
- foreach (var de in room.ListDevice)
- {
- var device = LocalDevice.Current.GetDevice(de);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- roomIncludeMatchDevice.Add(device);
- }
- }
- }
+ roomIncludeMatchDevice = GetMatchTemperatureSensorDevice(room);
break;
case 3:
+ roomIncludeMatchDevice = GetMatchHumiditySensorDevice(room);
foreach (var de in room.ListDevice)
{
var device = LocalDevice.Current.GetDevice(de);
@@ -1200,6 +1549,17 @@
}
break;
case 4:
+ foreach (var de in room.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(de);
+ if (device != null)
+ {
+ if (device.Type == DeviceType.PMSensor)
+ {
+ roomIncludeMatchDevice.Add(device);
+ }
+ }
+ }
break;
}
@@ -1207,23 +1567,105 @@
{
continue;
}
- }
- if (!string.IsNullOrEmpty(room.FloorId))
- {
- //鏈夋ゼ灞�
- if (room.FloorId == curControlDev.currentSelectFloorId)
+ if (!string.IsNullOrEmpty(room.FloorId))
{
+ //鏈夋ゼ灞�
+ if (room.FloorId == curControlDev.currentSelectFloorId)
+ {
+ roomTempList.Add(room);
+ }
+ }
+ else
+ {
+ //娌℃湁妤煎眰
roomTempList.Add(room);
}
}
- else
- {
- //娌℃湁妤煎眰
- roomTempList.Add(room);
- }
}
return roomTempList;
+ }
+
+ /// <summary>
+ /// 鍖归厤娓╁害浼犳劅鍣�
+ /// </summary>
+ /// <param name="room"></param>
+ List<CommonDevice> GetMatchTemperatureSensorDevice(Room room)
+ {
+ List<CommonDevice> roomIncludeMatchTempDevice = new List<CommonDevice>();
+ foreach (var de in room.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(de);
+ if (device != null)
+ {
+ //鐢垫睜璁惧涓嶆敮鎸佺粦瀹�
+ if (device.ZigbeeType != 1)
+ {
+ continue;
+ }
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var dev = device as TemperatureSensor;
+ if (dev.SensorDiv == 1)
+ {
+ roomIncludeMatchTempDevice.Add(device);
+ }
+ }
+ else if (device.Type == DeviceType.PMSensor)
+ {
+ var dev = device as PMSensor;
+ foreach (var clu in dev.InClusterList)
+ {
+ if (clu.InCluster == 1026)
+ {
+ roomIncludeMatchTempDevice.Add(device);
+ }
+ }
+ }
+ }
+ }
+ return roomIncludeMatchTempDevice;
+ }
+
+ /// <summary>
+ /// 鍖归厤婀垮害浼犳劅鍣�
+ /// </summary>
+ /// <param name="room"></param>
+ List<CommonDevice> GetMatchHumiditySensorDevice(Room room)
+ {
+ List<CommonDevice> roomIncludeMatchHumpDevice = new List<CommonDevice>();
+ foreach (var de in room.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(de);
+ if (device != null)
+ {
+ //鐢垫睜璁惧涓嶆敮鎸佺粦瀹�
+ if (device.ZigbeeType != 1)
+ {
+ continue;
+ }
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var dev = device as TemperatureSensor;
+ if (dev.SensorDiv == 2)
+ {
+ roomIncludeMatchHumpDevice.Add(device);
+ }
+ }
+ else if (device.Type == DeviceType.PMSensor)
+ {
+ var dev = device as PMSensor;
+ foreach (var clu in dev.InClusterList)
+ {
+ if (clu.InCluster == 1029)
+ {
+ roomIncludeMatchHumpDevice.Add(device);
+ }
+ }
+ }
+ }
+ }
+ return roomIncludeMatchHumpDevice;
}
/// <summary>
@@ -1309,16 +1751,10 @@
{
continue;
}
- foreach (var deviceKeys in r.ListDevice)
+ var deviceListTemp = GetMatchTemperatureSensorDevice(r);
+ foreach (var dev in deviceListTemp)
{
- var device = LocalDevice.Current.GetDevice(deviceKeys);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- currentPanelBindSupportDeviceListTemp.Add(device);
- }
- }
+ currentPanelBindSupportDeviceListTemp.Add(dev);
}
}
break;
@@ -1328,6 +1764,11 @@
if (r.ListDevice.Count == 0)
{
continue;
+ }
+ var deviceListTemp = GetMatchHumiditySensorDevice(r);
+ foreach (var dev in deviceListTemp)
+ {
+ currentPanelBindSupportDeviceListTemp.Add(dev);
}
foreach (var deviceKeys in r.ListDevice)
{
@@ -1343,6 +1784,24 @@
}
break;
case 4:
+ foreach (var r in supportRoomList)
+ {
+ if (r.ListDevice.Count == 0)
+ {
+ continue;
+ }
+ foreach (var deviceKeys in r.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(deviceKeys);
+ if (device != null)
+ {
+ if (device.Type == DeviceType.PMSensor)
+ {
+ currentPanelBindSupportDeviceListTemp.Add(device);
+ }
+ }
+ }
+ }
break;
}
return currentPanelBindSupportDeviceListTemp;
@@ -1361,7 +1820,7 @@
case 1:
foreach (var deviceKeys in curRoom.ListDevice)
{
- var device = LocalDevice.Current.GetDevice(deviceKeys);
+ var device = LocalDevice.Current.GetDevice(deviceKeys);
if (device != null)
{
//鑾峰彇璁惧绫诲瀷鐨�
@@ -1379,19 +1838,10 @@
}
break;
case 2:
- foreach (var deviceKeys in curRoom.ListDevice)
- {
- var device = LocalDevice.Current.GetDevice(deviceKeys);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- curRoomDeviceListTemp.Add(device);
- }
- }
- }
+ curRoomDeviceListTemp = GetMatchTemperatureSensorDevice(curRoom);
break;
case 3:
+ curRoomDeviceListTemp = GetMatchHumiditySensorDevice(curRoom);
foreach (var deviceKeys in curRoom.ListDevice)
{
var device = LocalDevice.Current.GetDevice(deviceKeys);
@@ -1405,6 +1855,17 @@
}
break;
case 4:
+ foreach (var deviceKeys in curRoom.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(deviceKeys);
+ if (device != null)
+ {
+ if (device.Type == DeviceType.PMSensor)
+ {
+ curRoomDeviceListTemp.Add(device);
+ }
+ }
+ }
break;
}
return curRoomDeviceListTemp;
--
Gitblit v1.8.0