mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Changed poller structure and attachment method
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using MewtocolNet;
|
||||
using MewtocolNet.Responses;
|
||||
|
||||
namespace Examples {
|
||||
class Program {
|
||||
@@ -16,6 +17,8 @@ namespace Examples {
|
||||
interf.AddRegister<short>("Cooler Status",1204);
|
||||
interf.AddRegister<string>(1101, 4);
|
||||
|
||||
interf.WithPoller();
|
||||
|
||||
interf.RegisterChanged += (o) => {
|
||||
Console.WriteLine($"DT{o.MemoryAdress} {(o.Name != null ? $"({o.Name}) " : "")}changed to {o.GetValueString()}");
|
||||
};
|
||||
@@ -24,11 +27,16 @@ namespace Examples {
|
||||
(plcinf) => {
|
||||
|
||||
Console.WriteLine("Connected to PLC:\n" + plcinf.ToString());
|
||||
|
||||
//read back a register value
|
||||
var statusNum = (NRegister<short>)interf.Registers[1204];
|
||||
Console.WriteLine($"Status num is: {statusNum.Value}");
|
||||
|
||||
},
|
||||
() => {
|
||||
Console.WriteLine("Failed connection");
|
||||
}
|
||||
).AttachContinousReader(50);
|
||||
);
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user