diff --git a/Plane.FormationCreator/App.xaml.cs b/Plane.FormationCreator/App.xaml.cs index 63bd207..c558e60 100644 --- a/Plane.FormationCreator/App.xaml.cs +++ b/Plane.FormationCreator/App.xaml.cs @@ -19,6 +19,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using Plane.CommunicationManagement; +using Plane.FormationCreator.Util; namespace Plane.FormationCreator { @@ -68,6 +69,8 @@ namespace Plane.FormationCreator }; //new Test().Prepare().Run(); + + VersionControl.GetVersionFromIni(); } private ILogger _logger; diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 85f7866..e82b101 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -374,8 +374,8 @@ namespace Plane.FormationCreator.Formation CurrentRunningTask = null; //起飞任务需要跳过 - if (CurrentRunningTaskIndex == 0) - CurrentRunningTaskIndex++; +// if (CurrentRunningTaskIndex == 0) +// CurrentRunningTaskIndex++; CurrentRunningTaskIndex++; await RunTaskAsync(); } @@ -572,6 +572,7 @@ namespace Plane.FormationCreator.Formation { var singleCopterInfoObj = singleCopterInfos[i]; takeOffTask.SingleCopterInfos[i].TakeOffWaitTime = (ushort)singleCopterInfoObj.waitTime; + //Message.Show(((ushort)singleCopterInfoObj.waitTime).ToString()); } } diff --git a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_Land.cs b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_Land.cs index 14ebc27..84be95e 100644 --- a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_Land.cs +++ b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_Land.cs @@ -19,7 +19,7 @@ namespace Plane.FormationCreator.Formation return info; } - private ushort _LandWaitTime = 5; + private ushort _LandWaitTime = 1; public ushort LandWaitTime { get { return _LandWaitTime; } diff --git a/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs b/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs index f20fbbe..0f44e08 100644 --- a/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs +++ b/Plane.FormationCreator/Formation/FlightTask_TakeOff.cs @@ -76,7 +76,15 @@ namespace Plane.FormationCreator.Formation var tasksTakeOff = new Task[infos.Count]; for (int i = 0; i < infos.Count; i++) { - tasksTakeOff[i] = NewSingleRunTaskOffTaskAsunc(infos[i]); + //tasksTakeOff[i] = NewSingleRunTaskOffTaskAsunc(infos[i]); + + + tasksTakeOff[i] = await Task.Factory.StartNew(async () => + { + var internalInfo = infos[i]; + + await NewSingleRunTaskOffTaskAsunc(internalInfo); + }); } await Task.WhenAll(tasksTakeOff).ConfigureAwait(false); //await Task.Delay(100); @@ -90,31 +98,24 @@ namespace Plane.FormationCreator.Formation int copterIndex = SingleCopterInfos.IndexOf(info); var copter = info.Copter; - - await copter.UnlockAsync(); - for (int i = 0; !copter.IsUnlocked; i++) - { - //8秒内每1000毫秒尝试解锁一次 - //解锁间隔一定要超过1s否则导致飞控以后无法解锁 - - if (i > 320) - return; //无法解锁后面不用执行了 - if (i % (1000 / 25) == 1000 / 25 - 1) - { - await copter.UnlockAsync(); // 每 1000 毫秒重试一次。 - } - - await Task.Delay(25).ConfigureAwait(false); - } //等待起飞时间 - while (ts.TotalMilliseconds < info.TakeOffWaitTime * 1000) + Windows.Messages.Message.Show($"{copter.Name}:等待起飞 = {info.TakeOffWaitTime}"); + while ((int)ts.TotalMilliseconds < (int)info.TakeOffWaitTime * 1000) { + if (_flightTaskManager.IsPaused == true) + { + await info.Copter.HoverAsync(); + return; + } await Task.Delay(100); dtNow = DateTime.Now; - ts = dtNow - dtLastTime; + ts = dtNow - dtLastTime; } + //虚拟飞机5秒后不起飞会自动上锁 + await copter.UnlockAsync(); + for (int i = 0; i < 5; i++) // added by ZJF { await copter.TakeOffAsync(); @@ -124,6 +125,9 @@ namespace Plane.FormationCreator.Formation var copterNextTask = _flightTaskManager.Tasks[TaskIndex + 1].SingleCopterInfos[copterIndex]; float takeOffAlt = copterNextTask.TargetAlt; + info.TargetLat = info.Copter.Latitude; + info.TargetLng = info.Copter.Longitude; + for (int j = 0; j < 3; j++) { await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt); @@ -133,8 +137,16 @@ namespace Plane.FormationCreator.Formation dtNow = DateTime.Now; ts = dtNow - dtLastTime; FlightTask task = _flightTaskManager.CurrentRunningTask; + + Windows.Messages.Message.Show($"{copter.Name}:等待到达飞行时间 = {task.TakeOffTime}"); while (ts.TotalMilliseconds < task.TakeOffTime * 1000) { + if (_flightTaskManager.IsPaused == true) + { + //Windows.Messages.Message.Show($"{copter.Name}:悬停"); + await info.Copter.HoverAsync(); + return; + } await Task.Delay(100).ConfigureAwait(false); dtNow = DateTime.Now; ts = dtNow - dtLastTime; diff --git a/Plane.FormationCreator/Formation/View3DManager.cs b/Plane.FormationCreator/Formation/View3DManager.cs new file mode 100644 index 0000000..41d6dbf --- /dev/null +++ b/Plane.FormationCreator/Formation/View3DManager.cs @@ -0,0 +1,19 @@ +using Plane.FormationCreator.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plane.FormationCreator.Formation +{ + public class View3DManager + { + public View3DViewModel _view3DViewModel { get; set; } + + public void ClearCopters() + { + this._view3DViewModel.Clear3DCopters(); + } + } +} diff --git a/Plane.FormationCreator/ModifyParam.xaml b/Plane.FormationCreator/ModifyParam.xaml index c10bb94..6b7bed8 100644 --- a/Plane.FormationCreator/ModifyParam.xaml +++ b/Plane.FormationCreator/ModifyParam.xaml @@ -12,75 +12,80 @@ + + +