about override Read(...)
Posted: 26 Dec 2018, 04:09
Hi, I am new to OPC UA, and trying UA .net SDK.
1. Learn from example project "GettingStarted_VS2010", I trying to override the method Read(...) like below in MyNodeManager.cs. But however, when I click that item in UAExpert, and going into VS breakpoint, the operationHandles.Count always be 0... So I don't know how to implement real data publish in my UA server.
BTW, I didn't use UaModoler...
2. Then I learn another example of "UaDemoServer_VS2010". I find another version of Read(...) works as below.
But the further problem in this way, is I need manually judge the action details, to avoid overwrite unexpected value... So below code as a part of overrided Read(...). But this seems a not good way, especially about the hard-coded number 13.
3. By using the method #2 above, the Value can be published however. But the item list in Data Access View in UAExpert can not be refreshed. I guess there is missing callback as in the Read(...) example in #1 above, right? If so, I have to solve the issue of operationHandles.Count = 0 in #1...
1. Learn from example project "GettingStarted_VS2010", I trying to override the method Read(...) like below in MyNodeManager.cs. But however, when I click that item in UAExpert, and going into VS breakpoint, the operationHandles.Count always be 0... So I don't know how to implement real data publish in my UA server.
BTW, I didn't use UaModoler...
Code: Select all
protected override void Read(
RequestContext context,
TransactionHandle transaction,
IList<NodeAttributeOperationHandle> operationHandles,
IList<ReadValueId> settings)
{ ...}
2. Then I learn another example of "UaDemoServer_VS2010". I find another version of Read(...) works as below.
Code: Select all
protected override DataValue Read(
RequestContext context,
NodeAttributeHandle nodeHandle,
string indexRange,
QualifiedName dataEncoding)
{ ... }
Code: Select all
if (/*context.RequestType != ServiceType.Read || */nodeHandle.AttributeId != 13)
{
return base.Read(context, nodeHandle, indexRange, dataEncoding);
}
else
{
dv = new DataValue(value, DateTime.UtcNow);
return dv;
}