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/DeviceAddSuccessForm.cs | 149 +++++++++++++++++++++++++++++++------------------
1 files changed, 94 insertions(+), 55 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
index a4c9e34..5080f98 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
@@ -20,6 +20,10 @@
/// </summary>
private VerticalListControl listview = null;
/// <summary>
+ /// 璁惧澶囨敞鎺т欢
+ /// </summary>
+ private FrameCaptionInputControl btnNote = null;
+ /// <summary>
/// 淇濆瓨榛樿鍚嶅瓧(涓昏閽堝娌℃湁淇敼鍚嶅瓧鐨勬椂鍊欙紝蹇呴』瑕佺粰涓�涓粯璁ゅ悕瀛楃粰缃戝叧)
/// </summary>
private string saveDefultName = string.Empty;
@@ -35,6 +39,14 @@
public void ShowForm(string deviceMac)
{
this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
+ if (listNewDevice.Count == 0)
+ {
+ //瀵瑰簲鍗曠函鍙湁200鍥炶矾鐨勮澶�
+ listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
+ }
+
+ //娣诲姞鏂拌澶囩殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
+ UserView.UserPage.Instance.RefreshForm = true;
//璁剧疆鏍囬淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
@@ -44,6 +56,10 @@
//璁剧疆鍏ㄩ儴鍥炶矾鐨勯粯璁ゅ悕瀛�
this.SetAllEpointName();
+ // 璁剧疆缃戝叧鎵�鍦ㄧ殑鏃跺尯鐨勬椂闂寸粰闂ㄩ攣鏃堕棿
+ this.SetDoorTime();
+ //鏂板叆缃戠殑璁惧,娓呯┖鎺夊畠鐨勬埧闂�
+ this.ClearDeviceFromRoom();
}
/// <summary>
@@ -90,7 +106,7 @@
//璁惧澶囨敞
string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
- var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
+ this.btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
listview.AddChidren(btnNote);
btnNote.InitControl();
//鍒掔嚎
@@ -116,30 +132,43 @@
//鍒掔嚎
btnType.AddBottomLine();
- //鎵�灞炲尯鍩�
+ //瀹夎浣嶇疆
var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
listview.AddChidren(rowBeloneArea);
- rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.listNewDevice);
+ rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uInstallationLocation), this.listNewDevice);
//搴曠嚎
rowBeloneArea.AddBottomLine();
var listCheck = new List<string>();
rowBeloneArea.SelectRoomEvent += (roomKeys) =>
{
+ //閫夋嫨鏈垎閰嶆椂,娓呯┖
+ if (roomKeys == string.Empty) { listCheck = new List<string>(); }
foreach (var device in this.listNewDevice)
{
- var room = Common.Room.CurrentRoom.GetRoomByDevice(device);
+ if (device is OTADevice)
+ {
+ continue;
+ }
+ if (roomKeys == string.Empty)
+ {
+ //濡傛灉閫夋嫨鐨勬槸鏈垎閰嶏紝鍒欏畠鐨勫叏閮ㄥ洖璺棤鏉′欢鍏ㄩ儴娓呯┖鎴块棿
+ HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
+ continue;
+ }
+
+ var room = HdlRoomLogic.Current.GetRoomByDevice(device);
string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
if (room == null)
{
//杩欓噷鏈夌偣鐗规畩,濡傛灉鍥炶矾娌℃湁璁剧疆鏈夊尯鍩熺殑鏃跺��,鎵嶈缃�
listCheck.Add(mainKeys);
- Common.Room.CurrentRoom.ChangedRoom(device, roomKeys);
+ HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
}
else if (listCheck.Contains(mainKeys) == true)
{
//濡傛灉杩欎釜鍥炶矾涔嬪墠閮借繕娌℃湁鍖哄煙,鍦ㄦ湰鐣岄潰杩樻病鏈夊叧闂箣鍓�,鍙互鏃犳潯浠堕殢渚垮彉鏇�
- Common.Room.CurrentRoom.ChangedRoom(device, roomKeys);
+ HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
}
}
//淇濆瓨璁惧鎴块棿绱㈠紩
@@ -155,6 +184,13 @@
btnHelp.Text = Language.StringByID(R.MyInternationalizationString.uMoreSettion);
btnHelp.ButtonClickEvent += (sender, e) =>
{
+ //鏇存敼杩囦竴娆′箣鍚庯紝鍒欑晫闈㈠叧闂悗涓嶅啀鏇存敼
+ this.saveDefultName = string.Empty;
+ //鏀瑰悕瀛�
+ btnNote.txtInput.FinishInputEvent();
+
+ this.CloseForm();
+
var form = new DeviceMacInfoEditorForm();
form.AddForm(this.listNewDevice[0].DeviceAddr);
};
@@ -208,90 +244,93 @@
detailBackFrame.AddChidren(btnFinish);
btnFinish.MouseUpEventHandler += (sender, e) =>
{
+ //鏇存敼杩囦竴娆′箣鍚庯紝鍒欑晫闈㈠叧闂悗涓嶅啀鏇存敼
+ this.saveDefultName = string.Empty;
+ //鏀瑰悕瀛�
+ btnNote.txtInput.FinishInputEvent();
//鍏抽棴鑷韩
this.CloseForm();
};
}
-#endregion
+ #endregion
-#region 鈻� 淇敼鍚嶅瓧___________________________
+ #region 鈻� 淇敼鍚嶅瓧___________________________
/// <summary>
/// 璁惧閲嶅懡鍚嶇劧鍚庢墦寮�鏂扮殑鐢婚潰
/// </summary>
/// <param name="i_deviceName">deviceName.</param>
/// <param name="mode">鏄惁鏄剧ず閿欒</param>
- private async void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES)
+ private void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES)
{
//淇敼MAC鍚�
string deviceName = i_deviceName.Trim();
- var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode);
+ var result = Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode);
if (result == false)
{
return;
}
//鏇存敼杩囦竴娆′箣鍚庯紝鍒欑晫闈㈠叧闂悗涓嶅啀鏇存敼
this.saveDefultName = string.Empty;
-
- //濡傛灉瀹冪殑鍥炶矾鍙湁涓�涓殑璇濓紝鍒欏湪璁惧涓婃姤鐨勬椂鍊欙紝淇敼MAC鍚嶅瓧涔嬪悗锛岃繛鍚岀鐐瑰悕瀛椾篃涓�璧蜂慨鏀�
- if (this.listNewDevice.Count == 1)
- {
- //淇敼绔偣鍚嶅瓧
- result = await Common.LocalDevice.Current.ReName(this.listNewDevice[0], deviceName, mode);
- if (result == false)
- {
- return;
- }
- }
}
/// <summary>
/// 璁剧疆鍏ㄩ儴鍥炶矾鐨勯粯璁ゅ悕瀛�
/// </summary>
- private async void SetAllEpointName()
+ private void SetAllEpointName()
{
- var tempValue = Common.LocalDevice.Current.GetDeviceObjectText(this.listNewDevice);
- var arry = tempValue.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
- var objName = arry[0].Trim();
-
- //鑾峰彇璁惧绫诲瀷
- var deviceInfoType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(this.listNewDevice);
foreach (var device in this.listNewDevice)
{
- if (Common.LocalDevice.Current.GetSimpleEpointName(device) != string.Empty)
+ if ((device is OTADevice) || Common.LocalDevice.Current.GetSimpleEpointName(device) != string.Empty)
{
+ //鏈夊悕瀛椾笉澶勭悊
continue;
}
- var epointName = objName;
- if (this.listNewDevice.Count > 1)
- {
- if (deviceInfoType.BeloneType == Common.DeviceBeloneType.A鎸夐敭闈㈡澘 && device.Type == DeviceType.TemperatureSensor)
- {
- //闈㈡澘鐨勬渶鍚庝竴涓洖璺槸娓╁害浼犳劅鍣�
- epointName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId11);
- }
- else if (deviceInfoType.ConcreteType == Common.DeviceConcreteType.Sensor_Pir)
- {
- //pir浼犳劅鍣�,瀹冨張鎼炵壒娈婁笢瑗�,浼犳劅鍣ㄨ嚜韬敤鑷繁鐨勫悕瀛�,缁х數鍣ㄥ洖璺殑璇濃�︹��
- if (device.Type == DeviceType.OnOffOutput)
- {
- epointName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2300);
- }
- }
- else
- {
- //XXXXX(N鍥炶矾)
- epointName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
- }
- }
- await Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO);
+ //鑾峰彇绔偣鍚嶅瓧
+ var epointName = Common.LocalDevice.Current.GetDeviceEpointName(device);
+ Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO);
}
}
-#endregion
+ /// <summary>
+ /// 璁剧疆缃戝叧鎵�鍦ㄧ殑鏃跺尯鐨勬椂闂寸粰闂ㄩ攣鏃堕棿
+ /// </summary>
+ private async void SetDoorTime()
+ {
+ //濡傛灉鏄棬閿�
+ if (this.listNewDevice[0].Type == DeviceType.DoorLock)
+ {
+ var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
+ //1銆佸叆缃戝悗鍏堣幏鍙栭棬閿佸湪缃戝叧涓殑鏃跺尯鏃堕棿
+ var curDateTime = DoorLock.DoorLockCommonInfo.GetDoorLockZoneTime();
+ //2銆佸皢鏃堕棿璁剧疆鍒扮綉鍏充腑
+ var dateTime = new DateTime(curDateTime.Year, curDateTime.Month, curDateTime.Day, curDateTime.Hour, curDateTime.Minute, curDateTime.Second);
+ var setTimestamp = DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(dateTime);
+ await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp));
+ }
+ }
-#region 鈻� 鐢婚潰鍏抽棴___________________________
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ /// <summary>
+ /// 鏂板叆缃戠殑璁惧,娓呯┖鎺夊畠鐨勬埧闂�
+ /// </summary>
+ private void ClearDeviceFromRoom()
+ {
+ foreach (var device in this.listNewDevice)
+ {
+ HdlRoomLogic.Current.DeleteDevice(device);
+ HdlRoomLogic.Current.DeleteLoveDevice(device);
+ }
+ Common.LocalDevice.Current.DeleteRealDeviceFromRoom(this.listNewDevice[0]);
+ }
+
+ #endregion
+
+ #region 鈻� 鐢婚潰鍏抽棴___________________________
/// <summary>
/// 鐢婚潰鍏抽棴
@@ -308,6 +347,6 @@
base.CloseFormBefore();
}
-#endregion
+ #endregion
}
}
--
Gitblit v1.8.0