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

GetDefaultHistoryCapabilities does not return the existing node from address space #1320

Closed
ososnilknarf opened this issue Mar 12, 2021 · 3 comments · Fixed by #1334
Closed
Assignees
Labels
bug A bug was identified and should be fixed. investigating

Comments

@ososnilknarf
Copy link

ososnilknarf commented Mar 12, 2021

Type of Issue
[ x] Bug [ ] Enhancement [ ] Compliance [ ] Question [ ] Help wanted

The method DiagnosticsNodeManager.GetDefaultHistoryCapabilities() does not return the existing HistoryCapabilities node from the address space. Instead, it creates a new instance. There is already one there because it is part of the predefined node model for that NodeManager.
GetDefaultHistoryCapabilities() keeps a 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.
Additionally, the HistoryServerCapabilities node that already exists in the address space is a BaseObjectState, not the derived class HistoryServerCapabilitiesState.
Also 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.

What seems to be missing is to convert this node to HistoryServerCapabilitiesState in AddBehaviourToPredefinedNode(), and initialize m_historyCapabilities with that instance when it is created.

The following 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.

To Reproduce
Steps to reproduce the behavior:

  1. Add the following code to a NodeManager's CreateAddressSpace method (this code is from the sample HistoricalAccess Server):
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;
}
  1. Connect to the Server
  2. Browse Address space to the path "Objects/Server/ServerCapabilities/" and browse the children of that node
  3. Observe that there are 2 instances of the HistoryServerCapabilities node. One of them contains the values that were set in Step 1.
  4. Observe that the one with uninitialized values has the node id constant value Opc.Ua.ObjectIds.HistoryServerCapabilities

Expected behavior
There should be a single instance of the HistoryServerCapabilities node, containing the specified values, and accessible using the GetDefaultHistoryCapabilities() method, or by finding it by the node id constant, Opc.Ua.ObjectIds.HistoryServerCapabilities.

Environment (please complete the following information):

  • OPC Package Release Version [1.4.365.23]
  • Component: [e.g. Opc.Ua.Core]
AlinMoldovean added a commit to AlinMoldovean/UA-.NETStandard that referenced this issue Mar 22, 2021
@AlinMoldovean AlinMoldovean added the bug A bug was identified and should be fixed. label Mar 22, 2021
@AlinMoldovean AlinMoldovean self-assigned this Mar 22, 2021
@AlinMoldovean
Copy link
Contributor

Hello @ososnilknarf ,

Thanks for reporting this.
A fix was added in #1334

@ososnilknarf
Copy link
Author

Thanks Alin.
When should this be available in the nuget package?

@AlinMoldovean
Copy link
Contributor

@ososnilknarf,

For the moment we do not have a fixed date for a NuGet package release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug was identified and should be fixed. investigating
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants