采用新的算法计算航线,可以全流程生成,起飞到图案(用3d生成),2d图案到2d图案(用2d错层生成),2d或3d回起飞矩阵(用3d,加2d拉开层,对应ID生成)

This commit is contained in:
pxzleo 2024-01-08 20:39:33 +08:00
parent ff37f4fa04
commit 9cfd7db051
10 changed files with 1888 additions and 1497 deletions

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio Version 17
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.FormationCreator", "Plane.FormationCreator\Plane.FormationCreator.csproj", "{61E2F31E-220A-4E3F-A64D-F7CDC2135008}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.FormationCreator", "Plane.FormationCreator\Plane.FormationCreator.csproj", "{61E2F31E-220A-4E3F-A64D-F7CDC2135008}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
@ -28,15 +28,9 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk.Contract_Shared
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRoute", "..\FlyTest\FlightRoute\FlightRoute.csproj", "{705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRoute", "..\FlyTest\FlightRoute\FlightRoute.csproj", "{705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}"
EndProject 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 EndProject
Global 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 GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
@ -128,4 +122,10 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection 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 EndGlobal

View File

@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Plane.FormationCreator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Plane.FormationCreator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup> </sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections> </configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup> </startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /> <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" /> <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.109.0" newVersion="1.0.109.0" /> <bindingRedirect oldVersion="0.0.0.0-1.0.109.0" newVersion="1.0.109.0"/>
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
@ -36,18 +36,18 @@
<entityFramework> <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters> <parameters>
<parameter value="mssqllocaldb" /> <parameter value="mssqllocaldb"/>
</parameters> </parameters>
</defaultConnectionFactory> </defaultConnectionFactory>
<providers> <providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
</providers> </providers>
</entityFramework> </entityFramework>
<system.data> <system.data>
<DbProviderFactories> <DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" /> <remove invariant="System.Data.SQLite.EF6"/>
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6"/>
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories> <remove invariant="System.Data.SQLite"/><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/></DbProviderFactories>
</system.data> </system.data>
</configuration> </configuration>

View File

@ -18,8 +18,9 @@ using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using Plane.CommunicationManagement;
using Plane.FormationCreator.Util; using Plane.FormationCreator.Util;
using Plane.CommunicationManagement;
namespace Plane.FormationCreator namespace Plane.FormationCreator
{ {

View File

@ -25,7 +25,7 @@ namespace Plane.FormationCreator.Formation
public class CopterCollection : ObservableCollection<ICopter> 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; public static DateTime Expire_SuperUser = Expire_App;
//允许飞行的飞机数量 //允许飞行的飞机数量

View File

@ -1,5 +1,4 @@
using Plane.Collections; using Plane.Copters;
using Plane.Copters;
using Plane.Geography; using Plane.Geography;
using Plane.Windows.Messages; using Plane.Windows.Messages;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
@ -10,14 +9,19 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Plane.CommunicationManagement;
using FlightRoute; using FlightRoute;
using FlightRouteV2;
using System.IO; using System.IO;
using System.Windows.Media.Media3D; using System.Windows.Media.Media3D;
using System.Diagnostics; using System.Diagnostics;
using Plane.FormationCreator.Util;
using System.Collections; using System.Collections;
using System.Windows; 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 namespace Plane.FormationCreator.Formation
{ {
@ -66,7 +70,7 @@ namespace Plane.FormationCreator.Formation
} }
} }
} }
if (selectedCopter!=null) if (selectedCopter != null)
selectedCopter.SetShowLEDFlashAsync(1, 100); selectedCopter.SetShowLEDFlashAsync(1, 100);
//if (selectedCopter != null) //if (selectedCopter != null)
@ -98,7 +102,7 @@ namespace Plane.FormationCreator.Formation
private string _MessageText="test"; private string _MessageText = "test";
public string MessageText public string MessageText
{ {
get { return _MessageText; } get { return _MessageText; }
@ -155,7 +159,7 @@ namespace Plane.FormationCreator.Formation
public int GetTaskTime(int TaskIndex) public int GetTaskTime(int TaskIndex)
{ {
int tasktime = 0; int tasktime = 0;
if ((Tasks==null)|| TaskIndex> Tasks.Count-1) return tasktime; if ((Tasks == null) || TaskIndex > Tasks.Count - 1) return tasktime;
FlightTask value = Tasks[TaskIndex]; FlightTask value = Tasks[TaskIndex];
switch (value.TaskType) switch (value.TaskType)
@ -165,12 +169,12 @@ namespace Plane.FormationCreator.Formation
//降落时间计算前一个任务目标高度最高的飞机的降落时间按1.5米/秒下降 //降落时间计算前一个任务目标高度最高的飞机的降落时间按1.5米/秒下降
case FlightTaskType.Land: case FlightTaskType.Land:
float maxalt = 0.0f; float maxalt = 0.0f;
for (int i = 0; i < Tasks[TaskIndex-1].SingleCopterInfos.Count; i++) for (int i = 0; i < Tasks[TaskIndex - 1].SingleCopterInfos.Count; i++)
{ {
var copterInfo = Tasks[TaskIndex - 1].SingleCopterInfos[i]; var copterInfo = Tasks[TaskIndex - 1].SingleCopterInfos[i];
if (maxalt < copterInfo.TargetAlt) maxalt = copterInfo.TargetAlt; if (maxalt < copterInfo.TargetAlt) maxalt = copterInfo.TargetAlt;
} }
tasktime =(int) Math.Round(maxalt / 1.5,0); tasktime = (int)Math.Round(maxalt / 1.5, 0);
break; break;
} }
return tasktime; return tasktime;
@ -188,7 +192,7 @@ namespace Plane.FormationCreator.Formation
{ {
if (_SelectedTask != value) if (_SelectedTask != value)
{ {
int starttime=0; int starttime = 0;
if (_SelectedTask != null) if (_SelectedTask != null)
{ {
@ -203,7 +207,7 @@ namespace Plane.FormationCreator.Formation
value.IsSelected = true; value.IsSelected = true;
value.IsRightSelected = true; value.IsRightSelected = true;
RightSelect(value); RightSelect(value);
if (TaskState== TasksStatus.Stop) if (TaskState == TasksStatus.Stop)
value.Status = FlightTaskStatus.Selected; value.Status = FlightTaskStatus.Selected;
for (int i = 0; i < value.TaskIndex; i++) for (int i = 0; i < value.TaskIndex; i++)
@ -240,7 +244,7 @@ namespace Plane.FormationCreator.Formation
} }
Message.ShowStatus($"选中 [{value.TaskIndex+1} {value.TaskCnName }] 从{str}开始执行,需{ GetTaskTime(value.TaskIndex)}秒,共{Tasks.Count}个任务"); Message.ShowStatus($"选中 [{value.TaskIndex + 1} {value.TaskCnName}] 从{str}开始执行,需{GetTaskTime(value.TaskIndex)}秒,共{Tasks.Count}个任务");
} }
else Message.ShowStatus($"无任务选中"); else Message.ShowStatus($"无任务选中");
@ -385,11 +389,11 @@ namespace Plane.FormationCreator.Formation
public event EventHandler<FlightTaskAddedEventArgs> TaskAdded; public event EventHandler<FlightTaskAddedEventArgs> TaskAdded;
public event EventHandler<FlightTaskDeledEventArgs> TaskDeled; public event EventHandler<FlightTaskDeledEventArgs> TaskDeled;
public void RaiseTaskDeled(FlightTask vDeledTask,int vTaskIndex) public void RaiseTaskDeled(FlightTask vDeledTask, int vTaskIndex)
{ {
try try
{ {
TaskDeled?.Invoke(this, new FlightTaskDeledEventArgs { DeledTask = vDeledTask, TaskIndex= vTaskIndex }); TaskDeled?.Invoke(this, new FlightTaskDeledEventArgs { DeledTask = vDeledTask, TaskIndex = vTaskIndex });
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -398,7 +402,7 @@ namespace Plane.FormationCreator.Formation
} }
public void RaiseTaskAdded(FlightTask lastTask ,FlightTask newTask) public void RaiseTaskAdded(FlightTask lastTask, FlightTask newTask)
{ {
try try
{ {
@ -451,7 +455,7 @@ namespace Plane.FormationCreator.Formation
if (Tasks.Count == 0) if (Tasks.Count == 0)
AddTakeOffTask(copters); AddTakeOffTask(copters);
var lastTask = Tasks.LastOrDefault(); var lastTask = Tasks.LastOrDefault();
if (SelectedTask !=null) if (SelectedTask != null)
lastTask = SelectedTask; lastTask = SelectedTask;
var nullableCenter = copters.GetCenter(); var nullableCenter = copters.GetCenter();
if (nullableCenter == null) return; if (nullableCenter == null) return;
@ -501,8 +505,8 @@ namespace Plane.FormationCreator.Formation
newTask.SingleCopterInfos.Add(newSingleCopterInfo); newTask.SingleCopterInfos.Add(newSingleCopterInfo);
} }
int selindex = SelectedTaskIndex+1; int selindex = SelectedTaskIndex + 1;
Tasks.Insert(SelectedTaskIndex+1, newTask); Tasks.Insert(SelectedTaskIndex + 1, newTask);
RaiseTaskAdded(lastTask, newTask); RaiseTaskAdded(lastTask, newTask);
SelectTask(selindex); SelectTask(selindex);
@ -613,7 +617,7 @@ namespace Plane.FormationCreator.Formation
// ResetTasks(); // ResetTasks();
SelectedTask.SingleCopterInfos.Clear(); SelectedTask.SingleCopterInfos.Clear();
Tasks.RemoveAt(SelectedTaskIndex); Tasks.RemoveAt(SelectedTaskIndex);
RaiseTaskDeled(SelectedTask,SelectedTaskIndex); RaiseTaskDeled(SelectedTask, SelectedTaskIndex);
SelectTask(selindex - 1); SelectTask(selindex - 1);
@ -631,7 +635,7 @@ namespace Plane.FormationCreator.Formation
Pause(); Pause();
int i = 0; int i = 0;
//等待暂停或2s超时(80*25ms) //等待暂停或2s超时(80*25ms)
while ((TaskState != TasksStatus.Paused)||(i>80)) while ((TaskState != TasksStatus.Paused) || (i > 80))
{ {
await Task.Delay(25).ConfigureAwait(false); await Task.Delay(25).ConfigureAwait(false);
i++; i++;
@ -643,8 +647,8 @@ namespace Plane.FormationCreator.Formation
CurrentRunningTask = null; CurrentRunningTask = null;
//起飞任务需要跳过 //起飞任务需要跳过
// if (CurrentRunningTaskIndex == 0) // if (CurrentRunningTaskIndex == 0)
// CurrentRunningTaskIndex++; // CurrentRunningTaskIndex++;
CurrentRunningTaskIndex++; CurrentRunningTaskIndex++;
await RunTaskAsync(); await RunTaskAsync();
} }
@ -654,10 +658,10 @@ namespace Plane.FormationCreator.Formation
public async Task FlyToTasks() public async Task FlyToTasks()
{ {
var copters = _copterManager.Copters; var copters = _copterManager.Copters;
if ((SelectedTaskIndex==-1) ||(TaskState == TasksStatus.Stop)) if ((SelectedTaskIndex == -1) || (TaskState == TasksStatus.Stop))
return; return;
int vSelectedTaskIndex= SelectedTaskIndex; int vSelectedTaskIndex = SelectedTaskIndex;
Pause(); Pause();
int i = 0; int i = 0;
@ -793,7 +797,7 @@ namespace Plane.FormationCreator.Formation
fc.SetProperties( fc.SetProperties(
latitude: Tasks[0].SingleCopterInfos[j].TargetLat, latitude: Tasks[0].SingleCopterInfos[j].TargetLat,
longitude: Tasks[0].SingleCopterInfos[j].TargetLng, longitude: Tasks[0].SingleCopterInfos[j].TargetLng,
altitude: 0 ); altitude: 0);
//设置灯光为默认颜色 //设置灯光为默认颜色
fc.LEDColor = CopterManager.CopterDefaultColor;// "000000"; fc.LEDColor = CopterManager.CopterDefaultColor;// "000000";
fc.LEDMode = 0; fc.LEDMode = 0;
@ -906,7 +910,7 @@ namespace Plane.FormationCreator.Formation
public void ImportDlltoVCopter(string filename) public void ImportDlltoVCopter(string filename)
{ {
Vector3[] vc; FlightRoute.Vector3[] vc;
@ -928,7 +932,7 @@ namespace Plane.FormationCreator.Formation
return; return;
} }
int id = 0; int id = 0;
foreach (Vector3 item in vc) foreach (FlightRoute.Vector3 item in vc)
{ {
Tuple<double, double> observationLatLng = null; Tuple<double, double> observationLatLng = null;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D( observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
@ -962,7 +966,7 @@ namespace Plane.FormationCreator.Formation
//导入外部航点 //导入外部航点
public void ImportDlltoTask(string filename) public void ImportDlltoTask(string filename)
{ {
Vector3[] vc; FlightRoute.Vector3[] vc;
string extname = Path.GetExtension(filename); string extname = Path.GetExtension(filename);
@ -976,18 +980,18 @@ namespace Plane.FormationCreator.Formation
} }
else return; else return;
if (vc.Count()!= _copterManager.Copters.Count) if (vc.Count() != _copterManager.Copters.Count)
{ {
Alert.Show($"飞机数量不匹配!导入{vc.Count()}架,实际{_copterManager.Copters.Count}"); Alert.Show($"飞机数量不匹配!导入{vc.Count()}架,实际{_copterManager.Copters.Count}");
return; return;
} }
var lastTask = Tasks.LastOrDefault(); var lastTask = Tasks.LastOrDefault();
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 1 }; var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 1 };
string vname=Path.GetFileNameWithoutExtension(filename); string vname = Path.GetFileNameWithoutExtension(filename);
if (vname.Length>6) vname= vname.Substring(0, 6); if (vname.Length > 6) vname = vname.Substring(0, 6);
newTask.TaskCnName = vname; newTask.TaskCnName = vname;
int id =0; int id = 0;
foreach (Vector3 item in vc) foreach (FlightRoute.Vector3 item in vc)
{ {
Tuple<double, double> observationLatLng = null; Tuple<double, double> observationLatLng = null;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D( observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
@ -1035,10 +1039,10 @@ namespace Plane.FormationCreator.Formation
{ {
//去掉前后的"[]" //去掉前后的"[]"
string taskName_temp = taskName.Substring(1); string taskName_temp = taskName.Substring(1);
taskName_temp= taskName_temp.Remove(taskName_temp.Length - 1); taskName_temp = taskName_temp.Remove(taskName_temp.Length - 1);
//新版用":"分割时间 //新版用":"分割时间
string[] words = taskName_temp.Split(':'); string[] words = taskName_temp.Split(':');
if (words.Count()==2) if (words.Count() == 2)
{ {
taskName = words[0]; taskName = words[0];
flytime = int.Parse(words[1]); flytime = int.Parse(words[1]);
@ -1148,7 +1152,7 @@ namespace Plane.FormationCreator.Formation
public void ImportBlenderFlyToTask(string blenderVectors) public void ImportBlenderFlyToTask(string blenderVectors)
{ {
string[] lineVectors = blenderVectors.Replace("\r\n","\n").Split('\n'); string[] lineVectors = blenderVectors.Replace("\r\n", "\n").Split('\n');
var lastTask = Tasks.LastOrDefault(); var lastTask = Tasks.LastOrDefault();
float alt = lastTask.SingleCopterInfos[0].TargetAlt; float alt = lastTask.SingleCopterInfos[0].TargetAlt;
@ -1203,7 +1207,7 @@ namespace Plane.FormationCreator.Formation
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 };
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++)
{ {
@ -1228,7 +1232,7 @@ namespace Plane.FormationCreator.Formation
var jsonArray = singleCopterInfoObj.ledInfos as Newtonsoft.Json.Linq.JArray; var jsonArray = singleCopterInfoObj.ledInfos as Newtonsoft.Json.Linq.JArray;
ObservableCollection<LEDInfo> ledList = jsonArray.ToObject<ObservableCollection<LEDInfo>>(); ObservableCollection<LEDInfo> ledList = jsonArray.ToObject<ObservableCollection<LEDInfo>>();
foreach(LEDInfo info in ledList) foreach (LEDInfo info in ledList)
{ {
newSingleCopterInfo.AddLEDInfo(info); newSingleCopterInfo.AddLEDInfo(info);
} }
@ -1270,7 +1274,7 @@ namespace Plane.FormationCreator.Formation
{ {
var singleCopterInfoObj = singleCopterInfos[i]; var singleCopterInfoObj = singleCopterInfos[i];
takeOffTask.SingleCopterInfos[i].TakeOffWaitTime = (ushort)singleCopterInfoObj.waitTime; takeOffTask.SingleCopterInfos[i].TakeOffWaitTime = (ushort)singleCopterInfoObj.waitTime;
if (singleCopterInfoObj.ledInfos!= null) if (singleCopterInfoObj.ledInfos != null)
{ {
var jsonArray = singleCopterInfoObj.ledInfos as Newtonsoft.Json.Linq.JArray; var jsonArray = singleCopterInfoObj.ledInfos as Newtonsoft.Json.Linq.JArray;
ObservableCollection<LEDInfo> ledList = jsonArray.ToObject<ObservableCollection<LEDInfo>>(); ObservableCollection<LEDInfo> ledList = jsonArray.ToObject<ObservableCollection<LEDInfo>>();
@ -1544,7 +1548,7 @@ namespace Plane.FormationCreator.Formation
//导入任务,可设置导入哪些步骤 //导入任务,可设置导入哪些步骤
public void ImportTasksindex(dynamic tasks, int startindex,int endindex, bool isMeter) public void ImportTasksindex(dynamic tasks, int startindex, int endindex, bool isMeter)
{ {
var copters = _copterManager.Copters; var copters = _copterManager.Copters;
@ -1552,10 +1556,10 @@ namespace Plane.FormationCreator.Formation
AddTakeOffTask(copters); AddTakeOffTask(copters);
int i =1; int i = 1;
foreach (var task in tasks) foreach (var task in tasks)
{ {
if ((i >= startindex)&& (i <= endindex)) if ((i >= startindex) && (i <= endindex))
{ {
switch ((FlightTaskType)task.type) switch ((FlightTaskType)task.type)
{ {
@ -1775,7 +1779,7 @@ namespace Plane.FormationCreator.Formation
{ {
tasktime = copter_tasktime; tasktime = copter_tasktime;
maxDistance_up = copter_maxDistance_up; maxDistance_up = copter_maxDistance_up;
copterName= copter.Name; copterName = copter.Name;
waittime = curWaypoint.TakeOffWaitTime; waittime = curWaypoint.TakeOffWaitTime;
upflytime = time_up; upflytime = time_up;
} }
@ -1872,7 +1876,7 @@ namespace Plane.FormationCreator.Formation
public void SetTaskFlytime(int taskIndex, bool settime = true) public void SetTaskFlytime(int taskIndex, bool settime = true)
{ {
if (taskIndex== 1) if (taskIndex == 1)
{ {
Message.Show($"2号任务是调整航点根据现场飞机摆放离设计位置偏差来调整"); Message.Show($"2号任务是调整航点根据现场飞机摆放离设计位置偏差来调整");
return; return;
@ -1888,7 +1892,7 @@ namespace Plane.FormationCreator.Formation
if (Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().IsChangeSpeed) if (Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().IsChangeSpeed)
{ {
_defvel_xy = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().LevelSpeed; _defvel_xy = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().LevelSpeed;
_defvel_up= Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().UpSpeed; _defvel_up = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().UpSpeed;
_defvel_down = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().DownSpeed; _defvel_down = Tasks[taskIndex].SingleCopterInfos.FirstOrDefault().DownSpeed;
} }
@ -1953,7 +1957,7 @@ namespace Plane.FormationCreator.Formation
} }
}//循环结束 }//循环结束
double time_xy = getMinfligthtime((float)maxDistance_xy, FC_acc_xy, FC_maxvel_xy,flytimetype); double time_xy = getMinfligthtime((float)maxDistance_xy, FC_acc_xy, FC_maxvel_xy, flytimetype);
double time_up = getMinfligthtime((float)maxDistance_up, FC_acc_z, FC_maxvel_up, flytimetype); double time_up = getMinfligthtime((float)maxDistance_up, FC_acc_z, FC_maxvel_up, flytimetype);
double time_down = getMinfligthtime((float)maxDistance_down, FC_acc_z, FC_maxvel_down, flytimetype); double time_down = getMinfligthtime((float)maxDistance_down, FC_acc_z, FC_maxvel_down, flytimetype);
double tasktime = time_xy; double tasktime = time_xy;
@ -2073,7 +2077,7 @@ namespace Plane.FormationCreator.Formation
return realflytime; return realflytime;
} }
float getMinfligthtime(float Distance, float fc_acc, float fc_maxspeed,int timetype) float getMinfligthtime(float Distance, float fc_acc, float fc_maxspeed, int timetype)
{ {
switch (timetype) switch (timetype)
{ {
@ -2107,12 +2111,123 @@ namespace Plane.FormationCreator.Formation
return t; return t;
} //计算优化线路,采用米计算 } //计算优化线路,采用米计算
/// <summary>
/// 自动生成航线2D和3D都用这个--------目前使用----------------
/// </summary> static public FlightRouteV2.Vector3[] GetFlyBase3d_V2(Point3D[] vPoints)
/// <param name="Is3d">3D计算</param> {
/// <param name="Ischange">是否改变线路的结束点顺序--返回起飞点航线不能交换</param>
public void OptimizeRouteMeter(bool Is3d=false,bool Ischange=true) 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> curTaskPoint = new Dictionary<int, Point3D>();
Dictionary<int, Point3D> prevTaskPoint = new Dictionary<int, Point3D>(); Dictionary<int, Point3D> prevTaskPoint = new Dictionary<int, Point3D>();
@ -2135,9 +2250,9 @@ namespace Plane.FormationCreator.Formation
if (Is3d) if (Is3d)
{ {
ArrayList resarray = Util.OptimizeRoute.Gen3DRoute(curTaskPoint.Values.ToArray(), prevTaskPoint.Values.ToArray()); 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++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2153,7 +2268,7 @@ namespace Plane.FormationCreator.Formation
else else
{ {
ArrayList resarray = Util.OptimizeRoute.Gen2DRoute(curTaskPoint.Values.ToArray(), prevTaskPoint.Values.ToArray(), Ischange); ArrayList resarray = Util.OptimizeRoute.Gen2DRoute(curTaskPoint.Values.ToArray(), prevTaskPoint.Values.ToArray(), Ischange);
Vector3[] RouteRes; FlightRoute.Vector3[] RouteRes;
//有错层需要插入2个错层任务 //有错层需要插入2个错层任务
if (resarray.Count == 3) if (resarray.Count == 3)
{ {
@ -2162,7 +2277,7 @@ namespace Plane.FormationCreator.Formation
AddTask(); AddTask();
//第一个错层 //第一个错层
RouteRes = (Vector3[])resarray[0]; RouteRes = (FlightRoute.Vector3[])resarray[0];
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2176,7 +2291,7 @@ namespace Plane.FormationCreator.Formation
//第二个错层 //第二个错层
AddTask(); AddTask();
RouteRes = (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++)
{ {
@ -2191,7 +2306,7 @@ namespace Plane.FormationCreator.Formation
SelectTask(SelectedTaskIndex + 1); SelectTask(SelectedTaskIndex + 1);
//最终 //最终
RouteRes = (Vector3[])resarray[2]; RouteRes = (FlightRoute.Vector3[])resarray[2];
for (int i = 0; i < _copterManager.Copters.Count; i++) for (int i = 0; i < _copterManager.Copters.Count; i++)
{ {
@ -2206,7 +2321,7 @@ namespace Plane.FormationCreator.Formation
else else
{ {
//最终 //最终
RouteRes = (Vector3[])resarray[0]; RouteRes = (FlightRoute.Vector3[])resarray[0];
for (int i = 0; i < _copterManager.Copters.Count; i++) 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); double sumlength = SumFlyLines(Tasks[SelectedTaskIndex - 1].SingleCopterInfos, SelectedTask.SingleCopterInfos);
Message.Show($"计算用时:{stopWatch.Elapsed.TotalMilliseconds}ms,总飞行距离{sumlength}米"); 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; 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);
}

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.FormationCreator</RootNamespace> <RootNamespace>Plane.FormationCreator</RootNamespace>
<AssemblyName>FGCS</AssemblyName> <AssemblyName>FGCS</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -447,9 +447,9 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\FlyCube\FlyBase\FlyBase.csproj"> <ProjectReference Include="..\..\FlyCube\FlightRouteV2\FlightRouteV2.csproj">
<Project>{626a9bfa-07de-4063-a178-360eb7057ed6}</Project> <Project>{626a9bfa-07de-4063-a178-360eb7057ed6}</Project>
<Name>FlyBase</Name> <Name>FlightRouteV2</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\FlyTest\FlightRoute\FlightRoute.csproj"> <ProjectReference Include="..\..\FlyTest\FlightRoute\FlightRoute.csproj">
<Project>{705aab55-ed7a-4856-8f7b-e7a78ed9e39a}</Project> <Project>{705aab55-ed7a-4856-8f7b-e7a78ed9e39a}</Project>
@ -514,6 +514,9 @@
<Install>false</Install> <Install>false</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <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')" /> <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"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -19,7 +19,7 @@ namespace Plane.FormationCreator.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
@ -47,8 +47,8 @@ namespace Plane.FormationCreator.Properties {
} }
/// <summary> /// <summary>
/// 使用此强类型资源类,为所有资源查找 /// 重写当前线程的 CurrentUICulture 属性,对
/// 重写当前线程的 CurrentUICulture 属性 /// 使用此强类型资源类的所有资源查找执行重写。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {

View File

@ -12,7 +12,7 @@ namespace Plane.FormationCreator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [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 { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -958,7 +958,12 @@ namespace Plane.FormationCreator.ViewModels
{ {
return _OptimizeRouteCommandRet ?? (_OptimizeRouteCommandRet = new RelayCommand<int>(async => 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不拉开层
})); }));
} }
} }