From 64b4412ff44bab84ada4993afb7ccc431c9bcdd1 Mon Sep 17 00:00:00 2001 From: pxzleo Date: Sat, 11 Mar 2017 02:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=8A=A0=E5=85=A5=E9=A3=9E=E6=9C=BA=E4=BA=AE=E7=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=8A=A0=E5=85=A5=E9=A3=9E=E8=A1=8C?= =?UTF-8?q?=E8=88=AA=E7=BA=BF=E4=BA=AE=E7=81=AF=E6=8E=A7=E5=88=B6=20[App.x?= =?UTF-8?q?aml.cs]=E4=BF=AE=E6=94=B9=E6=8A=A5=E9=94=99=E7=9A=84bug=20[Flig?= =?UTF-8?q?htTaskManager.cs]=20=E9=98=B2=E6=AD=A2=E6=8A=A5=E9=94=99=20[Fli?= =?UTF-8?q?ghtTask=5FFlyTo.cs]=E5=8A=A0=E5=85=A5=E4=BA=AE=E7=81=AF?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=20[FlightTask=5FTakeOff.cs]=E8=B5=B7?= =?UTF-8?q?=E9=A3=9E=E6=97=B6=E6=89=93=E5=BC=80=E7=81=AF=EF=BC=8C=E5=B9=B3?= =?UTF-8?q?=E9=A3=9E=E6=98=AF=E5=85=B3=E9=97=AD=E7=81=AF=20[MainWindow.xam?= =?UTF-8?q?l.cs]=E4=BB=8E=E6=9C=AC=E5=9C=B0=E5=BE=97=E5=88=B0=E4=BA=AE?= =?UTF-8?q?=E7=81=AF=E5=8F=98=E9=87=8F=EF=BC=8C=E4=B8=8D=E7=94=A8=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=8F=96=20[MapView=5FCopterDrawing.cs]=E4=BA=AE?= =?UTF-8?q?=E7=81=AF=E6=97=B6=E6=98=BE=E7=A4=BA=E4=B8=AA=E5=A4=96=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=20[ModifyTaskView.xaml]=E9=A3=9E=E5=BE=80=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=BA=AE=E7=81=AF=E6=8E=A7=E5=88=B6=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plane.FormationCreator/App.xaml.cs | 13 +++++++++++-- .../Formation/FlightTaskManager.cs | 13 +++++++++++-- .../Formation/FlightTask_FlyTo.cs | 14 ++++++++++++-- .../Formation/FlightTask_TakeOff.cs | 3 ++- Plane.FormationCreator/MainWindow.xaml.cs | 2 +- Plane.FormationCreator/Views/CopterInfoView.xaml | 6 +++--- .../Views/MapView_CopterDrawing.cs | 8 ++++++++ Plane.FormationCreator/Views/ModifyTaskView.xaml | 6 ++++++ 8 files changed, 54 insertions(+), 11 deletions(-) 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 @@ - +