/* * Date Sign TaskId Description * ---------- ---- ------- ----------- * 2006-07-31 RMa Added Debug ToString methods. * 2006-03-02 RMa Supply DeviceConnectionState in ConnectionChangedEventArgs instead of bool connected. * 2006-02-13 MLa This header added */ using System; namespace Wayne.Lib { /// /// Event arguments for a connection changed event from a Wayne Device. /// public sealed class ConnectionChangedEventArgs : EventArgs { #region Fields private DeviceConnectionState connectionState; #endregion #region Construction /// /// Constructor /// /// The new state of the connection public ConnectionChangedEventArgs(DeviceConnectionState connectionState) { this.connectionState = connectionState; } #endregion #region Properties /// /// True if the device was connected. /// public DeviceConnectionState ConnectionState { get { return connectionState; } } #endregion #region Debug methods /// /// Presents the class as a string. /// /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "format")] public string ToString(string format, IFormatProvider provider) { return string.Format(provider, "ConnectionChange ({0})", connectionState); } /// /// Presents the class as a string using the specified culture-specific format information. /// /// public string ToString(IFormatProvider provider) { return ToString("", provider); } /// /// Presents the class as a string using a format string. /// /// public string ToString(string format) { return ToString(format, System.Globalization.CultureInfo.InvariantCulture); } /// /// Presents the class as a string using a format string and the specified culture-specific format information. /// /// public override string ToString() { return ToString("", System.Globalization.CultureInfo.InvariantCulture); } #endregion } /// /// The state of the connection to a device. /// public enum DeviceConnectionState { #region Fields /// /// Unknown state of the connection. /// Unknown, /// /// Device is not connected. /// Disconnected, /// /// Trying to connect to device. /// Connecting, /// /// Connected to device. /// Connected, /// /// Disconnecting from device /// Disconnecting #endregion } /// /// The IConnectable defines a standard set of methods and properties for /// classes that represents devices that theoretically can have a connected/disconnected state. /// public interface IConnectable { #region Properties /// /// Indicates the state of the connection. /// DeviceConnectionState ConnectionState { get; } #endregion #region Methods /// /// Connect to the device. /// /// A string that contains the connection parameters. /// The format is provided by the implementation. void Connect(string connectionString); /// /// Disconnects from the device. /// void Disconnect(); #endregion #region Events /// /// An event that is fired when the ConnectionState changes for to device. /// event EventHandler OnConnectionStateChange; #endregion } }