Compare commits

..

1 Commits

Author SHA1 Message Date
xu
5296137208 修改为兼容老版固件
登录界面增加版本号
2020-05-05 18:59:09 +08:00
59 changed files with 13669 additions and 18531 deletions

View File

@ -1,12 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
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
{9BFB2123-2239-4A85-B5BC-0328CE7640D7} = {9BFB2123-2239-4A85-B5BC-0328CE7640D7}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Windows", "..\Plane.Libraries\Plane.Windows\Plane.Windows.csproj", "{06848293-9B17-4068-9B35-44D0ED713CD4}"
EndProject
@ -26,11 +23,13 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk_Shared", "..\Pl
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk.Contract_Shared", "..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.shproj", "{695733D7-99FF-4707-8C89-474E949CADCB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRoute", "..\FlyTest\FlightRoute\FlightRoute.csproj", "{9BFB2123-2239-4A85-B5BC-0328CE7640D7}"
EndProject
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
@ -102,30 +101,8 @@ Global
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.Release|Any CPU.Build.0 = Release|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
{9BFB2123-2239-4A85-B5BC-0328CE7640D7}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.Release|Any CPU.Build.0 = Release|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
{626A9BFA-07DE-4063-A178-360EB7057ED6}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
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,28 +1,28 @@
<?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">
<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>
<!-- 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>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<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"/>
<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"/>
<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"/>
<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>
@ -36,18 +36,18 @@
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
<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"/>
<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>
<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

@ -11,14 +11,6 @@
ShutdownMode="OnMainWindowClose">
<Application.Resources>
<materialDesign:PackIcon x:Key="ConnectIcon"
x:Shared="False"
Kind="LanConnect"
Foreground="#2196F3" />
<materialDesign:PackIcon x:Key="DisconnectIcon"
x:Shared="False"
Kind="LanDisconnect"
Foreground="White" />
<materialDesign:PackIcon x:Key="CheckIcon"
x:Shared="False"
Kind="Check"
@ -27,7 +19,6 @@
x:Shared="False"
Kind="Close"
Foreground="White" />
<cnv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<cnv:BooleanToVisibilityConverter x:Key="InversiveBooleanToVisibilityConverter"
False="Visible"
@ -45,25 +36,6 @@
False="【飞行模式】"
True="【设计模式】" />
<cnv:BooleanToStringConverter x:Key="MainColorConverterDes"
False="White"
True="DeepSkyBlue" />
<cnv:BooleanToStringConverter x:Key="MainFontSizeConverterDes"
False="12"
True="14" />
<cnv:BooleanToStringConverter x:Key="MainColorConverterFly"
False="DeepSkyBlue"
True="White" />
<cnv:BooleanToStringConverter x:Key="MainFontSizeConverterFly"
False="14"
True="12" />
<cnv:BooleanToStringConverter x:Key="Show2d3dButtonContentConverter"
False="平面视图"
True="立体视图" />
@ -73,8 +45,8 @@
FalseKey="CloseIcon"
TrueKey="CheckIcon" />
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter2"
FalseKey="DisconnectIcon"
TrueKey="ConnectIcon" />
FalseKey="CloseIcon"
TrueKey="CheckIcon" />
<cnv:BooleanToStringConverter x:Key="ColorConverter"
False="Red"
True="Green" />
@ -84,16 +56,6 @@
<lcnv:HeartbeatCountToBrushConverter x:Key="HeartbeatCountToBrushConverter" />
<lcnv:AppModeToVisibilityConverter x:Key="AppModeToVisibilityConverter" />
<lcnv:FlightTaskStatusToFillConverter x:Key="FlightTaskStatusToFillConverter" />
<lcnv:ErrorCodeToColorConverter x:Key="ErrorCodeToColorConverter" />
<lcnv:PrecheckToColorConverter x:Key="PrecheckToColorConverter" />
<lcnv:FlightTaskStatusAndTransitionToFillConverter x:Key="FlightTaskStatusAndTransitionToFillConverter" />
<lcnv:FlightTaskIsSelectedToEffectConverter x:Key="FlightTaskIsSelectedToEffectConverter" />
</Application.Resources>
</Application>

View File

@ -18,9 +18,8 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Plane.FormationCreator.Util;
using Plane.CommunicationManagement;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator
{
@ -202,7 +201,7 @@ namespace Plane.FormationCreator
Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1)
};
int _index;
_index = copters.AddCopter(copter, _copterManager.SortType);
_index = copters.AddCopter(copter);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
@ -262,13 +261,6 @@ namespace Plane.FormationCreator
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())
@ -281,9 +273,8 @@ namespace Plane.FormationCreator
Id = id.ToString(),
Name = id.ToString(),
};
copter.VirtualId = 0;
int _index;
_index = _copterManager.Copters.AddCopter(copter, _copterManager.SortType);
_index = _copterManager.Copters.AddCopter(copter);
copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived;
}

View File

@ -15,68 +15,15 @@ namespace Plane.FormationCreator.Converters
public class HeartbeatCountToBrushConverter : IMultiValueConverter
{
private static SolidColorBrush _zeroBrush = new SolidColorBrush(Color.FromArgb(125, 125, 125, 125));
private static SolidColorBrush _zeroBrush_fault = new SolidColorBrush(Color.FromRgb(160, 140, 0));
private static SolidColorBrush _oneBrush = Copter.DefaultBrush;
private static SolidColorBrush _FakeCopterBrush = Copter.DefaultFakeBrush;
private static SolidColorBrush _PreCheckNopassBrush = Copter.YellowBrush;
private static SolidColorBrush _NoconnectedBrush = Copter.RedBrush;
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == DependencyProperty.UnsetValue) return _zeroBrush;
var heartbeatCount = (ulong)values[0];
/* //绑定的是心跳,所以连接断开时不会调用这个转换器
//如果是真飞机,并且断开了,直接显示红色
if (values[1] is PLCopter)
{
var plcopter = values[1] as PLCopter;
if (!plcopter.CommModuleConnected)
return _NoconnectedBrush;
}
*/
//用于显示收到心跳的闪烁
if (heartbeatCount % 2 == 0)
{
//真飞机如果异常显示暗淡黄色
if (values[1] is PLCopter)
{
var plcopter = values[1] as PLCopter;
if (plcopter.CopterPreCheckPass)
return _zeroBrush;
else return _zeroBrush_fault;
}
else
return _zeroBrush;
}
if (values[1] is FakeCopter)
{
var fkcopter = values[1] as FakeCopter;
if (fkcopter.CopterPreCheckPass)
return _FakeCopterBrush;
else return _PreCheckNopassBrush;
}
if (values[1] is PLCopter)
{
var plcopter = values[1] as PLCopter;
if (plcopter.CopterPreCheckPass)
return _oneBrush;
else return _PreCheckNopassBrush;
}
if (heartbeatCount % 2 == 0) return _zeroBrush;
var copter = values[1] as Copter;
return copter == null ? _oneBrush : copter.Brush;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)

View File

@ -28,14 +28,6 @@ namespace Plane.FormationCreator.Formation
//RaiseLocationChangedIfNeeded();
}
internal static SolidColorBrush BlueBrush { get; } = new SolidColorBrush(Color.FromRgb(28, 151, 234));
internal static SolidColorBrush RedBrush { get; } = new SolidColorBrush(Color.FromRgb(255, 100, 100));
internal static SolidColorBrush GreenBrush { get; } = new SolidColorBrush(Color.FromRgb(100, 255, 100));
internal static SolidColorBrush YellowBrush { get; } = new SolidColorBrush(Color.FromRgb(255, 215, 0));
static SolidColorBrush[] _brushes = new[]
{
new SolidColorBrush(Color.FromArgb(180, 255, 0, 0)),
@ -51,24 +43,12 @@ namespace Plane.FormationCreator.Formation
{
return _brushIndex++ % _brushes.Length;
}
//真实飞机列表默认颜色
internal static SolidColorBrush DefaultBrush { get; } = GreenBrush;// new SolidColorBrush(Color.FromRgb(50, 205, 50));
//虚拟飞机列表默认颜色
internal static SolidColorBrush DefaultFakeBrush { get; } = BlueBrush;
internal static SolidColorBrush DefaultBrush { get; } = new SolidColorBrush(Color.FromRgb(28, 151, 234));
private SolidColorBrush _Brush;
public SolidColorBrush Brush
{
get {
if (CopterPreCheckPass)
return _Brush ?? DefaultBrush;
else
return _Brush ?? YellowBrush;
}
get { return _Brush ?? DefaultBrush; }
set { Set(nameof(Brush), ref _Brush, value); }
}
}

View File

@ -21,16 +21,11 @@ using System.IO;
namespace Plane.FormationCreator.Formation
{
public class CopterCollection : ObservableCollection<ICopter>
{
//软件过期时间---过期将无法添加飞机,并自动退出
public static DateTime Expire_App = DateTime.Parse("2024-12-31");
//超级用户过期时间--过期将无法使用内置超级用户登录
public static DateTime Expire_SuperUser = Expire_App;
//允许飞行的飞机数量
public int EnCopterNumber = 0;
//允许模拟的飞机数量
public int EnVCopterNumber = 0;
@ -39,15 +34,17 @@ namespace Plane.FormationCreator.Formation
/// 实现排序插入
/// </summary>
/// <param name="baseSemObjects"></param>
public int AddCopter(ICopter entityObject, CopterManager.CopterSortType vSortType)
public int AddCopter(ICopter entityObject,bool sortbyid=true)
{
////给第三方时候限制数量和时间用
DateTime dateTime2019 = DateTime.Parse("2020-06-01");
//新增飞机区域限制:内蒙
// if (entityObject.Latitude < 37.4307185218 || entityObject.Latitude > 45.6754821756
// || entityObject.Longitude < 97.3493089056 || entityObject.Longitude > 115.8006783856)
// return 0;
if (DateTime.UtcNow > Expire_App)
if (DateTime.UtcNow > dateTime2019)
{
throw new NotImplementedException();
}
@ -93,50 +90,11 @@ namespace Plane.FormationCreator.Formation
}
else
{
//删除重复
// if (entityObject is PLCopter)
// {
for (int i = 0; i < this.Count; i++)
{
if (vSortType == CopterManager.CopterSortType.ByID)
{
if (int.Parse(this[i].Id) == int.Parse(entityObject.Id))
{
if (this[i] is FakeCopter)
Remove(this[i]);
else
{
Message.Show($"无法加入飞机已有重复的真实飞机ID[{this[i].Id}]");
return -1;
}
}
}else
{
if ((entityObject.VirtualId!=0) &&(this[i].VirtualId == entityObject.VirtualId))
{
if (this[i] is FakeCopter)
Remove(this[i]);
else
{
Message.Show($"无法加入飞机已有重复的真实飞机ID[{this[i].VirtualId}]");
return -1;
}
}
}
}
// }
bool isInsret = false;
for (int i = 0; i < this.Count; i++)
{
//按ID排序插入
if (vSortType == CopterManager.CopterSortType.ByID)
if (sortbyid)
{
if (int.Parse(this[i].Id) > int.Parse(entityObject.Id))
{
@ -144,14 +102,14 @@ namespace Plane.FormationCreator.Formation
isInsret = true;
_index = i;
break;
}
}
else
}else
//按VID排序插入
{
if (this[i].VirtualId > entityObject.VirtualId)
{
if (this[i].VirtualId > entityObject.VirtualId)
{
InsertItem(i, entityObject);
isInsret = true;
_index = i;
@ -165,13 +123,7 @@ namespace Plane.FormationCreator.Formation
Add(entityObject);
_index = this.Count()-1 ;
}
}
entityObject.DisplayID = ((vSortType == CopterManager.CopterSortType.ByID) || (vSortType == CopterManager.CopterSortType.ByVIDShowAll));
entityObject.DisplayVirtualId = ((vSortType == CopterManager.CopterSortType.ByVID) || (vSortType == CopterManager.CopterSortType.ByVIDShowAll));
return _index;
}
}
@ -181,21 +133,9 @@ namespace Plane.FormationCreator.Formation
{
const string LoginPage = "checkforapp.php";
// const string supername = "admin";
// const string superpass = "admin0622";
const string supername = "user";
const string superpass = "123456";
const string supername = "admin";
const string superpass = "fxmf0622";
const string TEMP_MISSIONFILE = @".\gcs.dat";
//飞控版本控制
public int FC_VER_NO = 1;//"4.1.2" 这个版本以前版本灯光比较少no=1 //"4.5"以后no=2;
//飞控版本控制
public string FC_VER_STRING = "4.1.2以前"; //
//用户级别
const int LEVEL_NORMAL = 1;
const int LEVEL_ADMIN = 0;
@ -220,19 +160,7 @@ namespace Plane.FormationCreator.Formation
Task.WhenAll(Copters.Select(c => c.DisconnectAsync()));
};
Windows.IniHelper.IniFiles inifilse = new Windows.IniHelper.IniFiles();
string readvalue = "";
int intTemp;
readvalue = inifilse.IniReadvalue("Default", "FC_VER_NO");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
FC_VER_NO = int.Parse(readvalue);
readvalue = inifilse.IniReadvalue("Default", "FC_VER_STRING");
if (readvalue != "" )
FC_VER_STRING =readvalue;
}
}
public List<ICopter> ShowCopter = new List<ICopter>();
@ -282,42 +210,6 @@ namespace Plane.FormationCreator.Formation
netStatusChanged(Logined,Loginstate);
}
}
public enum CopterSortType { ByID, ByVID, ByVIDShowAll };
//排序类型
private CopterSortType _SortType =0;
public CopterSortType SortType
{
get { return _SortType; }
set
{
Set(nameof(SortType), ref _SortType, value);
switch (value)
{
case CopterSortType.ByID:
sortbyid();
break;
case CopterSortType.ByVID:
sortbyvid();
break;
case CopterSortType.ByVIDShowAll:
sortbyvid(true);
break;
default:
sortbyid();
break;
}
}
}
public void ReSort()
{
SortType = _SortType;
}
private int _EnCopterNumber = 0;
@ -355,7 +247,6 @@ namespace Plane.FormationCreator.Formation
private string _UserName = "";
private string _UserDisplayName = "";
public string RTK_URL = "";
public void NetLogined(string UserName,string UserDisplayName,int vEnCopterNumber,int vEnVCopterNumber,int userlever=1)
{
@ -367,7 +258,7 @@ namespace Plane.FormationCreator.Formation
string dis_EnVCopterNumber = "<" + EnVCopterNumber.ToString() + ">";
if (EnCopterNumber == -1) dis_EnCopterNumber = "<无限>";
if (EnVCopterNumber == -1) dis_EnVCopterNumber = "<无限>";
Loginstate ="["+ UserDisplayName + "] 模拟飞机:"+ dis_EnVCopterNumber + "架,真实飞机:"+ dis_EnCopterNumber + "架";
Loginstate ="["+ UserDisplayName + "]已登录,模拟飞机:"+ dis_EnVCopterNumber + "架,真实飞机:"+ dis_EnCopterNumber + "架";
Logined = true;
VersionControl.SetUserLever(userlever);
if (UserName != supername)
@ -383,40 +274,6 @@ namespace Plane.FormationCreator.Formation
}).ConfigureAwait(false);
}
}
public void GetRTKURL()
{
if (_UserName == "") return;
// 发送请求
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
sbUrl.Append(VersionControl.ServerURL + LoginPage);
sbUrl.Append("?");
sbUrl.Append("username=" + _UserName);
sbUrl.Append("&clientname=" + System.Net.Dns.GetHostName());
sbUrl.Append("&type=GetRTK");
sbUrl.Append("&ver=" + Assembly.GetExecutingAssembly().GetName().Version.ToString());
String strUrl = sbUrl.ToString();
string errorstr;
new AsynDataUtils().AsynGetData(strUrl, ResultCallBack_rtk, out errorstr);
}
public void ReleaseRTKURL()
{
if (_UserName == "") return;
// 发送请求
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
sbUrl.Append(VersionControl.ServerURL + LoginPage);
sbUrl.Append("?");
sbUrl.Append("username=" + _UserName);
sbUrl.Append("&clientname=" + System.Net.Dns.GetHostName());
sbUrl.Append("&type=RelRTK");
sbUrl.Append("&ver=" + Assembly.GetExecutingAssembly().GetName().Version.ToString());
String strUrl = sbUrl.ToString();
string errorstr;
new AsynDataUtils().AsynGetData(strUrl, null, out errorstr);
}
private void NetActivePost()
{
// 发送请求
@ -627,12 +484,9 @@ namespace Plane.FormationCreator.Formation
{
Logined = false;
//超级用户,无限制
if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) )
if ((username== supername) && (password== superpass))
{
// NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
NetLogined(supername, superDispname,6, 300, LEVEL_NORMAL);
VersionControl.SaveLogininfoToIni(supername, superpass, savepassword); //超级密码是否保存---不要就不保存
NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
return;
}
@ -655,29 +509,7 @@ namespace Plane.FormationCreator.Formation
else Loginstate = "登录失败,"+ errorstr;
}
private void ResultCallBack_rtk(string data, bool haveerror)
{
if (haveerror)
{
MessageBox.Show("获取RTK账号失败" + data, "错误");
return;
}
if (data == "")
{
MessageBox.Show("获取RTK账号失败请检查网络", "错误");
return;
}
string[] arr = data.Split(';');
string loginret = arr[0];
if (loginret == "ok")
{
RTK_URL = arr[1];
}
else
MessageBox.Show(loginret, "错误");
}
//在这个方法里面接收回调的返回信息
private void DataResultCallBack_changepassword(string data, bool haveerror)
@ -781,38 +613,6 @@ namespace Plane.FormationCreator.Formation
}
public async Task DelSelCopters()
{
if (AcceptingControlCopters == null || AcceptingControlCopters.Count() ==0)
{
return;
}
foreach (var copter in AcceptingControlCopters)
{
await copter.DisconnectAsync();
if(Copters.Contains(copter))
{
Copters.Remove(copter);
}
//标记是否跳过,这个已经没用了,随便删除第一个
CopterStatus.RemoveAt(0);
}
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
//wifi
// if (VersionControl.ConType == 1)
// UdpServerConnectionManager.Instance.ClearConnections();
}
public bool EnAddCopter_Real()
{
if (EnCopterNumber == -1) return true;
@ -839,13 +639,13 @@ namespace Plane.FormationCreator.Formation
/// <summary>
/// 按VID重新排序飞机
/// </summary>
public void sortbyvid(bool displayid=false)
public void sortbyvid()
{
List<ICopter> tempCopters = new List<ICopter>();
tempCopters.AddRange(Copters);
Copters.Clear();
foreach (var copter in tempCopters)
Copters.AddCopter(copter,SortType);
Copters.AddCopter(copter,false);
}
/// <summary>
/// 按原始ID重新排序飞机
@ -856,8 +656,7 @@ namespace Plane.FormationCreator.Formation
tempCopters.AddRange(Copters);
Copters.Clear();
foreach (var copter in tempCopters)
Copters.AddCopter(copter,SortType);
Copters.AddCopter(copter);
}
}

View File

@ -53,7 +53,6 @@ namespace Plane.FormationCreator.Formation
public static double DistanceTo(this ICopter copter, ICopter copter2)
{
return GeographyUtils.CalcDistance(copter.Latitude, copter.Longitude, copter.Altitude, copter2.Latitude, copter2.Longitude, copter2.Altitude);
//return GeographyUtils.CalcDistance_simple(copter.Latitude, copter.Longitude, copter.Altitude, copter2.Latitude, copter2.Longitude, copter2.Altitude);
}
public static double InPlaneDistanceTo(this ICopter copter, double targetLat, double targetLng)

View File

@ -122,21 +122,6 @@ namespace Plane.FormationCreator.Formation
}
}
private bool _IsTransition=false;
public bool IsTransition
{
get { return _IsTransition; }
set {
Set(nameof(IsTransition), ref _IsTransition, value);
if ((value)&& (TaskCnName == "航点"))
TaskCnName = "过度";
}
}
private bool _IsSelected;
public bool IsSelected
{
@ -163,11 +148,7 @@ namespace Plane.FormationCreator.Formation
get { return _ModifyingSingleCopterInfo; }
set { Set(nameof(ModifyingSingleCopterInfo), ref _ModifyingSingleCopterInfo, value); }
}
/// <summary>
/// 实际执行某一个任务--包含等待
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public async Task RunAsync()
{
switch (TaskType)
@ -176,6 +157,8 @@ namespace Plane.FormationCreator.Formation
await RunFlyToTaskAsync().ConfigureAwait(false);
break;
case FlightTaskType.TakeOff:
//多架同时起飞
//await MutilRunTakeOffTaskAsync().ConfigureAwait(false);
await NewMutilRunTakeOffTaskAsync().ConfigureAwait(false);
break;
case FlightTaskType.Land:

File diff suppressed because it is too large Load Diff

View File

@ -61,16 +61,7 @@ namespace Plane.FormationCreator.Formation
public bool IsLandWaypoint
{
get { return _IsLandWaypoint; }
set {
Set(nameof(IsLandWaypoint), ref _IsLandWaypoint, value);
if (_flightTaskManager.SelectedTask == null) return;
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
info._IsLandWaypoint = _IsLandWaypoint;
}
}
set { Set(nameof(IsLandWaypoint), ref _IsLandWaypoint, value); }
}
private bool _IsChangeSpeed = false;
@ -81,15 +72,7 @@ namespace Plane.FormationCreator.Formation
public bool IsChangeSpeed
{
get {return _IsChangeSpeed; }
set {
Set(nameof(IsChangeSpeed), ref _IsChangeSpeed, value);
if (_flightTaskManager.SelectedTask == null) return;
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
info._IsChangeSpeed = _IsChangeSpeed;
}
}
set { Set(nameof(IsChangeSpeed), ref _IsChangeSpeed, value); }
}
@ -100,14 +83,7 @@ namespace Plane.FormationCreator.Formation
public float LevelSpeed
{
get { return _LevelSpeed; }
set {
Set(nameof(LevelSpeed), ref _LevelSpeed, value);
if (_flightTaskManager.SelectedTask == null) return;
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
info._LevelSpeed = _LevelSpeed;
}
}
set { Set(nameof(LevelSpeed), ref _LevelSpeed, value); }
}
@ -118,14 +94,7 @@ namespace Plane.FormationCreator.Formation
public float UpSpeed
{
get { return _UpSpeed; }
set {
Set(nameof(UpSpeed), ref _UpSpeed, value);
if (_flightTaskManager.SelectedTask == null) return;
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
info._UpSpeed = _UpSpeed;
}
}
set { Set(nameof(UpSpeed), ref _UpSpeed, value); }
}
private float _DownSpeed = 1.5f;
@ -135,14 +104,7 @@ namespace Plane.FormationCreator.Formation
public float DownSpeed
{
get { return _DownSpeed; }
set {
Set(nameof(DownSpeed), ref _DownSpeed, value);
if (_flightTaskManager.SelectedTask == null) return;
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
{
info._DownSpeed = _DownSpeed;
}
}
set { Set(nameof(DownSpeed), ref _DownSpeed, value); }
}
/*

View File

@ -154,7 +154,7 @@ namespace Plane.FormationCreator.Formation
LEDTestRun = true;
foreach (LEDInfo vLEDInfo in LEDInfos)
{
Thread.Sleep((int)(vLEDInfo.Delay * 1000));
Thread.Sleep((int)vLEDInfo.Delay * 1000);
if (!LEDTestRun) break;
_commModuleManager.LED_TaskAsync(vLEDInfo.LEDMode, vLEDInfo.LEDInterval, vLEDInfo.LEDTimes, vLEDInfo.LEDRGB, this.Copter);
}
@ -164,8 +164,6 @@ namespace Plane.FormationCreator.Formation
{
LEDTestRun = false;
_commModuleManager.LED_TaskAsync(255, 0, 0, "000000", this.Copter);
_commModuleManager.LED_TaskAsync(255, 0, 0, "000000", this.Copter);
_commModuleManager.LED_TaskAsync(255, 0, 0, "000000", this.Copter);
}
}));
@ -245,12 +243,17 @@ namespace Plane.FormationCreator.Formation
get { return ledmode; }
set { ledmode = value; }
}
//为了发布兼容老版本的用ledInterval当成频率在用并且不保存LEDInterval到文件
[Newtonsoft.Json.JsonIgnore]
public float LEDInterval
{
get { return ledInterval; }
set { ledInterval = value;
if (ledInterval != 0)
ledrate = (int)Math.Round(1 / ledInterval); //用于兼容老版本
//为了发布兼容老版本的用ledInterval当成频率在用并且不保存LEDInterval到文件
ledrate = (int)ledInterval;
//新版用这个
//if (ledInterval != 0)
// ledrate = (int)Math.Round(1 / ledInterval); //用于兼容老版本
}
}
@ -258,8 +261,12 @@ namespace Plane.FormationCreator.Formation
{
get { return ledrate; }
set { ledrate = value;
if ((ledrate!=0)&&(ledInterval==0))
ledInterval = 1 / ledrate;
//为了发布兼容老版本的用ledInterval当成频率在用并且不保存LEDInterval到文件
ledInterval = ledrate;
//新版用这个
// if ((ledrate!=0)&&(ledInterval==0))
// ledInterval = 1 / ledrate;
}
}

View File

@ -86,10 +86,20 @@ namespace Plane.FormationCreator.Formation
for (int i = 0; i < infos.Count; i++)
{
var info = infos[i];
//为每架飞机创建一个航点任务
tasks[i] = await Task.Factory.StartNew(async () =>
{
var internalInfo = info;
//if (i1 > 0)
//{
// var prevCopter = infos[i1 - 1].Copter;
// while (CheckCrossing(infos, i1) &&
// prevCopter.Altitude - copter.Altitude < 2)
// {
// await Task.Delay(25).ConfigureAwait(false);
// }
//}
await FlyToTaskFlySingleCopterAsync(internalInfo);
});
}
@ -105,12 +115,8 @@ namespace Plane.FormationCreator.Formation
}
// private int RuningTaskRemaining = 0;
/// <summary>
/// 单独飞机执行飞行任务
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private int RuningTaskRemaining = 0;
private async Task FlyToTaskFlySingleCopterAsync(FlightTaskSingleCopterInfo info)
{
DateTime dtNow = DateTime.Now;
@ -138,6 +144,15 @@ namespace Plane.FormationCreator.Formation
await info.Copter.GuidAsync();
/*
for (int i = 0; i < 5; i++)
{
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, info.TargetAlt);
await Task.Delay(10).ConfigureAwait(false);
}
*/
double targetLat = info.TargetLat;
double targetLng = info.TargetLng;
if (info.IsLandWaypoint)
@ -145,21 +160,61 @@ namespace Plane.FormationCreator.Formation
targetLat = info.Copter.TakeOffPoint.Latitude;
targetLng = info.Copter.TakeOffPoint.Longitude;
}
int flytype = _flightTaskManager.getflytype(taskIndex);
//指定目标位置
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt, task.FlytoTime, flytype);
//发送目标航点1次
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt);
// await Task.Delay(10).ConfigureAwait(false);
dtNow = DateTime.Now;
ts = dtNow - dtLastTime;
//等待时间到达,并执行灯光模拟--不移动飞机,移动飞机是飞机自己计算的
int sendFlyToTimes = 0;
//第0个任务为takeoff
if (taskIndex > 0)
{
FlightTask prevTask = _flightTaskManager.Tasks[taskIndex - 1];
if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0)
flyToTime += prevTask.RuningTaskRemaining;
}
//while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 所有Copter到达目标点开始飞下个航点
while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点
{
/*
//悬停时间等于0为快速航点 到达之后立即出发下个航点 切时间累积
if (loiterTime == 0 &&
info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt))
{
task.RuningTaskRemaining = flyToTime - (int)ts.TotalMilliseconds;
break;
}
*/
if (_flightTaskManager.IsPaused == true)
{
await info.Copter.HoverAsync();
return;
}
await Task.Delay(100).ConfigureAwait(false); //判断是否到达位置10hz
//执行灯光模拟
// if (info.LEDInfos.Count > 0)
// {
// string LEDRGB = "";
// List<LEDInfo> LedControl = info.LEDInfos.OrderBy(i=>i.Delay).ToList();
// for (int i = 0; i < LedControl.Count; i++)
// {
// var led = LedControl[i];
// if (ts.TotalMilliseconds >= led.Delay * 1000)
// LEDRGB = info.LEDInfos[i].LEDRGB;
// else
// break;
// }
// info.Copter.LEDColor = LEDRGB;
//
// }
if (info.LEDInfos.Count > 0)
{
string LEDRGB = "";
@ -176,17 +231,29 @@ namespace Plane.FormationCreator.Formation
break;
}
info.Copter.LEDColor = LEDRGB;
}
/*
if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标
{
sendFlyToTimes++;
for (int i = 0; i < 2; i++)
{
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt);
await Task.Delay(10).ConfigureAwait(false);
}
//dtLastTime = dtNow;
}
*/
// 当该飞机被标记时,悬停并跳过飞行任务
if ((bool)_copterManager.CopterStatus[copterIndex])
{
await info.Copter.HoverAsync();
return;
}
if (_flightTaskManager.IsEmergencyRet == true)
{
return;
}
dtNow = DateTime.Now;
ts = dtNow - dtLastTime;
}

