Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return of TimeStamps when reading a tag from Client! #96

Open
SmackyPappelroy opened this issue Jul 6, 2021 · 0 comments
Open

Return of TimeStamps when reading a tag from Client! #96

SmackyPappelroy opened this issue Jul 6, 2021 · 0 comments

Comments

@SmackyPappelroy
Copy link

SmackyPappelroy commented Jul 6, 2021

In the ReadEvent method you don't return any time stamps:

public ReadEvent<T> Read<T>(string tag)
        {
            var nodesToRead = BuildReadValueIdCollection(tag, Attributes.Value);
            DataValueCollection results;
            DiagnosticInfoCollection diag;
            _session.Read(
                requestHeader: null,
                maxAge: 0,
                timestampsToReturn: TimestampsToReturn.Neither,
                nodesToRead: nodesToRead,
                results: out results,
                diagnosticInfos: out diag);
            var val = results[0];

            var readEvent = new ReadEvent<T>();
            readEvent.Value = (T)val.Value;
            readEvent.SourceTimestamp = val.SourceTimestamp;
            readEvent.ServerTimestamp = val.ServerTimestamp;
            if (StatusCode.IsGood(val.StatusCode)) readEvent.Quality = Quality.Good;
            if (StatusCode.IsBad(val.StatusCode)) readEvent.Quality = Quality.Bad;
            return readEvent;
        }

Can you change the code to:

 public ReadEvent<T> Read<T>(string tag)
  {
      var nodesToRead = BuildReadValueIdCollection(tag, Attributes.Value);
      DataValueCollection results;
      DiagnosticInfoCollection diag;
      _session.Read(
          requestHeader: null,
          maxAge: 0,
          timestampsToReturn: TimestampsToReturn.Both,
          nodesToRead: nodesToRead,
          results: out results,
          diagnosticInfos: out diag);
      var val = results[0];

      var readEvent = new ReadEvent<T>();
      readEvent.Value = (T)val.Value;
      readEvent.SourceTimestamp = val.SourceTimestamp;
      readEvent.ServerTimestamp = val.ServerTimestamp;
      if (StatusCode.IsGood(val.StatusCode)) readEvent.Quality = Quality.Good;
      if (StatusCode.IsBad(val.StatusCode)) readEvent.Quality = Quality.Bad;
      return readEvent;
  }

So it returns the timestamps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant