Reactive S7 PLC Communications Library
S7PlcRx is a library that provides a simple interface to communicate with Siemens S7 PLCs.
- Read and Write to PLC
- Read from PLC with Reactive Subscription
S7PlcRx is available on NuGet.
Install-Package S7PlcRx
dotnet add package S7PlcRx
using S7PlcRx;
var plc = new RxS7(S7PlcRx.Enums.CpuType.S71500, "PLC_IP_ADDRESS", 0, 5);
// Add Tag without Polling
plc.AddUpdateTagItem<double>("Tag0", "DB500.DBD0").SetTagPollIng(false);
// Add Tag with Polling
plc.AddUpdateTagItem<double>("Tag1", "DB500.DBD8");
plc.IsConnected
.Where(x => x)
.Take(1)
.Subscribe(async _ =>
{
Console.WriteLine("Connected");
// Read Tag Value manually
var tag0 = await plc.Value<double>("Tag0");
});
// Subscribe to Tag Values
plc.Observe<double>("Tag0").Subscribe(x => Console.WriteLine($"Tag0: {x}"));
plc.Observe<double>("Tag1").Subscribe(x => Console.WriteLine($"Tag1: {x}"));
// Start Polling on previously disabled Tag
plc?.GetTag("Tag0")?.SetTagPollIng(true);
plc.Value<double>("Tag0", 1.0);
var cpuInfo = await plc.CpuInfo();
This returns a CpuInfo
string Array with the following values:
AS Name, Module Name, Copyright, Serial Number, Module Type Name, Order Code, Version.
- Bool
- Byte
- Int
- DInt
- Real
- LReal
- String
- Word
- DWord
Further types will be added in the future.
- Logo-0BA8
- S7-200
- S7-300
- S7-400
- S7-1200
- S7-1500