通信模块的断线重连 固定IP改换为199.51

添加飞机选中数量的统计
优化写航点跳过错误,优化写航点的统计
通信模块的version
检测航点最小距离时显示ID号
This commit is contained in:
zxd 2018-08-26 22:08:32 +08:00
parent 6ade842b38
commit 4d464bc976
10 changed files with 95 additions and 13 deletions

View File

@ -200,7 +200,7 @@ namespace Plane.FormationCreator
private async void CommtionReceivedCopterInfo(object sender, CommunicationReceiveCopterInfoEventArgs e) 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; //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); await AddCommCopter(id);
lock (locker) lock (locker)
@ -266,7 +266,7 @@ namespace Plane.FormationCreator
{ {
PLCopter plcopter = (PLCopter)copter; PLCopter plcopter = (PLCopter)copter;
if (!plcopter.CommModuleConnected) plcopter.CommModuleConnected = true; if (!plcopter.CommModuleConnected) plcopter.CommModuleConnected = true;
plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package); plcopter.InternalCopter.AnalyzeCommMouldePositionIntPacket(package, CommModuleVersion);
plcopter.CommModuleConnected = true; plcopter.CommModuleConnected = true;
} }
} }

View File

@ -95,6 +95,12 @@ namespace Plane.FormationCreator.Formation
/// 注意:为避免多线程操作出问题,每次使用此属性时都会新建一个 List /// 注意:为避免多线程操作出问题,每次使用此属性时都会新建一个 List
/// </summary> /// </summary>
public IEnumerable<ICopter> AcceptingControlCopters { get { return SelectedCopters.ToList(); } } 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; private Func<IList> _selectedCoptersGetter;
@ -111,6 +117,7 @@ namespace Plane.FormationCreator.Formation
public void RaiseSelectedCoptersChanged(IEnumerable<ICopter> addedCopters, IEnumerable<ICopter> removedCopters) public void RaiseSelectedCoptersChanged(IEnumerable<ICopter> addedCopters, IEnumerable<ICopter> removedCopters)
{ {
SelectedCoptersChanged?.Invoke(this, new SelectedCoptersChangedEventArgs { AddedCopters = addedCopters, RemovedCopters = removedCopters }); SelectedCoptersChanged?.Invoke(this, new SelectedCoptersChangedEventArgs { AddedCopters = addedCopters, RemovedCopters = removedCopters });
SeletedCopterCount = SelectedCopters.Count();
} }
/// <summary> /// <summary>

View File

@ -40,6 +40,7 @@ namespace Plane.FormationCreator
//{ //{
// //App.Current.Shutdown(); // //App.Current.Shutdown();
//} //}
} }
private CommModuleManager _commModuleManager = CommModuleManager.Instance; private CommModuleManager _commModuleManager = CommModuleManager.Instance;
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>(); private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();

View File

