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/Curtain/UserDeviceToCurtains.cs | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 90 insertions(+), 0 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Curtain/UserDeviceToCurtains.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Curtain/UserDeviceToCurtains.cs index 99ffe19..374326a 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Curtain/UserDeviceToCurtains.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Curtain/UserDeviceToCurtains.cs @@ -534,6 +534,96 @@ } /// <summary> + /// 鎺у埗鎵�鏈夌獥甯� + /// </summary> + /// <param name="status">1锛氬紑锛�2锛氬叧.</param> + void controlAllCurtainNew (byte status) + { + if (CommonPage.IsRemote) { + if (!SmartHome.MqttCommon.IsGatewayOnline) { + new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); + return; + } + } + showTip = true; + MainPage.Loading.Start ("Sending..."); + 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 common in room.DeviceList) { + //2020-02-10 + byte [] returnBytes = null; + if (common.Type == DeviceType.CurtainModel || common.Type == DeviceType.CurtainRoller || common.Type == DeviceType.CurtainTrietex) { + System.Threading.Tasks.Task.Run (() => { + mSendCount++; + + if (common.Type == DeviceType.CurtainModel) { + var curtainmodel = common as CurtainModel; + returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, status }); + } else if (common.Type == DeviceType.CurtainRoller) { + var curtainroller = common as CurtainRoller; + returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { curtainroller.LoopID, status }); + } else if (common.Type == DeviceType.CurtainTrietex) { + var curtaintrietex = common as CurtainTrietex; + returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { curtaintrietex.LoopID, status }); + } + + if (showTip) { + if (returnBytes == null) { + Application.RunOnMainThread (() => { + + string tipString = ErrorCode.ControlFailure; + var btnTip = new Button () { + Height = Application.GetRealHeight (140), + Text = common.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), + BackgroundColor = 0xFFD7D7D7, + }; + MainPage.MainFrameLayout.AddChidren (btnTip); + btnTip.MouseUpEventHandler += (sender, e) => { + btnTip.RemoveFromParent (); + showTip = false; + }; + + System.Threading.Tasks.Task.Run (() => { + System.Threading.Thread.Sleep (3000); + Application.RunOnMainThread (() => { + btnTip.RemoveFromParent (); + }); + }); + + }); + } + } + + mSendCount--; + }); + + //绛夊緟100ms鍐嶅彂閫佺浜屼釜璁惧鏁版嵁 + System.Threading.Thread.Sleep (100); + + } + + + } + } + + while (mSendCount > 0) { + System.Threading.Thread.Sleep (100); + } + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + }); + } + + /// <summary> /// //2020-02-10 甯﹁繑鍥炵粨鏋滅殑淇敼绐楀笜鐘舵�� /// </summary> /// <param name="mLightCommon"></param> -- Gitblit v1.8.0