继续修改wifi,可以批量起飞等功能
This commit is contained in:
parent
da086831bf
commit
3aa4879511
@ -173,30 +173,40 @@ namespace Plane.FormationCreator
|
|||||||
{
|
{
|
||||||
_logger.Log(e.Message );
|
_logger.Log(e.Message );
|
||||||
}
|
}
|
||||||
|
//wifi模式添加飞机
|
||||||
private async Task AddOrUpdateCopter(string ip, IConnection Connection)
|
private async Task AddOrUpdateCopter(string ip, IConnection Connection)
|
||||||
{
|
{
|
||||||
var copters = _copterManager.Copters;
|
var copters = _copterManager.Copters;
|
||||||
var copterStatus = _copterManager.CopterStatus;
|
var copterStatus = _copterManager.CopterStatus;
|
||||||
|
|
||||||
var copter = copters.FirstOrDefault(c => c.Id == ip);
|
string[] iparr = ip.Split('.');
|
||||||
|
string vIPID = String.Format("{0:D3}", int.Parse(iparr[2])) + String.Format("{0:D3}", int.Parse(iparr[3]));
|
||||||
|
|
||||||
|
var copter = copters.FirstOrDefault(c => c.Id == vIPID);
|
||||||
if (copter == null)
|
if (copter == null)
|
||||||
{
|
{
|
||||||
await Dispatcher.BeginInvoke(new Action(() =>
|
if (!_copterManager.EnAddCopter_Real())
|
||||||
{
|
{
|
||||||
if (_copterManager.EnAddCopter_Real())
|
UdpServerConnectionManager.Instance.DeleteConnections(ip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
||||||
{
|
{
|
||||||
Id = ip,
|
Id = vIPID,
|
||||||
Name = ip.Substring(ip.LastIndexOf('.') + 1)
|
Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1)
|
||||||
|
|
||||||
};
|
};
|
||||||
int _index;
|
int _index;
|
||||||
_index = copters.AddCopter(copter);
|
_index = copters.AddCopter(copter);
|
||||||
copterStatus.Insert(_index, false);
|
copterStatus.Insert(_index, false);
|
||||||
copter.TextReceived += Copter_TextReceived;
|
copter.TextReceived += Copter_TextReceived;
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -591,6 +591,20 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task ClearCopters()
|
||||||
|
{
|
||||||
|
foreach (var copter in Copters)
|
||||||
|
{
|
||||||
|
await copter.DisconnectAsync();
|
||||||
|
}
|
||||||
|
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
Copters.Clear();
|
||||||
|
CopterStatus.Clear();
|
||||||
|
//wifi
|
||||||
|
if (VersionControl.ConType==1)
|
||||||
|
UdpServerConnectionManager.Instance.ClearConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool EnAddCopter_Real()
|
public bool EnAddCopter_Real()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
|
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
|
||||||
public ObservableCollection<RtcmInfo> rtcmInfoList { get; } = new ObservableCollection<RtcmInfo>();
|
public ObservableCollection<RtcmInfo> rtcmInfoList { get; } = new ObservableCollection<RtcmInfo>();
|
||||||
private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
|
private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance<ControlPanelViewModel>();
|
||||||
|
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||||
private bool _rtcmthreadrun = false;
|
private bool _rtcmthreadrun = false;
|
||||||
public bool Rtcmthreadrun
|
public bool Rtcmthreadrun
|
||||||
{
|
{
|
||||||
@ -310,10 +310,11 @@ namespace Plane.FormationCreator.Formation
|
|||||||
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
|
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
|
||||||
{
|
{
|
||||||
bpsusefull += rtcm.length;
|
bpsusefull += rtcm.length;
|
||||||
//用于双频RTK发送
|
//用于双频RTK发送
|
||||||
// await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
|
// await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
|
||||||
//用于单频rtk发送
|
//用于单频rtk发送
|
||||||
await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length);
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
|
await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length);
|
||||||
|
|
||||||
string msgname = "Rtcm" + seenmsg;
|
string msgname = "Rtcm" + seenmsg;
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@
|
|||||||
<TextBlock Margin="10,4"
|
<TextBlock Margin="10,4"
|
||||||
Width="300" Text="{Binding SysStatusText}" />
|
Width="300" Text="{Binding SysStatusText}" />
|
||||||
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
||||||
<TextBlock Margin="10,4" Width="200"
|
<TextBlock Margin="10,4" Width="400"
|
||||||
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -314,6 +314,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
{
|
{
|
||||||
return _AllLandCommand ?? (_AllLandCommand = new RelayCommand(async () =>
|
return _AllLandCommand ?? (_AllLandCommand = new RelayCommand(async () =>
|
||||||
{
|
{
|
||||||
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
await _commModuleManager.LandAsync();
|
await _commModuleManager.LandAsync();
|
||||||
/*
|
/*
|
||||||
await Task.WhenAll(_copterManager.Copters.Select(async c =>
|
await Task.WhenAll(_copterManager.Copters.Select(async c =>
|
||||||
@ -409,6 +410,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
|
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
await _commModuleManager.UnlockAsync();
|
await _commModuleManager.UnlockAsync();
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -536,6 +538,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
if (Alert.Show("您确定要上锁吗?飞行器将无视转速,立即强制停止运转!!!", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
if (Alert.Show("您确定要上锁吗?飞行器将无视转速,立即强制停止运转!!!", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||||
== MessageBoxResult.OK)
|
== MessageBoxResult.OK)
|
||||||
{
|
{
|
||||||
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
await _commModuleManager.LockAsync(_copterManager.AcceptingControlCopters);
|
await _commModuleManager.LockAsync(_copterManager.AcceptingControlCopters);
|
||||||
//await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.LockAsync()));
|
//await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.LockAsync()));
|
||||||
}
|
}
|
||||||
@ -702,7 +705,10 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
if (_copterManager.AcceptingControlCopters.Count() < _copterManager.Copters.Count)
|
if (_copterManager.AcceptingControlCopters.Count() < _copterManager.Copters.Count)
|
||||||
num = await _commModuleManager.SetParamAsync(paramstr, paramvalue, _copterManager.AcceptingControlCopters);
|
num = await _commModuleManager.SetParamAsync(paramstr, paramvalue, _copterManager.AcceptingControlCopters);
|
||||||
else if (_copterManager.AcceptingControlCopters.Count() == _copterManager.Copters.Count)
|
else if (_copterManager.AcceptingControlCopters.Count() == _copterManager.Copters.Count)
|
||||||
|
{
|
||||||
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
num = await _commModuleManager.SetParamAsync(paramstr, paramvalue);
|
num = await _commModuleManager.SetParamAsync(paramstr, paramvalue);
|
||||||
|
}
|
||||||
Alert.Show($"广播完成! 当前序列号:{num}");
|
Alert.Show($"广播完成! 当前序列号:{num}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -896,6 +902,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//稳定方案的rtk发送,用于单频
|
//稳定方案的rtk发送,用于单频
|
||||||
|
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
|
||||||
await _commModuleManager.InjectGpsDataAsync(packet, (ushort)packet.Length);
|
await _commModuleManager.InjectGpsDataAsync(packet, (ushort)packet.Length);
|
||||||
}
|
}
|
||||||
await Task.Delay(10).ConfigureAwait(false);
|
await Task.Delay(10).ConfigureAwait(false);
|
||||||
|
@ -441,6 +441,8 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
return _ClearCoptersCommand ?? (_ClearCoptersCommand = new RelayCommand(async () =>
|
return _ClearCoptersCommand ?? (_ClearCoptersCommand = new RelayCommand(async () =>
|
||||||
{
|
{
|
||||||
_flightTaskManager.Pause();
|
_flightTaskManager.Pause();
|
||||||
|
await _copterManager.ClearCopters();
|
||||||
|
/*
|
||||||
foreach (var copter in _copterManager.Copters)
|
foreach (var copter in _copterManager.Copters)
|
||||||
{
|
{
|
||||||
await copter.DisconnectAsync();
|
await copter.DisconnectAsync();
|
||||||
@ -448,10 +450,13 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
_copterManager.Copters.Clear();
|
_copterManager.Copters.Clear();
|
||||||
_copterManager.CopterStatus.Clear();
|
_copterManager.CopterStatus.Clear();
|
||||||
|
*/
|
||||||
|
|
||||||
_mapManager.ClearCopters();
|
_mapManager.ClearCopters();
|
||||||
_view3DManager.ClearCopters();
|
_view3DManager.ClearCopters();
|
||||||
_flightTaskManager.ClearTasks();
|
_flightTaskManager.ClearTasks();
|
||||||
//UdpServerConnectionManager.Instance.ClearConnections();
|
// UdpServerConnectionManager.Instance.ClearConnections();
|
||||||
|
|
||||||
_virtualCopterId = 1;
|
_virtualCopterId = 1;
|
||||||
_lastVirtualCopterLocation = null;
|
_lastVirtualCopterLocation = null;
|
||||||
_flightTaskManager.OriginLat = 0;
|
_flightTaskManager.OriginLat = 0;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<Button Content="开始校准" Width="100" Margin="10, 0"
|
<Button Content="开始校准" Width="100" Margin="10, 0"
|
||||||
Command="{Binding CalibrationCompassCommand}"/>
|
Command="{Binding CalibrationCompassCommand}"/>
|
||||||
<Button Content="放弃校准" Width="100" Margin="10, 0"
|
<Button Content="放弃校准" Width="100" Margin="10, 0"
|
||||||
Command="{Binding CancelCalibrationCompassCommand}"/>
|
Command="{Binding CancelCalibrationCompassCommand}" Visibility="Collapsed"/>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<ProgressBar Margin="0,20" Height="18" Width="220" Value="{Binding CompassPercent, UpdateSourceTrigger=PropertyChanged}"/>
|
<ProgressBar Margin="0,20" Height="18" Width="220" Value="{Binding CompassPercent, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user