增加通讯统计

修改一架飞机不能修改起飞任务参数的bug
增加抛物功能
增加机头统计排序功能
This commit is contained in:
xu 2022-09-15 00:59:20 +08:00
parent 09da3f24ba
commit ca07ddd155
11 changed files with 187 additions and 28 deletions

View File

@ -181,8 +181,11 @@ namespace Plane.FormationCreator.Formation
{
const string LoginPage = "checkforapp.php";
const string supername = "admin";
const string superpass = "admin0622";
// const string supername = "admin";
// const string superpass = "admin0622";
const string supername = "user";
const string superpass = "123456";
const string TEMP_MISSIONFILE = @".\gcs.dat";
//飞控版本控制
public int FC_VER_NO = 1;//"4.1.2" 这个版本以前版本灯光比较少no=1 //"4.5"以后no=2;

View File

@ -222,6 +222,23 @@ namespace Plane.FormationCreator.Formation
{
str = ts.Seconds + "秒";
}
if (value.ModifyingSingleCopterInfo == null)
{
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
foreach (var info in value.SingleCopterInfos)
{
if (info.Copter == selectedCopter)
{
value.ModifyingSingleCopterInfo = info;
break;
}
}
}
Message.ShowStatus($"选中 [{value.TaskIndex+1} {value.TaskCnName }] 从{str}开始执行,需{ GetTaskTime(value.TaskIndex)}秒,共{Tasks.Count}个任务");
}
else Message.ShowStatus($"无任务选中");
@ -1500,7 +1517,11 @@ namespace Plane.FormationCreator.Formation
}
public void SetAllTaskFlytime()
{
for (int taskIndex = 1; taskIndex < Tasks.Count; taskIndex++)
//起飞航点0需要单独计算
//第一个航点1是调整航点根据地面摆放情况调整默认2+1秒
//从2开始自动计算
Tasks[1].FlytoTime = 2;
for (int taskIndex = 2; taskIndex < Tasks.Count; taskIndex++)
SetTaskFlytime(taskIndex);
}
@ -2253,6 +2274,20 @@ namespace Plane.FormationCreator.Formation
public async Task RunTaskAsync()
{
if (Tasks.Count == 0) return;
//检查有没有真实飞机--真实飞机不能模拟,因为位置来自物理飞机--只能全部是模拟飞机才行
foreach (var copter in _copterManager.Copters)
{
if (!(copter is IFakeCopter))
{
Alert.Show($"模拟任务需要全部是模拟飞机,编号:{copter.Id } 不是模拟飞机,请检查");
return ;
}
}
if (CurrentRunningTaskIndex == 0)
{
taskStartTime = DateTime.Now;

View File

@ -319,11 +319,36 @@ namespace Plane.FormationCreator.Formation
}
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
private async Task RtcmLoop()
{
int reconnecttimeout = 10;
DateTime lastrecv = DateTime.MinValue;
//系统毫秒数
long ls_send_ms = CurrentTimeMillis();
long ls_send_gps = CurrentTimeMillis();
long ls_send_glonass = CurrentTimeMillis();
long ls_send_baidu = CurrentTimeMillis();
const int MSG_GPS = 1074;
const int MSG_GLONASS = 1084;
const int MSG_Beidou = 1124;
int MSG_BasePos = 1005;
int MSG_REV = 1033;
int Send_type = 0;
bool Ensend = false;
int last_mag = 0;
//新版本打包发送模式
//await _commModuleManager.StartRtcmLoop();
@ -356,8 +381,8 @@ namespace Plane.FormationCreator.Formation
}
//rtcm size=180
byte[] buffer = new byte[180];
byte[] buffer = new byte[180];// new byte[180];
//一次读取180个字节
int read = comPort.Read(buffer, 0, Math.Min(buffer.Length, comPort.BytesToRead));
if (read > 0)
lastrecv = DateTime.Now;
@ -366,15 +391,57 @@ namespace Plane.FormationCreator.Formation
for (int a = 0; a < read; a++)
{
int seenmsg = -1;
// rtcm
// rtcm类解析RTCM数据 如果 rtcm.Read>0解析成功返回消息号码-1解析失败
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
{
bpsusefull += rtcm.length;
_commModuleManager.SetAllCoptersForWifi(_copterManager.Copters);
//用于双频RTK发送
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
/* 使
switch (seenmsg)
{
case MSG_GPS:
if ((CurrentTimeMillis() - ls_send_gps) > 1000)
{
ls_send_gps = CurrentTimeMillis();
Ensend = true;
}
break;
case MSG_GLONASS:
if ((CurrentTimeMillis() - ls_send_glonass) > 1000)
{
ls_send_glonass = CurrentTimeMillis();
Ensend = true;
}
break;
case MSG_Beidou:
if ((CurrentTimeMillis() - ls_send_baidu) > 1000)
{
ls_send_baidu = CurrentTimeMillis();
Ensend = true;
}
break;
}
if ((seenmsg == MSG_REV) || (seenmsg == MSG_BasePos)) Ensend = true;
//Plane.Windows.Messages.Message.Show("---["+ seenmsg + "]RTCM:" + rtcm.length);
// await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
/* if (rtcm.length <= 180)
Ensend = true;
else Ensend = false;
*/
if (Ensend)
{
// await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
Ensend = false;
}
*/
//老的单频rtk发送
//await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length);
await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length);
string msgname = "Rtcm" + seenmsg;

View File

@ -166,14 +166,20 @@ namespace Plane.FormationCreator.ViewModels
float StepDis_Row = _flightTaskManager.ColumnDistance; //行内间距-列间距
float StepDis_Col = _flightTaskManager.RowDistance ; //列间距-行间距
float FindDis =Math.Min(StepDis_Row, StepDis_Col)*0.8f; //查找半径
//如果选中的飞机总数大于2--需要2-3架用来确认行列方向只有一行飞机就选2架多行需要3架
if (_copterManager.AcceptingControlCopters.Count() >= 2)
{
var copters = _copterManager.AcceptingControlCopters.ToList();
var firstCopter = copters[0];
var secondCopter = copters[1];
ICopter thirdCopter=null;
if (_copterManager.AcceptingControlCopters.Count()>2)
if (_copterManager.AcceptingControlCopters.Count() > 2)
{
thirdCopter = copters[2];
Message.Show($"选中了3架飞机将自动查找所有行列的飞机");
}
else
Message.Show($"选中了2架飞机将查找一行飞机");
//行角度(1,2) 用于查找每行的飞机位置
@ -186,21 +192,36 @@ namespace Plane.FormationCreator.ViewModels
ICopter LastCopter = firstCopter;
ILocation2D LastRowHewadCopter = firstCopter;
Message.Show($"开始查找飞机:行角度{RowDirect},列角度{ColDirect},列间距{StepDis_Row},行间距{StepDis_Col},查找半径{FindDis}米...");
firstCopter.VirtualId = 1;
int rowindex = 1;
while (FindedCopter!=null)
{
//按一行找飞机
FindedCopter = FindNextCopter(LastCopter, RowDirect, StepDis_Row, FindDis);
//一行找不到了 找下一行的前3架飞机
if ((FindedCopter == null)&&(thirdCopter!=null))
FindedCopter = FindNextColHeadCopter(out LastRowHewadCopter,LastRowHewadCopter, ColDirect, StepDis_Col, RowDirect, StepDis_Row, 3, FindDis);
//如果找到了分配ID
if ((FindedCopter == null) && (thirdCopter != null))
{
rowindex++;
FindedCopter = FindNextColHeadCopter(out LastRowHewadCopter, LastRowHewadCopter, ColDirect, StepDis_Col, RowDirect, StepDis_Row, 3, FindDis);
if (FindedCopter != null)
Message.Show($"开始第{rowindex}行--找到飞机");
else
Message.Show($"开始第{rowindex}行--无飞机");
}
//如果找到了分配ID
if (FindedCopter != null)
{
FindedCopter.VirtualId = GetVID(LastCopter.VirtualId);
Message.Show($"分配飞机VID:{FindedCopter.VirtualId}");
// Message.Show($"分配ID={FindedCopter.Id}飞机VID:={FindedCopter.VirtualId}");
LastCopter = FindedCopter;
}
}else
{
Message.Show($"未找到飞机,自动分配结束");
}
}
}
_copterManager.ReSort();

View File

@ -257,7 +257,7 @@ namespace Plane.FormationCreator.ViewModels
Array.Reverse(test);
string data = string.Join(".", test);
string copters = string.Join(",", kv.Value.ToArray());
Message.Show(string.Format("返回数据{0}{1}", data, copters));
Message.Show(string.Format("返回数据{0}({1}){2}", data, kv.Key,copters));
await Task.Delay(5).ConfigureAwait(false);
}
Message.Show("----统计完成----");
@ -314,8 +314,10 @@ namespace Plane.FormationCreator.ViewModels
Message.Show($"------------");
}
Message.Show($"==机头方向==");
//从小到大排个序
Dictionary<string, List<string>> SortedHeading = Heading.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
foreach (var item in Heading)
foreach (var item in SortedHeading)
{
Message.Show($"{item.Key} 度:{string.Join(",", item.Value)}");
Message.Show($"------------");
@ -770,7 +772,18 @@ namespace Plane.FormationCreator.ViewModels
}));
}
}
private ICommand _GetCommsumCommand;
public ICommand GetCommsumCommand
{
get
{
return _GetCommsumCommand ?? (_GetCommsumCommand = new RelayCommand(async () =>
{
//if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
await _commModuleManager.GetCommsumAsync();
}));
}
}
//打开校准界面
private ICommand _CalibrationSingleCommand;
public ICommand CalibrationSingleCommand
@ -1690,25 +1703,33 @@ namespace Plane.FormationCreator.ViewModels
foreach (LEDInfo ledInfo in LEDInfos)
{
float ledinterval=0;
//拉烟的ID 老版本只有8种新固件增加了
int fireno = 8;
Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB);
int ledMode = ledInfo.LEDMode;
//拉烟任务模式ID是50需要改为50
if (_copterManager.FC_VER_NO == 1)
{
fireno = 8;
//老版本是闪烁频率,且不能为小数
ledinterval = ledInfo.LEDInterval;
//老版本ledMode == 8 对应拉烟飞控对应50,ledinterval对应通道号
if (ledMode==8) ledMode = 50;
}
else
{
fireno = 15;
//新版本飞控 是闪烁间隔单位是100ms地面站还是频率可以有1位小数,用户输入0.5hz 飞控应该是(1/0.5)*10=20
ledinterval = (1/ledInfo.LEDInterval);
}
ledinterval = (1 / ledInfo.LEDInterval);
if (ledMode == fireno) ledMode = 50;
//新版本 ledMode=16是抛物飞控对应50ledinterval对应10 --固定的
if (ledMode == 16)
{
ledMode = 50;
ledinterval = 10;
}
else //新版本ledMode == 15 对应拉烟飞控对应50,ledinterval对应通道号
if (ledMode == 15)
{
ledMode = 50;
}
}
IMission LEDMission = Mission.CreateLEDControlMission(
(int)(ledInfo.Delay * 10),
ledMode,

View File

@ -2021,7 +2021,16 @@ public ICommand VerticlAlignmentCommand
//必须大于1架
if (_copterManager.SelectedCopters.Count() <= 1)
{
Alert.Show("必须选中多于一架飞机");
return;
}
if (EndTime<= BeginTime)
{
Alert.Show("结束时间必须大于开始时间(非持续时间!");
return;
}
//旋转飞机矩阵
if (CopterDirection != 0)

View File

@ -43,6 +43,8 @@
<Button Content="通讯版本" Command="{Binding DetectionCommModuleVersion}" />
<Button Content="统计返回"
Command="{Binding DetectionReturnData}" />
<Button Content="通讯统计"
Command="{Binding GetCommsumCommand}" />
<TextBlock
Margin="5,5,5,5" Foreground ="Red" VerticalAlignment="Center"

View File

@ -535,7 +535,7 @@
<TextBlock Text="时间" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
<TextBox Height="25" MinWidth="40" MaxWidth="45" Margin="5,0,0,0"
ToolTip="单位:秒,最小设置0.1秒"
ToolTip="相对延迟时间,最小0.1秒"
Text="{Binding Delay,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="频率" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>

View File

@ -170,6 +170,7 @@ namespace Plane.FormationCreator.Views
cb.Items.Add("异步变色(单色)"); //13
cb.Items.Add("异步变色(随机)"); //14
cb.Items.Add("拉烟"); //15
cb.Items.Add("抛物"); //16
}
cb.SelectedIndex = selind;

View File

@ -18,7 +18,7 @@
<RowDefinition Height="32"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="每数量" Margin="5,2"></Label>
<Label Content="每数量" Margin="5,2"></Label>
<TextBox Name="textboxColNum" Grid.Column="1" Margin="5" Width="80" ></TextBox>
<Label Content="列间距" Margin="5,2" Grid.Row="1"></Label>