测试双频

修改机头
This commit is contained in:
zxd 2019-11-04 10:28:17 +08:00
parent a8eb01bfb3
commit b554a1f4ae
4 changed files with 116 additions and 46 deletions

View File

@ -81,6 +81,7 @@
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
@ -105,6 +106,8 @@
</StackPanel> </StackPanel>
<Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导入分组信息" Margin="25,8,0,8" Grid.Row="2" <Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导入分组信息" Margin="25,8,0,8" Grid.Row="2"
Command="{Binding ImportGroupCommand}"/> Command="{Binding ImportGroupCommand}"/>
<Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导出任务时间" Margin="25,8,0,8" Grid.Row="3"
Command="{Binding ImportTaskTimeCommand}"/>
</Grid> </Grid>
</MenuItem> </MenuItem>
</Menu> </Menu>

View File

@ -39,6 +39,7 @@ namespace Plane.FormationCreator.ViewModels
{ {
_formationController = formationController; _formationController = formationController;
_copterManager = copterManager; _copterManager = copterManager;
LoadRTKcomvalue();
} }
private FormationController _formationController; private FormationController _formationController;
@ -54,7 +55,7 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(AltP), ref _AltP, value); } set { Set(nameof(AltP), ref _AltP, value); }
} }
private float _TaskOffAlt = 10; private float _TaskOffAlt = 2;
public float TaskOffAlt public float TaskOffAlt
{ {
get { return _TaskOffAlt; } get { return _TaskOffAlt; }
@ -751,12 +752,15 @@ namespace Plane.FormationCreator.ViewModels
return _TurnOffTestLightsCommand ?? (_TurnOffTestLightsCommand = new RelayCommand(async () => return _TurnOffTestLightsCommand ?? (_TurnOffTestLightsCommand = new RelayCommand(async () =>
{ {
int num = 0; int num = 0;
var o = new { NTF_G_RTLOFF = 1 }; //var o = new { NTF_G_RTLOFF = 1 };
num = await _commModuleManager.SetMultipleParamAsync( num = await _commModuleManager.SetMultipleParamAsync(
"NTF_G_RTLOFF", "1", "NTF_G_RTLOFF", "1",
"FS_GCS_ENABLE", "0", "FS_GCS_ENABLE", "0",
"NTF_G_RTKTEST", "0", "NTF_G_RTKTEST", "0",
"WAYPOINT_GLED", "0"); "WAYPOINT_GLED", "0",
"FS_BATT_VOLTAGE", "14.2",
"RTL_ALT","3000",
"RTL_ALT_MAX","5000");
Alert.Show($"广播完成! 当前序列号:{num}"); Alert.Show($"广播完成! 当前序列号:{num}");
})); }));
} }
@ -859,33 +863,37 @@ namespace Plane.FormationCreator.ViewModels
Alert.Show("RTK数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information); Alert.Show("RTK数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
RTKState = "RTK数据发送中"; RTKState = "RTK数据发送中";
RTKbtntxt = "停止RTK"; RTKbtntxt = "停止RTK";
await SaveRTKcomvalue();
await Task.Run(async () => await Task.Run(async () =>
{ {
//读取RTK数据循环 //读取RTK数据循环
rtcm3 rtcm3 = new rtcm3();
while (trkthreadrun) while (trkthreadrun)
{ {
//读入RTK数据 //读入RTK数据
var packet = await ReadRTKPacketAsync().ConfigureAwait(false); var packet = await ReadRTKPacketAsync().ConfigureAwait(false);
if (packet != null)
if (packet != null && packet.Length > 0)
{ {
Console.WriteLine("rev:" + (ushort)packet.Length); //Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---packet.length = {packet.Length}");
int read = packet.Length;
//分发到每个飞机 if (read > 0)
/*
foreach (var copter in _copterManager.Copters)
{ {
// int iid = Convert.ToInt32(copter.Name); for (int a = 0; a < read; a++)
//临时用来区分RTK发送数据 {
//if (iid<50) int seenmsg = -1;
// rtcm
await copter.InjectGpsDataAsync(packet, (ushort)packet.Length); if ((seenmsg = rtcm3.Read(packet[a])) > 0)
{
//Console.WriteLine($"{DateTime.Now.ToLongTimeString()}---rtcm3.length = {rtcm3.length}");
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
}
}
} }
*/
await _commModuleManager.InjectGpsDataAsync(packet, (ushort)packet.Length);
} }
await Task.Delay(10).ConfigureAwait(false);
await Task.Delay(200).ConfigureAwait(false);
} }
}).ConfigureAwait(false); }).ConfigureAwait(false);
@ -900,25 +908,6 @@ namespace Plane.FormationCreator.ViewModels
RTKState = "未发送RTK数据"; RTKState = "未发送RTK数据";
RTKbtntxt = "发送RTK"; RTKbtntxt = "发送RTK";
} }
/*
await Task.Run(() =>
{
if (!Rtkport.IsOpen)
{
return null;
}
// var packet = await ReadRTKPacketAsync().ConfigureAwait(false);
while (trkthreadrun)
{
await ReadRTKPacketAsync();
// if (await Rtkport.ReadAsync(buffer, 0, Math.Min(buffer.Length, 110)) > 0)
{
}
}
});*/
})); }));
} }
} }
@ -970,13 +959,17 @@ namespace Plane.FormationCreator.ViewModels
{ {
int read = commNTRIP.Read(buffer, 0, Math.Min(buffer.Length, commNTRIP.BytesToRead)); int read = commNTRIP.Read(buffer, 0, Math.Min(buffer.Length, commNTRIP.BytesToRead));
for (int a = 0; a < read; a++) if (read > 0)
{ {
int seenmsg = -1; for (int a = 0; a < read; a++)
// rtcm
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
{ {
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length); int seenmsg = -1;
// rtcm
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
{
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
}
} }
} }
} }
@ -991,6 +984,21 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
rtcm3 rtcm3 = new rtcm3();
private async Task AnalysisRendRrcmData(byte[] buffer, int length)
{
for (int a = 0; a < length; a++)
{
int seenmsg = -1;
// rtcm
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
{
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
}
}
await Task.Delay(1);
}
@ -1702,6 +1710,28 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
/// <summary>
/// 读取串口号
/// </summary>
private void LoadRTKcomvalue()
{
IniFiles inifilse = new IniFiles();
RTKcomvalue = inifilse.IniReadvalue("Default", "RTKcomvalue");
if (RTKcomvalue == "") RTKcomvalue = "COM6";
}
/// <summary>
/// 保存上次成功的串口号
/// </summary>
/// <returns></returns>
private async Task SaveRTKcomvalue()
{
IniFiles inifilse = new IniFiles();
inifilse.IniWritevalue("Default", "RTKcomvalue", RTKcomvalue);
await Task.Delay(1);
}
private async Task LEDFlashAsync(ICopter copter, bool isOn) private async Task LEDFlashAsync(ICopter copter, bool isOn)
{ {
// float gpsLed = await c.GetParamAsync("NOTI_GPSLED"); // float gpsLed = await c.GetParamAsync("NOTI_GPSLED");

View File

@ -358,6 +358,42 @@ namespace Plane.FormationCreator.ViewModels
} }
} }
private ICommand _ImportTaskTimeCommand;
public ICommand ImportTaskTimeCommand
{
get
{
return _ImportTaskTimeCommand ?? (_ImportTaskTimeCommand = new RelayCommand(() =>
{
var dialog = new SaveFileDialog
{
DefaultExt = "txt",
Filter = "文本文件 (*.txt)|*.txt"
};
if (dialog.ShowDialog() == true)
{
var importText = File.ReadAllText(dialog.FileName);
dynamic importInfo = JsonConvert.DeserializeObject(importText);
dynamic taskinfo = null;
if (importInfo is Newtonsoft.Json.Linq.JObject)
{
taskinfo = importInfo.tasks;
if (importInfo.groups != null)
{
_groupManager.ImportGroupsInfo(importInfo.groups);
}
}
else if (importInfo is Newtonsoft.Json.Linq.JArray)
{
taskinfo = importInfo;
}
}
}));
}
}
private void ImportCoptersLocate(dynamic coptersLocate) private void ImportCoptersLocate(dynamic coptersLocate)
{ {
int index = 0; int index = 0;

View File

@ -86,10 +86,11 @@
Command="{Binding ReportGPSTypeCommand}"/> Command="{Binding ReportGPSTypeCommand}"/>
<Button Content="统计模块" <Button Content="统计模块"
Command="{Binding DetectionCommModuleVersion}" /> Command="{Binding DetectionCommModuleVersion}" />
<Button Content="正式灯光" <Button Content="正式参数"
Command="{Binding TurnOffTestLightsCommand}" Command="{Binding TurnOffTestLightsCommand}"
Visibility="Collapsed"/> />
<TextBox Width="30" Text="{Binding TaskOffAlt}" <TextBlock Margin="5,0,3,0" Text="起飞高度" VerticalAlignment="Center"></TextBlock>
<TextBox Width="30" Height="26" Text="{Binding TaskOffAlt}"
/> />
<Label Visibility="Collapsed">Lat</Label> <Label Visibility="Collapsed">Lat</Label>
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/> <TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>