修复了起飞的bug

添加了返航电压
添加了版本控制中飞机数量
This commit is contained in:
zxd 2019-01-03 14:30:56 +08:00
parent e2dcb04d62
commit 1e69baaf9d
13 changed files with 96 additions and 36 deletions

View File

@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator.Formation
{
@ -21,18 +22,18 @@ namespace Plane.FormationCreator.Formation
{
////给第三方时候限制数量和时间用
// DateTime dateTime2019 = DateTime.Parse("2019-06-20");
//
// if (DateTime.UtcNow > dateTime2019)
// {
// throw new NotImplementedException();
// }
//
//
// if (this.Count >= 50)
// {
// return 0;
// }
DateTime dateTime2019 = DateTime.Parse("2019-06-20");
if (DateTime.UtcNow > dateTime2019)
{
throw new NotImplementedException();
}
if (this.Count >= VersionControl.CopterUpperLimit)
{
return 0;
}
int _index = 0;
if (this.Count == 0)

View File

@ -100,7 +100,6 @@ namespace Plane.FormationCreator.Formation
var copter = info.Copter;
//等待起飞时间
Windows.Messages.Message.Show($"{copter.Name}:等待起飞 = {info.TakeOffWaitTime}");
while ((int)ts.TotalMilliseconds < (int)info.TakeOffWaitTime * 1000)
{
if (_flightTaskManager.IsPaused == true)
@ -138,12 +137,10 @@ namespace Plane.FormationCreator.Formation
ts = dtNow - dtLastTime;
FlightTask task = _flightTaskManager.CurrentRunningTask;
Windows.Messages.Message.Show($"{copter.Name}:等待到达飞行时间 = {task.TakeOffTime}");
while (ts.TotalMilliseconds < task.TakeOffTime * 1000)
{
if (_flightTaskManager.IsPaused == true)
{
//Windows.Messages.Message.Show($"{copter.Name}:悬停");
await info.Copter.HoverAsync();
return;
}

View File

@ -42,15 +42,17 @@
<c:MetroWindow.RightWindowCommands>
<c:WindowCommands>
<Button Content="切换地图" Command="{Binding ChangeMapModeCommand}"></Button>
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
Command="{Binding ShowOrHideModifyTaskViewCommand}" />
<Button Content="切换地图"
Command="{Binding ChangeMapModeCommand}"/>
<Button Content="重启监听"
Visibility="Collapsed"
Command="{Binding RestartListeningCommand}" />
<Button Content="{Binding SwitchVelocityModeButtonContent}"
Command="{Binding SwitchVelocityModeCommand}" />
Command="{Binding SwitchVelocityModeCommand}"
Visibility="Collapsed"/>
<!--// 林俊清, 20150930, 不分这些模式了。
<Button Content="进入任务模式"
Command="{Binding SwitchAppModeCommand}"
@ -62,7 +64,8 @@
Visibility="{Binding Source={x:Static local:AppEx.Current}, Path=AppMode, Converter={StaticResource AppModeToVisibilityConverter}, ConverterParameter=SwitchToControllingCoptersModeButton}" />-->
<Button Name="btnGoHome"
Content="回家"
Click="btnGoHome_Click" />
Click="btnGoHome_Click"
Visibility="Collapsed"/>
<Button Name="btnRefreshMap"
Content="刷新地图"
Visibility="Collapsed"

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Plane.FormationCreator"
mc:Ignorable="d"
Title="修改参数" Height="418.215" Width="715.206" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
Title="修改参数" Height="469.53" Width="710.075" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid Margin="0,0,5,3.5">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@ -32,6 +32,10 @@
<Button Content="š开关灯" Tag="NTF_G_OFF" Click="Modify_Select" Width="130"/>
<Label Content="_NTF_G_OFF"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<Button Content="š返航电压" Tag="FS_BATT_VOLTAGE" Click="Modify_Select" Width="130"/>
<Label Content="_FS_BATT_VOLTAGE"/>
</StackPanel>
</WrapPanel>
<StackPanel Name="hide_panel">
@ -77,11 +81,13 @@
</StackPanel>
</StackPanel>
</WrapPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Center" Orientation ="Horizontal">
<WrapPanel VerticalAlignment="Center" Orientation="Vertical" >
<Label x:Name="label" Content="参数名称" Margin="5,0,5,5"/>
<Label x:Name="label" Content="参数" Margin="5,0,5,5"/>
<TextBox x:Name="textParamName" Width="160" Margin="5" />
<Label x:Name="label_cn" Content="描述" Margin="5,0,5,5"/>
<TextBox x:Name="textParamName_cn" Width="160" Margin="5" IsReadOnly="True"/>
<Label x:Name="label_Copy" Content="参数值" Margin="5"/>
<TextBox x:Name="textParamValue" Margin="5"/>
<Button x:Name="btnModify" Content="修改" Width="100" Margin="10" Click="btnModify_Click"/>

View File

@ -29,6 +29,9 @@ namespace Plane.FormationCreator
hide_panel.Visibility = Visibility.Collapsed;
textParamName.IsReadOnly = true;
btnLoad.Visibility = Visibility.Collapsed;
label.Visibility = Visibility.Collapsed;
textParamName.Visibility = Visibility.Collapsed;
}
}
@ -41,6 +44,7 @@ namespace Plane.FormationCreator
private void Modify_Select(object sender, RoutedEventArgs e)
{
textParamName.Text = ((Button)sender).Tag.ToString();
textParamName_cn.Text = ((Button)sender).Content.ToString();
}
private void btnLoad_Click(object sender, RoutedEventArgs e)

View File

@ -10,16 +10,31 @@ namespace Plane.FormationCreator.Util
public static class VersionControl
{
public static int Version = 0;
/// <summary>
/// 是否是完整版本 仅在Version = 255时为完整版本
/// </summary>
public static bool IsFullVersion = false;
/// <summary>
/// 默认的飞机上限
/// </summary>
public static int CopterUpperLimit = 50;
public static void GetVersionFromIni()
{
IniFiles iniFiles = new IniFiles();
string readvalue = iniFiles.IniReadvalue("Version", "Version");
int intTemp;
string readvalue;
readvalue = iniFiles.IniReadvalue("Version", "Version");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
Version = int.Parse(readvalue);
IsFullVersion = Version == 255;
readvalue = iniFiles.IniReadvalue("Version", "CopterUpperLimit");
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
CopterUpperLimit = int.Parse(readvalue);
}
}
}

View File

@ -335,6 +335,16 @@ namespace Plane.FormationCreator.ViewModels
}
}
/// <summary>
/// 是否允许开始任务全部解锁会在3秒内循环发送3次该过程中不允许开始任务
/// </summary>
private bool _AllowMissionStart = true;
public bool AllowMissionStart
{
get { return _AllowMissionStart; }
set { Set(nameof(AllowMissionStart), ref _AllowMissionStart, value); }
}
private ICommand _UnlockAllCommand;
public ICommand UnlockAllCommand
@ -343,13 +353,16 @@ namespace Plane.FormationCreator.ViewModels
{
return _UnlockAllCommand ?? (_UnlockAllCommand = new RelayCommand(async () =>
{
AllowMissionStart = false;
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
for (int i = 0; i < 3; i++)
{
await _commModuleManager.UnlockAsync();
await Task.Delay(1000).ConfigureAwait(false);
}
await Task.Delay(100);
AllowMissionStart = true;
/*
await Task.WhenAll(_copterManager.Copters.Select(async c => {
await c.UnlockAsync();
@ -963,7 +976,7 @@ namespace Plane.FormationCreator.ViewModels
int utchour = DateTime.UtcNow.AddSeconds(5).Hour;
int utcminute = DateTime.UtcNow.AddSeconds(5).Minute;
int utcsecond = DateTime.UtcNow.AddSeconds(5).Second;
Message.Show("开始任务");
//循环3次 发送起飞命令 避免通信问题
for (int i = 0; i < 5; i++)
{

View File

@ -16,6 +16,7 @@ using System.Threading;
using Plane.Communication;
using Plane.Geography;
using Microsoft.Practices.ServiceLocation;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator.ViewModels
{
@ -131,10 +132,10 @@ namespace Plane.FormationCreator.ViewModels
return _AddVirtualCopterCommand ?? (_AddVirtualCopterCommand = new RelayCommand<int>(async addcount =>
{
//给第三方时候限制数量用
// if (_copterManager.Copters.Count() >= 50)
// {
// return;
// }
if (_copterManager.Copters.Count() >= VersionControl.CopterUpperLimit)
{
return;
}
var center = _mapManager.Center;
string id;

View File

@ -88,7 +88,9 @@
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Grid.Row="1"
Grid.ColumnSpan="3">
Grid.ColumnSpan="3"
Name="panel1">
<ec:ProgressButton HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="10"
@ -128,7 +130,8 @@
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Grid.Row="2"
Grid.ColumnSpan="3">
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}" />
@ -142,14 +145,16 @@
<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 QueryAllCopterCommand}"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Grid.Row="4"
Grid.ColumnSpan="3">
Grid.ColumnSpan="3"
Name="panel3">
<Button Content="空中升级" Margin="5" Command="{Binding UpdateAllCopterCommand}"></Button>
<Button Content="搜索飞机" Margin="5" Command="{Binding QueryAllCopterCommand}"/>
</StackPanel>
</Grid>

View File

@ -15,6 +15,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator.Views
{
@ -38,6 +39,13 @@ namespace Plane.FormationCreator.Views
this.DataContext = ServiceLocator.Current.GetInstance<ConnectViewModel>();
if (!VersionControl.IsFullVersion)
{
panel1.Visibility = Visibility.Collapsed;
panel2.Visibility = Visibility.Collapsed;
panel3.Visibility = Visibility.Collapsed;
}
txtIPs.Focus();
}
}

View File

@ -102,9 +102,11 @@
<Button Content="写入航点"
Command="{Binding WriteMissionCommand}" />
<Button Content="全部解锁"
Command="{Binding UnlockAllCommand}" />
Command="{Binding UnlockAllCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="开始任务"
Command="{Binding MissionStartCommand}" />
Command="{Binding MissionStartCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="暂停任务"
Command="{Binding MissionPauseCommand}" />
<Button Content="继续任务"

View File

@ -287,7 +287,7 @@
<TabItem Header="灯光设计">
<StackPanel>
<StackPanel >
<StackPanel x:Name="lightDesign">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" >
<TextBlock Margin="5,7,0,0" Text="起始时间"/>
<TextBox Margin="5,5,0,3" Width="30" Text="{Binding BeginTime}"/>

View File

@ -16,6 +16,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Plane.Geography;
using Plane.FormationCreator.Util;
namespace Plane.FormationCreator.Views
{
@ -30,6 +31,10 @@ namespace Plane.FormationCreator.Views
InitializeComponent();
this.DataContext = _modifyTaskViewModel;
if (!VersionControl.IsFullVersion)
{
lightDesign.Visibility = Visibility.Collapsed;
}
}
private void Button_Click(object sender, RoutedEventArgs e)