View File

@ -66,20 +66,20 @@ namespace Plane.FormationCreator.Formation
var tasksTakeOff = new Task[infos.Count];
for (int i = 0; i < infos.Count; i++)
{
//tasksTakeOff[i] = NewSingleRunTaskOffTaskAsunc(infos[i]);
tasksTakeOff[i] = await Task.Factory.StartNew(async () =>
{
var internalInfo = infos[i];
await NewSingleRunTaskOffTaskAsunc(internalInfo);
});
}
await Task.WhenAll(tasksTakeOff).ConfigureAwait(false);
//await Task.Delay(100);
}
/// <summary>
/// 单独飞机 执行起飞任务
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private async Task NewSingleRunTaskOffTaskAsunc(FlightTaskSingleCopterInfo info)
{
DateTime dtNow = DateTime.Now;
@ -105,25 +105,31 @@ namespace Plane.FormationCreator.Formation
//虚拟飞机5秒后不起飞会自动上锁
await copter.UnlockAsync();
await copter.TakeOffAsync();
for (int i = 0; i < 5; i++) // added by ZJF
{
await copter.TakeOffAsync();
await Task.Delay(50).ConfigureAwait(false);
}
var copterNextTask = _flightTaskManager.Tasks[TaskIndex + 1].SingleCopterInfos[copterIndex];
float takeOffAlt = copterNextTask.TargetAlt;
info.TargetLat = info.Copter.Latitude;
info.TargetLng = info.Copter.Longitude;
//info.Copter.takeOffTargetAltitude = takeOffAlt;
FlightTask task = _flightTaskManager.CurrentRunningTask;
if (task==null)
return;
float takeflytime = task.TakeOffTime - info.TakeOffWaitTime;
//飞行目标,开始往上飞
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt, takeflytime, 1); //秒
// for (int j = 0; j < 3; j++)
// {
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt);
// await Task.Delay(10).ConfigureAwait(false);
// }
//解锁起飞用暗紫色
info.Copter.LEDColor = CopterManager.CopterTakeoffColor;
dtNow = DateTime.Now;
ts = dtNow - dtLastTime;
FlightTask task = _flightTaskManager.CurrentRunningTask;
//等待起飞时间完成,并模拟灯光--不移动飞机-飞机自己计算并移动位置
while (ts.TotalMilliseconds < task.TakeOffTime * 1000)
{
if (_flightTaskManager.IsPaused == true)
@ -156,6 +162,7 @@ namespace Plane.FormationCreator.Formation
}
//起飞完成用默认颜色
info.Copter.LEDColor = CopterManager.CopterFlyingColor;
}

View File

@ -133,16 +133,15 @@ namespace Plane.FormationCreator.Formation
// {
//_copterManager.Select(_copterManager.Copters[copterIndex]);
ICopter copter = null;
// try
// {
// copter = _copterManager.Copters.First(o => o.Name == (copterIndex + 1).ToString());
// }
// catch (Exception)
// {
// continue;
// }
string strcoptername = _copterManager.Copters[copterIndex].Name;
copter = _copterManager.Copters.FirstOrDefault(o => o.Name == strcoptername);
// try
// {
// copter = _copterManager.Copters.First(o => o.Name == (copterIndex + 1).ToString());
// }
// catch (Exception)
// {
// continue;
// }
copter = _copterManager.Copters.FirstOrDefault(o => o.Name == (copterIndex + 1).ToString());
if (copter != null)
{
_copterManager.Select(copter);

View File

@ -1,6 +1,5 @@
using GalaSoft.MvvmLight;
using Microsoft.Practices.ServiceLocation;
using Newtonsoft.Json.Linq;
using Plane.CommunicationManagement;
using Plane.FormationCreator.ViewModels;
using Plane.Util;
@ -10,12 +9,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Media;
using System.Windows.Threading;
@ -24,107 +21,31 @@ namespace Plane.FormationCreator.Formation
public class RtcmManager: ObservableObject
{
private rtcm3 rtcm = new rtcm3();
// ubx detection
private static Ubx ubx_m8p = new Ubx();
static nmea nmea = new nmea();
private Hashtable msgseen = new Hashtable();
private ICommsSerial comPort;
private ICommsSerial RecomPort;
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
public ObservableCollection<RtcmInfo> rtcmInfoList { get; } = new ObservableCollection<RtcmInfo>();
private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
private bool _rtcmthreadrun = false;
private bool _smallrtcmdata = false; //减少传输数据--用于带宽不够的通讯模块-对数传广播无效
// rtcm发送类型0:直接发送,
// 11秒只发一种卫星1秒发GPS,第2秒发北斗第3秒发格洛纳斯其他数据随来随发
/*
//F9P作为基站默认推荐的消息
RTCM 1005 RTK ARP
RTCM 1074 GPS MSM4
RTCM 1084 MSM4
RTCM 1094 MSM4
RTCM 1124 MSM4
RTCM 1230 GLONASS
RTCM 3.3
RTCM 3.3 GLONASS (RTCM 1230) 线(RTCM 1033)使RTK GLONASS
RTCM 1005 RTCM 1006
使使 MSM4 MSM7
RTCM RTCM MSM
*/
private int _resendtocom = 1;
const int MSG_GPS = 1074;
const int MSG_GLONASS = 1084;
const int MSG_Beidou = 1124;
const int MSG_BasePos = 1005;
const int MSG_REV = 1033;
const int MSG_GLONASS_PHASE = 1230;
const int MSG_GALILEO = 1094;
public string rtcm_typename(int msgtype)
{
string typename = "Rtcm" + msgtype;
switch (msgtype)
{
case MSG_GPS:
typename = "GPS(G)";
break;
case MSG_GLONASS:
typename = "GLONASS(R)";
break;
case MSG_GLONASS_PHASE:
typename = "GLONASS相位差";
break;
case MSG_Beidou:
typename = "北斗(B)";
break;
//位置5秒发一次就可以了
case MSG_BasePos:
typename = "基站位置";
break;
case MSG_REV: //这个没必要发
typename = "版本";
break;
case MSG_GALILEO: //这个没必要发-移动端默认配置不收这个卫星
typename = "伽利略(E)";
break;
}
return typename;
}
public bool Rtcmthreadrun
{
get { return _rtcmthreadrun; }
set {
Set(nameof(Rtcmthreadrun), ref _rtcmthreadrun, value);
var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
_RtcmInfoViewModel.SetRTKStatestr();
if (value)
ControlPanelVM.RTKState = "RTK发送中...";
else
ControlPanelVM.RTKState = "RTK未发送";
}
}
public bool SmallRtcmData
{
get { return _smallrtcmdata; }
set
{
Set(nameof(SmallRtcmData), ref _smallrtcmdata, value);
var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
_RtcmInfoViewModel.SetRTKStatestr();
}
}
//接收速率
private int bps;
//发送速率
private int bpsusefull;
private int _bps = 0;
@ -209,18 +130,6 @@ namespace Plane.FormationCreator.Formation
get { return _stationTime; }
set { Set(nameof(StationTime), ref _stationTime, value); }
}
private bool _sesendtocom;
public bool ResendToCom
{
get { return _sesendtocom; }
set {
Set(nameof(ResendToCom), ref _sesendtocom, value);
var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
_RtcmInfoViewModel.SetRTKStatestr();
}
}
private DispatcherTimer dispatcherTimer = null;
public RtcmManager()
@ -232,7 +141,6 @@ namespace Plane.FormationCreator.Formation
dispatcherTimer.Start();
}
//用于刷新界面,显示消息状态,基站和卫星是否有效等---1HZ
private void OnTimedEvent(object sender, EventArgs e)
{
BaseState = baseTime > DateTime.Now;
@ -259,7 +167,7 @@ namespace Plane.FormationCreator.Formation
}
//显示卫星信号强度条
private void Rtcm_ObsMessage(object sender, EventArgs e)
{
List<rtcm3.ob> obs = sender as List<rtcm3.ob>;
@ -289,7 +197,6 @@ namespace Plane.FormationCreator.Formation
partRtcmInfos[i].Sys = obs[i].sys;
partRtcmInfos[i].Prn = obs[i].prn;
partRtcmInfos[i].Snr = obs[i].snr;
partRtcmInfos[i].Snr2 = obs[i].snr2;
}
}
@ -300,23 +207,21 @@ namespace Plane.FormationCreator.Formation
return SerialPort.GetPortNames();
}
public async Task Open(string CMB_serialport)
{
if (CMB_serialport == "") return;
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
switch (CMB_serialport)
switch(CMB_serialport)
{
case "千寻":
case "千寻":
//检测原点
// FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
{
Alert.Show("作为参照的原点未设置无法发送RTCM", "提示");
return;
}
//ini里面的固定千寻账号
//千寻账号
string messagetips = "格式http://差分账号:差分密码@域名:端口/坐标系\r\n例如http://account:password@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
string url = "";
@ -327,42 +232,6 @@ namespace Plane.FormationCreator.Formation
//构造
comPort = new CommsNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
break;
case "魔方基站":
//检测原点
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
{
Alert.Show("作为参照的原点未设置无法发送RTCM", "提示");
return;
}
/* //ini里面的固定千寻账号
//千寻账号
string messagetips = "格式http://差分账号:差分密码@域名:端口/坐标系\r\n例如http://account:password@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
string url = "";
IniFiles inifilse = new IniFiles();
url = inifilse.IniReadvalue("Default", "RTKurl");
if (PlaneMessageBox.OnShow(messagetips, "发送RTK", ref url) == false) return;
inifilse.IniWritevalue("Default", "RTKurl", url);
*/
//通过网络得到千寻账号
if (_copterManager.RTK_URL == "")
{
//得到千寻账号
_copterManager.GetRTKURL();
//等到返回5秒
DateTime Tthen = DateTime.UtcNow;
do
{
Application.DoEvents();
} while ((_copterManager.RTK_URL == "") || (Tthen.AddSeconds(2) > DateTime.UtcNow));
}
if (_copterManager.RTK_URL != "")
{
//构造
comPort = new CommsNTRIP(_copterManager.RTK_URL, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
}
break;
default:
comPort = new SerialPort();
@ -377,7 +246,7 @@ namespace Plane.FormationCreator.Formation
}
catch (Exception ex)
{
Alert.Show("数据端口打开失败:"+ ex.Message, "提示");
//Message.Show(ex.Message);
}
if (comPort.IsOpen)
@ -387,65 +256,28 @@ namespace Plane.FormationCreator.Formation
}
}
public async Task Close(string CMB_serialport)
public async Task Close()
{
//如果需要关闭转发端口
_commModuleManager.CloseResendRtcmserial();
await _commModuleManager.CloseRtcmLoop();
Rtcmthreadrun = false;
comPort.Close();
switch (CMB_serialport)
{
case "魔方基站":
{
//释放千寻账号
_copterManager.ReleaseRTKURL();
}
break;
}
BaseState = false;
GpsState = false;
GlonassState = false;
BeidouState = false;
rtcmInfoList.Clear();
_copterManager.RTK_URL = "";
}
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
//发送RTK数据线程循环
private async Task RtcmLoop()
{
int reconnecttimeout = 10;
DateTime lastrecv = DateTime.MinValue;
DateTime unow = DateTime.UtcNow;
long last_send_pos = CurrentTimeMillis()- 5000;//5秒发一次就可以了
bool Ensend = false;
bool second_sended = false; //当前秒是否已发
int last_second = 0; //当前秒
//新版本打包发送模式
//await _commModuleManager.StartRtcmLoop();
Plane.Windows.Messages.Message.Show("RTCM发送开始............");
while (Rtcmthreadrun)
{
// Console.WriteLine(string.Format("{0:T} 1", DateTime.Now));
try
{
try
{
unow=DateTime.UtcNow;
if ((unow - lastrecv).TotalSeconds > reconnecttimeout || !comPort.IsOpen)
if ((DateTime.Now - lastrecv).TotalSeconds > reconnecttimeout || !comPort.IsOpen)
{
if (comPort is CommsNTRIP)
{
@ -454,230 +286,56 @@ namespace Plane.FormationCreator.Formation
{
comPort.Close();
comPort.Open();
Plane.Windows.Messages.Message.Show("RTCM数据超时或端口被关闭重新打开");
}
// reset timer
lastrecv = unow;
lastrecv = DateTime.Now;
}
}
catch { }
if (!comPort.IsOpen)
{
comPort.Open();
Plane.Windows.Messages.Message.Show("RTCM端口已被关闭再次打开");
// return;
return;
}
/////////////////////////////////重写发送RTCM数据部分---23/10/18 by panxu
///
// limit to 180 byte packet if using new packet
//rtcm size=180
byte[] buffer = new byte[180];
while (comPort.BytesToRead > 0)
int read = comPort.Read(buffer, 0, Math.Min(buffer.Length, comPort.BytesToRead));
if (read > 0)
lastrecv = DateTime.Now;
bps += read;
for (int a = 0; a < read; a++)
{
int read = comPort.Read(buffer, 0, Math.Min(buffer.Length, comPort.BytesToRead));
//Console.WriteLine(string.Format("{0:T} - read:{1:D}", DateTime.UtcNow, read));
if (read > 0)
lastrecv = DateTime.UtcNow;
bps += read; //接收速率bps,byte需要*8到bit
// check for valid rtcm/sbp/ubx packets
for (int a = 0; a < read; a++)
int seenmsg = -1;
// rtcm
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
{
int seenmsg = -1;
// rtcm and not can
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
{
// Console.WriteLine(string.Format("{0:T}------------RTCM Send {1:D}", DateTime.Now, rtcm.length));
ubx_m8p.resetParser();
nmea.resetParser();
string msgshowname = rtcm_typename(seenmsg);
//Plane.Windows.Messages.Message.Show("--收到[" + seenmsg + "]:"+ msgshowname+" ,长度:"+ rtcm.length);
//直接发送
if (!SmallRtcmData)
{
//发送到飞机
// Console.WriteLine(DateTime.UtcNow.ToString("HH:mm:ss") + "--通讯模块发送Rtcm长度: " + (ushort)rtcm.length + " 类型: " + msgshowname + " (" + seenmsg + ")");
await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length, ResendToCom);
//累加消息数量,用于界面显示
bpsusefull += rtcm.length;
}
else
//为了减少发送数据量:
//11秒只发一种卫星1秒发GPS,第2秒发北斗第3秒发格洛纳斯其他数据随来随发
bpsusefull += rtcm.length;
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
//用于双频RTK发送
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
//老的单频rtk发送
//await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length);
{
string msgname = "Rtcm" + seenmsg;
Ensend = false; //是否发送
//第1秒是gps,第2秒是GLONASS第3秒是 Beidou
//1秒内可能发送多个同一种类型的数据看数据大小和原始频率
long curr_s = CurrentTimeMillis() / 1000;
int sendtype = (int)(curr_s % 3);
if (last_second!= sendtype) //新一秒
{
second_sended = false; //设置未发送
last_second = sendtype; //设置秒数
}
//这些类型数据需要分秒发或者不发(MSG_REV)
if ((seenmsg == MSG_GPS) ||
//(seenmsg == MSG_GLONASS) ||
//(seenmsg == MSG_GLONASS_PHASE) ||
(seenmsg == MSG_Beidou) ||
(seenmsg == MSG_BasePos)
)
{
switch (sendtype)
{
case 0: //第1秒只发GPS
if ((!second_sended) && (seenmsg == MSG_GPS))
{
second_sended = true;
Ensend = true;
// Plane.Windows.Messages.Message.Show("发送GPS:" + rtcm.length+"字节");
}
break;
case 1://第2秒只发GLONASS
if ((!second_sended) && ((seenmsg == MSG_GLONASS)))// || (MSG_GPS == MSG_GLONASS_PHASE)))
{
second_sended = true;
Ensend = true;
// Plane.Windows.Messages.Message.Show("发送GLONASS:" + rtcm.length + "字节");
}
break;
case 2://空白
if ((!second_sended) && ((seenmsg == MSG_Beidou)))
{
second_sended = true;
Ensend = true;
//Plane.Windows.Messages.Message.Show("发送北斗:" + rtcm.length + "字节");
}
break;
/*
case 3://第4秒是 Beidou
if ((!second_sended) && ((seenmsg == MSG_Beidou)))
{
second_sended = true;
Ensend = true;
//Plane.Windows.Messages.Message.Show("发送北斗:" + rtcm.length + "字节");
}
break;
*/
}
if ((seenmsg == MSG_BasePos))////这些直接发
{
Ensend = true;
//Plane.Windows.Messages.Message.Show("发送位置:" + rtcm.length + "字节");
}
}
//else Ensend = true; ////其他类型数据不发
/*
switch (seenmsg)
{
case MSG_GPS:
if (sendtype == 0) //第1秒是gps,
Ensend = true;
break;
case MSG_GLONASS:
case MSG_GLONASS_PHASE:
if (sendtype == 1) //第2秒是GLONASS
Ensend = true;
break;
case MSG_Beidou:
if (sendtype == 2) //第3秒是 Beidou
Ensend = true;
break;
//位置4秒发一次就可以了
case MSG_BasePos:
{
long curr_send_pos = CurrentTimeMillis();
if ((curr_send_pos - last_send_pos) > 4000)
{
last_send_pos = curr_send_pos;
Ensend = true;
}
}
break;
case MSG_REV: //这个没必要发
Ensend = false;
break;
default: //其他类型数据随到随发
Ensend = true;
break;
}
*/
if (Ensend)
{
//Console.WriteLine(DateTime.UtcNow.ToString("HH:mm:ss") + "--通讯模块发送Rtcm长度: " + (ushort)rtcm.length + " 类型: " + msgshowname + " (" + seenmsg + ")");
await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length, ResendToCom);
//累加消息数量,用于界面显示
bpsusefull += rtcm.length;
}
}
string msgname = rtcm_typename(seenmsg);
if (!msgseen.ContainsKey(msgname))
msgseen[msgname] = 0;
msgseen[msgname] = (int)msgseen[msgname] + 1;
//检测基站定位状态和卫星定位状态,用于在界面上显示
await ExtractBasePos(seenmsg);
}
// ubx
if ((seenmsg = ubx_m8p.Read(buffer[a])) > 0)
{
//Console.WriteLine(string.Format("{0:T}----------------------------ubx_m8p ", DateTime.UtcNow));
rtcm.resetParser();
nmea.resetParser();
/*
//Ubx协议数据不用显示
string msgname = "Ubx" + seenmsg.ToString("X4");
if (!msgseen.ContainsKey(msgname))
msgseen[msgname] = 0;
msgseen[msgname] = (int)msgseen[msgname] + 1;
*/
}
// nmea
if ((seenmsg = nmea.Read(buffer[a])) > 0)
{
//Console.WriteLine(string.Format("{0:T}----------------------------nmea ", DateTime.UtcNow));
rtcm.resetParser();
ubx_m8p.resetParser();
/*
//NMEA协议数据不用显示
string msgname = "NMEA";
if (!msgseen.ContainsKey(msgname))
msgseen[msgname] = 0;
msgseen[msgname] = (int)msgseen[msgname] + 1;
*/
}
if (!msgseen.ContainsKey(msgname))
msgseen[msgname] = 0;
msgseen[msgname] = (int)msgseen[msgname] + 1;
await ExtractBasePos(seenmsg);
//await seenRTCM(seenmsg);
}
////////////////////////////解析/发送RTCM结束
await Task.Delay(20);
}
await Task.Delay(20); //新增加关键延迟,要不然界面会出现卡死现象
await Task.Delay(10);
}
catch (Exception ex)
catch(Exception ex)
{
//Plane.Windows.Messages.Message.Show("RTCM异常:" + ex.Message);
/*
StackFrame sf = new System.Diagnostics.StackTrace(ex, true).GetFrame(0);
Plane.Windows.Messages.Message.Show("RTCM异常:"+ ex.Message+" 行:" +
sf.GetFileLineNumber() + " 文件:"+ sf.GetFileName());
*/
Message.Show(ex.Message);
}
}
Plane.Windows.Messages.Message.Show("RTCM发送停止............");
Rtcmthreadrun = false;
}
@ -762,7 +420,7 @@ namespace Plane.FormationCreator.Formation
}
catch (Exception ex)
{
Plane.Windows.Messages.Message.Show(ex.Message);
Message.Show(ex.Message);
}
await Task.Delay(1);
@ -774,7 +432,6 @@ namespace Plane.FormationCreator.Formation
private char sys;
private byte prn;
private byte snr;
private byte snr2;
public RtcmInfo()
{
@ -798,10 +455,5 @@ namespace Plane.FormationCreator.Formation
get { return snr; }
set { Set(nameof(Snr), ref snr, value); }
}
public byte Snr2
{
get { return snr2; }
set { Set(nameof(Snr2), ref snr2, value); }
}
}
}

View File

