| | |
| | | }); |
| | | } |
| | | |
| | | private readonly object SendLocker = new object (); |
| | | /// <summary> |
| | | /// 控制所有的灯 |
| | | /// </summary> |
| | |
| | | byte [] returnBytes = null; |
| | | if (common.Type == DeviceType.LightEnergySocket) { |
| | | new System.Threading.Thread (() => { |
| | | mSendCount++; |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, common.SubnetID, common.DeviceID, new byte [] { common.LoopID, b, 0, 0 }); |
| | | if (showTip) { |
| | | if (returnBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | try { |
| | | lock (SendLocker) { |
| | | mSendCount++; |
| | | } |
| | | //mSendCount++; |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, common.SubnetID, common.DeviceID, new byte [] { common.LoopID, b, 0, 0 }); |
| | | if (showTip) { |
| | | if (returnBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = common.Name + ErrorCode.ControlFailure, |
| | | BackgroundColor = 0xFFD7D7D7, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | }; |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = common.Name + ErrorCode.ControlFailure, |
| | | BackgroundColor = 0xFFD7D7D7, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | }); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | //mSendCount--; |
| | | } catch { } finally { |
| | | lock (SendLocker) { |
| | | mSendCount--; |
| | | } |
| | | } |
| | | mSendCount--; |
| | | }) { IsBackground = true}.Start(); |
| | | }) { IsBackground = true }.Start (); |
| | | |
| | | //等待100ms再发送第二个设备数据 |
| | | System.Threading.Thread.Sleep (100); |