增加过度航点属性,通过颜色区分

加入起飞检测额外时间,默认4秒,加入参数控制时间和高度
加入自动计算航线碰撞检测间距参数
加入2D计算返航
This commit is contained in:
pxzleo 2024-01-16 21:43:44 +08:00
parent 17e4c8bd97
commit 2614dc2f59
7 changed files with 1285 additions and 1175 deletions

View File

@ -1,80 +1,83 @@
<Application x:Class="Plane.FormationCreator.App" <Application x:Class="Plane.FormationCreator.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Plane.FormationCreator" xmlns:local="clr-namespace:Plane.FormationCreator"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d1p1:Ignorable="d" d1p1:Ignorable="d"
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cnv="clr-namespace:Plane.Windows.Converters;assembly=Plane.Windows" xmlns:cnv="clr-namespace:Plane.Windows.Converters;assembly=Plane.Windows"
xmlns:lcnv="clr-namespace:Plane.FormationCreator.Converters" xmlns:lcnv="clr-namespace:Plane.FormationCreator.Converters"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
ShutdownMode="OnMainWindowClose"> ShutdownMode="OnMainWindowClose">
<Application.Resources> <Application.Resources>
<materialDesign:PackIcon x:Key="CheckIcon" <materialDesign:PackIcon x:Key="CheckIcon"
x:Shared="False" x:Shared="False"
Kind="Check" Kind="Check"
Foreground="#2196F3" /> Foreground="#2196F3" />
<materialDesign:PackIcon x:Key="CloseIcon" <materialDesign:PackIcon x:Key="CloseIcon"
x:Shared="False" x:Shared="False"
Kind="Close" Kind="Close"
Foreground="White" /> Foreground="White" />
<cnv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> <cnv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<cnv:BooleanToVisibilityConverter x:Key="InversiveBooleanToVisibilityConverter" <cnv:BooleanToVisibilityConverter x:Key="InversiveBooleanToVisibilityConverter"
False="Visible" False="Visible"
True="Collapsed" /> True="Collapsed" />
<cnv:NullableBooleanToVisibilityConverter x:Key="IsPausedToRunButtonVisibilityConverter" <cnv:NullableBooleanToVisibilityConverter x:Key="IsPausedToRunButtonVisibilityConverter"
False="Collapsed" False="Collapsed"
Null="Visible" Null="Visible"
True="Visible" /> True="Visible" />
<cnv:NullableBooleanToVisibilityConverter x:Key="IsPausedToPauseButtonVisibilityConverter" <cnv:NullableBooleanToVisibilityConverter x:Key="IsPausedToPauseButtonVisibilityConverter"
False="Visible" False="Visible"
Null="Collapsed" Null="Collapsed"
True="Collapsed" /> True="Collapsed" />
<cnv:InverseBooleanConverter x:Key="InverseBooleanConverter" /> <cnv:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<cnv:BooleanToStringConverter x:Key="ShowModifyTaskViewButtonContentConverter" <cnv:BooleanToStringConverter x:Key="ShowModifyTaskViewButtonContentConverter"
False="【飞行模式】" False="【飞行模式】"
True="【设计模式】" /> True="【设计模式】" />
<cnv:BooleanToStringConverter x:Key="MainColorConverterDes" <cnv:BooleanToStringConverter x:Key="MainColorConverterDes"
False="White" False="White"
True="DeepSkyBlue" /> True="DeepSkyBlue" />
<cnv:BooleanToStringConverter x:Key="MainFontSizeConverterDes" <cnv:BooleanToStringConverter x:Key="MainFontSizeConverterDes"
False="12" False="12"
True="14" /> True="14" />
<cnv:BooleanToStringConverter x:Key="MainColorConverterFly" <cnv:BooleanToStringConverter x:Key="MainColorConverterFly"
False="DeepSkyBlue" False="DeepSkyBlue"
True="White" /> True="White" />
<cnv:BooleanToStringConverter x:Key="MainFontSizeConverterFly" <cnv:BooleanToStringConverter x:Key="MainFontSizeConverterFly"
False="14" False="14"
True="12" /> True="12" />
<cnv:BooleanToStringConverter x:Key="Show2d3dButtonContentConverter" <cnv:BooleanToStringConverter x:Key="Show2d3dButtonContentConverter"
False="平面视图" False="平面视图"
True="立体视图" /> True="立体视图" />
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter" <cnv:BooleanToResourceConverter x:Key="CheckSignConverter"
FalseKey="CloseIcon" FalseKey="CloseIcon"
TrueKey="CheckIcon" /> TrueKey="CheckIcon" />
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter2" <cnv:BooleanToResourceConverter x:Key="CheckSignConverter2"
FalseKey="CloseIcon" FalseKey="CloseIcon"
TrueKey="CheckIcon" /> TrueKey="CheckIcon" />
<cnv:BooleanToStringConverter x:Key="ColorConverter" <cnv:BooleanToStringConverter x:Key="ColorConverter"
False="Red" False="Red"
True="Green" /> True="Green" />
<cnv:BooleanToStringConverter x:Key="SendConverter" <cnv:BooleanToStringConverter x:Key="SendConverter"
False="发送" False="发送"
True="关闭" /> True="关闭" />
<lcnv:HeartbeatCountToBrushConverter x:Key="HeartbeatCountToBrushConverter" /> <lcnv:HeartbeatCountToBrushConverter x:Key="HeartbeatCountToBrushConverter" />
<lcnv:AppModeToVisibilityConverter x:Key="AppModeToVisibilityConverter" /> <lcnv:AppModeToVisibilityConverter x:Key="AppModeToVisibilityConverter" />
<lcnv:FlightTaskStatusToFillConverter x:Key="FlightTaskStatusToFillConverter" /> <lcnv:FlightTaskStatusToFillConverter x:Key="FlightTaskStatusToFillConverter" />
<lcnv:FlightTaskIsSelectedToEffectConverter x:Key="FlightTaskIsSelectedToEffectConverter" />
</Application.Resources> <lcnv:FlightTaskStatusAndTransitionToFillConverter x:Key="FlightTaskStatusAndTransitionToFillConverter" />
<lcnv:FlightTaskIsSelectedToEffectConverter x:Key="FlightTaskIsSelectedToEffectConverter" />
</Application.Resources>
</Application> </Application>

