加入通讯模块类型,初步支持wifi通讯

This commit is contained in:
xu 2020-03-03 11:21:29 +08:00
parent 776b9cfe62
commit 3d2a3b10fb
2 changed files with 30 additions and 23 deletions

View File

@ -30,6 +30,7 @@ namespace Plane.FormationCreator
{ {
public App() public App()
{ {
VersionControl.GetSettingFromIni();
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
ServiceLocatorConfigurer.Instance.Configure(); ServiceLocatorConfigurer.Instance.Configure();
@ -69,7 +70,7 @@ namespace Plane.FormationCreator
}; };
//new Test().Prepare().Run(); //new Test().Prepare().Run();
VersionControl.GetSettingFromIni();
} }
private ILogger _logger; private ILogger _logger;
@ -133,20 +134,25 @@ namespace Plane.FormationCreator
} }
*/ */
/* if (VersionControl.ConType == 1)
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) => {
{ CommModuleManager.Instance.UseTransModule = false;
_logger.Log(e1.Exception); UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
}; {
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished; _logger.Log(e1.Exception);
UdpServerConnectionManager.Instance.StartReceiving(); };
*/ UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
UdpServerConnectionManager.Instance.StartReceiving();
//初始化地面站连接 }
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo; else
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect; {
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected; CommModuleManager.Instance.UseTransModule = true;
CommModuleManager.Instance.Connect(); //初始化地面站连接
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
CommModuleManager.Instance.Connect();
}
} }
catch (Exception ex) catch (Exception ex)
@ -196,7 +202,8 @@ namespace Plane.FormationCreator
{ {
copter.Connection = Connection; copter.Connection = Connection;
} }
await copter.ConnectAsync().ConfigureAwait(false); if (copter!=null)
await copter.ConnectAsync().ConfigureAwait(false);
} }
private async void ConnectionManager_ConnectionEstablished(object sender, ConnectionEstablishedEventArgs e) private async void ConnectionManager_ConnectionEstablished(object sender, ConnectionEstablishedEventArgs e)

View File

@ -29,6 +29,8 @@ namespace Plane.FormationCreator.Util
public static string ServerURL = ""; public static string ServerURL = "";
public static int ConType = 0; //通讯模块
public static void SetUserLever(int vuserlever) public static void SetUserLever(int vuserlever)
{ {
if (vuserlever==0) if (vuserlever==0)
@ -78,13 +80,11 @@ namespace Plane.FormationCreator.Util
else else
ServerURL = DefaultServrURL; ServerURL = DefaultServrURL;
readvalue = iniFiles.IniReadvalue("Default", "ConType");
if (readvalue != "")
ConType = int.Parse(readvalue);
else
ConType = 0;
} }
public static void SaveLogininfoToIni(string username,string password,bool issavepassword) public static void SaveLogininfoToIni(string username,string password,bool issavepassword)