From 75a893f51fb7d6508741e0938535b170252e5d20 Mon Sep 17 00:00:00 2001 From: Peter Butzhammer Date: Tue, 30 Jul 2024 12:24:01 +0200 Subject: [PATCH] Add Sharp7Plc.ToString() --- Sharp7.Rx/Sharp7Connector.cs | 1 + Sharp7.Rx/Sharp7Plc.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Sharp7.Rx/Sharp7Connector.cs b/Sharp7.Rx/Sharp7Connector.cs index 78c911f..51991e3 100644 --- a/Sharp7.Rx/Sharp7Connector.cs +++ b/Sharp7.Rx/Sharp7Connector.cs @@ -40,6 +40,7 @@ internal class Sharp7Connector : IDisposable } public IObservable ConnectionState => connectionStateSubject.DistinctUntilChanged().AsObservable(); + public ConnectionState CurrentConnectionState => connectionStateSubject.Value; public ILogger Logger { get; set; } diff --git a/Sharp7.Rx/Sharp7Plc.cs b/Sharp7.Rx/Sharp7Plc.cs index e77d51b..8cea1e7 100644 --- a/Sharp7.Rx/Sharp7Plc.cs +++ b/Sharp7.Rx/Sharp7Plc.cs @@ -240,6 +240,8 @@ public class Sharp7Plc : IPlc .ToTask(token); } + public override string ToString() => $"S7 {s7Connector} ({s7Connector.CurrentConnectionState})"; + /// /// Initialize PLC and trigger connection. This method will not wait for the connection to be established. ///