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

Make IsConnected an abstract member of ModbusClient #115

Merged
merged 1 commit into from
Apr 23, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/FluentModbus/Client/ModbusClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public abstract partial class ModbusClient
{
#region Properties

/// <summary>
/// Gets the connection status of the underlying client.
/// </summary>
public abstract bool IsConnected { get; }

protected private bool SwapBytes { get; set; }

#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/FluentModbus/Client/ModbusRtuClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ModbusRtuClient()
/// <summary>
/// Gets the connection status of the underlying serial port.
/// </summary>
public bool IsConnected => _serialPort?.Value.IsOpen ?? false;
public override bool IsConnected => _serialPort?.Value.IsOpen ?? false;

/// <summary>
/// Gets or sets the serial baud rate. Default is 9600.
Expand Down
10 changes: 5 additions & 5 deletions src/FluentModbus/Client/ModbusTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public ModbusTcpClient()

#region Properties

/// <summary>
/// Gets the connection status of the underlying TCP client.
/// </summary>
public override bool IsConnected => _tcpClient?.Value.Connected ?? false;

/// <summary>
/// Gets or sets the connect timeout in milliseconds. Default is 1000 ms.
/// </summary>
Expand All @@ -56,11 +61,6 @@ public ModbusTcpClient()

#region Methods

/// <summary>
/// Gets the connection status of the underlying TCP client.
/// </summary>
public bool IsConnected => _tcpClient?.Value.Connected ?? false;

/// <summary>
/// Connect to localhost at port 502 with <see cref="ModbusEndianness.LittleEndian"/> as default byte layout.
/// </summary>
Expand Down