diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index 2771ab0..6f8e619 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -25,7 +25,7 @@ namespace Plane.FormationCreator.Formation public class CopterCollection : ObservableCollection { //软件过期时间---过期将无法添加飞机,并自动退出 - public static DateTime Expire_App = DateTime.Parse("2022-12-31"); + public static DateTime Expire_App = DateTime.Parse("2023-12-31"); //超级用户过期时间--过期将无法使用内置超级用户登录 public static DateTime Expire_SuperUser = Expire_App; //允许飞行的飞机数量 diff --git a/Plane.FormationCreator/Formation/RtcmManager.cs b/Plane.FormationCreator/Formation/RtcmManager.cs index 685d2a0..a5f9971 100644 --- a/Plane.FormationCreator/Formation/RtcmManager.cs +++ b/Plane.FormationCreator/Formation/RtcmManager.cs @@ -30,6 +30,41 @@ namespace Plane.FormationCreator.Formation private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance(); private CopterManager _copterManager = ServiceLocator.Current.GetInstance(); private bool _rtcmthreadrun = false; + // rtcm发送类型0:直接发送, + // 1:1秒只发一种卫星,1秒发GPS,第2秒发北斗,第3秒发格洛纳斯,其他数据随来随发 + private int _rtcmsendtype = 1; + + const int MSG_GPS = 1074; + const int MSG_GLONASS = 1084; + const int MSG_Beidou = 1124; + const int MSG_BasePos = 1005; + const int MSG_REV = 1033; + + public string rtcm_typename(int msgtype) + { + string typename = "Rtcm" + msgtype; + switch (msgtype) + { + case MSG_GPS: + typename = "GPS"; + break; + case MSG_GLONASS: + typename = "GLONASS"; + break; + case MSG_Beidou: + typename = "北斗"; + break; + //位置5秒发一次就可以了 + case MSG_BasePos: + typename = "基站位置"; + break; + case MSG_REV: //这个没必要发 + typename = "版本"; + break; + } + return typename; + + } public bool Rtcmthreadrun { get { return _rtcmthreadrun; } @@ -142,6 +177,7 @@ namespace Plane.FormationCreator.Formation dispatcherTimer.Start(); } + //用于刷新界面,显示消息状态,基站和卫星是否有效等 private void OnTimedEvent(object sender, EventArgs e) { BaseState = baseTime > DateTime.Now; @@ -168,7 +204,7 @@ namespace Plane.FormationCreator.Formation } - + //显示卫星信号强度条 private void Rtcm_ObsMessage(object sender, EventArgs e) { List obs = sender as List; @@ -331,28 +367,10 @@ namespace Plane.FormationCreator.Formation { 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; + long last_send_pos = CurrentTimeMillis()- 5000;//5秒发一次就可以了 bool Ensend = false; - int last_mag = 0; - - //新版本打包发送模式 //await _commModuleManager.StartRtcmLoop(); - while (Rtcmthreadrun) { try @@ -395,62 +413,70 @@ namespace Plane.FormationCreator.Formation if ((seenmsg = rtcm.Read(buffer[a])) > 0) { bpsusefull += rtcm.length; + string msgshowname = rtcm_typename(seenmsg); _commModuleManager.SetAllCoptersForWifi(_copterManager.Copters); -/* 在数据量大的时候这样可以减少数据量,但测试结果是老方法更可靠,固定更快,特别是使用物理基站时 - switch (seenmsg) + if (_rtcmsendtype == 0) { - 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.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length); + }else + if (_rtcmsendtype == 1) { - // await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length); - Ensend = false; + //第1秒是gps,第2秒是GLONASS,第3秒是 Beidou + //1秒内可能发送多个同一种类型的数据,看数据大小和原始频率 + long curr_s = CurrentTimeMillis()/1000; + int sendtype = (int) (curr_s % 3); + switch (seenmsg) + { + case MSG_GPS: + if (sendtype==0) //第1秒是gps, + Ensend = true; + break; + + case MSG_GLONASS: + if (sendtype == 1) //第2秒是GLONASS, + Ensend = true; + break; + case MSG_Beidou: + if (sendtype == 2) //第3秒是 Beidou + Ensend = true; + break; + //位置4秒发一次就可以了 + case MSG_BasePos: + { + long curr_send_pos = CurrentTimeMillis(); + if ((curr_send_pos - last_send_pos) > 4000) + { + last_send_pos = curr_send_pos; + Ensend = true; + } + } + break; + case MSG_REV: //这个没必要发 + Ensend = false; + break; + default: //其他类型数据随到随发 + Ensend = true; + break; + } + if (Ensend) + { + // Plane.Windows.Messages.Message.Show(DateTime.Now.ToString("HH:mm:ss")+"--Rtcm长度: " + (ushort)rtcm.length+" , 类型: "+ seenmsg); + Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "--Rtcm长度: " + (ushort)rtcm.length + " 类型: " + msgshowname + " ("+ seenmsg+")"); + await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length); + } + //else + // Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "--放弃发送-----Rtcm长度: " + (ushort)rtcm.length + " 类型: " + msgshowname + " (" + seenmsg + ")"); + } - */ - //老的单频rtk发送 - await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length); - string msgname = "Rtcm" + seenmsg; - - if (!msgseen.ContainsKey(msgname)) - msgseen[msgname] = 0; - msgseen[msgname] = (int)msgseen[msgname] + 1; - - await ExtractBasePos(seenmsg); - //await seenRTCM(seenmsg); + //累加消息数量,用于界面显示 + if (!msgseen.ContainsKey(msgshowname)) + msgseen[msgshowname] = 0; + msgseen[msgshowname] = (int)msgseen[msgshowname] + 1; + //检测基站定位状态和卫星定位状态,用于在界面上显示 + await ExtractBasePos(seenmsg); } } await Task.Delay(10); diff --git a/Plane.FormationCreator/Plane.FormationCreator.csproj b/Plane.FormationCreator/Plane.FormationCreator.csproj index 483c843..13bf095 100644 --- a/Plane.FormationCreator/Plane.FormationCreator.csproj +++ b/Plane.FormationCreator/Plane.FormationCreator.csproj @@ -106,7 +106,9 @@ ..\packages\MaterialDesignThemes.1.4.0.473\lib\net45\MaterialDesignThemes.Wpf.dll True - + + ..\packages\Unnoficial.Microsoft.Expression.Drawing.1.0.0\lib\Microsoft.Expression.Drawing.dll + ..\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll True diff --git a/Plane.FormationCreator/Util/CommNTRIP.cs b/Plane.FormationCreator/Util/CommNTRIP.cs index 4bd9def..d54efc1 100644 --- a/Plane.FormationCreator/Util/CommNTRIP.cs +++ b/Plane.FormationCreator/Util/CommNTRIP.cs @@ -261,7 +261,7 @@ namespace Plane.Util retrys--; } - throw new Exception("The ntrip is closed"); + throw new Exception("网络RTK基站通讯已关闭!"); } } diff --git a/Plane.FormationCreator/Util/rtcm3.cs b/Plane.FormationCreator/Util/rtcm3.cs index a4e404f..82cae04 100644 --- a/Plane.FormationCreator/Util/rtcm3.cs +++ b/Plane.FormationCreator/Util/rtcm3.cs @@ -2278,6 +2278,7 @@ namespace Plane.Util return i; } + } } } \ No newline at end of file diff --git a/Plane.FormationCreator/Views/RtcmInfoView.xaml b/Plane.FormationCreator/Views/RtcmInfoView.xaml index f71aa56..24f84db 100644 --- a/Plane.FormationCreator/Views/RtcmInfoView.xaml +++ b/Plane.FormationCreator/Views/RtcmInfoView.xaml @@ -54,10 +54,10 @@ Fill="{Binding RtcmManager.BaseState,Converter={StaticResource ColorConverter}}"/> + Fill="{Binding RtcmManager.GpsState ,Converter={StaticResource ColorConverter}}"/> + Fill="{Binding RtcmManager.GlonassState,Converter={StaticResource ColorConverter}}"/> diff --git a/Plane.FormationCreator/packages.config b/Plane.FormationCreator/packages.config index 0e1fa51..a759f4e 100644 --- a/Plane.FormationCreator/packages.config +++ b/Plane.FormationCreator/packages.config @@ -15,4 +15,5 @@ + \ No newline at end of file