titanium-as / TitaniumAS.Opc.Client

Open source .NET client library for OPC DA
MIT License
197 stars 93 forks source link

OPC DA Client gets old timestamps from items #12

Open GMejoras opened 7 years ago

GMejoras commented 7 years ago

Hi, I'm trying to read somew real dato from an opc server. I'm able to read the data but after 7 minutes of reading the data Timestamp is older than the Timestamp I was reading. For example: item:1 value 1 timestamp: 13/06/2017 11:31:10 item:1 value 1 timestamp: 13/06/2017 11:31:20 item:1 value 1 timestamp: 13/06/2017 11:31:30 After a time, (without rtestarting the server or the client or the pc) then the read data are item:1 value 1 timestamp: 13/06/2017 11:21:10 item:1 value 1 timestamp: 13/06/2017 11:21:20 item:1 value 1 timestamp: 13/06/2017 11:21:30 I've tried syn and async reading with same results. I need to get the newest value only And I don´t kwon why I get old timestamps suddenly. What can I be doing wrong? Thanks in advance,

pranny commented 7 years ago

@GMejoras I have been facing the same issue https://github.com/titanium-as/TitaniumAS.Opc.Client/issues/16 for sometime now. Were you able to find a solution?

GMejoras commented 7 years ago

Sorry Nobody answered me And I could not solve it by my own. I hope you find a solution

pranny commented 7 years ago

@GMejoras just curious, if you use any external causal message ordering system or was your use case agnostic to the message order

alexey-titov commented 7 years ago

Try to read uncached values.

group.Read(items, OpcDaDataSource.Device);

fallfman commented 6 years ago

I have found a bug. In the following file, replace it with:

TitaniumAS.Opc.Client-master\TitaniumAS.Opc.Client\Interop\Helpers\FileTimeConverter.cs

        var lft = (((long)fileTime.dwHighDateTime) << 32) + (fileTime.dwLowDateTime & 0xffffffff);

Thanks~

EuroEager2008 commented 4 years ago

Another and more direct (and slightly better performant) way is to cast the dwLowDateTime component to uint before the addition: var lft = (((long)fileTime.dwHighDateTime) << 32) + (uint)fileTime.dwLowDateTime;

Cyborge1 commented 4 years ago

@

I have found a bug. In the following file, replace it with:

TitaniumAS.Opc.Client-master\TitaniumAS.Opc.Client\Interop\Helpers\FileTimeConverter.cs

        var lft = (((long)fileTime.dwHighDateTime) << 32) + (fileTime.dwLowDateTime & 0xffffffff);

Thanks~ This way solve the problem. Thank you @fallfman && @EuroEager2008