https://github.com/chrispulman/s7plcrx
S7PlcRx is a comprehensive, production-ready reactive library for communicating with Siemens S7 PLCs. Built on Reactive Extensions (Rx.NET), it provides real-time data streaming, advanced performance optimizations, enterprise-grade reliability, and comprehensive industrial automation features.
https://github.com/chrispulman/s7plcrx
plc-programming reactive s7-plc siemens
Last synced: about 2 months ago
JSON representation
S7PlcRx is a comprehensive, production-ready reactive library for communicating with Siemens S7 PLCs. Built on Reactive Extensions (Rx.NET), it provides real-time data streaming, advanced performance optimizations, enterprise-grade reliability, and comprehensive industrial automation features.
- Host: GitHub
- URL: https://github.com/chrispulman/s7plcrx
- Owner: ChrisPulman
- License: mit
- Created: 2022-07-25T20:12:00.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-04-18T22:27:52.000Z (about 2 months ago)
- Last Synced: 2026-04-19T00:32:44.839Z (about 2 months ago)
- Topics: plc-programming, reactive, s7-plc, siemens
- Language: C#
- Homepage:
- Size: 15 MB
- Stars: 21
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
 [](https://github.com/ChrisPulman/S7PlcRx/actions/workflows/BuildOnly.yml)  [](https://www.nuget.org/packages/S7PlcRx)
# S7PlcRx
Reactive Siemens S7 PLC communication for .NET. S7PlcRx provides tag-based S7 reads/writes, Rx observables, optimized batch helpers, caching, diagnostics, production reliability helpers, high-availability helpers, PLC byte conversion utilities, and source-generator assisted property bindings.
> Siemens and S7 are trademarks of Siemens AG. This project is independent and is not affiliated with or endorsed by Siemens AG. Test all automation code against a simulator or safe test rig before using production equipment.
## Contents
- [Supported PLCs and frameworks](#supported-plcs-and-frameworks)
- [PLC prerequisites](#plc-prerequisites)
- [Installation](#installation)
- [Quick start](#quick-start)
- [Addressing and data types](#addressing-and-data-types)
- [Core tag API](#core-tag-api)
- [Reactive reading](#reactive-reading)
- [Manual reads and writes](#manual-reads-and-writes)
- [Batch, async, and optimized APIs](#batch-async-and-optimized-apis)
- [Source generator property binding](#source-generator-property-binding)
- [Performance and cache features](#performance-and-cache-features)
- [Enterprise features](#enterprise-features)
- [Production reliability and diagnostics](#production-reliability-and-diagnostics)
- [PLC type conversion helpers](#plc-type-conversion-helpers)
- [Public API reference](#public-api-reference)
- [Build and test](#build-and-test)
## Supported PLCs and frameworks
| PLC family | API |
|---|---|
| S7-1500 | `CpuType.S71500`, `S71500.Create(...)` |
| S7-1200 | `CpuType.S71200`, `S71200.Create(...)` |
| S7-400 | `CpuType.S7400`, `S7400.Create(...)` |
| S7-300 | `CpuType.S7300`, `S7300.Create(...)` |
| S7-200 | `CpuType.S7200`, `S7200.Create(...)` |
| Logo 0BA8 | enum support where supported by the protocol path |
`S7PlcRx` targets `net462`, `net472`, `net481`, `net8.0`, `net9.0`, and `net10.0`.
`S7PlcRx.SourceGenerators` targets `netstandard2.0` and runs as a Roslyn analyzer/source generator.
## PLC prerequisites
For absolute DB addressing such as `DB1.DBD0` on modern Siemens CPUs:
1. Enable PUT/GET communication.
2. Use non-optimized DB layout for directly addressed DBs.
3. Confirm IP address, rack, and slot.
4. Keep write tests away from live actuators until proven safe.
5. For source-generated byte-array batching, place related tags in the same DB and adjacent byte ranges.
## Installation
```powershell
Install-Package S7PlcRx
```
```bash
dotnet add package S7PlcRx
```
Repository/analyzer usage for the source generator:
```xml
```
## Quick start
```csharp
using System.Reactive.Linq;
using S7PlcRx;
using S7PlcRx.Enums;
using var plc = new RxS7(CpuType.S71500, "192.168.1.100", rack: 0, slot: 1, interval: 100);
plc.AddUpdateTagItem("Temperature", "DB1.DBD0");
plc.AddUpdateTagItem("Running", "DB1.DBX4.0");
plc.AddUpdateTagItem("TemperatureSetPoint", "DB1.DBD8");
using var connected = plc.IsConnected
.DistinctUntilChanged()
.Subscribe(x => Console.WriteLine($"Connected: {x}"));
using var temperature = plc.Observe("Temperature")
.Where(x => x.HasValue)
.Subscribe(x => Console.WriteLine($"Temperature: {x:F1} °C"));
plc.Value("TemperatureSetPoint", 72.5f);
```
Factory equivalent:
```csharp
using IRxS7 plc = S71500.Create("192.168.1.100", rack: 0, slot: 1, interval: 100);
```
## Addressing and data types
| Area | Examples | Notes |
|---|---|---|
| DB bit | `DB1.DBX0.0`, `DB1.DBX4.7` | Bit index must be 0-7. |
| DB byte | `DB1.DBB0` | `byte`, `byte[]`, generated raw ranges. |
| DB word | `DB1.DBW2` | `short`, `ushort`. |
| DB double word | `DB1.DBD4` | `int`, `uint`, `float`; `double` uses 8 bytes from the start offset. |
| Inputs | `I0.0`, `IB0`, `IW0`, `ID0`; `E` aliases | Input area. |
| Outputs | `Q0.0`, `QB0`, `QW0`, `QD0`; `A` aliases | Output area. |
| Memory | `M0.0`, `MB0`, `MW0`, `MD0` | Marker memory. |
| Timers | `T1` | S7 timers. |
| Counters | `C1`, `Z1` | S7 counters. |
| S7 representation | C# type | Address example | Bytes |
|---|---:|---|---:|
| BOOL | `bool` | `DB1.DBX0.0` | bit in byte |
| BYTE | `byte` | `DB1.DBB1` | 1 |
| BYTE array | `byte[]` | `DB1.DBB100`, `arrayLength: 64` | length |
| INT | `short` | `DB1.DBW2` | 2 |
| WORD | `ushort` | `DB1.DBW4` | 2 |
| DINT | `int` | `DB1.DBD6` | 4 |
| DWORD | `uint` | `DB1.DBD10` | 4 |
| REAL | `float` | `DB1.DBD14` | 4 |
| LREAL | `double` | `DB1.DBD18` | 8 |
| STRING | `string` | `DB1.DBB40` | variable |
| Arrays | `short[]`, `ushort[]`, `int[]`, `uint[]`, `float[]`, `double[]` | first element address plus `arrayLength` | element size x length |
## Core tag API
Register tags:
```csharp
plc.AddUpdateTagItem("Temperature", "DB1.DBD0");
plc.AddUpdateTagItem("Running", "DB1.DBX4.0");
plc.AddUpdateTagItem("RecipeBytes", "DB10.DBB0", arrayLength: 64);
plc.AddUpdateTagItem("Curve", "DB20.DBD0", arrayLength: 16);
```
Fluent registration and polling control:
```csharp
plc.AddUpdateTagItem("Temp1", "DB1.DBD0")
.AddUpdateTagItem("Temp2", "DB1.DBD4")
.AddUpdateTagItem("Alarm", "DB1.DBX8.0")
.SetTagPollIng(false); // disables polling on the last tag
plc.GetTag("Temp1").SetTagPollIng(false);
plc.GetTag("Temp1").SetTagPollIng(true);
plc.RemoveTagItem("Temp1");
```
Tag stream projections:
```csharp
using S7PlcRx;
using var dictionary = plc.ObserveAll
.TagToDictionary()
.Subscribe(values => Console.WriteLine(values.Count));
using var namedValue = plc.Observe("Temperature")
.ToTagValue("Temperature")
.Subscribe(item => Console.WriteLine($"{item.Tag}={item.Value}"));
```
## Reactive reading
```csharp
using System.Reactive.Linq;
using var highTemp = plc.Observe("Temperature")
.Where(x => x > 80.0f)
.Subscribe(x => Console.WriteLine($"High temperature: {x:F1}"));
using var sampledPressure = plc.Observe("Pressure")
.Sample(TimeSpan.FromSeconds(5))
.Subscribe(x => Console.WriteLine($"Pressure: {x:F2}"));
using var averageFlow = plc.Observe("FlowRate")
.Buffer(TimeSpan.FromMinutes(1))
.Where(values => values.Count > 0)
.Select(values => values.Average())
.Subscribe(avg => Console.WriteLine($"Average flow: {avg:F2}"));
```
Connection and diagnostic streams:
```csharp
plc.IsConnected.Subscribe(x => Console.WriteLine($"Connected: {x}"));
plc.LastError.Subscribe(Console.WriteLine);
plc.LastErrorCode.Subscribe(code => Console.WriteLine($"Error code: {code}"));
plc.Status.Subscribe(Console.WriteLine);
plc.IsPaused.Subscribe(paused => Console.WriteLine($"Paused: {paused}"));
plc.ReadTime.Subscribe(ticks => Console.WriteLine($"Read ticks: {ticks}"));
```
CPU information:
```csharp
using System.Reactive.Linq;
var cpuInfo = await plc.GetCpuInfo().FirstAsync();
Console.WriteLine($"AS name: {cpuInfo[0]}, Module: {cpuInfo[1]}");
```
## Manual reads and writes
```csharp
var temperature = await plc.Value("Temperature");
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2));
var pressure = await plc.ValueAsync("Pressure", cts.Token);
plc.Value("SetPoint", 72.5f);
plc.Value("Enabled", true);
plc.Value("RecipeNumber", (short)12);
plc.Value("RecipeBytes", new byte[] { 0x01, 0x02, 0x03 });
```
Watchdog:
```csharp
using var plcWithWatchdog = new RxS7(
CpuType.S71500,
"192.168.1.100",
rack: 0,
slot: 1,
watchDogAddress: "DB100.DBW0",
interval: 100,
watchDogValueToWrite: 4500,
watchDogInterval: 10);
plcWithWatchdog.ShowWatchDogWriting = true;
```
## Batch, async, and optimized APIs
Advanced batch helpers:
```csharp
using S7PlcRx.Advanced;
var values = await plc.ValueBatch("Temp1", "Temp2", "Temp3");
await plc.ValueBatch(new Dictionary
{
["SetPoint1"] = 70.0f,
["SetPoint2"] = 75.0f,
});
using var batchSub = plc.ObserveBatch("Temp1", "Temp2")
.Subscribe(snapshot => Console.WriteLine(snapshot.Count));
```
Dictionary batch helpers:
```csharp
var tagMap = new Dictionary
{
["Temperature"] = "DB1.DBD0",
["Pressure"] = "DB1.DBD4",
};
var read = await plc.ReadBatchOptimized(tagMap, timeoutMs: 5000);
var write = await plc.WriteBatchOptimized(
new Dictionary { ["Temperature"] = 22.5f },
verifyWrites: false,
enableRollback: false);
```
Async-first `ValueTask` helpers:
```csharp
using S7PlcRx.Advanced;
var current = await plc.ReadValueAsync("Temperature");
var many = await plc.ReadValuesAsync("Temp1", "Temp2");
await plc.WriteValuesAsync(new Dictionary
{
["SetPoint1"] = 72.5f,
["SetPoint2"] = 73.0f,
});
```
.NET 8+ async observable helpers:
```csharp
using ReactiveUI.Extensions.Async;
using S7PlcRx.Advanced;
await using var sub = await plc.ObserveValueAsync("Temperature")
.SubscribeAsync(
async (value, cancellationToken) =>
{
Console.WriteLine($"Async temperature: {value}" );
await Task.CompletedTask;
},
CancellationToken.None);
```
## Source generator property binding
`S7PlcRx.SourceGenerators` generates PLC-bound properties from attributes. It removes repetitive tag registration, polling assignment, and setter write hooks.
### Generated compile-time attributes
The generator injects this namespace into the consuming compilation:
```csharp
namespace S7PlcRx.SourceGeneration;
[AttributeUsage(AttributeTargets.Class)]
public sealed class S7PlcBindingAttribute : Attribute;
[AttributeUsage(AttributeTargets.Property)]
public sealed class S7TagAttribute : Attribute
{
public S7TagAttribute(string address);
public string Address { get; }
public int PollIntervalMs { get; set; } = 100;
public S7TagDirection Direction { get; set; } = S7TagDirection.ReadWrite;
public int ArrayLength { get; set; } = 1;
}
public enum S7TagDirection
{
ReadWrite,
ReadOnly,
WriteOnly
}
```
### Generated binding example
```csharp
using S7PlcRx;
using S7PlcRx.SourceGeneration;
[S7PlcBinding]
public partial class MachineTags
{
[S7Tag("DB1.DBD0", PollIntervalMs = 100)]
public partial float Temperature { get; set; }
[S7Tag("DB1.DBX4.0", PollIntervalMs = 100)]
public partial bool Running { get; set; }
[S7Tag("DB1.DBW6", PollIntervalMs = 250, Direction = S7TagDirection.ReadOnly)]
public partial short ActualSpeed { get; set; }
[S7Tag("DB1.DBD8", Direction = S7TagDirection.WriteOnly)]
public partial float SetPoint { get; set; }
}
using var plc = S71500.Create("192.168.1.100");
var tags = new MachineTags();
using var binding = tags.Bind(plc);
tags.SetPoint = 72.5f; // queues a PLC write
```
### Generator rules and behavior
- The class must be `partial` and marked with `[S7PlcBinding]`.
- Each bound property must be `partial` and marked with `[S7Tag("...")]`.
- The generator emits backing fields, property implementations, a write hook, a read-apply hook, and `IDisposable Bind(IRxS7 plc)`.
- Property setters call the runtime write hook when the value changes.
- PLC reads update backing fields without creating write-back loops.
- `PollIntervalMs > 0` enables interval reads; `PollIntervalMs = 0` disables interval reads.
- `ReadOnly` disables property writes; `WriteOnly` disables interval reads; `ReadWrite` enables both.
- `ArrayLength` defines array/string/byte range length.
- Generated byte-array batching supports DB addresses: `DBX`, `DBB`, `DBW`, `DBD`.
### Efficient byte-array DB grouping
For same-DB nearby tags, the runtime reads one DB byte range and decodes properties locally:
```text
DB1.DBD0 Temperature float bytes 0..3
DB1.DBD4 Pressure float bytes 4..7
DB1.DBX8.0 Running bool byte 8 bit 0
```
Runtime range tag:
```csharp
plc.AddUpdateTagItem("__s7_binding_db1_0_9", "DB1.DBB0", arrayLength: 9);
```
Writes are coalesced on a short flush timer. The runtime performs read-modify-write byte-array writes so unrelated bytes/bits in the same range are preserved.
### Manual runtime binding API
```csharp
using S7PlcRx.Binding;
var definitions = new[]
{
new S7TagDefinition("Temperature", "DB1.DBD0", typeof(float), 100, S7TagDirection.ReadWrite),
new S7TagDefinition("Running", "DB1.DBX4.0", typeof(bool), 100, S7TagDirection.ReadWrite),
};
using var runtime = S7TagRuntimeBinding.Bind(
plc,
definitions,
(name, value) => Console.WriteLine($"{name}={value}"));
runtime.Write("Temperature", 25.5f);
```
## Performance and cache features
```csharp
using S7PlcRx.Optimization;
using S7PlcRx.Performance;
var cached = await plc.ValueCached("Temperature", TimeSpan.FromSeconds(1));
var cacheStats = plc.GetCacheStatistics();
plc.ClearCache("Temperature");
using var smart = plc.MonitorTagSmart("Temperature", changeThreshold: 0.5, debounceMs: 100)
.Subscribe(change => Console.WriteLine($"{change.TagName}: {change.PreviousValue} -> {change.CurrentValue}"));
using var perf = plc.MonitorPerformance(TimeSpan.FromSeconds(30))
.Subscribe(metrics => Console.WriteLine($"{metrics.OperationsPerSecond:F1} ops/sec"));
var optimizedReads = await plc.ReadOptimized(new[] { "Temp1", "Temp2" });
var optimizedWrite = await plc.WriteOptimized(new Dictionary
{
["SetPoint1"] = 72.5f,
["SetPoint2"] = 73.0f,
});
var benchmark = await plc.RunBenchmark(new BenchmarkConfig
{
LatencyTestCount = 10,
ThroughputTestDuration = TimeSpan.FromSeconds(10),
ReliabilityTestCount = 20,
});
var stats = plc.GetPerformanceStatistics();
```
High-performance tag groups:
```csharp
using S7PlcRx.Advanced;
using S7PlcRx.Performance;
using var group = plc.CreateTagGroup("Process", "Temperature", "Pressure", "Flow");
using var groupSub = group.ObserveGroup().Subscribe(snapshot => Console.WriteLine(snapshot.Count));
var allValues = await group.ReadAll();
await group.WriteAll(new Dictionary
{
["Temperature"] = 21.0f,
["Pressure"] = 1.2f,
});
```
## Enterprise features
Symbol tables:
```csharp
using S7PlcRx.Enterprise;
var csv = """
Name,Address,DataType,Length,Description
Temperature,DB1.DBD0,REAL,1,Process temperature
Running,DB1.DBX4.0,BOOL,1,Machine running
Recipe,DB10.DBB0,ARRAY,64,Recipe bytes
""";
var table = await plc.LoadSymbolTable(csv, SymbolTableFormat.Csv);
var temperature = await plc.ReadSymbol("Temperature");
plc.WriteSymbol("Running", true);
```
High availability:
```csharp
using S7PlcRx.Enterprise;
using var primary = S71500.Create("192.168.1.100");
var backups = new List
{
S71500.Create("192.168.1.101"),
S71500.Create("192.168.1.102"),
};
using var ha = EnterpriseExtensions.CreateHighAvailabilityConnection(primary, backups, TimeSpan.FromSeconds(10));
using var failoverSub = ha.FailoverEvents.Subscribe(evt => Console.WriteLine(evt.Reason));
IRxS7 active = ha.ActivePLC;
await ha.TriggerFailover();
```
Connection pool:
```csharp
using S7PlcRx.Core;
using S7PlcRx.Enterprise;
using S7PlcRx.Enums;
using var pool = EnterpriseExtensions.CreateConnectionPool(
new[]
{
new PlcConnectionConfig
{
PLCType = CpuType.S71500,
IPAddress = "192.168.1.100",
Rack = 0,
Slot = 1,
ConnectionName = "Line1Primary",
},
},
new ConnectionPoolConfig
{
MaxConnections = 10,
EnableConnectionReuse = true,
HealthCheckInterval = TimeSpan.FromMinutes(1),
});
IRxS7 connection = pool.GetConnection;
```
## Production reliability and diagnostics
```csharp
using S7PlcRx.Advanced;
using S7PlcRx.Production;
var diagnostics = await plc.GetDiagnostics();
Console.WriteLine($"Connected: {diagnostics.IsConnected}, latency: {diagnostics.ConnectionLatencyMs:F0} ms");
var analysis = await plc.AnalyzePerformance(TimeSpan.FromMinutes(5));
Console.WriteLine($"Total changes: {analysis.TotalTagChanges}" );
var validation = await plc.ValidateProductionReadiness(new ProductionValidationConfig
{
MaxAcceptableResponseTime = TimeSpan.FromMilliseconds(500),
MinimumReliabilityRate = 0.95,
ReliabilityTestCount = 10,
MinimumProductionScore = 80.0,
});
var result = await plc.ExecuteWithErrorHandling(
() => plc.Value("CriticalSensor"),
new ProductionErrorConfig
{
MaxRetryAttempts = 3,
BaseRetryDelayMs = 1000,
UseExponentialBackoff = true,
CircuitBreakerThreshold = 5,
CircuitBreakerTimeout = TimeSpan.FromMinutes(1),
});
var handler = plc.EnableProductionErrorHandling(new ProductionErrorConfig());
var guarded = await handler.ExecuteAsync(() => plc.Value("Temperature"));
```
## PLC type conversion helpers
All conversion helpers use Siemens S7 byte ordering and are useful for codecs, tests, and generated/runtime byte-array binding logic.
| Type/helper | Purpose | Common functions |
|---|---|---|
| `Bit` | Bit extraction/mutation from byte spans | `FromByte`, `FromSpan`, `ToBitArray`, `SetBit`, `GetBits`, `SetBits` |
| `Boolean` | Single byte bit helpers | `GetValue`, `SetBit`, `ClearBit` |
| `Byte` | Byte conversion | `ToByteArray`, `ToSpan`, `FromByteArray`, `FromSpan` |
| `ByteArray` | Growable pooled byte buffer | `Add`, `Clear`, `TryCopyTo`, `Span`, `Memory`, `Array`, `Length` |
| `Int` / `Word` | 16-bit signed/unsigned | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `DInt` / `DWord` | 32-bit signed/unsigned | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `Real` / `LReal` | 32/64-bit floating point | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `Counter` / `Timer` | S7 counter/timer formats | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `DateTime` / `DateTimeLong` | S7 date/time formats | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `TimeSpan` | S7 time span conversion | `FromByteArray`, `FromSpan`, `ToArray`, `ToByteArray`, `ToSpan` |
| `String`, `S7String`, `S7WString` | String encodings | `FromByteArray`, `FromSpan`, `ToByteArray`, `ToSpan`, `TryToSpan` |
| `Struct`, `Class` | Reflection-based complex type conversion | `GetStructSize`/`GetClassSize`, `FromBytes`, `ToBytes` |
```csharp
using S7PlcRx.PlcTypes;
Span bytes = stackalloc byte[4];
Real.ToSpan(12.5f, bytes);
float roundTrip = Real.FromSpan(bytes);
```
## Error handling
```csharp
plc.LastError.Subscribe(message => Console.WriteLine(message));
plc.LastErrorCode.Subscribe(code => Console.WriteLine(code));
```
- `PlcException` carries an `ErrorCode` for PLC communication failures.
- `S7Exception` is a general S7 exception type.
- `TagAddressOutOfRangeException` is thrown for invalid tag addresses.
- Production error handling adds retries and circuit-breaker behavior.
## Public API reference
This section is generated from the public C# surface in `src/S7PlcRx` and `src/S7PlcRx.SourceGenerators`, then paired with the usage guidance above. It is intended to make this README a single documentation source for the repository.
### Source generator generated API
The source generator emits these compile-time-only types into consumer projects:
- `S7PlcRx.SourceGeneration.S7PlcBindingAttribute` — marks a `partial class` for PLC property binding generation.
- `S7PlcRx.SourceGeneration.S7TagAttribute` — marks a `partial` property with an S7 address; properties: `Address`, `PollIntervalMs`, `Direction`, `ArrayLength`.
- `S7PlcRx.SourceGeneration.S7TagDirection` — `ReadWrite`, `ReadOnly`, `WriteOnly`.
- Generated instance method: `public IDisposable Bind(IRxS7 plc)` on each `[S7PlcBinding]` class.
### Runtime public surface
All public types and members
#### Namespace `S7PlcRx`
##### `S7PlcRx.IRxS7`
Source: `IRxS7.cs:19`
Defines an interface for reactive communication with a Siemens S7 PLC, providing observable access to connection status, errors, tag values, and PLC information, as well as methods for reading and writing variables asynchronously. The IRxS7 interface exposes members for monitoring and interacting with a PLC in a reactive manner using observables. It supports observing connection state, errors, and tag values, as well as reading and writing variables with optional cancellation support. Implementations are expected to handle connection management and provide up-to-date PLC information. Thread safety and subscription management depend on the specific implementation.
| Member | Summary |
|---|---|
| `public string IP get; }` | Gets the IP address associated with the current instance. |
| `public IObservable IsConnected get; }` | Gets an observable sequence that indicates whether the connection is currently established. Subscribers receive updates whenever the connection state changes. The sequence emits when connected and when disconnected. |
| `public bool IsConnectedValue get; }` | Gets a value indicating whether the connection is currently established. |
| `public IObservable LastError get; }` | Gets an observable sequence that provides error messages encountered during operation. Subscribers receive error messages as they occur. The sequence completes when the underlying process completes or is disposed. No errors are pushed after completion. |
| `public IObservable LastErrorCode get; }` | Gets an observable sequence that provides notifications of the most recent error code encountered by the component. Subscribers receive updates whenever a new error occurs. The sequence completes when the component is disposed or no longer reports errors. Thread safety and emission timing depend on the implementation of the observable. |
| `public IObservable ObserveAll get; }` | Gets an observable sequence that emits all tag updates as they occur. Subscribers receive notifications for every tag, including additions, updates, and removals. The sequence emits a value of when a tag is removed. |
| `public CpuType PLCType get; }` | Gets the type of programmable logic controller (PLC) associated with this instance. |
| `public short Rack get; }` | Gets the rack number associated with the device or connection. |
| `public short Slot get; }` | Gets the slot number associated with the current instance. |
| `public IObservable IsPaused get; }` | Gets an observable sequence that indicates whether the operation is currently paused. Subscribers receive a value of when the operation is paused and when it is active. The sequence emits updates whenever the paused state changes. |
| `public IObservable Status get; }` | Gets an observable sequence that provides status updates as strings. Subscribers receive status notifications as they occur. The sequence may complete or error depending on the underlying implementation. |
| `public Tags TagList get; }` | Gets the collection of tags associated with the current instance. |
| `public bool ShowWatchDogWriting get; set; }` | Gets or sets a value indicating whether WatchDog writing operations are displayed. |
| `public string? WatchDogAddress get; }` | Gets the network address of the WatchDog service, if configured. |
| `public ushort WatchDogValueToWrite get; set; }` | Gets or sets the value to be written to the watchdog register. |
| `public int WatchDogWritingTime get; }` | Gets the time interval, in milliseconds, used by the watchdog for writing operations. |
| `public IObservable ReadTime get; }` | Gets an observable sequence that provides the current read time in ticks. Subscribers receive updates whenever the read time changes. The value represents the number of ticks elapsed, where one tick equals 100 nanoseconds. |
| `public IObservable Observe(string? variable);` | Observes changes to the specified variable and returns a sequence of its values as they are updated. The type of the variable to observe. The name of the variable to observe. Can be null to observe the default variable, if applicable. An observable sequence that emits the current and subsequent values of the specified variable. The value is null if the variable does not exist or has not been set. |
| `public Task Value(string? variable);` | Asynchronously retrieves the value of the specified variable, if it exists. The type of the value to retrieve. The name of the variable whose value is to be retrieved. Can be null to indicate the default variable. A task that represents the asynchronous operation. The task result contains the value of the variable if found; otherwise, null. |
| `public Task ValueAsync(string? variable, CancellationToken cancellationToken);` | Asynchronously retrieves the value of the specified variable, if it exists. The type of the value to retrieve. The name of the variable to retrieve. Can be null to indicate the default variable, if supported. A cancellation token that can be used to cancel the asynchronous operation. A task that represents the asynchronous operation. The task result contains the value of the variable if found; otherwise, null. |
| `public void Value(string? variable, T? value);` | Sets the value of a variable with the specified name and value. The type of the value to assign to the variable. The name of the variable to set. Can be null to indicate an unnamed or default variable. The value to assign to the variable. Can be null if the variable type allows null values. |
| `public IObservable GetCpuInfo();` | Retrieves an observable sequence containing information about the system's CPU. Subscribers receive updates as the CPU information changes. The format and content of each string array may vary depending on the platform or implementation. An observable sequence of string arrays, where each array contains details about the CPU. The sequence emits new arrays when CPU information is updated. |
##### `S7PlcRx.ITag`
Source: `Tags/ITag.cs:9`
Represents a tag that can be configured to control polling behavior.
| Member | Summary |
|---|---|
| `public void SetDoNotPoll(bool value);` | Sets whether the object should be excluded from polling operations. true to prevent the object from being polled; otherwise, false. |
##### `S7PlcRx.PlcException`
Source: `PlcException.cs:16`
| Member | Summary |
|---|---|
| `public PlcException(ErrorCode errorCode) : this(errorCode, $"PLC communication failed with error '{errorCode}'.")` | Initializes a new instance of the class. The error code. |
| `public PlcException(ErrorCode errorCode, Exception? innerException) : this(errorCode, innerException?.Message, innerException)` | Initializes a new instance of the class. The error code. The inner exception. |
| `public PlcException(ErrorCode errorCode, string? message) : base(message) => ...` | Initializes a new instance of the class. The error code. The message. |
| `public PlcException(ErrorCode errorCode, string? message, Exception? inner) : base(message, inner) => ...` | Initializes a new instance of the class. The error code. The message. The inner. |
| `public ErrorCode ErrorCode get; }` | Gets the error code. The error code. |
##### `S7PlcRx.RxS7`
Source: `RxS7.cs:32`
Provides an observable, reactive interface for reading from and writing to Siemens S7 PLCs, supporting tag-based access, status monitoring, and asynchronous operations. The RxS7 class enables integration with Siemens S7 programmable logic controllers (PLCs) using a tag-based model and reactive programming patterns. It exposes observables for PLC data, connection status, errors, and operational metrics, allowing clients to subscribe to real-time updates. The class supports both synchronous and asynchronous read/write operations, as well as advanced features such as watchdog monitoring and batch variable access. Thread safety is maintained for concurrent operations. Dispose the instance when no longer needed to release resources and terminate background operations.
| Member | Summary |
|---|---|
| `public RxS7(CpuType type, string ip, short rack, short slot, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 10)` | Initializes a new instance of the class and establishes a connection to a Siemens S7 PLC with optional. watchdog monitoring and periodic tag reading. If a valid watchdog address is provided, the constructor enables periodic writing to the specified address to support external watchdog monitoring. Tag reading and connection status monitoring are started automatically upon construction. The type of the PLC CPU to connect to. The IP address of the PLC to connect to. The rack number of the PLC hardware configuration. The slot number of the PLC CPU module. The address of the watchdog tag in the PLC memory. Must be a DBW address or null to disable watchdog monitoring. The interval, in milliseconds, at which tag values are read from the PLC. Must be greater than 0. The value to write to the watchdog address during each watchdog cycle. The interval, in seconds, at which the watchdog value is written. Must be greater than 0 if watchdog monitoring is enabled. Thrown if watchDogAddress is provided and is not a valid DBW address. Thrown if watchDogInterval is less than 1 when watchdog monitoring is enabled. |
| `public IObservable ObserveAll => ...` | Gets an observable sequence that emits all tag updates as they occur. Each observer receives tag updates in real time as they are published. The sequence is shared among all subscribers, and subscriptions are managed automatically. Observers may receive null values if a tag is removed or unavailable. |
| `public IObservable IsPaused => ...` | Gets an observable sequence that indicates whether the operation is currently paused. The returned observable emits a value of when the operation enters a paused state, and when it resumes. Subscribers receive updates only when the paused state changes. The sequence is shared among all subscribers. |
| `public string IP get; }` | Gets the IP address associated with the current instance. |
| `public IObservable IsConnected get; }` | Gets an observable sequence that indicates whether the connection is currently established. Subscribers receive updates whenever the connection state changes. The sequence emits when connected and when disconnected. |
| `public bool IsConnectedValue get; private set; }` | Gets a value indicating whether the connection is currently established. |
| `public IObservable LastError => ...` | Gets an observable sequence that provides the most recent error messages encountered by the component. Subscribers receive error messages as they occur. The sequence is shared among all subscribers, and each subscriber receives messages from the point of subscription onward. |
| `public IObservable LastErrorCode => ...` | Gets an observable sequence that emits the most recent error code reported by the system. Subscribers receive updates whenever a new error code is reported. The sequence is shared among all subscribers and only remains active while there is at least one active subscription. |
| `public CpuType PLCType get; }` | Gets the type of PLC (Programmable Logic Controller) associated with this instance. |
| `public short Rack get; }` | Gets the rack number associated with the device or component. |
| `public bool ShowWatchDogWriting get; set; }` | Gets or sets a value indicating whether WatchDog writing output is displayed. |
| `public short Slot get; }` | Gets the slot number associated with this instance. |
| `public IObservable Status => ...` | Gets an observable sequence that provides status updates as strings. Subscribers receive status updates as they occur. The observable sequence is shared among all subscribers, and subscriptions are managed automatically. Status updates are pushed to observers in real time. |
| `public Tags TagList get; } = [];` | Gets the collection of tags associated with the current instance. |
| `public string? WatchDogAddress get; }` | Gets the network address of the WatchDog service, if configured. |
| `public ushort WatchDogValueToWrite get; set; } = 4500;` | Gets or sets the value to be written to the watchdog timer. |
| `public int WatchDogWritingTime get; } = 10;` | Gets the interval, in seconds, that the watchdog uses when writing status updates. |
| `public bool IsDisposed get; private set; }` | Gets a value indicating whether gets a value that indicates whether the object is disposed. |
| `public IObservable ReadTime => ...` | Gets an observable sequence that emits the current read time in ticks whenever a read operation occurs. The observable sequence is shared among all subscribers. Each subscriber receives notifications when a read operation is performed, with the value representing the read time in ticks. The sequence completes when the underlying source completes. |
| `public IObservable Observe(string? variable) => ...` | Returns an observable sequence that emits the current and future values of the specified variable, cast to the specified type. The returned observable is hot and shared among all subscribers. Subscribers receive the most recent value and all subsequent updates. If the variable does not exist or its value cannot be cast to the specified type, the observable emits null. The type to which the variable's value is cast in the observable sequence. The name of the variable to observe. If null, all variables are observed. An observable sequence of values of type T, or null if the variable's value is not present or cannot be cast to T. The sequence emits a new value each time the variable changes. |
| `public async Task Value(string? variable)` | Asynchronously retrieves the value of the specified variable, cast to the specified type, if available. If the variable's type is not known, it is set to the requested type before retrieving the value. The method waits for an internal pause condition to be met before proceeding. The type to which the variable's value is cast and returned. The name of the variable whose value is to be retrieved. Can be null. A value of type if the variable exists and can be cast to the specified type; otherwise, . |
| `public async Task ValueAsync(string? variable, CancellationToken cancellationToken)` | Asynchronously retrieves the value of the specified variable, pausing polling operations during the read. Polling is temporarily paused while the value is being read to ensure consistency. If no polling is active, the method may wait briefly before proceeding. The method is cancellation-friendly and will respond promptly to cancellation requests. The expected type of the variable's value to retrieve. The name of the variable whose value is to be retrieved. Cannot be null, empty, or consist only of white-space characters. A cancellation token that can be used to cancel the operation. A task that represents the asynchronous operation. The task result contains the value of the specified variable cast to type T, or the default value of T if the variable is not found or cannot be cast. Thrown if variable is null, empty, or consists only of white-space characters. Thrown if the operation is canceled via the cancellation token. |
| `public void Value(string? variable, T? value)` | Sets the value of the specified variable if it exists and the value is compatible with the variable's type. If the variable does not exist or the value is null, this method does nothing. The value is only set if its type matches the variable's expected type or if the type parameter is object. The type of the value to assign to the variable. The name of the variable whose value is to be set. Cannot be null. The value to assign to the variable. Must be compatible with the variable's type. |
| `public void Dispose()` | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
| `public IObservable GetCpuInfo() => ...` | Retrieves detailed information about the connected CPU as an observable sequence. The method waits until a connection is established before retrieving CPU information. If the required data is not immediately available, the method will retry until successful or until the subscription is disposed. The order and content of the returned string array correspond to specific CPU information fields. This method is intended for use in reactive programming scenarios where CPU information is needed asynchronously. An observable sequence that emits a string array containing CPU information fields, such as the AS name, module name, copyright, serial number, module type name, order code, and version numbers. The sequence completes after emitting the data. |
##### `S7PlcRx.S71200`
Source: `Create/S71200.cs:9`
Provides factory methods for creating connections to Siemens S7-1200 PLC devices.
| Member | Summary |
|---|---|
| `public static IRxS7 Create(string ip, short rack = 0, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 100)` | Creates a new instance of an S7 PLC connection with the specified configuration parameters. The IP address of the S7 PLC to connect to. The rack number of the PLC. Must be between 0 and 7. The default is 0. The address of the watchdog variable in the PLC memory. If null, the watchdog feature is disabled. The polling interval, in milliseconds, for reading data from the PLC. The default is 100 milliseconds. The value to write to the watchdog variable, if specified. The default is 4500. The interval, in milliseconds, at which the watchdog value is written. The default is 100 milliseconds. An object implementing the IRxS7 interface that represents the configured PLC connection. Thrown if the value of rack is less than 0 or greater than 7. |
##### `S7PlcRx.S71500`
Source: `Create/S71500.cs:9`
Provides factory methods for creating connections to Siemens S7-1500 PLC devices.
| Member | Summary |
|---|---|
| `public static IRxS7 Create(string ip, short rack = 0, short slot = 1, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 10)` | Creates a new instance of an S7 PLC client configured for the specified IP address, rack, slot, and optional watchdog monitoring. If is specified, the client will periodically write to the given address at the specified . This can be used to implement a heartbeat or keep-alive mechanism with the PLC. The IP address of the S7 PLC to connect to. The rack number of the PLC. Must be between 0 and 7. The slot number of the PLC CPU module. Must be between 1 and 31. The address of the watchdog variable in the PLC memory to monitor. If null, watchdog monitoring is disabled. The polling interval, in milliseconds, for communication with the PLC. Must be positive. The value to write to the watchdog variable when monitoring is enabled. The interval, in seconds, at which the watchdog value is written. Must be positive. An IRxS7 instance configured to communicate with the specified S7 PLC and optional watchdog monitoring. Thrown when the value of is not between 0 and 7, or is not between 1 and 31. |
##### `S7PlcRx.S7200`
Source: `Create/S7200.cs:9`
Provides factory methods for creating connections to Siemens S7-200 PLC devices.
| Member | Summary |
|---|---|
| `public static IRxS7 Create(string ip, short rack, short slot, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 100) => ...` | Creates a new instance of an S7-200 PLC client for communication over TCP/IP with optional watchdog monitoring. If a watchdog address is specified, the client will periodically write the specified value to the PLC at the given interval to support connection monitoring or fail-safe logic. Ensure that the PLC is configured to handle the watchdog mechanism as expected. The IP address of the S7-200 PLC to connect to. Cannot be null or empty. The rack number of the PLC CPU module. Typically 0 for S7-200 devices. The slot number of the PLC CPU module. Typically 0 or 1 for S7-200 devices. The address in the PLC memory to use for the watchdog mechanism, or null to disable watchdog monitoring. The polling interval, in milliseconds, for regular communication with the PLC. Must be greater than 0. The value to write to the watchdog address during each watchdog cycle. The interval, in milliseconds, at which the watchdog value is written. Must be greater than 0. An IRxS7 instance configured to communicate with the specified S7-200 PLC, with optional watchdog monitoring enabled. |
##### `S7PlcRx.S7300`
Source: `Create/S7300.cs:9`
Provides factory methods for creating connections to Siemens S7-300 PLC devices.
| Member | Summary |
|---|---|
| `public static IRxS7 Create(string ip, short rack, short slot, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 100)` | Creates a new instance of an S7 PLC connection with the specified configuration parameters. The IP address of the S7 PLC to connect to. The rack number of the PLC. Must be between 0 and 7, inclusive. The slot number of the PLC. Must be between 1 and 31, inclusive. The address in the PLC memory to use for the watchdog mechanism, or null to disable the watchdog. The polling interval, in milliseconds, for communication with the PLC. Must be greater than 0. The value to write to the watchdog address during each interval. The interval, in milliseconds, at which the watchdog value is written. Must be greater than 0. An object implementing the IRxS7 interface that represents the configured PLC connection. Thrown when the value of is not between 0 and 7, or when the value of is not between 1 and 31. |
##### `S7PlcRx.S7400`
Source: `Create/S7400.cs:9`
Provides factory methods for creating S7-400 PLC connections.
| Member | Summary |
|---|---|
| `public static IRxS7 Create(string ip, short rack, short slot, string? watchDogAddress = null, double interval = 100, ushort watchDogValueToWrite = 4500, int watchDogInterval = 100)` | Creates a new instance of an S7 PLC client configured for the specified IP address, rack, slot, and optional watchdog monitoring parameters. If watchdog monitoring is enabled by specifying a non-null watchDogAddress, the client will periodically write the specified value to the given address at the defined interval. This can be used to implement a heartbeat or keep-alive mechanism with the PLC. The IP address of the S7 PLC to connect to. The rack number of the PLC. Must be between 0 and 7. The slot number of the PLC CPU. Must be between 1 and 31. The address in the PLC memory to use for the watchdog mechanism, or null to disable watchdog monitoring. The polling interval, in milliseconds, for reading data from the PLC. Must be greater than 0. The value to write to the watchdog address during each interval if watchdog monitoring is enabled. The interval, in milliseconds, at which the watchdog value is written if watchdog monitoring is enabled. Must be greater than 0. An IRxS7 instance configured to communicate with the specified S7 PLC and optional watchdog monitoring. Thrown if rack is not between 0 and 7, or if slot is not between 1 and 31. |
##### `S7PlcRx.S7Exception`
Source: `S7Exception.cs:13`
| Member | Summary |
|---|---|
| `public S7Exception()` | Initializes a new instance of the class. |
| `public S7Exception(string message) : base(message)` | Initializes a new instance of the class. The message that describes the error. |
| `public S7Exception(string message, Exception innerException) : base(message, innerException)` | Initializes a new instance of the class. The error message that explains the reason for the exception. The exception that is the cause of the current exception, or a null reference ( in Visual Basic) if no inner exception is specified. |
##### `S7PlcRx.Tag`
Source: `Tags/Tag.cs:15`
| Member | Summary |
|---|---|
| `public Tag()` | Initializes a new instance of the class. |
| `public Tag(string address, Type type)` | Initializes a new instance of the class. The address. The type. |
| `public Tag(string address, Type type, int arrayLength)` | Initializes a new instance of the class. The address. The type. Length of the array. |
| `public Tag(string name, string address, Type type)` | Initializes a new instance of the class. The name. The address. The type. |
| `public Tag(string name, string address, Type type, int arrayLength)` | Initializes a new instance of the class. The name. The address. The type. Length of the array. |
| `public Tag(string name, string address, object value, Type type)` | Initializes a new instance of the class. The name. The address. The value. The type. |
| `public string? Address get; set; }` | Gets or sets the address associated with the entity. |
| `public string? Name get; set; }` | Gets or sets the name associated with the object. |
| `public object? Value get; set; }` | Gets or sets the value associated with this instance. |
| `public object? NewValue get; internal set; }` | Gets the new value associated with the change event. |
| `public Type Type get; internal set; }` | Gets the runtime type information associated with the current instance. |
| `public int? ArrayLength get; internal set; }` | Gets the length of the array, if known. |
| `public bool DoNotPoll get; internal set; }` | Gets a value indicating whether polling operations should be suppressed for this instance. |
| `public void SetDoNotPoll(bool value) => ...` | Sets a value indicating whether polling operations should be disabled. true to disable polling; otherwise, false. |
##### `S7PlcRx.TagAddressOutOfRangeException`
Source: `Tags/TagAddressOutOfRangeException.cs:15`
No public instance/static members declared directly on this type.
##### `S7PlcRx.TagExtensions`
Source: `Tags/TagExtensions.cs:18`
Provides extension methods for managing and interacting with tag items in IRxS7-based PLC systems. These methods enable adding, updating, retrieving, and removing tags, as well as converting tag streams to dictionary representations. The TagExtensions class offers a fluent API for working with tags in Siemens S7 PLC communication scenarios. It includes methods for adding tags with type and array support, controlling polling behavior, and transforming tag data streams. All methods are implemented as extension methods to enhance usability and integration with IRxS7 and related types. Thread safety and error handling depend on the underlying IRxS7 and Tag implementations.
| Member | Summary |
|---|---|
| `public static (ITag? tag, IRxS7? plc) AddUpdateTagItem(this IRxS7 @this, string tagName, string address, int? arrayLength = null)` | Adds or updates a tag item of the specified type in the PLC and returns the created tag and the PLC instance. If the specified type parameter is a string or an array type and an array length is provided, the tag will be created as an array with the given length. Otherwise, the tag will be created as a single value. This method is an extension method for IRxS7 implementations that support tag management. The data type of the tag to add or update. This determines the type of value the tag will hold. The PLC instance to which the tag item will be added or updated. The name to assign to the tag item. The address in the PLC where the tag item is located. The length of the array for the tag item, if the tag represents an array type. Specify null for non-array types. A tuple containing the created or updated tag as the first element and the PLC instance as the second element. The tag will be null if the PLC instance does not support tag operations. |
| `public static (ITag? tag, IRxS7? plc) AddUpdateTagItem(this IRxS7 @this, Type type, string tagName, string address, int? arrayLength = null)` | Adds or updates a tag item in the specified PLC instance and returns the created tag and the PLC reference. If the specified type is an array or a string, the array length must be provided. If the PLC instance does not support adding or updating tags, the returned tag will be null. The PLC instance to which the tag item will be added or updated. The data type of the tag to add or update. Must not be null. The name of the tag to add or update. The address in the PLC where the tag is located. The length of the array if the tag type is an array or a string; otherwise, null. A tuple containing the created tag (or null if the operation was not successful) and the PLC reference. |
| `public static (ITag? tag, IRxS7? plc) AddUpdateTagItem(this (ITag? _, IRxS7? plc) @this, string tagName, string address, int? arrayLength = null)` | Adds or updates a tag item of the specified type in the PLC and returns the created tag along with the PLC instance. If the PLC instance is not of type , no tag is added or updated and the returned tag will be null. When adding a string or array tag, must be specified to define the size of the tag. The data type of the tag to add or update. This can be a primitive type, string, or array type. A tuple containing the current tag (which may be null) and the PLC instance in which to add or update the tag. The name to assign to the tag item. The address in the PLC where the tag is located. The length of the array if the tag represents an array type. This parameter is required when is a string or an array type; otherwise, it is ignored. A tuple containing the created or updated tag as and the PLC instance as . If the PLC instance is null, the tag will also be null. |
| `public static (ITag? tag, IRxS7? plc) AddUpdateTagItem(this (ITag? _, IRxS7? plc) @this, Type type, string tagName, string address, int? arrayLength = null)` | Adds or updates a tag item in the specified PLC instance using the provided type, tag name, and address. If the tag type is a string or an array, the array length must be specified. The method does not modify the PLC instance if it is null or if the type is null. A tuple containing the current tag (ignored) and the PLC instance in which to add or update the tag item. The type of the tag to add or update. Must not be null. The name of the tag to add or update in the PLC. The address in the PLC where the tag is located. The length of the array if the tag type is an array or a string. Optional. A tuple containing the created or updated tag and the PLC instance. The tag is null if the PLC instance or type is null. |
| `public static (ITag? tag, IRxS7? plc) SetTagPollIng(this (ITag? tag, IRxS7? plc) @this, bool polling = true)` | Enables or disables polling for the specified tag by setting its polling state. If the tag is null, this method has no effect. This method does not modify the PLC instance. A tuple containing the tag and PLC instance to update. true to enable polling for the tag; false to disable polling. The default is true. A tuple containing the original tag and PLC instance. |
| `public static (ITag? tag, IRxS7? plc) GetTag(this IRxS7 @this, string tagName) => ...` | Retrieves the tag with the specified name from the PLC's tag list, along with the associated PLC instance. If the specified tag name does not exist in the PLC's tag list, the method returns a tuple with a null tag and the original PLC instance. This method is an extension method for the IRxS7 interface. The PLC instance from which to retrieve the tag. The name of the tag to retrieve. Cannot be null. A tuple containing the tag that matches the specified name and the PLC instance. If the tag is not found, the tag element of the tuple is null. |
| `public static void RemoveTagItem(this IRxS7 @this, string tagName)` | Removes the tag item with the specified name from the underlying RxS7 instance, if applicable. If the underlying object is not an RxS7 instance, this method has no effect. The IRxS7 instance from which to remove the tag item. The name of the tag item to remove. Cannot be null. |
| `public static IObservable> TagToDictionary(this IObservable source)` | Projects a sequence of nullable Tag objects into a stream of dictionaries containing the most recent values for each tag name, filtered by the specified value type. Each emitted dictionary contains all tag names encountered so far whose values are of type TValue and are not null. The dictionary is updated with each new matching tag in the source sequence. The same dictionary instance is reused and updated for each emission; callers should not modify the returned dictionary. The type to which tag values are filtered and cast. Only tags whose values are of this type are included in the resulting dictionaries. The observable sequence of nullable Tag objects to process. An observable sequence of dictionaries mapping tag names to their most recent non-null values of type TValue. Each dictionary reflects the accumulated state up to that point in the source sequence. |
| `public static IObservable<(string Tag, TValue Value)> ToTagValue(this IObservable source, string tag) => ...` | Projects each non-null value in the source sequence into a tuple containing the specified tag and the value. Null values in the source sequence are filtered out. The resulting sequence will not contain any tuples with a null value. The type of the values in the source sequence. The observable sequence of nullable values to process. Only non-null values are included in the result. The tag to associate with each value in the resulting sequence. This value is included in each emitted tuple. An observable sequence of tuples, where each tuple contains the specified tag and a non-null value from the source sequence. |
##### `S7PlcRx.Tags`
Source: `Tags/Tags.cs:18`
| Member | Summary |
|---|---|
| `public Tags()` | Initializes a new instance of the class. |
| `public object? this[object key, bool isEnd = false] #pragma warning restore RCS1163 // Unused parameter.` | |
| `public Tag? this[string name] => ...` | Gets the tag with the specified name, if it exists. The name of the tag to retrieve. The comparison may be case-sensitive depending on the implementation. The tag associated with the specified name, or null if no tag with that name exists. |
| `public Tag? this[Tag? tag] => ...` | Gets the tag from the collection that matches the specified tag's name, if present. This indexer performs a lookup based on the name of the provided tag. If the specified tag is null, the result is null. The tag whose name is used to locate the corresponding tag in the collection. Can be null. The tag from the collection that has the same name as the specified tag, or null if no such tag exists. |
| `public new void Add(object key, object value)` | Adds an element with the specified key and value to the collection in a thread-safe manner. This method ensures that the add operation is thread-safe. If an element with the same key already exists, an exception is thrown. The key of the element to add. Cannot be null. The value of the element to add. Can be null. |
| `public void Add(object key, Tag tag)` | Adds the specified tag to the collection with the associated key. If the collection already contains an element with the same key, an exception may be thrown depending on the underlying implementation. This method is thread-safe. The key with which the specified tag is to be associated. Cannot be null. The tag to add to the collection. Cannot be null. |
| `public void Add(Tag tag)` | Adds the specified tag to the collection. The tag to add to the collection. Cannot be null. |
| `public void Add(object key, Tags tags)` | Adds the specified key and associated tags to the collection. The key with which the specified tags are to be associated. Cannot be null. The tags to associate with the specified key. Cannot be null. |
| `public void AddRange(IEnumerable tags)` | Adds a collection of tags to the current instance, including only those tags whose values are not null. The collection of objects to add. Only tags with non-null values are added. Thrown if is null. |
| `public Tags GetTags()` | Retrieves a collection of tags that have non-null values. A collection containing all tags with non-null values. The collection will be empty if no such tags exist. |
| `public List ToList()` | Returns a list containing all tags in the collection. The returned list is a snapshot of the collection at the time of the call. Subsequent modifications to the collection are not reflected in the returned list. This method is thread-safe. A list of objects representing the tags in the collection. The list is empty if the collection contains no tags or if an error occurs while retrieving the tags. |
#### Namespace `S7PlcRx.Advanced`
##### `S7PlcRx.Advanced.AdvancedExtensions`
Source: `Advanced/AdvancedExtensions.cs:22`
Provides advanced extension methods for efficient batch operations, diagnostics, and performance analysis on PLC (Programmable Logic Controller) instances using the IRxS7 interface. These extension methods enable high-performance reading, writing, monitoring, and analysis of PLC variables, supporting scenarios such as batch updates, optimized data access, and system diagnostics. Methods are designed to simplify complex PLC interactions and provide recommendations for optimization. All methods require a valid IRxS7 instance and may throw exceptions if invalid arguments are supplied. Thread safety and performance considerations are addressed where relevant in individual method documentation.
| Member | Summary |
|---|---|
| `public static IObservable> ObserveBatch(this IRxS7 plc, params string[] variables)` | Observes the values of multiple PLC variables as a batch and emits updates as a dictionary when any of the specified variables change. The returned observable is hot and shared among all subscribers. If a specified variable is not already being polled, polling is automatically enabled for that variable. The sequence emits a new dictionary only when the set of variable values changes. The type of the variable values to observe. Must be compatible with the PLC variable types. The PLC instance that provides access to the variables to observe. Cannot be null. The names of the PLC variables to observe. If empty, an empty dictionary is emitted. An observable sequence that emits a dictionary mapping each specified variable name to its most recent value. The dictionary is updated and emitted whenever any of the observed variables change. Thrown if the parameter is null. |
| `public static async Task> ValueBatch(this IRxS7 plc, params string[] variables)` | Asynchronously reads the values of multiple variables from the PLC and returns a dictionary mapping variable names to their values. If a variable name does not exist in the PLC or cannot be read, its value in the returned dictionary will be the default value for type T. The order of the returned dictionary corresponds to the order of the requested variable names. This method may perform the reads in parallel for efficiency. The type of the variable values to read from the PLC. The PLC instance from which to read the variable values. Cannot be null. An array of variable names to read from the PLC. Each name must correspond to a valid variable in the PLC. A task that represents the asynchronous operation. The task result contains a dictionary mapping each requested variable name to its value of type T, or to the default value of T if the variable could not be read or does not exist. If no variables are specified, returns an empty dictionary. Thrown if the plc parameter is null. |
| `public static async Task ValueBatch(this IRxS7 plc, Dictionary values)` | Writes a batch of values to the PLC asynchronously using the specified tag-value pairs. If the underlying PLC implementation supports batch writing, the method attempts to write all values in a single operation for improved performance. Otherwise, values are written individually in parallel. No action is taken if the dictionary is null or empty. The type of the values to write to the PLC. The PLC interface to which the values will be written. A dictionary containing tag names as keys and the corresponding values to write. Cannot be null or empty. A task that represents the asynchronous write operation. |
| `public static async Task> ReadBatchOptimized( this IRxS7 plc, Dictionary tagMapping, int timeoutMs = 5000)` | Reads a batch of tags from the PLC in an optimized manner, grouping reads by data block to improve performance. If the tagMapping dictionary is null or empty, the method returns a successful result with no values. Tags are grouped by data block to minimize communication overhead. If a tag does not exist in the PLC's tag list, it is added before reading. Each tag read is subject to the specified timeout. The type of the values to read from the PLC tags. The PLC instance that provides access to the tags to be read. Cannot be null. A dictionary mapping logical tag names to their corresponding PLC addresses. Each key is the tag name, and each value is the PLC address to read. The maximum time, in milliseconds, to wait for each tag read operation before timing out. The default is 5000 milliseconds. A task that represents the asynchronous operation. The task result contains a BatchReadResult{T} with the values read, per-tag success status, and any errors encountered. Thrown if the plc parameter is null. |
| `public static async Task WriteBatchOptimized( this IRxS7 plc, Dictionary values, bool verifyWrites = false, bool enableRollback = false)` | Writes a batch of values to the specified PLC in an optimized manner, with optional write verification and rollback support. If enableRollback is set to true and any write fails, the method attempts to restore all affected PLC addresses to their original values. Write verification, if enabled, reads back each value after writing to ensure correctness. This method is asynchronous and should be awaited to ensure completion of all write and verification operations. The type of the values to write to the PLC. The PLC instance to which the values will be written. Cannot be null. A dictionary mapping PLC variable addresses to the values to write. Each key represents a PLC address, and each value is the data to write to that address. If the dictionary is null or empty, no write operations are performed. true to verify each write by reading back the value after writing; otherwise, false. Verification may increase operation time. true to enable rollback of all written values to their original state if any write fails; otherwise, false. Rollback is attempted only if an error occurs during the batch write. A BatchWriteResult object containing the outcome of the batch write operation, including per-address success and error information. If no values are provided, the result indicates overall success. Thrown if plc is null. |
| `public static async Task GetDiagnostics(this IRxS7 plc)` | Asynchronously collects diagnostic information and performance metrics from the specified PLC instance. If the PLC is not connected, only basic information is included in the diagnostics. For S7-1500 PLCs, additional CPU information and connection latency are measured. Any errors encountered during diagnostic collection are recorded in the Errors property of the returned ProductionDiagnostics object. The PLC instance from which to retrieve diagnostics. Must implement the IRxS7 interface. A task that represents the asynchronous operation. The task result contains a ProductionDiagnostics object with collected diagnostic data, tag metrics, and optimization recommendations. Thrown if the plc parameter is null. |
| `public static async Task AnalyzePerformance(this IRxS7 plc, TimeSpan monitoringDuration)` | Analyzes tag change performance on the specified PLC over a given monitoring duration and returns a summary of tag change frequencies and recommendations. This method subscribes to all tag changes on the PLC and tracks the frequency of changes for each tag during the specified monitoring period. The analysis includes total tag changes, per-tag change counts, and suggestions for optimizing performance based on observed activity. The method is thread-safe and does not block the calling thread. The PLC instance to monitor for tag changes. Cannot be null. The length of time to observe tag changes. Must be a positive time span. A task that represents the asynchronous operation. The task result contains a PerformanceAnalysis object with tag change statistics and performance recommendations for the monitored period. Thrown if the plc parameter is null. |
| `public static HighPerformanceTagGroup CreateTagGroup(this IRxS7 plc, string groupName, params string[] tagNames) => ...` | Creates a new high-performance tag group for batch reading or writing of multiple tags from the specified PLC connection. Use this method to efficiently manage and operate on multiple tags as a single group, which can improve performance for batch operations. The data type of the tag values in the group. The PLC connection used to access the tags. Cannot be null. The name assigned to the tag group. Used to identify the group within the PLC context. An array of tag names to include in the group. Each name must correspond to a valid tag in the PLC. A new instance of HighPerformanceTagGroup{T} containing the specified tags, associated with the given PLC connection. |
##### `S7PlcRx.Advanced.AsyncExtensions`
Source: `Advanced/AsyncExtensions.cs:18`
Provides additional async-first helpers for reading, writing, and observing PLC values without changing the base API surface. These helpers layer and async-observable patterns over the existing PLC API. Where possible, they complete synchronously from cached tag values or the existing multi-variable read/write paths to reduce avoidable allocations.
| Member | Summary |
|---|---|
| `public static ValueTask ReadValueAsync(this IRxS7 plc, string? variable, CancellationToken cancellationToken = default)` | Reads a PLC value using a , returning synchronously when a compatible cached tag value is already available. The expected PLC value type. The PLC instance. The tag name to read. The cancellation token for the read operation. A that resolves to the current PLC value. |
| `public static ValueTask> ReadValuesAsync(this IRxS7 plc, params string[] variables) => ...` | Reads multiple PLC values using a , preferring cached values and the optimized multi-variable read path where available. The expected PLC value type. The PLC instance. The tag names to read. A that resolves to a dictionary of tag values keyed by tag name. |
| `public static ValueTask> ReadValuesAsync(this IRxS7 plc, IReadOnlyList variables, CancellationToken cancellationToken = default)` | Reads multiple PLC values using a , honoring cancellation for deferred reads. The expected PLC value type. The PLC instance. The tag names to read. The cancellation token for deferred reads. A that resolves to a dictionary of tag values keyed by tag name. |
| `public static ValueTask WriteValuesAsync(this IRxS7 plc, IReadOnlyDictionary values, CancellationToken cancellationToken = default)` | Writes multiple PLC values using a , preferring the optimized multi-variable write path where available. The PLC value type. The PLC instance. The tag values to write. The cancellation token. A completed when the writes have been issued. |
| `public static IObservableAsync ObserveValueAsync(this IRxS7 plc, string? variable)` | Exposes a PLC variable as an async observable sequence. The expected PLC value type. The PLC instance. The tag name to observe. An that emits tag value updates asynchronously. |
| `public static IObservableAsync> ObserveValuesAsync(this IRxS7 plc, params string[] variables)` | Exposes a batch PLC observation as an async observable sequence. The expected PLC value type. The PLC instance. The tag names to observe. An that emits dictionaries of tag values asynchronously. |
##### `S7PlcRx.Advanced.DictionaryEqualityComparer`
Source: `Advanced/DictionaryEqualityComparer.cs:15`
Provides an equality comparer for dictionaries that determines equality based on their key-value pairs. This comparer considers two dictionaries equal if they contain the same number of key-value pairs and each key in one dictionary exists in the other with an equal value, as determined by the default equality comparer for the value type. The order of key-value pairs does not affect equality. This comparer can be used to compare dictionaries in collections such as hash sets or as keys in other dictionaries. The type of keys in the dictionaries. Must be non-nullable. The type of values in the dictionaries.
No public instance/static members declared directly on this type.
#### Namespace `S7PlcRx.BatchOperations`
##### `S7PlcRx.BatchOperations.BatchOperationResult`
Source: `BatchOperations/BatchOperationResult.cs:14`
Represents the result of executing a batch operation, including summary statistics and details for each operation. Use this class to access aggregate information such as the number of successful and failed operations, processing times, and detailed results for each operation in the batch. The class provides both summary properties and collections for per-operation and error details.
| Member | Summary |
|---|---|
| `public DateTime StartTime get; set; }` | Gets or sets the operation start time. |
| `public DateTime EndTime get; set; }` | Gets or sets the operation end time. |
| `public int OperationCount get; set; }` | Gets or sets the number of operations in the batch. |
| `public int SuccessfulOperations get; set; }` | Gets or sets the number of successful operations. |
| `public int FailedOperations get; set; }` | Gets or sets the number of failed operations. |
| `public TimeSpan ProcessingTime => ...` | Gets the total processing time. |
| `public double AverageTimePerOperation => ...` | Gets the average time per operation. |
| `public List OperationDetails get; } = [];` | Gets operation details. |
| `public List ErrorDetails get; } = [];` | Gets error details for failed operations. |
##### `S7PlcRx.BatchOperations.BatchReadResult`
Source: `BatchOperations/BatchReadResult.cs:17`
Represents the result of a batch read operation, including the values read, per-tag success status, error messages, and overall success information. Use this class to access the outcome of a batch read, including which tags succeeded, which failed, and any associated error messages. The dictionaries provide per-tag details, while the overall success and count properties offer summary information. This class is typically used in scenarios where multiple items are read in a single operation and individual results must be tracked. The type of the values returned for each tag in the batch read operation.
| Member | Summary |
|---|---|
| `public Dictionary Values get; } = [];` | Gets the successfully read values. |
| `public Dictionary Success get; } = [];` | Gets the success status for each tag. |
| `public Dictionary Errors get; } = [];` | Gets error messages for failed reads. |
| `public bool OverallSuccess get; set; }` | Gets or sets a value indicating whether gets whether all reads were successful. |
| `public int SuccessCount => ...` | Gets the count of successful reads. |
| `public int ErrorCount => ...` | Gets the count of failed reads. |
##### `S7PlcRx.BatchOperations.BatchWriteResult`
Source: `BatchOperations/BatchWriteResult.cs:15`
Represents the result of a batch write operation, including per-item success status, error messages, and overall outcome. Use this class to inspect which items in a batch write succeeded or failed, retrieve error details for failed items, and determine whether the entire batch was successful or if a rollback was performed. The dictionaries map item identifiers (such as tag names) to their respective statuses and error messages.
| Member | Summary |
|---|---|
| `public Dictionary Success get; } = [];` | Gets the success status for each tag. |
| `public Dictionary Errors get; } = [];` | Gets error messages for failed writes. |
| `public bool OverallSuccess get; set; }` | Gets or sets a value indicating whether gets whether all writes were successful. |
| `public bool RollbackPerformed get; set; }` | Gets or sets a value indicating whether gets whether rollback was performed. |
| `public int SuccessCount => ...` | Gets the count of successful writes. |
| `public int ErrorCount => ...` | Gets the count of failed writes. |
#### Namespace `S7PlcRx.Binding`
##### `S7PlcRx.Binding.S7TagDefinition`
Source: `Binding/S7TagDefinition.cs:9`
Describes a generated PLC tag/property binding.
| Member | Summary |
|---|---|
| `public S7TagDefinition(string name, string address, Type valueType, int pollIntervalMs, S7TagDirection direction, int arrayLength = 1)` | Initializes a new instance of the class. The property and PLC tag name. The S7 DB address. The .NET value type. The read polling interval in milliseconds. The tag access direction. The array/string element length. |
| `public string Name get; }` | Gets the property and PLC tag name. |
| `public string Address get; }` | Gets the S7 DB address. |
| `public Type ValueType get; }` | Gets the .NET value type. |
| `public int PollIntervalMs get; }` | Gets the read polling interval in milliseconds. |
| `public S7TagDirection Direction get; }` | Gets the tag access direction. |
| `public int ArrayLength get; }` | Gets the array/string element length. |
| `public bool CanRead => ...` | Gets a value indicating whether this tag should be read on polling intervals. |
| `public bool CanWrite => ...` | Gets a value indicating whether this tag can write property changes to the PLC. |
##### `S7PlcRx.Binding.S7TagDirection`
Source: `Binding/S7TagDirection.cs:9`
Defines the PLC access direction for a generated tag binding.
Enum values: `ReadWrite`, `ReadOnly`, `WriteOnly`.
##### `S7PlcRx.Binding.S7TagRuntimeBinding`
Source: `Binding/S7TagRuntimeBinding.cs:15`
Runtime engine used by generated tag bindings to poll and write PLC DB values in byte-array batches.
| Member | Summary |
|---|---|
| `public static S7TagRuntimeBinding Bind(IRxS7 plc, IReadOnlyList definitions, Action applyRead) => ...` | Creates and starts a runtime binding for generated PLC tag definitions. The PLC instance. The tag definitions emitted by the source generator. A generated callback that assigns PLC values to backing fields without re-writing them. A disposable runtime binding. |
| `public void Write(string name, object? value)` | Queues a generated property change for a grouped byte-array write. The generated tag/property name. The new property value. |
| `public void Dispose()` | Releases timers and pending write state. |
#### Namespace `S7PlcRx.Cache`
##### `S7PlcRx.Cache.CacheStatistics`
Source: `Cache/CacheStatistics.cs:13`
Provides statistical information about the state and performance of a cache, including entry counts, hit rates, and entry timestamps. Use this class to monitor cache usage patterns and effectiveness. The statistics can help identify cache performance issues or guide tuning decisions. All values represent a snapshot at the time the object is created or updated; they do not update automatically.
| Member | Summary |
|---|---|
| `public int TotalEntries get; set; }` | Gets or sets the total number of cached entries. |
| `public long TotalHits get; set; }` | Gets or sets the total number of cache hits. |
| `public double HitRate get; set; }` | Gets or sets the cache hit rate (0.0 to 1.0). |
| `public DateTime OldestEntry get; set; }` | Gets or sets the timestamp of the oldest cache entry. |
| `public DateTime NewestEntry get; set; }` | Gets or sets the timestamp of the newest cache entry. |
| `public int CachedValueCount get; internal set; }` | Gets the cached value count. The cached value count. |
| `public int PendingRequestCount get; internal set; }` | Gets the pending request count. The pending request count. |
| `public double CacheHitRatio get; internal set; }` | Gets the cache hit ratio. The cache hit ratio. |
##### `S7PlcRx.Cache.CachedTagValue`
Source: `Cache/CachedTagValue.cs:12`
Represents a cached value along with metadata about its storage and usage. This class is typically used to store a value retrieved from a data source, along with the time it was cached and the number of times it has been accessed. It is intended for use in caching scenarios where tracking cache usage and freshness is important.
| Member | Summary |
|---|---|
| `public object? Value get; set; }` | Gets or sets the cached value. |
| `public DateTime Timestamp get; set; }` | Gets or sets when the value was cached. |
| `public long HitCount get; set; }` | Gets or sets the number of cache hits. |
#### Namespace `S7PlcRx.Core`
##### `S7PlcRx.Core.ConnectionPool`
Source: `Core/ConnectionPool.cs:17`
Manages a pool of PLC connections, providing load-balanced access and connection reuse according to the specified configuration. The ConnectionPool enables efficient management of multiple PLC connections by reusing and balancing requests across available connections. It supports configurable pool size and connection reuse strategies. This class is thread-safe for concurrent access. Call Dispose to release all connections when the pool is no longer needed.
| Member | Summary |
|---|---|
| `public ConnectionPool(ConnectionPoolConfig config) => ...` | Initializes a new instance of the class. The pool configuration. |
| `public ConnectionPool( IEnumerable connectionConfigs, ConnectionPoolConfig poolConfig)` | Initializes a new instance of the class. The connection configurations. The pool configuration. |
| `public int MaxConnections => ...` | Gets the maximum number of connections in the pool. |
| `public int ActiveConnections => ...` | Gets the number of active connections. |
| `public IRxS7 GetConnection` | Gets a connection from the pool using load balancing. An available PLC connection. |
| `public IEnumerable GetAllConnections() => ...` | Gets all connections in the pool. All connections. |
| `public void Dispose()` | Disposes all connections in the pool. |
##### `S7PlcRx.Core.ConnectionPoolConfig`
Source: `Core/ConnectionPoolConfig.cs:12`
Represents the configuration settings for a connection pool, including limits, timeouts, and behavior options. Use this class to specify parameters that control the size, performance, and health monitoring of a connection pool. Adjusting these settings can help optimize resource usage and connection reliability for applications that manage multiple concurrent connections.
| Member | Summary |
|---|---|
| `public int MaxPoolSize get; set; } = 10;` | Gets or sets the maximum pool size. |
| `public int MaxConnections get; set; } = 10;` | Gets or sets the maximum number of connections in the pool. |
| `public TimeSpan ConnectionTimeout get; set; } = TimeSpan.FromSeconds(30);` | Gets or sets the connection timeout. |
| `public bool EnableLoadBalancing get; set; } = true;` | Gets or sets a value indicating whether to enable load balancing. |
| `public bool EnableConnectionReuse get; set; } = true;` | Gets or sets a value indicating whether to enable connection reuse. |
| `public TimeSpan HealthCheckInterval get; set; } = TimeSpan.FromMinutes(1);` | Gets or sets the health check interval. |
##### `S7PlcRx.Core.DataBlockInfo`
Source: `Core/DataBlockInfo.cs:14`
Represents metadata and configuration information for a data block, including its identifier, size, tag details, access frequency, and optimization settings. Use this class to describe the characteristics of a data block, such as its block number, size in bytes, and associated tag names. The properties provide information useful for managing, analyzing, or optimizing data storage and access patterns. Instances of this class are typically used in scenarios where data blocks are processed, monitored, or configured for batch operations.
| Member | Summary |
|---|---|
| `public int BlockNumber get; set; }` | Gets or sets the data block number. |
| `public int SizeBytes get; set; }` | Gets or sets the total size in bytes. |
| `public int TagCount get; set; }` | Gets or sets the number of tags in this block. |
| `public double AccessFrequency get; set; }` | Gets or sets the access frequency. |
| `public bool IsBatchOptimized get; set; }` | Gets or sets a value indicating whether gets or sets whether the block is optimized for batch operations. |
| `public List TagNames get; } = [];` | Gets the tags in this data block. |
##### `S7PlcRx.Core.OperationDetail`
Source: `Core/OperationDetail.cs:9`
Represents the details of an operation, including its type, status, duration, and related metadata.
| Member | Summary |
|---|---|
| `public string TagName get; set; } = string.Empty;` | Gets or sets the tag name. |
| `public string OperationType get; set; } = string.Empty;` | Gets or sets the operation type. |
| `public bool Success get; set; }` | Gets or sets a value indicating whether gets or sets whether the operation succeeded. |
| `public TimeSpan Duration get; set; }` | Gets or sets the operation duration. |
| `public string? ErrorMessage get; set; }` | Gets or sets any error message. |
| `public int DataBlockNumber get; set; }` | Gets or sets the data block number. |
##### `S7PlcRx.Core.RequestPriority`
Source: `Core/RequestPriority.cs:9`
Request priority levels for batch processing.
Enum values: `Low`, `Normal`, `High`, `Critical`.
#### Namespace `S7PlcRx.Enterprise`
##### `S7PlcRx.Enterprise.EnterpriseExtensions`
Source: `Enterprise/EnterpriseExtensions.cs:19`
Provides extension methods for enhanced PLC connectivity, symbolic addressing, high-availability management, and connection pooling in enterprise automation scenarios. The EnterpriseExtensions class offers advanced features for working with PLCs, including loading and caching symbol tables for symbolic access, reading and writing values by symbol name, creating high-availability connections with automatic failover, and managing connection pools for high-throughput applications. These methods are designed to simplify integration with industrial automation systems and improve reliability and scalability in production environments.
| Member | Summary |
|---|---|
| `public static async Task LoadSymbolTable( this IRxS7 plc, string symbolTableData, SymbolTableFormat format = SymbolTableFormat.Csv)` | Loads and caches a symbol table for symbolic addressing support. Enables reading/writing using symbolic names instead of absolute addresses. The PLC instance. Symbol table data (CSV format supported). The format of the symbol table data. The loaded symbol table. |
| `public static async Task ReadSymbol(this IRxS7 plc, string symbolName)` | Asynchronously reads the value of the specified symbol from the PLC and returns it as the specified type. The type to which the symbol's value is converted and returned. The PLC connection used to access the symbol table and read the symbol value. Cannot be null. The name of the symbol to read from the PLC. Must correspond to a symbol present in the PLC's symbol table. A task that represents the asynchronous read operation. The task result contains the value of the symbol as type , or if the symbol's value is null. Thrown if is null. Thrown if a symbol with the specified does not exist in the PLC's symbol table. |
| `public static void WriteSymbol(this IRxS7 plc, string symbolName, T value)` | Writes a value to the specified PLC symbol by name. The type of the value to write to the symbol. The PLC instance to which the symbol value will be written. Cannot be null. The name of the symbol in the PLC to write the value to. Must correspond to a valid symbol in the PLC's symbol table. The value to write to the specified symbol. Thrown if is null. Thrown if does not correspond to a symbol in the PLC's symbol table. |
| `public static HighAvailabilityPlcManager CreateHighAvailabilityConnection( IRxS7 primaryPlc, IList backupPlcs, TimeSpan? healthCheckInterval = null)` | Creates a high-availability connection manager that coordinates failover between a primary PLC and one or more backup PLCs. The returned manager automatically monitors the health of the primary and backup PLCs and handles failover as needed. The order of backupPlcs determines the failover priority. The primary PLC instance to be used for initial communication and operations. Cannot be null. A list of backup PLC instances to be used for failover if the primary PLC becomes unavailable. Cannot be null or empty. The interval at which the health of the PLCs is checked. If null, a default interval is used. A HighAvailabilityPlcManager instance that manages high-availability communication across the specified PLCs. Thrown if primaryPlc or backupPlcs is null. |
| `public static ConnectionPool CreateConnectionPool( IEnumerable connectionConfigs, ConnectionPoolConfig poolConfig)` | Creates a new connection pool using the specified PLC connection configurations and pool settings. A collection of PLC connection configurations to include in the pool. Must contain at least one configuration. The configuration settings to apply to the connection pool. Cannot be null. A new instance of initialized with the provided connection configurations and pool settings. Thrown if or is null. Thrown if does not contain at least one configuration. |
##### `S7PlcRx.Enterprise.HighAvailabilityPlcManager`
Source: `Enterprise/HighAvailabilityPlcManager.cs:17`
Provides high-availability management for a set of PLC (Programmable Logic Controller) connections, automatically handling failover to backup PLCs in case of connection loss. The HighAvailabilityPlcManager monitors the health of the primary PLC and automatically switches to a backup PLC if the primary becomes unavailable. It exposes an observable stream of failover events for monitoring and allows manual triggering of failover. This class is thread-safe for typical usage scenarios. Dispose the manager when it is no longer needed to release resources.
| Member | Summary |
|---|---|
| `public HighAvailabilityPlcManager( IRxS7 primaryPlc, IList backupPlcs, TimeSpan? healthCheckInterval = null)` | Initializes a new instance of the class with a primary PLC, a list of backup PLCs,. and an optional health check interval. The primary PLC is always treated as the first PLC in the managed list, regardless of its position in the provided backupPlcs collection. Health checks are performed at the specified interval to monitor PLC availability and facilitate failover if necessary. The primary PLC to be managed. Cannot be null. A list of backup PLCs to use for failover. The primary PLC will be inserted as the first element in this list. The interval at which health checks are performed on the PLCs. If null, a default interval of 30 seconds is used. Thrown if primaryPlc is null.