Duplicate HistoryServerCapabilitiesState objects in HistricalAccessServer|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Duplicate HistoryServerCapabilitiesState objects in HistricalAccessServer
Avatar
Peter Franklin
Member
Members
Forum Posts: 24
Member Since:
04/14/2020
sp_UserOfflineSmall Offline
1
03/10/2021 - 17:26
sp_Permalink sp_Print

When following the sample code in the QuickStart sample "HistoricalAccess Server", in the method CreateAddressSpace() where it sets the history capabilities using this code:

lock (Server.DiagnosticsLock)
{
HistoryServerCapabilitiesState capabilities = Server.DiagnosticsNodeManager.GetDefaultHistoryCapabilities();
capabilities.AccessHistoryDataCapability.Value = true;
capabilities.InsertDataCapability.Value = true;
capabilities.ReplaceDataCapability.Value = true;
capabilities.UpdateDataCapability.Value = true;
capabilities.DeleteRawCapability.Value = true;
capabilities.DeleteAtTimeCapability.Value = true;
capabilities.InsertAnnotationCapability.Value = true;
}

This results in 2 instances of HistoryServerCapabilitiesState in the address space. Because the call to "GetDefaultHistoryCapabilities()" creates a new one even though there is already one in the address space.

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
03/10/2021 - 21:04
sp_Permalink sp_Print

Sounds like a bug in the sample.

GetDefaultHistoryCapabilities() should return the only instance.

Avatar
Peter Franklin
Member
Members
Forum Posts: 24
Member Since:
04/14/2020
sp_UserOfflineSmall Offline
3
03/11/2021 - 15:45
sp_Permalink sp_Print sp_EditHistory

Randy Armstrong said
Sounds like a bug in the sample.

GetDefaultHistoryCapabilities() should return the only instance.  

It looks like a bug in the OPC Library from what I can tell. The GetDefaultHistoryCapabilities() stores the instance in the private member m_historyCapabilities. That private member is only ever initialized in that method, and it never attempts to find the existing instance in the address space.

The HistoryServerCapabilities node already exists in the address space as it is a predefined node from the model file for the Config/DiagnosticNodeManager.

However, in the address space, it is only a NodeState, not an instance of the derived class HistoryServerCapabilitiesState. Maybe what is missing in the OPC library code is to add a case for this node to AddBehaviourToPredefinedNode(), and initialize m_historyCapabilities with that instance when it is created.

Short of that OPC library fix, we found that this workaround seems to work to get the existing predefined node and update it:

                var nodeHistoryServerCapabilities = FindNodeInAddressSpace(Opc.Ua.ObjectIds.HistoryServerCapabilities);

                if (nodeHistoryServerCapabilities == null)
                    return;

                var qualAHDCName = new QualifiedName("AccessHistoryDataCapability");

                nodeHistoryServerCapabilities.SetChildValue(SystemContext, qualAHDCName, true, true);

 

This is not ideal though, since the HistoryServerCapabilitiesState class isn't able to be used.

Also note that when HistoryServerCapabilities is created in GetDefaultHistoryCapabilities() it doesn't use the node ID constant that is provided with the OPC library, (Opc.Ua.ObjectIds.HistoryServerCapabilities), so the capabilities object would not be accessible using this nodeId.

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
03/11/2021 - 19:30
sp_Permalink sp_Print

You report the bug on GitHub:
https://github.com/OPCFoundati.....ard/issues

Your workaround seems reasonable.

The default object after load is a BaseObjectState instance. The AddBehaviourToPredefinedNode on the DiagnosticNodeManager method should convert it to a HistoryServerCapabilitiesState. If you have the SDK source you could update AddBehaviourToPredefinedNode

see:
https://github.com/OPCFoundati.....Manager.cs

Avatar
Peter Franklin
Member
Members
Forum Posts: 24
Member Since:
04/14/2020
sp_UserOfflineSmall Offline
5
03/12/2021 - 10:07
sp_Permalink sp_Print

If we did update DiagnosticsNodeManager.cs we would need to submit a pull request correct?

We do have the SDK source but we are only using it for troubleshooting purposes. We are using the nuget packages for our project.

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
03/12/2021 - 18:09
sp_Permalink sp_Print

Yes submit a pull request.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1349
Posts: 4579