diff --git a/Plane.FormationCreator.sln b/Plane.FormationCreator.sln index 038963d..9c5dad5 100644 --- a/Plane.FormationCreator.sln +++ b/Plane.FormationCreator.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.FormationCreator", "Plane.FormationCreator\Plane.FormationCreator.csproj", "{61E2F31E-220A-4E3F-A64D-F7CDC2135008}" ProjectSection(ProjectDependencies) = postProject - {BE3280E8-8C7F-4961-9685-1124C5B990CB} = {BE3280E8-8C7F-4961-9685-1124C5B990CB} + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A} = {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A} EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Windows", "..\Plane.Libraries\Plane.Windows\Plane.Windows.csproj", "{06848293-9B17-4068-9B35-44D0ED713CD4}" @@ -26,7 +26,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk_Shared", "..\Pl EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlaneGcsSdk.Contract_Shared", "..\Plane.Sdk3\PlaneGcsSdk.Contract_Shared\PlaneGcsSdk.Contract_Shared.shproj", "{695733D7-99FF-4707-8C89-474E949CADCB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "flyBase", "..\flyBase\flyBase.csproj", "{BE3280E8-8C7F-4961-9685-1124C5B990CB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlightRoute", "..\FlyTest\FlightRoute\FlightRoute.csproj", "{705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -106,14 +106,14 @@ Global {47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU {47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU {47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.Release|Any CPU.Build.0 = Release|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU - {BE3280E8-8C7F-4961-9685-1124C5B990CB}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.Release|Any CPU.Build.0 = Release|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU + {705AAB55-ED7A-4856-8F7B-E7A78ED9E39A}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index 7d4a0b2..7d14c1a 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -20,12 +20,17 @@ using System.IO; namespace Plane.FormationCreator.Formation { + public class CopterCollection : ObservableCollection { - + //软件过期时间---过期将无法添加飞机,并自动退出 + public static DateTime Expire_App = DateTime.Parse("2021-06-01"); + //超级用户过期时间--过期将无法使用内置超级用户登录 + public static DateTime Expire_SuperUser = Expire_App; + //允许飞行的飞机数量 public int EnCopterNumber = 0; - + //允许模拟的飞机数量 public int EnVCopterNumber = 0; @@ -36,15 +41,13 @@ namespace Plane.FormationCreator.Formation /// public int AddCopter(ICopter entityObject, CopterManager.CopterSortType vSortType) { - ////给第三方时候限制数量和时间用 - DateTime dateTime2019 = DateTime.Parse("2020-08-01"); //新增飞机区域限制:内蒙 // if (entityObject.Latitude < 37.4307185218 || entityObject.Latitude > 45.6754821756 // || entityObject.Longitude < 97.3493089056 || entityObject.Longitude > 115.8006783856) // return 0; - if (DateTime.UtcNow > dateTime2019) + if (DateTime.UtcNow > Expire_App) { throw new NotImplementedException(); } @@ -179,8 +182,17 @@ namespace Plane.FormationCreator.Formation const string LoginPage = "checkforapp.php"; const string supername = "admin"; - const string superpass = "fxmf0622"; + const string superpass = "admin0622"; const string TEMP_MISSIONFILE = @".\gcs.dat"; + //飞控版本控制 + public int FC_VER_NO = 1;//"4.1.2" 这个版本以前版本灯光比较少no=1 //"4.5"以后no=2; + //飞控版本控制 + public string FC_VER_STRING = "4.1.2以前"; // + + + + + //用户级别 const int LEVEL_NORMAL = 1; const int LEVEL_ADMIN = 0; @@ -205,7 +217,19 @@ namespace Plane.FormationCreator.Formation Task.WhenAll(Copters.Select(c => c.DisconnectAsync())); }; - } + + Windows.IniHelper.IniFiles inifilse = new Windows.IniHelper.IniFiles(); + string readvalue = ""; + int intTemp; + readvalue = inifilse.IniReadvalue("Default", "FC_VER_NO"); + if (readvalue != "" && int.TryParse(readvalue, out intTemp)) + FC_VER_NO = int.Parse(readvalue); + + + readvalue = inifilse.IniReadvalue("Default", "FC_VER_STRING"); + if (readvalue != "" ) + FC_VER_STRING =readvalue; + } public List ShowCopter = new List(); @@ -328,6 +352,7 @@ namespace Plane.FormationCreator.Formation private string _UserName = ""; private string _UserDisplayName = ""; + public string RTK_URL = ""; public void NetLogined(string UserName,string UserDisplayName,int vEnCopterNumber,int vEnVCopterNumber,int userlever=1) { @@ -355,6 +380,40 @@ namespace Plane.FormationCreator.Formation }).ConfigureAwait(false); } } + public void GetRTKURL() + { + if (_UserName == "") return; + // 发送请求 + 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=GetRTK"); + sbUrl.Append("&ver=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()); + String strUrl = sbUrl.ToString(); + string errorstr; + new AsynDataUtils().AsynGetData(strUrl, ResultCallBack_rtk, out errorstr); + } + + public void ReleaseRTKURL() + { + if (_UserName == "") return; + // 发送请求 + 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=RelRTK"); + sbUrl.Append("&ver=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()); + String strUrl = sbUrl.ToString(); + string errorstr; + new AsynDataUtils().AsynGetData(strUrl, null, out errorstr); + + } + + private void NetActivePost() { // 发送请求 @@ -565,7 +624,8 @@ namespace Plane.FormationCreator.Formation { Logined = false; //超级用户,无限制 - if ((username== supername) && (password== superpass)) + + if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) ) { NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN); return; @@ -590,7 +650,29 @@ namespace Plane.FormationCreator.Formation else Loginstate = "登录失败,"+ errorstr; } + private void ResultCallBack_rtk(string data, bool haveerror) + { + if (haveerror) + { + MessageBox.Show("获取RTK账号失败," + data, "错误"); + return; + } + if (data == "") + { + MessageBox.Show("获取RTK账号失败,请检查网络", "错误"); + return; + } + string[] arr = data.Split(';'); + string loginret = arr[0]; + if (loginret == "ok") + { + RTK_URL = arr[1]; + } + else + MessageBox.Show(loginret, "错误"); + + } //在这个方法里面接收回调的返回信息 private void DataResultCallBack_changepassword(string data, bool haveerror) diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index bd9217f..96180a5 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -31,7 +31,7 @@ namespace Plane.FormationCreator.Formation _copterManager.Copters.CollectionChanged += (sender, e) => { - // TODO: 林俊清, 20150724, 需要改为正确的做法(清除旧飞机的任务,补充新飞机的任务)。 + // TODO: 王海, 20150724, 需要改为正确的做法(清除旧飞机的任务,补充新飞机的任务)。 //AddTakeOffTask(e.NewItems?.Cast()); }; @@ -47,7 +47,7 @@ namespace Plane.FormationCreator.Formation } */ - // TODO: 林俊清, 20150803, 处理选中多个飞行器的情况。 + // TODO: 王海, 20150803, 处理选中多个飞行器的情况。 if (_copterManager.SelectedCopters.Count() > 1) { return; @@ -74,7 +74,7 @@ namespace Plane.FormationCreator.Formation TaskAdded += (sender, e) => { - // TODO: 林俊清, 20150803, 处理选中多个飞行器的情况。 + // TODO: 王海, 20150803, 处理选中多个飞行器的情况。 if (_copterManager.SelectedCopters.Count() > 1) { return; @@ -1072,7 +1072,7 @@ namespace Plane.FormationCreator.Formation var center = nullableCenter.Value; var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes, FlytoTime = flytoTime, LoiterTime = loiterTime }; if(taskName != null) newTask.TaskCnName = taskName; - // TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。 + // TODO: 王海, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。 for (int i = 0; i < copters.Count; i++) { var copter = copters[i]; @@ -1505,15 +1505,34 @@ namespace Plane.FormationCreator.Formation } - public void SetTaskFlytime(int taskIndex,bool settime=true) + public void SetTaskFlytime(int taskIndex,bool settime=true,float currspeed=-1.0f) { + double speed = 5.0f; //默认速度 + if ((taskIndex > 0 )&&(taskIndex < Tasks.Count) &&( Tasks[taskIndex].TaskType == FlightTaskType.FlyTo)) { if (_copterManager.Copters.Count() > 0) { + + //计算之前航点有没改变速度,有就取最后一次速度 + if (currspeed==-1.0) + { + for (int _taskIndex = taskIndex-1; _taskIndex > 1; _taskIndex--) + + { + var curWaypoint = Tasks[_taskIndex].SingleCopterInfos.FirstOrDefault(); + if ((curWaypoint.IsChangeSpeed)) + { + speed = curWaypoint.LevelSpeed; + break; + } + + } + } double maxDistance = 0.0f; string copterName = ""; - double speed = 0.0f; + + foreach (var copter in _copterManager.Copters) { var prevWaypoint = Tasks[taskIndex - 1].SingleCopterInfos.FirstOrDefault(c => c.Copter == copter); @@ -1523,6 +1542,16 @@ namespace Plane.FormationCreator.Formation Message.Show($"任务{taskIndex + 1}飞机编号:{copter.Id}是自动速度,无法计算时间!"); return ; } + + //当前航点是否改变速度,有就取修改的速度 + if (curWaypoint.IsChangeSpeed) + { + + speed = curWaypoint.LevelSpeed; + + } + + double distance = GeographyUtils.CalcDistance( prevWaypoint.TargetLat, prevWaypoint.TargetLng, prevWaypoint.TargetAlt, curWaypoint.TargetLat, curWaypoint.TargetLng, curWaypoint.TargetAlt); @@ -1530,7 +1559,7 @@ namespace Plane.FormationCreator.Formation { maxDistance = distance; copterName = copter.Name; - speed = curWaypoint.LevelSpeed; + // speed = curWaypoint.LevelSpeed; } } @@ -1564,7 +1593,7 @@ namespace Plane.FormationCreator.Formation } //计算优化线路,采用米计算 /// - /// + /// 自动生成航线2D和3D都用这个--------目前使用---------------- /// /// 3D计算 /// 是否改变线路的结束点顺序--返回起飞点航线不能交换 @@ -2320,7 +2349,7 @@ namespace Plane.FormationCreator.Formation } AvoidCrashLog.Clear(); //可能有丢失 } - catch // 林俊清, 20151102, 通常是“集合已修改”异常。 + catch // 王海, 20151102, 通常是“集合已修改”异常。 { } finally @@ -2351,7 +2380,7 @@ namespace Plane.FormationCreator.Formation } - catch // 林俊清, 20151102, 通常是“集合已修改”异常。 + catch // 王海, 20151102, 通常是“集合已修改”异常。 { } finally diff --git a/Plane.FormationCreator/Formation/RtcmManager.cs b/Plane.FormationCreator/Formation/RtcmManager.cs index 68d9860..c25d0dd 100644 --- a/Plane.FormationCreator/Formation/RtcmManager.cs +++ b/Plane.FormationCreator/Formation/RtcmManager.cs @@ -13,6 +13,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Forms; using System.Windows.Media; using System.Windows.Threading; @@ -210,18 +211,19 @@ namespace Plane.FormationCreator.Formation public async Task Open(string CMB_serialport) { if (CMB_serialport == "") return; + FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance(); - switch(CMB_serialport) + switch (CMB_serialport) { - case "千寻": + case "千寻": //检测原点 - FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance(); + // FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance(); if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0) { Alert.Show("作为参照的原点未设置,无法发送RTCM!", "提示"); return; } - + //ini里面的固定千寻账号 //千寻账号 string messagetips = "格式:http://差分账号:差分密码@域名:端口/坐标系\r\n例如:http://account:password@rtk.ntrip.qxwz.com:8002/RTCM32_GGB"; string url = ""; @@ -229,9 +231,45 @@ namespace Plane.FormationCreator.Formation url = inifilse.IniReadvalue("Default", "RTKurl"); if (PlaneMessageBox.OnShow(messagetips, "发送RTK", ref url) == false) return; inifilse.IniWritevalue("Default", "RTKurl", url); - + //构造 comPort = new CommsNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng); + + break; + + case "魔方基站": + //检测原点 + if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0) + { + Alert.Show("作为参照的原点未设置,无法发送RTCM!", "提示"); + return; + } + /* //ini里面的固定千寻账号 + //千寻账号 + string messagetips = "格式:http://差分账号:差分密码@域名:端口/坐标系\r\n例如:http://account:password@rtk.ntrip.qxwz.com:8002/RTCM32_GGB"; + string url = ""; + IniFiles inifilse = new IniFiles(); + url = inifilse.IniReadvalue("Default", "RTKurl"); + if (PlaneMessageBox.OnShow(messagetips, "发送RTK", ref url) == false) return; + inifilse.IniWritevalue("Default", "RTKurl", url); + */ + //通过网络得到千寻账号 + if (_copterManager.RTK_URL == "") + { + //得到千寻账号 + _copterManager.GetRTKURL(); + //等到返回5秒 + DateTime Tthen = DateTime.Now; + do + { + Application.DoEvents(); + } while ((_copterManager.RTK_URL == "") || (Tthen.AddSeconds(2) > DateTime.Now)); + } + if (_copterManager.RTK_URL != "") + { + //构造 + comPort = new CommsNTRIP(_copterManager.RTK_URL, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng); + } break; default: comPort = new SerialPort(); @@ -256,11 +294,30 @@ namespace Plane.FormationCreator.Formation } } - public async Task Close() + public async Task Close(string CMB_serialport) { await _commModuleManager.CloseRtcmLoop(); Rtcmthreadrun = false; comPort.Close(); + switch (CMB_serialport) + { + case "魔方基站": + { + //释放千寻账号 + _copterManager.ReleaseRTKURL(); + + } + break; + } + + BaseState = false; + GpsState = false; + GlonassState = false; + BeidouState = false; + rtcmInfoList.Clear(); + _copterManager.RTK_URL = ""; + + } private async Task RtcmLoop() @@ -333,7 +390,7 @@ namespace Plane.FormationCreator.Formation } catch(Exception ex) { - Message.Show(ex.Message); + Plane.Windows.Messages.Message.Show(ex.Message); } } } @@ -420,7 +477,7 @@ namespace Plane.FormationCreator.Formation } catch (Exception ex) { - Message.Show(ex.Message); + Plane.Windows.Messages.Message.Show(ex.Message); } await Task.Delay(1); diff --git a/Plane.FormationCreator/MainWindow.xaml b/Plane.FormationCreator/MainWindow.xaml index e98b081..2047078 100644 --- a/Plane.FormationCreator/MainWindow.xaml +++ b/Plane.FormationCreator/MainWindow.xaml @@ -87,7 +87,7 @@