From d34639b1dbdb26868af84d5f6fa67ff60fc1f73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Mon, 20 Jun 2022 17:19:18 +0200 Subject: [PATCH 1/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a6dc8c5..41596b5 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Logger.OnNewLogMessage((date, msg) => { }); //setting up a new PLC interface -MewtocolInterface interf = new MewtocolInterface("10.237.191.3"); +MewtocolInterface interf = new MewtocolInterface("192.168.115.5"); await interf.ConnectAsync(); ``` @@ -124,7 +124,7 @@ Logger.OnNewLogMessage((date, msg) => { }); //setting up a new PLC interface and register collection -MewtocolInterface interf = new MewtocolInterface("192.168.115.3"); +MewtocolInterface interf = new MewtocolInterface("192.168.115.5"); TestRegisters registers = new TestRegisters(); //attaching the register collection and an automatic poller From 4993ae6bf255a0afa922c7b04164b1e2d36ec1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Mon, 20 Jun 2022 17:19:41 +0200 Subject: [PATCH 2/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41596b5..379049b 100644 --- a/README.md +++ b/README.md @@ -183,5 +183,5 @@ Sets the register waiting for the PLC to confirm it was set ```C# //inverts the boolean register -interf.SetRegisterAsync(nameof(registers.TestBool1), !registers.TestBool1); +await interf.SetRegisterAsync(nameof(registers.TestBool1), !registers.TestBool1); ``` From 6d9c92d24fe3024f876013accf0a5dfe1a9564c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:49:54 +0200 Subject: [PATCH 3/8] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 379049b..0a30178 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +![Nuget](https://img.shields.io/nuget/v/MewtocolNet) +![Lines of code](https://img.shields.io/tokei/lines/github/WOmed/MewtocolNet) +![Nuget](https://img.shields.io/nuget/dt/MewtocolNet) +![GitHub](https://img.shields.io/github/license/WOmed/MewtocolNet) +![Status](https://img.shields.io/badge/Status-In%20dev-orange) + # MewtocolNet An easy to use Mewtocol protocol library to interface with Panasonic PLCs over TCP/Serial. @@ -43,6 +49,18 @@ Where is the RS232/Serial support? > Support for the serial protocol will be added soon, feel free to contribute +# Installing + +Install this package by using [Nuget](https://www.nuget.org/packages/MewtocolNet/) or reference +```XML + +``` +in your dependencies. +Alternatively use the dotnet CLI and run +```Shell +dotnet add package MewtocolNet +``` + # Protocol description Panasonic has published a [protocol definition](https://mediap.industry.panasonic.eu/assets/custom-upload/Factory%20&%20Automation/PLC/Manuals/mn_all_plcs_mewtocol_user_pidsx_en.pdf) on their site. From 3a5cdb11c2ac94a43c0502cb6ea17b7da3ee15f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:59:27 +0200 Subject: [PATCH 4/8] Create dotnet-windows.yml --- .github/workflows/dotnet-windows.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dotnet-windows.yml diff --git a/.github/workflows/dotnet-windows.yml b/.github/workflows/dotnet-windows.yml new file mode 100644 index 0000000..e737a9e --- /dev/null +++ b/.github/workflows/dotnet-windows.yml @@ -0,0 +1,25 @@ +name: .NET + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 5.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From 881253130b05820797c14b74083074b9679e36e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:07:50 +0200 Subject: [PATCH 5/8] Update dotnet-windows.yml --- .github/workflows/dotnet-windows.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/dotnet-windows.yml b/.github/workflows/dotnet-windows.yml index e737a9e..9508202 100644 --- a/.github/workflows/dotnet-windows.yml +++ b/.github/workflows/dotnet-windows.yml @@ -1,4 +1,4 @@ -name: .NET +name: .NET Windows on: push: @@ -8,18 +8,16 @@ on: jobs: build: - runs-on: windows-latest - + strategy: + matrix: + dotnet-version: [ '3.0', '3.1.x', '5.0.x' ] steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 5.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + - uses: actions/checkout@v3 + - name: Setup dotnet ${{ matrix.dotnet-version }} + uses: actions/setup-dotnet@v2 + with: + dotnet-version: ${{ matrix.dotnet-version }} + # You can test your matrix by printing the current dotnet version + - name: Display dotnet version + run: dotnet --version From 4a63fb10bd1bfb534eb74c1d351fe8de4eb6f044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:12:04 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a30178..54d9589 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![.NET Windows](https://github.com/WOmed/MewtocolNet/actions/workflows/dotnet-windows.yml/badge.svg)](https://github.com/WOmed/MewtocolNet/actions/workflows/dotnet-windows.yml) ![Nuget](https://img.shields.io/nuget/v/MewtocolNet) ![Lines of code](https://img.shields.io/tokei/lines/github/WOmed/MewtocolNet) ![Nuget](https://img.shields.io/nuget/dt/MewtocolNet) From 26c0e9add019469158418a6aae03958597d88a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:11:01 +0200 Subject: [PATCH 7/8] Update README.md --- README.md | 56 ++++++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 54d9589..f2c19a6 100644 --- a/README.md +++ b/README.md @@ -85,28 +85,15 @@ Logger.OnNewLogMessage((date, msg) => { }); //setting up a new PLC interface -MewtocolInterface interf = new MewtocolInterface("192.168.115.5"); +MewtocolInterface plc = new MewtocolInterface("192.168.115.5"); -await interf.ConnectAsync(); +await plc.ConnectAsync(); ``` -You can also use the callbacks of the `ConnectAsync()` method to do something after the initial connection establishment. - -```C# -await interf.ConnectAsync( - //PLC connected - (plc) => { - if(plcinf.OperationMode.RunMode) - Console.WriteLine("PLC is in RUN"); - }, - //Connection failed - () => { - Console.WriteLine("PLC failed to connect"); - } -); -``` ## Reading data registers / contacts +[Detailed instructions](/wiki/Attribute-handled-reading) + - Create a new class that inherits from `RegisterCollectionBase` ```C# @@ -136,20 +123,14 @@ public class TestRegisters : RegisterCollectionBase { - attach an automatic poller by chaining `.WithPoller()` after the register attachment ```C# -//attaching a logger -Logger.LogLevel = LogLevel.Verbose; -Logger.OnNewLogMessage((date, msg) => { - Console.WriteLine($"{date.ToString("HH:mm:ss")} {msg}"); -}); - //setting up a new PLC interface and register collection -MewtocolInterface interf = new MewtocolInterface("192.168.115.5"); +MewtocolInterface plc = new MewtocolInterface("192.168.115.5"); TestRegisters registers = new TestRegisters(); //attaching the register collection and an automatic poller -interf.WithRegisterCollection(registers).WithPoller(); +plc.WithRegisterCollection(registers).WithPoller(); -await interf.ConnectAsync( +await plc.ConnectAsync( (plcinf) => { //reading a value from the register collection Console.WriteLine($"Time Value is: {registers.TestTime}"); @@ -170,37 +151,28 @@ Sets the register without feedback if it was set ```C# //inverts the boolean register -interf.SetRegister(nameof(registers.TestBool1), !registers.TestBool1); +plc.SetRegister(nameof(registers.TestBool1), !registers.TestBool1); //set the current second to the PLCs TIME register -interf.SetRegister(nameof(registers.TestTime), TimeSpan.FromSeconds(DateTime.Now.Second)); +plc.SetRegister(nameof(registers.TestTime), TimeSpan.FromSeconds(DateTime.Now.Second)); //writes 'Test' to the PLCs string register -interf.SetRegister(nameof(registers.TestString1), "Test"); +plc.SetRegister(nameof(registers.TestString1), "Test"); ``` You can also set a register by calling its name directly (Must be either in an attached register collection or added to the list manually) Adding registers to a manual list ```C# -interf.AddRegister(105, _name: "ManualBoolRegister"); +plc.AddRegister(105, _name: "ManualBoolRegister"); ``` Reading the value of the manually added register ```C# //get the value as a string -string value = interf.GetRegister("ManualBoolRegister").GetValueString(); +string value = plc.GetRegister("ManualBoolRegister").GetValueString(); //get the value by casting -bool value2 = interf.GetRegister("ManualBoolRegister").Value; +bool value2 = plc.GetRegister("ManualBoolRegister").Value; //for double casted ones like numbers -var value2 = interf.GetRegister>("NumberRegister").Value; -``` - -### Asynchronous - -Sets the register waiting for the PLC to confirm it was set - -```C# -//inverts the boolean register -await interf.SetRegisterAsync(nameof(registers.TestBool1), !registers.TestBool1); +var value2 = plc.GetRegister>("NumberRegister").Value; ``` From 3aa8aa227c6126409df388e3ec16b25aab445b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:13:37 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2c19a6..0039653 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ await plc.ConnectAsync(); ## Reading data registers / contacts -[Detailed instructions](/wiki/Attribute-handled-reading) +[Detailed instructions](https://github.com/WOmed/MewtocolNet/wiki/Attribute-handled-reading) - Create a new class that inherits from `RegisterCollectionBase`