diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 12355f7..8c2fd2f 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -262,7 +262,7 @@ namespace Plane.FormationCreator.Formation coptindex++; - var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt, true); + var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt, 10,10); newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading; newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading; newTask.SingleCopterInfos.Add(newSingleCopterInfo); @@ -380,13 +380,19 @@ namespace Plane.FormationCreator.Formation { var singleCopterInfoObj = singleCopterInfos[i]; tagalt = (float)singleCopterInfoObj.targetAlt; - newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt, (bool)singleCopterInfoObj.showLED); + newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask( + copter, new LatLng((double)singleCopterInfoObj.latOffset, + (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt, + (int)singleCopterInfoObj.flytoTime, + (int)singleCopterInfoObj.loiterTime); } else { + //实际飞机比保存的任务计划的飞机多,多的飞机设置默认航点 newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask - (copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, (bool)false); + (copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, 10,10 + ); } newTask.SingleCopterInfos.Add(newSingleCopterInfo); @@ -519,6 +525,7 @@ namespace Plane.FormationCreator.Formation SelectedTaskIndex = Tasks.Count - 1; } + //导出任务 public string ExportTasks() { // For reference. @@ -635,7 +642,9 @@ namespace Plane.FormationCreator.Formation latOffset = offset.Lat, lngOffset = offset.Lng, targetAlt = info.TargetAlt, - showLED = info.FlytoShowLED + showLED = info.FlytoShowLED, + flytoTime = info.FlytoTime, + loiterTime = info.LoiterTime }; }) }; @@ -735,6 +744,7 @@ namespace Plane.FormationCreator.Formation } + //导入任务,可设置导入哪些步骤 public void ImportTasksindex(string tasksText,int startindex,int endindex) { dynamic tasks = JsonConvert.DeserializeObject(tasksText); @@ -781,7 +791,7 @@ namespace Plane.FormationCreator.Formation i++; } } - + // 导入任务 public void ImportTasks(string tasksText) { dynamic tasks = JsonConvert.DeserializeObject(tasksText); diff --git a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs index ce65b73..786bd21 100644 --- a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs +++ b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs @@ -1,35 +1,38 @@ -using Plane.Copters; +using GalaSoft.MvvmLight.Command; +using Plane.Copters; +using Plane.Windows.Messages; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace Plane.FormationCreator.Formation { public partial class FlightTaskSingleCopterInfo { - public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt,bool showLED) + public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt,int flytoTime,int loiterTime) { var info = new FlightTaskSingleCopterInfo(copter) { TargetLat = targetLat, TargetLng = targetLng, TargetAlt = targetAlt, - FlytoShowLED= showLED, - // FlytoTime= flytoTime, - // LoiterTime = loiterTime + FlytoTime= flytoTime, + LoiterTime = loiterTime }; return info; } - public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt, bool showLED) + public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt, int flytoTime, int loiterTime) { var info = new FlightTaskSingleCopterInfo(copter) { LatLngOffset = latLngOffset, TargetAlt = targetAlt, - FlytoShowLED = showLED + FlytoTime = flytoTime, + LoiterTime = loiterTime }; return info; } @@ -52,7 +55,18 @@ namespace Plane.FormationCreator.Formation get { return _LoiterTime; } set { Set(nameof(LoiterTime), ref _LoiterTime, value); } } - + //设置飞机航点中灯光 + private ICommand _ModiFlytoLEDCommand; + public ICommand ModiFlytoLEDCommand + { + get + { + return _ModiFlytoLEDCommand ?? (_ModiFlytoLEDCommand = new RelayCommand(async => + { + Alert.Show("sfsdf"); + })); + } + } } } diff --git a/Plane.FormationCreator/Plane.FormationCreator.csproj b/Plane.FormationCreator/Plane.FormationCreator.csproj index 333062b..b15f556 100644 --- a/Plane.FormationCreator/Plane.FormationCreator.csproj +++ b/Plane.FormationCreator/Plane.FormationCreator.csproj @@ -152,6 +152,7 @@ + ControlPanelView.xaml @@ -172,6 +173,9 @@ ModifyTaskView.xaml + + ModiLEDWindow.xaml + TaskBarView.xaml @@ -275,6 +279,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index ef40b4f..0b60bc4 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -205,6 +205,7 @@ namespace Plane.FormationCreator.ViewModels await Task.WhenAll(_copterManager.AcceptingControlCopters.Select (copter => copter.SetParamAsync(name, value))); + /* await Task.WhenAll( _copterManager.AcceptingControlCopters.Select(async copter => @@ -218,6 +219,7 @@ namespace Plane.FormationCreator.ViewModels } )); + */ } @@ -606,7 +608,7 @@ namespace Plane.FormationCreator.ViewModels var _flightTaskManager = _taskmodimodel.FlightTaskManager; int coptercount = _copterManager.Copters.Count; int taskcount = _flightTaskManager.Tasks.Count; - bool havewritefault = true; + // bool havewritefault = true; if (taskcount < 2) return; for (int i = 0; i < coptercount; i++) @@ -622,15 +624,24 @@ namespace Plane.FormationCreator.ViewModels switch (_flightTaskManager.Tasks[j].TaskType) { case FlightTaskType.TakeOff: - - missions[missindex++] = Mission.CreateTakeoffMission(2,5,_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat, - _flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j+1].SingleCopterInfos[i].TargetAlt); + //计算起飞需要的时间,5秒是上升加速和最后稳定时间 + int takeofftime = (int)(_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetAlt / 2.5 + 5); + missions[missindex++] = Mission.CreateTakeoffMission(1, + takeofftime, + _flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat, + _flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng, + _flightTaskManager.Tasks[j+1].SingleCopterInfos[i].TargetAlt); //要起飞任务 break; case FlightTaskType.FlyTo: - missions[missindex++] = Mission.CreateWaypointMission(5,15,_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat, - _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt); + + missions[missindex++] = Mission.CreateWaypointMission( + 5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime, + 20,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime, + _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat, + _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, + _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt); break; case FlightTaskType.Loiter: // missions[missindex++] = Mission.CreateWaypointMission(10,10,_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat, diff --git a/Plane.FormationCreator/Views/ModifyTaskView.xaml b/Plane.FormationCreator/Views/ModifyTaskView.xaml index 0407576..663cb20 100644 --- a/Plane.FormationCreator/Views/ModifyTaskView.xaml +++ b/Plane.FormationCreator/Views/ModifyTaskView.xaml @@ -206,7 +206,8 @@ - + + @@ -219,19 +220,26 @@ - + +