提交之前未添加文件
导入导出添加速度改变 灯光添加应用所选
This commit is contained in:
parent
4d464bc976
commit
5b194cb7bf
@ -417,6 +417,17 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
newSingleCopterInfo.AddLEDInfo(info);
|
||||
}
|
||||
if (singleCopterInfoObj.isChangeSpeed != null)
|
||||
{
|
||||
bool isChangeSpeed = (bool)singleCopterInfoObj.isChangeSpeed;
|
||||
if (isChangeSpeed)
|
||||
{
|
||||
newSingleCopterInfo.IsChangeSpeed = isChangeSpeed;
|
||||
newSingleCopterInfo.LevelSpeed = (float)singleCopterInfoObj.levelSpeed;
|
||||
newSingleCopterInfo.UpSpeed = (float)singleCopterInfoObj.upSpeed;
|
||||
newSingleCopterInfo.DownSpeed = (float)singleCopterInfoObj.downSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -722,7 +733,11 @@ namespace Plane.FormationCreator.Formation
|
||||
targetAlt = info.TargetAlt,
|
||||
//showLED = info.FlytoShowLED,
|
||||
ledInfos = info.LEDInfos,
|
||||
isLandWaypoint = info.IsLandWaypoint
|
||||
isLandWaypoint = info.IsLandWaypoint,
|
||||
isChangeSpeed = info.IsChangeSpeed,
|
||||
levelSpeed = info.LevelSpeed,
|
||||
upSpeed = info.UpSpeed,
|
||||
downSpeed = info.DownSpeed
|
||||
};
|
||||
})
|
||||
};
|
||||
@ -857,7 +872,9 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
case FlightTaskType.TakeOff:
|
||||
// AddTakeOffTask(copters); // added by ZJF
|
||||
// TakeOffNumAttr = task.takeoffnumber;
|
||||
// TakeOffNumAttr = task.takeoffnumber;
|
||||
TakeOffNumAttr = task.takeoffnumber;
|
||||
RestoreTakeOffTask((byte)task.takeoffTime, task.singleCopterInfos);
|
||||
break;
|
||||
case FlightTaskType.FlyTo:
|
||||
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, task.singleCopterInfos);
|
||||
|
@ -0,0 +1,176 @@
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Plane.Copters;
|
||||
using Plane.Windows.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
public partial class FlightTaskSingleCopterInfo
|
||||
{
|
||||
public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter)
|
||||
{
|
||||
var info = new FlightTaskSingleCopterInfo(copter)
|
||||
{
|
||||
|
||||
};
|
||||
return info;
|
||||
}
|
||||
|
||||
public void AddLEDInfo()
|
||||
{
|
||||
LEDInfo LedInfo = new LEDInfo();
|
||||
LEDInfos.Add(LedInfo);
|
||||
LedInfo.RemoveEvent += new LEDInfo.RemoveEventHandler(LEDRemove);
|
||||
}
|
||||
|
||||
public void AddLEDInfo(LEDInfo LedInfo)
|
||||
{
|
||||
LEDInfos.Add(LedInfo);
|
||||
LedInfo.RemoveEvent += new LEDInfo.RemoveEventHandler(LEDRemove);
|
||||
}
|
||||
|
||||
public void LEDRemove(object sender)
|
||||
{
|
||||
LEDInfo LedInfo = sender as LEDInfo;
|
||||
LEDInfos.Remove(LedInfo);
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<LEDInfo> LEDInfos { get; } = new ObservableCollection<LEDInfo>();
|
||||
|
||||
|
||||
//设置飞机航点中灯光
|
||||
private ICommand _AddLEDCommand;
|
||||
public ICommand AddLEDCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AddLEDCommand ?? (_AddLEDCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
AddLEDInfo();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _SetAllCopterLEDCommand;
|
||||
public ICommand SetAllCopterLEDCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SetAllCopterLEDCommand ?? (_SetAllCopterLEDCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
|
||||
{
|
||||
if (!info.Equals(this))
|
||||
{
|
||||
info.LEDInfos.Clear();
|
||||
foreach (LEDInfo led in LEDInfos)
|
||||
{
|
||||
LEDInfo addLED = new LEDInfo();
|
||||
addLED.CopyForm(led);
|
||||
info.AddLEDInfo(addLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _SetSelectedCopterLEDCommand;
|
||||
public ICommand SetSelectedCopterLEDCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SetSelectedCopterLEDCommand ?? (_SetSelectedCopterLEDCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.SelectedTask.SingleCopterInfos)
|
||||
{
|
||||
if (_copterManager.AcceptingControlCopters.Contains(info.Copter))
|
||||
{
|
||||
if (!info.Equals(this))
|
||||
{
|
||||
info.LEDInfos.Clear();
|
||||
foreach (LEDInfo led in LEDInfos)
|
||||
{
|
||||
LEDInfo addLED = new LEDInfo();
|
||||
addLED.CopyForm(led);
|
||||
info.AddLEDInfo(addLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LEDInfo
|
||||
{
|
||||
private double delay = 1; //灯光延时 单位:100ms (从当前任务开为0,延时几秒后设置LED)
|
||||
private int ledmode = 0; //灯光模式 0常亮 1闪烁 2随机闪烁(RGB无意义)
|
||||
private int ledrate = 0; //闪烁延时 单位:100ms
|
||||
private int ledtimes = 0; //次数 (预留、暂取消其意义)
|
||||
private string ledRGB = "FFFFFF"; //灯光颜色
|
||||
|
||||
public LEDInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CopyForm(LEDInfo led)
|
||||
{
|
||||
delay = led.delay;
|
||||
ledmode = led.ledmode;
|
||||
ledrate = led.ledrate;
|
||||
ledRGB = led.ledRGB;
|
||||
}
|
||||
public double Delay
|
||||
{
|
||||
get { return delay; }
|
||||
set { delay = value; }
|
||||
}
|
||||
|
||||
public int LEDMode
|
||||
{
|
||||
get { return ledmode; }
|
||||
set { ledmode = value; }
|
||||
}
|
||||
public int LEDRate
|
||||
{
|
||||
get { return ledrate; }
|
||||
set { ledrate = value; }
|
||||
}
|
||||
public int LEDTimes
|
||||
{
|
||||
get { return ledtimes; }
|
||||
set { ledtimes = value; }
|
||||
}
|
||||
|
||||
public string LEDRGB
|
||||
{
|
||||
get { return ledRGB; }
|
||||
set { ledRGB = value; }
|
||||
}
|
||||
|
||||
public delegate void RemoveEventHandler(object sender);
|
||||
public event RemoveEventHandler RemoveEvent;
|
||||
private ICommand _RemoveLEDCommand;
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ICommand RemoveLEDCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RemoveLEDCommand ?? (_RemoveLEDCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
RemoveEvent(this);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Plane.Copters;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
public partial class FlightTaskSingleCopterInfo
|
||||
{
|
||||
// This file is added by ZJF
|
||||
public static FlightTaskSingleCopterInfo CreateForLandTask(ICopter copter, int landWaitTime)
|
||||
{
|
||||
var info = new FlightTaskSingleCopterInfo(copter)
|
||||
{
|
||||
LandWaitTime = (ushort)landWaitTime
|
||||
};
|
||||
return info;
|
||||
}
|
||||
|
||||
private ushort _LandWaitTime = 5;
|
||||
public ushort LandWaitTime
|
||||
{
|
||||
get { return _LandWaitTime; }
|
||||
set { Set(nameof(LandWaitTime), ref _LandWaitTime, value); }
|
||||
}
|
||||
}
|
||||
}
|
43
Plane.FormationCreator/Formation/FlightTask_Land.cs
Normal file
43
Plane.FormationCreator/Formation/FlightTask_Land.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
public partial class FlightTask
|
||||
{
|
||||
public async Task MutilLandTaskAsync()
|
||||
{
|
||||
int TaskCount = _flightTaskManager.Tasks.Count();
|
||||
if (TaskCount > 1)
|
||||
{
|
||||
var infos = SingleCopterInfos;
|
||||
// var infos = SingleCopterInfos.OrderByDescending(i => i.TargetAlt).ToList();
|
||||
var tasks = new Task[infos.Count];
|
||||
var tasksTmp = new Task[infos.Count];
|
||||
Task[] test = new Task[infos.Count];
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
var info = infos[i];
|
||||
test[i] = LandTaskAsync(info);
|
||||
}
|
||||
await Task.WhenAll(test).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task LandTaskAsync(FlightTaskSingleCopterInfo info)
|
||||
{
|
||||
DateTime dtNow = DateTime.Now;
|
||||
DateTime dtLastTime = DateTime.Now;
|
||||
TimeSpan ts = dtNow - dtLastTime;
|
||||
int waittime = (int)info.LandWaitTime * 1000;
|
||||
await Task.Delay(waittime).ConfigureAwait(false);
|
||||
await info.Copter.LandAsync();
|
||||
}
|
||||
}
|
||||
}
|
@ -97,7 +97,7 @@
|
||||
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<ImageBrush ImageSource=".\bg.jpg"/>
|
||||
<ImageBrush ImageSource=".\bg.jpg" />
|
||||
</Grid.Background>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
|
@ -1185,6 +1185,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
foreach (LEDInfo ledInfo in LEDInfos)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB);
|
||||
if (ledInfo.LEDMode == 5) ledInfo.LEDMode = 6;
|
||||
IMission LEDMission = Mission.CreateLEDControlMission(
|
||||
(int)(ledInfo.Delay * 10),
|
||||
ledInfo.LEDMode,
|
||||
|
@ -56,9 +56,10 @@ namespace Plane.FormationCreator.ViewModels
|
||||
public string Message
|
||||
{
|
||||
get { return _Message; }
|
||||
set {
|
||||
Set(nameof(Message), ref _Message, value);
|
||||
_MessageList.Add(value);
|
||||
set
|
||||
{
|
||||
Set(nameof(Message), ref _Message, value);
|
||||
_MessageList.Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,73 +213,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(StaggerRoutes), ref _StaggerRoutes, value); }
|
||||
}
|
||||
|
||||
private ICommand _ExportTasksCommand;
|
||||
public ICommand ExportTasksCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ExportTasksCommand ?? (_ExportTasksCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||
{
|
||||
Alert.Show("作为参照的原点未设置,无法导出相对位置!", "提示");
|
||||
return;
|
||||
}
|
||||
var exportedText = _flightTaskManager.ExportTasks();
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
DefaultExt = "fcg",
|
||||
Filter = "编队飞行任务 (*.fcg)|*.fcg"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
File.WriteAllText(dialog.FileName, exportedText);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ImportTasksCommand;
|
||||
public ICommand ImportTasksCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ImportTasksCommand ?? (_ImportTasksCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||
{
|
||||
Alert.Show("作为参照的原点未设置,无法导入相对位置!", "提示");
|
||||
return;
|
||||
}
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
DefaultExt = "fcg",
|
||||
Filter = "编队飞行任务 (*.fcg)|*.fcg"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
int _startindex = txtStarindex;
|
||||
int _endindex= txtendindex;
|
||||
|
||||
var tasksText = File.ReadAllText(dialog.FileName);
|
||||
if ((txtStarindex == 0) && (txtendindex == 0))
|
||||
_flightTaskManager.ImportTasks(tasksText);
|
||||
else
|
||||
{
|
||||
_endindex = txtendindex;
|
||||
if (_startindex == 0)
|
||||
_startindex = 1;
|
||||
if (_endindex == 0)
|
||||
_endindex = _startindex;
|
||||
_flightTaskManager.ImportTasksindex(tasksText, _startindex, _endindex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
//调整所有任务经度
|
||||
private ICommand _ModiAllPosCommand;
|
||||
public ICommand ModiAllPosCommand
|
||||
|
37
Plane.FormationCreator/Views/LogWindow.xaml
Normal file
37
Plane.FormationCreator/Views/LogWindow.xaml
Normal file
@ -0,0 +1,37 @@
|
||||
<c:MetroWindow x:Class="Plane.FormationCreator.Views.LogWindow"
|
||||
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:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
|
||||
mc:Ignorable="d"
|
||||
Style="{StaticResource VSWindowStyleKey}"
|
||||
Title="日志" Height="776.219" Width="1195.283">
|
||||
<Grid>
|
||||
<TabControl>
|
||||
<TabItem Header="软件日志">
|
||||
<TextBox
|
||||
Name="textAppLog"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Margin="10,10,10,10"
|
||||
TextWrapping="Wrap"
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
|
||||
</TabItem>
|
||||
<TabItem Header="飞机日志">
|
||||
<TextBox
|
||||
Name="textCopterLog"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Margin="10,10,10,10"
|
||||
TextWrapping="Wrap"
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Grid>
|
||||
</c:MetroWindow>
|
41
Plane.FormationCreator/Views/LogWindow.xaml.cs
Normal file
41
Plane.FormationCreator/Views/LogWindow.xaml.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Plane.FormationCreator.Formation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using MahApps.Metro.Controls;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Plane.Logging;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// LogWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LogWindow : MetroWindow
|
||||
{
|
||||
public LogWindow(string log)
|
||||
{
|
||||
InitializeComponent();
|
||||
textAppLog.Text = log;
|
||||
textAppLog.SelectionStart = textAppLog.Text.Length;
|
||||
textAppLog.ScrollToEnd();
|
||||
var _logger = ServiceLocator.Current.GetInstance<ILogger>();
|
||||
string loger = _logger.ReadLog();
|
||||
textCopterLog.Text = loger;
|
||||
textCopterLog.SelectionStart = textCopterLog.Text.Length;
|
||||
}
|
||||
}
|
||||
}
|
@ -289,18 +289,25 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="灯光控制: " Margin="5, 10, 5, 0" VerticalAlignment="Center"/>
|
||||
<Grid Grid.Column="1" VerticalAlignment="Center">
|
||||
<Grid Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Content="应用到全部" VerticalAlignment="Center"
|
||||
Margin="0,5,5,0"
|
||||
Command="{Binding SetAllCopterLEDCommand}" />
|
||||
<Button Content="应用到所选" VerticalAlignment="Center"
|
||||
Margin="0,5,5,0"
|
||||
Grid.Column="1"
|
||||
Command="{Binding SetSelectedCopterLEDCommand}" />
|
||||
<Button Content="添加" VerticalAlignment="Center"
|
||||
Grid.Column="1"
|
||||
Grid.Column="2"
|
||||
Margin="0,5,5,0"
|
||||
Command="{Binding AddLEDCommand}" />
|
||||
</Grid>
|
||||
@ -343,6 +350,7 @@
|
||||
<ComboBoxItem Content="随机" />
|
||||
<ComboBoxItem Content="渐亮" />
|
||||
<ComboBoxItem Content="渐暗" />
|
||||
<ComboBoxItem Content="同步随机" />
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="时间" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
|
||||
|
@ -115,9 +115,9 @@
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Height="100" Background="#FF2D2D2D" >
|
||||
<StackPanel Height="100" Background="#FF2D2D2D" VerticalAlignment="Bottom">
|
||||
|
||||
<TabControl
|
||||
DataContext="{Binding FlightTaskManager.SelectedTask}"
|
||||
|
Loading…
Reference in New Issue
Block a user