Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readline, ConnectionStatusChange Specification #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions SerialPortLib/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ limitations under the License.

using System;

namespace SerialPortLib
{
namespace SerialPortLib {

public enum ConnectionEventType {
Disconnected,
DisconnectWithRetry,
Connected
}

/// <summary>
/// Connected state changed event arguments.
Expand All @@ -35,14 +40,24 @@ public class ConnectionStatusChangedEventArgs
/// The connected state.
/// </summary>
public readonly bool Connected;

/// <summary>
/// Message
/// </summary>
public readonly ConnectionEventType ConnectionEventType;

/// <summary>
/// Initializes a new instance of the <see cref="SerialPortLib.ConnectionStatusChangedEventArgs"/> class.
/// </summary>
/// <param name="state">State of the connection (true = connected, false = not connected).</param>
public ConnectionStatusChangedEventArgs(bool state)
{
/// <param name="connectionEventType">Details on the state of the connection:
/// Disconnected=The connection has been lost and the library will not attempt to reconnect,
/// DisconnectWithRetry=The connection has been lost and the library will attempt to reconnect,
/// Connected=The connection has been established
/// </param>
public ConnectionStatusChangedEventArgs(bool state, ConnectionEventType connectionEventType) {
Connected = state;
ConnectionEventType = connectionEventType;
}
}

Expand All @@ -65,5 +80,25 @@ public MessageReceivedEventArgs(byte[] data)
Data = data;
}
}

/// <summary>
/// Message received event arguments from ReadLine.
/// </summary>
public class MessageReceivedLineEventArgs
{
/// <summary>
/// The line string.
/// </summary>
public readonly string Data;

/// <summary>
/// Initializes a new instance of the <see cref="SerialPortLib.MessageReceivedEventArgs"/> class.
/// </summary>
/// <param name="line"></param>
public MessageReceivedLineEventArgs(string Line)
{
Data =Line;
}
}
}

Loading