通信模块协议的添加和修改
小批量、读写通信地面站配置、修改连接id总数
This commit is contained in:
parent
0f19e2addf
commit
725c4b6d71
@ -169,7 +169,7 @@ namespace Plane.FormationCreator.Formation
|
||||
if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0)
|
||||
flyToTime += prevTask.RuningTaskRemaining;
|
||||
}
|
||||
|
||||
int LEDIndex = 0;
|
||||
//while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 :所有Copter到达目标点开始飞下个航点
|
||||
while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点
|
||||
{
|
||||
@ -212,20 +212,21 @@ namespace Plane.FormationCreator.Formation
|
||||
double time = 0;
|
||||
for (int i = 0; i < LedControl.Count; i++)
|
||||
{
|
||||
|
||||
var led = LedControl[i];
|
||||
time += led.Delay * 1000;
|
||||
if (ts.TotalMilliseconds >= time)
|
||||
{
|
||||
LEDRGB = info.LEDInfos[i].LEDRGB;
|
||||
LEDIndex = i;
|
||||
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
Message.Show(LEDIndex.ToString());
|
||||
info.Copter.LEDColor = LEDRGB;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标
|
||||
{
|
||||
sendFlyToTimes++;
|
||||
|
@ -86,7 +86,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _SendCommand ?? (_SendCommand = new RelayCommand(async () =>
|
||||
{
|
||||
await SendCommandAsync(CopterNum);
|
||||
await commModule.SetCommCount(CopterCount, (short)(CopterStartNum - 1));
|
||||
}
|
||||
));
|
||||
}
|
||||
@ -132,6 +132,27 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(CopterColor), ref _CopterColor, value); }
|
||||
}
|
||||
|
||||
private byte _TransmittedPower = 5;
|
||||
public byte TransmittedPower
|
||||
{
|
||||
get { return _TransmittedPower; }
|
||||
set { Set(nameof(TransmittedPower), ref _TransmittedPower, value); }
|
||||
}
|
||||
|
||||
private short _CopterCount;
|
||||
public short CopterCount
|
||||
{
|
||||
get { return _CopterCount; }
|
||||
set { Set(nameof(CopterCount), ref _CopterCount, value); }
|
||||
}
|
||||
|
||||
private short _CopterStartNum;
|
||||
public short CopterStartNum
|
||||
{
|
||||
get { return _CopterStartNum; }
|
||||
set { Set(nameof(CopterStartNum), ref _CopterStartNum, value); }
|
||||
}
|
||||
|
||||
private ICommand _WriteIdCommand;
|
||||
public ICommand WriteIdCommand
|
||||
{
|
||||
@ -215,6 +236,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部1S一次闪灯 主要用于测试通信
|
||||
/// </summary>
|
||||
private ICommand _CommDataAsync;
|
||||
public ICommand CommDataAsync
|
||||
{
|
||||
@ -228,6 +252,54 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置回传功率
|
||||
/// </summary>
|
||||
private ICommand _CommSetPowerAsync;
|
||||
public ICommand CommSetPowerAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommSetPowerAsync ?? (_CommSetPowerAsync = new RelayCommand(async () =>
|
||||
{
|
||||
if (TransmittedPower >= 1 && TransmittedPower <= 16)
|
||||
await commModule.SetCopterCommBackPower((short)CopterNum, TransmittedPower);
|
||||
else
|
||||
Alert.Show("功率范围只能设置为1-16");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置
|
||||
/// </summary>
|
||||
private ICommand _CommGetCurrSysParmAsync;
|
||||
public ICommand CommGetCurrSysParmAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommGetCurrSysParmAsync ?? (_CommGetCurrSysParmAsync = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.GetCurr_Sys_Parm();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改写配置
|
||||
/// </summary>
|
||||
private ICommand _CommSetCurrSysParmAsync;
|
||||
public ICommand CommSetCurrSysParmAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommSetCurrSysParmAsync ?? (_CommSetCurrSysParmAsync = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.SetCurr_Sys_Parm();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private List<IMission> CreateLEDMissions(IEnumerable<LEDInfo> LEDInfos)
|
||||
{
|
||||
List<IMission> missions = new List<IMission>();
|
||||
|
@ -68,6 +68,8 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -89,7 +91,8 @@
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel1">
|
||||
Name="panel1"
|
||||
Visibility="Collapsed">
|
||||
|
||||
<ec:ProgressButton HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
@ -133,7 +136,7 @@
|
||||
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,6 +145,7 @@
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="3"
|
||||
Grid.ColumnSpan="3">
|
||||
<Label Content="ID:"/>
|
||||
<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}"/>
|
||||
@ -152,11 +156,33 @@
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="3">
|
||||
<Button Content="设置回传功率" Command="{Binding CommSetPowerAsync}"/>
|
||||
<TextBox Margin="5,0" Width="80" Text="{Binding TransmittedPower}"/>
|
||||
<Button Margin="5,0" Content="读取配置" Command="{Binding CommGetCurrSysParmAsync}"/>
|
||||
<Button Margin="5,0" Content="写入配置" Command="{Binding CommSetCurrSysParmAsync}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="5"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel3">
|
||||
<Button Content="空中升级" Margin="5" Command="{Binding UpdateAllCopterCommand}"></Button>
|
||||
<Button Content="搜索飞机" Margin="5" Command="{Binding QueryAllCopterCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="6"
|
||||
Grid.ColumnSpan="3"
|
||||
>
|
||||
<Button Content="设置总数" Margin="5" Command="{Binding Path=SendCommand}" />
|
||||
<Label Content="总数:"/>
|
||||
<TextBox Width="50" Text="{Binding CopterCount}"/>
|
||||
<Label Content="起始号:"/>
|
||||
<TextBox Width="50" Text="{Binding CopterStartNum}"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</c:MetroWindow>
|
||||
|
Loading…
Reference in New Issue
Block a user