I am trying to understand how Historical Access works for a simple variable. I have a variable in my address space and I am updating the value of the variable on the basis of a timer. I do not have an underlying system (as shown in the example server in the sdk). I am updating the value of the variable something like this :
Code: Select all
variableNode.Write(13,newValue);
ReportDataChanges(Server.DefaultRequestContext, variableHandle);
Now I would like this variable to have Historical Access as well. What I understand from the documentation is this:
1. add a child HAConfiguration node under this variableNode.
2. set Historizing to true.
3. Call LinkModeltoNode method with appropriate parameters ,
I did all this like this :
Code: Select all
variableNode.Historizing = true;
variableNode.AccessLevel |= AccessLevels.HistoryReadOrWrite;
variableNode.UserAccessLevel |= AccessLevels.HistoryReadOrWrite;
settings = new CreateObjectSettings()
{
ParentNodeId = variableNodeId,
ReferenceTypeId = ReferenceTypeIds.HasHistoricalConfiguration,
RequestedNodeId = new NodeId(9999,2),
BrowseName = BrowseNames.HAConfiguration,
TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.HistoricalDataConfigurationType
};
CreateObject(Server.DefaultRequestContext, settings);
LinkModelToNode(variableNodeId, new HistoricalDataConfigurationModel(), null, null, 500);
Code: Select all
history.Insert(new Variant(value, null), StatusCodes.Good, DateTime.UtcNow);