@ -48,46 +48,18 @@
<Button Content="{Binding LoginDisp}"
Command="{Binding LoginCommand}" />
<Button Content="飞行面板"
Foreground="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource MainColorConverterFly}}"
FontSize="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource MainFontSizeConverterFly}}"
Command="{Binding HideModifyTaskViewCommand}" />
<Button Content="设计面板"
Foreground="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource MainColorConverterDes}}"
FontSize="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource MainFontSizeConverterDes}}"
Command="{Binding ShowModifyTaskViewCommand}" />
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
Command="{Binding ShowOrHideModifyTaskViewCommand}" Visibility="Collapsed" />
<Button Content="平面编辑"
Foreground="{Binding b2DMapMode, Converter={StaticResource MainColorConverterDes}}"
FontSize="{Binding b2DMapMode, Converter={StaticResource MainFontSizeConverterDes}}"
Command="{Binding Map2DCommand}"/>
<Button Content="实景效果"
Foreground="{Binding b2DMapMode, Converter={StaticResource MainColorConverterFly}}"
FontSize="{Binding b2DMapMode, Converter={StaticResource MainFontSizeConverterFly}}"
Command="{Binding Map3DCommand}"/>
Command="{Binding ShowOrHideModifyTaskViewCommand}" />
<Button Content="{Binding b2DMapMode, Converter={StaticResource Show2d3dButtonContentConverter}}"
Command="{Binding ChangeMapModeCommand}" Visibility="Collapsed"/>
Command="{Binding ChangeMapModeCommand}"/>
<Button Content="重启监听"
Visibility="Collapsed"
Command="{Binding RestartListeningCommand}" />
<Button Content="{Binding SwitchVelocityModeButtonContent}"
Command="{Binding SwitchVelocityModeCommand}"
Visibility="Collapsed"/>
<!--// 王海, 20150930, 不分这些模式了。
<!--// 林俊清, 20150930, 不分这些模式了。
<Button Content="进入任务模式"
Command="{Binding SwitchAppModeCommand}"
CommandParameter="{x:Static m:AppMode.PreparedForRunningTasks}"
@ -132,17 +104,11 @@
Command="{Binding ImportTasksCommand}"/>
<StackPanel VerticalAlignment="Center" Margin="0,8,0,8" Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
<TextBlock Foreground="#969696" VerticalAlignment="Center" Text="起始步骤:"/>
<TextBox VerticalAlignment="Center" Width="40" Margin="0,0,5,0"
<TextBox VerticalAlignment="Bottom" Width="40"
Text="{Binding txtStarindex, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Foreground="#969696" VerticalAlignment="Center" Text="截止:"/>
<TextBox VerticalAlignment="Center" Width="40" Margin="0,0,5,0"
<TextBox VerticalAlignment="Bottom" Width="40"
Text="{Binding txtendindex, UpdateSourceTrigger=PropertyChanged}"/>
<CheckBox Content="飞机位置" Grid.Column="1" Margin="0,8,0,8" Foreground="#969696"
IsChecked="{Binding isimpCopterLoc}" />
</StackPanel>
<Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导入分组信息" Margin="25,8,0,8" Grid.Row="2"
Command="{Binding ImportGroupCommand}"/>
@ -162,7 +128,7 @@
</c:WindowCommands>
</c:MetroWindow.RightWindowCommands>
<Grid>
<Grid>
<Grid.Background>
<ImageBrush ImageSource=".\bg.jpg" />
</Grid.Background>
@ -224,10 +190,10 @@
Visibility="{Binding Source={x:Static local:AppEx.Current}, Path=AppMode, Converter={StaticResource AppModeToVisibilityConverter}, ConverterParameter=TaskBarView}" />
</Grid>
<Viewbox Stretch="Fill" Grid.Column="1" Margin="0,0,0,0">
<DockPanel>
<Grid Margin="0,0,0,0"
>
<Grid Margin="0,0,0,0"
Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
@ -256,8 +222,7 @@
<v:CopterInfoView DataContext="{Binding Path=CopterListViewModel.SelectedCopter}" />
</StackPanel>
</Grid>
</DockPanel>
</Viewbox>
</Grid>
<Border Grid.Row="1"
@ -265,22 +230,22 @@
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Margin="10,4"
Text="{Binding Message}" Width="480" MouseUp="LogShowHide"/>
Text="{Binding Message}" Width="400" MouseUp="LogShowHide"/>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
<TextBlock Margin="10,4" Width="280" Text="{Binding SysStatusText}" />
<TextBlock Margin="10,4"
Width="300" Text="{Binding SysStatusText}" />
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
<TextBlock Margin="10,4" Width="210"
Text="{Binding ControlPanelViewModelData.RTKState}" />
<TextBlock Margin="10,4" Width="400"
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
<TextBlock Margin="10,4" Width="400"
Text="{Binding ControlPanelViewModel.RTKState}" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="{Binding Loginstate}" Margin="0,4,14,0"/>
<TextBlock Text="广播端口:" Margin="4"/>
<ContentPresenter Margin="0,4,4,0" Content="{Binding BoardcastPortOpened, Converter={StaticResource CheckSignConverter2}, Mode=OneWay}" />
<TextBlock Text="通信连接:" Margin="4"/>
<ContentPresenter Margin="0,4,14,0" Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter2}, Mode=OneWay}" />
<ContentPresenter Margin="0,4,14,0" Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
</StackPanel>
</Grid>
@ -304,7 +269,6 @@
TextChanged="LogTextChange"
IsReadOnly="True"
TextWrapping="Wrap"
FontSize="14"
ContextMenu="{StaticResource LogMenu}"/>
</DockPanel>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="3" Margin="0,0,0,0" Background="MidnightBlue"
@ -319,6 +283,4 @@
</Grid>
</c:MetroWindow>

View File

@ -138,9 +138,7 @@ namespace Plane.FormationCreator
{
case Key.LeftCtrl:
case Key.RightCtrl:
case Key.LeftAlt:
{
{
var copters = _copterManager.AcceptingControlCopters;
Shiftkeydown = true;
_copterManager.shiftkeydown = true;
@ -424,8 +422,6 @@ namespace Plane.FormationCreator
switch (e.Key)
{
case Key.LeftCtrl:
case Key.RightCtrl:
case Key.LeftAlt:
{
Shiftkeydown = false;
_copterManager.shiftkeydown = false;

View File

@ -1,5 +1,4 @@
using Microsoft.Practices.ServiceLocation;
using Plane.FormationCreator.Util;
using Plane.FormationCreator.Util;
using System;
using System.Collections.Generic;
using System.Linq;
@ -44,15 +43,7 @@ namespace Plane.FormationCreator
private void Modify_Select(object sender, RoutedEventArgs e)
{
Formation.CopterManager _copterManager = ServiceLocator.Current.GetInstance<Formation.CopterManager>();
String strParamName = ((Button)sender).Tag.ToString();
if (strParamName == "FS_BATT_VOLTAGE")
{
if (_copterManager.FC_VER_NO >= 3)
strParamName = "BATT_LOW_VOLT";
}
textParamName.Text = strParamName;
textParamName.Text = ((Button)sender).Tag.ToString();
textParamName_cn.Text = ((Button)sender).Content.ToString();
}

View File

@ -9,28 +9,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.FormationCreator</RootNamespace>
<AssemblyName>FGCS</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -53,7 +38,6 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\FGCS.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>gcs.ico</ApplicationIcon>
@ -67,6 +51,9 @@
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="flyBase">
<HintPath>..\..\Tools\flyBase.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.2.0.37222, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.2.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
<Private>True</Private>
@ -107,9 +94,7 @@
<HintPath>..\packages\MaterialDesignThemes.1.4.0.473\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Expression.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Unnoficial.Microsoft.Expression.Drawing.1.0.0\lib\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Drawing, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Maps.MapControl.WPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll</HintPath>
<Private>True</Private>
@ -167,10 +152,7 @@
<Compile Include="AppEx.cs" />
<Compile Include="AppConfig.cs" />
<Compile Include="Converters\AppModeToVisibilityConverter.cs" />
<Compile Include="Converters\PrecheckToColorConverter.cs" />
<Compile Include="Converters\ErrorCodeToColorConverter.cs" />
<Compile Include="Converters\FlightTaskIsSelectedToEffectConverter.cs" />
<Compile Include="Converters\FlightTaskStatusAndTransitionToFillConverter.cs" />
<Compile Include="Converters\FlightTaskStatusToFillConverter.cs" />
<Compile Include="Converters\HeartbeatCountToBrushConverter.cs" />
<Compile Include="Formation\AppMode.cs" />
@ -215,12 +197,9 @@
</Compile>
<Compile Include="Util\ICommsSerial.cs" />
<Compile Include="Util\ICorrections.cs" />
<Compile Include="Util\nmea.cs" />
<Compile Include="Util\OptimizeRoute.cs" />
<Compile Include="Util\ParamFile.cs" />
<Compile Include="Util\PasswordBoxHelper.cs" />
<Compile Include="Util\rtcm3.cs" />
<Compile Include="Util\ubx_m8p.cs" />
<Compile Include="Util\VersionControl.cs" />
<Compile Include="ViewModels\CalibrationViewModel.cs" />
<Compile Include="ViewModels\ConfigVirtualIdViewModel.cs" />
@ -264,9 +243,6 @@
<Compile Include="Views\ChangePasswordView.xaml.cs">
<DependentUpon>ChangePasswordView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\InputDialog.xaml.cs">
<DependentUpon>InputDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LoginView.xaml.cs">
<DependentUpon>LoginView.xaml</DependentUpon>
</Compile>
@ -413,10 +389,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\InputDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\LoginView.xaml">
<SubType>Form</SubType>
<Generator>MSBuild:Compile</Generator>
@ -451,14 +423,6 @@
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\FlyCube\FlightRouteV2\FlightRouteV2.csproj">
<Project>{626a9bfa-07de-4063-a178-360eb7057ed6}</Project>
<Name>FlightRouteV2</Name>
</ProjectReference>
<ProjectReference Include="..\..\FlyTest\FlightRoute\FlightRoute.csproj">
<Project>{705aab55-ed7a-4856-8f7b-e7a78ed9e39a}</Project>
<Name>FlightRoute</Name>
</ProjectReference>
<ProjectReference Include="..\..\Plane.Libraries\Plane.Logging\Plane.Logging.csproj">
<Project>{9c2cafda-cf1d-4565-b797-398376fcd346}</Project>
<Name>Plane.Logging</Name>
@ -500,27 +464,6 @@
<ItemGroup>
<Resource Include="Resources\Logo_small.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\logo_big.png" />
</ItemGroup>
<ItemGroup>
<None Include="SplashScreen2.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<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

@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("北京飞行魔方科技有限公司")]
[assembly: AssemblyProduct("无人机编队地面控制系统")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.*")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.0.*")]
[assembly: AssemblyFileVersion("2.0.0.0")]

View File

@ -19,7 +19,7 @@ namespace Plane.FormationCreator.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[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 {
@ -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 {

View File

@ -12,7 +12,7 @@ namespace Plane.FormationCreator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
[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())));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -188,21 +188,22 @@ namespace Plane.Util
{
if (lat != 0 || lng != 0)
{
DateTime currentUtcTime = DateTime.UtcNow;
if (_lastnmea.AddSeconds(30) < currentUtcTime)
if (_lastnmea.AddSeconds(30) < DateTime.Now)
{
double latdms = (int)lat + ((lat - (int)lat) * .6f);
double lngdms = (int)lng + ((lng - (int)lng) * .6f);
var line = string.Format(System.Globalization.CultureInfo.InvariantCulture,
"$GP{0},{1:HHmmss.ff},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", "GGA",
currentUtcTime, Math.Abs(latdms * 100).ToString("0000.00"), lat < 0 ? "S" : "N",
DateTime.Now.ToUniversalTime(), Math.Abs(latdms * 100).ToString("0000.00"), lat < 0 ? "S" : "N",
Math.Abs(lngdms * 100).ToString("00000.00"), lng < 0 ? "W" : "E", 1, 10,
1, alt.ToString("0.00"), "M", 0, "M", "0.0", "0");
string checksum = GetChecksum(line);
WriteLine(line + "*" + checksum);
_lastnmea = currentUtcTime;
_lastnmea = DateTime.Now;
}
}
@ -260,7 +261,7 @@ namespace Plane.Util
retrys--;
}
throw new Exception("网络RTK基站通讯已关闭!");
throw new Exception("The ntrip is closed");
}
}

View File

@ -1,123 +0,0 @@
using System;
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using int32_t = System.Int32;
using uint32_t = System.UInt32;
using int8_t = System.SByte;
using System.Runtime.InteropServices;
namespace Plane.Util
{
public class nmea : ICorrections
{
int step = 0;
public byte[] buffer = new byte[1024 * 1];
int payloadlen = 0;
int msglencount = 0;
public int length
{
get
{
return 2 + 2 + 2 + 2 + payloadlen; // header2, class,subclass,length2,data,crc2
}
}
public byte[] packet
{
get
{
return buffer;
}
}
public bool resetParser()
{
step = 0;
return true;
}
public int Read(byte data)
{
switch (step)
{
default:
case 0:
if (data == '$')
{
step = 1;
msglencount = 0;
buffer[0] = data;
}
break;
case 1:
if (data == 'G')
{
buffer[1] = data;
step++;
}
else
step = 0;
break;
case 2:
if (msglencount > 1000)
{
step = 0;
}
buffer[msglencount + 2] = data;
msglencount++;
if(data == '\n')
{
var line = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, msglencount + 2);
string[] items = line.Trim().Split(',', '*');
if (items[items.Length-1] == GetChecksum(line))
{
return 1;
}
step = 0;
}
break;
}
return -1;
}
// Calculates the checksum for a sentence
string GetChecksum(string sentence)
{
// Loop through all chars to get a checksum
int Checksum = 0;
foreach (char Character in sentence.ToCharArray())
{
switch (Character)
{
case '$':
// Ignore the dollar sign
break;
case '*':
// Stop processing before the asterisk
return Checksum.ToString("X2");
default:
// Is this the first value for the checksum?
if (Checksum == 0)
{
// Yes. Set the checksum to the value
Checksum = Convert.ToByte(Character);
}
else
{
// No. XOR the checksum with this character's value
Checksum = Checksum ^ Convert.ToByte(Character);
}
break;
}
}
// Return the checksum formatted as a two-character hexadecimal
return Checksum.ToString("X2");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,573 +0,0 @@
using System;
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using int32_t = System.Int32;
using uint32_t = System.UInt32;
using int8_t = System.SByte;
using System.Runtime.InteropServices;
using System.Threading;
namespace Plane.Util
{
public class Ubx : ICorrections
{
int step = 0;
public byte[] buffer = new byte[1024 * 8];
int payloadlen = 0;
int msglencount = 0;
public byte @class
{
get { return buffer[2]; }
}
public byte subclass
{
get { return buffer[3]; }
}
public int length
{
get
{
return 2 + 2 + 2 + 2 + payloadlen; // header2, class,subclass,length2,data,crc2
}
}
public byte[] packet
{
get { return buffer; }
}
public bool resetParser()
{
step = 0;
return true;
}
public int Read(byte data)
{
switch (step)
{
default:
case 0:
if (data == 0xb5)
{
step = 1;
buffer[0] = data;
}
break;
case 1:
if (data == 0x62)
{
buffer[1] = data;
step++;
}
else
step = 0;
break;
case 2:
buffer[2] = data;
step++;
break;
case 3:
buffer[3] = data;
step++;
break;
case 4:
buffer[4] = data;
payloadlen = data;
step++;
break;
case 5:
buffer[5] = data;
step++;
payloadlen += (data << 8);
msglencount = 0;
// reset on oversize packet
if (payloadlen > buffer.Length)
step = 0;
break;
case 6:
if (msglencount < (payloadlen))
{
buffer[msglencount + 6] = data;
msglencount++;
if (msglencount == payloadlen)
step++;
}
break;
case 7:
buffer[msglencount + 6] = data;
step++;
break;
case 8:
buffer[msglencount + 6 + 1] = data;
var crc = ubx_checksum(buffer, payloadlen + 6);
var crcpacket = new byte[] { buffer[msglencount + 6], data };
if (crc[0] == crcpacket[0] && crc[1] == crcpacket[1])
{
step = 0;
return (@class << 8) + subclass;
}
step = 0;
break;
}
return -1;
}
private static byte[] ubx_checksum(byte[] packet, int size, int offset = 2)
{
uint a = 0x00;
uint b = 0x00;
var i = offset;
while (i < size)
{
a += packet[i++];
b += a;
}
var ans = new byte[2];
ans[0] = (byte)(a & 0xFF);
ans[1] = (byte)(b & 0xFF);
return ans;
}
public static byte[] generate(byte cl, byte subclass, byte[] payload)
{
var data = new byte[2 + 2 + 2 + 2 + payload.Length];
data[0] = 0xb5;
data[1] = 0x62;
data[2] = cl;
data[3] = subclass;
data[4] = (byte)(payload.Length & 0xff);
data[5] = (byte)((payload.Length >> 8) & 0xff);
Array.ConstrainedCopy(payload, 0, data, 6, payload.Length);
var checksum = ubx_checksum(data, data.Length - 2);
data[data.Length - 2] = checksum[0];
data[data.Length - 1] = checksum[1];
return data;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_mon_ver
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
public byte[] swVersion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public Byte[] hwVersion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
public byte[] extension;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_mon_hw
{
public int pinSel;
public int pinBank;
public int pinDir;
public int pinVal;
public ushort noisePerMS;
public ushort agcCnt;
public byte aStatus;
public byte aPower;
public byte flags;
public byte reserved1;
public int usedMask;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
public byte[] VP;
public byte jamInd;
public ushort reserved3;
public int pinIrq;
public int pullH;
public int pullL;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_nav_pvt
{
public uint32_t itow;
public uint16_t year;
public uint8_t month, day, hour, min, sec;
public uint8_t valid;
public uint32_t t_acc;
public int32_t nano;
public uint8_t fix_type;
public uint8_t flags;
public uint8_t flags2;
public uint8_t num_sv;
public int32_t lon, lat;
public int32_t height, h_msl;
public uint32_t h_acc, v_acc;
public int32_t velN, velE, velD, gspeed;
public int32_t head_mot;
public uint32_t s_acc;
public uint32_t head_acc;
public uint16_t p_dop;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public uint8_t[] reserved1;
public uint32_t headVeh;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint8_t[] reserved2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_nav_svin
{
public uint8_t version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint8_t[] reserved1;
public uint32_t iTOW;
public uint32_t dur;
public int32_t meanX;
public int32_t meanY;
public int32_t meanZ;
public int8_t meanXHP;
public int8_t meanYHP;
public int8_t meanZHP;
public uint8_t reserved2;
public uint32_t meanAcc;
public uint32_t obs;
public uint8_t valid;
public uint8_t active;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint8_t[] reserved3;
public double[] getECEF()
{
var X = meanX / 100.0 + meanXHP * 0.0001;
var Y = meanY / 100.0 + meanYHP * 0.0001;
var Z = meanZ / 100.0 + meanZHP * 0.0001;
return new double[] { X, Y, Z };
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_nav_velned
{
public uint iTOW;
public int velN;
public int velE;
public int velD;
public uint speed;
public uint gSpeed;
public int heading;
public uint sAcc;
public uint cAcc;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ubx_cfg_nav5_getset_s
{
public uint16_t mask;
public uint8_t dynModel;
public uint8_t fixMode;
public int32_t fixedAlt;
public uint32_t fixedAltVar;
public int8_t minElev;
public uint8_t drLimit;
public uint16_t pDop;
public uint16_t tDop;
public uint16_t pAcc;
public uint16_t tAcc;
public uint8_t staticHoldThresh;
public uint8_t dgnssTimeout;
public uint8_t cnoThreshNumSVs;
public uint8_t cnoThresh;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint8_t[] reserved1;
public uint16_t staticHoldMaxDist;
public uint8_t utcStandard;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public uint8_t[] reserved2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 40)]
public struct ubx_cfg_tmode3
{
public ubx_cfg_tmode3(double lat, double lng, double alt, double acc = 0.001)
{
version = 0;
reserved1 = 0;
if (Math.Abs(lat) > 90)
{
flags = 2; // fixed mode ecef
ecefXorLat = (int)(lat * 100);
ecefYorLon = (int)(lng * 100);
ecefZorAlt = (int)(alt * 100);
ecefXOrLatHP = (sbyte)((lat * 100 - ecefXorLat) * 100.0);
ecefYOrLonHP = (sbyte)((lng * 100 - ecefYorLon) * 100.0);
ecefZOrAltHP = (sbyte)((alt * 100 - ecefZorAlt) * 100.0);
}
else
{
flags = 256 + 2; // lla + fixed mode
ecefXorLat = (int)(lat * 1e7);
ecefYorLon = (int)(lng * 1e7);
ecefZorAlt = (int)(alt * 100.0);
ecefXOrLatHP = (sbyte)((lat * 1e7 - ecefXorLat) * 100.0);
ecefYOrLonHP = (sbyte)((lng * 1e7 - ecefYorLon) * 100.0);
ecefZOrAltHP = (sbyte)((alt * 100.0 - ecefZorAlt) * 100.0);
}
reserved2 = 0;
fixedPosAcc = (uint)(acc * 1000.0);
svinMinDur = 60;
svinAccLimit = 2000;
reserved3 = new byte[8];
}
public ubx_cfg_tmode3(uint DurationS, double AccLimit)
{
version = 0;
reserved1 = 0;
flags = 1; // surveyin mode
ecefXorLat = 0;
ecefYorLon = 0;
ecefZorAlt = 0;
ecefXOrLatHP = (sbyte)0;
ecefYOrLonHP = (sbyte)0;
ecefZOrAltHP = (sbyte)0;
reserved2 = 0;
fixedPosAcc = 0;
svinMinDur = DurationS;
svinAccLimit = (uint)(AccLimit * 10000);
reserved3 = new byte[8];
}
public static ubx_cfg_tmode3 Disable
{
get
{
return new ubx_cfg_tmode3()
{
flags = 0, // disable
reserved3 = new byte[8]
};
}
}
public static implicit operator byte[] (ubx_cfg_tmode3 input)
{
return null;// MavlinkUtil.StructureToByteArray(input);
}
public enum modeflags
{
Disabled = 0,
SurveyIn = 1,
FixedECEF = 2,
LLA = 256,
FixedLLA = 258
}
public byte version;
public byte reserved1;
public ushort flags;
public int ecefXorLat; // 1e7
public int ecefYorLon;
public int ecefZorAlt;
public sbyte ecefXOrLatHP;
public sbyte ecefYOrLonHP;
public sbyte ecefZOrAltHP;
public byte reserved2;
public uint fixedPosAcc;
public uint svinMinDur;
public uint svinAccLimit;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] reserved3;
public void SetupM8P(ICommsSerial port, bool m8p_130plus = false, bool movingbase = false)
{
port.BaseStream.Flush();
var bauds = new[] { port.BaudRate, 9600, 38400, 57600, 115200, 230400, 460800 };
// change the baudrate
foreach (var baud in bauds)
{
port.BaudRate = baud;
System.Threading.Thread.Sleep(50);
// U = bit 01010101 - often used for autobaud
port.Write("UU");
// port config - 460800 - uart1
var packet = generate(0x6, 0x00, new byte[]
{
0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x08,
0x07, 0x00, 0x23, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00
});
port.Write(packet, 0, packet.Length);
port.BaseStream.Flush();
System.Threading.Thread.Sleep(100);
}
{
// port config - usb
var packet = generate(0x6, 0x00, new byte[]
{
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x23, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00
});
port.Write(packet, 0, packet.Length);
System.Threading.Thread.Sleep(300);
port.BaseStream.Flush();
port.BaudRate = 460800;
}
{
// set rate to 1hz
var packet = generate(0x6, 0x8, new byte[] { 0xE8, 0x03, 0x01, 0x00, 0x01, 0x00 });
port.Write(packet, 0, packet.Length);
System.Threading.Thread.Sleep(200);
// set navmode to stationary
{
packet = generate(0x6, 0x24,
new byte[]
{
0xFF, 0xFF, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x0F, 0x00, 0xFA,
0x00,
0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x23, 0x10, 0x27, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00
});
port.Write(packet, 0, packet.Length);
System.Threading.Thread.Sleep(200);
}
}
// turn off all nmea
for (int a = 0; a <= 0xf; a++)
{
if (a == 0xb || a == 0xc || a == 0xe)
continue;
turnon_off(port, 0xf0, (byte)a, 0);
}
// mon-ver
poll_msg(port, 0xa, 0x4);
// surveyin msg - for feedback
turnon_off(port, 0x01, 0x3b, 1);
// pvt msg - for feedback
turnon_off(port, 0x01, 0x07, 1);
// 1005 - 5s
turnon_off(port, 0xf5, 0x05, 5);
byte rate1 = 1;
byte rate2 = 0;
if (m8p_130plus)
{
rate1 = 0;
rate2 = 1;
}
// 1074 - 1s
turnon_off(port, 0xf5, 0x4a, rate2);
// 1077 - 1s
turnon_off(port, 0xf5, 0x4d, rate1);
// 1084 - 1s
turnon_off(port, 0xf5, 0x54, rate2);
// 1087 - 1s
turnon_off(port, 0xf5, 0x57, rate1);
// 1094 - 1s
turnon_off(port, 0xf5, 0x5e, rate2);
// 1097 - 1s
turnon_off(port, 0xf5, 0x61, rate1);
// 1124 - 1s
turnon_off(port, 0xf5, 0x7c, rate2);
// 1127 - 1s
turnon_off(port, 0xf5, 0x7f, rate1);
// 4072
turnon_off(port, 0xf5, 0xFE, 0);
// 1230 - 5s
turnon_off(port, 0xf5, 0xE6, 5);
// NAV-VELNED - 1s
turnon_off(port, 0x01, 0x12, 1);
// rxm-raw/rawx - 1s
turnon_off(port, 0x02, 0x15, 1);
turnon_off(port, 0x02, 0x10, 1);
// rxm-sfrb/sfrb - 2s
turnon_off(port, 0x02, 0x13, 2);
turnon_off(port, 0x02, 0x11, 2);
// mon-hw - 2s
turnon_off(port, 0x0a, 0x09, 2);
System.Threading.Thread.Sleep(100);
}
public void turnon_off(ICommsSerial port, byte clas, byte subclass, byte every_xsamples)
{
byte[] datastruct1 = { clas, subclass, 0, every_xsamples, 0, every_xsamples, 0, 0 };
var packet = generate(0x6, 0x1, datastruct1);
port.Write(packet, 0, packet.Length);
System.Threading.Thread.Sleep(10);
}
public void poll_msg(ICommsSerial port, byte clas, byte subclass)
{
byte[] datastruct1 = { };
var packet = generate(clas, subclass, datastruct1);
port.Write(packet, 0, packet.Length);
System.Threading.Thread.Sleep(10);
}
}
}
}

View File

@ -139,47 +139,6 @@ namespace Plane.FormationCreator.ViewModels
}
public bool IsCalibration { get; set; }
/// <summary>
/// 重启飞控
/// </summary>
private ICommand _RestartFCCommand;
public ICommand RestartFCCommand
{
get
{
return _RestartFCCommand ?? (_RestartFCCommand = new RelayCommand(async () =>
{
if (_copterManager.SelectedCopters.Count() == 0) return;
Message.Show("重启飞控");
await commModule.DoRestartFCAsync(_copterManager.SelectedCopters);
await Task.Delay(50).ConfigureAwait(false);
}));
}
}
/// <summary>
/// 陀螺仪校准
/// </summary>
private ICommand _CalibrationPreflightCommand;
public ICommand CalibrationPreflightCommand
{
get
{
return _CalibrationPreflightCommand ?? (_CalibrationPreflightCommand = new RelayCommand(async () =>
{
if (_copterManager.SelectedCopters.Count() == 0) return;
Message.Show("开始校准陀螺仪");
await commModule.DoCalibrationPreflightAsync(_copterManager.SelectedCopters);
await Task.Delay(50).ConfigureAwait(false);
}));
}
}
/// <summary>
/// 校准指南针
/// </summary>

View File

@ -108,9 +108,7 @@ namespace Plane.FormationCreator.ViewModels
copter.VirtualId = int.Parse(arrs[1]);
}
}
_copterManager.SortType = CopterManager.CopterSortType.ByVID;// .sortbyvid();
Message.Show($"读入成功");
Message.Show($"读入成功");
}));
}
}
@ -143,7 +141,6 @@ namespace Plane.FormationCreator.ViewModels
copter.VirtualId = SingleVirtualId;
Message.Show($"飞机{copter.Name} 设置编号={SingleVirtualId}");
}
_copterManager.ReSort();
}));
}
@ -166,20 +163,14 @@ namespace Plane.FormationCreator.ViewModels
float StepDis_Row = _flightTaskManager.ColumnDistance; //行内间距-列间距
float StepDis_Col = _flightTaskManager.RowDistance ; //列间距-行间距
float FindDis =Math.Min(StepDis_Row, StepDis_Col)*0.8f; //查找半径
//如果选中的飞机总数大于2--需要2-3架用来确认行列方向只有一行飞机就选2架多行需要3架
if (_copterManager.AcceptingControlCopters.Count() >= 2)
{
var copters = _copterManager.AcceptingControlCopters.ToList();
var firstCopter = copters[0];
var secondCopter = copters[1];
ICopter thirdCopter=null;
if (_copterManager.AcceptingControlCopters.Count() > 2)
{
if (_copterManager.AcceptingControlCopters.Count()>2)
thirdCopter = copters[2];
Message.Show($"选中了3架飞机将自动查找所有行列的飞机");
}
else
Message.Show($"选中了2架飞机将查找一行飞机");
//行角度(1,2) 用于查找每行的飞机位置
@ -192,39 +183,23 @@ namespace Plane.FormationCreator.ViewModels
ICopter LastCopter = firstCopter;
ILocation2D LastRowHewadCopter = firstCopter;
Message.Show($"开始查找飞机:行角度{RowDirect},列角度{ColDirect},列间距{StepDis_Row},行间距{StepDis_Col},查找半径{FindDis}米...");
firstCopter.VirtualId = 1;
int rowindex = 1;
while (FindedCopter!=null)
{
//按一行找飞机
FindedCopter = FindNextCopter(LastCopter, RowDirect, StepDis_Row, FindDis);
//一行找不到了 找下一行的前3架飞机
if ((FindedCopter == null) && (thirdCopter != null))
{
rowindex++;
FindedCopter = FindNextColHeadCopter(out LastRowHewadCopter, LastRowHewadCopter, ColDirect, StepDis_Col, RowDirect, StepDis_Row, 3, FindDis);
if (FindedCopter != null)
Message.Show($"开始第{rowindex}行--找到飞机");
else
Message.Show($"开始第{rowindex}行--无飞机");
}
//如果找到了分配ID
if ((FindedCopter == null)&&(thirdCopter!=null))
FindedCopter = FindNextColHeadCopter(out LastRowHewadCopter,LastRowHewadCopter, ColDirect, StepDis_Col, RowDirect, StepDis_Row, 3, FindDis);
//如果找到了分配ID
if (FindedCopter != null)
{
FindedCopter.VirtualId = GetVID(LastCopter.VirtualId);
// Message.Show($"分配ID={FindedCopter.Id}飞机VID:={FindedCopter.VirtualId}");
Message.Show($"分配飞机VID:{FindedCopter.VirtualId}");
LastCopter = FindedCopter;
}else
{
Message.Show($"未找到飞机,自动分配结束");
}
}
}
}
_copterManager.ReSort();
}));
}
}

