Closed AlexeyTipunin closed 6 years ago
or other arbitrary fields
Do you mean while monitoring?
reading and monitoring, and set on write
I'm not sure I understand what you're asking.
I want to read the value as well as its quality and time stamp of when it was installed. So I want to set the quality of the installation of values.
I'm sorry. When what was installed? The OPC server?
I want to read value, quality and time stamp. And I want to set the quality on value write.
I understand now. I'll look into it
This is definitely possible. These results are gotten but basically discarded.
I've already done this, here is my DA and UA code...
`public enum TagQualities { [DescriptionAttribute("None")] None, [DescriptionAttribute("Bad")] Bad, [DescriptionAttribute("Good")] Good }
public Practicon.OPC.Common.TagQualities TagQuality(string tagName)
{
var item = new OpcDa.Item { ItemName = tagName };
if (Status == OpcStatus.NotConnected)
{
throw new OpcException("Server not connected. Cannot read tag.");
}
var result = _server.Read(new[] { item })[0];
if (result.Quality == OpcDa.Quality.Bad)
{
return TagQualities.Bad;
}
else if (result.Quality == OpcDa.Quality.Good)
{
return TagQualities.Good;
}
return TagQualities.None;
}
//
///
UA Code
`/
///
DataValueCollection results;
DiagnosticInfoCollection diag;
_session.Read(
requestHeader: null,
maxAge: 0,
timestampsToReturn: TimestampsToReturn.Server,
nodesToRead: nodesToRead,
results: out results,
diagnosticInfos: out diag);
var val = results[0];
return val.ServerTimestamp;
}
public Practicon.OPC.Common.TagQualities TagQuality(string tagName)
{
var nodesToRead = BuildReadValueIdCollection(tagName, Attributes.Value);
DataValueCollection results;
DiagnosticInfoCollection diag;
_session.Read(
requestHeader: null,
maxAge: 0,
timestampsToReturn: TimestampsToReturn.Server,
nodesToRead: nodesToRead,
results: out results,
diagnosticInfos: out diag);
var val = results[0];
if (StatusCode.IsGood(val.StatusCode))
{
return TagQualities.Good;
}
else if (StatusCode.IsBad(val.StatusCode))
{
return TagQualities.Bad;
}
return TagQualities.None
}`
I've haveto use my own enumeration for Quality since I need a common result type to pass to COM clients...
That's very helpful. We'll also want to add it to the Node classes so we can retrieve these when reading tag's value. That way, it could optionally come back in the monitor callback in case you want to monitor it yourself
Hi guys, great work with the library. This specific point is also very important for me, I can do the changes in a branch, and then we can merge it, would that be fine by you? Thanks
@bajcmartinez, of course it would!
@jmbeach I have the changes ready, but can't push a new branch, can you give me access or you prefer me to do a fork? Thanks
I'd prefer you to do a fork and then make a pull request. Thanks!
Hello. Is it possible to get quality and a timestamp?