加入通讯模块类型,初步支持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()
{
VersionControl.GetSettingFromIni();
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
ServiceLocatorConfigurer.Instance.Configure();
@ -69,7 +70,7 @@ namespace Plane.FormationCreator
};
//new Test().Prepare().Run();
VersionControl.GetSettingFromIni();
}
private ILogger _logger;
@ -133,20 +134,25 @@ namespace Plane.FormationCreator
}
*/
/*
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
{
_logger.Log(e1.Exception);
};
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
UdpServerConnectionManager.Instance.StartReceiving();
*/
//初始化地面站连接
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
CommModuleManager.Instance.Connect();
if (VersionControl.ConType == 1)
{
CommModuleManager.Instance.UseTransModule = false;
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
{
_logger.Log(e1.Exception);
};
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
UdpServerConnectionManager.Instance.StartReceiving();
}
else
{
CommModuleManager.Instance.UseTransModule = true;
//初始化地面站连接
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
CommModuleManager.Instance.Connect();
}
}
catch (Exception ex)
@ -196,7 +202,8 @@ namespace Plane.FormationCreator
{
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)

View File

@ -29,6 +29,8 @@ namespace Plane.FormationCreator.Util
public static string ServerURL = "";
public static int ConType = 0; //通讯模块
public static void SetUserLever(int vuserlever)
{
if (vuserlever==0)
@ -78,13 +80,11 @@ namespace Plane.FormationCreator.Util
else
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)