Skip to content
/ S7PlcRx Public
forked from ChrisPulman/S7PlcRx

A Reactive S7 PLC Communications Library

License

Notifications You must be signed in to change notification settings

mozesa/S7PlcRx

 
 

Repository files navigation

License Build Nuget NuGet

Alt

S7PlcRx

S7PlcRx

Reactive S7 PLC Communications Library

Introduction

S7PlcRx is a library that provides a simple interface to communicate with Siemens S7 PLCs.

Features

  • Read and Write to PLC
  • Read from PLC with Reactive Subscription

Getting Started

Installation

S7PlcRx is available on NuGet.

Package Manager

Install-Package S7PlcRx

.NET CLI

dotnet add package S7PlcRx

Usage

Setup Tags and Observe values in PLC

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);

Write to PLC

plc.Value<double>("Tag0", 1.0);

Read PLC CPU Info

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.

Supported Data Types

  • Bool
  • Byte
  • Int
  • DInt
  • Real
  • LReal
  • String
  • Word
  • DWord

Further types will be added in the future.

Supported PLCs

  • Logo-0BA8
  • S7-200
  • S7-300
  • S7-400
  • S7-1200
  • S7-1500

About

A Reactive S7 PLC Communications Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 96.4%
  • PowerShell 1.9%
  • Shell 1.6%
  • Batchfile 0.1%