| | |
| | | |
| | | public void ControlScene (string sceneFilePath) |
| | | { |
| | | if (CommonPage.IsRemote) { |
| | | if (!SmartHome.MqttCommon.IsGatewayOnline) { |
| | | new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); |
| | | return; |
| | | } |
| | | } |
| | | var tempScene = Scene.GetSceneByFilePath (sceneFilePath); |
| | | if (tempScene == null) |
| | | return; |
| | | showTip = true; |
| | | MainPage.Loading.Start ("Sending..."); |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | int sceneDeviceCount = tempScene.DeviceFilePathList.Count; |
| | | int controlDeviceIndex = 0; |
| | |
| | | replyBytes = Control.ControlBytesSendHasReturn (Command.SetLogicLoopColor, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 254, device.DelayTimeHeigh,device.DelayTimeLow, |
| | | 3,device.RStatus,device.GStatus,device.BStatus,0,0}); |
| | | } |
| | | } else if (common.Type == DeviceType.LightSwitch ) { |
| | | } else if (common.Type == DeviceType.LightSwitch) { |
| | | var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); |
| | | if (device == null) { |
| | | continue; |
| | |
| | | replyBytes = Control.ControlBytesSendHasReturn (Command.SetScene, device.SubnetID, device.DeviceID, new byte [] { |
| | | device.AreaID,device.AreaSceneID}); |
| | | } |
| | | Application.RunOnMainThread (() => { |
| | | try { |
| | | if (showTip) { |
| | | if (replyBytes == null) { |
| | | |
| | | try { |
| | | if (showTip) { |
| | | if (replyBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | showTip = false; |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | }; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | btnTip.RemoveFromParent (); |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | showTip = false; |
| | | //showTip = false; |
| | | }); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | } catch { } |
| | | }); |
| | | } |
| | | } catch { } |
| | | |
| | | } |
| | | } else { |
| | | foreach (var common in tempScene.GlobalSceneDeviceList) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | |