加入批量修改参数功能
This commit is contained in:
parent
db60b6b8cc
commit
074c5bdedf
17
Plane.FormationCreator/ModifyParam.xaml
Normal file
17
Plane.FormationCreator/ModifyParam.xaml
Normal file
@ -0,0 +1,17 @@
|
||||
<Window x:Class="Plane.FormationCreator.ModifyParam"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
Title="修改参数" Height="238.21" Width="170.881" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
|
||||
<Grid Margin="0,0,5,3.5">
|
||||
<Button x:Name="btnModify" Content="修改" HorizontalAlignment="Left" Margin="66,168,0,0" VerticalAlignment="Top" Width="75" Click="btnModify_Click"/>
|
||||
<TextBox x:Name="textParamValue" HorizontalAlignment="Left" Height="23" Margin="21,119,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
|
||||
<TextBox x:Name="textParamName" HorizontalAlignment="Left" Height="23" Margin="21,53,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" RenderTransformOrigin="-0.246,1.213"/>
|
||||
<Label x:Name="label" Content="参数名称" HorizontalAlignment="Left" Margin="21,23,0,0" VerticalAlignment="Top"/>
|
||||
<Label x:Name="label_Copy" Content="参数值" HorizontalAlignment="Left" Margin="21,89,0,0" VerticalAlignment="Top"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
33
Plane.FormationCreator/ModifyParam.xaml.cs
Normal file
33
Plane.FormationCreator/ModifyParam.xaml.cs
Normal file
@ -0,0 +1,33 @@
|
||||
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.Windows.Shapes;
|
||||
|
||||
namespace Plane.FormationCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// ModifyParam.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ModifyParam : Window
|
||||
{
|
||||
public ModifyParam()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnModify_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.DialogResult = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -139,6 +139,9 @@
|
||||
<Compile Include="Formation\FlightTask_TakeOff.cs" />
|
||||
<Compile Include="Maps\OpenStreetMapTileLayer.cs" />
|
||||
<Compile Include="Maps\OpenStreetMapTileSource.cs" />
|
||||
<Compile Include="ModifyParam.xaml.cs">
|
||||
<DependentUpon>ModifyParam.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ServiceLocatorConfigurer.cs" />
|
||||
<Compile Include="Test.cs" />
|
||||
<Compile Include="CalculationLogLatDistance.cs" />
|
||||
@ -211,6 +214,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ModifyParam.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -151,6 +151,51 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _ParamModify;
|
||||
public ICommand ParamModify
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ParamModify ?? (_ParamModify = new RelayCommand(async () =>
|
||||
{
|
||||
|
||||
var ModifyParamWindow = new Plane.FormationCreator.ModifyParam();
|
||||
if (ModifyParamWindow.ShowDialog() == true)
|
||||
{
|
||||
|
||||
string paramstr = ModifyParamWindow.textParamName.Text;
|
||||
float paramvalue = Convert.ToSingle(ModifyParamWindow.textParamValue.Text);
|
||||
|
||||
await Task.WhenAll(_copterManager.AcceptingControlCopters.Select
|
||||
(copter => copter.SetParamAsync(paramstr, paramvalue)));
|
||||
|
||||
bool ifallok = true;
|
||||
await Task.WhenAll(
|
||||
|
||||
_copterManager.AcceptingControlCopters.Select(async copter =>
|
||||
{
|
||||
float getvaule = await copter.GetParamAsync(paramstr);
|
||||
if (getvaule != paramvalue)
|
||||
{
|
||||
ifallok = false;
|
||||
Alert.Show(copter.Id + "设置失败,读取的参数是" + getvaule, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
|
||||
));
|
||||
if (ifallok)
|
||||
Alert.Show("所有已选的飞机参数设置完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
else
|
||||
Alert.Show("有部分飞机参数设置失败,请检查并再次设置", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _RTKcomvalue = "COM3";
|
||||
public string RTKcomvalue
|
||||
{
|
||||
@ -255,9 +300,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
//分发到每个飞机
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
int iid = Convert.ToInt32(copter.Name);
|
||||
// int iid = Convert.ToInt32(copter.Name);
|
||||
//临时用来区分RTK发送数据
|
||||
if (iid<50)
|
||||
//if (iid<50)
|
||||
await copter.InjectGpsDataAsync(packet, (ushort)packet.Length);
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@
|
||||
<Button Content="测试"
|
||||
|
||||
Command="{Binding TestCommand}" />
|
||||
<Button Content="参数"
|
||||
Command="{Binding ParamModify}" />
|
||||
<TextBox Width="50"
|
||||
Visibility="Hidden"
|
||||
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
Loading…
Reference in New Issue
Block a user