View File

@ -25,31 +25,16 @@ using Plane.Protocols;
using Microsoft.Practices.ServiceLocation;
using System.Windows.Media;
using Plane.FormationCreator.Views;
using System.Collections.ObjectModel;
using Plane.Util;
using System.IO.Ports;
using SerialPort = Plane.Util.SerialPort;
namespace Plane.FormationCreator.ViewModels
{
public class ConnectViewModel : ViewModelBase
{
public ConnectViewModel(CopterManager copterManager)
{
_copterManager = copterManager;
RefreshPorts();
}
public void RefreshPorts()
{
serialRePorts.Clear();
string[] commports = SerialPort.GetPortNames();
foreach (var item in commports)
{
serialRePorts.Add(item);
}
}
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
private CopterManager _copterManager;
private const int PORT = 5250;
@ -82,16 +67,6 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(IsProcessing), ref _IsProcessing, value); }
}
public ObservableCollection<string> serialRePorts { get; } = new ObservableCollection<string>();
private string _serialPortResend;
public string SerialPortResend
{
get { return _serialPortResend; }
set { Set(nameof(SerialPortResend), ref _serialPortResend, value); }
}
private ICommand _ConnectCommand;
public ICommand ConnectCommand
{
@ -104,66 +79,6 @@ namespace Plane.FormationCreator.ViewModels
));
}
}
RtcmInfoViewModel _rtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
private ICommand _Openboardport;
public ICommand Openboardport
{
get
{
return _Openboardport ?? (_Openboardport = new RelayCommand<string>(async connectionType =>
{
if (btnBoardPortStr== "关闭广播端口")
{
//关闭广播端口
//正在发送rtcm数据并且使用了广播端口
if (_rtcmInfoViewModel.RtcmManager.Rtcmthreadrun&& _rtcmInfoViewModel.ResendToComMK)
{
if (Alert.Show("正在使用广播端口发送RTCM数据关闭后广播端口将停止发送,继续吗?", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
== MessageBoxResult.OK)
{
// _rtcmInfoViewModel.ResendToComMK = false;
}
else
{
return;
}
}
//关闭同时清除广播端口,这样就不会重试打开
_commModuleManager.CloseResendRtcmserial(true);
btnBoardPortStr = "打开广播端口";
BoardPortStatusStr = _commModuleManager.BoardPortStatusStr;
Message.BoardOpen(false);
}
else
{ //打开广播端口
if ((SerialPortResend != null))
{
if (!_commModuleManager.OpenResendRtcmserial(SerialPortResend))
{
Alert.Show($"打开串口失败", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
btnBoardPortStr = "关闭广播端口";
Message.BoardOpen(true);
}
BoardPortStatusStr = _commModuleManager.BoardPortStatusStr;
}
else
{
Alert.Show($"请选择需要广播的端口", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
}
_rtcmInfoViewModel.SetRTKStatestr();
}
));
}
}
private ICommand _SendCommand;
public ICommand SendCommand
@ -234,20 +149,6 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(CopterColor), ref _CopterColor, value); }
}
private string _BoardPortStatusStr = "广播端口未打开";
public string BoardPortStatusStr
{
get { return _BoardPortStatusStr; }
set { Set(nameof(BoardPortStatusStr), ref _BoardPortStatusStr, value); }
}
private string _btnBoardPortStr = "打开广播端口";
public string btnBoardPortStr
{
get { return _btnBoardPortStr; }
set { Set(nameof(btnBoardPortStr), ref _btnBoardPortStr, value); }
}
private ICommand _WriteIdCommand;
public ICommand WriteIdCommand
{
@ -341,35 +242,6 @@ namespace Plane.FormationCreator.ViewModels
}));
}
}
private ICommand _TestModuleCommand;
public ICommand TestModuleCommand
{
get
{
return _TestModuleCommand ?? (_TestModuleCommand = new RelayCommand(async () =>
{
await commModule.TestModule((short)scale3d);
}));
}
}
private ICommand _SetModulePowerCommand;
public ICommand SetModulePowerCommand
{
get
{
return _SetModulePowerCommand ?? (_SetModulePowerCommand = new RelayCommand(async () =>
{
int mPower = int.Parse(CopterColor);
await commModule.SetModulePower((short)CopterNum, (short)mPower);
}));
}
}
private ICommand _CommDataAsync;
public ICommand CommDataAsync
{
@ -383,27 +255,6 @@ namespace Plane.FormationCreator.ViewModels
}
}
private ICommand _TestPWMCommandAsync;
public ICommand TestPWMCommandAsync
{
get
{
return _TestPWMCommandAsync ?? (_TestPWMCommandAsync = new RelayCommand(async () =>
{
try
{
int channel = 10; //固定10是控制PWM舵机
await commModule.TestFire((short)CopterNum, channel);
}
catch
{ }
}
));
}
}
private ICommand _TestFireCommandAsync;
public ICommand TestFireCommandAsync
{
@ -415,7 +266,7 @@ namespace Plane.FormationCreator.ViewModels
{
int channel = int.Parse(CopterColor);
if (channel >= 0 && channel <= 4)
await commModule.TestFire((short)CopterNum, channel);
await commModule.TestFire((short)CopterNum, channel);
}
catch
{ }

View File

@ -119,77 +119,38 @@ namespace Plane.FormationCreator.ViewModels
{
return _DetectionVoltage ?? (_DetectionVoltage = new RelayCommand(async () =>
{
Message.Show("--------------开始检测电压--------------");
Dictionary<string, float> dic_voltage = new Dictionary<string, float>();
await Task.WhenAll(_copterManager.Copters.Select(async c =>
{
float voltageSum = 0.0f;
string name = c.Name;
float minVol;
InputDialog inputDialog = new InputDialog("最低检测电压( 0 恢复灯光):", "15.6");
if (inputDialog.ShowDialog() == true)
minVol = float.Parse(inputDialog.Answer);
else return;
//测试电池
await _commModuleManager.TestBattery((short)0, minVol);
if (minVol == 0.0) return;
Message.Show("---请检查飞机灯光---");
Message.Show(string.Format("---绿 色 电压高于 {0:F2}v (单节高于 {1:F2}v)--- ", minVol, minVol / 4.0f));
Message.Show(string.Format("---黄 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol, minVol / 4.0f));
Message.Show(string.Format("---棕 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.2, (minVol - 0.2) / 4.0f));
Message.Show(string.Format("---洋红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.4, (minVol - 0.4) / 4.0f));
Message.Show(string.Format("---亮红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.6, (minVol - 0.6) / 4.0f));
Message.Show("---输入0恢复灯光---");
Message.Show("--------------开始检测单机电压--------------");
Dictionary<string, float> dic_voltage = new Dictionary<string, float>();
await Task.WhenAll(_copterManager.Copters.Select(async c =>
for (int i = 0; i < 5; i++)
{
float voltageSum = 0.0f;
string name = c.Name;
for (int i = 0; i < 5; i++)
voltageSum += c.Voltage;
await Task.Delay(1000).ConfigureAwait(false);
}
float voltageAverage = voltageSum / 5;
if (name != null && name != "")
{
lock(locker)
{
voltageSum += c.Voltage;
await Task.Delay(1000).ConfigureAwait(false);
dic_voltage.Add(name, voltageAverage);
}
float voltageAverage = voltageSum / 5;
if (name != null && name != "")
{
lock (locker)
{
dic_voltage.Add(name, voltageAverage);
}
}
})).ConfigureAwait(false);
}
})).ConfigureAwait(false);
await Task.Run(async () => {
Dictionary<string, float> dic_voltage_Order = dic_voltage.OrderByDescending(o => o.Value).ToDictionary(o => o.Key, o => o.Value);
bool showch = false;
ICopter vcopter = null;
_copterManager.shiftkeydown = true;
//清除选择
_copterManager.Select(null);
foreach (KeyValuePair<string, float> kv in dic_voltage_Order)
{
if ((!showch) && (minVol > 0.00) && (kv.Value <= minVol))
{
Message.Show(string.Format("以下飞机电压低于[{0}V单节{1:F2}]", minVol, minVol / 4));
showch = true;
}
Message.Show(string.Format("{0} --> 5秒平均电压{1:F2},单节{2:F2}", kv.Key, kv.Value, kv.Value / 4));
//选中低电压飞机
if ((minVol > 0.00) && (kv.Value <= minVol))
{
vcopter = _copterManager.Copters.FirstOrDefault(o => o.Name == kv.Key);
if (vcopter != null)
_copterManager.Select(vcopter); //需要访问UI线程
}
Message.Show(string.Format("{0} --> 5秒平均电压{1}", kv.Key, kv.Value));
await Task.Delay(5).ConfigureAwait(false);
}
await Task.Delay(500).ConfigureAwait(false);
_copterManager.shiftkeydown = false;
Message.Show(string.Format("----检测电压完成,检测总数:{0}----", dic_voltage.Count));
//todo:增加电压阈值变成不同颜色灯
}).ConfigureAwait(false);
}));
}
}
@ -257,7 +218,7 @@ namespace Plane.FormationCreator.ViewModels
Array.Reverse(test);
string data = string.Join(".", test);
string copters = string.Join(",", kv.Value.ToArray());
Message.Show(string.Format("返回数据{0}({1}){2}", data, kv.Key,copters));
Message.Show(string.Format("返回数据{0}{1}", data, copters));
await Task.Delay(5).ConfigureAwait(false);
}
Message.Show("----统计完成----");
@ -277,9 +238,6 @@ namespace Plane.FormationCreator.ViewModels
if (_copterManager.Copters.Count > 0)
{
Dictionary<string, List<string>> GPSTypes = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> Heading = new Dictionary<string, List<string>>();
foreach (var copter in _copterManager.Copters)
{
string name = copter.Name;
@ -291,39 +249,12 @@ namespace Plane.FormationCreator.ViewModels
}
else
GPSTypes[copter.GpsFixType.ToString()].Add(name);
if (!Heading.Keys.Contains(copter.Heading.ToString()))
{
List<string> copterNames = new List<string>();
copterNames.Add(name);
Heading.Add(copter.Heading.ToString(), copterNames);
}
else
Heading[copter.Heading.ToString()].Add(name);
}
Message.Show($"==定位状态==");
foreach (var item in GPSTypes)
{
Message.Show($"{item.Key}:{string.Join(",", item.Value)}");
Message.Show($"------------");
}
Message.Show($"==机头方向==");
//从小到大排个序
Dictionary<string, List<string>> SortedHeading = Heading.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
foreach (var item in SortedHeading)
{
Message.Show($"{item.Key} 度:{string.Join(",", item.Value)}");
Message.Show($"------------");
}
}
await Task.Delay(10);
}));
@ -395,86 +326,6 @@ namespace Plane.FormationCreator.ViewModels
}
}
private ICommand _ResetRealMissionCommand;
public ICommand ResetRealMissionCommand
{
get
{
return _ResetRealMissionCommand ?? (_ResetRealMissionCommand = new RelayCommand(async () =>
{
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
_flightTaskManager.RealResetTask();
AllowMissionStart = true;
}));
}
}
/// <summary>
/// 紧急返航:计算当前图案中心点,起飞图案中心点,图案距离起飞图案中心点最近距离
/// 条件:任务已经开始,且飞行器已经飞行
/// 可用于模拟和实际飞行,
/// 1首先需要导入最后的飞行任务文件
/// 2实际飞机需要执行解锁和开始任务
/// 3模拟任务需要开始任务并且暂停任务才能计算
/// </summary>
private ICommand _EmergencyRetCommand;
public ICommand EmergencyRetCommand
{
get
{
return _EmergencyRetCommand ?? (_EmergencyRetCommand = new RelayCommand(async () =>
{
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
if (_flightTaskManager.Tasks.Count==0)
{
Alert.Show("没有航点无法紧急返航!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if ((_flightTaskManager.TaskState_real == TasksStatus.Stop)
&&((_flightTaskManager.IsPaused ?? false) == false))
{
Alert.Show("没有开始真实任务,模拟紧急返航需要先暂停模拟任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
//if (Alert.Show("您确定要紧急返航吗?紧急返航可能导致飞行器碰撞!!!!", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
// != MessageBoxResult.OK)
// return;
//计算当前图案中心点,起飞图案中心点,图案距离起飞图案中心点最近距离
//计算无人机返航方向和最近的飞机距离
PLLocation takeoffcentloc;
PLLocation taskcentloc;
double mindistance; //单位米
bool overlapping; //图案否重叠
int rettime=0;
if (_flightTaskManager.TaskState_real!= TasksStatus.Stop)
//计算实际飞行时间
rettime = (int)(DateTime.UtcNow - _flightTaskManager.TaskStartTime_real).TotalSeconds;
else
if (_flightTaskManager.TaskState!= TasksStatus.Stop)
//计算模拟飞行时间
rettime = (int)_flightTaskManager.taskflyTime.TotalSeconds;
if (!_flightTaskManager.EmergencyRet(rettime,out takeoffcentloc,out taskcentloc, out mindistance,out overlapping))
{
Alert.Show("紧急返航数据计算失败!", "提示");
return;
}
//模拟测试
if (_flightTaskManager.TaskState != TasksStatus.Stop)
await _flightTaskManager.sim_DoMissionEmergencyRetAsync(takeoffcentloc, taskcentloc, (float)mindistance, rettime, overlapping);
for (int i = 0; i < 10; i++)
{
await _commModuleManager.DoMissionEmergencyRetAsync(takeoffcentloc,taskcentloc,(float)mindistance, rettime, overlapping);
}
}));
}
}
private ICommand _LEDFlickerCommand;
public ICommand LEDFlickerCommand
{
@ -487,30 +338,6 @@ namespace Plane.FormationCreator.ViewModels
}
}
private ICommand _DelCommand;
public ICommand DelCommand
{
get
{
return _DelCommand ?? (_DelCommand = new RelayCommand(async () =>
{
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
{
if (_flightTaskManager.Tasks.Count > 0)
{
Alert.Show("有航点任务无法删除飞机,请先清除航点!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
await _copterManager.DelSelCopters();
}
}));
}
}
private ICommand _MotorTestCommand;
public ICommand MotorTestCommand
{
@ -588,8 +415,7 @@ namespace Plane.FormationCreator.ViewModels
await Task.Delay(1000).ConfigureAwait(false);
}
await Task.Delay(100);
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
AllowMissionStart = (_flightTaskManager.TaskState_real == TasksStatus.Stop);
AllowMissionStart = true;
/*
await Task.WhenAll(_copterManager.Copters.Select(async c => {
@ -728,72 +554,7 @@ namespace Plane.FormationCreator.ViewModels
{
return _TakeOffCommand ?? (_TakeOffCommand = new RelayCommand(async () =>
{
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
{
Alert.Show("作为参照的原点未设置,无法开始任务!", "提示");
return;
}
//飞机用UTC时间日志用本地时间记录
DateTime MissionTime = DateTime.UtcNow.AddSeconds(5);
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
Message.Show("任务开始:" + MissionTime_log.ToString());
IEnumerable<ICopter> selcopters = _copterManager.AcceptingControlCopters;
//循环3次 发送起飞命令 避免通信问题
for (int i = 0; i < 20; i++)
{
/*await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
MissionTime.Hour,
MissionTime.Minute,
MissionTime.Second,
_flightTaskManager.OriginLng,
_flightTaskManager.OriginLat
);
*/
await _commModuleManager.DoMissionStartAsync(selcopters,
MissionTime.Hour,
MissionTime.Minute,
MissionTime.Second,
_flightTaskManager.OriginLng,
_flightTaskManager.OriginLat
);
/* await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.MissionStartAsync(
MissionTime.Hour,
MissionTime.Minute,
MissionTime.Second,
_flightTaskManager.OriginLng,
_flightTaskManager.OriginLat
)));
*/
await Task.Delay(20).ConfigureAwait(false);
}
//_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
Alert.Show("所有选中飞机开始执行航点任务。请勿多次开始任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}));
}
}
private ICommand _ThrowoutCommand;
public ICommand ThrowoutCommand
{
get
{
return _ThrowoutCommand ?? (_ThrowoutCommand = new RelayCommand( () =>
{
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
_commModuleManager.ThrowoutAsync(_copterManager.AcceptingControlCopters);
await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.TakeOffAsync()));
}));
}
}
@ -853,18 +614,7 @@ namespace Plane.FormationCreator.ViewModels
}));
}
}
private ICommand _GetCommsumCommand;
public ICommand GetCommsumCommand
{
get
{
return _GetCommsumCommand ?? (_GetCommsumCommand = new RelayCommand(async () =>
{
//if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
await _commModuleManager.GetCommsumAsync();
}));
}
}
//打开校准界面
private ICommand _CalibrationSingleCommand;
public ICommand CalibrationSingleCommand
@ -1485,27 +1235,14 @@ namespace Plane.FormationCreator.ViewModels
Alert.Show("作为参照的原点未设置,无法开始任务!", "提示");
return;
}
if (_flightTaskManager.Tasks.Count == 0 )
{
if (Alert.Show("没有导入任务,紧急返航功能不能使用,继续吗?", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
!= MessageBoxResult.OK)
return;
}
//飞机用UTC时间日志用本地时间记录
DateTime MissionTime = DateTime.UtcNow.AddSeconds(5);
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
if (!_flightTaskManager.RealRunTask(MissionTime))
{
Alert.Show("任务已经开始,请先重设任务!", "提示");
return;
}
AllowMissionStart = false;
Message.Show("任务开始:" + MissionTime_log.ToString());
//循环3次 发送起飞命令 避免通信问题
for (int i = 0; i < 20; i++) //20
for (int i = 0; i < 10; i++)
{
await _commModuleManager.DoMissionStartAsync(null,
await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
MissionTime.Hour,
MissionTime.Minute,
MissionTime.Second,
@ -1525,7 +1262,7 @@ namespace Plane.FormationCreator.ViewModels
}
*/
await Task.Delay(20).ConfigureAwait(false);
await Task.Delay(10).ConfigureAwait(false);
}
_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
@ -1596,14 +1333,6 @@ namespace Plane.FormationCreator.ViewModels
Alert.Show("作为参照的原点未设置,无法写入相对位置!", "提示");
return;
}
var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
if (_RtcmInfoViewModel.RtcmManager.Rtcmthreadrun)
{
Alert.Show("RTK数据正在发送将自动关闭", "提示");
await _RtcmInfoViewModel.RtcmManager.Close(_RtcmInfoViewModel.SerialPortsSelectdValue);
}
int taskcount = _flightTaskManager.Tasks.Count;
if (taskcount < 2) return;
foreach (var copter in _copterManager.AcceptingControlCopters)
@ -1629,13 +1358,6 @@ namespace Plane.FormationCreator.ViewModels
Alert.Show("作为参照的原点未设置,无法写入相对位置!", "提示");
return;
}
var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
if (_RtcmInfoViewModel.RtcmManager.Rtcmthreadrun)
{
Alert.Show("RTK数据正在发送将自动关闭", "提示");
await _RtcmInfoViewModel.RtcmManager.Close(_RtcmInfoViewModel.SerialPortsSelectdValue);
}
int coptercount = _copterManager.Copters.Count;
int taskcount = _flightTaskManager.Tasks.Count;
if (taskcount < 2) return;
@ -1674,15 +1396,13 @@ namespace Plane.FormationCreator.ViewModels
if (_RtcmInfoViewModel.RtcmManager.Rtcmthreadrun)
{
Alert.Show("RTK数据正在发送将自动关闭", "提示");
await _RtcmInfoViewModel.RtcmManager.Close(_RtcmInfoViewModel.SerialPortsSelectdValue);
await _RtcmInfoViewModel.RtcmManager.Close();
}
Alert.Show("开始写入航点,飞机绿色成功红色失败!(先关灯再开灯可恢复飞机灯光)", "提示");
Alert.Show("开始写入航点,请稍等!", "提示");
_commModuleManager.ClearMissionWriteState();
for (int i = 0; i < coptercount; i++)
{
//虚拟飞机不用写航点跳过
if (_copterManager.Copters[i] is FakeCopter) continue;
///写航线开始
await CollectMissions(i).ConfigureAwait(false);
}
@ -1691,8 +1411,8 @@ namespace Plane.FormationCreator.ViewModels
}
}
/// <summary>
/// 用通讯模块 写入航点信息
/// <summary>
/// 收集航点信息
/// </summary>
/// <param name="i">copterIndex</param>
/// <returns></returns>
@ -1711,14 +1431,14 @@ namespace Plane.FormationCreator.ViewModels
switch (_flightTaskManager.Tasks[j].TaskType)
{
case FlightTaskType.TakeOff:
//int takeofftime = (int)(_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetAlt / 2.5 + 5);
int takeofftime = (int)(_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetAlt / 2.5 + 5);
missions.AddRange(CreateLEDMissions(_flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos));
missions.Add(Mission.CreateTakeoffMission(
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TakeOffWaitTime, //起飞等待时间
_flightTaskManager.Tasks[j].TakeOffTime, //起飞时间
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat, //位置没用
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng, //位置没用
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetAlt - groudAlt) //下一个航点的高度
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TakeOffWaitTime,
_flightTaskManager.Tasks[j].TakeOffTime,
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat,
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng,
_flightTaskManager.Tasks[j + 1].SingleCopterInfos[i].TargetAlt - groudAlt)
);
break;
@ -1735,7 +1455,6 @@ namespace Plane.FormationCreator.ViewModels
double Lat = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat;
double Lng = _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng;
//如果是返航点,位置写入固定值,这样直接返回起飞点
if (_flightTaskManager.Tasks[j].SingleCopterInfos[i].IsLandWaypoint)
{
Lat = 90;
@ -1762,37 +1481,23 @@ namespace Plane.FormationCreator.ViewModels
break;
}
}
//186是通讯模块的限制--张伟那边
if (missions.Count > 186)
//虚拟ID在排序时已经变为ID了直接按ID写入
// var targetCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == (i+1));
// bool result = await _commModuleManager.WriteMissionListAsync(targetCopter, missions);
bool result = await _commModuleManager.WriteMissionListAsync(_copterManager.Copters[i], missions);
//CommWriteMissinState state = new CommWriteMissinState(result);
//_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state);
if (!result)
{
Message.Show($"飞机:{_copterManager.Copters[i].VirtualId} 航点数量超过186请减少再重写该飞机!");
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输失败!");
}
else
{
//虚拟ID在排序时已经变为ID了直接按ID写入
// var targetCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == (i+1));
// bool result = await _commModuleManager.WriteMissionListAsync(targetCopter, missions);
bool result = await _commModuleManager.WriteMissionListAsync(_copterManager.Copters[i], missions);
//CommWriteMissinState state = new CommWriteMissinState(result);
//_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state);
if (!result)
{
if (_copterManager.SortType == CopterManager.CopterSortType.ByVID)
Message.Show($"飞机:{_copterManager.Copters[i].VirtualId} 通信模块传输失败!");
else
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输失败!");
}
else
{
if (_copterManager.SortType == CopterManager.CopterSortType.ByVID)
Message.Show($"飞机:{_copterManager.Copters[i].VirtualId} 通信模块传输完成!");
else
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输完成!");
}
await Task.Delay(500).ConfigureAwait(false);
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输完成!");
}
await Task.Delay(500).ConfigureAwait(false);
}
catch (Exception ex)
{
@ -1806,38 +1511,14 @@ namespace Plane.FormationCreator.ViewModels
List<IMission> missions = new List<IMission>();
foreach (LEDInfo ledInfo in LEDInfos)
{
float ledinterval=0;
Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB);
int ledMode = ledInfo.LEDMode;
//拉烟任务模式ID是50需要改为50
if (_copterManager.FC_VER_NO == 1)
{
//老版本是闪烁频率,且不能为小数
ledinterval = ledInfo.LEDInterval;
//老版本ledMode == 8 对应拉烟飞控对应50,ledinterval对应通道号
if (ledMode==8) ledMode = 50;
}
else
{
//新版本飞控 是闪烁间隔单位是100ms地面站还是频率可以有1位小数,用户输入0.5hz 飞控应该是(1/0.5)*10=20
ledinterval = (1 / ledInfo.LEDInterval);
//新版本 ledMode=16是抛物飞控对应50ledinterval对应10 --固定的
if (ledMode == 16)
{
ledMode = 50;
ledinterval = 10;
}
else //新版本ledMode == 15 对应拉烟飞控对应50,ledinterval对应通道号
if (ledMode == 15)
{
ledMode = 50;
}
}
if (ledMode == 8) ledMode = 50;
IMission LEDMission = Mission.CreateLEDControlMission(
(int)(ledInfo.Delay * 10),
ledMode,
ledinterval,
ledInfo.LEDInterval,
0, //ledInfo.LEDTimes,
color.R,
color.G,

View File

@ -93,12 +93,6 @@ namespace Plane.FormationCreator.ViewModels
get { return _IntervalNum; }
set { Set(nameof(IntervalNum), ref _IntervalNum, value); }
}
private int _RowNum;
public int RowNum
{
get { return _RowNum; }
set { Set(nameof(RowNum), ref _RowNum, value); }
}
private int _ContinuousNum;
public int ContinuousNum
@ -117,19 +111,6 @@ namespace Plane.FormationCreator.ViewModels
public ObservableCollection<string[]> CopterGroups { get; } = new ObservableCollection<string[]>();
private int getNextcopterindex( int currindex)
{
//每行数量
int colcount = _flightTaskManager.ColumnCount;
int newind = currindex;
for (int i = 0;i< IntervalNum;i++)
{
newind +=1;
if ((newind % colcount) == 0)
newind += RowNum * colcount;
}
return newind;
}
private ICommand _IntervalSelectCoptersCommand;
public ICommand IntervalSelectCoptersCommand
@ -145,21 +126,6 @@ namespace Plane.FormationCreator.ViewModels
_copterManager.Select(null);
int index = _copterManager.Copters.IndexOf(copter);
_copterManager.shiftkeydown = true;
int colcount = _flightTaskManager.ColumnCount;
for (; index < _copterManager.Copters.Count; index= getNextcopterindex( index) )
{
for (int i = 0; i < ContinuousNum; i++)
{
if (index >= _copterManager.Copters.Count) break;
_copterManager.Select(_copterManager.Copters[index]);
index += 1;
if ((index % colcount) == 0)
index += RowNum * colcount;
getNextcopterindex(index);
}
}
/*
for (; index < _copterManager.Copters.Count; index += IntervalNum)
{
for (int i = 0; i < ContinuousNum; i++)
@ -169,7 +135,6 @@ namespace Plane.FormationCreator.ViewModels
index++;
}
}
*/
_copterManager.shiftkeydown = false;
}));
@ -204,9 +169,16 @@ namespace Plane.FormationCreator.ViewModels
{
return _SortbyVIdCommand ?? (_SortbyVIdCommand = new RelayCommand( () =>
{
_copterManager.SortType = CopterManager.CopterSortType.ByVID;
_copterManager.sortbyvid();
foreach (var copter in _copterManager.Copters)
{
copter.DisplayVirtualId = true;
copter.DisplayID = false;
}
//强制刷新飞机显示
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
}));
@ -221,10 +193,14 @@ namespace Plane.FormationCreator.ViewModels
{
return _SortbyIdCommand ?? (_SortbyVIdCommand = new RelayCommand(() =>
{
_copterManager.SortType = CopterManager.CopterSortType.ByID;
_copterManager.sortbyid();
foreach (var copter in _copterManager.Copters)
{
copter.DisplayVirtualId = false;
copter.DisplayID = true;
}
//强制刷新飞机显示
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
}));
}
@ -247,6 +223,24 @@ namespace Plane.FormationCreator.ViewModels
}
}
bool showVirtualId = false;
private ICommand _SwitchIdVirtualIdCommand;
public ICommand SwitchIdVirtualIdCommand
{
get
{
return _SwitchIdVirtualIdCommand ?? (_SwitchIdVirtualIdCommand = new RelayCommand(() =>
{
showVirtualId = !showVirtualId;
foreach (var copter in _copterManager.Copters)
{
copter.DisplayVirtualId = showVirtualId;
}
}));
}
}
@ -257,9 +251,11 @@ namespace Plane.FormationCreator.ViewModels
{
return _ShowAllIDCommand ?? (_ShowAllIDCommand = new RelayCommand(() =>
{
_copterManager.SortType = CopterManager.CopterSortType.ByVIDShowAll;
foreach (var copter in _copterManager.Copters)
{
copter.DisplayVirtualId = true;
copter.DisplayID = true;
}
//强制刷新飞机显示
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
@ -371,15 +367,10 @@ namespace Plane.FormationCreator.ViewModels
id: id,
name: id
);
if (_copterManager.FC_VER_NO >= 3)
copter.FlightControlMode = 1;
else copter.FlightControlMode = 0;
//不再预先分配VID
// copter.VirtualId = _virtualCopterId;
await copter.ConnectAsync();
await copter.GetCopterDataAsync();
_copterManager.Copters.AddCopter(copter);
_copterManager.CopterStatus.Add(false);
_copterManager.Copters.AddCopter(copter, _copterManager.SortType);
}
}
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
@ -476,8 +467,6 @@ namespace Plane.FormationCreator.ViewModels
_lastVirtualCopterLocation = null;
_flightTaskManager.OriginLat = 0;
_flightTaskManager.OriginLng = 0;
_flightTaskManager.ObserverLat = 0;
_flightTaskManager.ObserverLng = 0;
}));
}
}

