From 7b60238359b94125d591678eff105ae2bf47843f Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 15 十一月 2019 13:16:21 +0800
Subject: [PATCH] 2019.11.15
---
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs | 391 +++++++++++++++++++++++++++++++------------------------
1 files changed, 223 insertions(+), 168 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
index 1815322..1819ec7 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
@@ -13,14 +13,8 @@
/// <param name="common">Common.</param>
public void Changed(CommonDevice common)
{
- //if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
- //{
- // return;
- //}
-
Shared.Application.RunOnMainThread(() =>
{
- //var dev = common as Panel;
});
}
@@ -45,6 +39,10 @@
/// 鎸夐敭閰嶇疆鐨勭洰鏍囧垪琛�
/// </summary>
List<CommonDevice> targetList = new List<CommonDevice>();
+ /// <summary>
+ /// 鏂扮殑鎸夐敭閰嶇疆鐩爣鍒楄〃涓紝鐩爣瀹為檯瀛樺湪鎸夐敭涓紝姝ゆ椂瑕佸垹鎺夌殑鏁版嵁
+ /// </summary>
+ List<CommonDevice> oldTargetList = new List<CommonDevice>();
List<Room> roomList = new List<Room>();
int currentClusterID = 6;
public Action<List<BindListResponseObj>> action;
@@ -106,207 +104,264 @@
btnFinifh.MouseUpEventHandler += async (sender, e) =>
{
+ oldTargetList.Clear();
+ bool isFinish = false;
btnFinifh.Enable = false;
btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
- if (oldModeID != 65535 && oldModeID != currentModeID)
+ try
{
- var bindResult = await currentKey.ClearBindInfoAsync();
- if (bindResult.clearBindInfoResponseData != null)
+ CommonPage.Loading.Start("");
+ //1銆佹竻绌烘墍鏈夌洰鏍�
+ if (currentKey.bindList != null)
{
- if (bindResult.clearBindInfoResponseData.Result != 0)
+ var bindResult = await currentKey.ClearBindInfoAsync();
+
+ if (bindResult != null && bindResult.clearBindInfoResponseData != null)
{
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
- CommonPage.Loading.Hide();
- this.RemoveFromParent();
- btnFinifh.Enable = true;
- return;
+ if (bindResult.clearBindInfoResponseData.Result != 0)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ CommonPage.Loading.Hide();
+ this.RemoveFromParent();
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ return;
+ }
+ else
+ {
+ currentKey.bindList.Clear();
+ }
}
else
{
- currentKey.bindList.Clear();
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ CommonPage.Loading.Hide();
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ return;
}
}
- }
- else
- {
- foreach (var bindedDev in currentKey.bindList)
+
+ //2銆侀厤缃ā寮�
+ Panel.SetWritableValueResponAllData temp = null;
+ switch (currentModeID)
{
- for (int i = 0; i < targetList.Count; i++)
+ case 100:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_On);
+ break;
+ case 101:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_oFF);
+ break;
+ case 102:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_OnOff);
+ break;
+ case 200:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Up);
+ break;
+ case 201:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Down);
+ break;
+ case 203:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up);
+ break;
+ case 204:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Down);
+ break;
+ case 205:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up_Down);
+ break;
+ case 300:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up);
+ break;
+ case 301:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down);
+ break;
+ case 302:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Stop);
+ break;
+ case 303:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up_Stop);
+ break;
+ case 304:
+ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down_Stop);
+ break;
+ }
+ if (temp != null && temp.setWritableValueResponData != null)
+ {
+ if (temp.setWritableValueResponData.Status == 0)
{
- var de = targetList[i];
- if (de.DeviceAddr == bindedDev.BindMacAddr && de.DeviceEpoint == bindedDev.BindEpoint)
+ //3銆佺粦瀹氭柊鐨勬暟鎹�
+ var addBindeDev = new AddBindData();
+ addBindeDev.DeviceAddr = currentKey.DeviceAddr;
+ addBindeDev.Epoint = currentKey.DeviceEpoint;
+
+ foreach (var de in targetList)
{
- targetList.RemoveAt(i);
- i--;
+ if (de.DeviceAddr != null)
+ {
+ var addBindInfo = new AddBindListObj();
+ addBindInfo.BindType = 0;
+ addBindInfo.BindCluster = currentClusterID;
+ addBindInfo.BindMacAddr = de.DeviceAddr;
+ addBindInfo.BindEpoint = de.DeviceEpoint;
+ addBindeDev.BindList.Add(addBindInfo);
+ }
}
- }
- }
- }
- var temp = new Panel.SetWritableValueResponAllData();
- switch (currentModeID)
- {
- case 100:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_On);
- break;
- case 101:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_oFF);
- break;
- case 102:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.OnOff_OnOff);
- break;
- case 200:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Up);
- break;
- case 201:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Step_Down);
- break;
- case 203:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up);
- break;
- case 204:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Down);
- break;
- case 205:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Level_Up_Down);
- break;
- case 300:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up);
- break;
- case 301:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down);
- break;
- case 302:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Stop);
- break;
- case 303:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Up_Stop);
- break;
- case 304:
- temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down_Stop);
- break;
- }
- if (temp.setWritableValueResponData?.Status != 0)
- {
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
- btnFinifh.Enable = true;
- btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
- return;
- }
- else
- {
- var addBindeDev = new AddBindData();
- addBindeDev.DeviceAddr = currentKey.DeviceAddr;
- addBindeDev.Epoint = currentKey.DeviceEpoint;
-
- foreach (var de in targetList)
- {
- if (de.DeviceAddr != null)
- {
- var addBindInfo = new AddBindListObj();
- addBindInfo.BindType = 0;
- addBindInfo.BindCluster = currentClusterID;
- addBindInfo.BindMacAddr = de.DeviceAddr;
- addBindInfo.BindEpoint = de.DeviceEpoint;
- addBindeDev.BindList.Add(addBindInfo);
- }
- }
- bool isFinish = false;
- try
- {
- CommonPage.Loading.Start("");
- var dev = new AddedDeviceBindResponseAllData();
- dev = await currentKey.AddDeviceBindAsync(addBindeDev);
- foreach (var ab in dev.addedDeviceBindResponseData?.BindList)
- {
- switch (ab.Result)
+ var dev = new AddedDeviceBindResponseAllData();
+ dev = await currentKey.AddDeviceBindAsync(addBindeDev);
+ if (dev.addedDeviceBindResponseData == null)
{
- case 0:
- currentKey.bindList.Add((BindListResponseObj)ab);
-
- for (int i = 0; i < targetList.Count; i++)
- {
- var de = targetList[i];
- var sc1 = new SceneUI();
- if (de.DeviceAddr == null)
- {
- sc1 = (SceneUI)de;
-
- if (sc1.Id == ab.BindScenesId)
- {
- targetList.RemoveAt(i);
- i--;
- }
- }
- }
- isFinish = true;
- break;
- case 1:
- new Tip()
- {
- MaxWidth = 150,
- Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence),
- Direction = AMPopTipDirection.Up,
- CloseTime = 1
- }.Show(btnFinifh);
- break;
- case 2:
- var abr = dev.addBindResultResponseData?.Result;
- switch (dev.addBindResultResponseData?.Result)
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ }
+ else
+ {
+ foreach (var ab in dev.addedDeviceBindResponseData?.BindList)
+ {
+ switch (ab.Result)
{
case 0:
currentKey.bindList.Add((BindListResponseObj)ab);
+
for (int i = 0; i < targetList.Count; i++)
{
var de = targetList[i];
- if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint)
+ var sc1 = new SceneUI();
+ if (de.DeviceAddr == null)
{
- targetList.RemoveAt(i);
- i--;
+ sc1 = (SceneUI)de;
+
+ if (sc1.Id == ab.BindScenesId)
+ {
+ targetList.RemoveAt(i);
+ i--;
+ }
}
}
- isFinish = true;
+ //isFinish = true;
break;
- case 140:
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ case 1:
+ Application.RunOnMainThread(() =>
+ {
+ new Tip()
+ {
+ MaxWidth = 150,
+ Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence),
+ Direction = AMPopTipDirection.Up,
+ CloseTime = 1
+ }.Show(btnFinifh);
+ });
+ break;
+ case 2:
+ var abr = dev.addBindResultResponseData?.Result;
+ switch (dev.addBindResultResponseData?.Result)
+ {
+ case 0:
+ currentKey.bindList.Add((BindListResponseObj)ab);
+ for (int i = 0; i < targetList.Count; i++)
+ {
+ var de = targetList[i];
+ if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint)
+ {
+ targetList.RemoveAt(i);
+ i--;
+ }
+ }
+ //isFinish = true;
+ break;
+ case 140:
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ break;
+ default:
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ break;
+ }
+ break;
+ case 3:
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
+ break;
+ case 4:
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
break;
default:
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+ });
break;
}
- break;
- case 3:
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
- break;
- case 4:
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
- break;
- default:
- break;
+ }
}
- }
- }
- catch { }
- finally
- {
- if (isFinish)
- {
- if (action != null)
- {
- action(currentKey.bindList);
-
- }
- this.RemoveFromParent();
}
else
{
- this.RemoveFromParent();
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+ });
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ return;
}
- CommonPage.Loading.Hide();
+ }
+ else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+ });
btnFinifh.Enable = true;
btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ return;
}
}
+ catch { }
+ finally
+ {
+ //if (isFinish)
+ //{
+ // if (action != null)
+ // {
+ // action(currentKey.bindList);
+ // }
+ // this.RemoveFromParent();
+ //}
+ //else
+ //{
+ // this.RemoveFromParent();
+ //}
+ if (action != null)
+ {
+ action(currentKey.bindList);
+ }
+ this.RemoveFromParent();
+ CommonPage.Loading.Hide();
+ btnFinifh.Enable = true;
+ btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ }
};
#endregion
}
--
Gitblit v1.8.0