Try Notification value changed
patopat opened this issue · comments
Hi,
From the project "Examples", I modified a little bit the ExampleNotifyChanged.cs" to add print debug details. I have nothing in the console window except the "test started...". When I do a read Tag, I have a lot of message in the console and the value is read correctly.
static private NotifyValueChangedTag<DintPlcMapper, int> myDINT;
public static void Run()
{
LibPlcTag.LogEvent += LibPlcTag_LogEvent;
LibPlcTag.DebugLevel = DebugLevel.Detail;
myDINT = new()
{
Name = "TestEvent",
Gateway = "192.168.1.1",
Path = "1,0",
PlcType = PlcType.ControlLogix,
Protocol = Protocol.ab_eip,
AutoSyncReadInterval = TimeSpan.FromMilliseconds(500)
};
Console.WriteLine("test started...");
myDINT.ValueChanged += (s, e) => Console.WriteLine($"{myDINT.Name} changed at {DateTime.Now} to {myDINT.Value}");
}
private static void LibPlcTag_LogEvent(object sender, LogEventArgs e)
{
Console.WriteLine($"{e.DebugLevel}\t\t{e.Message}");
}
Do you know if I need to configure anything in the PLC program for notification or any idea why no event occurs ?
Regards,
Pat
Fixed by calling the initialize method.