View File

@ -17,8 +17,6 @@ using Plane.Geography;
using Plane.FormationCreator.Views;
using System.Windows;
using Plane.Collections;
using Plane.Copters;
using Newtonsoft.Json.Linq;
namespace Plane.FormationCreator.ViewModels
{
@ -35,15 +33,10 @@ namespace Plane.FormationCreator.ViewModels
//连接信息
Plane.Windows.Messages.Message.Configure(connectAction: connected => this.CommunicationModuleConnected = connected);
//广播是否打开
Plane.Windows.Messages.Message.Configureboard(boardportAction: opened => this.BoardcastPortOpened = opened);
this.SwitchVelocityModeButtonContent = GetSwitchVelocityModeButtonContent();
AppEx.Current.PropertyChanged += AppEx_PropertyChanged;
_copterManager.netStatusChanged += CopterManagernetStatusChanged;
ControlPanelViewModelData = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
}
private CopterListViewModel _copterListViewModel;
@ -93,18 +86,10 @@ namespace Plane.FormationCreator.ViewModels
Logs += (Environment.NewLine + value);
}
}
private ControlPanelViewModel _controlPanelViewModelData;
public ControlPanelViewModel ControlPanelViewModelData
{
get { return _controlPanelViewModelData; }
set
{
Set(nameof(ControlPanelViewModelData), ref _controlPanelViewModelData, value);
}
}
// public ControlPanelViewModel ControlPanelViewModelData = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
private bool _CommunicationModuleConnected;
public bool CommunicationModuleConnected
@ -116,18 +101,6 @@ namespace Plane.FormationCreator.ViewModels
}
}
private bool _BoardcastPortOpened=false;
public bool BoardcastPortOpened
{
get { return _BoardcastPortOpened; }
set
{
Set(nameof(BoardcastPortOpened), ref _BoardcastPortOpened, value);
}
}
private string _SysStatusText="系统信息";
public string SysStatusText
{
@ -245,30 +218,6 @@ namespace Plane.FormationCreator.ViewModels
}));
}
}
private ICommand _ShowModifyTaskViewCommand;
public ICommand ShowModifyTaskViewCommand
{
get
{
return _ShowModifyTaskViewCommand ?? (_ShowModifyTaskViewCommand = new RelayCommand(() =>
{
AppEx.Current.ShowModifyTaskView = true;
}));
}
}
private ICommand _HideModifyTaskViewCommand;
public ICommand HideModifyTaskViewCommand
{
get
{
return _HideModifyTaskViewCommand ?? (_HideModifyTaskViewCommand = new RelayCommand(() =>
{
AppEx.Current.ShowModifyTaskView =false;
}));
}
}
private ICommand _ShowOrHideModifyTaskViewCommand;
public ICommand ShowOrHideModifyTaskViewCommand
@ -306,55 +255,6 @@ namespace Plane.FormationCreator.ViewModels
private ICommand _Map2DCommand;
public ICommand Map2DCommand
{
get
{
return _Map2DCommand ?? (_Map2DCommand = new RelayCommand(() =>
{
MainWindow mainw = (MainWindow)App.Current.MainWindow;
mainw.map.Visibility = System.Windows.Visibility.Visible;
mainw.map3D.Visibility = System.Windows.Visibility.Collapsed;
MapMode = 0;
b2DMapMode = true;
_flightTaskManager.TaskRun_2D = b2DMapMode; //2D模式模拟显示
//强制刷新飞机位置
_copterManager.Copters.ForEach(copter => copter.RefreashLoc());
}));
}
}
private ICommand _Map3DCommand;
public ICommand Map3DCommand
{
get
{
return _Map3DCommand ?? (_Map3DCommand = new RelayCommand(() =>
{
MainWindow mainw = (MainWindow)App.Current.MainWindow;
mainw.map.Visibility = System.Windows.Visibility.Collapsed;
mainw.map3D.Visibility = System.Windows.Visibility.Visible;
MapMode = 1;
b2DMapMode = false;
_flightTaskManager.TaskRun_2D = b2DMapMode; //3D模式模拟显示
mainw.map3D.ResetCamera();
}));
}
}
private ICommand _ChangeMapModeCommand;
public ICommand ChangeMapModeCommand
{
@ -397,22 +297,6 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(OnlyImpotWaypointS), ref _OnlyImpotWaypointS, value); }
}
//导入飞机的位置
private bool _isimpCopterLoc =true;
public bool isimpCopterLoc
{
get { return _isimpCopterLoc; }
set { Set(nameof(isimpCopterLoc), ref _isimpCopterLoc, value); }
}
//导出飞机和航点等
private ICommand _ExportTasksCommand;
public ICommand ExportTasksCommand
{
@ -425,7 +309,7 @@ namespace Plane.FormationCreator.ViewModels
Alert.Show("作为参照的原点未设置,无法导出相对位置!", "提示");
return;
}
bool isToMeter = false;
var dialog = new SaveFileDialog
{
DefaultExt = "fcgm",
@ -435,16 +319,11 @@ namespace Plane.FormationCreator.ViewModels
{
IEnumerable<object> taskObject;
string extension = Path.GetExtension(dialog.FileName);
isToMeter = (extension == ".fcgm");
if (isToMeter)
if (extension == ".fcgm")
taskObject = _flightTaskManager.ExportTasksToMeter();
else
taskObject = _flightTaskManager.ExportTasks();
string exportedText;
if (OnlyImpotWaypointS)
@ -454,15 +333,11 @@ namespace Plane.FormationCreator.ViewModels
else
{
var groupObject = _groupManager.ExportGroups();
var locateObject = ExportLocate(isToMeter);
var locateObject = ExportLocate();
object obj = new
{
ID="flycube.com",
ver = "2.0",
coptercount = _copterManager.Copters.Count,
taskcount = _flightTaskManager.Tasks.Count,
groups = groupObject,
locate = locateObject,
tasks = taskObject
@ -479,41 +354,21 @@ namespace Plane.FormationCreator.ViewModels
}
}
private List<object> ExportLocate(bool isToMeter)
private List<object> ExportLocate()
{
List<object> locateList = new List<object>();
foreach (var copter in _copterManager.Copters)
{
double[] locate = new double[3];
if (isToMeter)
{
double x = GeographyUtils.CalcDistance(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, 0,
_flightTaskManager.OriginLat, copter.Longitude, 0);
if (copter.Longitude < _flightTaskManager.OriginLng) x = -x;
double y = GeographyUtils.CalcDistance(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, 0,
copter.Latitude, _flightTaskManager.OriginLng, 0);
if (copter.Latitude < _flightTaskManager.OriginLat) y = -y;
locate[0] = x;
locate[1] = y;
}
else
{
//为了和老版本兼容
locate[1] = copter.Longitude - _flightTaskManager.OriginLng;
locate[0] = copter.Latitude - _flightTaskManager.OriginLat;
}
locate[0] = copter.Latitude - _flightTaskManager.OriginLat;
locate[1] = copter.Longitude - _flightTaskManager.OriginLng;
locate[2] = copter.GroundAlt;
locateList.Add(locate);
}
return locateList;
}
private int _txtStarindex = 0;
public int txtStarindex
{
@ -528,7 +383,6 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(txtendindex), ref _txtendindex, value); }
}
//导入航点
private ICommand _ImportTasksCommand;
public ICommand ImportTasksCommand
{
@ -550,8 +404,7 @@ namespace Plane.FormationCreator.ViewModels
{
string extension = Path.GetExtension(dialog.FileName);
bool isMeter = extension == ".fcgm";
int _startindex = txtStarindex;
int _endindex = txtendindex;
@ -561,31 +414,10 @@ namespace Plane.FormationCreator.ViewModels
dynamic taskinfo = null;
if (importInfo is Newtonsoft.Json.Linq.JObject)
{
int ? filecoptercount = importInfo.coptercount;
string ver = importInfo.ver;
string ID = importInfo.ID;
if ((ID!=null)&&(ID!="flycube.com"))
{
Alert.Show($"文件格式不正确", "提示");
return;
}
if ((filecoptercount != null)&&(filecoptercount != _copterManager.Copters.Count ))
{
Alert.Show($"导入的飞机数量不符!导入飞机{filecoptercount},实际飞机{ _copterManager.Copters.Count}", "提示");
return;
}
taskinfo = importInfo.tasks;
if (importInfo.locate != null)
{
//老版本无论是fcgm还是fcg格式这个地方都存的经纬差新版fcgm才用米为单位保存
if ((ver != null) && (ver == "2.0"))
ImportCoptersLocate(importInfo.locate, isMeter);
else
ImportCoptersLocate(importInfo.locate, false);
ImportCoptersLocate(importInfo.locate);
}
if (importInfo.groups != null)
{
@ -599,21 +431,8 @@ namespace Plane.FormationCreator.ViewModels
//int task Newtonsoft.Json.Linq.JArray
if (taskinfo.Count == 0)
{
Alert.Show($"导入的文件没有飞行任务!", "提示");
return;
}
if ((taskinfo[0].singleCopterInfos.Count != _copterManager.Copters.Count))
{
Alert.Show($"导入的飞机数量不符!导入飞机{taskinfo[0].singleCopterInfos.Count},实际飞机{ _copterManager.Copters.Count}", "提示");
return;
}
string extension = Path.GetExtension(dialog.FileName);
bool isMeter = extension == ".fcgm";
if ((txtStarindex == 0) && (txtendindex == 0))
@ -707,53 +526,15 @@ namespace Plane.FormationCreator.ViewModels
}
}
private void ImportCoptersLocate(dynamic coptersLocate,bool isMeter)
private void ImportCoptersLocate(dynamic coptersLocate)
{
//if (Newtonsoft.Json.Linq.JArray)
try
{
int index = 0;
bool loadxyLocate = isimpCopterLoc;
foreach (var locate in coptersLocate)
{
_copterManager.Copters[index].GroundAlt = Convert.ToSingle(locate[2]);
//虚拟飞机将读入保存时的位置
if (loadxyLocate&&(_copterManager.Copters[index] is FakeCopter))
{
var fc = _copterManager.Copters[index] as FakeCopter;
if (isMeter)
{
Tuple<double, double> observationLatLng = null;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat,
_flightTaskManager.OriginLng,
90,
Convert.ToSingle(locate[0]));
double TargetLng = observationLatLng.Item2;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat,
_flightTaskManager.OriginLng,
0,
Convert.ToSingle(locate[1]));
double TargetLat = observationLatLng.Item1;
fc.SetProperties(
latitude: TargetLat,
longitude: TargetLng
);
}else
{
double TargetLng = _flightTaskManager.OriginLng + Convert.ToSingle(locate[1]);
double TargetLat = _flightTaskManager.OriginLat + Convert.ToSingle(locate[0]);
fc.SetProperties(
latitude:TargetLat,
longitude: TargetLng
);
}
}
index++;
}

View File

@ -37,7 +37,7 @@ namespace Plane.FormationCreator.ViewModels
// }
// }
//};
// TODO: 王海, 20150803, 没什么问题就把这段以及 FlyToLat 等属性删了。
// TODO: 林俊清, 20150803, 没什么问题就把这段以及 FlyToLat 等属性删了。
//_flightTaskManager.PropertyChanged += (sender, e) =>
//{
// switch (e.PropertyName)
@ -66,7 +66,7 @@ namespace Plane.FormationCreator.ViewModels
//};
//_copterManager.SelectedCoptersChanged += (sender, e) =>
//{
// // TODO: 王海, 20150731, 处理多选飞行器时的情况。
// // TODO: 林俊清, 20150731, 处理多选飞行器时的情况。
// var selectedCopters = _copterManager.SelectedCopters;
// if (selectedCopters.Count() > 1)
// {
@ -129,13 +129,13 @@ namespace Plane.FormationCreator.ViewModels
//private void InvokeForSelectedSingleCopterInfos(Action<FlightTaskSingleCopterInfo> action)
//{
// var modifyingTask = _flightTaskManager.SelectedTask as FlyToFlightTask;
// if (modifyingTask != null && _copterManager.SelectedCopters.Count() == 1) // 王海, 20150731, 目前不处理多选的情况。
// if (modifyingTask != null && _copterManager.SelectedCopters.Count() == 1) // 林俊清, 20150731, 目前不处理多选的情况。
// {
// modifyingTask.FlyToFlightTaskSingleCopterInfos
// .Where(i => _copterManager.SelectedCopters.FirstOrDefault() == i.Copter)
// .ForEach(action);
// // TODO: 王海, 20150731, 添加同时改多个 SingleCopterInfo 的程序。
// // TODO: 林俊清, 20150731, 添加同时改多个 SingleCopterInfo 的程序。
// //.Where(i => _copterManager.SelectedCopters.Contains(i.Copter))
// }
//}
@ -191,34 +191,6 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(directionvalueall), ref _directionvalueall, value); }
}
private int _taskstartno = 0;
public int taskstartno
{
get { return _taskstartno; }
set { Set(nameof(taskstartno), ref _taskstartno, value); }
}
private int _taskendno = 0;
public int taskendno
{
get { return _taskendno; }
set { Set(nameof(taskendno), ref _taskendno, value); }
}
private float _taskdirection = 0;
public float taskdirection
{
get { return _taskdirection; }
set { Set(nameof(taskdirection), ref _taskdirection, value); }
}
private double _FlyToLat;
public double FlyToLat
{
@ -256,135 +228,6 @@ namespace Plane.FormationCreator.ViewModels
/// <summary>
/// 垂直旋转多个任务
/// </summary>
private ICommand _MitTaskVrotationCommand;
public ICommand MitTaskVrotationCommand
{
get
{
return _MitTaskVrotationCommand ?? (_MitTaskVrotationCommand = new RelayCommand<float>(async =>
{
double lngsum = 0;
double latsum = 0;
double altsum = 0;
int selectcount = 0;
// double centlng = 0;
double centlat = 0;
double centalt = 0;
int _taskstartno = 0;
int _taskendno = 0;
if (taskstartno == 0)
_taskstartno = 0;
else _taskstartno = taskstartno - 1;
if (taskendno == 0)
_taskendno = _flightTaskManager.Tasks.Count()-1;
else _taskendno = taskendno - 1;
//计算旋转中心轴
for (int i = _taskstartno ; i <= _taskendno; i++)
{
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff) || (_flightTaskManager.Tasks[i].TaskType == FlightTaskType.Land))
continue;
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
{
lngsum += _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng;
latsum += _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat;
altsum += _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetAlt;
selectcount++;
}
}
if (selectcount > 0)
{
// centlng = lngsum / selectcount;
centlat = latsum / selectcount;
centalt = altsum / selectcount;
}
//////////计算旋转,经测试用下面的函数组合计算比较准确
double k = (double)taskdirection / 180 * Math.PI;
double dx = 0;
double dy = 0;
double ax = 0;
double ay = 0;
double tlng = 0;
double tlat = 0;
for (int i = _taskstartno; i <= _taskendno; i++)
{
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff) || (_flightTaskManager.Tasks[i].TaskType == FlightTaskType.Land))
continue;
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
{
tlng = _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng;
tlat = _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat;
//纬度方向距离单位m
ax = CalculationLogLatDistance.GetDistanceOne(tlng, centlat, tlng, tlat) * 1000;
//方向角用于正负,0为正180为负
CalculationLogLatDistance.MyLatLng mypos1, mypos2;
mypos1 = new CalculationLogLatDistance.MyLatLng(tlng, centlat);
mypos2 = new CalculationLogLatDistance.MyLatLng(tlng, tlat);
double lpAzimuth = CalculationLogLatDistance.getAngle(mypos1, mypos2);
if (lpAzimuth > 90)
ax = -ax;
//高度方向距离单位m
ay = (_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetAlt - centalt);
dx = ax * Math.Cos(k) + ay * Math.Sin(k);
dy = -ax * Math.Sin(k) + ay * Math.Cos(k);
//新高度(米)
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetAlt = (float)(centalt + dy);
//计算新纬度
double lng2 = 0;
double lat2 = 0;
if (dx < 0)
lpAzimuth = 180;
else
lpAzimuth = 0;
dx = Math.Abs(dx);
CalculationLogLatDistance.ConvertDistanceToLogLat(
tlng,
centlat, //旋转中心纬度
dx / 1000, //新距离
lpAzimuth, //方向垂直
out lng2,
out lat2);
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat = lat2;
}
}
// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
}));
}
}
private ICommand _ShowallTaskpointCommand;
public ICommand ShowallTaskpointCommand
@ -400,87 +243,11 @@ namespace Plane.FormationCreator.ViewModels
//_flightTaskManager.SelectedTask = null;
}));
}
}
private void GetMaxMissions()
{
int missiontmp = 0;
string maxCopterName = "";
int maxmission = 0;
string minCopterName = "";
int minmission = 65535;
ICopter vcopter = _copterManager.SelectedCopters.FirstOrDefault();
if (vcopter == null)
{
Alert.Show($"请先选中飞机!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
int coptercount = _copterManager.Copters.Count;
for (int i = 0; i < coptercount; i++)
{
missiontmp = 0;
var currcopter = _copterManager.Copters[i];
foreach (var capter in _copterManager.SelectedCopters)
{
if (currcopter == capter)
{
for (int j = 0; j < _flightTaskManager.Tasks.Count; j++)
{
missiontmp++;
missiontmp += _flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos.Count();
}
if (missiontmp > maxmission)
{
maxCopterName = _copterManager.Copters[i].Name;
maxmission = missiontmp;
}
if (missiontmp < minmission)
{
minCopterName = _copterManager.Copters[i].Name;
minmission = missiontmp;
}
}
}
}
if (maxmission>256)
Alert.Show($"飞机:[ {maxCopterName} ] 有最多任务数量:{maxmission} 已超出256的最大航点限制请减少灯光; \n飞机[ {minCopterName} ] 有最少任务数量:{minmission}", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
else
Alert.Show($"飞机:[ {maxCopterName} ] 有最多任务数量:{maxmission} \n飞机[ {minCopterName} ] 有最少任务数量:{minmission} \n (航点加灯光不能超过256个任务)", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return ;
}
private ICommand _CheckMissionCountCommand;
public ICommand CheckMissionCountCommand
{
get
{
return _CheckMissionCountCommand ?? (_CheckMissionCountCommand = new RelayCommand<float>(async =>
{
GetMaxMissions();
}));
}
}
//调整所有任务经度
private ICommand _ModiAllPosCommand;
public ICommand ModiAllPosCommand
@ -493,22 +260,9 @@ namespace Plane.FormationCreator.ViewModels
float lowalt = 200;
int itaskendno = taskendno;
if (taskendno == 0) itaskendno = _flightTaskManager.Tasks.Count - 1;
else itaskendno = taskendno - 1;
if (itaskendno > _flightTaskManager.Tasks.Count-1) itaskendno = _flightTaskManager.Tasks.Count-1;
// for (int i = taskstartno; i < itaskendno; i++)
int _startindex = taskstartno;
if (taskstartno == 0)
_startindex = 0;
else
_startindex = taskstartno - 1;
int _endindex = itaskendno;
int _startindex = 0;
int _endindex = _flightTaskManager.Tasks.Count - 1;
int lowtask = 0;
int lowCopter = 0;
@ -521,7 +275,7 @@ namespace Plane.FormationCreator.ViewModels
for (int i = _startindex; i <= _endindex; i++)
{
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff)|| (_flightTaskManager.Tasks[i].TaskType == FlightTaskType.Land))
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff))
continue;
@ -805,13 +559,8 @@ namespace Plane.FormationCreator.ViewModels
{
var tasksText = File.ReadAllText(dialog.FileName);
_flightTaskManager.ImportC4DFlytoTask(tasksText);
if (_copterManager.FC_VER_NO >= 3)
Alert.Show($"导入的第一个航点默认为0,需要重新计算时间", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
else
_flightTaskManager.SetAllTaskFlytime();
}
else
autoalltasktime();
}else
if ((extname == ".svg")|| (extname == ".obj"))
{
_flightTaskManager.ImportDlltoTask(dialog.FileName);
@ -826,56 +575,45 @@ namespace Plane.FormationCreator.ViewModels
private ICommand _ImportBlenderrCopterPosCommand;
public ICommand ImportBlenderCopterPosCommand
public void autoalltasktime()
{
get
for (int taskIndex = 1; taskIndex < _flightTaskManager.Tasks.Count; taskIndex++)
{
return _ImportBlenderrCopterPosCommand ?? (_ImportBlenderrCopterPosCommand = new RelayCommand<int>(async =>
if (taskIndex != 0 || _flightTaskManager.Tasks[taskIndex].TaskType == FlightTaskType.FlyTo)
{
//有不是虚拟飞机的直接退出
foreach (var copter in _copterManager.Copters)
if (_copterManager.Copters.Count() > 0)
{
if (!(copter is FakeCopter))
double maxDistance = 0.0f;
string copterName = "";
double speed = 0.0f;
foreach (var copter in _copterManager.Copters)
{
Alert.Show($"导入起飞位置只能用于虚拟飞机,{copter.Id}不是虚拟飞机", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
var prevWaypoint = _flightTaskManager.Tasks[taskIndex - 1].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
var curWaypoint = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
double distance = GeographyUtils.CalcDistance(
prevWaypoint.TargetLat, prevWaypoint.TargetLng, prevWaypoint.TargetAlt,
curWaypoint.TargetLat, curWaypoint.TargetLng, curWaypoint.TargetAlt);
if (distance > maxDistance)
{
maxDistance = distance;
copterName = copter.Name;
speed = curWaypoint.LevelSpeed;
}
}
double time = CalculateFlyIime(maxDistance, speed);
Message.Show($"任务:{taskIndex},最大航点间距 = {Math.Round(maxDistance, 2)}米, 水平速度={Math.Round(speed, 2)}, 飞行时间 = {Math.Round(time, 2)}秒, 飞机编号:{copterName}");
_flightTaskManager.Tasks[taskIndex].FlytoTime = (int)Math.Round(time, 2);
}
var dialog = new OpenFileDialog
{
DefaultExt = "txt",
Filter = "航点文件(*.txt,*.svg,*.obj) |*.txt;*.svg;*.obj" // "图片文件(*.jpg, *.gif, *.bmp, *.png) | *.jpg; *.gif; *.bmp; *.png"
};
if (dialog.ShowDialog() == true)
{
string extname = Path.GetExtension(dialog.FileName);
if (extname == ".txt")
{
var tasksText = File.ReadAllText(dialog.FileName);
_flightTaskManager.ImportC4DFlytoVCopter(tasksText);
}
else
if ((extname == ".svg") || (extname == ".obj"))
{
_flightTaskManager.ImportDlltoVCopter(dialog.FileName);
};
}
}));
}
}
}
private ICommand _ExportWayPointCommand;
public ICommand ExportWayPointCommand
{
@ -883,9 +621,6 @@ namespace Plane.FormationCreator.ViewModels
{
return _ExportWayPointCommand ?? (_ExportWayPointCommand = new RelayCommand<int>(async =>
{
// _flightTaskManager.OptimizeRouteNew();
// return;
var dialog = new SaveFileDialog
{
DefaultExt = "txt",
@ -910,7 +645,58 @@ namespace Plane.FormationCreator.ViewModels
{
return _AutoWayPointTmCommand ?? (_AutoWayPointTmCommand = new RelayCommand<int>(async =>
{
_flightTaskManager.SetTaskFlytime(_flightTaskManager.SelectedTaskIndex);
int taskIndex = _flightTaskManager.SelectedTaskIndex;
if (taskIndex != 0 || _flightTaskManager.SelectedTask.TaskType == FlightTaskType.FlyTo)
{
if (_copterManager.Copters.Count() > 0)
{
double maxDistance = 0.0f;
string copterName = "";
double speed = 0.0f;
foreach (var copter in _copterManager.Copters)
{
var prevWaypoint = _flightTaskManager.Tasks[taskIndex - 1].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
var curWaypoint = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
double distance = GeographyUtils.CalcDistance(
prevWaypoint.TargetLat, prevWaypoint.TargetLng, prevWaypoint.TargetAlt,
curWaypoint.TargetLat, curWaypoint.TargetLng, curWaypoint.TargetAlt);
if (distance > maxDistance)
{
maxDistance = distance;
copterName = copter.Name;
speed = curWaypoint.LevelSpeed;
}
}
double time = CalculateFlyIime(maxDistance, speed);
Message.Show($"最大航点间距 = {Math.Round(maxDistance, 2)}米, 水平速度={Math.Round(speed, 2)}, 飞行时间 = {Math.Round(time, 2)}秒, 飞机编号:{copterName}");
_flightTaskManager.SelectedTask.FlytoTime = (int)Math.Round(time, 2);
}
}
}));
}
}
@ -925,80 +711,19 @@ namespace Plane.FormationCreator.ViewModels
return _AutoWayPointAllTmCommand ?? (_AutoWayPointAllTmCommand = new RelayCommand<int>(async =>
{
if (Alert.Show("本操作将导致除2号任务以外所有任务飞行时间重新计算(不修改悬停时间),您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
if (Alert.Show("本操作将导致所有任务飞行时间重新计算,您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
== MessageBoxResult.OK)
{
_flightTaskManager.SetAllTaskFlytime();
autoalltasktime();
}
}));
}
}
private ICommand _CheckTmCommand;
public ICommand CheckTmCommand
{
get
{
return _CheckTmCommand ?? (_CheckTmCommand = new RelayCommand<int>(async =>
{
if (Alert.Show("本操作将检测2号任务以后所有任务飞行时间是否合理您确定要继续吗", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
== MessageBoxResult.OK)
{
_flightTaskManager.CheckAllTaskFlytime();
}
}));
}
}
//2D计算不改变ID拉开层
private ICommand _OptimizeRouteCommandRet;
public ICommand OptimizeRouteCommandRet
{
get
{
return _OptimizeRouteCommandRet ?? (_OptimizeRouteCommandRet = new RelayCommand<int>(async =>
{
if (_copterManager.FC_VER_NO >= 3)
//2D计算不改变ID不用错层
_flightTaskManager.OptimizeRouteMeter(false, false, false); //采用米计算逻辑用3D生成不改变ID可拉开层(2D回起飞矩阵专用)
else
_flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑用2D生成不改变ID不拉开层
}));
}
}
//3D计算不改变ID不拉开层
private ICommand _OptimizeRouteCommandRet3D;
public ICommand OptimizeRouteCommandRet3D
{
get
{
return _OptimizeRouteCommandRet3D ?? (_OptimizeRouteCommandRet3D = new RelayCommand<int>(async =>
{
if (_copterManager.FC_VER_NO >= 3)
//3D计算不改变ID可以错层
_flightTaskManager.OptimizeRouteMeter(true, false, true); //采用米计算逻辑用3D生成不改变ID拉开层(3D回起飞矩阵专用,结束必须是矩阵)
else
_flightTaskManager.OptimizeRouteMeter(false, false); //采用米计算逻辑用2D生成不改变ID不拉开层
}));
}
}
private ICommand _OptimizeRouteCommand3D;
public ICommand OptimizeRouteCommand3D
{
get
{
return _OptimizeRouteCommand3D ?? (_OptimizeRouteCommand3D = new RelayCommand<int>(async =>
{
//_flightTaskManager.OptimizeRoute2();
// _flightTaskManager.OptimizeRouteNew (); //最后可用的,但是经纬度计算,
_flightTaskManager.OptimizeRouteMeter(true); //采用米计算逻辑和OptimizeRouteNew一样
}));
}
}
private ICommand _OptimizeRouteCommand;
public ICommand OptimizeRouteCommand
{
@ -1007,8 +732,7 @@ namespace Plane.FormationCreator.ViewModels
return _OptimizeRouteCommand ?? (_OptimizeRouteCommand = new RelayCommand<int>(async =>
{
//_flightTaskManager.OptimizeRoute2();
// _flightTaskManager.OptimizeRouteNew (); //最后可用的,但是经纬度计算,
_flightTaskManager.OptimizeRouteMeter(); //采用米计算逻辑和OptimizeRouteNew一样
_flightTaskManager.OptimizeRouteNew();
}));
}
}
@ -1195,7 +919,23 @@ public ICommand VerticlAlignmentCommand
}
public static double CalculateFlyIime(double s, double v)
{
double t;
double a = 1; //加速度1米每秒
double at = v / a;
double a_s = 0.5f * a * at * at;
if (a_s > (s / 2)) //还没到特定速度就到了中点了
{
t = (float)System.Math.Sqrt(s / a) * 2;
}
else
{
t = (s - a_s * 2) / v + at * 2;
}
return t;
}
@ -1417,20 +1157,11 @@ public ICommand VerticlAlignmentCommand
double copterlat = 0;
double lng_out1 = 0;
double lat_out1 = 0;
int itaskendno = taskendno;
if (itaskendno == 0) itaskendno = _flightTaskManager.Tasks.Count - 1;
else itaskendno = taskendno - 1;
if (itaskendno > _flightTaskManager.Tasks.Count-1) itaskendno = _flightTaskManager.Tasks.Count-1;
int _taskstartno = 0;
if (taskstartno == 0) _taskstartno = 0;
else _taskstartno = taskstartno - 1;
for (int i = _taskstartno; i <= itaskendno; i++)
for (int i = 0; i < _flightTaskManager.Tasks.Count; i++)
{
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
{
copterlng=_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng;
copterlat = _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat;
@ -1716,15 +1447,8 @@ public ICommand VerticlAlignmentCommand
float lowalt = 200;
int itaskendno = taskendno;
if (itaskendno == 0) itaskendno = _flightTaskManager.Tasks.Count - 1;
else itaskendno = taskendno - 1;
if (itaskendno > _flightTaskManager.Tasks.Count-1) itaskendno = _flightTaskManager.Tasks.Count-1;
// for (int i = taskstartno; i < itaskendno; i++)
int _startindex = taskstartno;
if (_startindex != 0) _startindex = taskstartno - 1;
int _endindex = itaskendno ;
int _startindex = 0;
int _endindex = _flightTaskManager.Tasks.Count-1;
int lowtask = 0;
int lowCopter = 0;
@ -1737,8 +1461,10 @@ public ICommand VerticlAlignmentCommand
for (int i = _startindex; i <= _endindex; i++)
{
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff)|| (_flightTaskManager.Tasks[i].TaskType == FlightTaskType.Land))
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff))
continue;
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
{
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetAlt +=(float) cModialtvalue;
@ -1769,85 +1495,44 @@ public ICommand VerticlAlignmentCommand
{
get
{
return _calDistinceCommand ?? (_calDistinceCommand = new RelayCommand<double>(async =>
return _calDistinceCommand ?? (_calDistinceCommand = new RelayCommand<double>(async =>
{
if (_copterManager.AcceptingControlCopters.Count() < 2)
return;
double minDistance = double.MaxValue;
string currselectstr = "";
for (int tsi = 1; tsi < _flightTaskManager.Tasks.Count ; tsi++)
var flightTask = _flightTaskManager.SelectedTask;
List<ICopter> selectedCopter = new List<ICopter>();
selectedCopter.AddRange(_copterManager.AcceptingControlCopters);
string minCopterId1 = "0";
string minCopterId2 = "0";
for (int i = 0; i < selectedCopter.Count; i++)
{
var copter1 = selectedCopter[i];
var copterInfo1 = _flightTaskManager.SelectedTask.SingleCopterInfos.FirstOrDefault(c =>c.Copter == copter1);
if ((_flightTaskManager.Tasks[tsi].TaskType == FlightTaskType.TakeOff) || (_flightTaskManager.Tasks[tsi].TaskType == FlightTaskType.Land))
continue;
double minDistance = double.MaxValue;
double maxDistance = 0.0;
var flightTask = _flightTaskManager.Tasks[tsi];
List<ICopter> selectedCopter = new List<ICopter>();
selectedCopter.AddRange(_copterManager.AcceptingControlCopters);
string minCopterId1 = "0";
string minCopterId2 = "0";
string maxCopterId1 = "0";
string maxCopterId2 = "0";
for (int i = 0; i < selectedCopter.Count; i++)
for (int j = i + 1; j < selectedCopter.Count; j++)
{
var copter1 = selectedCopter[i];
var copterInfo1 = flightTask.SingleCopterInfos.FirstOrDefault(c => c.Copter == copter1);
var copter2 = selectedCopter[j];
var copterInfo2 = _flightTaskManager.SelectedTask.SingleCopterInfos.FirstOrDefault(c => c.Copter == copter2);
for (int j = i + 1; j < selectedCopter.Count; j++)
double distance = GeographyUtils.CalcDistance(
copterInfo1.TargetLat, copterInfo1.TargetLng, copterInfo1.TargetAlt,
copterInfo2.TargetLat, copterInfo2.TargetLng, copterInfo2.TargetAlt);
//minDistance = Math.Min(minDistance, distance);
if (distance < minDistance)
{
var copter2 = selectedCopter[j];
var copterInfo2 = flightTask.SingleCopterInfos.FirstOrDefault(c => c.Copter == copter2);
double distance = GeographyUtils.CalcDistance(
copterInfo1.TargetLat, copterInfo1.TargetLng, copterInfo1.TargetAlt,
copterInfo2.TargetLat, copterInfo2.TargetLng, copterInfo2.TargetAlt);
//minDistance = Math.Min(minDistance, distance);
if (distance < minDistance)
{
minDistance = distance;
minCopterId1 = copter1.Id;
minCopterId2 = copter2.Id;
}
if (distance > maxDistance)
{
maxDistance = distance;
maxCopterId1 = copter1.Id;
maxCopterId2 = copter2.Id;
}
minDistance = distance;
minCopterId1 = copter1.Id;
minCopterId2 = copter2.Id;
}
}
minDistance = Math.Round(minDistance, 2);
maxDistance = Math.Round(maxDistance, 2);
string showstr = string.Format("[{0}{1}] 最小距离 = {2:F2} 飞机: {3} 和 {4}; 最大距离 = {5:F2} 飞机: {6} 和 {7}",
flightTask.TaskIndex + 1, flightTask.TaskCnName, minDistance, minCopterId1, minCopterId2, maxDistance,
maxCopterId1, maxCopterId2);
Message.Show(showstr);
// Message.Show($"[{0:flightTask.TaskIndex + 1}{flightTask.TaskCnName}]最小距离 = {minDistance} 飞机:{minCopterId1}和{minCopterId2} ; 最大距离 = {maxDistance} 飞机:{maxCopterId1}和{maxCopterId2}");
if (flightTask == _flightTaskManager.SelectedTask)
currselectstr = showstr;
}
Message.Show("选中任务:");
Message.Show(currselectstr);
//Distancevalue = minDistance;
Message.Show($"最小距离 = {minDistance} 飞机:{minCopterId1}和{minCopterId2}");
}));
}
@ -1861,8 +1546,35 @@ public ICommand VerticlAlignmentCommand
{
return _MaxDistinceAndTimeCommand ?? (_MaxDistinceAndTimeCommand = new RelayCommand<double>(async =>
{
//不设置时间,只是计算
_flightTaskManager.SetTaskFlytime(_flightTaskManager.SelectedTaskIndex, false);
int taskIndex = _flightTaskManager.SelectedTaskIndex;
if (taskIndex != 0 || _flightTaskManager.SelectedTask.TaskType == FlightTaskType.FlyTo)
{
if (_copterManager.AcceptingControlCopters.Count() > 0)
{
double maxDistance = 0.0f;
string copterName = "";
double speed = 0.0f;
foreach (var copter in _copterManager.AcceptingControlCopters)
{
var prevWaypoint = _flightTaskManager.Tasks[taskIndex - 1].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
var curWaypoint = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter);
double distance = GeographyUtils.CalcDistance(
prevWaypoint.TargetLat, prevWaypoint.TargetLng, prevWaypoint.TargetAlt,
curWaypoint.TargetLat, curWaypoint.TargetLng, curWaypoint.TargetAlt);
if (distance > maxDistance)
{
maxDistance = distance;
copterName = copter.Name;
speed = curWaypoint.LevelSpeed;
}
}
double time = CalculateFlyIime(maxDistance, speed);
Message.Show($"最大航点间距 = {Math.Round(maxDistance, 2)}米, 水平速度={Math.Round(speed, 2)}, 飞行时间 = {Math.Round(time, 2)}秒, 飞机编号:{copterName}");
}
}
}));
}
}
@ -2062,18 +1774,8 @@ public ICommand VerticlAlignmentCommand
{
float CopterDirection =90- (float)BeltDirection ;
//必须大于1架
if (_copterManager.SelectedCopters.Count() <= 1)
{
Alert.Show("必须选中多于一架飞机");
if (_copterManager.SelectedCopters.Count() <= 0)
return;
}
if (EndTime<= BeginTime)
{
Alert.Show("结束时间必须大于开始时间(非持续时间!");
return;
}
//旋转飞机矩阵
if (CopterDirection != 0)
@ -2191,8 +1893,7 @@ public ICommand VerticlAlignmentCommand
{
return _SetStrokesLampCommamd ?? (_SetStrokesLampCommamd = new RelayCommand(async () =>
{
//必须大于1架
if (_copterManager.SelectedCopters.Count() <= 1)
if (_copterManager.SelectedCopters.Count() <= 0)
return;
@ -2248,7 +1949,7 @@ public ICommand VerticlAlignmentCommand
#region
private double _GradientRampTime = 1;
private double _GradientRampTime = 10;
public double GradientRampTime
{
get { return _GradientRampTime; }
@ -2405,12 +2106,8 @@ public ICommand VerticlAlignmentCommand
LEDInfo endLed = new LEDInfo();
endLed.LEDMode = 0;
endLed.Delay = AlignmentTime - leddelay;
if (copterInfo.LEDInfos.Count > 0)
endLed.LEDRGB = copterInfo.LEDInfos[copterInfo.LEDInfos.Count - 1].LEDRGB;
else
endLed.LEDRGB = "FFFFFF";
copterInfo.AddLEDInfo(endLed);
endLed.LEDRGB = copterInfo.LEDInfos[copterInfo.LEDInfos.Count - 1].LEDRGB;
copterInfo.AddLEDInfo(endLed);
}
}
}));
@ -2434,46 +2131,15 @@ public ICommand VerticlAlignmentCommand
{
float CopterDirection = 90 - (float)GradualDirection;
//渐变需要2架以上
if (_copterManager.SelectedCopters.Count() <= 1)
return;
List<FlightTaskSingleCopterInfo> TempSingleCopterInfos = new List<FlightTaskSingleCopterInfo>();
if (_copterManager.SelectedCopters.Count() <= 0)
return;
//旋转飞机矩阵
if (CopterDirection != 0)
{
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
if (_flightTaskManager.SelectedTask != null)
{
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
{
//得到每个选择的飞机
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
//根据飞机查找任务中的位置信息
foreach (var capter in _copterManager.SelectedCopters)
{
//如果是选择的那架飞机
if (capter == selectedCopter)
{
FlightTaskSingleCopterInfo vFlightTaskSingleCopterInfo = new FlightTaskSingleCopterInfo(capter);
vFlightTaskSingleCopterInfo.TargetLng = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng;
vFlightTaskSingleCopterInfo.TargetAlt = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt;
vFlightTaskSingleCopterInfo.TargetLat = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat;
TempSingleCopterInfos.Add(vFlightTaskSingleCopterInfo);
}
}
}
}
LevelRotateCommand.Execute(CopterDirection);
await Task.Delay(100);
LevelRotateCommand.Execute(CopterDirection);
await Task.Delay(100);
}
@ -2518,55 +2184,16 @@ public ICommand VerticlAlignmentCommand
LEDInfo led = new LEDInfo();
led.LEDMode = 0;
led.Delay = GradientRampTime;
led.LEDRGB = "000000";
//led.LEDRGB = Convert.ToString(R, 16) + Convert.ToString(G, 16) + Convert.ToString(B, 16);
try
{
led.LEDRGB = R.ToString("X2") + G.ToString("X2") + B.ToString("X2");
}
catch (Exception)
{
//throw;
}
led.LEDRGB = R.ToString("X2") + G.ToString("X2") + B.ToString("X2");
copterInfo.AddLEDInfo(led);
}
await Task.Delay(100);
//使用之前保存的位置回到飞机原来的位置,不使用旋转因为转回去和原来的位置有一点点偏差
if (CopterDirection != 0)
{
int j = 0;
var selectedCopter1 = _copterManager.SelectedCopters.FirstOrDefault();
if (_flightTaskManager.SelectedTask != null)
{
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
{
selectedCopter1 = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
foreach (var capter in _copterManager.SelectedCopters)
{
if (capter == selectedCopter1)
{
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat = TempSingleCopterInfos[j].TargetLat;
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng = TempSingleCopterInfos[j].TargetLng;
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt = TempSingleCopterInfos[j].TargetAlt;
j++;
}
}
}
}
// LevelRotateCommand.Execute(0 - CopterDirection);
}
//旋转飞机矩阵
if (CopterDirection != 0)
LevelRotateCommand.Execute(0 - CopterDirection);
}));
}

View File

@ -1,7 +1,5 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Practices.ServiceLocation;
using Plane.CommunicationManagement;
using Plane.FormationCreator.Formation;
using Plane.Windows.Messages;
using System;
@ -10,7 +8,6 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace Plane.FormationCreator.ViewModels
@ -20,41 +17,9 @@ namespace Plane.FormationCreator.ViewModels
private RtcmManager _rtcmManager;
public RtcmManager RtcmManager { get { return _rtcmManager; } }
//方式
public ObservableCollection<string> serialPorts { get; } = new ObservableCollection<string>();
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
public string BoardPortsStatus
{
get
{
return _commModuleManager.BoardPortStatusStr;
}
}
private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
public void SetRTKStatestr()
{
string rtksstr = "";
// ResendToCom
if (_rtcmManager.Rtcmthreadrun)
{
rtksstr = "RTK发送中 ";
if (_rtcmManager.SmallRtcmData)
rtksstr += ",低带宽模式 ";
if (_rtcmManager.ResendToCom && _commModuleManager.Recomisopen)
rtksstr += ",双通道模式 ";
rtksstr += "...";
}
else
rtksstr = "RTK未发送";
ControlPanelVM.RTKState = rtksstr;
}
private string _serialPortsSelectdValue;
public string SerialPortsSelectdValue
{
@ -64,57 +29,15 @@ namespace Plane.FormationCreator.ViewModels
}
private bool _smalldatamk;
public bool SmalldataMK
{
get { return _smalldatamk; }
set
{
Set(nameof(SmalldataMK), ref _smalldatamk, value);
_rtcmManager.SmallRtcmData= value;
}
}
private bool _resendtocommk=true;
public bool ResendToComMK
{
get { return _resendtocommk; }
set
{
if (value)
{
//发送
if (_commModuleManager.last_reserialport == "")
{
Alert.Show($"先在设置里打开广播端口", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}else
if (!_commModuleManager.Recomisopen)
{
Alert.Show($"广播端口未打开,无法发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
Set(nameof(ResendToComMK), ref _resendtocommk, value);
_rtcmManager.ResendToCom = value;
}
}
public RtcmInfoViewModel(RtcmManager rtcmManager)
{
_rtcmManager = rtcmManager;
serialPorts.Add("魔方基站");
serialPorts.Add("千寻");
string[] commports = _rtcmManager.GetPortNames();
foreach (var item in commports)
{
serialPorts.Add(item);
}
serialPorts.Add("千寻");
SerialPortsSelectdValue = serialPorts[0];
}
@ -124,13 +47,12 @@ namespace Plane.FormationCreator.ViewModels
{
string lastSelectValue = SerialPortsSelectdValue;
serialPorts.Clear();
serialPorts.Add("魔方基站");
serialPorts.Add("千寻");
string[] commports = _rtcmManager.GetPortNames();
foreach (var item in commports)
{
serialPorts.Add(item);
}
serialPorts.Add("千寻");
if (serialPorts.Contains(lastSelectValue))
SerialPortsSelectdValue = lastSelectValue;
}
@ -142,13 +64,10 @@ namespace Plane.FormationCreator.ViewModels
{
return _ConnectRtcmCommand ?? (_ConnectRtcmCommand = new RelayCommand(async() =>
{
//是否转发到特定端口
string resendserial = "";
_rtcmManager.ResendToCom = ResendToComMK;
if (!_rtcmManager.Rtcmthreadrun)
await _rtcmManager.Open(SerialPortsSelectdValue);
else
await _rtcmManager.Close(SerialPortsSelectdValue);
await _rtcmManager.Close();
}));
}
}

View File

@ -93,7 +93,6 @@ namespace Plane.FormationCreator.ViewModels
planeModel3Ds.Clear();
planeGroup.Children.Clear();
observationLatLng = null;
SelectTask();
}
private void Copter_LocationChanged(object sender, EventArgs e)
@ -110,31 +109,7 @@ namespace Plane.FormationCreator.ViewModels
}
private Dictionary<ICopter, GeometryModel3D> planeModel3Ds = new Dictionary<ICopter, GeometryModel3D>();
private Tuple<double, double> observationLatLng = null;
//得到观测位置
//observationLatLng 观察点坐标,第一列的中间再往前2个中间距离)
//观测点的位置放到最后排飞机的中间位置
private void getobservationpos()
{
observationLatLng = new Tuple<double, double>(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng);
/*
//第一列到中间的距离
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat,
_flightTaskManager.OriginLng,
_flightTaskManager.Orientation + 90,
midColDistance);
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
observationLatLng.Item1,
observationLatLng.Item2,
_flightTaskManager.Orientation + 180,
midColDistance * 4);
*/
}
Tuple<double, double> observationLatLng = null;
private void AddOrMove3DCopter(ICopter copter)
{
@ -142,16 +117,29 @@ namespace Plane.FormationCreator.ViewModels
//var copternum1 = _copterManager.Copters.FirstOrDefault();
if (_flightTaskManager.OriginLat == 0 || _flightTaskManager.OriginLng == 0)
return;
//得到观测位置
//第一列到中间的距离
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
if (observationLatLng == null)
{
getobservationpos();
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat,
_flightTaskManager.OriginLng,
_flightTaskManager.Orientation + 90,
midColDistance);
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
observationLatLng.Item1,
observationLatLng.Item2,
_flightTaskManager.Orientation + 180,
midColDistance * 2);
}
//没有这架飞机就加入
if (!planeModel3Ds.ContainsKey(copter))
{
//观测点的位置放到最后排飞机的中间位置
var meshBuilderwaypoint = new MeshBuilder(false, false);
//meshBuilderwaypoint.AddTriangle(new Point3D(-0.1, -0.1, 0), new Point3D(0.1, -0.1, 0), new Point3D(0, 0.2, 0));
@ -159,13 +147,12 @@ namespace Plane.FormationCreator.ViewModels
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3* _copterManager.scale3d);
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
//离观测点距离y
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
if (observationLatLng.Item1 > copter.Latitude) y = -y;
//离观测点距离x
double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, copter.Longitude, 0, 0) / 2;
if (observationLatLng.Item2 > copter.Longitude) x = -x;
//离观测点距离z
double z = copter.Altitude + 0.1;
x *= _copterManager.scale3d;
@ -180,9 +167,8 @@ namespace Plane.FormationCreator.ViewModels
{
Geometry = meshwaypoint,
Transform = new TranslateTransform3D(x, y, z),
Material = new DiffuseMaterial(new SolidColorBrush(color)),
//Material = MaterialHelper.CreateMaterial(color),
// BackMaterial = MaterialHelper.CreateMaterial(color)
Material = MaterialHelper.CreateMaterial(color),
BackMaterial = MaterialHelper.CreateMaterial(color)
};
planeModel3Ds.Add(copter, model3D);
@ -191,7 +177,7 @@ namespace Plane.FormationCreator.ViewModels
//有飞机在视图里就移动位置
else
{
//计算和观测点的相对位置
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
if (observationLatLng.Item1 > copter.Latitude) y = -y;
@ -202,45 +188,30 @@ namespace Plane.FormationCreator.ViewModels
x = Math.Round(x, 2);//按照四舍五入的国际标准
y = Math.Round(y, 2);
double z = Math.Round(copter.Altitude / 2, 2);
GeometryModel3D panle3D = planeModel3Ds[copter];
x *= _copterManager.scale3d;
y *= _copterManager.scale3d;
z *= _copterManager.scale3d;
//移动飞机到新位置
GeometryModel3D panle3D = planeModel3Ds[copter];
if (x != panle3D.Transform.Value.OffsetX || y != panle3D.Transform.Value.OffsetY || z != panle3D.Transform.Value.OffsetZ)
{
var trans = panle3D.Transform as TranslateTransform3D;
trans.OffsetX = x;
trans.OffsetY = y;
trans.OffsetZ = z;
panle3D.Transform = new TranslateTransform3D(x, y, z);
}
//设置灯光
Color color;
if (copter.LEDColor != null && copter.LEDColor != "")
{
color = (Color)ColorConverter.ConvertFromString("#" + copter.LEDColor);
panle3D.Material = MaterialHelper.CreateMaterial(color);
// panle3D.BackMaterial = MaterialHelper.CreateMaterial(color);
panle3D.BackMaterial = MaterialHelper.CreateMaterial(color);
}
//else
// color = (Color)ColorConverter.ConvertFromString("#" + CopterManager.CopterDefaultColor);
}
/*
// Color color;
if (copter.LEDShowColor != null)
{
Color currcolor = System.Windows.Media.Color.FromArgb(
copter.LEDShowColor.A, copter.LEDShowColor.R, copter.LEDShowColor.G, copter.LEDShowColor.B);
{
((panle3D.Material as DiffuseMaterial).Brush as SolidColorBrush).Color = currcolor;
}
}
*/
}
//Message.Show("添加3D飞机" + copter.Name);
}
@ -251,12 +222,16 @@ namespace Plane.FormationCreator.ViewModels
waypointGroup.Children.Clear();
if (_flightTaskManager.SelectedTaskIndex > 0)
{
//观测点的位置放到最后排飞机的中间位置
Tuple<double, double> observationLatLng;
//得到观测位置
if (observationLatLng == null)
{
getobservationpos();
}
//列的中间位置
float midDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, _flightTaskManager.Orientation + 90, midDistance);
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
observationLatLng.Item1, observationLatLng.Item2, _flightTaskManager.Orientation + 180, midDistance * 2);
//modelGroup.Children.Clear();

View File

@ -6,8 +6,8 @@
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="校准" Height="329" Width="455">
<Grid Margin="0,0,0,7">
Title="校准" Height="320" Width="450">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70*"/>
<RowDefinition Height="30*"/>
@ -25,16 +25,12 @@
</StackPanel>
<StackPanel Grid.Row="1" Margin="10,0,10,10">
<Label Content="其他" Margin="0,0,0,10" FontWeight="Bold" FontSize="14"/>
<Label Content="指南针" Margin="0,0,0,10" FontWeight="Bold" FontSize="14"/>
<WrapPanel HorizontalAlignment="Center">
<Button Content="开始校准" Width="100" Margin="10, 0"
Command="{Binding CalibrationCompassCommand}"/>
<Button Content="放弃校准" Width="100" Margin="10, 0"
Command="{Binding CancelCalibrationCompassCommand}" Visibility="Collapsed"/>
<Button Content="校准指南针" Width="120"
Command="{Binding CalibrationCompassCommand}"/>
<Button Content="校准陀螺仪" Width="120" Margin="20, 0"
Command="{Binding CalibrationPreflightCommand}"/>
<Button Content="重启飞控" Width="100" Margin="10, 0"
Command="{Binding RestartFCCommand}"/>
</WrapPanel>
<ProgressBar Margin="0,20" Height="18" Width="220" Value="{Binding CompassPercent, UpdateSourceTrigger=PropertyChanged}"/>

View File

@ -8,7 +8,7 @@
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
mc:Ignorable="d"
Title=""
Width="565.58"
Width="500"
Height="325.107"
WindowStartupLocation="CenterScreen"
@ -24,10 +24,11 @@
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="50" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@ -43,11 +44,9 @@
<TextBox Width="30" VerticalContentAlignment="Center" Text="{Binding CopterNum}" Margin="5,5,5,5" />
<TextBlock Margin="5" VerticalAlignment="Center" Text="参数:" />
<TextBox Width="56" VerticalContentAlignment="Center" Text="{Binding CopterColor}" Margin="5,5,5,5"/>
<Button Content="对频" Width="67" Margin="5,5,5,5" Command="{Binding Path=WriteIdCommand}" ToolTip="ID框输入新编号" />
<Button Content="闪灯 " Width="67" Margin="5,5,5,5" Command="{Binding CommDataAsync}" ToolTip="参数为十六进制颜色"/>
<Button Content="拉烟" Width="67" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}" ToolTip="参数为通道号1-4"/>
<Button Content="抛物" Width="67" Margin="5,5,5,5" Command="{Binding TestPWMCommandAsync}" ToolTip="接入舵机控制"/>
<Button Content="功率" Width="67" Margin="5,5,5,5" Command="{Binding SetModulePowerCommand}" ToolTip="设置模块回传功率"/>
<Button Content="对频" Width="67" Margin="5,5,5,5" Command="{Binding Path=WriteIdCommand}" />
<Button Content="闪灯 " Width="67" Margin="5,5,5,5" Command="{Binding CommDataAsync}"/>
<Button Content="拉烟" Width="67" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}"/>
</StackPanel>
@ -56,27 +55,15 @@
Grid.Row="1"
Name="panel4" >
<Button Content="立体缩放" Width="90" Margin="5,5,5,5" Command="{Binding UpdateAllCopterCommand}"></Button>
<TextBlock Margin="5" VerticalAlignment="Center" Text="比例/模块号:" />
<TextBlock Margin="5" VerticalAlignment="Center" Text="比例:" />
<TextBox Width="30" VerticalContentAlignment="Center" Text="{Binding scale3d}" Margin="5,5,5,5" />
<Button Content="更改密码" Width="90" Margin="5,5,5,5" Command="{Binding ChangepasswordCommand}"></Button>
<Button Content="测试模块" Width="90" Margin="5,5,5,5" Command="{Binding TestModuleCommand}" ToolTip="测试地面站通讯模块1-8"></Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="2" Name="panel7" >
<Button Content="{Binding btnBoardPortStr}" Width="115" Margin="5,5,5,5" Command="{Binding Openboardport}"/>
<ComboBox Width="90" Height="25" Foreground="White" SelectedIndex="0"
ItemsSource="{Binding serialRePorts, Mode=OneWay}"
SelectedValue="{Binding SerialPortResend}"
DropDownOpened="ComboBox_DropDownOpened"/>
<TextBlock Margin="10,5,5,5" VerticalAlignment="Center" Text="{Binding BoardPortStatusStr}" />
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="3"
Grid.Row="2"
Name="panel2" >
<TextBlock Margin="5" VerticalAlignment="Center" Text="总数:" />
<TextBox Width="45" VerticalContentAlignment="Center" Text="{Binding CopterSum}" Margin="5,5,5,5" />
@ -87,7 +74,7 @@
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="4"
Grid.Row="3"
Name="panel3" >
<Button Content="空中升级" Width="90" Margin="5,5,5,5" Command="{Binding UpdateAllCopterCommand}"></Button>
<Button Content="搜索飞机" Width="90" Margin="5,5,5,5" Command="{Binding QueryAllCopterCommand}"/>
@ -97,9 +84,9 @@
<Image Margin="0,0,0,0" x:Name="image1" Grid.RowSpan="2" Grid.Row="5" Source="/Resources/Logo_small.png" HorizontalAlignment="Left" />
<TextBlock Margin="5" Grid.Row="6" x:Name="about_ver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="版本V2.0.1213" />
<TextBlock Margin="5" Grid.Row="7" HorizontalAlignment="Right" x:Name="about_buildtm" VerticalAlignment="Bottom" Text="编译日期2020.12.12" />
<Image Margin="0,0,0,0" x:Name="image1" Grid.RowSpan="2" Grid.Row="4" Source="/Resources/Logo_small.png" HorizontalAlignment="Left" />
<TextBlock Margin="5" Grid.Row="5" x:Name="about_ver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="版本V2.0.1213" />
<TextBlock Margin="5" Grid.Row="6" HorizontalAlignment="Right" x:Name="about_buildtm" VerticalAlignment="Bottom" Text="编译日期2020.12.12" />

