任务时间提示
防止修改任务为起飞任务 下方添加状态提示信息 任务块,在任务模拟中双击是马上执行该任务,右键改名 调整界面,去掉不必要的元素
This commit is contained in:
parent
b80026ff8c
commit
6f33c3867c
@ -161,6 +161,36 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
public ObservableCollection<FlightTask> Tasks { get; } = new ObservableCollection<FlightTask>();
|
||||
|
||||
|
||||
|
||||
public int GetTaskTime(int TaskIndex)
|
||||
{
|
||||
int tasktime = 0;
|
||||
if ((Tasks==null)|| TaskIndex> Tasks.Count-1) return tasktime;
|
||||
|
||||
FlightTask value = Tasks[TaskIndex];
|
||||
switch (value.TaskType)
|
||||
{
|
||||
case FlightTaskType.TakeOff: tasktime = value.TakeOffTime; ; break;
|
||||
case FlightTaskType.FlyTo: tasktime = value.FlytoTime + value.LoiterTime; break;
|
||||
//降落时间计算前一个任务目标高度最高的飞机的降落时间按1.5米/秒下降
|
||||
case FlightTaskType.Land:
|
||||
float maxalt = 0.0f;
|
||||
for (int i = 0; i < Tasks[TaskIndex-1].SingleCopterInfos.Count; i++)
|
||||
{
|
||||
var copterInfo = Tasks[TaskIndex - 1].SingleCopterInfos[i];
|
||||
if (maxalt < copterInfo.TargetAlt) maxalt = copterInfo.TargetAlt;
|
||||
}
|
||||
tasktime =(int) Math.Round(maxalt / 1.5,0);
|
||||
break;
|
||||
}
|
||||
return tasktime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private FlightTask _SelectedTask;
|
||||
public FlightTask SelectedTask
|
||||
{
|
||||
@ -169,8 +199,33 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
if (_SelectedTask != value)
|
||||
{
|
||||
int starttime=0;
|
||||
|
||||
if (_SelectedTask != null) _SelectedTask.IsSelected = false;
|
||||
if (value != null) value.IsSelected = true;
|
||||
if (value != null)
|
||||
{
|
||||
value.IsSelected = true;
|
||||
for (int i = 0; i < value.TaskIndex; i++)
|
||||
starttime += GetTaskTime(i);
|
||||
|
||||
TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(starttime));
|
||||
string str = "";
|
||||
if (ts.Hours > 0)
|
||||
{
|
||||
str = ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分" + ts.Seconds + "秒";
|
||||
}
|
||||
if (ts.Hours == 0 && ts.Minutes > 0)
|
||||
{
|
||||
str = ts.Minutes.ToString() + "分" + ts.Seconds + "秒";
|
||||
}
|
||||
if (ts.Hours == 0 && ts.Minutes == 0)
|
||||
{
|
||||
str = ts.Seconds + "秒";
|
||||
}
|
||||
Message.ShowStatus($"选中 [{value.TaskIndex+1} {value.TaskCnName }] 从{str}开始执行,需{ GetTaskTime(value.TaskIndex)}秒");
|
||||
}
|
||||
else Message.ShowStatus($"无任务选中");
|
||||
|
||||
}
|
||||
Set(nameof(SelectedTask), ref _SelectedTask, value);
|
||||
}
|
||||
@ -361,7 +416,7 @@ namespace Plane.FormationCreator.Formation
|
||||
SelectedTask = null;
|
||||
SelectedTaskIndex = 0;
|
||||
TasksCleared?.Invoke(this, EventArgs.Empty);
|
||||
AddTakeOffTask(_copterManager.Copters);
|
||||
// AddTakeOffTask(_copterManager.Copters);
|
||||
}
|
||||
|
||||
|
||||
@ -397,12 +452,9 @@ namespace Plane.FormationCreator.Formation
|
||||
public async Task FlyToTasks()
|
||||
{
|
||||
var copters = _copterManager.Copters;
|
||||
|
||||
|
||||
|
||||
if ((TaskState == TasksStatus.Stop) ||( CurrentRunningTaskIndex == Tasks.Count - 1))
|
||||
if ((TaskState == TasksStatus.Stop))
|
||||
return;
|
||||
|
||||
|
||||
Pause();
|
||||
int i = 0;
|
||||
//等待暂停或2s超时(80*25ms)
|
||||
@ -425,10 +477,36 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
var copter = copters[j];
|
||||
var fc = copter as FakeCopter;
|
||||
float targalt = 0.0f;
|
||||
double lat = 0.0f;
|
||||
double lng = 0.0f;
|
||||
|
||||
//飞机回到前一个任务位置,
|
||||
|
||||
//起飞任务直接用当前起飞任务位置
|
||||
if (Tasks[SelectedTaskIndex].TaskType == FlightTaskType.TakeOff)
|
||||
{
|
||||
lat = Tasks[SelectedTaskIndex].SingleCopterInfos[j].TargetLat;
|
||||
lng = Tasks[SelectedTaskIndex].SingleCopterInfos[j].TargetLng;
|
||||
targalt = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//用前一个任务目标位置
|
||||
lat = Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLat;
|
||||
lng = Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLng;
|
||||
|
||||
|
||||
//如果前一个是起飞任务,没有目标高度,用当前的
|
||||
if (Tasks[SelectedTaskIndex - 1].TaskType == FlightTaskType.TakeOff)
|
||||
targalt = Tasks[SelectedTaskIndex].SingleCopterInfos[j].TargetAlt;
|
||||
else
|
||||
targalt = Tasks[SelectedTaskIndex - 1].SingleCopterInfos[j].TargetAlt;
|
||||
}
|
||||
fc.SetProperties(
|
||||
latitude: Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLat,
|
||||
longitude: Tasks[SelectedTaskIndex-1].SingleCopterInfos[j].TargetLng,
|
||||
altitude: Tasks[SelectedTaskIndex - 1].SingleCopterInfos[j].TargetAlt
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
altitude: targalt
|
||||
|
||||
);
|
||||
|
||||
@ -1850,11 +1928,16 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
return copterStr;
|
||||
}
|
||||
|
||||
//左键选中任务
|
||||
public void Select(FlightTask flightTask)
|
||||
{
|
||||
this.SelectedTaskIndex = Tasks.IndexOf(flightTask);
|
||||
this.SelectedTask = flightTask;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 右键选中任务
|
||||
@ -1898,6 +1981,7 @@ namespace Plane.FormationCreator.Formation
|
||||
DateTime taskStartTime;
|
||||
public async Task RunTaskAsync()
|
||||
{
|
||||
if (Tasks.Count == 0) return;
|
||||
if (CurrentRunningTaskIndex == 0)
|
||||
{
|
||||
taskStartTime = DateTime.Now;
|
||||
@ -1922,9 +2006,6 @@ namespace Plane.FormationCreator.Formation
|
||||
//task.Status目前只用于任务条下面状态显示不同颜色
|
||||
task.Status = FlightTaskStatus.Stop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AppEx.Current.AppMode = AppMode.RunningTasks;
|
||||
StartAvoidingCrash(); //开始碰撞检测
|
||||
TaskState = TasksStatus.Running;
|
||||
@ -1935,13 +2016,23 @@ namespace Plane.FormationCreator.Formation
|
||||
task.Status = FlightTaskStatus.Running;
|
||||
CurrentRunningTask = task;
|
||||
CurrentRunningTaskIndex = i;
|
||||
Message.Show($"任务{i+1}开始执行");
|
||||
|
||||
//////////////////显示提示信息
|
||||
int starttime = 0;
|
||||
for (int j = 0; j < task.TaskIndex; j++)
|
||||
starttime += GetTaskTime(j);
|
||||
TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(starttime));
|
||||
Message.Show($"{ts}:任务{i+1} {task.TaskCnName } 开始执行,需{ GetTaskTime(task.TaskIndex)}秒");
|
||||
/////////////////////////
|
||||
|
||||
|
||||
await task.RunAsync().ConfigureAwait(false);
|
||||
// 1. 被暂停时,中断 RunAsync。继续运行时将把此时运行了一半的 CurrentRunningTask 重新运行一遍。
|
||||
if (IsPaused == true)
|
||||
{
|
||||
task.Status = FlightTaskStatus.Paused;
|
||||
TaskState = TasksStatus.Paused;
|
||||
Message.Show($"任务{i + 1} {task.TaskCnName } 暂停执行");
|
||||
return;
|
||||
}
|
||||
task.Status = FlightTaskStatus.Stop;
|
||||
|
@ -223,15 +223,19 @@
|
||||
Background="{StaticResource WhiteBrush}">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Margin="4"
|
||||
Text="{Binding Message}" MouseUp="LogShowHide"/>
|
||||
<TextBlock Margin="4"
|
||||
<TextBlock Margin="10,4"
|
||||
Text="{Binding Message}" Width="300" MouseUp="LogShowHide"/>
|
||||
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
||||
<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="200"
|
||||
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<TextBlock Text="通信连接:" Margin="4"/>
|
||||
<ContentPresenter Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
|
||||
<ContentPresenter Margin="0,4,14,0" Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
@ -489,7 +489,10 @@ namespace Plane.FormationCreator
|
||||
if (logTextBox.Visibility == Visibility.Visible)
|
||||
logTextBox.Visibility = Visibility.Hidden;
|
||||
else
|
||||
{
|
||||
logTextBox.Height= Math.Max( map.ActualHeight, map3D.ActualHeight) - ((TaskBarView) TaskbarControl).TasksControl.ActualHeight;
|
||||
logTextBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void LogTextChange(object sender, TextChangedEventArgs e)
|
||||
|
@ -23,7 +23,11 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
_copterListViewModel = copterListViewModel;
|
||||
|
||||
//状态信息
|
||||
Plane.Windows.Messages.Message.ConfigureStatus(showAction: msg => this.SysStatusText = msg);
|
||||
//日志信息
|
||||
Plane.Windows.Messages.Message.Configure(showAction: msg => this.Message = msg);
|
||||
//连接信息
|
||||
Plane.Windows.Messages.Message.Configure(connectAction: connected => this.CommunicationModuleConnected = connected);
|
||||
|
||||
this.SwitchVelocityModeButtonContent = GetSwitchVelocityModeButtonContent();
|
||||
@ -69,6 +73,10 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private bool _CommunicationModuleConnected;
|
||||
public bool CommunicationModuleConnected
|
||||
{
|
||||
@ -79,6 +87,17 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private string _SysStatusText="系统信息";
|
||||
public string SysStatusText
|
||||
{
|
||||
get { return _SysStatusText; }
|
||||
set
|
||||
{
|
||||
Set(nameof(SysStatusText), ref _SysStatusText, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<string> _MessageList = new List<string>();
|
||||
|
||||
public string Messages
|
||||
|
@ -89,7 +89,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
|
||||
FlightTask task = _flightTaskManager.SelectedTask;
|
||||
if (task.TaskType != FlightTaskType.FlyTo) return;
|
||||
if ((task==null) ||(task.TaskType != FlightTaskType.FlyTo)) return;
|
||||
|
||||
string newName = task.TaskCnName;
|
||||
if (PlaneMessageBox.OnShow("请输入新的名称", "重命名", ref newName))
|
||||
|
@ -41,16 +41,16 @@
|
||||
>
|
||||
<CheckBox Grid.Row="0" Content="所有航点" Margin="5,5,0,0"
|
||||
Click="showallpoint_Checked"
|
||||
Foreground="White" IsChecked="True"
|
||||
Foreground="White" IsChecked="True" Visibility="Collapsed"
|
||||
/>
|
||||
<CheckBox Grid.Row="0" Content="计划航线" Margin="5,5,0,0"
|
||||
<CheckBox Grid.Row="0" Content="飞行航线" Margin="5,5,0,0"
|
||||
Click="showpanline_Checked"
|
||||
Foreground="White"
|
||||
/>
|
||||
|
||||
<CheckBox Grid.Row="0" Content="实时航线" Margin="5,5,0,0"
|
||||
Foreground="White"
|
||||
Click="showrealtimeline_Checked" />
|
||||
Click="showrealtimeline_Checked" Visibility="Collapsed" />
|
||||
|
||||
<ComboBox x:Name="MapSelectionComboBox"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -91,7 +91,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Background="{Binding Status, Converter={StaticResource FlightTaskStatusToFillConverter}}"
|
||||
Width="85"
|
||||
Width="90"
|
||||
Height="19"
|
||||
BorderThickness="1"
|
||||
BorderBrush="Black"
|
||||
@ -127,13 +127,15 @@
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Height="100" Background="#FF2D2D2D" VerticalAlignment="Bottom">
|
||||
|
||||
<TabControl
|
||||
<TextBlock x:Name="hintaddtask" Margin="0,25,0,0" Text="请添加或选择飞行任务" Visibility="Collapsed" FontSize="18" TextAlignment="Center"/>
|
||||
|
||||
<TabControl x:Name="tasktabcont"
|
||||
DataContext="{Binding FlightTaskManager.SelectedTask}"
|
||||
SelectedIndex="{Binding TaskTypeIndex,UpdateSourceTrigger=PropertyChanged}">
|
||||
|
||||
|
||||
|
||||
<TabItem Header="起飞">
|
||||
<TabItem Header="起飞" x:Name="takeoffpage">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
@ -145,7 +147,7 @@
|
||||
</Grid>
|
||||
|
||||
</TabItem>
|
||||
<TabItem Header="航点">
|
||||
<TabItem Header="航点" x:Name="flytopage">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
@ -166,7 +168,7 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="降落">
|
||||
<TabItem Header="降落" x:Name="landpage">
|
||||
<Grid Margin="10" >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
|
@ -28,6 +28,60 @@ namespace Plane.FormationCreator.Views
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = ServiceLocator.Current.GetInstance<TaskBarViewModel>();
|
||||
|
||||
|
||||
|
||||
hintaddtask.Visibility = Visibility.Visible;
|
||||
tasktabcont.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
|
||||
_flightTaskManager.PropertyChanged += (sender, e) =>
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
//选中任务时触发
|
||||
case nameof(FlightTaskManager.SelectedTaskIndex):
|
||||
if (_flightTaskManager.Tasks.Count == 0)
|
||||
{
|
||||
|
||||
tasktabcont.Visibility = Visibility.Collapsed;
|
||||
hintaddtask.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
hintaddtask.Visibility = Visibility.Collapsed;
|
||||
tasktabcont.Visibility = Visibility.Visible;
|
||||
|
||||
if (_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskType == FlightTaskType.TakeOff)
|
||||
{
|
||||
takeoffpage.Visibility = Visibility.Visible;
|
||||
landpage.Visibility = Visibility.Collapsed;
|
||||
flytopage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
takeoffpage.Visibility = Visibility.Collapsed;
|
||||
landpage.Visibility = Visibility.Visible;
|
||||
flytopage.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||
@ -42,16 +96,17 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
}
|
||||
|
||||
//选择任务
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//选择任务
|
||||
private void SelectTask(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var elem = sender as FrameworkElement;
|
||||
var task = elem.DataContext as FlightTask;
|
||||
//if (task.TaskType != FlightTaskType.TakeOff) // 不让选起飞任务。 现在可以选择起飞任务
|
||||
{
|
||||
_flightTaskManager.Select(task);
|
||||
}
|
||||
|
||||
_flightTaskManager.Select(task);
|
||||
}
|
||||
|
||||
//以前的右键隐藏航点,已不用
|
||||
|
Loading…
Reference in New Issue
Block a user