修改小问题,加入飞机亮灯显示,加入飞行航线亮灯控制

[App.xaml.cs]修改报错的bug
[FlightTaskManager.cs] 防止报错
[FlightTask_FlyTo.cs]加入亮灯控制
[FlightTask_TakeOff.cs]起飞时打开灯,平飞是关闭灯
[MainWindow.xaml.cs]从本地得到亮灯变量,不用异步取
[MapView_CopterDrawing.cs]亮灯时显示个外边框
[ModifyTaskView.xaml]飞往加入亮灯控制开关
This commit is contained in:
pxzleo 2017-03-11 02:50:07 +08:00
parent 517146971f
commit 64b4412ff4
8 changed files with 54 additions and 11 deletions

View File

@ -53,9 +53,17 @@ namespace Plane.FormationCreator
UdpServerConnectionManager.Instance.StopReceiving();
};
this.Exit += (s, e) =>
{
try
{
TcpServerConnectionManager.Instance.StopListening();
UdpServerConnectionManager.Instance.StopReceiving();
}
catch (Exception ex)
{
// RaiseExceptionThrown(ex);
}
};
//new Test().Prepare().Run();
}
@ -110,6 +118,7 @@ namespace Plane.FormationCreator
if (!TcpServerConnectionManager.Instance.StartListening())
{
Alert.Show("网络连接不正常,无法启动监听。");
return;
}
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
{

View File

@ -47,6 +47,7 @@ namespace Plane.FormationCreator.Formation
}
}
}
if (selectedCopter!=null)
selectedCopter.SetShowLEDFlashAsync(1, 100);
};
@ -189,7 +190,15 @@ namespace Plane.FormationCreator.Formation
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
}
Tasks.Add(newTask);
try
{
TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = newTask });
}
catch (Exception ex)
{
//RaiseExceptionThrown(ex);
}
SelectedTask = newTask;
SelectedTaskIndex = Tasks.Count - 1;
}

View File

@ -18,6 +18,15 @@ namespace Plane.FormationCreator.Formation
set { Set(nameof(StaggerRoutes), ref _StaggerRoutes, value); }
}
private bool _FlytoShowLED = true;
public bool FlytoShowLED
{
get { return _FlytoShowLED; }
set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); }
}
private bool _VerticalLift = false;
public bool VerticalLift // 垂直升降标志位,后面需要加入即使拖动地图上的飞机,也不会变化经纬度. added by ZJF
{
@ -522,6 +531,7 @@ namespace Plane.FormationCreator.Formation
tasks[i] = await Task.Factory.StartNew(async () =>
{
var internalInfo = info;
await info.Copter.SetShowLEDAsync(FlytoShowLED);
//if (i1 > 0)
//{
// var prevCopter = infos[i1 - 1].Copter;

View File

@ -143,7 +143,7 @@ namespace Plane.FormationCreator.Formation
{
return;
}
//await copter.SetShowLEDAsync(true);
await copter.SetShowLEDAsync(true);
await copter.UnlockAsync();
for (int i = 0; !copter.IsUnlocked; i++)
{
@ -225,6 +225,7 @@ namespace Plane.FormationCreator.Formation
if (info.takeOffStage == 1)
{
await info.Copter.GuidAsync();
await info.Copter.SetShowLEDAsync(false);
for (int j = 0; j < 3; j++)
{
await info.Copter.FlyToAsync(copterNextTask.TargetLat, copterNextTask.TargetLng, takeOffAlt);

View File

@ -111,7 +111,7 @@ namespace Plane.FormationCreator
var copters = _copterManager.AcceptingControlCopters;
await Task.WhenAll(copters.Select(async copter =>
{
isledon = await copter.GetShowLEDAsync();
isledon = copter.GetShowLEDAsync();
await copter.SetShowLEDAsync(!isledon);
})).ConfigureAwait(false);

View File

@ -63,7 +63,7 @@
<TextBlock Text="{Binding Path=SatCount}" />
</StackPanel>
<StackPanel>
<TextBlock Text="Heading" />
<TextBlock Text="方向" />
<TextBlock Text="{Binding Path=Heading}" />
</StackPanel>
<!--<StackPanel>
@ -87,7 +87,7 @@
<TextBlock Text="{Binding FlightDistance, StringFormat=0.##}" />
</StackPanel>
<StackPanel>
<TextBlock Text="Fix type" />
<TextBlock Text="锁定类型" />
<TextBlock Text="{Binding GpsFixType}" />
</StackPanel>
<!--
@ -156,7 +156,7 @@
<TextBlock Text="{Binding Channel4}" />
</StackPanel>
<StackPanel>
<TextBlock Text="HDOP" />
<TextBlock Text="定位精度" />
<TextBlock Text="{Binding GpsHdop, StringFormat=0.##}" />
</StackPanel>
</StackPanel>

View File

@ -94,6 +94,7 @@ namespace Plane.FormationCreator.Views
var location = new Location(Copter.Latitude, Copter.Longitude, Copter.Altitude);
Point center = _map.LocationToViewportPoint(location);
bool locationUpdated = true;
SolidColorBrush blackBrush = new SolidColorBrush();
if (this.Dot == null)
{
Track = new MapPolyline();
@ -109,6 +110,7 @@ namespace Plane.FormationCreator.Views
Dot.Points.Add(new Point(COPTER_RADIUS * 2 / 3, COPTER_RADIUS));
Dot.Fill = _brush; // new SolidColorBrush(Color.FromArgb(200, 0, 122, 204));
Dot.StrokeThickness = 1;
Dot.Width = COPTER_RADIUS * 2;
Dot.Height = COPTER_RADIUS * 2;
ToolTip tt = new ToolTip();
@ -149,6 +151,12 @@ namespace Plane.FormationCreator.Views
}
}
if (Copter.GetShowLEDAsync())
blackBrush.Color = Colors.White;
else
blackBrush.Color = Colors.Transparent;
Dot.Stroke = blackBrush;
var trans = Dot.RenderTransform as RotateTransform;
if (trans == null)
{

View File

@ -93,6 +93,7 @@
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@ -104,6 +105,11 @@
<TextBlock Grid.Row="1" Text="垂直升降: " />
<CheckBox Grid.Row="1" Grid.Column="1"
IsChecked="{Binding VerticalLift}" />
<TextBlock Grid.Row="2" Text="开灯: " />
<CheckBox Grid.Row="2" Grid.Column="1"
IsChecked="{Binding FlytoShowLED}" />
</Grid>
<Separator Grid.Row="1" />