View File

@ -1,179 +1,194 @@
using Plane.Copters; using Plane.Copters;
using Plane.Logging; using Plane.Logging;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.ServiceLocation;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Plane.FormationCreator.Formation namespace Plane.FormationCreator.Formation
{ {
public partial class FlightTask : ObservableObject public partial class FlightTask : ObservableObject
{ {
public FlightTask(FlightTaskType type) public FlightTask(FlightTaskType type)
{ {
TaskType = type; TaskType = type;
} }
private FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>(); private FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
private ILogger _logger = ServiceLocator.Current.GetInstance<ILogger>(); private ILogger _logger = ServiceLocator.Current.GetInstance<ILogger>();
private FlightTaskStatus _Status = FlightTaskStatus.Stop; private FlightTaskStatus _Status = FlightTaskStatus.Stop;
public FlightTaskStatus Status public FlightTaskStatus Status
{ {
get { return _Status; } get { return _Status; }
set { Set(nameof(Status), ref _Status, value); } set { Set(nameof(Status), ref _Status, value); }
} }
private FlightTaskType _TaskType; private FlightTaskType _TaskType;
public FlightTaskType TaskType public FlightTaskType TaskType
{ {
get { return _TaskType; } get { return _TaskType; }
set set
{ {
Set(nameof(TaskType), ref _TaskType, value); Set(nameof(TaskType), ref _TaskType, value);
RaisePropertyChanged(nameof(TaskTypeIndex)); RaisePropertyChanged(nameof(TaskTypeIndex));
RaisePropertyChanged(nameof(TaskCnName)); RaisePropertyChanged(nameof(TaskCnName));
} }
} }
/* /*
public int TaskTypeIndex public int TaskTypeIndex
{ {
get { return (int)TaskType; } get { return (int)TaskType; }
set set
{ {
TaskType = (FlightTaskType)value; TaskType = (FlightTaskType)value;
VerticalLift = false; VerticalLift = false;
if ( (value == (int)FlightTaskType.Loiter) || (value == (int)FlightTaskType.Circle) ) if ( (value == (int)FlightTaskType.Loiter) || (value == (int)FlightTaskType.Circle) )
{ {
VerticalLift = true; VerticalLift = true;
} }
} }
} }
*/ */
private string _TaskName = ""; private string _TaskName = "";
public string TaskCnName public string TaskCnName
{ {
get get
{ {
string name = ""; string name = "";
switch (TaskType) switch (TaskType)
{ {
case FlightTaskType.TakeOff: name = "起飞"; break; case FlightTaskType.TakeOff: name = "起飞"; break;
case FlightTaskType.FlyTo: name = _TaskName == "" ? "航点" : _TaskName; break; case FlightTaskType.FlyTo: name = _TaskName == "" ? "航点" : _TaskName; break;
case FlightTaskType.Land: name = "降落"; break; case FlightTaskType.Land: name = "降落"; break;
} }
//name = (TaskIndex + 1).ToString() + "." + name; //name = (TaskIndex + 1).ToString() + "." + name;
return name; return name;
} }
set { set {
Set(nameof(TaskCnName), ref _TaskName, value); Set(nameof(TaskCnName), ref _TaskName, value);
RaisePropertyChanged(nameof(TaskCnName)); RaisePropertyChanged(nameof(TaskCnName));
} }
} }
public int TaskTypeIndex public int TaskTypeIndex
{ {
get { get {
int index = 1; int index = 1;
switch (TaskType) switch (TaskType)
{ {
case FlightTaskType.TakeOff:index = 0; break; case FlightTaskType.TakeOff:index = 0; break;
case FlightTaskType.FlyTo: index = 1; break; case FlightTaskType.FlyTo: index = 1; break;
case FlightTaskType.Land: index = 2; break; case FlightTaskType.Land: index = 2; break;
} }
return index; return index;
} }
set set
{ {
switch (value) switch (value)
{ {
case 0: TaskType = FlightTaskType.TakeOff; break; case 0: TaskType = FlightTaskType.TakeOff; break;
case 1: TaskType = FlightTaskType.FlyTo; break; case 1: TaskType = FlightTaskType.FlyTo; break;
case 2: TaskType = FlightTaskType.Land; break; case 2: TaskType = FlightTaskType.Land; break;
} }
} }
} }
//task在所以任务中的index //task在所以任务中的index
public int TaskIndex public int TaskIndex
{ {
get get
{ {
return _flightTaskManager.Tasks.IndexOf(this); return _flightTaskManager.Tasks.IndexOf(this);
} }
} }
public int TaskNum public int TaskNum
{ {
get get
{ {
return TaskIndex + 1; return TaskIndex + 1;
} }
} }
private bool _IsSelected; private bool _IsTransition=false;
public bool IsSelected public bool IsTransition
{ {
get { return _IsSelected; } get { return _IsTransition; }
set { Set(nameof(IsSelected), ref _IsSelected, value); } set {
}
Set(nameof(IsTransition), ref _IsTransition, value);
// 右键单击任务,用于隐藏任务图标, added by ZJF if ((value)&& (TaskCnName == "航点"))
private bool _IsRightSelected; TaskCnName = "过度";
public bool IsRightSelected
{ }
get { return _IsRightSelected; } }
set { Set(nameof(IsRightSelected), ref _IsRightSelected, value); }
}
private bool _IsSelected;
public bool IsSelected
{
public List<FlightTaskSingleCopterInfo> SingleCopterInfos { get; set; } = new List<FlightTaskSingleCopterInfo>(); get { return _IsSelected; }
set { Set(nameof(IsSelected), ref _IsSelected, value); }
private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo; }
public FlightTaskSingleCopterInfo ModifyingSingleCopterInfo
{ // 右键单击任务,用于隐藏任务图标, added by ZJF
get { return _ModifyingSingleCopterInfo; } private bool _IsRightSelected;
set { Set(nameof(ModifyingSingleCopterInfo), ref _ModifyingSingleCopterInfo, value); } public bool IsRightSelected
} {
get { return _IsRightSelected; }
public async Task RunAsync() set { Set(nameof(IsRightSelected), ref _IsRightSelected, value); }
{ }
switch (TaskType)
{
case FlightTaskType.FlyTo:
await RunFlyToTaskAsync().ConfigureAwait(false);
break; public List<FlightTaskSingleCopterInfo> SingleCopterInfos { get; set; } = new List<FlightTaskSingleCopterInfo>();
case FlightTaskType.TakeOff:
//多架同时起飞 private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo;
//await MutilRunTakeOffTaskAsync().ConfigureAwait(false); public FlightTaskSingleCopterInfo ModifyingSingleCopterInfo
await NewMutilRunTakeOffTaskAsync().ConfigureAwait(false); {
break; get { return _ModifyingSingleCopterInfo; }
case FlightTaskType.Land: set { Set(nameof(ModifyingSingleCopterInfo), ref _ModifyingSingleCopterInfo, value); }
await MutilLandTaskAsync().ConfigureAwait(false); }
break;
default: public async Task RunAsync()
throw new InvalidOperationException(); {
} switch (TaskType)
} {
} case FlightTaskType.FlyTo:
await RunFlyToTaskAsync().ConfigureAwait(false);
public enum FlightTaskType break;
{ case FlightTaskType.TakeOff:
FlyTo = 0, //多架同时起飞
Land = 6, //await MutilRunTakeOffTaskAsync().ConfigureAwait(false);
TakeOff = 100 await NewMutilRunTakeOffTaskAsync().ConfigureAwait(false);
} break;
} case FlightTaskType.Land:
await MutilLandTaskAsync().ConfigureAwait(false);
break;
default:
throw new InvalidOperationException();
}
}
}
public enum FlightTaskType
{
FlyTo = 0,
Land = 6,
TakeOff = 100
}
}

