/* ---------- Public methods ----------------------------------------------------------/**/ /// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> /// <remarks> /// The hash code generation process ignores properties <see cref="Checksum1" />, /// <see cref="Checksum2" /> and <see cref="NcomPacket.Checksum3" />, since they are not /// used when testing for equality. /// </remarks> public override int GetHashCode() { int hash = 13; int mul = 7; hash = (hash * mul) + base.GetHashCode(); hash = (hash * mul) + Time.GetHashCode(); hash = (hash * mul) + AccelerationX.GetHashCode(); hash = (hash * mul) + AccelerationY.GetHashCode(); hash = (hash * mul) + AccelerationZ.GetHashCode(); hash = (hash * mul) + AngularRateX.GetHashCode(); hash = (hash * mul) + AngularRateY.GetHashCode(); hash = (hash * mul) + AngularRateZ.GetHashCode(); hash = (hash * mul) + Latitude.GetHashCode(); hash = (hash * mul) + Longitude.GetHashCode(); hash = (hash * mul) + Altitude.GetHashCode(); hash = (hash * mul) + NorthVelocity.GetHashCode(); hash = (hash * mul) + EastVelocity.GetHashCode(); hash = (hash * mul) + DownVelocity.GetHashCode(); hash = (hash * mul) + Heading.GetHashCode(); hash = (hash * mul) + Pitch.GetHashCode(); hash = (hash * mul) + Roll.GetHashCode(); hash = (hash * mul) + (StatusChannel != null ? StatusChannel.GetHashCode() : 0); return(hash); }
/// <summary> /// /// </summary> /// <returns></returns> public StatusChannel GatherStatusInformation( ) { StatusChannel sc = new StatusChannel( ); sc.Name = this.Name; lock (this) { sc.QueueCount = this.Queue.Count; sc.Queue = this.Queue.ToArray( ); } sc.CurrentFlowManifest = this.CurrentFlowManifest; lock (this) { foreach (TTransparentFlow transparentFlow in this.Flows) { sc.Flows.Add(transparentFlow.GatherStatusInformation( )); } } return(sc); }
public void ClearStatus(StatusChannel channel) { int intChannel = (int)channel; if ((intChannel >= 0) && (intChannel < m_maxChannels)) { m_statusTexts[intChannel] = String.Empty; m_statusTypes[intChannel] = StatusType.Ok; } }
public void SetStatus(StatusChannel channel, String text, StatusType type) { int intChannel = (int)channel; if ((intChannel >= 0) && (intChannel < m_maxChannels)) { m_statusTexts[intChannel] = text; m_statusTypes[intChannel] = type; } }
public StatusConnectionHandler(EnvironmentValidatorRepository repo) : base("^/status", "GET") { _statusChannel = new StatusChannel(repo); }
/// <summary> /// Marshals this <see cref="NcomPacketA"/> into a byte array of length /// <see cref="NcomPacket.PacketLength"/>. /// </summary> /// <returns> /// A <see cref="byte"/> array of length equal to <see cref="NcomPacket.PacketLength"/>. /// </returns> public override byte[] Marshal() { // Call base method to get byte array to marshal into byte[] buffer = base.Marshal(); int offset = 1; // Batch A // -------- // Insert Time ByteHandling.Marshal(buffer, ref offset, (ushort)(Time % MaxTimeValue)); // Insert accelerations ByteHandling.MarshalInt24(buffer, ref offset, (int)(AccelerationX / AccelerationScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(AccelerationY / AccelerationScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(AccelerationZ / AccelerationScaling)); // Insert Angular Rates ByteHandling.MarshalInt24(buffer, ref offset, (int)(AngularRateX / AngularRateScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(AngularRateY / AngularRateScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(AngularRateZ / AngularRateScaling)); // Skip over nav. status offset++; // Calculate and insert Checksum 1 buffer[offset] = CalculateChecksum(buffer, 1, offset - 2); offset++; // Batch B // -------- // Insert Latitude, Longitude and altitude ByteHandling.Marshal(buffer, ref offset, Latitude); ByteHandling.Marshal(buffer, ref offset, Longitude); ByteHandling.Marshal(buffer, ref offset, Altitude); // Insert Velocities ByteHandling.MarshalInt24(buffer, ref offset, (int)(NorthVelocity / VeloityScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(EastVelocity / VeloityScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(DownVelocity / VeloityScaling)); // Insert Heading, Pitch and Roll ByteHandling.MarshalInt24(buffer, ref offset, (int)(Heading / OrientationScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(Pitch / OrientationScaling)); ByteHandling.MarshalInt24(buffer, ref offset, (int)(Roll / OrientationScaling)); // Calculate and insert Checksum 2 buffer[offset] = CalculateChecksum(buffer, 1, offset - 2); offset++; // Batch S // -------- // Insert Status Channel if (StatusChannel != null) { buffer[offset++] = StatusChannel.StatusChannelByte; StatusChannel.Marshal(buffer, ref offset); } else { buffer[offset++] = 0xFF; offset += StatusChannelLength; } // Calculate and insert Checksum 3 buffer[offset] = CalculateChecksum(buffer, 1, offset - 2); // Return the marshalled NCOM packet return(buffer); }