diff --git a/PlaneGcsSdk.Contract_Shared/Copters/ICopterActions.cs b/PlaneGcsSdk.Contract_Shared/Copters/ICopterActions.cs index 97a3360..b597f9e 100644 --- a/PlaneGcsSdk.Contract_Shared/Copters/ICopterActions.cs +++ b/PlaneGcsSdk.Contract_Shared/Copters/ICopterActions.cs @@ -108,6 +108,12 @@ namespace Plane.Copters /// 表示异步设置参数操作的 实例。 /// 操作超时。 Task SetParamAsync(string paramName, float value, int millisecondsTimeout = Timeout.Infinite); + bool GetShowLEDAsync(); + + Task SetShowLEDAsync(bool Ledon); + Task SetShowLEDFlashAsync(int Flashtype, int millisecondsTime); + + /// /// 开始对频。 diff --git a/PlaneGcsSdk_Shared/Communication/TcpServerConnectionManager.cs b/PlaneGcsSdk_Shared/Communication/TcpServerConnectionManager.cs index e392cc8..1c378b8 100644 --- a/PlaneGcsSdk_Shared/Communication/TcpServerConnectionManager.cs +++ b/PlaneGcsSdk_Shared/Communication/TcpServerConnectionManager.cs @@ -54,7 +54,15 @@ namespace Plane.Communication var address = Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault(addr => addr.AddressFamily == AddressFamily.InterNetwork && addr.GetAddressBytes()[0] == 192); if (address == null) return false; _listener = new TcpListener(address, TCP_LOCAL_PORT); - _listener.Start(); + try + { + _listener.Start(); + } + catch (Exception ex) + { + // RaiseExceptionThrown(ex); + return false; + } _shouldListen = true; Task.Factory.StartNew(async () => { diff --git a/PlaneGcsSdk_Shared/Copters/EmptyCopter.cs b/PlaneGcsSdk_Shared/Copters/EmptyCopter.cs index 240cade..e215448 100644 --- a/PlaneGcsSdk_Shared/Copters/EmptyCopter.cs +++ b/PlaneGcsSdk_Shared/Copters/EmptyCopter.cs @@ -58,6 +58,19 @@ namespace Plane.Copters { return TaskUtils.CompletedTask; } + public Task SetShowLEDFlashAsync(int Flashtype, int millisecondsTime) + { + return TaskUtils.CompletedTask; + } + + public bool GetShowLEDAsync() + { + return false; + } + public Task SetShowLEDAsync(bool Ledon) + { + return TaskUtils.CompletedTask; + } public Task StartPairingAsync() { diff --git a/PlaneGcsSdk_Shared/Copters/FakeCopter.cs b/PlaneGcsSdk_Shared/Copters/FakeCopter.cs index 2114922..651b834 100644 --- a/PlaneGcsSdk_Shared/Copters/FakeCopter.cs +++ b/PlaneGcsSdk_Shared/Copters/FakeCopter.cs @@ -84,6 +84,13 @@ namespace Plane.Copters /// private double _targetLng; + + /// + /// FlyTo 的目标经度。 + /// + private bool _ShowLED; + + /// /// 使用 创建 实例。 /// @@ -258,6 +265,35 @@ namespace Plane.Copters // TODO: 林俊清, 20150807, 实现仿真的 SetParamAsync。 return TaskUtils.CompletedTask; } + public bool GetShowLEDAsync() + { + return _ShowLED; + } + public Task SetShowLEDAsync(bool Ledon) + { + _ShowLED = Ledon; + RaiseLocationChanged(); + return TaskUtils.CompletedTask; + } + public Task SetShowLEDFlashAsync(int Flashtype, int millisecondsTime) + { + bool Ledison; + Ledison = GetShowLEDAsync(); + if (!Ledison) + { + SetShowLEDAsync(true); + Task.Delay(millisecondsTime).ConfigureAwait(false); + SetShowLEDAsync(false); + } + else + { + SetShowLEDAsync(false); + Task.Delay(millisecondsTime).ConfigureAwait(false); + SetShowLEDAsync(true); + } + + return TaskUtils.CompletedTask; + } public void SetProperties( string id = null, //"Junqing's Drone", diff --git a/PlaneGcsSdk_Shared/Copters/PLCopter.cs b/PlaneGcsSdk_Shared/Copters/PLCopter.cs index 0122be3..5519aed 100644 --- a/PlaneGcsSdk_Shared/Copters/PLCopter.cs +++ b/PlaneGcsSdk_Shared/Copters/PLCopter.cs @@ -18,6 +18,7 @@ namespace Plane.Copters private int _setModeCount = 0; private int _takeOffCount; + private bool _showLed=false; #if PRIVATE public PLCopter(IConnection connection, SynchronizationContext uiSyncContext, bool autoSendHeartbeat = true, bool autoRequestData = true) : base(uiSyncContext) @@ -113,6 +114,62 @@ namespace Plane.Copters ).ConfigureAwait(false); } + + + + + + public bool GetShowLEDAsync() + { + return _showLed; + + /* + int showled; + showled=(int)await _internalCopter.GetParamAsync("NTF_SHOWLED", 0).ConfigureAwait(false); + if (showled == 0) + return false; + else return true; + */ + + } + + + public async Task SetShowLEDAsync(bool Ledon) + { + if (Ledon) + await SetParamAsync("NTF_SHOWLED", 1, 5000); + else + await SetParamAsync("NTF_SHOWLED", 0, 5000); + _showLed = Ledon; + } + + /// + /// 闪烁SHOWLED,如果当前没亮,那就亮一下,如果本来就是亮的,那就暗一下 + /// + /// 闪烁类型,目前没用 + /// 闪烁时间ms + /// + public async Task SetShowLEDFlashAsync(int Flashtype,int millisecondsTime) + { + bool Ledison; + Ledison= GetShowLEDAsync(); + if (!Ledison) + { + await SetShowLEDAsync(true); + await Task.Delay(millisecondsTime).ConfigureAwait(false); + await SetShowLEDAsync(false); + await SetShowLEDAsync(false); + }else + { + await SetShowLEDAsync(false); + await Task.Delay(millisecondsTime).ConfigureAwait(false); + await SetShowLEDAsync(true); + await SetShowLEDAsync(true); + } + + + } + public async Task SetParamAsync(string paramName, float paramValue, int millisecondsTimeout = Timeout.Infinite) { var stopwatch = Stopwatch.StartNew();