View File

@ -46,20 +46,14 @@ namespace Plane.FormationCreator.Views
panel2.Visibility = Visibility.Collapsed;
panel3.Visibility = Visibility.Collapsed;
}
CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
var version = Assembly.GetExecutingAssembly().GetName().Version;
about_ver.Text = "版本:" + version.ToString() + "(飞控兼容:" + _copterManager.FC_VER_STRING + ")";
about_buildtm .Text= "编译时间:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString();
about_ver.Text = "版本:" + version.ToString();
about_buildtm .Text= "编译时间:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString()+"(兼容4.1.2之前固件)";
//txtIPs.Focus();
}
ConnectViewModel _ConnectViewModel = ServiceLocator.Current.GetInstance<ConnectViewModel>();
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
_ConnectViewModel.RefreshPorts();
}
}
}

View File

@ -43,8 +43,11 @@
<Button Content="通讯版本" Command="{Binding DetectionCommModuleVersion}" />
<Button Content="统计返回"
Command="{Binding DetectionReturnData}" />
<Button Content="通讯统计"
Command="{Binding GetCommsumCommand}" />
<TextBlock
Margin="5,5,5,5" Foreground ="Red" VerticalAlignment="Center"
Text="{Binding RTKState}"
/>
</WrapPanel>
<WrapPanel>
@ -52,20 +55,15 @@
Command="{Binding ParamModify}" />
<Button Content="读入参数"
Command="{Binding LoadParamfile}" />
<Button Content="状态统计" Command="{Binding ReportGPSTypeCommand}"/>
<Button Content="定位统计" Command="{Binding ReportGPSTypeCommand}"/>
<Button Content="飞机校准"
Command="{Binding CalibrationSingleCommand}" />
<Button Content="正式参数" Command="{Binding TurnOffTestLightsCommand}" Visibility="Collapsed" />
<Button Content="电机" Visibility="Collapsed"
<Button Content="电机测试"
Command="{Binding MotorTestCommand}" />
<Button Content="删除飞机"
Command="{Binding DelCommand}" />
<Label Visibility="Collapsed" Content="Lat"/>
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
<Label Visibility="Collapsed" Content="Lng"/>
@ -113,11 +111,10 @@
Command="{Binding UnlockCommand}" />
<Button Content="加锁"
Command="{Binding LockCommand}" />
<Button Content="单独任务"
<Button Content="起飞" Visibility="Collapsed"
Command="{Binding TakeOffCommand}" />
<Button Content="抛物"
Command="{Binding ThrowoutCommand}" />
</WrapPanel>
<WrapPanel>
@ -193,13 +190,10 @@
<WrapPanel>
<Button Content="全部降落"
<Button Content="全部降落"
Command="{Binding AllLandCommand}" />
<Button Content="紧急返航"
Command="{Binding EmergencyRetCommand}" />
<Button Content="重设任务"
Command="{Binding ResetRealMissionCommand}" />
</WrapPanel>
</StackPanel>

