自动按照位置排序虚拟ID

This commit is contained in:
zxd 2019-12-11 20:40:30 +08:00
parent ce73335fd9
commit c254013048
5 changed files with 43 additions and 5 deletions

View File

@ -2,7 +2,7 @@
namespace Plane.Copters namespace Plane.Copters
{ {
public partial interface ICopter : ICopterStatus, ICopterEvents, ICopterActions, ICopterCommunication, INotifyPropertyChanged, ICopterAttribute public partial interface ICopter : ICopterStatus, ICopterEvents, ICopterVirtualId, ICopterActions, ICopterCommunication, INotifyPropertyChanged, ICopterAttribute
{ {
} }

View File

@ -10,6 +10,6 @@ namespace Plane.Copters
/// <summary> /// <summary>
/// 获取名称。 /// 获取名称。
/// </summary> /// </summary>
string Name { get; } string Name { get; set; }
} }
} }

View File

@ -22,6 +22,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Copters\CopterCommand.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\CopterCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\CopterState.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\CopterState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\ICopterAttribute.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\ICopterAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\ICopterVirtualId.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\PLObservableObject.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\PLObservableObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\FlightCommand.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\FlightCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Copters\GpsFixType.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Copters\GpsFixType.cs" />

View File

@ -413,6 +413,23 @@ namespace Plane.CommunicationManagement
/// <returns></returns> /// <returns></returns>
public async Task WriteCommPacketAsync(short copterId, short messageType, byte[] data = null, byte[] batchPacket = null) public async Task WriteCommPacketAsync(short copterId, short messageType, byte[] data = null, byte[] batchPacket = null)
{ {
if (messageType == MavComm.COMM_DOWNLOAD_COMM && copterId == 0)
{
short byteNum;
short length;
if (batchPacket == null)
{
byteNum = 0;
length = (short)((0x5 << 12) ^ byteNum);
batchPacket = BitConverter.GetBytes(length);
}
else
{
byteNum = (short)(batchPacket.Length / 2);
length = (short)((0x5 << 12) ^ byteNum);
batchPacket = BitConverter.GetBytes(length).Concat(batchPacket).ToArray();
}
}
if (data != null && batchPacket != null) data = batchPacket.Concat(data).ToArray(); if (data != null && batchPacket != null) data = batchPacket.Concat(data).ToArray();
int packetlength = data == null ? 0 : data.Length; int packetlength = data == null ? 0 : data.Length;
@ -466,11 +483,13 @@ namespace Plane.CommunicationManagement
{ {
int dataLength = 6 + 2 + indata.Length * 32; int dataLength = 6 + 2 + indata.Length * 32;
byte[] data = new byte[dataLength]; byte[] data = new byte[dataLength];
Int16 countNum = (Int16)indata.Length;
byte[] uses = new byte[] { 0, 1, 0, 0, 0, 0 };
byte[] uses = new byte[] { 0, 0, 1, 0, 0, 0 };
Array.Copy(uses, 0, data, 0, 6); Array.Copy(uses, 0, data, 0, 6);
Int16 countNum = (Int16)indata.Length; Array.Copy(BitConverter.GetBytes(countNum), 0, data, 2, 2);
Array.Copy(BitConverter.GetBytes(countNum), 0, data, 6, 2); Array.Copy(BitConverter.GetBytes(countNum), 0, data, 6, 2);
int offset = 8; int offset = 8;

View File

@ -169,6 +169,11 @@ namespace Plane.Copters
private double _RecordLng; private double _RecordLng;
private int _VirtualId;
private bool _DisplayVirtualId = false;
#endregion Backing Fields #endregion Backing Fields
public CopterImplSharedPart(SynchronizationContext uiSyncContext) : base(uiSyncContext) public CopterImplSharedPart(SynchronizationContext uiSyncContext) : base(uiSyncContext)
@ -394,6 +399,20 @@ namespace Plane.Copters
protected set { Set(nameof(Elevation), ref _Elevation, value); } protected set { Set(nameof(Elevation), ref _Elevation, value); }
} }
public int VirtualId
{
get { return _VirtualId; }
set { Set(nameof(VirtualId), ref _VirtualId, value); }
}
public bool DisplayVirtualId
{
get { return _DisplayVirtualId; }
set { Set(nameof(DisplayVirtualId), ref _DisplayVirtualId, value); }
}
/// <summary> /// <summary>
/// 获取固件版本。 /// 获取固件版本。
/// </summary> /// </summary>
@ -597,7 +616,6 @@ namespace Plane.Copters
public string Name { get; set; } public string Name { get; set; }
public float Pitch public float Pitch
{ {
get { return _Pitch; } get { return _Pitch; }