From 9137222ece9b978eb97b5598f2eee6e070bcf9d6 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 28 二月 2020 15:22:16 +0800 Subject: [PATCH] 2020-02-28 更新 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Fan/UserDeviceToFan.cs | 87 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 84 insertions(+), 3 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Fan/UserDeviceToFan.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Fan/UserDeviceToFan.cs index d5bac9c..51310f8 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Fan/UserDeviceToFan.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Fan/UserDeviceToFan.cs @@ -92,7 +92,7 @@ #region 鏄剧ず int devcieCount = 0; foreach (var room in Room.Lists) { - if (string.IsNullOrEmpty(room.Name)) { + if (string.IsNullOrEmpty (room.Name)) { continue; } foreach (var common in room.DeviceList) { @@ -223,7 +223,7 @@ Application.RunOnMainThread (() => { int brighingCount = 0; foreach (var room in Room.Lists) { - if (string.IsNullOrEmpty(room.Name)) { + if (string.IsNullOrEmpty (room.Name)) { continue; } foreach (var light in room.DeviceList) { @@ -283,7 +283,7 @@ if (string.IsNullOrEmpty (room.Name)) { continue; } - + foreach (var fanD in room.DeviceList) { //2020-02-10 byte [] returnBytes = null; @@ -331,5 +331,86 @@ }); }); } + + void ControlAllFanNew (bool open) + { + if (CommonPage.IsRemote) { + if (!SmartHome.MqttCommon.IsGatewayOnline) { + new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); + return; + } + } + MainPage.Loading.Start ("Sending..."); + bool showTip = true; + System.Threading.Tasks.Task.Run (() => { + int mSendCount = 0; + + foreach (var room in Room.Lists) { + if (room == null) + continue; + if (string.IsNullOrEmpty (room.Name)) { + continue; + } + + foreach (var fanD in room.DeviceList) { + //2020-02-10 + byte [] returnBytes = null; + if (fanD.Type == DeviceType.FanModule) { + System.Threading.Tasks.Task.Run (() => { + mSendCount++; + if (open) { + returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, (fanD as FanModule).WindSpeed }); + } else { + returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, 0 }); + } + + + if (showTip) { + if (returnBytes == null) { + Application.RunOnMainThread (() => { + + string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); + var btnTip = new Button () { + Height = Application.GetRealHeight (140), + Text = fanD.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), + BackgroundColor = 0xFFD7D7D7, + }; + MainPage.MainFrameLayout.AddChidren (btnTip); + btnTip.MouseUpEventHandler += (sender, e) => { + btnTip.RemoveFromParent (); + //MainPage.MainFrameLayout.Remove (btnTip); + showTip = false; + }; + + System.Threading.Tasks.Task.Run (() => { + System.Threading.Thread.Sleep (3000); + Application.RunOnMainThread (() => { + btnTip.RemoveFromParent (); + //MainPage.MainFrameLayout.Remove (btnTip); + }); + }); + + }); + } + } + mSendCount--; + }); + + //绛夊緟100ms鍐嶅彂閫佺浜屼釜璁惧鏁版嵁 + System.Threading.Thread.Sleep (100); + + } + } + } + + while (mSendCount > 0) { + System.Threading.Thread.Sleep (100); + } + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + }); + } } } \ No newline at end of file -- Gitblit v1.8.0