V2.0 修改
1重设将飞机回到起飞点 2默认悬停时间改为1秒 3解锁起飞模拟真飞机改变颜色 4自动计算所有任务飞行时间 5增加从指定任务开始模拟 6连接窗口改为设置并优化布局 7不创建所有航点,只创建要显示的,优化导入速度 8更改背景 9模拟检测碰撞的间隔改为10hz,之前是100hz,对于大量飞机拖慢速度[FlightTask_FlyTo.cs]
This commit is contained in:
parent
f49cd3c722
commit
7ac2f48500
@ -21,7 +21,7 @@ namespace Plane.FormationCreator.Formation
|
||||
public int AddCopter(ICopter entityObject)
|
||||
{
|
||||
////给第三方时候限制数量和时间用
|
||||
DateTime dateTime2019 = DateTime.Parse("2020-01-20");
|
||||
DateTime dateTime2019 = DateTime.Parse("2020-03-01");
|
||||
|
||||
//新增飞机区域限制:内蒙
|
||||
// if (entityObject.Latitude < 37.4307185218 || entityObject.Latitude > 45.6754821756
|
||||
|
@ -81,8 +81,10 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
public static bool IsTooCloseTo(this ICopter copter, ICopter copter2, out double distance)
|
||||
{
|
||||
// distance = 0;
|
||||
// return false; //效果图用 不检测碰撞
|
||||
distance = Math.Round(copter.DistanceTo(copter2), 2) ;
|
||||
//return false; //效果图用 不检测碰撞
|
||||
|
||||
if (copter.Altitude < 3 || copter2.Altitude < 3)
|
||||
return false;
|
||||
|
||||
|
@ -380,9 +380,72 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetTasks()
|
||||
//指定任务开始模拟
|
||||
public async Task FlyToTasks()
|
||||
{
|
||||
var copters = _copterManager.Copters;
|
||||
|
||||
if (CurrentRunningTaskIndex == Tasks.Count - 1)
|
||||
return;
|
||||
|
||||
Pause();
|
||||
int i = 0;
|
||||
//等待暂停或2s超时(80*25ms)
|
||||
while ((TaskState != TasksStatus.Paused) || (i > 80))
|
||||
{
|
||||
await Task.Delay(25).ConfigureAwait(false);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (TaskState == TasksStatus.Paused)
|
||||
{
|
||||
CurrentRunningTask.Status = FlightTaskStatus.Stop;
|
||||
CurrentRunningTask = null;
|
||||
CurrentRunningTaskIndex = SelectedTaskIndex;
|
||||
|
||||
|
||||
|
||||
//设置所有模拟飞机的位置
|
||||
for (int j = 0; j < copters.Count; j++)
|
||||
{
|
||||
var copter = copters[j];
|
||||
var fc = copter as FakeCopter;
|
||||
fc.SetProperties(
|
||||
latitude: Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLat,
|
||||
longitude: Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLng,
|
||||
altitude: Tasks[SelectedTaskIndex - 1].SingleCopterInfos[j].TargetAlt
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//起飞任务需要跳过
|
||||
// if (CurrentRunningTaskIndex == 0)
|
||||
// CurrentRunningTaskIndex++;
|
||||
|
||||
await RunTaskAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async void ResetTasks()
|
||||
{
|
||||
var copters = _copterManager.Copters;
|
||||
Pause();
|
||||
//等待暂停或2s超时(80*25ms)
|
||||
int k = 0;
|
||||
while ((TaskState != TasksStatus.Paused) || (k > 80))
|
||||
{
|
||||
await Task.Delay(25).ConfigureAwait(false);
|
||||
k++;
|
||||
}
|
||||
|
||||
|
||||
CurrentRunningTaskIndex = 0;
|
||||
if (CurrentRunningTask != null)
|
||||
{
|
||||
@ -414,6 +477,24 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//设置所有模拟飞机的位置
|
||||
for (int j = 0; j < copters.Count; j++)
|
||||
{
|
||||
var copter = copters[j];
|
||||
var fc = copter as FakeCopter;
|
||||
fc.SetProperties(
|
||||
latitude: Tasks[0].SingleCopterInfos[j].TargetLat,
|
||||
longitude: Tasks[0].SingleCopterInfos[j].TargetLng,
|
||||
altitude:0
|
||||
|
||||
);
|
||||
//设置灯光为默认黑色
|
||||
fc.LEDColor = "000000";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string ExportC4DFlytoTask()
|
||||
@ -472,7 +553,7 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
|
||||
var lastTask = Tasks.LastOrDefault();
|
||||
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 10 };
|
||||
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 1 };
|
||||
newTask.TaskCnName = taskName;
|
||||
for (int k = 0; k < PointDic.Count; k++)
|
||||
{
|
||||
@ -504,7 +585,7 @@ namespace Plane.FormationCreator.Formation
|
||||
Tasks.Add(newTask);
|
||||
TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = newTask });
|
||||
}
|
||||
|
||||
Alert.Show("导入完成!");
|
||||
/*
|
||||
Dictionary<int, string[]> PointDic = new Dictionary<int, string[]>();
|
||||
foreach (string line in lines)
|
||||
@ -664,8 +745,6 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
Tasks.Add(newTask);
|
||||
TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = newTask });
|
||||
SelectedTask = newTask;
|
||||
SelectedTaskIndex = Tasks.Count - 1;
|
||||
}
|
||||
|
||||
private void RestoreTurnTask(dynamic singleCopterInfos)
|
||||
@ -748,8 +827,7 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
Tasks.Add(RTLTask);
|
||||
TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = RTLTask });
|
||||
SelectedTask = RTLTask;
|
||||
SelectedTaskIndex = Tasks.Count - 1;
|
||||
|
||||
}
|
||||
|
||||
private void RestoreTakeOffTask(byte takeOffTime, dynamic singleCopterInfos)
|
||||
@ -797,8 +875,7 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
Tasks.Add(LandTask);
|
||||
TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = LandTask });
|
||||
SelectedTask = LandTask;
|
||||
SelectedTaskIndex = Tasks.Count - 1;
|
||||
|
||||
}
|
||||
|
||||
// added by ZJF
|
||||
@ -1753,7 +1830,7 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
return copterStr;
|
||||
}
|
||||
|
||||
//左键选中任务
|
||||
public void Select(FlightTask flightTask)
|
||||
{
|
||||
this.SelectedTaskIndex = Tasks.IndexOf(flightTask);
|
||||
@ -1819,6 +1896,15 @@ namespace Plane.FormationCreator.Formation
|
||||
public async Task RunAsync()
|
||||
{
|
||||
IsPaused = false;
|
||||
for (int i = CurrentRunningTaskIndex; i < Tasks.Count; i++)
|
||||
{
|
||||
var task = Tasks[i];
|
||||
//task.Status目前只用于任务条下面状态显示不同颜色
|
||||
task.Status = FlightTaskStatus.Stop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AppEx.Current.AppMode = AppMode.RunningTasks;
|
||||
StartAvoidingCrash(); //开始碰撞检测
|
||||
TaskState = TasksStatus.Running;
|
||||
|
@ -32,7 +32,7 @@ namespace Plane.FormationCreator.Formation
|
||||
Set(nameof(FlytoTime), ref _FlytoTime, value);
|
||||
}
|
||||
}
|
||||
private int _LoiterTime = 10;
|
||||
private int _LoiterTime = 1;
|
||||
public int LoiterTime
|
||||
{
|
||||
get { return _LoiterTime; }
|
||||
@ -193,7 +193,7 @@ namespace Plane.FormationCreator.Formation
|
||||
await info.Copter.HoverAsync();
|
||||
return;
|
||||
}
|
||||
await Task.Delay(10).ConfigureAwait(false); //判断是否到达位置10hz
|
||||
await Task.Delay(100).ConfigureAwait(false); //判断是否到达位置10hz
|
||||
|
||||
|
||||
|
||||
|
@ -133,6 +133,8 @@ namespace Plane.FormationCreator.Formation
|
||||
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt);
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
//解锁起飞用暗紫色
|
||||
info.Copter.LEDColor = "FF00FF";
|
||||
|
||||
dtNow = DateTime.Now;
|
||||
ts = dtNow - dtLastTime;
|
||||
@ -149,6 +151,9 @@ namespace Plane.FormationCreator.Formation
|
||||
dtNow = DateTime.Now;
|
||||
ts = dtNow - dtLastTime;
|
||||
}
|
||||
//起飞完成用暗蓝色
|
||||
info.Copter.LEDColor = "0000FF";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,12 +13,12 @@
|
||||
WindowTransitionsEnabled="False"
|
||||
FontFamily="Microsoft YaHei"
|
||||
WindowState="Maximized"
|
||||
Title="无人机编队控制中心"
|
||||
Title="飞行魔方--无人机编队控制中心 V2.0"
|
||||
PreviewKeyDown="MetroWindow_PreviewKeyDown"
|
||||
PreviewKeyUp="MetroWindow_PreviewKeyUp"
|
||||
Style="{StaticResource VSWindowStyleKey}"
|
||||
Width="800"
|
||||
Height="600">
|
||||
Width="1920"
|
||||
Height="1080">
|
||||
|
||||
<c:MetroWindow.Resources>
|
||||
<Style TargetType="Separator"
|
||||
@ -71,7 +71,7 @@
|
||||
Visibility="Collapsed"
|
||||
Click="btnRefreshMap_Click" />
|
||||
<Button Name="btnConnect"
|
||||
Content="连接"
|
||||
Content="设置"
|
||||
Click="btnConnect_Click" />
|
||||
<Menu Name="menuTask" Background="Transparent" VerticalAlignment="Center" >
|
||||
|
||||
@ -139,13 +139,17 @@
|
||||
|
||||
<Grid Margin="0,0,10,0"
|
||||
Width="Auto" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1371*"/>
|
||||
<ColumnDefinition Width="13*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TabControl SelectedIndex="{Binding MapMode,UpdateSourceTrigger=PropertyChanged}" Grid.RowSpan="3">
|
||||
<TabControl SelectedIndex="{Binding MapMode,UpdateSourceTrigger=PropertyChanged}" Grid.RowSpan="3" Margin="0">
|
||||
<TabItem Visibility="Collapsed">
|
||||
<v:MapView x:Name="map"/>
|
||||
</TabItem >
|
||||
|
@ -81,7 +81,7 @@ namespace Plane.FormationCreator
|
||||
};
|
||||
var point = PointToScreen(Mouse.GetPosition(this));
|
||||
point.X = Math.Min(point.X, SystemParameters.WorkArea.Width - connectWindow.Width - 30);
|
||||
point.Y = Math.Min(point.Y, SystemParameters.WorkArea.Height - connectWindow.Height - 30);
|
||||
point.Y = Math.Min(point.Y+10, SystemParameters.WorkArea.Height - connectWindow.Height - 30);
|
||||
connectWindow.Left = point.X;
|
||||
connectWindow.Top = point.Y;
|
||||
|
||||
|
@ -283,6 +283,8 @@ namespace Plane.FormationCreator.ViewModels
|
||||
await copter.GetCopterDataAsync();
|
||||
_copterManager.Copters.AddCopter(copter);
|
||||
_copterManager.CopterStatus.Add(false);
|
||||
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||
_flightTaskManager.SetOriginal();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -337,6 +337,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
|
||||
}
|
||||
Alert.Show("导入完成!", "提示");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -529,12 +529,54 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
var tasksText = File.ReadAllText(dialog.FileName);
|
||||
_flightTaskManager.ImportC4DFlytoTask(tasksText);
|
||||
autoalltasktime();
|
||||
//_flightTaskManager.ImportBlenderFlyToTask(tasksText);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void autoalltasktime()
|
||||
{
|
||||
for (int taskIndex = 1; taskIndex < _flightTaskManager.Tasks.Count; taskIndex++)
|
||||
{
|
||||
|
||||
|
||||
if (taskIndex != 0 || _flightTaskManager.Tasks[taskIndex].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($"任务:{taskIndex},最大航点间距 = {Math.Round(maxDistance, 2)}米, 水平速度={Math.Round(speed, 2)}, 飞行时间 = {Math.Round(time, 2)}秒, 飞机编号:{copterName}");
|
||||
_flightTaskManager.Tasks[taskIndex].FlytoTime = (int)Math.Round(time, 2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _ExportWayPointCommand;
|
||||
public ICommand ExportWayPointCommand
|
||||
{
|
||||
@ -558,6 +600,93 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _AutoWayPointTmCommand;
|
||||
public ICommand AutoWayPointTmCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AutoWayPointTmCommand ?? (_AutoWayPointTmCommand = new RelayCommand<int>(async =>
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _AutoWayPointAllTmCommand;
|
||||
public ICommand AutoWayPointAllTmCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AutoWayPointAllTmCommand ?? (_AutoWayPointAllTmCommand = new RelayCommand<int>(async =>
|
||||
{
|
||||
|
||||
if (Alert.Show("本操作将导致所有任务飞行时间重新计算,您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||
== MessageBoxResult.OK)
|
||||
{
|
||||
autoalltasktime();
|
||||
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _OptimizeRouteCommand;
|
||||
public ICommand OptimizeRouteCommand
|
||||
{
|
||||
|
@ -65,6 +65,25 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _flyTotaskCommand;
|
||||
public ICommand flyTotaskCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _flyTotaskCommand ?? (_flyTotaskCommand = new RelayCommand(async () =>
|
||||
{
|
||||
// await _flightTaskManager.RunAsync();
|
||||
await _flightTaskManager.FlyToTasks();
|
||||
// Message.Show("任务开始");
|
||||
// await _flightTaskManager.RunAsync();
|
||||
// Message.Show(_flightTaskManager.IsPaused == true ? "任务暂停" : "任务完成");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _SetOriginCommand;
|
||||
public ICommand SetOriginCommand
|
||||
{
|
||||
|
@ -7,157 +7,57 @@
|
||||
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="连接"
|
||||
Width="432.175"
|
||||
Height="300.371"
|
||||
|
||||
Title="设置"
|
||||
Width="496.634"
|
||||
Height="205.942"
|
||||
|
||||
WindowStartupLocation="CenterScreen"
|
||||
FontFamily="Microsoft YaHei"
|
||||
ResizeMode="NoResize">
|
||||
ResizeMode="NoResize" >
|
||||
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="Auto" Width="Auto" >
|
||||
|
||||
<Grid HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
|
||||
<Grid.Resources>
|
||||
<Style TargetType="Label"
|
||||
BasedOn="{StaticResource {x:Type Label}}">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Right" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
</Style>
|
||||
<Style TargetType="ComboBox"
|
||||
BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Width"
|
||||
Value="150" />
|
||||
</Style>
|
||||
<Style TargetType="TextBox"
|
||||
BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Width"
|
||||
Value="150" />
|
||||
</Style>
|
||||
<Style TargetType="PasswordBox"
|
||||
BasedOn="{StaticResource {x:Type PasswordBox}}">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Left" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="MinWidth"
|
||||
Value="150" />
|
||||
</Style>
|
||||
<Style TargetType="Button"
|
||||
BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition />
|
||||
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Target="{Binding ElementName=txtIPs}" Visibility="Collapsed"
|
||||
Content="IP" />
|
||||
<TextBox Name="txtIPs"
|
||||
Grid.Column="2"
|
||||
AcceptsReturn="True"
|
||||
MinHeight="200"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="Collapsed"
|
||||
Text="{Binding IPs, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel1">
|
||||
|
||||
<ec:ProgressButton HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10"
|
||||
Content="连接 _TCP"
|
||||
IsDefault="True"
|
||||
IsProcessing="{Binding IsProcessing}"
|
||||
Command="{Binding Path=ConnectCommand}" />
|
||||
<ec:ProgressButton HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10"
|
||||
Content="连接 _UDP"
|
||||
IsDefault="True"
|
||||
IsProcessing="{Binding IsProcessing}"
|
||||
Command="{Binding Path=ConnectCommand}"
|
||||
CommandParameter="UDP"/>
|
||||
<ec:ProgressButton HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10"
|
||||
Content="连接串口"
|
||||
IsProcessing="{Binding IsProcessing}"
|
||||
Command="{Binding Path=ConnectCommand}"
|
||||
CommandParameter="SerialPort" />
|
||||
|
||||
<!--<ec:ProgressButton Name="btnConnectUdp"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="10"
|
||||
Content="连接 _UDP"
|
||||
IsDefault="True"
|
||||
IsProcessing="{Binding IsProcessing}"
|
||||
Command="{Binding Path=ConnectCommand}"
|
||||
CommandParameter="UDP" />-->
|
||||
<Button Content="关闭TCP" Margin="5" Command="{Binding CloseCommand}"/>
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="0"
|
||||
Name="panel2" >
|
||||
<Button Content="设置总数" Width="90" Margin="5,5,5,5" Command="{Binding Path=SendCommand}" />
|
||||
<Button Content="切换写航点" Width="90" Margin="5,5,5,5" Command="{Binding Path=ChangeWriteMissionCommand}" />
|
||||
<Button Content="通信状态" Width="90" Margin="5,5,5,5" Command="{Binding StateInquireCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel2">
|
||||
<Button Content="通信模块状态" Margin="5" Command="{Binding Path=StateInquireCommand}"/>
|
||||
<Button Content="设置总数" Margin="5" Command="{Binding Path=SendCommand}" />
|
||||
<Button Content="切换写航点" Margin="5" Command="{Binding Path=ChangeWriteMissionCommand}" />
|
||||
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="3"
|
||||
Grid.ColumnSpan="3">
|
||||
<TextBox Margin="2,5,5,5" Width="30" Text="{Binding CopterNum}"></TextBox>
|
||||
<Button Content=" 对频 " Margin="5,5,0,5" Command="{Binding Path=WriteIdCommand}" />
|
||||
<Button Content="闪灯" Margin="5" Command="{Binding CommDataAsync}"/>
|
||||
<Button Content="拉烟" Margin="5" Command="{Binding TestFireCommandAsync}"/>
|
||||
<TextBox Width="80" Text="{Binding CopterColor}"/>
|
||||
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="1" >
|
||||
<TextBox Width="90" VerticalContentAlignment="Center" Text="{Binding CopterNum}" Margin="5,5,5,5" />
|
||||
<Button Content="对频" Width="90" Margin="5,5,5,5" Command="{Binding Path=WriteIdCommand}" />
|
||||
<Button Content="闪灯 " Width="90" Margin="5,5,5,5" Command="{Binding CommDataAsync}"/>
|
||||
<Button Content="拉烟" Width="90" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}"/>
|
||||
<TextBox Width="50" VerticalContentAlignment="Center" Text="{Binding CopterColor}" Margin="5,5,5,5"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel3">
|
||||
<Button Content="空中升级" Margin="5" Command="{Binding UpdateAllCopterCommand}"></Button>
|
||||
<Button Content="搜索飞机" Margin="5" Command="{Binding QueryAllCopterCommand}"/>
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Row="2"
|
||||
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}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
</c:MetroWindow>
|
||||
|
@ -41,12 +41,12 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
if (!VersionControl.IsFullVersion)
|
||||
{
|
||||
panel1.Visibility = Visibility.Collapsed;
|
||||
//panel1.Visibility = Visibility.Collapsed;
|
||||
panel2.Visibility = Visibility.Collapsed;
|
||||
panel3.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
txtIPs.Focus();
|
||||
//txtIPs.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,11 +87,18 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
//选中任务时触发
|
||||
case nameof(FlightTaskManager.SelectedTaskIndex):
|
||||
//_copterDrawings有多少架飞机(航点)
|
||||
foreach (var item in _copterDrawings)
|
||||
{
|
||||
var copterDrawing = item.Value;
|
||||
//设置选中的航点白边和下面任务块的白影
|
||||
|
||||
copterDrawing.ShowWaypoint(_flightTaskManager.SelectedTaskIndex);
|
||||
|
||||
copterDrawing.SetTaskEffect(_flightTaskManager.SelectedTaskIndex);
|
||||
//重画计划航线
|
||||
copterDrawing.ResetRoute(_flightTaskManager.SelectedTaskIndex);
|
||||
}
|
||||
break;
|
||||
|
@ -294,6 +294,33 @@ namespace Plane.FormationCreator.Views
|
||||
//this.Dot.Fill = _brush;
|
||||
}
|
||||
|
||||
public void ShowWaypoint(int taskIndex)
|
||||
{
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
|
||||
foreach (var item in this.Waypoints)
|
||||
{
|
||||
_map.Markers.Remove(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (wpIndex >= 0 && wpIndex < Waypoints.Count)
|
||||
{
|
||||
|
||||
//选中的航点
|
||||
GMapMarker wpmarker = (GMapMarker)(Waypoints[wpIndex]);
|
||||
//航点轮廓变为白色
|
||||
// wpmarker.Shape.Stroke = _selectedTaskStroke;
|
||||
_map.Markers.Add(wpmarker); //消耗大量时间费时
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void AddWaypoint(Location location, FlightTaskType type)
|
||||
{
|
||||
// Add waypoint.
|
||||
@ -305,7 +332,7 @@ namespace Plane.FormationCreator.Views
|
||||
marker.Shape = shapesContainer;
|
||||
|
||||
Waypoints.Add(marker);
|
||||
_map.Markers.Add(marker);
|
||||
// _map.Markers.Add(marker); //消耗大量时间费时 ,为了提高效率改为选中才添加见ShowWaypoint
|
||||
marker.ZIndex = 100;
|
||||
//MapLayer.SetZIndex(shapesContainer, 100);
|
||||
//var wpPos = _map.LocationToViewportPoint(location);
|
||||
@ -593,18 +620,23 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
}
|
||||
|
||||
//设置选中任务航点为白色外框
|
||||
public void SetTaskEffect(int taskIndex)
|
||||
{
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
if (wpIndex >= 0 && wpIndex < Waypoints.Count)
|
||||
{
|
||||
//清除所有白色轮廓
|
||||
Waypoints.ForEach(p => ((ShapesContainer)(p.Shape)).wp.Stroke = null);
|
||||
//选中的航点
|
||||
var wp = ((ShapesContainer)(Waypoints[wpIndex].Shape)).wp;
|
||||
//航点轮廓变为白色
|
||||
wp.Stroke = _selectedTaskStroke;
|
||||
}
|
||||
}
|
||||
|
||||
// 右击任务时触发
|
||||
//显示或者隐藏任务航点
|
||||
public void SetTaskRightEffect(int taskIndex, bool flag)
|
||||
{
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
|
@ -83,6 +83,8 @@
|
||||
/>
|
||||
<Button Content="导入航点" Command="{Binding ImportBlenderWayPointCommand}"/>
|
||||
<Button Content="导出航点" Command="{Binding ExportWayPointCommand}"/>
|
||||
<Button Content="估计时间" Command="{Binding AutoWayPointTmCommand}"/>
|
||||
<Button Content="自动时间" Command="{Binding AutoWayPointAllTmCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Separator Margin="0,1"/>
|
||||
|
@ -184,18 +184,21 @@
|
||||
<StackPanel Grid.Row="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Bottom">
|
||||
<Button Content="添加任务"
|
||||
<Button Content="添加"
|
||||
Background="#232323"
|
||||
Command="{Binding AddTaskCommand}" />
|
||||
<Button Content="清除任务"
|
||||
<Button Content="清除"
|
||||
Background="#232323"
|
||||
Command="{Binding ClearTasksCommand}" />
|
||||
<Button Content="重置任务"
|
||||
<Button Content="重置"
|
||||
Background="#232323"
|
||||
Command="{Binding ResetTasksCommand}" />
|
||||
<Button Content="强制下一步"
|
||||
<Button Content="下一步"
|
||||
Background="#232323"
|
||||
Command="{Binding NextTasksCommand}" />
|
||||
<Button Content="飞到任务"
|
||||
Background="#232323"
|
||||
Command="{Binding flyTotaskCommand}" />
|
||||
<Button Content="重设原点"
|
||||
Background="#232323"
|
||||
Command="{Binding SetOriginCommand}" />
|
||||
|
@ -32,6 +32,7 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
private FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||
|
||||
//用于更名
|
||||
public void TaskLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ClickCount > 1)
|
||||
@ -48,7 +49,7 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//选择任务
|
||||
private void SelectTask(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var elem = sender as FrameworkElement;
|
||||
@ -110,9 +111,10 @@ namespace Plane.FormationCreator.Views
|
||||
var elem = sender as FrameworkElement;
|
||||
var task = elem.DataContext as FlightTask;
|
||||
// int a = _flightTaskManager.RightSelectedTaskIndex;
|
||||
//右键任务条显示橙红色
|
||||
if (task.TaskType != FlightTaskType.TakeOff) // 不让选起飞任务。
|
||||
{
|
||||
var borderBrush = new SolidColorBrush(task.IsRightSelected ? Colors.Gray : Colors.OrangeRed);
|
||||
var borderBrush = new SolidColorBrush(task.IsRightSelected ? Colors.Gray : Colors.OrangeRed);
|
||||
if (elem is Rectangle)
|
||||
{
|
||||
(elem as Rectangle).Stroke = borderBrush;
|
||||
@ -121,7 +123,7 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
(elem as Border).BorderBrush = borderBrush;
|
||||
}
|
||||
|
||||
//显示隐藏任务航点
|
||||
_flightTaskManager.RightSelect(task);
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 52 KiB |
Loading…
Reference in New Issue
Block a user