From a5271518e5b9358328cb4213cc5737e1796ec4ec Mon Sep 17 00:00:00 2001 From: pxzleo Date: Sun, 17 Sep 2017 12:50:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8E=BB=E6=8E=89=E4=BA=A4=E5=8F=89=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=EF=BC=8C=E8=BF=99=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=95=B4=E4=B8=AA=E7=BC=96=E9=98=9F=E5=81=9C=E4=B8=BB=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=BB=A7=E7=BB=AD=E7=BB=84=E9=98=9F=EF=BC=8C=E5=89=8D?= =?UTF-8?q?=E9=9D=A2=E9=A3=9E=E6=9C=BA=E6=B2=A1=E5=88=B0=E4=BD=8D=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=E5=B0=B1=E6=B2=A1=E6=B3=95=E9=A3=9E,=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=90=8E=E9=9D=A2=E8=A6=81=E5=8A=A0=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=A4=9A=E6=B5=8B=E8=AF=95=E8=A7=A3=E5=86=B3=E5=89=8D?= =?UTF-8?q?=E5=BA=8F=E9=A3=9E=E6=9C=BA=E5=8F=AF=E9=9D=A0=E5=88=B0=E8=BE=BE?= =?UTF-8?q?=E5=92=8C=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=98=AF=E8=BF=99=E9=87=8C=E5=AF=BC=E8=87=B4=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=9A=82=E5=AE=9A=202.=E4=BF=AE=E6=94=B9=E6=82=AC=E5=81=9C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=B6=E4=B8=8D=E8=83=BD=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E6=AD=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Formation/FlightTask_FlyTo.cs | 16 ++++- .../Formation/FlightTask_LoiterTime.cs | 64 +++++++++++++++---- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs index 59f0a5b..f7af45c 100644 --- a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs +++ b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs @@ -11,7 +11,8 @@ namespace Plane.FormationCreator.Formation { public partial class FlightTask { - private bool _StaggerRoutes = true; + //默认不开这个功能 + private bool _StaggerRoutes = false; //是否有交错 public bool StaggerRoutes @@ -55,6 +56,18 @@ namespace Plane.FormationCreator.Formation var tasks = new Task[infos.Count]; for (int i = 0; i < infos.Count; i++) { + + var info = infos[i]; + + tasks[i] = await Task.Factory.StartNew(async () => + { + var internalInfo = info; + await FlyToTaskFlySingleCopterAsync(internalInfo); + }); + + /* + //检测交叉可能导致整个编队停主无法继续组队,前面飞机没到位后面就没法飞 + //如果后面要加,需要多测试解决前序飞机可靠到达和记录日志确认是这里导致任务暂定 var info = infos[i]; var copter = info.Copter; var i1 = i; @@ -72,6 +85,7 @@ namespace Plane.FormationCreator.Formation } await FlyToTaskFlySingleCopterAsync(info); }); + */ } await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs b/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs index ff56365..35e3bb2 100644 --- a/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs +++ b/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs @@ -27,9 +27,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand5 ?? (_NumberCommand5 = new RelayCommand(async => + return _NumberCommand5 ?? (_NumberCommand5 = new RelayCommand(async param => { - LEDNumberAsync(numberfive); + await LEDNumberAsync(numberfive); })); } } @@ -39,9 +39,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand4 ?? (_NumberCommand4 = new RelayCommand(async => + return _NumberCommand4 ?? (_NumberCommand4 = new RelayCommand(async param => { - LEDNumberAsync(numberFour); + await LEDNumberAsync(numberFour); })); } } @@ -50,9 +50,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand3 ?? (_NumberCommand3 = new RelayCommand(async => + return _NumberCommand3 ?? (_NumberCommand3 = new RelayCommand(async param => { - LEDNumberAsync(numberthree); + await LEDNumberAsync(numberthree); })); } } @@ -61,9 +61,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand2 ?? (_NumberCommand2 = new RelayCommand(async => + return _NumberCommand2 ?? (_NumberCommand2 = new RelayCommand(async param => { - LEDNumberAsync(numbertwo); + await LEDNumberAsync(numbertwo); })); } } @@ -72,9 +72,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand1 ?? (_NumberCommand1 = new RelayCommand(async => + return _NumberCommand1 ?? (_NumberCommand1 = new RelayCommand(async param => { - LEDNumberAsync(numberone); + await LEDNumberAsync(numberone); })); } } @@ -83,9 +83,17 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommand0 ?? (_NumberCommand0 = new RelayCommand(async => + return _NumberCommand0 ?? (_NumberCommand0 = new RelayCommand(async param => { - LEDNumberAsync(numberzero); + await LEDNumberAsync(numberzero); + await Task.Delay(200).ConfigureAwait(false); + await LEDNumberFlashAsync(false); + await Task.Delay(200).ConfigureAwait(false); + await LEDNumberAsync(numberzero); + await Task.Delay(200).ConfigureAwait(false); + await LEDNumberFlashAsync(false); + await Task.Delay(200).ConfigureAwait(false); + await LEDNumberAsync(numberzero); })); } } @@ -96,8 +104,9 @@ namespace Plane.FormationCreator.Formation { get { - return _NumberCommandok ?? (_NumberCommandok = new RelayCommand(async => + return _NumberCommandok ?? (_NumberCommandok = new RelayCommand(async param => { + await LEDNumberFlashAsync(true); numberisend = true; })); } @@ -398,7 +407,29 @@ namespace Plane.FormationCreator.Formation // LED灯全亮 await Task.WhenAll(SingleCopterInfos.Select(info => LEDFlashTaskFlySingleCopterAsync(info, true))); //延时等待 - await Task.Delay((int)(LoiterTimeAttr * 1000)).ConfigureAwait(false); + + //判断是否下一步 + DateTime start = DateTime.Now; + while (true) + { + if (_flightTaskManager.IsPaused == true) + { + await Task.WhenAll(SingleCopterInfos.Select(info => (info.Copter.HoverAsync()))); + return; + } + + DateTime end = DateTime.Now; + TimeSpan ts = end - start; + //等待指定时间 + if (ts.TotalMilliseconds> LoiterTimeAttr* 1000) + return; + await Task.Delay(20).ConfigureAwait(false); + + } + + + + } else if (numberShow) // LED数字倒计时,目前固定需要13架飞机,并且在跑马灯\数字顺序里设置13架飞机的顺序 @@ -420,6 +451,11 @@ namespace Plane.FormationCreator.Formation //判断是否下一步 while (! numberisend) { + if (_flightTaskManager.IsPaused == true) + { + await Task.WhenAll(SingleCopterInfos.Select(info => (info.Copter.HoverAsync()))); + return; + } await Task.Delay(25).ConfigureAwait(false); //判断是否下一步20hz }