Adding support for Historical Access

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
dennisi
Full Member
Full Member
Posts: 9
Joined: 27 May 2015, 05:49

Adding support for Historical Access

Post by dennisi »

Hello guys,

I am new to OPC Server UA. I am encountering ''The type of the history values of node 'NS2|String|Data Root\Site1' can not be displayed". Could you be able to help with this type of error. Below is the code how I construct my variable node.

Code: Select all

 CreateVariableSettings settings2 = new CreateVariableSettings()
            {
                ParentNodeId = parentNodeId,
                ReferenceTypeId = ReferenceTypeIds.HasComponent,
                RequestedNodeId = requestedNodeId,
                BrowseName = new QualifiedName("DefinitionString", 4),
                DisplayName = displayName,
                DataType = DataTypeIds.String,
                ValueRank = ValueRanks.Scalar,
                AccessLevel = (AccessLevels.CurrentReadOrWrite | AccessLevels.HistoryReadOrWrite),
                ValueType = NodeHandleType.ExternalPolled,
                ValueData = new SystemAddress() { Address = blockAddress, Offset = valueOffset, NodeFullPath = fullPath },
                Historizing = true,
                Value = sValue
            };

            CreateVariable(Server.DefaultRequestContext, settings2);

lock (InMemoryNodeLock)
            {
                if (treeEntry.IsHistorizing())
                {
                    SetNodeUserData(requestedNodeId, new SystemAddress() 
                    { 
                        Address = blockAddress, 
                        Offset = valueOffset, 
                        NodeFullPath = fullPath 
                    });
                    
                    NodeId configurationId = new NodeId(
                        editedParentNode + "." + displayName + "." + 
                        BrowseNames.HAConfiguration, 
                        InstanceNamespaceIndex);

                    parentNodeId = new NodeId(fullPath, InstanceNamespaceIndex);

                    // create historical configuration object.
                    CreateObjectSettings settings = new CreateObjectSettings()
                    {
                        ParentNodeId = parentNodeId,
                        ReferenceTypeId = ReferenceTypeIds.HasHistoricalConfiguration,
                        RequestedNodeId = configurationId,
                        BrowseName = BrowseNames.HAConfiguration,
                        TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.HistoricalDataConfigurationType,

                        // add optional properties.
                        OptionalBrowsePaths = new string[] 
                        { 
                            BrowseNames.StartOfArchive, 
                            BrowseNames.StartOfOnlineArchive 
                        }
                    };

                    CreateObject(Server.DefaultRequestContext, settings);

                    // Link model to node
                    LinkModelToNode(configurationId, treeEntry.HistoryConfiguration, null, null, 500);
                }
            }

Thanks in advance!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Adding support for Historical Access

Post by Support Team »

Hello,

You did not describe how you get this error.

We are asuming that you are using the history trend view of UaExpert. Are you using the latest version of UaExpert (1.3.1)?
Does the server return History results? You only pasted code for creating nodes. Did you implement CreateHistoryContinuationPoint? Did you implement HistoryReadRaw?

Best regards
Support Team

dennisi
Full Member
Full Member
Posts: 9
Joined: 27 May 2015, 05:49

Re: Adding support for Historical Access

Post by dennisi »

I used the latest version of the UA Expert which is 1.3.1.

I have implemented CreateHistoryContinuationPoint but i missed the HistoryReadRaw. Thank you for guiding me.
In addition, I am planning to query the history from an sql database, do you have some guide to store it in the in-memory storage. I am really new to opc stuff.

Thanks you.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Adding support for Historical Access

Post by Support Team »

Hello,

If you are implementing CreateHistoryContinuationPoint you need not to implement other history methods like HistoryReadRaw. It seems that there are no history read results available for the specified time range. Please see Lesson 7 of Server Getting Started.

Do you want to read the comple sql data base and store it in-memory? If you want to do this, you can create an instance of InMemoryHistoryDataSource and insert the entries from the data base. If you want to read the historian results from the data base for each HistoryRead (e.g. to avoid keeping in-memory historian values and data base consistent) you can implment the interface IHistoryDataSource.

Best regards
Support Team

Post Reply