From 6bca8fcd37a48808a0b9c9342fc1be0adddfece6 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期五, 08 五月 2020 17:46:44 +0800 Subject: [PATCH] 请合并最新代码,优化绑定信息 --- ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs | 314 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 314 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs new file mode 100755 index 0000000..8c174d1 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs @@ -0,0 +1,314 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.DeviceAirConditioner +{ + /// <summary> + /// 绌鸿皟瀹ゅ唴鏈鸿缃晫闈� + /// </summary> + public class IndoorUnitSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private FrameListControl listview = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勭綉鍏� + /// </summary> + private AC deviceAc = null; + /// <summary> + /// 鎽嗛妯″紡(鐢ㄤ簩杩涘埗鏉ョ帺鑷畾涔夋ā寮� 0:涓嶄娇鐢� 1:浣跨敤) + /// </summary> + private int swingMode = 0; + /// <summary> + /// 鍥哄畾棰勭暀鐨勬暟鎹� + /// </summary> + private string fixValue = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_deviceAc">閫夋嫨鐨勭┖璋冨洖璺�</param> + public void ShowForm(AC i_deviceAc) + { + this.deviceAc = i_deviceAc; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion)); + + //鍒濆鍖栧彸涓婅鑿滃崟 + this.InitTopRightMenu(); + + HdlThreadLogic.Current.RunThread(() => + { + //寮�鍚繘搴︽潯 + this.ShowProgressBar(); + //璇诲彇绌鸿皟鎽嗛妯″紡 + var result = this.ReadAirConditionerSwingModeSupport(); + if (result == false) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + + HdlThreadLogic.Current.RunMain(() => + { + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + }); + }); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var listBackControl = new VerticalFrameControl(); + listBackControl.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listBackControl); + + //鍒濆鍖栨甯� + var tableContr = new InformationEditorControl(); + this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1368); + + //鍥剧墖 + var btnPic = new DeviceInfoIconControl(); + btnPic.Y = Application.GetRealHeight(92); + btnPic.Gravity = Gravity.CenterHorizontal; + listBackControl.frameTable.AddChidren(btnPic); + btnPic.InitControl(this.deviceAc); + + //璁惧澶囨敞 + string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote); + string nameValue = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc); + var btnNote = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2); + listview.AddChidren(btnNote); + btnNote.InitControl(); + //鍒掔嚎 + btnNote.AddBottomLine(); + btnNote.txtInput.FinishInputEvent += async () => + { + string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc); + if (btnNote.Text.Trim() == string.Empty) + { + //灏嗗悕瀛楄繕鍘� + btnNote.Text = oldName; + } + if (oldName != btnNote.Text) + { + //璁惧鍚嶇О淇敼 + var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); + if (result == false) + { + return; + } + //璁惧澶囨敞淇敼鎴愬姛! + string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess); + this.ShowMassage(ShowMsgType.Tip, msg); + } + }; + + //璁惧绫诲瀷 + caption = Language.StringByID(R.MyInternationalizationString.uDeviceType); + nameValue = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { deviceAc }); + var btnType = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2); + btnType.UseClickStatu = false; + listview.AddChidren(btnType); + btnType.InitControl(); + //鍒掔嚎 + btnType.AddBottomLine(); + + //鎵�灞炲尯鍩� + var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2); + listview.AddChidren(rowBeloneArea); + rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), deviceAc); + //搴曠嚎 + rowBeloneArea.AddBottomLine(); + rowBeloneArea.SelectRoomEvent += (roomKeys) => + { + HdlRoomLogic.Current.ChangedRoom(deviceAc, roomKeys); + }; + + //绌鸿皟妯″紡 + var rowMode = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowMode); + rowMode.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAirConditionerMode), 600); + rowMode.AddRightArrow(); + rowMode.AddBottomLine(); + rowMode.ButtonClickEvent += (sender, e) => + { + var form = new AirConditionerModeForm(); + form.AddForm(deviceAc); + }; + + //鎽嗛 + var rowSwing = new FrameRowControl(listview.rowSpace / 2); + rowSwing.UseClickStatu = false; + listview.AddChidren(rowSwing); + rowSwing.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAirConditionerSwing), 400); + rowSwing.AddBottomLine(); + var btnSwingSwitch = rowSwing.AddMostRightSwitchIcon(); + if (this.swingMode == 1) + { + btnSwingSwitch.IsSelected = true; + } + btnSwingSwitch.ButtonClickEvent += (sender, e) => + { + //涓嶈兘鍐嶇偣鍑� + btnSwingSwitch.CanClick = false; + string statu = btnSwingSwitch.IsSelected == true ? "0" : "1"; + //灏嗕簩杩涘埗杞崲涓哄崄杩涘埗 + int sendData = Convert.ToInt32(this.fixValue + statu, 2); + HdlThreadLogic.Current.RunThread(async () => + { + var result = await HdlDeviceAirConditionerLogic.Current.SetUseAcSwingFunctionStatu(deviceAc, sendData); + if (result == true) + { + HdlThreadLogic.Current.RunMain(() => + { + btnSwingSwitch.IsSelected = !btnSwingSwitch.IsSelected; + this.swingMode = this.swingMode == 1 ? 0 : 1; + + deviceAc.UseSwingFunction = btnSwingSwitch.IsSelected; + deviceAc.ReSave(); + }); + } + //鑳藉缁х画鐐瑰嚮 + btnSwingSwitch.CanClick = true; + }); + }; + + //鍒濆鍖栨甯冨畬鎴� + tableContr.FinishInitControl(); + tableContr = null; + + //淇濆瓨 + var btnFinish = new BottomClickButton(); + btnFinish.TextID = R.MyInternationalizationString.uSave; + bodyFrameLayout.AddChidren(btnFinish); + btnFinish.ButtonClickEvent += async (sender, e) => + { + string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc); + if (oldName != btnNote.Text) + { + //璁惧鍚嶇О淇敼 + var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text); + if (result == false) + { + return; + } + } + this.CloseForm(); + }; + } + + #endregion + + #region 鈻� 鍙充笂瑙掕彍鍗昣________________________ + + /// <summary> + /// 鍒濆鍖栧彸涓婅鑿滃崟 + /// </summary> + private void InitTopRightMenu() + { + //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘(鎷跨鐐规渶灏忕殑閭d釜鍥炶矾鍘诲畾浣�) + bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(deviceAc); + if (canTest == false) + { + return; + } + var btnIcon = new MostRightIconControl(69, 69); + btnIcon.UnSelectedImagePath = "Item/More.png"; + topFrameLayout.AddChidren(btnIcon); + btnIcon.InitControl(); + btnIcon.ButtonClickEvent += ((sender, e) => + { + //鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + this.ShowTopRightMenu(); + }); + } + + /// <summary> + /// 鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + /// </summary> + private void ShowTopRightMenu() + { + var frame = new TopRightMenuControl(1, 1); + //瀹氫綅 + var deviceMenu = Language.StringByID(R.MyInternationalizationString.uFixedPosition); + frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () => + { + //鍙戦�佸畾浣嶅姛鑳� + Common.LocalDevice.Current.SetFixedPositionCommand(deviceAc); + }); + } + + #endregion + + #region 鈻� 璇诲彇绌鸿皟鎽嗛妯″紡___________________ + + /// <summary> + /// 璇诲彇绌鸿皟鎽嗛妯″紡 + /// </summary> + private bool ReadAirConditionerSwingModeSupport() + { + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceAc); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => + { + string checkKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); + if (checkKeys != mainkeys || report.DeviceStatusReport.CluterID != 514) + { + return; + } + for (int i = 0; i < report.DeviceStatusReport.AttriBute.Count; i++) + { + var data = report.DeviceStatusReport.AttriBute[i]; + if (data.AttributeId == 4097) + { + HdlGatewayReceiveLogic.Current.RemoveEvent("ReadAirConditionerModeSupport"); + //杞崲涓轰簩杩涘埗 + var value = Convert.ToString(data.AttriButeData, 2).PadLeft(16, '0'); + //杩欎釜璁剧疆鏄斁鍦ㄥ悗闈㈢殑 + this.fixValue = value.Substring(0, value.Length - 1); + this.swingMode = Convert.ToInt32(value.Substring(this.fixValue.Length)); + } + } + }); + //鑾峰彇鏄惁鍚敤绌鸿皟鎽嗛妯″紡鐨勭姸鎬�(鎵撳紑 鎴栬�� 鍏抽棴) + deviceAc.ReadUseSwingFunctionStatu(); + + int timeOut = 0; + while (this.fixValue == null && timeOut <= 30) + { + System.Threading.Thread.Sleep(100); + timeOut++; + } + if (this.fixValue == null) + { + //鑾峰彇绌鸿皟鎽嗛鐘舵�佸け璐� + string msg = Language.StringByID(R.MyInternationalizationString.uGetAirConditionerSwingFunctionFail); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + this.ShowMassage(ShowMsgType.Tip, msg); + return false; + } + return true; + } + + #endregion + } +} -- Gitblit v1.8.0