/// <summary> /// Copy constructor. Initializes a new instance of the <see cref="NcomPacketA"/> class, /// logically equivalent to to the specified <paramref name="source"/>. /// </summary> /// <param name="source"> /// The source <see cref="NcomPacketA"/> with which to initialise this instance. /// </param> public NcomPacketA(NcomPacketA source) : base(source) { if (source != null) { this.Time = source.Time; this.AccelerationX = source.AccelerationX; this.AccelerationY = source.AccelerationY; this.AccelerationZ = source.AccelerationZ; this.AngularRateX = source.AngularRateX; this.AngularRateY = source.AngularRateY; this.AngularRateZ = source.AngularRateZ; this.Checksum1 = source.Checksum1; this.Latitude = source.Latitude; this.Longitude = source.Longitude; this.Altitude = source.Altitude; this.DownVelocity = source.DownVelocity; this.EastVelocity = source.EastVelocity; this.NorthVelocity = source.NorthVelocity; this.Heading = source.Heading; this.Pitch = source.Pitch; this.Roll = source.Roll; this.Checksum2 = source.Checksum2; this.StatusChannel = source.StatusChannel?.Clone(); } }
/* ---------- Public methods ----------------------------------------------------------/**/ public virtual List <NcomPacket> ProcessNcom(byte[] buffer) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } // Create a list to store packets in List <NcomPacket> pkts = new List <NcomPacket>(); NcomPacket pkt; // Iterate over the buffer to find sync bytes int p = 0; while (p <= buffer.Length - NcomPacket.PacketLength) { // Have we found a sync byte? if (buffer[p++] == NcomPacket.SyncByte) { // Test the navigation status byte (byte 21). If it is 11, parse as structure B, else // structure A. if (buffer[(p - 1) + 21] == (byte)NavigationStatus.InternalUse) { pkt = new NcomPacketB(); } else { pkt = new NcomPacketA(); } // Try to unmarshal the Ncom packet if (pkt.Unmarshal(buffer, p - 1)) { pkts.Add(pkt); p += NcomPacket.PacketLength - 1; } } } // Return the list of processed Ncom packets return(pkts); }
protected override bool IsEqual(NcomPacket _pkt) { NcomPacketA pkt = _pkt as NcomPacketA; return(base.IsEqual(pkt) && this.Time == pkt.Time && this.AccelerationX == pkt.AccelerationX && this.AccelerationY == pkt.AccelerationY && this.AccelerationZ == pkt.AccelerationZ && this.AngularRateX == pkt.AngularRateX && this.AngularRateY == pkt.AngularRateY && this.AngularRateZ == pkt.AngularRateZ && this.Latitude == pkt.Latitude && this.Longitude == pkt.Longitude && this.Altitude == pkt.Altitude && this.NorthVelocity == pkt.NorthVelocity && this.EastVelocity == pkt.EastVelocity && this.DownVelocity == pkt.DownVelocity && this.Heading == pkt.Heading && this.Pitch == pkt.Pitch && this.Roll == pkt.Roll && (this.StatusChannel == null ? pkt.StatusChannel == null : this.StatusChannel.Equals(pkt.StatusChannel))); }