采用新的算法计算航线,可以全流程生成,起飞到图案(用3d生成),2d图案到2d图案(用2d错层生成),2d或3d回起飞矩阵(用3d,加2d拉开层,对应ID生成)
This commit is contained in:
parent
ff37f4fa04
commit
9cfd7db051
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34202.233
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.FormationCreator", "Plane.FormationCreator\Plane.FormationCreator.csproj", "{61E2F31E-220A-4E3F-A64D-F7CDC2135008}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
@ -28,15 +28,9 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk.Contract_Shared
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRoute", "..\FlyTest\FlightRoute\FlightRoute.csproj", "{705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyBase", "..\FlyCube\FlyBase\FlyBase.csproj", "{626A9BFA-07DE-4063-A178-360EB7057ED6}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRouteV2", "..\FlyCube\FlightRouteV2\FlightRouteV2.csproj", "{626A9BFA-07DE-4063-A178-360EB7057ED6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
..\Plane.Sdk3\PlaneGcsSdk_Shared\PlaneGcsSdk_Shared.projitems*{0111eb6e-72e3-499c-a3ba-022f5bbc4caf}*SharedItemsImports = 4
|
||||
..\Plane.Sdk3\PlaneGcsSdk_Shared\PlaneGcsSdk_Shared.projitems*{2be393dc-21a4-48b3-83fd-f21cbe8b038b}*SharedItemsImports = 13
|
||||
..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.projitems*{47141894-ece3-48ca-8dcf-ca751bda231e}*SharedItemsImports = 4
|
||||
..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.projitems*{695733d7-99ff-4707-8c89-474e949cadcb}*SharedItemsImports = 13
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
@ -128,4 +122,10 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
..\Plane.Sdk3\PlaneGcsSdk_Shared\PlaneGcsSdk_Shared.projitems*{0111eb6e-72e3-499c-a3ba-022f5bbc4caf}*SharedItemsImports = 4
|
||||
..\Plane.Sdk3\PlaneGcsSdk_Shared\PlaneGcsSdk_Shared.projitems*{2be393dc-21a4-48b3-83fd-f21cbe8b038b}*SharedItemsImports = 13
|
||||
..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.projitems*{47141894-ece3-48ca-8dcf-ca751bda231e}*SharedItemsImports = 4
|
||||
..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.projitems*{695733d7-99ff-4707-8c89-474e949cadcb}*SharedItemsImports = 13
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
@ -8,7 +8,7 @@
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
@ -18,8 +18,9 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Plane.CommunicationManagement;
|
||||
|
||||
using Plane.FormationCreator.Util;
|
||||
using Plane.CommunicationManagement;
|
||||
|
||||
namespace Plane.FormationCreator
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace Plane.FormationCreator.Formation
|
||||
public class CopterCollection : ObservableCollection<ICopter>
|
||||
{
|
||||
//软件过期时间---过期将无法添加飞机,并自动退出
|
||||
public static DateTime Expire_App = DateTime.Parse("2023-12-31");
|
||||
public static DateTime Expire_App = DateTime.Parse("2024-12-31");
|
||||
//超级用户过期时间--过期将无法使用内置超级用户登录
|
||||
public static DateTime Expire_SuperUser = Expire_App;
|
||||
//允许飞行的飞机数量
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Plane.Collections;
|
||||
using Plane.Copters;
|
||||
using Plane.Copters;
|
||||
using Plane.Geography;
|
||||
using Plane.Windows.Messages;
|
||||
using GalaSoft.MvvmLight;
|
||||
@ -10,14 +9,19 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Plane.CommunicationManagement;
|
||||
|
||||
using FlightRoute;
|
||||
using FlightRouteV2;
|
||||
using System.IO;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Diagnostics;
|
||||
using Plane.FormationCreator.Util;
|
||||
using System.Collections;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
using Plane.CommunicationManagement;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using MahApps.Metro.Controls;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
@ -906,7 +910,7 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
public void ImportDlltoVCopter(string filename)
|
||||
{
|
||||
Vector3[] vc;
|
||||
FlightRoute.Vector3[] vc;
|
||||
|
||||
|
||||
|
||||
@ -928,7 +932,7 @@ namespace Plane.FormationCreator.Formation
|
||||
return;
|
||||
}
|
||||
int id = 0;
|
||||
foreach (Vector3 item in vc)
|
||||
foreach (FlightRoute.Vector3 item in vc)
|
||||
{
|
||||
Tuple<double, double> observationLatLng = null;
|
||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||
@ -962,7 +966,7 @@ namespace Plane.FormationCreator.Formation
|
||||
//导入外部航点
|
||||
public void ImportDlltoTask(string filename)
|
||||
{
|
||||
Vector3[] vc;
|
||||
FlightRoute.Vector3[] vc;
|
||||
|
||||
|
||||
string extname = Path.GetExtension(filename);
|
||||
@ -987,7 +991,7 @@ namespace Plane.FormationCreator.Formation
|
||||
if (vname.Length > 6) vname = vname.Substring(0, 6);
|
||||
newTask.TaskCnName = vname;
|
||||
int id = 0;
|
||||
foreach (Vector3 item in vc)
|
||||
foreach (FlightRoute.Vector3 item in vc)
|
||||
{
|
||||
Tuple<double, double> observationLatLng = null;
|
||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||
@ -2107,12 +2111,123 @@ namespace Plane.FormationCreator.Formation
|
||||
return t;
|
||||
} //计算优化线路,采用米计算
|
||||
|
||||
/// <summary>
|
||||
/// 自动生成航线2D和3D都用这个--------目前使用----------------
|
||||
/// </summary>
|
||||
/// <param name="Is3d">3D计算</param>
|
||||
/// <param name="Ischange">是否改变线路的结束点顺序--返回起飞点航线不能交换</param>
|
||||
public void OptimizeRouteMeter(bool Is3d=false,bool Ischange=true)
|
||||
|
||||
|
||||
static public FlightRouteV2.Vector3[] GetFlyBase3d_V2(Point3D[] vPoints)
|
||||
{
|
||||
|
||||
FlightRouteV2.Vector3[] ret3d = new FlightRouteV2.Vector3[vPoints.Count()];
|
||||
for (int i = 0; i < vPoints.Count(); i++)
|
||||
{
|
||||
ret3d[i].X = vPoints[i].X;
|
||||
ret3d[i].Y = vPoints[i].Y;
|
||||
ret3d[i].Z = vPoints[i].Z;
|
||||
}
|
||||
return ret3d;
|
||||
|
||||
}
|
||||
|
||||
//计算中状态信息
|
||||
public void Routecallback(string str)
|
||||
{
|
||||
// Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Message.Show(str);
|
||||
});
|
||||
}
|
||||
//计算进度
|
||||
public void Cronograma(int val)
|
||||
{
|
||||
// Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
ServiceLocator.Current.GetInstance<MainViewModel>().SysStatusText = "计算进度:"+val+"%";
|
||||
});
|
||||
}
|
||||
|
||||
//新开线程异步调用ContactABOut并等待返回
|
||||
public async Task<FlightRouteV2.Vector3[]> ContactABOutAsync(FlightRouteV2.Vector3[] aVecs, FlightRouteV2.Vector3[] bVecs)
|
||||
{
|
||||
FlightRouteV2.Vector3[] ret=null;
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
ret = FlyVecFun.ContactABOut(aVecs, bVecs, Routecallback);
|
||||
});
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
Message.Show("目标计算失败");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
//新开线程异步调用ABypassB并等待返回
|
||||
public async Task<(List<List<FlightRouteV2.Vector3>>,bool)> ABypassBAsync(FlightRouteV2.Vector3[] aVecs, FlightRouteV2.Vector3[] bVecs)
|
||||
{
|
||||
List<List<FlightRouteV2.Vector3>> ret = null;
|
||||
bool isPasstmp = false;
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
ret = FlyVecFun.ABypassB(aVecs, bVecs, Routecallback, Cronograma, out isPasstmp);
|
||||
});
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
Message.Show("绕行计算失败");
|
||||
}
|
||||
return (ret,isPasstmp);
|
||||
|
||||
}
|
||||
|
||||
public async Task<FlightRouteV2.Vector3[]> NormalPullsync(FlightRouteV2.Vector3[] aVecs, FlightRouteV2.Vector3[] bVecs)
|
||||
{
|
||||
|
||||
FlightRouteV2.Vector3[] ret = null;
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
ret = FlyVecFun.NormalPull(aVecs, bVecs, Routecallback);
|
||||
});
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
Message.Show("绕行计算失败");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<List<List<FlightRouteV2.Vector3>>> CollisionLayersync(FlightRouteV2.Vector3[] aVecs, FlightRouteV2.Vector3[] bVecs,string taskname_a,string taskname_b)
|
||||
{
|
||||
List<List<FlightRouteV2.Vector3>> ret = null;
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
ret = FlyVecFun.CollisionLayer(aVecs, bVecs, taskname_a, taskname_b, Routecallback);
|
||||
});
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
Message.Show("2D计算失败");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void OptimizeRouteMeterV1(bool Is3d = false, bool Ischange = true, bool Is3dstagger = false)
|
||||
{
|
||||
Dictionary<int, Point3D> curTaskPoint = new Dictionary<int, Point3D>();
|
||||
Dictionary<int, Point3D> prevTaskPoint = new Dictionary<int, Point3D>();
|
||||
@ -2135,9 +2250,9 @@ namespace Plane.FormationCreator.Formation
|
||||
if (Is3d)
|
||||
{
|
||||
ArrayList resarray = Util.OptimizeRoute.Gen3DRoute(curTaskPoint.Values.ToArray(), prevTaskPoint.Values.ToArray());
|
||||
Vector3[] RouteRes;
|
||||
FlightRoute.Vector3[] RouteRes;
|
||||
//最终
|
||||
RouteRes = (Vector3[])resarray[0];
|
||||
RouteRes = (FlightRoute.Vector3[])resarray[0];
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
@ -2153,7 +2268,7 @@ namespace Plane.FormationCreator.Formation
|
||||
else
|
||||
{
|
||||
ArrayList resarray = Util.OptimizeRoute.Gen2DRoute(curTaskPoint.Values.ToArray(), prevTaskPoint.Values.ToArray(), Ischange);
|
||||
Vector3[] RouteRes;
|
||||
FlightRoute.Vector3[] RouteRes;
|
||||
//有错层,需要插入2个错层任务
|
||||
if (resarray.Count == 3)
|
||||
{
|
||||
@ -2162,7 +2277,7 @@ namespace Plane.FormationCreator.Formation
|
||||
AddTask();
|
||||
|
||||
//第一个错层
|
||||
RouteRes = (Vector3[])resarray[0];
|
||||
RouteRes = (FlightRoute.Vector3[])resarray[0];
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
@ -2176,7 +2291,7 @@ namespace Plane.FormationCreator.Formation
|
||||
//第二个错层
|
||||
AddTask();
|
||||
|
||||
RouteRes = (Vector3[])resarray[1];
|
||||
RouteRes = (FlightRoute.Vector3[])resarray[1];
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
@ -2191,7 +2306,7 @@ namespace Plane.FormationCreator.Formation
|
||||
SelectTask(SelectedTaskIndex + 1);
|
||||
|
||||
//最终
|
||||
RouteRes = (Vector3[])resarray[2];
|
||||
RouteRes = (FlightRoute.Vector3[])resarray[2];
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
@ -2206,7 +2321,7 @@ namespace Plane.FormationCreator.Formation
|
||||
else
|
||||
{
|
||||
//最终
|
||||
RouteRes = (Vector3[])resarray[0];
|
||||
RouteRes = (FlightRoute.Vector3[])resarray[0];
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
@ -2223,10 +2338,277 @@ namespace Plane.FormationCreator.Formation
|
||||
double sumlength = SumFlyLines(Tasks[SelectedTaskIndex - 1].SingleCopterInfos, SelectedTask.SingleCopterInfos);
|
||||
|
||||
Message.Show($"计算用时:{stopWatch.Elapsed.TotalMilliseconds}ms,总飞行距离{sumlength}米");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动生成航线2D和3D都用这个-------V2版使用新的碰撞检测和绕行,用flybase.cs库,只用于新版固件--------------
|
||||
/// </summary>
|
||||
/// <param name="Is3d">3D计算</param>
|
||||
/// <param name="Ischange">是否改变线路的结束点顺序--返回起飞点航线不能交换</param>
|
||||
/// <param name="Is3dstagger">3D是否自动插入拉开层,用于2D画面回起飞矩阵,拉开2D画面</param>
|
||||
public async Task OptimizeRouteMeterV2(bool Is3d = false, bool Ischange = true,bool Is3dstagger=false)
|
||||
{
|
||||
Dictionary<int, Point3D> curTaskPoint = new Dictionary<int, Point3D>();
|
||||
Dictionary<int, Point3D> prevTaskPoint = new Dictionary<int, Point3D>();
|
||||
var stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
|
||||
//设置随机数种子
|
||||
FlyVecFun.RandomSeed = (int)DateTime.Now.Ticks;
|
||||
Message.Show($"开始自动生成任务,种子数:{FlyVecFun.RandomSeed}");
|
||||
|
||||
//获取当前航点与前一航点所有经纬高
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
//当前任务
|
||||
var curinfo = SelectedTask.SingleCopterInfos[i];
|
||||
Point3D curLoc = new Point3D(curinfo.X * 100, curinfo.TargetAlt * 100, curinfo.Y * 100);
|
||||
curTaskPoint.Add(i, curLoc);
|
||||
|
||||
//前一任务
|
||||
var prevInfo = Tasks[SelectedTaskIndex - 1].SingleCopterInfos[i];
|
||||
Point3D prevLoc = new Point3D(prevInfo.X * 100, prevInfo.TargetAlt * 100, prevInfo.Y * 100);
|
||||
prevTaskPoint.Add(i, prevLoc);
|
||||
}
|
||||
string taskname_a = SelectedTaskIndex.ToString() + Tasks[SelectedTaskIndex - 1].TaskCnName;
|
||||
string taskname_b = (SelectedTaskIndex+1).ToString()+SelectedTask.TaskCnName;
|
||||
|
||||
|
||||
FlightRouteV2.Vector3[] aVecs = GetFlyBase3d_V2(prevTaskPoint.Values.ToArray());
|
||||
FlightRouteV2.Vector3[] bVecs = GetFlyBase3d_V2(curTaskPoint.Values.ToArray());
|
||||
|
||||
|
||||
List<FlightRouteV2.Vector3> firstMiddleVecs;
|
||||
List<FlightRouteV2.Vector3> middleVecs;
|
||||
List<FlightRouteV2.Vector3> lastMiddleVecs;
|
||||
|
||||
//如果是true表示目标图案可以修改ID,false就是按ID飞行
|
||||
if (Ischange)
|
||||
{
|
||||
//通过交换改变目标航点的对应关系,减少碰撞
|
||||
bVecs = await ContactABOutAsync(aVecs, bVecs);
|
||||
//得到当前航点的名称
|
||||
string taskname = SelectedTask.TaskCnName;
|
||||
int loitertime=SelectedTask.LoiterTime;
|
||||
DelSelectedTask();
|
||||
AddTask();
|
||||
SelectedTask.TaskCnName = taskname;
|
||||
SelectedTask.LoiterTime = loitertime;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = bVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = bVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)bVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
}
|
||||
|
||||
|
||||
if (Is3d)
|
||||
{
|
||||
bool isPass = false;
|
||||
var result= await ABypassBAsync(aVecs, bVecs);
|
||||
List<List<FlightRouteV2.Vector3>> flyret = result.Item1;
|
||||
isPass= result.Item2;
|
||||
if ((flyret.Count == 0)&&(!isPass))
|
||||
{
|
||||
FlightRouteV2.Vector3[] cVecs=null;
|
||||
if (Is3dstagger)
|
||||
{
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}无法直接生成3D航线,尝试拉开画面");
|
||||
cVecs = await NormalPullsync(aVecs, bVecs);
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}后插入拉开层...");
|
||||
//插入错层航点
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = cVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = cVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)cVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
//选到最后一个航点
|
||||
SelectTask(SelectedTaskIndex + 1);
|
||||
var result1= await ABypassBAsync(cVecs, bVecs);
|
||||
flyret = result1.Item1;
|
||||
isPass = result1.Item2;
|
||||
}
|
||||
if ((flyret.Count == 0) && (!isPass))
|
||||
{
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}无法生成3D航线");
|
||||
return;
|
||||
}
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}后插入新层...");
|
||||
//插入错层航点
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = cVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = cVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)cVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
//选到最后一个航点
|
||||
SelectTask(SelectedTaskIndex + 1);
|
||||
}
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}需要再插入{flyret.Count}个中间层");
|
||||
switch (flyret.Count)
|
||||
{
|
||||
case 1:
|
||||
middleVecs = flyret[0];
|
||||
//选中前一个任务,插入错层
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
//第一个中间航点
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = middleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = middleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)middleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
break;
|
||||
case 2:
|
||||
firstMiddleVecs = flyret[0];
|
||||
middleVecs = flyret[1];
|
||||
//选中前一个任务,插入错层
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
//第一个中间航点
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = firstMiddleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = firstMiddleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)firstMiddleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
|
||||
//第二个中间航点
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = middleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = middleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)middleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
break;
|
||||
case 3:
|
||||
firstMiddleVecs = flyret[0];
|
||||
middleVecs = flyret[1];
|
||||
lastMiddleVecs = flyret[2];
|
||||
//选中前一个任务,插入错层
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
//第一个中间航点
|
||||
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = firstMiddleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = firstMiddleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)firstMiddleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
|
||||
//第二个中间航点
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = middleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = middleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)middleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
|
||||
//第三个中间航点
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = lastMiddleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = lastMiddleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)lastMiddleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
//选中最后一个任务
|
||||
SelectTask(SelectedTaskIndex + 1);
|
||||
//计算最后一个任务时间
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
|
||||
}else //计算2D错层--固定两个中间航点
|
||||
{
|
||||
List<List<FlightRouteV2.Vector3>> flyret = await CollisionLayersync(aVecs, bVecs, taskname_a, taskname_b);
|
||||
if (flyret.Count == 0)
|
||||
{
|
||||
Message.Show($"任务{SelectedTaskIndex + 1}无法生成2D航线");
|
||||
return;
|
||||
}
|
||||
firstMiddleVecs = flyret[0];
|
||||
lastMiddleVecs = flyret[1];
|
||||
|
||||
SelectTask(SelectedTaskIndex - 1);
|
||||
|
||||
//第一个中间航点
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = firstMiddleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = firstMiddleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)firstMiddleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
//第二个中间航点
|
||||
AddTask();
|
||||
SelectedTask.LoiterTime = 0;
|
||||
for (int i = 0; i < _copterManager.Copters.Count; i++)
|
||||
{
|
||||
SelectedTask.SingleCopterInfos[i].X = lastMiddleVecs[i].X / 100;
|
||||
SelectedTask.SingleCopterInfos[i].Y = lastMiddleVecs[i].Z / 100;
|
||||
SelectedTask.SingleCopterInfos[i].TargetAlt = (float)lastMiddleVecs[i].Y / 100;
|
||||
}
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
//选中最后一个任务
|
||||
SelectTask(SelectedTaskIndex + 1);
|
||||
//计算最后一个任务时间
|
||||
SetTaskFlytime(SelectedTaskIndex);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
Message.Show($"计算用时:{Math.Round(stopWatch.Elapsed.TotalMilliseconds/1000,2)}秒");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动生成航线2D和3D都用这个--------目前使用----------------
|
||||
/// </summary>
|
||||
/// <param name="Is3d">3D计算</param>
|
||||
/// <param name="Ischange">是否改变线路的结束点顺序--返回起飞点航线不能交换</param>
|
||||
/// 按个按钮,计算航线2D,计算航线3D,计算返航
|
||||
/// 老版本只用2D计算,计算返航要ID对应,Ischange=false
|
||||
public void OptimizeRouteMeter(bool Is3d=false,bool Ischange=true, bool Is3dstagger = false)
|
||||
{
|
||||
if (_copterManager.FC_VER_NO >= 3)
|
||||
//新固件使用V2版
|
||||
OptimizeRouteMeterV2(Is3d, Ischange, Is3dstagger);
|
||||
else
|
||||
OptimizeRouteMeterV1(Is3d, Ischange, Is3dstagger);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.FormationCreator</RootNamespace>
|
||||
<AssemblyName>FGCS</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -447,9 +447,9 @@
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\FlyCube\FlyBase\FlyBase.csproj">
|
||||
<ProjectReference Include="..\..\FlyCube\FlightRouteV2\FlightRouteV2.csproj">
|
||||
<Project>{626a9bfa-07de-4063-a178-360eb7057ed6}</Project>
|
||||
<Name>FlyBase</Name>
|
||||
<Name>FlightRouteV2</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\FlyTest\FlightRoute\FlightRoute.csproj">
|
||||
<Project>{705aab55-ed7a-4856-8f7b-e7a78ed9e39a}</Project>
|
||||
@ -514,6 +514,9 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -19,7 +19,7 @@ namespace Plane.FormationCreator.Properties {
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
@ -47,8 +47,8 @@ namespace Plane.FormationCreator.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
|
@ -12,7 +12,7 @@ namespace Plane.FormationCreator.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
@ -958,7 +958,12 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _OptimizeRouteCommandRet ?? (_OptimizeRouteCommandRet = new RelayCommand<int>(async =>
|
||||
{
|
||||
_flightTaskManager.OptimizeRouteMeter(false,false); //采用米计算逻辑和OptimizeRouteNew一样
|
||||
if (_copterManager.FC_VER_NO >= 3)
|
||||
//3D计算,不改变ID,可以错层
|
||||
_flightTaskManager.OptimizeRouteMeter(true, false, true); //采用米计算逻辑,用3D生成,不改变ID,可拉开层(2D回起飞矩阵专用)
|
||||
else
|
||||
_flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑,用2D生成,不改变ID,不拉开层
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user