View File

@ -17,7 +17,7 @@
<Label Margin="5,0,0,0" Content="属性设置" VerticalAlignment="Center"/>
<Separator></Separator>
<StackPanel Margin="5,0,0,5" Orientation="Horizontal" HorizontalAlignment="Left">
<Label Margin="0" Content="摆放高度(米)" ></Label>
<Label Margin="0" Content="摆放高度" ></Label>
<TextBox
Margin="30,0"
Width="80"

View File

@ -12,12 +12,9 @@
d:DataContext="{d:DesignInstance Type=ec:FakeCopter, IsDesignTimeCreatable=True}">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="14" />
</Style>
@ -178,10 +175,9 @@
<StackPanel>
<TextBlock Text="飞行信息" />
<TextBlock Text="飞行信息" />
<Grid>
<Grid.Resources>
<Grid.Resources>
<Style x:Key="CopterInfo_ComboBox"
TargetType="ComboBox"
BasedOn="{StaticResource {x:Type ComboBox}}">
@ -204,7 +200,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Vertical">
<StackPanel.Resources>
<Style TargetType="ComboBox"
BasedOn="{StaticResource CopterInfo_ComboBox}" />
@ -254,19 +250,36 @@
<TextBlock Text="高度:" />
<TextBlock Text="{Binding Altitude, StringFormat=0.##}" />
</StackPanel>
<StackPanel>
<TextBlock Text="距离:" />
<TextBlock Text="{Binding FlightDistance, StringFormat=0.##}" />
</StackPanel>
<StackPanel>
<TextBlock Text="锁定类型:" />
<TextBlock Text="{Binding GpsFixType}" />
</StackPanel>
<StackPanel>
<TextBlock Text="预检查状态:" />
<TextBlock Text="{Binding CopterPreCheckPassStr}"
Foreground="{Binding CopterPreCheckPass, Converter={StaticResource PrecheckToColorConverter}}" />
</StackPanel>
</StackPanel>
<TextBlock Text="返回数据:" />
<StackPanel ToolTip="{Binding RetainInt}">
<TextBlock Text="{Binding Retain[3]}" />
<TextBlock Text="." />
<TextBlock Text="{Binding Retain[2]}" />
<TextBlock Text="." />
<TextBlock Text="{Binding Retain[1]}" />
<TextBlock Text="." />
<TextBlock Text="{Binding Retain[0]}" />
</StackPanel>
</StackPanel>
<!--
<StackPanel>
<TextBlock Text="固件版本:" />
<TextBlock Text="{Binding FirmwareVersionText}" />
</StackPanel>-->
</StackPanel>
<StackPanel Grid.Row="1"
Grid.Column="1"
Orientation="Vertical">
@ -276,12 +289,28 @@
<Style TargetType="StackPanel"
BasedOn="{StaticResource CopterInfo_StackPanel}" />
</StackPanel.Resources>
<StackPanel Visibility="Hidden">
<TextBlock Text="电压值:" />
<TextBlock Text="{Binding Path=Voltage}" />
</StackPanel>
<StackPanel>
<StackPanel>
<TextBlock Text="电压:" />
<Slider x:Name="sldChannel3"
Width="75"
Minimum="1100"
Maximum="1900"
Value="{Binding Channel3, Mode=OneWay}"
ValueChanged="sldChannel3_ValueChanged">
<Slider.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Slider.Resources>
</Slider>
</StackPanel>
<StackPanel>
<TextBlock Text="电压值:" />
<TextBlock Text="{Binding Path=Voltage}" />
</StackPanel>
@ -302,30 +331,29 @@
<TextBlock Text="经度:" />
<TextBlock Text="{Binding Longitude}" />
</StackPanel>
<StackPanel>
<TextBlock Text="通道3" />
<TextBlock Text="{Binding Channel3}" />
</StackPanel>
<StackPanel>
<TextBlock Text="通道4" />
<TextBlock Text="{Binding Channel4}" />
</StackPanel>
<StackPanel>
<TextBlock Text="定位精度:" />
<TextBlock Text="{Binding GpsHdop, StringFormat=0.##}" />
</StackPanel>
<StackPanel>
<TextBlock Text="通信模块版本:" />
<TextBlock Text="{Binding CommModuleVersion}" />
</StackPanel>
<StackPanel>
<TextBlock Text="返回数据:" />
<StackPanel Margin="0,0,0,0" Height="14" ToolTip="{Binding RetainInt}">
<TextBlock Margin="0,-1,0,0" Text="{Binding Retain[3]}" />
<TextBlock Margin="0,-1,0,0" Text="." />
<TextBlock Margin="0,-1,0,0" Text="{Binding Retain[2]}" />
<TextBlock Margin="0,-1,0,0" Text="." />
<TextBlock Margin="0,-1,0,0" Text="{Binding Retain[1]}" />
<TextBlock Margin="0,-1,0,0" Text="." />
<TextBlock Margin="0,-1,0,0" Text="{Binding Retain[0]}" />
</StackPanel>
</StackPanel>
<StackPanel >
<TextBlock Text="最后异常:" />
<TextBlock Text="{Binding CopterErrorString}"/>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
</UserControl>

View File

@ -31,9 +31,9 @@
</ContextMenu>
</UserControl.Resources>
<Grid Width="550">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="540"/>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
@ -91,9 +91,6 @@
<TextBox Width="30" Margin="5,0" VerticalContentAlignment="Center" Text="{Binding ContinuousNum}"/>
<TextBlock Text="间隔数量" Margin="5,5,0,0"/>
<TextBox Width="30" Margin="5,0" VerticalContentAlignment="Center" Text="{Binding IntervalNum}"/>
<TextBlock Text="间隔排数" Margin="5,5,0,0"/>
<TextBox Width="30" Margin="5,0" VerticalContentAlignment="Center" Text="{Binding RowNum}"/>
<TextBlock Text="选中个数" Margin="5,5,0,0"/>
<TextBlock Width="30" Margin="5,5,0,0" Text="{Binding CopterManager.SeletedCopterCount, UpdateSourceTrigger=PropertyChanged}"/>

View File

@ -16,8 +16,6 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
using System.Windows.Threading;
namespace Plane.FormationCreator.Views
{
@ -46,46 +44,21 @@ namespace Plane.FormationCreator.Views
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
private void SelectitemMessage(ICopter copter)
{
////需要访问UI线程可能在其他线程里面
Dispatcher dispatcher = Dispatcher.FromThread(Thread.CurrentThread);
if (dispatcher != null)
if (copter == null)
{
if (copter == null)
lvwDrones.SelectedItems.Clear();
}
else
{
if (!_copterManager.shiftkeydown)
{
lvwDrones.SelectedItems.Clear();
lvwDrones.SelectedItem = copter;
}
else
{
if (!_copterManager.shiftkeydown)
{
lvwDrones.SelectedItems.Clear();
lvwDrones.SelectedItem = copter;
}
else
lvwDrones.SelectedItems.Add(copter);
}
}else
lvwDrones.SelectedItems.Add(copter);
}
lvwDrones.Dispatcher.BeginInvoke(new Action(() =>
{
if (copter == null)
{
lvwDrones.SelectedItems.Clear();
}
else
{
if (!_copterManager.shiftkeydown)
{
lvwDrones.SelectedItems.Clear();
lvwDrones.SelectedItem = copter;
}
else
lvwDrones.SelectedItems.Add(copter);
}
}));
}

View File

@ -1,30 +0,0 @@
<Window x:Class="Plane.FormationCreator.Views.InputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ignore="http://www.galasoft.ch/ignore"
Title="输入窗口" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
ContentRendered="Window_ContentRendered" ResizeMode="NoResize">
<Grid Margin="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="/FGCS;component/Resources/logo_big.png" Width="40" Height="40" Grid.RowSpan="2" Margin="20,0" />
<Label Name="lblQuestion" Grid.Column="1">最低更换电压:</Label>
<TextBox Name="txtAnswer" Grid.Column="1" Grid.Row="1" MinWidth="250">15.6</TextBox>
<WrapPanel Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button IsDefault="True" Name="btnDialogOk" Click="btnDialogOk_Click" MinWidth="60" Margin="0,0,10,0">确定</Button>
<Button IsCancel="True" MinWidth="60">取消</Button>
</WrapPanel>
</Grid>
</Window>

View File

@ -1,31 +0,0 @@
using System;
using System.Windows;
namespace Plane.FormationCreator.Views
{
public partial class InputDialog : Window
{
public InputDialog(string question, string defaultAnswer = "")
{
InitializeComponent();
lblQuestion.Content = question;
txtAnswer.Text = defaultAnswer;
}
private void btnDialogOk_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
private void Window_ContentRendered(object sender, EventArgs e)
{
txtAnswer.SelectAll();
txtAnswer.Focus();
}
public string Answer
{
get { return txtAnswer.Text; }
}
}
}

View File

@ -1,5 +1,4 @@
using Microsoft.Practices.ServiceLocation;
using Plane.FormationCreator.Formation;
using Plane.FormationCreator.ViewModels;
using System.Reflection;
using System.Windows;
@ -21,8 +20,7 @@ namespace Plane.FormationCreator.Views
LoginViewModel loginViewModel = ServiceLocator.Current.GetInstance<LoginViewModel>();
this.DataContext = loginViewModel;
var version = Assembly.GetExecutingAssembly().GetName().Version;
CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
about_ver.Content = "版本:" + version.ToString() + "(飞控兼容:"+ _copterManager.FC_VER_STRING + ")";
about_ver.Content = "版本:" + version.ToString()+ "(兼容版)";
}
}

View File

@ -140,7 +140,30 @@ namespace Plane.FormationCreator.Views
gmap.MouseDoubleClick += async (sender, e) =>
{
};
e.Handled = true;
//// Test
//var pos = map.ViewportPointToLocation(e.GetPosition(map));
//AddOrMoveCopter(new FakeCopter(pos.Latitude, pos.Longitude));
// 林俊清, 20150930, AppMode 存在意义已不大;只有正在运行任务的时候才不允许指点。
//if (AppEx.Current.AppMode != AppMode.ControllingCopters) return;
if (_flightTaskManager.IsPaused == false) return;
var copters = _copterManager.AcceptingControlCopters;
if (!copters.Any()) return;
Point clickPoint = e.GetPosition(gmap);
var pos = gmap.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y);
var centerLat = copters.Average(c => c.Latitude);
var centerLng = copters.Average(c => c.Longitude);
var latDelta = pos.Lat - centerLat;
var lngDelta = pos.Lng - centerLng;
await Task.WhenAll(copters.Select(copter => copter.FlyToAsync(copter.Latitude + latDelta, copter.Longitude + lngDelta, copter.Altitude)));
};
var center = _appConfig.Center;
gmap.Position = new LatLng(center.Lat, center.Lng).ToGCJ02();
@ -162,19 +185,6 @@ namespace Plane.FormationCreator.Views
originalMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
}
if (observerMarker != null && gmap.Markers.Contains(observerMarker))
{
PointLatLng location = new LatLng(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng).ToGCJ02();
GPoint wpPos = gmap.FromLatLngToLocal(location);
//Point wpPos = gmap.LocationToViewportPoint(location);
wpPos.X -= (long)ORIGIN_RADIUS;
wpPos.Y -= (long)ORIGIN_RADIUS;
observerMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
}
};
GMapMarker rectangleMarker = null;
@ -268,9 +278,6 @@ namespace Plane.FormationCreator.Views
gmap.MouseMove += new MouseEventHandler(OriginalMove);
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(OriginalMouseUp);
gmap.MouseMove += new MouseEventHandler(observerMove);
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(observerMouseUp);
}
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
@ -281,7 +288,6 @@ namespace Plane.FormationCreator.Views
const string COPTER_TAG = "Copter";
const string WAYPOINT_TAG = "Waypoint";
const string ORIGINALPOINT_TAG = "Originalpoint";
const string OBSERVER_TAG = "Observerpoint";
public void Refresh()
{
@ -331,8 +337,6 @@ namespace Plane.FormationCreator.Views
private void Copter_LocationChanged(object sender, EventArgs e)
{
if (!_flightTaskManager.TaskRun_2D) return; //不在3D模式运行直接退出
var copter = sender as ICopter;
if (App.Current.CheckAccess())
{
@ -440,8 +444,7 @@ namespace Plane.FormationCreator.Views
// }
}
GMapMarker observerMarker = null;
Microsoft.Expression.Shapes.RegularPolygon observer = null;
GMapMarker originalMarker = null;
Microsoft.Expression.Shapes.RegularPolygon original = null;
const double ORIGIN_RADIUS = 12;
@ -480,131 +483,8 @@ namespace Plane.FormationCreator.Views
_flightTaskManager.OriginLng = location.Lng;
original.MouseLeftButtonDown += new MouseButtonEventHandler(OriginalMouseDown);
///加入或者改变观测点用于3D模拟
if (gmap.Markers.Contains(observerMarker))
gmap.Markers.Remove(observerMarker);
observer = new Microsoft.Expression.Shapes.RegularPolygon
{
Tag = OBSERVER_TAG,
Fill = new SolidColorBrush(Color.FromArgb(200, 3, 155, 3)),
Stroke = new SolidColorBrush(Color.FromArgb(200, 3, 80, 238)),
StrokeThickness = 1,
Width = ORIGIN_RADIUS *2,
Height = ORIGIN_RADIUS * 2,
InnerRadius = 1,
PointCount = 6,
};
if (_flightTaskManager.ObserverLat == 0)
{
Tuple<double, double> observationLatLng = null;
//第一列到中间的距离
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
_flightTaskManager.OriginLat,
_flightTaskManager.OriginLng,
_flightTaskManager.Orientation + 90,
midColDistance);
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
observationLatLng.Item1,
observationLatLng.Item2,
_flightTaskManager.Orientation + 180,
midColDistance * 4);
_flightTaskManager.ObserverLat = observationLatLng.Item1;
_flightTaskManager.ObserverLng = observationLatLng.Item2;
}
//_flightTaskManager.ObserverLat = _flightTaskManager.OriginLat;
//_flightTaskManager.ObserverLng = _flightTaskManager.OriginLng;
PointLatLng Observerlocation = new LatLng(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng).ToGCJ02();
GPoint opoint = gmap.FromLatLngToLocal(Observerlocation);
opoint.X -= (long)ORIGIN_RADIUS;
opoint.Y -= (long)ORIGIN_RADIUS;
mapLocation = gmap.FromLocalToLatLng((int)opoint.X, (int)opoint.Y);
observerMarker = new GMapMarker(mapLocation);
observerMarker.ZIndex = 200;
observerMarker.Shape = observer;
observerDrag = false;
observer.MouseLeftButtonDown += new MouseButtonEventHandler(observerMouseDown);
gmap.Markers.Add(observerMarker);
}
private bool observerDrag = false;
double observerX = 0;
double observerY = 0;
private void observerMouseDown(object sender, MouseButtonEventArgs e)
{
observerDrag = true;
gmap.CanDragMap = false;
var originPoint = e.GetPosition(gmap);
observerX = originPoint.X;
observerX = originPoint.Y;
var posInObject = e.GetPosition(observer);
wpOffsetX = posInObject.X;
wpOffsetY = posInObject.Y;
}
private void observerMove(object sender, MouseEventArgs e)
{
if (observerDrag)
{
Point eventPos = e.GetPosition(gmap);
var leftTopPos = new Point(eventPos.X - wpOffsetX, eventPos.Y - wpOffsetY);
observerMarker.Position = gmap.FromLocalToLatLng((int)leftTopPos.X, (int)leftTopPos.Y);
//MapLayer.SetPosition(original, map.ViewportPointToLocation(leftTopPos));
}
}
private void observerMouseUp(object sender, MouseButtonEventArgs e)
{
if (observerDrag)
{
Point eventPos = e.GetPosition(gmap);
var centrePos = new Point(eventPos.X - wpOffsetX + ORIGIN_RADIUS, eventPos.Y - wpOffsetY + ORIGIN_RADIUS);
PointLatLng location = gmap.FromLocalToLatLng((int)centrePos.X, (int)centrePos.Y);
_flightTaskManager.ObserverLat = location.Lat;
_flightTaskManager.ObserverLng = location.Lng;
// original.ToolTip = location.ToString();
//Clipboard.SetDataObject(string.Format("{0},{1}", location.Lat, location.Lng), true);
observerDrag = false;
gmap.CanDragMap = true;
}
}
private bool originaDrag = false;
double originX = 0;
double originY = 0;

