diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index f06c4e5..f2d93ac 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -16,6 +16,7 @@ using Plane.Util; using System.Windows; using Plane.Windows.Messages; using System.Reflection; +using System.IO; namespace Plane.FormationCreator.Formation { @@ -26,7 +27,8 @@ namespace Plane.FormationCreator.Formation public int EnCopterNumber = 0; public int EnVCopterNumber = 0; - + + /// /// 实现排序插入 @@ -133,6 +135,7 @@ namespace Plane.FormationCreator.Formation const string LoginPage = "checkforapp.php"; const string supername = "admin"; const string superpass = "fxmf0622"; + const string TEMP_MISSIONFILE = @".\gcs.dat"; //用户级别 const int LEVEL_NORMAL = 1; const int LEVEL_ADMIN = 0; @@ -306,9 +309,65 @@ namespace Plane.FormationCreator.Formation Loginstate = "未登录"; } + //本地飞行任务日志 提交到服务器 + public void Net_PostTempMission() + { + string filePath = TEMP_MISSIONFILE; + string[] Missionstrs = { }; + try + { + if (File.Exists(filePath)) + { + Missionstrs = File.ReadAllLines(filePath); + List Mlist = new List(Missionstrs); + string upstr = ""; + foreach (var mstr in Mlist) + upstr = upstr + mstr + "|"; + Net_PostTempMission(upstr); + Mlist.Clear(); + File.WriteAllLines(TEMP_MISSIONFILE, Mlist); + } + + } + catch (Exception ex) + { + + } + + } + + //保存飞行任务日志临时到本地 + public void Net_WriteTempMission(DateTime MissionTime, double OriginLng, double OriginLat) + { + string filePath = TEMP_MISSIONFILE; + string[] Missionstrs = { }; + try + { + if (File.Exists(filePath)) + Missionstrs = File.ReadAllLines(filePath); + List Mlist = new List(Missionstrs); + Mlist.Add(MissionTime.ToString() + ";" + OriginLng.ToString() + ";" + OriginLat.ToString() + ";" + Copters.Count().ToString() + + ";" + Assembly.GetExecutingAssembly().GetName().Version.ToString()); + + File.WriteAllLines(TEMP_MISSIONFILE, Mlist); + + } + catch (Exception ex) + { + + } + } //提交飞行记录 - public void Net_PostStartMission(DateTime MissionTime,double OriginLng, double OriginLat) + public void Net_LogStartMission(DateTime MissionTime,double OriginLng, double OriginLat) + { + Net_WriteTempMission(MissionTime, OriginLng, OriginLat); + Net_PostStartMission(MissionTime, OriginLng, OriginLat); + } + + + //提交飞行记录 + public void Net_PostStartMission(DateTime MissionTime, double OriginLng, double OriginLat) { // 发送请求 @@ -318,9 +377,9 @@ namespace Plane.FormationCreator.Formation sbUrl.Append("username=" + _UserName); sbUrl.Append("&" + "clientname=" + System.Net.Dns.GetHostName()); sbUrl.Append("&type=StartMission"); - sbUrl.Append("&mtime="+ MissionTime.ToString()); - sbUrl.Append("&orgLng="+ OriginLng.ToString()); - sbUrl.Append("&orgLat="+ OriginLat.ToString()); + sbUrl.Append("&mtime=" + MissionTime.ToString()); + sbUrl.Append("&orgLng=" + OriginLng.ToString()); + sbUrl.Append("&orgLat=" + OriginLat.ToString()); sbUrl.Append("&coptercount=" + Copters.Count().ToString()); sbUrl.Append("&ver=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()); String strUrl = sbUrl.ToString(); @@ -328,7 +387,21 @@ namespace Plane.FormationCreator.Formation new AsynDataUtils().AsynGetData(strUrl, null, out errorstr); } - + //提交本地飞行记录 + public void Net_PostTempMission(string missstr) + { + // 发送请求 + StringBuilder sbUrl = new StringBuilder(); // 请求URL内容 + sbUrl.Append(VersionControl.ServerURL + LoginPage); + sbUrl.Append("?"); + sbUrl.Append("username=" + _UserName); + sbUrl.Append("&" + "clientname=" + System.Net.Dns.GetHostName()); + sbUrl.Append("&type=TempMission"); + sbUrl.Append("&Mission=" + missstr); + String strUrl = sbUrl.ToString(); + string errorstr; + new AsynDataUtils().AsynGetData(strUrl, null, out errorstr); + } @@ -374,6 +447,7 @@ namespace Plane.FormationCreator.Formation int userlevel = int.Parse(arr[4]); NetLogined(tempuser, UserDisplayName, vEnCopterNumber, vEnVCopterNumber, userlevel); VersionControl.SaveLogininfoToIni(tempuser, tempPassword, tempSavePassword); + Net_PostTempMission(); //MessageBox.Show(UserDisplayName + " 登录成功!", "登录提示"); } else diff --git a/Plane.FormationCreator/Formation/RtcmManager.cs b/Plane.FormationCreator/Formation/RtcmManager.cs index 3102fbf..77e5f06 100644 --- a/Plane.FormationCreator/Formation/RtcmManager.cs +++ b/Plane.FormationCreator/Formation/RtcmManager.cs @@ -290,8 +290,10 @@ namespace Plane.FormationCreator.Formation if ((seenmsg = rtcm.Read(buffer[a])) > 0) { bpsusefull += rtcm.length; - - await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length); + //用于双频RTK发送 + // await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length); + //用于单频rtk发送 + await _commModuleManager.InjectGpsDataAsync(rtcm.packet, (ushort)rtcm.length); string msgname = "Rtcm" + seenmsg; diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index b4f3f29..7d9ce91 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -878,6 +878,8 @@ namespace Plane.FormationCreator.ViewModels if (packet != null && packet.Length > 0) { //Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---packet.length = {packet.Length}"); + //新方案的RTK发送,用于双频 + /* int read = packet.Length; if (read > 0) { @@ -892,6 +894,9 @@ namespace Plane.FormationCreator.ViewModels } } } + */ + //稳定方案的rtk发送,用于单频 + await _commModuleManager.InjectGpsDataAsync(packet, (ushort)packet.Length); } await Task.Delay(10).ConfigureAwait(false); @@ -1177,7 +1182,7 @@ namespace Plane.FormationCreator.ViewModels await Task.Delay(10).ConfigureAwait(false); } - _copterManager.Net_PostStartMission(MissionTime, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat); + _copterManager.Net_LogStartMission(MissionTime, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat); Alert.Show("所有飞机开始执行航点任务。请勿多次开始任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); })); }