@ -335,6 +335,12 @@
<ItemGroup> <ItemGroup>
<Resource Include="bg.jpg" /> <Resource Include="bg.jpg" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="tiane.bmp" />
</ItemGroup>
<ItemGroup>
<Resource Include="tiane.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -144,14 +144,16 @@ namespace Plane.FormationCreator.ViewModels
{ {
return _DetectionMissionData ?? (_DetectionMissionData = new RelayCommand(async () => 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) if (missionState.Count() == 0)
Message.Show("航点全部写入成功"); Message.Show("航点全部写入成功");
else else
{ {
Message.Show("----统计失败航点写入失败----");
foreach (KeyValuePair<int, CommWriteMissinState> item in missionState) 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); Message.Show(msg);
await Task.Delay(10); 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; private ICommand _AllLandCommand;
public ICommand AllLandCommand public ICommand AllLandCommand
{ {

View File

@ -1256,6 +1256,8 @@ public ICommand VerticlAlignmentCommand
var flightTask = _flightTaskManager.SelectedTask; var flightTask = _flightTaskManager.SelectedTask;
List<ICopter> selectedCopter = new List<ICopter>(); List<ICopter> selectedCopter = new List<ICopter>();
selectedCopter.AddRange(_copterManager.AcceptingControlCopters); selectedCopter.AddRange(_copterManager.AcceptingControlCopters);
string minCopterId1 = "0";
string minCopterId2 = "0";
for (int i = 0; i < selectedCopter.Count; i++) for (int i = 0; i < selectedCopter.Count; i++)
{ {
var copter1 = selectedCopter[i]; var copter1 = selectedCopter[i];
@ -1269,13 +1271,19 @@ public ICommand VerticlAlignmentCommand
double distance = GeographyUtils.CalcDistance( double distance = GeographyUtils.CalcDistance(
copterInfo1.TargetLat, copterInfo1.TargetLng, copterInfo1.TargetAlt, copterInfo1.TargetLat, copterInfo1.TargetLng, copterInfo1.TargetAlt,
copterInfo2.TargetLat, copterInfo2.TargetLng, copterInfo2.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; //Distancevalue = minDistance;
Message.Show($"最小距离 = {minDistance}"); Message.Show($"最小距离 = {minDistance} 飞机:{minCopterId1}和{minCopterId2}");
})); }));
} }

View File

@ -70,12 +70,17 @@
CommandParameter="1"/> CommandParameter="1"/>
<Button Content="电机" <Button Content="电机"
Command="{Binding MotorTestCommand}" /> Command="{Binding MotorTestCommand}" />
<Button Content="航点"
Command="{Binding WriteMissionSingleCommand}" />
<TextBox Width="50" <TextBox Width="50"
Visibility="Collapsed" Visibility="Collapsed"
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
</WrapPanel> </WrapPanel>
<WrapPanel>
<Button Content="选写航点"
Command="{Binding WriteMissionSingleCommand}" />
<Button Content="统计模块"
Command="{Binding DetectionCommModuleVersion}" />
</WrapPanel>
<Separator/> <Separator/>
<WrapPanel> <WrapPanel>
<Button Content="全部降落" <Button Content="全部降落"

View File

@ -103,6 +103,7 @@
<TextBlock Text="{Binding Retain[0]}" /> <TextBlock Text="{Binding Retain[0]}" />
</StackPanel> </StackPanel>
<!-- <!--
<StackPanel> <StackPanel>
<TextBlock Text="固件版本:" /> <TextBlock Text="固件版本:" />
@ -172,7 +173,12 @@
<TextBlock Text="定位精度:" /> <TextBlock Text="定位精度:" />
<TextBlock Text="{Binding GpsHdop, StringFormat=0.##}" /> <TextBlock Text="{Binding GpsHdop, StringFormat=0.##}" />
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel>
<TextBlock Text="通信模块:" />
<TextBlock Text="{Binding CommModuleVersion}" />
</StackPanel>
</StackPanel>
</Grid> </Grid>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -60,6 +60,8 @@
<TextBox Width="30" Margin="5,0,0,0" Text="{Binding ContinuousNum}"/> <TextBox Width="30" Margin="5,0,0,0" Text="{Binding ContinuousNum}"/>
<TextBlock Text="间隔数量" Margin="5,5,0,0"/> <TextBlock Text="间隔数量" Margin="5,5,0,0"/>
<TextBox Width="30" Margin="5,0,0,0" Text="{Binding IntervalNum}"/> <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> </StackPanel>

View File

@ -11,9 +11,9 @@
d:DesignWidth="300"> d:DesignWidth="300">
<Grid> <Grid>
<bingMaps:Map Name="map" <bingMaps:Map Name="map"
CredentialsProvider="8IGVSMWVqW8lDaMuGr2c~XaqB2qlBDLvSvXFzrQ8c-A~AiPIQttopdwAl4kXs8xm6_r59NEGdyqXejcaMDum6qB1BUJ6e25uViKL7fEdEROP" CredentialsProvider="8IGVSMWVqW8lDaMuGr2c~XaqB2qlBDLvSvXFzrQ8c-A~AiPIQttopdwAl4kXs8xm6_r59NEGdyqXejcaMDum6qB1BUJ6e25uViKL7fEdEROP"
ZoomLevel="20"> ZoomLevel="20" Opacity="1">
<bingMaps:Map.Mode> <bingMaps:Map.Mode>
<bingMaps:AerialMode /> <bingMaps:AerialMode />
</bingMaps:Map.Mode> </bingMaps:Map.Mode>