初步支持wifi通讯
This commit is contained in:
parent
21d9c121f5
commit
0d1f38f27a
@ -130,5 +130,9 @@ namespace Plane.Copters
|
||||
/// </summary>
|
||||
/// <returns>表示此命令异步发送操作的 <see cref="Task"/> 实例。</returns>
|
||||
Task StopPairingAsync();
|
||||
|
||||
|
||||
Task DoCommandAsync(int actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Plane.CommunicationManagement
|
||||
private bool starttime = false;
|
||||
private bool rtcm_run = false;
|
||||
//是否使用专用传输模块
|
||||
private bool UseTransModule = true;
|
||||
public bool UseTransModule = true;
|
||||
|
||||
private byte[] SetChannels(ushort? ch1 = null, ushort? ch2 = null, ushort? ch3 = null, ushort? ch4 = null, ushort? ch5 = null, ushort? ch6 = null, ushort? ch7 = null, ushort? ch8 = null)
|
||||
{
|
||||
@ -493,7 +493,10 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, data, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.UnlockAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -516,7 +519,15 @@ namespace Plane.CommunicationManagement
|
||||
});
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.LEDAsync();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -542,7 +553,8 @@ namespace Plane.CommunicationManagement
|
||||
}
|
||||
else
|
||||
{
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.SetParamAsync(paramname, value);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -553,11 +565,11 @@ namespace Plane.CommunicationManagement
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> SetMultipleParamAsync(params string[] param)
|
||||
{
|
||||
if (UseTransModule)
|
||||
{
|
||||
if (param.Length % 2 == 1)
|
||||
return 0;
|
||||
if (UseTransModule)
|
||||
{
|
||||
|
||||
byte[] packet = null;
|
||||
int packetNum = 0;
|
||||
@ -574,7 +586,20 @@ namespace Plane.CommunicationManagement
|
||||
}
|
||||
else
|
||||
{
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
byte[] packet = null;
|
||||
int packetNum = 0;
|
||||
for (int i = 0; i < param.Length; i += 2)
|
||||
{
|
||||
string paramname = param[i];
|
||||
float value = float.Parse(param[i + 1]);
|
||||
// foreach (var vcopter in Copters )
|
||||
// await vcopter.SetParamAsync(paramname, value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -628,7 +653,11 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, data, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.TakeOffAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -648,7 +677,12 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync((short)copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.ReturnToLaunchAsync ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -673,8 +707,12 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync((short)copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 降落
|
||||
/// </summary>
|
||||
@ -691,7 +729,12 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync((short)copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.LandAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -715,7 +758,12 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync((short)copterId, MavComm.COMM_DOWNLOAD_COMM, data, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.LockAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -741,7 +789,17 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, data, batchPacket);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
{
|
||||
await vcopter.MotorTestAsync(1);
|
||||
await vcopter.MotorTestAsync(2);
|
||||
await vcopter.MotorTestAsync(3);
|
||||
await vcopter.MotorTestAsync(4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -764,7 +822,12 @@ namespace Plane.CommunicationManagement
|
||||
await WriteCommPacketAsync((short)copterId, MavComm.COMM_DOWNLOAD_COMM, data, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.HoverAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -773,6 +836,8 @@ namespace Plane.CommunicationManagement
|
||||
/// <param name="copters"></param>
|
||||
/// <returns></returns>
|
||||
public async Task FloatAsync(IEnumerable<ICopter> copters = null)
|
||||
{
|
||||
if (UseTransModule)
|
||||
{
|
||||
short copterId = 0;
|
||||
byte[] batchPacket = null;
|
||||
@ -781,6 +846,13 @@ namespace Plane.CommunicationManagement
|
||||
byte[] packet = SetModeAsync(FlightMode.ALT_HOLD);
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.FloatAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校准加速计
|
||||
@ -788,6 +860,8 @@ namespace Plane.CommunicationManagement
|
||||
/// <param name="copterId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DoStartPreflightCompassAsync(IEnumerable<ICopter> copters = null)
|
||||
{
|
||||
if (UseTransModule)
|
||||
{
|
||||
short copterId = 0;
|
||||
byte[] batchPacket = null;
|
||||
@ -796,6 +870,13 @@ namespace Plane.CommunicationManagement
|
||||
byte[] packet = DoCommandAsync(MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION, 0, 0, 0, 0, 1, 0, 0);
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.DoCommandAsync((int)MAVLink.MAV_CMD.PREFLIGHT_CALIBRATION, 0, 0, 0, 0, 1, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校准加速计下一步
|
||||
@ -803,6 +884,8 @@ namespace Plane.CommunicationManagement
|
||||
/// <param name="copterId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DoNextPreflightCompassAsync(IEnumerable<ICopter> copters = null)
|
||||
{
|
||||
if (UseTransModule)
|
||||
{
|
||||
short copterId = 0;
|
||||
byte[] batchPacket = null;
|
||||
@ -815,6 +898,12 @@ namespace Plane.CommunicationManagement
|
||||
byte[] packet = GeneratePacket(MAVLink.MAVLINK_MSG_ID_COMMAND_ACK, req);
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Windows.Messages.Message.Show($"未开发完成!!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校准指南针
|
||||
@ -822,6 +911,8 @@ namespace Plane.CommunicationManagement
|
||||
/// <param name="copterId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DoCalibrationCompassAsync(IEnumerable<ICopter> copters = null)
|
||||
{
|
||||
if (UseTransModule)
|
||||
{
|
||||
short copterId = 0;
|
||||
byte[] batchPacket = null;
|
||||
@ -830,6 +921,13 @@ namespace Plane.CommunicationManagement
|
||||
byte[] packet = DoCommandAsync(MAVLink.MAV_CMD.DO_START_MAG_CAL, 0, 1, 1, 0, 0, 0, 0);
|
||||
await WriteCommPacketAsync(copterId, MavComm.COMM_DOWNLOAD_COMM, packet, batchPacket).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var vcopter in copters)
|
||||
await vcopter.DoCommandAsync((int)MAVLink.MAV_CMD.DO_START_MAG_CAL, 0, 1, 1, 0, 0, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 放弃校准指南针
|
||||
|
@ -24,5 +24,14 @@ namespace Plane.Copters
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
public async Task DoCommandAsync(int actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7)
|
||||
{
|
||||
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +295,13 @@ namespace Plane.Copters
|
||||
|
||||
}
|
||||
|
||||
public async Task DoCommandAsync(int actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7)
|
||||
{
|
||||
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
|
||||
|
||||
}
|
||||
public Task SetParamAsync(string paramName, float value, int millisecondsTimeout = Timeout.Infinite)
|
||||
{
|
||||
// TODO: 林俊清, 20150807, 实现仿真的 SetParamAsync。
|
||||
|
@ -356,6 +356,12 @@ namespace Plane.Copters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task DoCommandAsync(int actionid, float p1, float p2, float p3, float p4, float p5, float p6, float p7)
|
||||
{
|
||||
await _internalCopter.DoCommandAsync((MAVLink.MAV_CMD)actionid, p1, p2, p3, p4, p5, p6, p7).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task LEDAsync()
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user