1.飞机按编号顺序加入飞行列表
2.默认起飞高度为15米 3.修改航点位置改为按住左shift再按下asdw,不按shift则是控制移动飞机 4.修复上下旋转的高度bug 5.为防止碰撞,加入两个按钮,一个为自动计算高度(未实现),一个为自动设为前一步高度,这样一个图案应该有三个同样形状的飞行任务,一个进入(高度不同)一个表演,一个退出(高度不同)
This commit is contained in:
parent
84659afdab
commit
7e04c83e26
@ -143,8 +143,9 @@ namespace Plane.FormationCreator
|
|||||||
Id = ip,
|
Id = ip,
|
||||||
Name = ip.Substring(ip.LastIndexOf('.') + 1)
|
Name = ip.Substring(ip.LastIndexOf('.') + 1)
|
||||||
};
|
};
|
||||||
copters.Add(copter);
|
int _index;
|
||||||
copterStatus.Add(false);
|
_index=copters.AddCopter(copter);
|
||||||
|
copterStatus.Insert(_index,false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -10,6 +10,46 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Plane.FormationCreator.Formation
|
namespace Plane.FormationCreator.Formation
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public class CopterCollection : ObservableCollection<ICopter>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 实现排序插入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="baseSemObjects"></param>
|
||||||
|
public int AddCopter(ICopter entityObject)
|
||||||
|
{
|
||||||
|
int _index = 0;
|
||||||
|
if (this.Count == 0)
|
||||||
|
{
|
||||||
|
Add(entityObject);
|
||||||
|
_index = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool isInsret = false;
|
||||||
|
for (int i = 0; i < this.Count; i++)
|
||||||
|
{
|
||||||
|
if (String.Compare(this[i].Name, entityObject.Name, false) >= 0)
|
||||||
|
{
|
||||||
|
InsertItem(i, entityObject);
|
||||||
|
isInsret = true;
|
||||||
|
_index= i;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isInsret)
|
||||||
|
{
|
||||||
|
Add(entityObject);
|
||||||
|
_index = this.Count()-1 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class CopterManager : ObservableObject
|
public class CopterManager : ObservableObject
|
||||||
{
|
{
|
||||||
public CopterManager()
|
public CopterManager()
|
||||||
@ -25,7 +65,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObservableCollection<ICopter> Copters { get; } = new ObservableCollection<ICopter>();
|
public CopterCollection Copters { get;} = new CopterCollection();
|
||||||
|
|
||||||
public ArrayList CopterStatus = new ArrayList();
|
public ArrayList CopterStatus = new ArrayList();
|
||||||
//public ObservableCollection<ICopter> Copters
|
//public ObservableCollection<ICopter> Copters
|
||||||
|
@ -128,7 +128,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
foreach (var copter in copters)
|
foreach (var copter in copters)
|
||||||
{
|
{
|
||||||
takeOffTask.SingleCopterInfos.Add(FlightTaskSingleCopterInfo.CreateForTakeOffTask(copter, targetAlt: 10));
|
takeOffTask.SingleCopterInfos.Add(FlightTaskSingleCopterInfo.CreateForTakeOffTask(copter, targetAlt: 15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,8 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
currcol++;
|
currcol++;
|
||||||
coptindex++;
|
coptindex++;
|
||||||
var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, lastSingleCopterInfo.TargetAlt, true);
|
var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2,
|
||||||
|
lastTask.SingleCopterInfos.Find(info => info.Copter == copter).TargetAlt, true);
|
||||||
newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading;
|
newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading;
|
||||||
newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading;
|
newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading;
|
||||||
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
|
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
|
||||||
|
@ -94,7 +94,7 @@ namespace Plane.FormationCreator
|
|||||||
{
|
{
|
||||||
map.GoHome();
|
map.GoHome();
|
||||||
}
|
}
|
||||||
|
bool Shiftkeydown = false;
|
||||||
private async void MetroWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
private async void MetroWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
// 如果正在输入,忽略。
|
// 如果正在输入,忽略。
|
||||||
@ -105,6 +105,11 @@ namespace Plane.FormationCreator
|
|||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
case Key.LeftShift:
|
||||||
|
{
|
||||||
|
Shiftkeydown = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
//开关SHOWLED
|
//开关SHOWLED
|
||||||
case Key.C:
|
case Key.C:
|
||||||
{
|
{
|
||||||
@ -123,7 +128,7 @@ namespace Plane.FormationCreator
|
|||||||
case Key.S:
|
case Key.S:
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((_flightTaskManager.CurrentRunningTask == null) && (_flightTaskManager.SelectedTask != null))
|
if (Shiftkeydown &&(_flightTaskManager.CurrentRunningTask == null) && (_flightTaskManager.SelectedTask != null))
|
||||||
{
|
{
|
||||||
|
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
@ -174,7 +179,7 @@ namespace Plane.FormationCreator
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ((_flightTaskManager.CurrentRunningTask == null)&&(_flightTaskManager.SelectedTask!=null))
|
if (Shiftkeydown && (_flightTaskManager.CurrentRunningTask == null)&&(_flightTaskManager.SelectedTask!=null))
|
||||||
{
|
{
|
||||||
|
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
@ -351,6 +356,11 @@ namespace Plane.FormationCreator
|
|||||||
|
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
|
case Key.LeftShift:
|
||||||
|
{
|
||||||
|
Shiftkeydown = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Key.W:
|
case Key.W:
|
||||||
case Key.S:
|
case Key.S:
|
||||||
{
|
{
|
||||||
|
@ -761,7 +761,7 @@ public ICommand VerticlAlignmentCommand
|
|||||||
dy = -ax * Math.Sin(k) + ay * Math.Cos(k);
|
dy = -ax * Math.Sin(k) + ay * Math.Cos(k);
|
||||||
|
|
||||||
//新高度(米)
|
//新高度(米)
|
||||||
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt += (float) dy;
|
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt= (float)(centalt + dy);
|
||||||
//计算新纬度
|
//计算新纬度
|
||||||
double lng2 = 0;
|
double lng2 = 0;
|
||||||
double lat2 = 0;
|
double lat2 = 0;
|
||||||
@ -796,9 +796,78 @@ public ICommand VerticlAlignmentCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//缩放
|
private ICommand _AutoaltCommand;
|
||||||
|
public ICommand AutoaltCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _AutoaltCommand ?? (_AutoaltCommand = new RelayCommand<double>(async =>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICommand _PrealtCommand;
|
||||||
|
public ICommand PrealtCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _PrealtCommand ?? (_PrealtCommand = new RelayCommand<double>(async =>
|
||||||
|
{
|
||||||
|
|
||||||
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (_flightTaskManager.SelectedTaskIndex > 1)
|
||||||
|
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt =
|
||||||
|
_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex - 1].SingleCopterInfos[i].TargetAlt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//计算距离
|
||||||
private ICommand _calDistinceCommand;
|
private ICommand _calDistinceCommand;
|
||||||
public ICommand calDistinceCommand
|
public ICommand calDistinceCommand
|
||||||
{
|
{
|
||||||
@ -811,10 +880,9 @@ public ICommand VerticlAlignmentCommand
|
|||||||
double distance = 0;
|
double distance = 0;
|
||||||
|
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
bool copterisselect;
|
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
copterisselect = false;
|
|
||||||
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
||||||
foreach (var capter in _copterManager.SelectedCopters)
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
{
|
{
|
||||||
|
@ -113,6 +113,17 @@
|
|||||||
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
|
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
|
||||||
|
<Button Content="自动高度"
|
||||||
|
Margin="0,5,5,0"
|
||||||
|
Command="{Binding AutoaltCommand}" />
|
||||||
|
<Button Content="前一高度"
|
||||||
|
Margin="0,5,5,0"
|
||||||
|
Command="{Binding PrealtCommand}" />
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<Separator />
|
<Separator />
|
||||||
<TextBlock Text="任务属性" Margin="0, 0, 5, 0" FontWeight="Bold" />
|
<TextBlock Text="任务属性" Margin="0, 0, 5, 0" FontWeight="Bold" />
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
Loading…
Reference in New Issue
Block a user