From 7056ebd252d30722e1cbca40e00522e8af45ccdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Thu, 16 Jun 2022 11:53:32 +0200 Subject: [PATCH] Create README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..df175e6 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# MewtocolNet +A Mewtocol protocol library to interface with Panasonic PLCs over TCP/Serial. + +# Usage + +1. Connecting to a PLC + +```C# +//Create a new interface class with your PLCs IP address and port +MewtocolInterface interf = new MewtocolInterface("127.0.0.1", 9094); + +//Setup the dataregisters of the PLC you want to read +interf.AddRegister("Test Integer",1204); +interf.AddRegister(1101, 4); + +//attaches an auto reader that polls the registers +interf.WithPoller(); + +//triggers when a dataregister changes its value +interf.RegisterChanged += (o) => { + Console.WriteLine($"DT{o.MemoryAdress} {(o.Name != null ? $"({o.Name}) " : "")}changed to {o.GetValueString()}"); +}; + +//Connects to the PLC asynchronous and invokes connected or failed +await interf.ConnectAsync( + (plcinf) => { + + Console.WriteLine("Connected to PLC:\n" + plcinf.ToString()); + + //read back a register value + var statusNum = (NRegister)interf.Registers[1204]; + Console.WriteLine($"Status num is: {statusNum.Value}"); + + }, + () => { + Console.WriteLine("Failed connection"); + } +); +```