View File

@ -375,9 +375,32 @@ namespace Plane.FormationCreator.Formation
set { Set(nameof(FC_defvel_down), ref _FC_defvel_down, value); } set { Set(nameof(FC_defvel_down), ref _FC_defvel_down, value); }
} }
//起飞检测额外时间默认4秒
private float _FC_takeoff_ct = 4000;
public float FC_takeoff_ct
{
get { return _FC_takeoff_ct; }
set { Set(nameof(FC_takeoff_ct), ref _FC_takeoff_ct, value); }
}
//起飞检测高度cm
private float _FC_takeoff_calt = 100;
public float FC_takeoff_calt
{
get { return _FC_takeoff_calt; }
set { Set(nameof(FC_takeoff_calt), ref _FC_takeoff_calt, value); }
}
//自动计算航线,碰撞检测间距,航线小于1.8米再检测前后距离是否大于_FC_SpaceBetween (cm)
private float _FC_SpaceBetween = 250;
public float FC_SpaceBetween
{
get { return _FC_SpaceBetween;}
set { Set(nameof(FC_SpaceBetween), ref _FC_SpaceBetween, value); }
}
private TasksStatus _TaskState = TasksStatus.Stop; private TasksStatus _TaskState = TasksStatus.Stop;
public TasksStatus TaskState public TasksStatus TaskState
@ -1196,7 +1219,7 @@ namespace Plane.FormationCreator.Formation
} }
} }
public void RestoreFlyToTask(bool staggerRoutes, int flytoTime, int loiterTime, string taskName, dynamic singleCopterInfos, bool isMeter) public void RestoreFlyToTask(bool staggerRoutes, int flytoTime, int loiterTime, string taskName, dynamic singleCopterInfos, bool isMeter, bool istrans)
{ {
var copters = _copterManager.Copters; var copters = _copterManager.Copters;
float tagalt = 15; float tagalt = 15;
@ -1206,7 +1229,7 @@ namespace Plane.FormationCreator.Formation
var nullableCenter = copters.GetCenter(); var nullableCenter = copters.GetCenter();
if (nullableCenter == null) return; if (nullableCenter == null) return;
var center = nullableCenter.Value; var center = nullableCenter.Value;
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes, FlytoTime = flytoTime, LoiterTime = loiterTime }; var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes, FlytoTime = flytoTime, LoiterTime = loiterTime,IsTransition= istrans };
if (taskName != null) newTask.TaskCnName = taskName; if (taskName != null) newTask.TaskCnName = taskName;
// TODO: 王海, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。 // TODO: 王海, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。
for (int i = 0; i < copters.Count; i++) for (int i = 0; i < copters.Count; i++)
@ -1341,6 +1364,7 @@ namespace Plane.FormationCreator.Formation
flytoTime = task.FlytoTime, flytoTime = task.FlytoTime,
loiterTime = task.LoiterTime, loiterTime = task.LoiterTime,
taskname = task.TaskCnName, taskname = task.TaskCnName,
istransition = task.IsTransition,
singleCopterInfos = task.SingleCopterInfos.Select(info => singleCopterInfos = task.SingleCopterInfos.Select(info =>
{ {
var offset = info.LatLngOffset; var offset = info.LatLngOffset;
@ -1570,7 +1594,10 @@ namespace Plane.FormationCreator.Formation
RestoreTakeOffTask((byte)task.takeoffTime, task.singleCopterInfos); RestoreTakeOffTask((byte)task.takeoffTime, task.singleCopterInfos);
break; break;
case FlightTaskType.FlyTo: case FlightTaskType.FlyTo:
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, (string)task.taskname, task.singleCopterInfos, isMeter); bool isTransition = false;
if (task.istransition != null)
isTransition = (bool)task.istransition;
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, (string)task.taskname, task.singleCopterInfos, isMeter, isTransition);
break; break;
case FlightTaskType.Land: case FlightTaskType.Land:
RestoreLandTask(task.singleCopterInfos); RestoreLandTask(task.singleCopterInfos);
@ -1772,20 +1799,28 @@ namespace Plane.FormationCreator.Formation
var curWaypoint = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter); var curWaypoint = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
double copter_maxDistance_up = nextWaypoint.TargetAlt; double copter_maxDistance_up = nextWaypoint.TargetAlt;
double copter_maxDistance_show = copter_maxDistance_up;
//减去测试起飞高度
if (FC_takeoff_ct > 0)
copter_maxDistance_up -= FC_takeoff_calt / 100.0f;
double time_up = getMinfligthtime((float)copter_maxDistance_up, acc_z, defvel_up, flytimetype); double time_up = getMinfligthtime((float)copter_maxDistance_up, acc_z, defvel_up, flytimetype);
double copter_tasktime = curWaypoint.TakeOffWaitTime + time_up; double copter_tasktime = curWaypoint.TakeOffWaitTime + time_up;
if (copter_tasktime > tasktime) if (copter_tasktime > tasktime)
{ {
tasktime = copter_tasktime; tasktime = copter_tasktime;
maxDistance_up = copter_maxDistance_up; maxDistance_up = copter_maxDistance_show;
copterName = copter.Name; copterName = copter.Name;
waittime = curWaypoint.TakeOffWaitTime; waittime = curWaypoint.TakeOffWaitTime;
upflytime = time_up; upflytime = time_up;
} }
} }
//加入起飞测试时间
tasktime += FC_takeoff_ct / 1000.0f;
Message.Show($"起飞任务{taskIndex + 1}参数:检测起飞高度:{Math.Round(FC_takeoff_calt / 100.0f, 2)}米,检测时间:{Math.Round( FC_takeoff_ct / 1000.0f, 2)}秒"
);
Message.Show($"起飞任务{taskIndex + 1}起飞高度:{Math.Round(maxDistance_up, 2)}米 " + Message.Show($"起飞任务{taskIndex + 1}起飞高度:{Math.Round(maxDistance_up, 2)}米 " +
$"最长耗时:{Math.Round(tasktime, 2)}秒({Math.Round(upflytime, 2)},{Math.Round(waittime, 2)}),编号:{copterName}" $"最长耗时:{Math.Round(tasktime, 2)}秒({Math.Round(upflytime, 2)},等待{Math.Round(waittime, 2)}),编号:{copterName}"
); );
if (settime) if (settime)
{ {
@ -2275,7 +2310,8 @@ namespace Plane.FormationCreator.Formation
//选中前一个任务,插入错层 //选中前一个任务,插入错层
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
//设置为过度航点
SelectedTask.IsTransition = true;
//第一个错层 //第一个错层
RouteRes = (FlightRoute.Vector3[])resarray[0]; RouteRes = (FlightRoute.Vector3[])resarray[0];
@ -2290,7 +2326,7 @@ namespace Plane.FormationCreator.Formation
//第二个错层 //第二个错层
AddTask(); AddTask();
SelectedTask.IsTransition = true;
RouteRes = (FlightRoute.Vector3[])resarray[1]; RouteRes = (FlightRoute.Vector3[])resarray[1];
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
@ -2357,6 +2393,7 @@ namespace Plane.FormationCreator.Formation
//设置随机数种子 //设置随机数种子
FlyVecFun.RandomSeed = (int)DateTime.Now.Ticks; FlyVecFun.RandomSeed = (int)DateTime.Now.Ticks;
Message.Show($"开始自动生成任务,种子数:{FlyVecFun.RandomSeed}"); Message.Show($"开始自动生成任务,种子数:{FlyVecFun.RandomSeed}");
FlyVecFun.SpaceBetweenSquare=FC_SpaceBetween* FC_SpaceBetween; //这是个平方值
//获取当前航点与前一航点所有经纬高 //获取当前航点与前一航点所有经纬高
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
@ -2422,6 +2459,7 @@ namespace Plane.FormationCreator.Formation
//插入错层航点 //插入错层航点
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2445,6 +2483,7 @@ namespace Plane.FormationCreator.Formation
//插入错层航点 //插入错层航点
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2464,6 +2503,7 @@ namespace Plane.FormationCreator.Formation
//选中前一个任务,插入错层 //选中前一个任务,插入错层
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
//第一个中间航点 //第一个中间航点
@ -2481,6 +2521,7 @@ namespace Plane.FormationCreator.Formation
//选中前一个任务,插入错层 //选中前一个任务,插入错层
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
//第一个中间航点 //第一个中间航点
@ -2494,6 +2535,7 @@ namespace Plane.FormationCreator.Formation
//第二个中间航点 //第二个中间航点
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2510,6 +2552,7 @@ namespace Plane.FormationCreator.Formation
//选中前一个任务,插入错层 //选中前一个任务,插入错层
SelectTask(SelectedTaskIndex - 1); SelectTask(SelectedTaskIndex - 1);
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
//第一个中间航点 //第一个中间航点
@ -2523,6 +2566,7 @@ namespace Plane.FormationCreator.Formation
//第二个中间航点 //第二个中间航点
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2534,6 +2578,7 @@ namespace Plane.FormationCreator.Formation
//第三个中间航点 //第三个中间航点
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2565,6 +2610,7 @@ namespace Plane.FormationCreator.Formation
//第一个中间航点 //第一个中间航点
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2575,6 +2621,7 @@ namespace Plane.FormationCreator.Formation
SetTaskFlytime(SelectedTaskIndex); SetTaskFlytime(SelectedTaskIndex);
//第二个中间航点 //第二个中间航点
AddTask(); AddTask();
SelectedTask.IsTransition = true;
SelectedTask.LoiterTime = 0; SelectedTask.LoiterTime = 0;
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -3026,7 +3073,10 @@ namespace Plane.FormationCreator.Formation
RestoreTakeOffTask((byte)task.takeoffTime, task.singleCopterInfos); RestoreTakeOffTask((byte)task.takeoffTime, task.singleCopterInfos);
break; break;
case FlightTaskType.FlyTo: case FlightTaskType.FlyTo:
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, (string)task.taskname, task.singleCopterInfos, isMeter); bool isTransition = false;
if (task.istransition != null)
isTransition = (bool)task.istransition;
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, (string)task.taskname, task.singleCopterInfos, isMeter, isTransition);
break; break;
case FlightTaskType.Land: case FlightTaskType.Land:
@ -3377,6 +3427,17 @@ namespace Plane.FormationCreator.Formation
if (readvalue != "" && float.TryParse(readvalue, out floatTemp)) if (readvalue != "" && float.TryParse(readvalue, out floatTemp))
FC_defvel_down = float.Parse(readvalue); FC_defvel_down = float.Parse(readvalue);
readvalue = inifilse.IniReadvalue("Default", "FC_takeoff_ct");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
FC_takeoff_ct = int.Parse(readvalue);
readvalue = inifilse.IniReadvalue("Default", "FC_takeoff_calt");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
FC_takeoff_calt = int.Parse(readvalue);
readvalue = inifilse.IniReadvalue("Default", "FC_spacbetween");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
FC_SpaceBetween = int.Parse(readvalue);
} }

