diff --git a/Plane.FormationCreator/App.xaml.cs b/Plane.FormationCreator/App.xaml.cs index f8b5748..9e10f56 100644 --- a/Plane.FormationCreator/App.xaml.cs +++ b/Plane.FormationCreator/App.xaml.cs @@ -54,8 +54,16 @@ namespace Plane.FormationCreator }; this.Exit += (s, e) => { - TcpServerConnectionManager.Instance.StopListening(); - UdpServerConnectionManager.Instance.StopReceiving(); + try + { + TcpServerConnectionManager.Instance.StopListening(); + UdpServerConnectionManager.Instance.StopReceiving(); + } + catch (Exception ex) + { + // RaiseExceptionThrown(ex); + } + }; //new Test().Prepare().Run(); } @@ -110,6 +118,7 @@ namespace Plane.FormationCreator if (!TcpServerConnectionManager.Instance.StartListening()) { Alert.Show("网络连接不正常,无法启动监听。"); + return; } UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) => { diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 7420df7..1dd0581 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -47,7 +47,8 @@ namespace Plane.FormationCreator.Formation } } } - selectedCopter.SetShowLEDFlashAsync(1, 100); + if (selectedCopter!=null) + selectedCopter.SetShowLEDFlashAsync(1, 100); }; TaskAdded += (sender, e) => @@ -189,7 +190,15 @@ namespace Plane.FormationCreator.Formation newTask.SingleCopterInfos.Add(newSingleCopterInfo); } Tasks.Add(newTask); - TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = newTask }); + try + { + TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = newTask }); + } + catch (Exception ex) + { + //RaiseExceptionThrown(ex); + } + SelectedTask = newTask; SelectedTaskIndex = Tasks.Count - 1; } diff --git a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs index b4bbe4b..b98dbce 100644 --- a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs +++ b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs @@ -18,6 +18,15 @@ namespace Plane.FormationCreator.Formation set { Set(nameof(StaggerRoutes), ref _StaggerRoutes, value); } } + + private bool _FlytoShowLED = true; + public bool FlytoShowLED + { + get { return _FlytoShowLED; } + set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); } + } + + private bool _VerticalLift = false; public bool VerticalLift // 垂直升降标志位,后面需要加入即使拖动地图上的飞机,也不会变化经纬度. added by ZJF { @@ -522,7 +531,8 @@ namespace Plane.FormationCreator.Formation tasks[i] = await Task.Factory.StartNew(async () => { var internalInfo = info; - //if (i1 > 0) + await info.Copter.SetShowLEDAsync(FlytoShowLED); + //if (i1 > 0) //{ // var prevCopter = infos[i1 - 1].Copter; // while (CheckCrossing(infos, i1) && @@ -531,7 +541,7 @@ namespace Plane.FormationCreator.Formation // await Task.Delay(25).ConfigureAwait(false); // } //} - + await FlyToTaskFlySingleCopterAsync(internalInfo); }); } diff --git a/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs b/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs index 98ad9f5..1781526 100644 --- a/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs +++ b/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs @@ -143,7 +143,7 @@ namespace Plane.FormationCreator.Formation { return; } - //await copter.SetShowLEDAsync(true); + await copter.SetShowLEDAsync(true); await copter.UnlockAsync(); for (int i = 0; !copter.IsUnlocked; i++) { @@ -225,6 +225,7 @@ namespace Plane.FormationCreator.Formation if (info.takeOffStage == 1) { await info.Copter.GuidAsync(); + await info.Copter.SetShowLEDAsync(false); for (int j = 0; j < 3; j++) { await info.Copter.FlyToAsync(copterNextTask.TargetLat, copterNextTask.TargetLng, takeOffAlt); diff --git a/Plane.FormationCreator/MainWindow.xaml.cs b/Plane.FormationCreator/MainWindow.xaml.cs index 1bc63cf..da6e6d4 100644 --- a/Plane.FormationCreator/MainWindow.xaml.cs +++ b/Plane.FormationCreator/MainWindow.xaml.cs @@ -111,7 +111,7 @@ namespace Plane.FormationCreator var copters = _copterManager.AcceptingControlCopters; await Task.WhenAll(copters.Select(async copter => { - isledon = await copter.GetShowLEDAsync(); + isledon = copter.GetShowLEDAsync(); await copter.SetShowLEDAsync(!isledon); })).ConfigureAwait(false); diff --git a/Plane.FormationCreator/Views/CopterInfoView.xaml b/Plane.FormationCreator/Views/CopterInfoView.xaml index 19b5e33..de6565d 100644 --- a/Plane.FormationCreator/Views/CopterInfoView.xaml +++ b/Plane.FormationCreator/Views/CopterInfoView.xaml @@ -63,7 +63,7 @@ - +