通信模块的断线重连 固定IP改换为199.51
添加飞机选中数量的统计 优化写航点跳过错误,优化写航点的统计 通信模块的version 检测航点最小距离时显示ID号
This commit is contained in:
parent
6ade842b38
commit
4d464bc976
@ -200,7 +200,7 @@ namespace Plane.FormationCreator
|
||||
|
||||
private async void CommtionReceivedCopterInfo(object sender, CommunicationReceiveCopterInfoEventArgs e)
|
||||
{
|
||||
await UpdateCommCopterInfo(e.Id, e.Package);
|
||||
await UpdateCommCopterInfo(e.Id, e.Package, e.CommModuleVersion);
|
||||
//await TaskUtils.CompletedTask;
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ namespace Plane.FormationCreator
|
||||
}));
|
||||
}
|
||||
|
||||
private async Task UpdateCommCopterInfo(int id, byte[] package)
|
||||
private async Task UpdateCommCopterInfo(int id, byte[] package, byte CommModuleVersion)
|
||||
{
|
||||
await AddCommCopter(id);
|
||||
lock (locker)
|
||||
@ -266,7 +266,7 @@ namespace Plane.FormationCreator
|
||||
{
|
||||
PLCopter plcopter = (PLCopter)copter;
|
||||
if (!plcopter.CommModuleConnected) plcopter.CommModuleConnected = true;
|
||||
plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package);
|
||||
plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package, CommModuleVersion);
|
||||
plcopter.CommModuleConnected = true;
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,12 @@ namespace Plane.FormationCreator.Formation
|
||||
/// 注意:为避免多线程操作出问题,每次使用此属性时都会新建一个 List!
|
||||
/// </summary>
|
||||
public IEnumerable<ICopter> AcceptingControlCopters { get { return SelectedCopters.ToList(); } }
|
||||
private int _SeletedCopterCount;
|
||||
public int SeletedCopterCount
|
||||
{
|
||||
get { return _SeletedCopterCount; }
|
||||
set { Set(nameof(SeletedCopterCount), ref _SeletedCopterCount, value); }
|
||||
}
|
||||
|
||||
private Func<IList> _selectedCoptersGetter;
|
||||
|
||||
@ -111,6 +117,7 @@ namespace Plane.FormationCreator.Formation
|
||||
public void RaiseSelectedCoptersChanged(IEnumerable<ICopter> addedCopters, IEnumerable<ICopter> removedCopters)
|
||||
{
|
||||
SelectedCoptersChanged?.Invoke(this, new SelectedCoptersChangedEventArgs { AddedCopters = addedCopters, RemovedCopters = removedCopters });
|
||||
SeletedCopterCount = SelectedCopters.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -40,6 +40,7 @@ namespace Plane.FormationCreator
|
||||
//{
|
||||
// //App.Current.Shutdown();
|
||||
//}
|
||||
|
||||
}
|
||||
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
|
||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||
|
@ -335,6 +335,12 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="bg.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="tiane.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="tiane.jpg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -144,14 +144,16 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _DetectionMissionData ?? (_DetectionMissionData = new RelayCommand(async () =>
|
||||
{
|
||||
var missionState = _commModuleManager.MissionWriteState.Where(i => !i.Value.SendAchieved || !i.Value.WriteSucceed);
|
||||
var missionState = _commModuleManager.MissionWriteState.Where(i => i.Value.IsFailed);
|
||||
if (missionState.Count() == 0)
|
||||
Message.Show("航点全部写入成功");
|
||||
else
|
||||
{
|
||||
Message.Show("----统计失败航点写入失败----");
|
||||
foreach (KeyValuePair<int, CommWriteMissinState> item in missionState)
|
||||
{
|
||||
string msg = $"{item.Key}: 传输:{item.Value.SendAchieved}, 写入:{item.Value.WriteSucceed} ";
|
||||
CommWriteMissinState state = item.Value;
|
||||
string msg = $"{item.Key}:飞机状态:{state.StateReturn}, 错误码:{state.ErrorCode}, 传输:{state.SendAchieved}, 写入:{state.WriteSucceed} ";
|
||||
Message.Show(msg);
|
||||
await Task.Delay(10);
|
||||
}
|
||||
@ -208,6 +210,51 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _DetectionCommModuleVersion;
|
||||
public ICommand DetectionCommModuleVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _DetectionCommModuleVersion ?? (_DetectionCommModuleVersion = new RelayCommand(async () =>
|
||||
{
|
||||
Dictionary<int, List<string>> dic_version = new Dictionary<int, List<string>>();
|
||||
await Task.WhenAll(_copterManager.Copters.Select(async c =>
|
||||
{
|
||||
string name = c.Name;
|
||||
int version = c.CommModuleVersion;
|
||||
|
||||
lock (locker)
|
||||
{
|
||||
List<string> copterList;
|
||||
if (!dic_version.ContainsKey(version))
|
||||
{
|
||||
copterList = new List<string>();
|
||||
dic_version.Add(version, copterList);
|
||||
}
|
||||
else
|
||||
copterList = dic_version[version];
|
||||
|
||||
copterList.Add(name);
|
||||
}
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
})).ConfigureAwait(false);
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
foreach (KeyValuePair<int, List<string>> kv in dic_version)
|
||||
{
|
||||
string copters = string.Join(",", kv.Value.ToArray());
|
||||
Message.Show(string.Format("通信模块版本{0}:{1}", kv.Key, copters));
|
||||
await Task.Delay(5).ConfigureAwait(false);
|
||||
}
|
||||
Message.Show("----统计完成----");
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _AllLandCommand;
|
||||
public ICommand AllLandCommand
|
||||
{
|
||||
|
@ -1256,6 +1256,8 @@ public ICommand VerticlAlignmentCommand
|
||||
var flightTask = _flightTaskManager.SelectedTask;
|
||||
List<ICopter> selectedCopter = new List<ICopter>();
|
||||
selectedCopter.AddRange(_copterManager.AcceptingControlCopters);
|
||||
string minCopterId1 = "0";
|
||||
string minCopterId2 = "0";
|
||||
for (int i = 0; i < selectedCopter.Count; i++)
|
||||
{
|
||||
var copter1 = selectedCopter[i];
|
||||
@ -1269,13 +1271,19 @@ public ICommand VerticlAlignmentCommand
|
||||
double distance = GeographyUtils.CalcDistance(
|
||||
copterInfo1.TargetLat, copterInfo1.TargetLng, copterInfo1.TargetAlt,
|
||||
copterInfo2.TargetLat, copterInfo2.TargetLng, copterInfo2.TargetAlt);
|
||||
|
||||
minDistance = Math.Min(minDistance, distance);
|
||||
//minDistance = Math.Min(minDistance, distance);
|
||||
if (distance < minDistance)
|
||||
{
|
||||
minDistance = distance;
|
||||
minCopterId1 = copter1.Id;
|
||||
minCopterId2 = copter2.Id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Distancevalue = minDistance;
|
||||
Message.Show($"最小距离 = {minDistance}");
|
||||
Message.Show($"最小距离 = {minDistance} 飞机:{minCopterId1}和{minCopterId2}");
|
||||
|
||||
}));
|
||||
}
|
||||
|
@ -70,12 +70,17 @@
|
||||
CommandParameter="1"/>
|
||||
<Button Content="电机"
|
||||
Command="{Binding MotorTestCommand}" />
|
||||
<Button Content="航点"
|
||||
Command="{Binding WriteMissionSingleCommand}" />
|
||||
|
||||
<TextBox Width="50"
|
||||
Visibility="Collapsed"
|
||||
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</WrapPanel>
|
||||
<WrapPanel>
|
||||
<Button Content="选写航点"
|
||||
Command="{Binding WriteMissionSingleCommand}" />
|
||||
<Button Content="统计模块"
|
||||
Command="{Binding DetectionCommModuleVersion}" />
|
||||
</WrapPanel>
|
||||
<Separator/>
|
||||
<WrapPanel>
|
||||
<Button Content="全部降落"
|
||||
|
@ -103,6 +103,7 @@
|
||||
<TextBlock Text="{Binding Retain[0]}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!--
|
||||
<StackPanel>
|
||||
<TextBlock Text="固件版本:" />
|
||||
@ -172,7 +173,12 @@
|
||||
<TextBlock Text="定位精度:" />
|
||||
<TextBlock Text="{Binding GpsHdop, StringFormat=0.##}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock Text="通信模块:" />
|
||||
<TextBlock Text="{Binding CommModuleVersion}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
@ -60,6 +60,8 @@
|
||||
<TextBox Width="30" Margin="5,0,0,0" Text="{Binding ContinuousNum}"/>
|
||||
<TextBlock Text="间隔数量" Margin="5,5,0,0"/>
|
||||
<TextBox Width="30" Margin="5,0,0,0" Text="{Binding IntervalNum}"/>
|
||||
<TextBlock Text="选中个数" Margin="5,5,0,0"/>
|
||||
<TextBlock Width="30" Margin="5,5,0,0" Text="{Binding CopterManager.SeletedCopterCount, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
|
||||
<bingMaps:Map Name="map"
|
||||
<bingMaps:Map Name="map"
|
||||
CredentialsProvider="8IGVSMWVqW8lDaMuGr2c~XaqB2qlBDLvSvXFzrQ8c-A~AiPIQttopdwAl4kXs8xm6_r59NEGdyqXejcaMDum6qB1BUJ6e25uViKL7fEdEROP"
|
||||
ZoomLevel="20">
|
||||
ZoomLevel="20" Opacity="1">
|
||||
<bingMaps:Map.Mode>
|
||||
<bingMaps:AerialMode />
|
||||
</bingMaps:Map.Mode>
|
||||
|
Loading…
Reference in New Issue
Block a user