From d6554486aba3376f4f41e2d28eec7b34cef355b7 Mon Sep 17 00:00:00 2001 From: zxd Date: Tue, 17 Jul 2018 17:13:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8D=95=E4=B8=AA=E8=88=AA?= =?UTF-8?q?=E7=82=B9=E7=9A=84FlytoTime=E5=92=8CLoiterTime=EF=BC=8C=20?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E4=B8=AA=E4=BB=BB=E5=8A=A1=E6=AF=8F=E4=B8=80?= =?UTF-8?q?=E6=9E=B6=E9=A3=9E=E6=9C=BA=E7=9A=84FlytoTime=E5=92=8CLoiterTim?= =?UTF-8?q?e=E4=BF=9D=E6=8C=81=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Formation/FlightTask.cs | 17 ++- .../Formation/FlightTaskManager.cs | 22 ++- .../FlightTaskSingleCopterInfo_FlyTo.cs | 23 +-- .../ViewModels/ControlPanelViewModel.cs | 6 +- .../Views/ModifyTaskView.xaml | 132 ++++++++---------- 5 files changed, 99 insertions(+), 101 deletions(-) diff --git a/Plane.FormationCreator/Formation/FlightTask.cs b/Plane.FormationCreator/Formation/FlightTask.cs index c1c0c3c..b49cbb1 100644 --- a/Plane.FormationCreator/Formation/FlightTask.cs +++ b/Plane.FormationCreator/Formation/FlightTask.cs @@ -70,7 +70,22 @@ namespace Plane.FormationCreator.Formation get { return _IsRightSelected; } set { Set(nameof(IsRightSelected), ref _IsRightSelected, value); } } - + + + //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一 + private int _FlytoTime = 123; + public int FlytoTime + { + get { return _FlytoTime; } + set { Set(nameof(FlytoTime), ref _FlytoTime, value); } + } + private int _LoiterTime = 321; + public int LoiterTime + { + get { return _LoiterTime; } + set { Set(nameof(LoiterTime), ref _LoiterTime, value); } + } + public List SingleCopterInfos { get; set; } = new List(); private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo; diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 1739f89..2a056bd 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -251,7 +251,7 @@ namespace Plane.FormationCreator.Formation coptindex++; - var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt, 10,10); + var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt); newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading; newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading; newTask.SingleCopterInfos.Add(newSingleCopterInfo); @@ -372,7 +372,7 @@ namespace Plane.FormationCreator.Formation } } - public void RestoreFlyToTask(bool staggerRoutes, dynamic singleCopterInfos) + public void RestoreFlyToTask(bool staggerRoutes, int flytoTime, int loiterTime, dynamic singleCopterInfos) { var copters = _copterManager.Copters; float tagalt = 15; @@ -382,7 +382,8 @@ namespace Plane.FormationCreator.Formation var nullableCenter = copters.GetCenter(); if (nullableCenter == null) return; var center = nullableCenter.Value; - var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes }; + var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes, FlytoTime = flytoTime, LoiterTime = loiterTime }; + // TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。 for (int i = 0; i < copters.Count; i++) { @@ -394,17 +395,14 @@ namespace Plane.FormationCreator.Formation tagalt = (float)singleCopterInfoObj.targetAlt; newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask( copter, new LatLng((double)singleCopterInfoObj.latOffset, - (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt, - (int)singleCopterInfoObj.flytoTime, - (int)singleCopterInfoObj.loiterTime); + (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt); } else { //实际飞机比保存的任务计划的飞机多,多的飞机设置默认航点 newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask - (copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, 10,10 - ); + (copter, (double)copter.Latitude, (double)copter.Longitude, tagalt); } newTask.SingleCopterInfos.Add(newSingleCopterInfo); @@ -646,6 +644,8 @@ namespace Plane.FormationCreator.Formation { type = type, staggerRoutes = task.StaggerRoutes, + flytoTime = task.FlytoTime, + loiterTime = task.LoiterTime, singleCopterInfos = task.SingleCopterInfos.Select(info => { var offset = info.LatLngOffset; @@ -655,8 +655,6 @@ namespace Plane.FormationCreator.Formation lngOffset = offset.Lng, targetAlt = info.TargetAlt, showLED = info.FlytoShowLED, - flytoTime = info.FlytoTime, - loiterTime = info.LoiterTime }; }) }; @@ -778,7 +776,7 @@ namespace Plane.FormationCreator.Formation // TakeOffNumAttr = task.takeoffnumber; break; case FlightTaskType.FlyTo: - RestoreFlyToTask((bool)task.staggerRoutes, task.singleCopterInfos); + RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, task.singleCopterInfos); break; case FlightTaskType.Turn: RestoreTurnTask(task.singleCopterInfos); @@ -819,7 +817,7 @@ namespace Plane.FormationCreator.Formation TakeOffNumAttr = task.takeoffnumber; break; case FlightTaskType.FlyTo: - RestoreFlyToTask((bool)task.staggerRoutes, task.singleCopterInfos); + RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, task.singleCopterInfos); break; case FlightTaskType.Turn: RestoreTurnTask(task.singleCopterInfos); diff --git a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs index 1906ed6..6c6ccf9 100644 --- a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs +++ b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_FlyTo.cs @@ -12,30 +12,27 @@ namespace Plane.FormationCreator.Formation { public partial class FlightTaskSingleCopterInfo { - public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt,int flytoTime,int loiterTime) + public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt) { var info = new FlightTaskSingleCopterInfo(copter) { TargetLat = targetLat, TargetLng = targetLng, - TargetAlt = targetAlt, - FlytoTime= flytoTime, - LoiterTime = loiterTime + TargetAlt = targetAlt }; return info; } - public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt, int flytoTime, int loiterTime) + public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt) { var info = new FlightTaskSingleCopterInfo(copter) { LatLngOffset = latLngOffset, - TargetAlt = targetAlt, - FlytoTime = flytoTime, - LoiterTime = loiterTime + TargetAlt = targetAlt }; return info; } + private bool _FlytoShowLED = true; public bool FlytoShowLED { @@ -43,6 +40,10 @@ namespace Plane.FormationCreator.Formation set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); } } + + /* + * //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一,已将FlytoTime和LoiterTime改到FlightTask.cs中 + * private int _FlytoTime = 10; public int FlytoTime { @@ -55,6 +56,8 @@ namespace Plane.FormationCreator.Formation get { return _LoiterTime; } set { Set(nameof(LoiterTime), ref _LoiterTime, value); } } + */ + //设置飞机航点中灯光 private ICommand _ModiFlytoLEDCommand; public ICommand ModiFlytoLEDCommand @@ -63,7 +66,9 @@ namespace Plane.FormationCreator.Formation { return _ModiFlytoLEDCommand ?? (_ModiFlytoLEDCommand = new RelayCommand(async => { - Alert.Show("灯光控制"); + //Alert.Show("灯光控制"); + Views.modiLED LEDConfig = new Views.modiLED(); + LEDConfig.ShowDialog(); })); } } diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index 4e2138c..bf77ea8 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -661,8 +661,10 @@ namespace Plane.FormationCreator.ViewModels case FlightTaskType.FlyTo: missions[missindex++] = Mission.CreateWaypointMission( - 5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime, - 5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime, + //5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime, + //5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime, + _flightTaskManager.Tasks[j].LoiterTime, + _flightTaskManager.Tasks[j].FlytoTime, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt); diff --git a/Plane.FormationCreator/Views/ModifyTaskView.xaml b/Plane.FormationCreator/Views/ModifyTaskView.xaml index 663cb20..f7dd385 100644 --- a/Plane.FormationCreator/Views/ModifyTaskView.xaml +++ b/Plane.FormationCreator/Views/ModifyTaskView.xaml @@ -8,19 +8,19 @@ xmlns:m="clr-namespace:Plane.FormationCreator.Formation" mc:Ignorable="d" d:DesignWidth="300" Height="420"> - - + + + + + - - -