View File

@ -167,6 +167,7 @@
<Compile Include="AppConfig.cs" /> <Compile Include="AppConfig.cs" />
<Compile Include="Converters\AppModeToVisibilityConverter.cs" /> <Compile Include="Converters\AppModeToVisibilityConverter.cs" />
<Compile Include="Converters\FlightTaskIsSelectedToEffectConverter.cs" /> <Compile Include="Converters\FlightTaskIsSelectedToEffectConverter.cs" />
<Compile Include="Converters\FlightTaskStatusAndTransitionToFillConverter.cs" />
<Compile Include="Converters\FlightTaskStatusToFillConverter.cs" /> <Compile Include="Converters\FlightTaskStatusToFillConverter.cs" />
<Compile Include="Converters\HeartbeatCountToBrushConverter.cs" /> <Compile Include="Converters\HeartbeatCountToBrushConverter.cs" />
<Compile Include="Formation\AppMode.cs" /> <Compile Include="Formation\AppMode.cs" />

View File

@ -950,7 +950,7 @@ namespace Plane.FormationCreator.ViewModels
})); }));
} }
} }
//2D计算不改变ID拉开层
private ICommand _OptimizeRouteCommandRet; private ICommand _OptimizeRouteCommandRet;
public ICommand OptimizeRouteCommandRet public ICommand OptimizeRouteCommandRet
{ {
@ -960,7 +960,7 @@ namespace Plane.FormationCreator.ViewModels
{ {
if (_copterManager.FC_VER_NO >= 3) if (_copterManager.FC_VER_NO >= 3)
//3D计算不改变ID可以错层 //3D计算不改变ID可以错层
_flightTaskManager.OptimizeRouteMeter(true, false, true); //采用米计算逻辑用3D生成不改变ID可拉开层(2D回起飞矩阵专用) _flightTaskManager.OptimizeRouteMeter(false, false, true); //采用米计算逻辑用3D生成不改变ID可拉开层(2D回起飞矩阵专用)
else else
_flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑用2D生成不改变ID不拉开层 _flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑用2D生成不改变ID不拉开层
@ -968,6 +968,23 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
//3D计算不改变ID不拉开层
private ICommand _OptimizeRouteCommandRet3D;
public ICommand OptimizeRouteCommandRet3D
{
get
{
return _OptimizeRouteCommandRet3D ?? (_OptimizeRouteCommandRet3D = new RelayCommand<int>(async =>
{
if (_copterManager.FC_VER_NO >= 3)
//3D计算不改变ID可以错层
_flightTaskManager.OptimizeRouteMeter(true, false, false); //采用米计算逻辑用3D生成不改变ID不拉开层(3D回起飞矩阵专用)
else
_flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑用2D生成不改变ID不拉开层
}));
}
}
private ICommand _OptimizeRouteCommand3D; private ICommand _OptimizeRouteCommand3D;
public ICommand OptimizeRouteCommand3D public ICommand OptimizeRouteCommand3D

File diff suppressed because it is too large Load Diff

View File

@ -1,224 +1,234 @@
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Plane.FormationCreator.Views" xmlns:local="clr-namespace:Plane.FormationCreator.Views"
xmlns:m="clr-namespace:Plane.FormationCreator.Formation" xmlns:m="clr-namespace:Plane.FormationCreator.Formation"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
x:Class="Plane.FormationCreator.Views.TaskBarView" x:Class="Plane.FormationCreator.Views.TaskBarView"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="156.968" d:DesignHeight="156.968"
d:DesignWidth="500"> d:DesignWidth="500">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button HorizontalAlignment="Left" Grid.Column="1" <Button HorizontalAlignment="Left" Grid.Column="1"
Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToRunButtonVisibilityConverter}}" Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToRunButtonVisibilityConverter}}"
Command="{Binding RunTasksCommand}"> Command="{Binding RunTasksCommand}">
<Button.Template> <Button.Template>
<ControlTemplate> <ControlTemplate>
<Grid Width="40" <Grid Width="40"
Height="40" Height="40"
Background="#00FFFFFF" Background="#00FFFFFF"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<ed:RegularPolygon Fill="MidnightBlue" <ed:RegularPolygon Fill="MidnightBlue"
InnerRadius="1" InnerRadius="1"
PointCount="3" PointCount="3"
Width="40" Width="40"
Height="40" Height="40"
Stretch="Fill" Stretch="Fill"
Stroke="Gray"> Stroke="Gray">
<ed:RegularPolygon.RenderTransform> <ed:RegularPolygon.RenderTransform>
<TransformGroup> <TransformGroup>
<ScaleTransform /> <ScaleTransform />
<SkewTransform /> <SkewTransform />
<RotateTransform Angle="90" /> <RotateTransform Angle="90" />
<TranslateTransform X="40" /> <TranslateTransform X="40" />
</TransformGroup> </TransformGroup>
</ed:RegularPolygon.RenderTransform> </ed:RegularPolygon.RenderTransform>
</ed:RegularPolygon> </ed:RegularPolygon>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Button HorizontalAlignment="Left" Grid.Column="1" <Button HorizontalAlignment="Left" Grid.Column="1"
Background="#00FFFFFF" Background="#00FFFFFF"
Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToPauseButtonVisibilityConverter}}" Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToPauseButtonVisibilityConverter}}"
Command="{Binding PauseTasksCommand}"> Command="{Binding PauseTasksCommand}">
<Button.Template> <Button.Template>
<ControlTemplate> <ControlTemplate>
<Grid Width="40" <Grid Width="40"
Height="40" Height="40"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Background="#00FFFFFF"> Background="#00FFFFFF">
<Rectangle Fill="Red" <Rectangle Fill="Red"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Width="15" Width="15"
Height="40" Height="40"
Stroke="Gray" /> Stroke="Gray" />
<Rectangle Fill="Red" <Rectangle Fill="Red"
Margin="0,0,3,0" Margin="0,0,3,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Width="15" Width="15"
Height="40" Height="40"
Stroke="Gray" /> Stroke="Gray" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<ItemsControl Grid.Column="0" <ItemsControl Grid.Column="0"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
ItemsSource="{Binding Tasks}" ItemsSource="{Binding Tasks}"
Name="TasksControl"> Name="TasksControl">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" /> <WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid x:Name="itemgrid"> <Grid x:Name="itemgrid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Background="{Binding Status, Converter={StaticResource FlightTaskStatusToFillConverter}}" <Border
Width="88" Width="88"
Height="19" Height="19"
BorderThickness="1" BorderThickness="1"
BorderBrush="Black" BorderBrush="Black"
Effect="{Binding IsSelected, Converter={StaticResource FlightTaskIsSelectedToEffectConverter}}" Effect="{Binding IsSelected, Converter={StaticResource FlightTaskIsSelectedToEffectConverter}}"
MouseLeftButtonDown="TaskLeftButtonDown" MouseLeftButtonDown="TaskLeftButtonDown"
MouseLeftButtonUp="SelectTask" MouseLeftButtonUp="SelectTask"
MouseRightButtonUp="HideTask"> MouseRightButtonUp="HideTask">
<Border.Background>
<WrapPanel VerticalAlignment="Center" <MultiBinding Converter="{StaticResource FlightTaskStatusAndTransitionToFillConverter}">
HorizontalAlignment="Center" > <Binding Path="Status" />
<TextBlock Width="auto" <Binding Path="IsTransition" />
FontSize="12" </MultiBinding>
Margin="0,0,2,0" </Border.Background>
Foreground="White"
Text="{Binding TaskNum}"/> <WrapPanel VerticalAlignment="Center"
<TextBlock Width="auto" HorizontalAlignment="Center" >
FontSize="12" <TextBlock Width="auto"
Foreground="White" FontSize="12"
Text="{Binding TaskCnName}"/> Margin="0,0,2,0"
</WrapPanel> Foreground="White"
</Border> Text="{Binding TaskNum}"/>
<TextBlock Width="auto"
</Grid> FontSize="12"
Foreground="White"
</DataTemplate> Text="{Binding TaskCnName}"/>
</ItemsControl.ItemTemplate> </WrapPanel>
</ItemsControl> </Border>
<Grid Grid.Column="2" > </Grid>
<Grid.RowDefinitions>
<RowDefinition/> </DataTemplate>
<RowDefinition Height="28"/> </ItemsControl.ItemTemplate>
</Grid.RowDefinitions> </ItemsControl>
<StackPanel Height="100" Background="#FF2D2D2D" VerticalAlignment="Bottom">
<Grid Grid.Column="2" >
<TextBlock x:Name="hintaddtask" Margin="0,25,0,0" Text="请添加或选择飞行任务" Visibility="Collapsed" FontSize="18" TextAlignment="Center"/> <Grid.RowDefinitions>
<RowDefinition/>
<TabControl x:Name="tasktabcont" <RowDefinition Height="28"/>
DataContext="{Binding FlightTaskManager.SelectedTask}" </Grid.RowDefinitions>
SelectedIndex="{Binding TaskTypeIndex,UpdateSourceTrigger=PropertyChanged}"> <StackPanel Height="120" Background="#FF2D2D2D" VerticalAlignment="Bottom">
<TextBlock x:Name="hintaddtask" Margin="0,25,0,0" Text="请添加或选择飞行任务" Visibility="Collapsed" FontSize="18" TextAlignment="Center"/>
<TabItem Header="1 起飞" x:Name="takeoffpage"> <TabControl x:Name="tasktabcont"
<Grid Margin="10"> DataContext="{Binding FlightTaskManager.SelectedTask}"
<Grid.ColumnDefinitions> SelectedIndex="{Binding TaskTypeIndex,UpdateSourceTrigger=PropertyChanged}">
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="起飞时间:" Margin="2" VerticalAlignment="Center"/> <TabItem Header="1 起飞" x:Name="takeoffpage">
<TextBox Grid.Column="1" Margin="2" VerticalAlignment="Center" <Grid Margin="10">
Text="{Binding TakeOffTime, UpdateSourceTrigger=PropertyChanged}" /> <Grid.ColumnDefinitions>
</Grid> <ColumnDefinition/>
<ColumnDefinition/>
</TabItem> </Grid.ColumnDefinitions>
<TabItem x:Name="flytopage" > <TextBlock Text="起飞时间:" Margin="2" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Margin="2" VerticalAlignment="Center"
<TabItem.Header> Text="{Binding TakeOffTime, UpdateSourceTrigger=PropertyChanged}" />
<Label x:Name="flytoLabel" Content="航点" HorizontalAlignment="Stretch" MouseLeftButtonDown="TaskLabelLeftButtonDown" </Grid>
ToolTip="双击修改名称" />
</TabItem.Header> </TabItem>
<TabItem x:Name="flytopage" >
<Grid Margin="10"> <TabItem.Header>
<Grid.RowDefinitions> <Label x:Name="flytoLabel" Content="航点" HorizontalAlignment="Stretch" MouseLeftButtonDown="TaskLabelLeftButtonDown"
<RowDefinition /> ToolTip="双击修改名称" />
<RowDefinition /> </TabItem.Header>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition /> <Grid Margin="10">
<ColumnDefinition /> <Grid.RowDefinitions>
</Grid.ColumnDefinitions> <RowDefinition />
<TextBlock Grid.Row="0" Margin="2" Text="飞行时间: " VerticalAlignment="Center" /> <RowDefinition />
<TextBox Grid.Column="1" Margin="2" VerticalAlignment="Center" <RowDefinition />
MaxLength="4" </Grid.RowDefinitions>
Text="{Binding FlytoTime, UpdateSourceTrigger=PropertyChanged}" /> <Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" Margin="2" Text="悬停时间: " VerticalAlignment="Center" /> <ColumnDefinition />
<TextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center" <ColumnDefinition />
MaxLength="4" </Grid.ColumnDefinitions>
Text="{Binding LoiterTime, UpdateSourceTrigger=PropertyChanged}" /> <TextBlock Grid.Row="0" Margin="2" Text="飞行时间: " VerticalAlignment="Center" />
</Grid> <TextBox Grid.Column="1" Margin="2" VerticalAlignment="Center"
</TabItem> MaxLength="4"
Text="{Binding FlytoTime, UpdateSourceTrigger=PropertyChanged}" />
<TabItem Header="降落" x:Name="landpage"> <TextBlock Grid.Row="1" Margin="2" Text="悬停时间: " VerticalAlignment="Center" />
<Grid Margin="10" > <TextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center"
<Grid.RowDefinitions> MaxLength="4"
<RowDefinition /> Text="{Binding LoiterTime, UpdateSourceTrigger=PropertyChanged}" />
</Grid.RowDefinitions> <CheckBox Grid.Row="2" Grid.Column="2" x:Name="tranBox" Content="过度航点" HorizontalAlignment="Left" Width="75.353"
<Grid.ColumnDefinitions> IsChecked="{Binding IsTransition}"/>
<ColumnDefinition />
<ColumnDefinition /> </Grid>
</Grid.ColumnDefinitions> </TabItem>
</Grid> <TabItem Header="降落" x:Name="landpage">
</TabItem> <Grid Margin="10" >
<Grid.RowDefinitions>
</TabControl> <RowDefinition />
</StackPanel> </Grid.RowDefinitions>
<StackPanel Grid.Row="1" <Grid.ColumnDefinitions>
Orientation="Horizontal" <ColumnDefinition />
VerticalAlignment="Bottom"> <ColumnDefinition />
<Button Content="添加" x:Name="addtaskbtn" </Grid.ColumnDefinitions>
Background="#232323"
Command="{Binding AddTaskCommand}" /> </Grid>
<Button Content="删除" </TabItem>
Background="#232323"
Command="{Binding DelTaskCommand}" /> </TabControl>
<Button Content="清除" </StackPanel>
Background="#232323" <StackPanel Grid.Row="1"
Command="{Binding ClearTasksCommand}" /> Orientation="Horizontal"
<Button Content="重置" VerticalAlignment="Bottom">
Background="#232323" <Button Content="添加" x:Name="addtaskbtn"
Command="{Binding ResetTasksCommand}" /> Background="#232323"
Command="{Binding AddTaskCommand}" />
<Button Content="更名" Visibility="Collapsed" <Button Content="删除"
Background="#232323" Background="#232323"
Command="{Binding renametaskCommand}" /> Command="{Binding DelTaskCommand}" />
<Button Content="原点" <Button Content="清除"
Background="#232323" Background="#232323"
Command="{Binding SetOriginCommand}" /> Command="{Binding ClearTasksCommand}" />
<Button Content="重置"
Background="#232323"
<!--<Button Content="保存" /> Command="{Binding ResetTasksCommand}" />
<Button Content="取消" />-->
</StackPanel> <Button Content="更名" Visibility="Collapsed"
</Grid> Background="#232323"
Command="{Binding renametaskCommand}" />
<Button Content="原点"
</Grid> Background="#232323"
</UserControl> Command="{Binding SetOriginCommand}" />
<!--<Button Content="保存" />
<Button Content="取消" />-->
</StackPanel>
</Grid>
</Grid>
</UserControl>