Closed pranny closed 6 years ago
Try to refresh group.
group.RefreshAsync(OpcDaDataSource.Device);
@alexy-titov, Thanks for the response. I don't fully get it. Where should i refresh group? Should I do it after server connection or should i do it every second when my timer function wakes up?
You can refresh group on timer. Also there is another way to acquire data via subscriptions. Please check tests Test_RefreshAsync and Test_IsSubscribed for details.
This does not seem to be working. I replaced Task<OpcDaItemValue[]> task = opcGroup.ReadAsync(opcGroup.Items);
with var task = opcGroup.RefreshAsync(OpcDaDataSource.Device);
in the ReadOPCTagValues
function. It still results in the same issue.
I ended up using OPC Foundation's library which does not have this issue.
I am using this library to build an app. I am using Matrikon OPC Simulator for DA protocol. I noticed that sometimes the values read from OPC Server are from past. It would be like a series of near-real-time values and then there would be a series of values from about 7-8 minutes back. Then again the near-real-time values and so on. This looks pretty weird to me and I am not sure what/where is the issue lying.
The app is a windows service that uses Timer to wake up every 1 second and get the data from OPC Server. It uses locks and timer disabling to make sure that only one thread be running at a time. The data read is interpreted in a custom Class which is then written as JSON files to the hdd.
The log generated looks something like below. This is generated from
eventLog
so it's in reverse chronological order with the latest event on top. Notice that at8:53:52
the results were correct, but the next instant it changes.Any thoughts on this?