采用新的算法计算航线,可以全流程生成,起飞到图案(用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
# 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

View File

@ -1,53 +1,53 @@
<?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">
<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>
<!-- 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" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.109.0" newVersion="1.0.109.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<Plane.FormationCreator.Properties.Settings>
<setting name="IPs" serializeAs="String">
<value>192.168.1.50</value>
</setting>
</Plane.FormationCreator.Properties.Settings>
</userSettings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<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" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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" />
<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>
</configuration>
<?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">
<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>
<!-- 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"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.109.0" newVersion="1.0.109.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<Plane.FormationCreator.Properties.Settings>
<setting name="IPs" serializeAs="String">
<value>192.168.1.50</value>
</setting>
</Plane.FormationCreator.Properties.Settings>
</userSettings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<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"/>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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"/>
<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>
</configuration>

View File

@ -1,312 +1,313 @@
using Plane.Communication;
using Plane.Copters;
using Plane.FormationCreator.Formation;
using Plane.Logging;
using Plane.Windows;
using Plane.Windows.Messages;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Plane.CommunicationManagement;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
VersionControl.GetSettingFromIni();
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
ServiceLocatorConfigurer.Instance.Configure();
_logger = ServiceLocator.Current.GetInstance<ILogger>();
_copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
_formationController = ServiceLocator.Current.GetInstance<FormationController>();
_mapManager = ServiceLocator.Current.GetInstance<MapManager>();
AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
{
var simpleName = new AssemblyName(e.Name).Name;
if (simpleName.EndsWith(".resources"))
{
return null;
}
return LoadAssembly(simpleName);
};
this.DispatcherUnhandledException += (s, e) =>
{
_logger.Log(e.Exception);
// await _formationController.AllStop();
TcpServerConnectionManager.Instance.StopListening();
UdpServerConnectionManager.Instance.StopReceiving();
};
this.Exit += (s, e) =>
{
try
{
// TcpServerConnectionManager.Instance.StopListening();
UdpServerConnectionManager.Instance.StopReceiving();
}
catch (Exception ex)
{
// RaiseExceptionThrown(ex);
}
};
//new Test().Prepare().Run();
}
private ILogger _logger;
private CopterManager _copterManager;
private FormationController _formationController;
private MapManager _mapManager;
private Assembly LoadAssembly(string simpleName)
{
String resourceName = this.GetType().Namespace + ".AssemblyLoadingAndReflection." + simpleName + ".dll";
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var md = Resources.MergedDictionaries;
// md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Plane.Windows.Messages;component/Styles.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Styles/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Styles.xaml") });
/*
new UpdateChecker("http://dl.Plane.com/tools/ver.php?app=FormationCreator", _logger)
.CheckAsync(ver =>
{
var currentVersion = this.GetType().Assembly.GetName().Version;
if (currentVersion < ver
&& Alert.Show("检测到新版本,请下载。", "更新提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
Process.Start("http://dl.Plane.com/tools/FormationCreatorSetup.exe");
this.Shutdown();
}
});
*/
System.Windows.FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false;
MainWindow = new MainWindow();
MainWindow.Show();
try
{
/* by panxu tcp 使 --使TCP监听在自动获取IP的情况下
TcpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
if (!TcpServerConnectionManager.Instance.StartListening())
{
Alert.Show("网络连接不正常,无法连接飞机。");
return;
}
*/
if (VersionControl.ConType == 1)
{
CommModuleManager.Instance.UseTransModule = false;
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
{
_logger.Log(e1.Exception);
};
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
UdpServerConnectionManager.Instance.StartReceiving();
}
else
{
CommModuleManager.Instance.UseTransModule = true;
//初始化地面站连接
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
CommModuleManager.Instance.Connect();
}
}
catch (Exception ex)
{
Alert.Show("网络连接不正常,无法连接飞机。");
return;
}
}
protected override void OnExit(ExitEventArgs e)
{
CommModuleManager.Instance.CloseConnection();
base.OnExit(e);
}
private void Copter_TextReceived(object sender, MessageCreatedEventArgs e)
{
_logger.Log(e.Message );
}
//wifi模式添加飞机
private async Task AddOrUpdateCopter(string ip, IConnection Connection)
{
var copters = _copterManager.Copters;
var copterStatus = _copterManager.CopterStatus;
string[] iparr = ip.Split('.');
string vIPID = String.Format("{0:D3}", int.Parse(iparr[2])) + String.Format("{0:D3}", int.Parse(iparr[3]));
var copter = copters.FirstOrDefault(c => c.Id == vIPID);
if (copter == null)
{
if (!_copterManager.EnAddCopter_Real())
{
UdpServerConnectionManager.Instance.DeleteConnections(ip);
}
else
{
await Dispatcher.BeginInvoke(new Action(() =>
{
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
{
Id = vIPID,
Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1)
};
int _index;
_index = copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
}));
}
}
else
{
copter.Connection = Connection;
}
if (copter!=null)
await copter.ConnectAsync().ConfigureAwait(false);
}
private async void ConnectionManager_ConnectionEstablished(object sender, ConnectionEstablishedEventArgs e)
{
await AddOrUpdateCopter(e.RemoteAddress, e.Connection);
}
private async void CommtionReceivedCopterInfo(object sender, CommunicationReceiveCopterInfoEventArgs e)
{
await UpdateCommCopterInfo(e.Id, e.Package, e.CommModuleVersion);
//await TaskUtils.CompletedTask;
}
private async void CommCopterDisconnect(object sender, CommunicationCopterDisconnectEventArgs e)
{
await DisconnectCopter(e.Id);
}
private async void CommCopterconnected(object sender, CommunicationConnectEventArgs e)
{
await AddCommCopter(e.Id);
}
private async Task DisconnectCopter(int id)
{
var copters = _copterManager.Copters;
var copter = copters.FirstOrDefault(c => c.Id == id.ToString());
if (copter != null)
{
if (copter is PLCopter)
{
PLCopter plcopter = (PLCopter)copter;
plcopter.CommModuleConnected = false;
}
}
await TaskUtils.CompletedTask;
}
private static readonly object locker = new object();
private async Task AddCommCopter(int id)
{
await Dispatcher.BeginInvoke(new Action(() =>
{
lock(locker)
{
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
if ((copter != null)&&(copter is FakeCopter))
{
_copterManager.Copters.Remove(copter);
copter = null;
}
if (copter == null)
{
if (_copterManager.EnAddCopter_Real())
{
var copterStatus = _copterManager.CopterStatus;
var connection = new CommConnection();
copter = new Copter(connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
{
Id = id.ToString(),
Name = id.ToString(),
};
copter.VirtualId = 0;
int _index;
_index = _copterManager.Copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
}
}
}
}));
}
private async Task UpdateCommCopterInfo(int id, byte[] package, byte CommModuleVersion)
{
await AddCommCopter(id);
lock (locker)
{
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
if (copter!= null && copter is PLCopter)
{
PLCopter plcopter = (PLCopter)copter;
if (!plcopter.CommModuleConnected) plcopter.CommModuleConnected = true;
plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package, CommModuleVersion);
plcopter.CommModuleConnected = true;
}
}
}
}
}
using Plane.Communication;
using Plane.Copters;
using Plane.FormationCreator.Formation;
using Plane.Logging;
using Plane.Windows;
using Plane.Windows.Messages;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Plane.FormationCreator.Util;
using Plane.CommunicationManagement;
namespace Plane.FormationCreator
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
VersionControl.GetSettingFromIni();
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
ServiceLocatorConfigurer.Instance.Configure();
_logger = ServiceLocator.Current.GetInstance<ILogger>();
_copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
_formationController = ServiceLocator.Current.GetInstance<FormationController>();
_mapManager = ServiceLocator.Current.GetInstance<MapManager>();
AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
{
var simpleName = new AssemblyName(e.Name).Name;
if (simpleName.EndsWith(".resources"))
{
return null;
}
return LoadAssembly(simpleName);
};
this.DispatcherUnhandledException += (s, e) =>
{
_logger.Log(e.Exception);
// await _formationController.AllStop();
TcpServerConnectionManager.Instance.StopListening();
UdpServerConnectionManager.Instance.StopReceiving();
};
this.Exit += (s, e) =>
{
try
{
// TcpServerConnectionManager.Instance.StopListening();
UdpServerConnectionManager.Instance.StopReceiving();
}
catch (Exception ex)
{
// RaiseExceptionThrown(ex);
}
};
//new Test().Prepare().Run();
}
private ILogger _logger;
private CopterManager _copterManager;
private FormationController _formationController;
private MapManager _mapManager;
private Assembly LoadAssembly(string simpleName)
{
String resourceName = this.GetType().Namespace + ".AssemblyLoadingAndReflection." + simpleName + ".dll";
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var md = Resources.MergedDictionaries;
// md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Plane.Windows.Messages;component/Styles.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Styles/Colors.xaml") });
md.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Styles.xaml") });
/*
new UpdateChecker("http://dl.Plane.com/tools/ver.php?app=FormationCreator", _logger)
.CheckAsync(ver =>
{
var currentVersion = this.GetType().Assembly.GetName().Version;
if (currentVersion < ver
&& Alert.Show("检测到新版本,请下载。", "更新提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
Process.Start("http://dl.Plane.com/tools/FormationCreatorSetup.exe");
this.Shutdown();
}
});
*/
System.Windows.FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false;
MainWindow = new MainWindow();
MainWindow.Show();
try
{
/* by panxu tcp 使 --使TCP监听在自动获取IP的情况下
TcpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
if (!TcpServerConnectionManager.Instance.StartListening())
{
Alert.Show("网络连接不正常,无法连接飞机。");
return;
}
*/
if (VersionControl.ConType == 1)
{
CommModuleManager.Instance.UseTransModule = false;
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
{
_logger.Log(e1.Exception);
};
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
UdpServerConnectionManager.Instance.StartReceiving();
}
else
{
CommModuleManager.Instance.UseTransModule = true;
//初始化地面站连接
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
CommModuleManager.Instance.Connect();
}
}
catch (Exception ex)
{
Alert.Show("网络连接不正常,无法连接飞机。");
return;
}
}
protected override void OnExit(ExitEventArgs e)
{
CommModuleManager.Instance.CloseConnection();
base.OnExit(e);
}
private void Copter_TextReceived(object sender, MessageCreatedEventArgs e)
{
_logger.Log(e.Message );
}
//wifi模式添加飞机
private async Task AddOrUpdateCopter(string ip, IConnection Connection)
{
var copters = _copterManager.Copters;
var copterStatus = _copterManager.CopterStatus;
string[] iparr = ip.Split('.');
string vIPID = String.Format("{0:D3}", int.Parse(iparr[2])) + String.Format("{0:D3}", int.Parse(iparr[3]));
var copter = copters.FirstOrDefault(c => c.Id == vIPID);
if (copter == null)
{
if (!_copterManager.EnAddCopter_Real())
{
UdpServerConnectionManager.Instance.DeleteConnections(ip);
}
else
{
await Dispatcher.BeginInvoke(new Action(() =>
{
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
{
Id = vIPID,
Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1)
};
int _index;
_index = copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
}));
}
}
else
{
copter.Connection = Connection;
}
if (copter!=null)
await copter.ConnectAsync().ConfigureAwait(false);
}
private async void ConnectionManager_ConnectionEstablished(object sender, ConnectionEstablishedEventArgs e)
{
await AddOrUpdateCopter(e.RemoteAddress, e.Connection);
}
private async void CommtionReceivedCopterInfo(object sender, CommunicationReceiveCopterInfoEventArgs e)
{
await UpdateCommCopterInfo(e.Id, e.Package, e.CommModuleVersion);
//await TaskUtils.CompletedTask;
}
private async void CommCopterDisconnect(object sender, CommunicationCopterDisconnectEventArgs e)
{
await DisconnectCopter(e.Id);
}
private async void CommCopterconnected(object sender, CommunicationConnectEventArgs e)
{
await AddCommCopter(e.Id);
}
private async Task DisconnectCopter(int id)
{
var copters = _copterManager.Copters;
var copter = copters.FirstOrDefault(c => c.Id == id.ToString());
if (copter != null)
{
if (copter is PLCopter)
{
PLCopter plcopter = (PLCopter)copter;
plcopter.CommModuleConnected = false;
}
}
await TaskUtils.CompletedTask;
}
private static readonly object locker = new object();
private async Task AddCommCopter(int id)
{
await Dispatcher.BeginInvoke(new Action(() =>
{
lock(locker)
{
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
if ((copter != null)&&(copter is FakeCopter))
{
_copterManager.Copters.Remove(copter);
copter = null;
}
if (copter == null)
{
if (_copterManager.EnAddCopter_Real())
{
var copterStatus = _copterManager.CopterStatus;
var connection = new CommConnection();
copter = new Copter(connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
{
Id = id.ToString(),
Name = id.ToString(),
};
copter.VirtualId = 0;
int _index;
_index = _copterManager.Copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
}
}
}
}));
}
private async Task UpdateCommCopterInfo(int id, byte[] package, byte CommModuleVersion)
{
await AddCommCopter(id);
lock (locker)
{
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
if (copter!= null && copter is PLCopter)
{
PLCopter plcopter = (PLCopter)copter;
if (!plcopter.CommModuleConnected) plcopter.CommModuleConnected = true;
plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package, CommModuleVersion);
plcopter.CommModuleConnected = true;
}
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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">

View File

@ -1,73 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Plane.FormationCreator.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Plane.FormationCreator.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Logo_small {
get {
object obj = ResourceManager.GetObject("Logo_small", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Plane.FormationCreator.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[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 {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Plane.FormationCreator.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Logo_small {
get {
object obj = ResourceManager.GetObject("Logo_small", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -1,38 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Plane.FormationCreator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("192.168.1.50")]
public string IPs {
get {
return ((string)(this["IPs"]));
}
set {
this["IPs"] = value;
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Plane.FormationCreator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[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())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("192.168.1.50")]
public string IPs {
get {
return ((string)(this["IPs"]));
}
set {
this["IPs"] = value;
}
}
}
}

View File

@ -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不拉开层
}));
}
}

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="GMap.NET.Windows" version="1.8.5" targetFramework="net46" />
<package id="HelixToolkit" version="2.4.0" targetFramework="net46" />
<package id="HelixToolkit.Wpf" version="2.4.0" targetFramework="net46" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
<package id="MaterialDesignThemes" version="1.4.0.473" targetFramework="net46" />
<package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net46" />
<package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="System.Data.SQLite" version="1.0.109.1" targetFramework="net46" />
<package id="System.Data.SQLite.Core" version="1.0.109.1" targetFramework="net46" />
<package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net46" />
<package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net46" />
<package id="Unnoficial.Microsoft.Expression.Drawing" version="1.0.0" targetFramework="net46" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="GMap.NET.Windows" version="1.8.5" targetFramework="net46" />
<package id="HelixToolkit" version="2.4.0" targetFramework="net46" />
<package id="HelixToolkit.Wpf" version="2.4.0" targetFramework="net46" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
<package id="MaterialDesignThemes" version="1.4.0.473" targetFramework="net46" />
<package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net46" />
<package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="System.Data.SQLite" version="1.0.109.1" targetFramework="net46" />
<package id="System.Data.SQLite.Core" version="1.0.109.1" targetFramework="net46" />
<package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net46" />
<package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net46" />
<package id="Unnoficial.Microsoft.Expression.Drawing" version="1.0.0" targetFramework="net46" />
</packages>