View File

@ -269,24 +269,16 @@ namespace Plane.FormationCreator.Views
}
}
switch (_copterManager.SortType)
if (Copter.DisplayVirtualId)
{
case CopterManager.CopterSortType.ByID:
CopterText.Text = Copter.Name;
CopterText.Foreground = new SolidColorBrush(Colors.White);
break;
case CopterManager.CopterSortType.ByVID:
case CopterManager.CopterSortType.ByVIDShowAll:
CopterText.Text = Copter.VirtualId.ToString();
CopterText.Foreground = new SolidColorBrush(Colors.Yellow);
break;
default:
CopterText.Text = Copter.Name;
CopterText.Foreground = new SolidColorBrush(Colors.White);
break;
CopterText.Text = Copter.VirtualId.ToString();
CopterText.Foreground = new SolidColorBrush(Colors.Yellow);
}
else
{
CopterText.Text = Copter.Name;
CopterText.Foreground = new SolidColorBrush(Colors.White);
}
if (Copter.GetShowLEDAsync())
@ -578,8 +570,7 @@ namespace Plane.FormationCreator.Views
// routePoint.Lng = info.TargetLng;
if (Route != null)
{
if (Route.Points.Count>1)
Route.Points.RemoveAt(1);
Route.Points.RemoveAt(1);
Route.Points.Add(marker.Position);
this.Route.RegenerateShape(_map);
}

View File

@ -70,17 +70,10 @@
<TextBlock Margin="0,5,5,0" Text="所有:" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Margin="0,5,5,0" Content="导入航点" Command="{Binding ImportWayPointCommand}"
Visibility="Collapsed"/>
<Button Margin="0,5,5,0" Content="2D航线" Width="82" Command="{Binding OptimizeRouteCommand}"
<Button Margin="0,5,5,0" Content="优化路线" Width="105" Command="{Binding OptimizeRouteCommand}"
/>
<Button Margin="0,5,5,0" Content="3D航线" Width="82" Command="{Binding OptimizeRouteCommand3D}"
/>
<Button Margin="0,5,5,0" Content="2D对应" Width="82" Command="{Binding OptimizeRouteCommandRet}"
/>
<Button Margin="0,5,5,0" Content="3D对应" Width="82" Command="{Binding OptimizeRouteCommandRet3D}"
/>
<Button Margin="0,5,5,0" Content="导出到C4D" Width="105" Command="{Binding ExportWayPointCommand}"/>
<Button Margin="0,5,5,0" Content="估计时间" Width="105" Command="{Binding AutoWayPointTmCommand}"/>
</StackPanel>
<StackPanel>
@ -97,7 +90,6 @@
Margin="0,5,5,0" Width="105"
Command="{Binding BackTakeOffPointCommand}" />
<Button Margin="0,5,5,0" Content="计算时间" Width="105" Command="{Binding AutoWayPointTmCommand}"/>
</StackPanel>
@ -245,7 +237,7 @@
</Grid.ColumnDefinitions>
<CheckBox Content="返航点" ToolTip="勾选后航点仅高度有用,经纬度无效,无视原点自动飞回起飞点" Margin="0,5,0,0" IsChecked="{Binding IsLandWaypoint,UpdateSourceTrigger=PropertyChanged}" />
<Button Content="影响所有飞机" Margin="0,2,5,0" IsEnabled="False" Command="{Binding SetIsLandCommand}" Grid.Column="1"/>
<Button Content="应用到所选" Margin="0,2,5,0" Command="{Binding SetIsLandCommand}" Grid.Column="1"/>
</Grid>
@ -262,7 +254,7 @@
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox Content="改变最大速度" Margin="0,3"
<CheckBox Content="改变速度" Margin="0,3"
IsChecked="{Binding IsChangeSpeed, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Margin="0,0" Grid.Column="1">
<TextBlock Text="水平" Margin="0,0,5,5" VerticalAlignment="Center" HorizontalAlignment="Left"/>
@ -275,7 +267,7 @@
<TextBox Width="45" Margin="5,0,5,5" VerticalAlignment="Center"
Text="{Binding DownSpeed, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
<Button Content="改变后需重新计算飞行时间" IsEnabled="False" Margin="5,0,5,5" Grid.Row="1" Grid.Column="1" Command="{Binding SetIsChangeCommand}"/>
<Button Content="应用到所选" Margin="5,0,5,5" Grid.Row="1" Grid.Column="1" Command="{Binding SetIsChangeCommand}"/>
</Grid>
</StackPanel>
@ -500,23 +492,17 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate x:Name="LEDTemplate">
<DataTemplate>
<StackPanel Margin="0,5,0,0" Orientation="Horizontal" >
<TextBlock Text="类型" Margin="0,0,0,0" VerticalAlignment="Center" ></TextBlock>
<ComboBox x:Name="cmbTemplateLEDMode" Height="25" MinWidth="125" Width="110" Margin="5,0,0,0" Foreground="White" VerticalContentAlignment="Center"
SelectedIndex="{Binding Path=LEDMode}"
Loaded="OnCBLoaded" Initialized="cmbTemplateLEDMode_Initialized"
>
<ComboBox Height="25" MinWidth="125" Width="110" Margin="5,0,0,0" Foreground="White" VerticalContentAlignment="Center"
SelectedIndex="{Binding Path=LEDMode}">
<ComboBox.ItemContainerStyle>
<Style>
<Setter Property="ComboBoxItem.Foreground" Value="White"/>
</Style>
</ComboBox.ItemContainerStyle>
<ComboBoxItem Content="代码里面动态添加--这里数量要够" />
<ComboBoxItem Content="常亮" />
<ComboBoxItem Content="同步闪烁(单色)" />
<ComboBoxItem Content="异步闪烁(随机)" />
<ComboBoxItem Content="渐亮" />
@ -525,25 +511,17 @@
<ComboBoxItem Content="同步闪烁(随机)" />
<ComboBoxItem Content="异步闪烁(单色)" />
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
<ComboBoxItem Content="拉烟"/>
</ComboBox>
<TextBlock Text="时间" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
<TextBox Height="25" MinWidth="40" MaxWidth="45" Margin="5,0,0,0"
ToolTip="相对延迟时间,最小0.1秒"
ToolTip="单位:秒最小设置0.1秒"
Text="{Binding Delay,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="频率" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
<TextBox Height="25" MinWidth="35" MaxWidth="40" Margin="5,0,0,0"
ToolTip="单位:HZ最小设置0.1HZ"
ToolTip="单位:HZ最小设置1HZ"
Text="{Binding Path=LEDInterval, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="颜色" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
@ -572,65 +550,37 @@
<StackPanel x:Name="PanelDesign1">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" >
<Button Width="120" Margin="10,5,0,5" Content="导入外部航点" Command="{Binding ImportBlenderWayPointCommand}"/>
<Button Width="120" Margin="10,5,0,5" Content="导入起飞位置" Command="{Binding ImportBlenderCopterPosCommand}"/>
<Button Width="120" Content="计算飞行时间" Margin="10,5,0,5"
<Button Width="120" Content="自动飞行时间" Margin="10,5,0,5"
Command="{Binding AutoWayPointAllTmCommand}" HorizontalAlignment="Right" />
<Button Width="120" Content="检查飞行时间" Margin="10,5,0,5"
Command="{Binding CheckTmCommand}" HorizontalAlignment="Right" />
<Button Width="120" Content="飞行图案" Margin="10,5,0,5"
Command="{Binding SetHorseRaceLampCommand}" Visibility="Collapsed" HorizontalAlignment="Right" Height="26"/>
<Button Width="120" Content="飞行图案设计" Margin="10,5,0,5"
Command="{Binding SetHorseRaceLampCommand}" HorizontalAlignment="Right" Height="26"/>
</StackPanel>
<Separator Margin="5,0,5,0" />
</StackPanel>
<StackPanel x:Name="PanelDesign2">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" >
<TextBlock Text="开始任务" Margin="10, 5, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBox
Width="35"
Margin="6,5,0,5" Height="26"
HorizontalContentAlignment="Right"
Text="{Binding taskstartno, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="结束任务" Margin="20, 5, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBox
Width="35"
Margin="0,5,0,5" Height="26"
HorizontalContentAlignment="Right"
Text="{Binding taskendno, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5" >
<Button Content="水平旋转" Width="120"
<Button Content="整体旋转" Width="120"
Margin="10,5,0,5" Height="26"
ToolTip="用于整体飞行方向调整,地面飞机矩阵同时旋转"
Command="{Binding TaskRotateCommand}"
CommandParameter="{Binding ElementName=txtAlignmentLine1, Path=Text}"/>
<Button Content="垂直旋转" Width="120"
Margin="10,5,5,5" Height="26"
ToolTip="用于多个任务同时倾斜角度,旋转中心为各任务的共同中心,各任务图案位置尽量重叠"
Command="{Binding MitTaskVrotationCommand}"
CommandParameter="{Binding ElementName=txtAlignmentLine1, Path=Text}" />
<TextBox x:Name="txtAlignmentLine1"
Width="40"
Margin="6,5,0,5" Height="26"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Center"
Text="{Binding taskdirection, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="度" Margin="10, 5, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
Width="120"
Margin="10,5,0,5" Height="26"
Text="0"
VerticalContentAlignment="Center" />
<TextBlock Text="度" Margin="10, 10, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5" >
<Button Content="调整高度"
<Button Content="整体调整高度"
Width="120"
Margin="10,5,0,5" Height="26"
Command="{Binding ModiAltCommand}"
CommandParameter="{Binding ElementName=txtModialtvalue, Path=Text}"
/>
<Button Content="移动"
<Button Content="整体移动"
Width="120"
Margin="10,5,0,5" Height="26"
Command="{Binding ModiAllPosCommand}"
@ -639,24 +589,20 @@
<TextBox x:Name="txtModialtvalue"
Grid.Column="1"
Width="40"
Width="35"
Margin="10,5,0,5" Height="26"
HorizontalContentAlignment="Right"
Text="0"/>
<TextBlock Text="米 方向" Margin="10, 5, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Text="米 方向" Margin="5, 10, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBox Grid.Column="1" x:Name="txtdirectionvalue"
Width="40"
Width="35"
Margin="0,5,0,5" Height="26"
HorizontalContentAlignment="Right"
Text="{Binding directionvalueall, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="度" Margin="5, 5, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Text="度" Margin="5, 10, 5, 0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<Separator Margin="5,0,5,0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5" >
@ -666,10 +612,8 @@
Command="{Binding ShowallTaskpointCommand}"
/>
<Button Content="计算任务数" Width="120"
Margin="10,5,0,5" Height="26"
Command="{Binding CheckMissionCountCommand}"
/>
</StackPanel>
@ -677,8 +621,6 @@
</StackPanel>
</TabItem>

View File

@ -29,36 +29,11 @@ namespace Plane.FormationCreator.Views
{
private int[] defcolor= { 255, 65280, 16711680, 65535 , 16711935, 16776960,0 };
ModifyTaskViewModel _modifyTaskViewModel = ServiceLocator.Current.GetInstance<ModifyTaskViewModel>();
CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
private childItem FindVisualChild<childItem>(DependencyObject obj)
where childItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
{
return (childItem)child;
}
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
public ModifyTaskView()
{
InitializeComponent();
this.DataContext = _modifyTaskViewModel;
if (!VersionControl.IsFullVersion)
{
//lightDesign.Visibility = Visibility.Collapsed;
@ -67,48 +42,27 @@ namespace Plane.FormationCreator.Views
private void Button_Click(object sender, RoutedEventArgs e)
{
/*
DependencyObject myListItem = LEDItems.ItemContainerGenerator.ContainerFromItem(LEDItems.Items.CurrentItem);
ContentPresenter myContentPresenter = FindVisualChild<ContentPresenter>(myListItem);
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
ComboBox ledcomb = (ComboBox)myDataTemplate.FindName("cmbTemplateLEDMode", myContentPresenter);
// ledcomb.SelectedIndex = 2;
// distanceCopters.Text;
/*
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
int firstIndex = int.Parse( firstCopter.Text );
int secondIndex = int.Parse( secondCopter.Text );
if (_flightTaskManager.SelectedTask != null)
{
var firstCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[firstIndex-1];
var secondCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[secondIndex-1];
double distance = GeographyUtils.CalcDistance(firstCopterInfo.TargetLat, firstCopterInfo.TargetLng, firstCopterInfo.TargetAlt,
secondCopterInfo.TargetLat, secondCopterInfo.TargetLng, secondCopterInfo.TargetAlt);
distanceCopters.Text = ((double)Math.Round(distance*100)/100).ToString();
}
*/
// distanceCopters.Text;
/*
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
int firstIndex = int.Parse( firstCopter.Text );
int secondIndex = int.Parse( secondCopter.Text );
if (_flightTaskManager.SelectedTask != null)
{
var firstCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[firstIndex-1];
var secondCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos[secondIndex-1];
double distance = GeographyUtils.CalcDistance(firstCopterInfo.TargetLat, firstCopterInfo.TargetLng, firstCopterInfo.TargetAlt,
secondCopterInfo.TargetLat, secondCopterInfo.TargetLng, secondCopterInfo.TargetAlt);
distanceCopters.Text = ((double)Math.Round(distance*100)/100).ToString();
}
*/
}
void OnCBLoaded(object sender, EventArgs e)
{
}
private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
@ -133,47 +87,5 @@ namespace Plane.FormationCreator.Views
}
}
private void cmbTemplateLEDMode_Initialized(object sender, EventArgs e)
{
int selind = 0;
ComboBox cb = (ComboBox)sender;
selind = cb.SelectedIndex;
cb.Items.Clear();
if (_copterManager.FC_VER_NO == 1)
{
cb.Items.Add("常亮"); //0
cb.Items.Add("同步闪烁(单色)"); //1
cb.Items.Add("异步闪烁(随机)"); //2
cb.Items.Add("渐亮"); //3
cb.Items.Add("渐暗"); //4
cb.Items.Add("呼吸灯(单色)"); //5
cb.Items.Add("同步闪烁(随机)"); //6
cb.Items.Add("异步闪烁(单色)"); //7
cb.Items.Add("拉烟"); //8
}
else
{
cb.Items.Add("常亮"); //0
cb.Items.Add("同步闪烁(单色)"); //1
cb.Items.Add("异步闪烁(随机)"); //2
cb.Items.Add("同步闪烁(随机)"); //3
cb.Items.Add("异步闪烁(单色)"); //4
cb.Items.Add("渐亮"); //5
cb.Items.Add("渐暗"); //6
cb.Items.Add("同步呼吸灯(单色)"); //7
cb.Items.Add("同步呼吸灯(随机色)"); //8
cb.Items.Add("异步呼吸(单色)"); //9
cb.Items.Add("异步呼吸(随机色)"); //10
cb.Items.Add("变色(单色)"); //11
cb.Items.Add("变色(随机)"); //12
cb.Items.Add("异步变色(单色)"); //13
cb.Items.Add("异步变色(随机)"); //14
cb.Items.Add("拉烟"); //15
cb.Items.Add("抛物"); //16
}
cb.SelectedIndex = selind;
}
}
}

View File

@ -5,45 +5,24 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d" d:DesignWidth="800"
Height="426" Width="1500" WindowStartupLocation="CenterScreen" Background="#FF2D2D2D" BorderBrush="#FF039AF0" Title="RTK控制" ResizeMode="NoResize">
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="800"
Height="350" Width="1500" WindowStartupLocation="CenterScreen" Background="#FF2D2D2D" BorderBrush="#FF039AF0" Title="RTK控制" ResizeMode="NoResize" Topmost="True">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Margin="5" Orientation="Horizontal" VerticalAlignment="Center">
<Border Margin="10,5" BorderBrush="#FFB9B8B8" BorderThickness="1">
<StackPanel Margin="0" Orientation="Vertical">
<StackPanel Margin="0" Orientation="Horizontal">
<ComboBox Width="120" Height="25" Foreground="White" SelectedIndex="0"
<ComboBox Width="120" Height="25" Foreground="White" SelectedIndex="0"
Margin="10" ItemsSource="{Binding serialPorts, Mode=OneWay}"
SelectedValue="{Binding SerialPortsSelectdValue}"
DropDownOpened="ComboBox_DropDownOpened"/>
<Button Margin="6" Width="90" Height="28"
<Button Margin="6" Width="80" Height="28"
Content="{Binding RtcmManager.Rtcmthreadrun,Converter={StaticResource SendConverter}}"
Command="{Binding ConnectRtcmCommand}"/>
<Label Margin="6,6,0,6" Height="28" Content="卫星数:"/>
<Label Margin="0,6,6,6" Height="28" Content="{Binding RtcmManager.rtcmInfoList.Count,UpdateSourceTrigger=PropertyChanged}"></Label>
</StackPanel>
<StackPanel Margin="6,0,0,2" Orientation="Horizontal">
<CheckBox x:Name="checkBox" Content="双通道模式 (同时发到广播端口)"
Margin="4,5,5,0" Width="190"
IsChecked="{Binding ResendToComMK}"/>
<CheckBox x:Name="cBsmalldata" Content="低带宽模式"
Margin="20,5,5,0" Width="95"
IsChecked="{Binding SmalldataMK}"/>
</StackPanel>
<StackPanel Margin="6,0,0,2" Orientation="Horizontal">
<TextBlock Margin="23,1,0,0" Text="{Binding BoardPortsStatus}"/>
</StackPanel>
</StackPanel>
</Border>
<Label Margin="6,6,0,6" Height="28" Content="总数:"/>
<Label Margin="0,6,6,6" Height="28" Content="{Binding RtcmManager.rtcmInfoList.Count,UpdateSourceTrigger=PropertyChanged}"></Label>
<Border Margin="10,5" BorderBrush="#FFB9B8B8" BorderThickness="1">
<StackPanel Margin="5" Orientation="Vertical">
@ -51,30 +30,17 @@
<TextBlock Text="接收速率: "/>
<TextBlock TextAlignment="Right" Width="30"
Text="{Binding RtcmManager.Bps}"/>
<TextBlock Text=" 字节/秒;发送速率:"/>
<TextBlock Text=" bps;发送速率:"/>
<TextBlock TextAlignment="Right" Width="30"
Text="{Binding RtcmManager.Bpsusefull}"/>
<TextBlock Text=" 字节/秒"/>
<TextBlock Text=" bps"/>
</StackPanel>
<StackPanel Margin="5" Orientation="Horizontal">
<TextBlock Text="消息: "/>
<TextBlock Text="{Binding RtcmManager.Messages_seen}"/>
<TextBlock Text="{Binding RtcmManager.Messages_seen}"
/>
</StackPanel>
<StackPanel Margin="0" Orientation="Horizontal">
<TextBlock Margin="5" Text="L1信号强度"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20" Fill="#3EBE55"/>
<TextBlock Margin="5" Text="L2信号强度"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20" Fill="#ACACEC"/>
<TextBlock Margin="5" Text="L1/L2重合"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20" Fill="#04845C"/>
</StackPanel>
</StackPanel>
@ -88,10 +54,10 @@
Fill="{Binding RtcmManager.BaseState,Converter={StaticResource ColorConverter}}"/>
<TextBlock Margin="5" Text="Gps"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
Fill="{Binding RtcmManager.GpsState ,Converter={StaticResource ColorConverter}}"/>
Fill="{Binding RtcmManager.GlonassState,Converter={StaticResource ColorConverter}}"/>
<TextBlock Margin="5" Text="Glonass"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
Fill="{Binding RtcmManager.GlonassState,Converter={StaticResource ColorConverter}}"/>
Fill="{Binding RtcmManager.GpsState,Converter={StaticResource ColorConverter}}"/>
<TextBlock Margin="5" Text="北斗"/>
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
Fill="{Binding RtcmManager.BeidouState,Converter={StaticResource ColorConverter}}"/>
@ -107,12 +73,10 @@
</StackPanel>
</Border>
</StackPanel>
<ItemsControl Grid.Row="1"
ItemsSource="{Binding Path = RtcmManager.rtcmInfoList}" Margin="0,0.333,-0.333,-80" Height="303" VerticalAlignment="Top"
ItemsSource="{Binding Path = RtcmManager.rtcmInfoList}"
>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@ -131,28 +95,13 @@
Minimum="25"
Maximum="55"
Grid.RowSpan="2"
Value="{Binding Snr, UpdateSourceTrigger=PropertyChanged}"
/>
<ProgressBar x:Name="BarSnr2"
Margin="0.5"
Orientation="Vertical"
Minimum="25"
Maximum="55"
Grid.RowSpan="2"
Foreground="Blue"
Value="{Binding Snr2, UpdateSourceTrigger=PropertyChanged}"
Opacity="0.25"
/>
<StackPanel Orientation ="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center">
Value="{Binding Snr, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Orientation ="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel Orientation ="Horizontal">
<TextBlock Text="{Binding Sys,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
<TextBlock Text="{Binding Prn,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
</StackPanel>
<TextBlock Margin="0,5,0,0" Text="{Binding Snr,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
<TextBlock Margin="0,5,0,0" Text="{Binding Snr2,UpdateSourceTrigger=PropertyChanged}" Foreground="Blue" ></TextBlock>
<TextBlock Margin="0,20,0,0" Text="{Binding Snr,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
</StackPanel>
<StackPanel Grid.Row="1" Orientation ="Vertical" HorizontalAlignment="Center">
<Line Stroke="Red" X2="1000" StrokeThickness="3" />

View File

@ -18,7 +18,7 @@
<RowDefinition Height="32"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="每数量" Margin="5,2"></Label>
<Label Content="每数量" Margin="5,2"></Label>
<TextBox Name="textboxColNum" Grid.Column="1" Margin="5" Width="80" ></TextBox>
<Label Content="列间距" Margin="5,2" Grid.Row="1"></Label>

View File

@ -90,7 +90,7 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
<Border Background="{Binding Status, Converter={StaticResource FlightTaskStatusToFillConverter}}"
Width="88"
Height="19"
BorderThickness="1"
@ -99,12 +99,6 @@
MouseLeftButtonDown="TaskLeftButtonDown"
MouseLeftButtonUp="SelectTask"
MouseRightButtonUp="HideTask">
<Border.Background>
<MultiBinding Converter="{StaticResource FlightTaskStatusAndTransitionToFillConverter}">
<Binding Path="Status" />
<Binding Path="IsTransition" />
</MultiBinding>
</Border.Background>
<WrapPanel VerticalAlignment="Center"
HorizontalAlignment="Center" >
@ -131,7 +125,7 @@
<RowDefinition/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<StackPanel Height="120" Background="#FF2D2D2D" VerticalAlignment="Bottom">
<StackPanel Height="100" Background="#FF2D2D2D" VerticalAlignment="Bottom">
<TextBlock x:Name="hintaddtask" Margin="0,25,0,0" Text="请添加或选择飞行任务" Visibility="Collapsed" FontSize="18" TextAlignment="Center"/>
@ -157,7 +151,7 @@
<TabItem.Header>
<Label x:Name="flytoLabel" Content="航点" HorizontalAlignment="Stretch" MouseLeftButtonDown="TaskLabelLeftButtonDown"
ToolTip="双击修改名称" />
ToolTip="双击修改名称" />
</TabItem.Header>
@ -165,7 +159,6 @@
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@ -179,9 +172,6 @@
<TextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center"
MaxLength="4"
Text="{Binding LoiterTime, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Grid.Row="2" Grid.Column="2" x:Name="tranBox" Content="过度航点" HorizontalAlignment="Left" Width="75.353"
IsChecked="{Binding IsTransition}"/>
</Grid>
</TabItem>

View File

@ -39,7 +39,7 @@ namespace Plane.FormationCreator.Views
}
public void ResetCamera()
private void ResetCamera()
{
// view3d.CameraController.CameraPosition = new Point3D(0, 40, 1);
// view3d.CameraController.CameraUpDirection = new Vector3D(0, -1, 10);
@ -49,10 +49,8 @@ namespace Plane.FormationCreator.Views
var camera = view3d.Camera as PerspectiveCamera;
camera.Position = new Point3D(0, 0, 1);
//用于朝向180度
// camera.LookDirection = new Vector3D(-0.025, -0.911, 0.411);
//用于朝向9度
camera.LookDirection = new Vector3D(0, 1, 0.8);
//用于180度
camera.LookDirection = new Vector3D(-0.025, -0.911, 0.411);
camera.UpDirection = new Vector3D(0.011, 0.411, 0.912);
//用于0度

View File

@ -15,5 +15,4 @@
<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>