/// <summary> /// Creates a new instance of a item. /// </summary> public ArchiveItemState(ISystemContext context, ArchiveItem item, ushort namespaceIndex) : base(null) { ArchiveItem = item; TypeDefinitionId = VariableTypeIds.DataItemType; SymbolicName = ArchiveItem.Name; NodeId = ConstructId(ArchiveItem.UniquePath, namespaceIndex); BrowseName = new QualifiedName(ArchiveItem.Name, namespaceIndex); DisplayName = new LocalizedText(BrowseName.Name); Description = null; WriteMask = 0; UserWriteMask = 0; DataType = DataTypeIds.BaseDataType; ValueRank = ValueRanks.Scalar; AccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; UserAccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; Historizing = true; _annotations = new PropertyState <Annotation>(this) { ReferenceTypeId = ReferenceTypeIds.HasProperty, TypeDefinitionId = VariableTypeIds.PropertyType, SymbolicName = BrowseNames.Annotations, BrowseName = BrowseNames.Annotations }; _annotations.DisplayName = new LocalizedText(_annotations.BrowseName.Name); _annotations.Description = null; _annotations.WriteMask = 0; _annotations.UserWriteMask = 0; _annotations.DataType = DataTypeIds.Annotation; _annotations.ValueRank = ValueRanks.Scalar; _annotations.AccessLevel = AccessLevels.HistoryReadOrWrite; _annotations.UserAccessLevel = AccessLevels.HistoryReadOrWrite; _annotations.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; _annotations.Historizing = false; AddChild(_annotations); _annotations.NodeId = NodeTypes.ConstructIdForComponent(_annotations, namespaceIndex); _configuration = new HistoricalDataConfigurationState(this); _configuration.MaxTimeInterval = new PropertyState <double>(_configuration); _configuration.MinTimeInterval = new PropertyState <double>(_configuration); _configuration.StartOfArchive = new PropertyState <DateTime>(_configuration); _configuration.StartOfOnlineArchive = new PropertyState <DateTime>(_configuration); _configuration.Create( context, null, BrowseNames.HAConfiguration, null, true); _configuration.SymbolicName = BrowseNames.HAConfiguration; _configuration.ReferenceTypeId = ReferenceTypeIds.HasHistoricalConfiguration; AddChild(_configuration); }
/// <summary> /// Creates a new variable. /// </summary> private BaseDataVariableState CreateHistoricalAccessVariable(NodeState parent, string path, string name, string description, NodeId dataType, int valueRank, byte accessLevel, object initialValue) { var variable = CreateBaseDataVariableState(parent, path, name, description, dataType, valueRank, accessLevel, initialValue); variable.Historizing = true; variable.AccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; variable.UserAccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; variable.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; // TODO Support of Annotations //var annotations = new PropertyState<Annotation>(variable) //{ // ReferenceTypeId = ReferenceTypeIds.HasProperty, // TypeDefinitionId = VariableTypeIds.PropertyType, // SymbolicName = Opc.Ua.BrowseNames.Annotations, // BrowseName = Opc.Ua.BrowseNames.Annotations //}; //annotations.DisplayName = new LocalizedText(annotations.BrowseName.Name); //annotations.Description = null; //annotations.WriteMask = 0; //annotations.UserWriteMask = 0; //annotations.DataType = DataTypeIds.Annotation; //annotations.ValueRank = ValueRanks.Scalar; //annotations.AccessLevel = AccessLevels.HistoryReadOrWrite; //annotations.UserAccessLevel = AccessLevels.HistoryReadOrWrite; //annotations.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; //annotations.Historizing = false; //variable.AddChild(annotations); //annotations.NodeId = new NodeId(annotations.BrowseName.Name, NamespaceIndex); HistoricalDataConfigurationState historicalDataConfigurationState = new HistoricalDataConfigurationState(variable); historicalDataConfigurationState.MaxTimeInterval = new PropertyState <double>(historicalDataConfigurationState); historicalDataConfigurationState.MinTimeInterval = new PropertyState <double>(historicalDataConfigurationState);; historicalDataConfigurationState.StartOfArchive = new PropertyState <DateTime>(historicalDataConfigurationState); historicalDataConfigurationState.StartOfOnlineArchive = new PropertyState <DateTime>(historicalDataConfigurationState); historicalDataConfigurationState.Create( SystemContext, null, Opc.Ua.BrowseNames.HAConfiguration, null, true); historicalDataConfigurationState.SymbolicName = Opc.Ua.BrowseNames.HAConfiguration; historicalDataConfigurationState.ReferenceTypeId = ReferenceTypeIds.HasHistoricalConfiguration; variable.AddChild(historicalDataConfigurationState); dynamicNodes_.Add(variable); return(variable); }
/// <summary> /// Creates a new instance of a item. /// </summary> public ArchiveItemState(ISystemContext context, ArchiveItem item, ushort namespaceIndex) : base(null) { m_archiveItem = item; this.TypeDefinitionId = VariableTypeIds.DataItemType; this.SymbolicName = m_archiveItem.Name; this.NodeId = ConstructId(m_archiveItem.UniquePath, namespaceIndex); this.BrowseName = new QualifiedName(m_archiveItem.Name, namespaceIndex); this.DisplayName = new LocalizedText(this.BrowseName.Name); this.Description = null; this.WriteMask = 0; this.UserWriteMask = 0; this.DataType = DataTypeIds.BaseDataType; this.ValueRank = ValueRanks.Scalar; this.AccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; this.UserAccessLevel = AccessLevels.HistoryReadOrWrite | AccessLevels.CurrentRead; this.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; this.Historizing = true; m_annotations = new PropertyState<Annotation>(this); m_annotations.ReferenceTypeId = ReferenceTypeIds.HasProperty; m_annotations.TypeDefinitionId = VariableTypeIds.PropertyType; m_annotations.SymbolicName = Opc.Ua.BrowseNames.Annotations; m_annotations.BrowseName = Opc.Ua.BrowseNames.Annotations; m_annotations.DisplayName = new LocalizedText(m_annotations.BrowseName.Name); m_annotations.Description = null; m_annotations.WriteMask = 0; m_annotations.UserWriteMask = 0; m_annotations.DataType = DataTypeIds.Annotation; m_annotations.ValueRank = ValueRanks.Scalar; m_annotations.AccessLevel = AccessLevels.HistoryReadOrWrite; m_annotations.UserAccessLevel = AccessLevels.HistoryReadOrWrite; m_annotations.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; m_annotations.Historizing = false; this.AddChild(m_annotations); m_annotations.NodeId = NodeTypes.ConstructIdForComponent(m_annotations, namespaceIndex); m_configuration = new HistoricalDataConfigurationState(this); m_configuration.MaxTimeInterval = new PropertyState<double>(m_configuration); m_configuration.MinTimeInterval = new PropertyState<double>(m_configuration); ; m_configuration.StartOfArchive = new PropertyState<DateTime>(m_configuration); m_configuration.StartOfOnlineArchive = new PropertyState<DateTime>(m_configuration); m_configuration.Create( context, null, Opc.Ua.BrowseNames.HAConfiguration, null, true); m_configuration.SymbolicName = Opc.Ua.BrowseNames.HAConfiguration; m_configuration.ReferenceTypeId = ReferenceTypeIds.HasHistoricalConfiguration; this.AddChild(m_configuration); }
/// <summary> /// Reads the historical configuration for the node. /// </summary> private HistoricalDataConfigurationState ReadConfiguration() { // load the defaults for the historical configuration object. HistoricalDataConfigurationState configuration = new HistoricalDataConfigurationState(null); configuration.Definition = new PropertyState<string>(configuration); configuration.MaxTimeInterval = new PropertyState<double>(configuration); configuration.MinTimeInterval = new PropertyState<double>(configuration); configuration.ExceptionDeviation = new PropertyState<double>(configuration); configuration.ExceptionDeviationFormat = new PropertyState<ExceptionDeviationFormat>(configuration); configuration.StartOfArchive = new PropertyState<DateTime>(configuration); configuration.StartOfOnlineArchive = new PropertyState<DateTime>(configuration); configuration.Create( m_session.SystemContext, null, Opc.Ua.BrowseNames.HAConfiguration, null, false); // get the browse paths to query. RelativePathElement element = new RelativePathElement(); element.ReferenceTypeId = Opc.Ua.ReferenceTypeIds.HasHistoricalConfiguration; element.IsInverse = false; element.IncludeSubtypes = false; element.TargetName = Opc.Ua.BrowseNames.HAConfiguration; RelativePath relativePath = new RelativePath(); relativePath.Elements.Add(element); BrowsePathCollection pathsToTranslate = new BrowsePathCollection(); GetBrowsePathFromNodeState( m_session.SystemContext, m_nodeId, configuration, relativePath, pathsToTranslate); // translate browse paths. BrowsePathResultCollection results = null; DiagnosticInfoCollection diagnosticInfos = null; m_session.TranslateBrowsePathsToNodeIds( null, pathsToTranslate, out results, out diagnosticInfos); ClientBase.ValidateResponse(results, pathsToTranslate); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, pathsToTranslate); // build list of values to read. ReadValueIdCollection valuesToRead = new ReadValueIdCollection(); for (int ii = 0; ii < pathsToTranslate.Count; ii++) { BaseVariableState variable = (BaseVariableState)pathsToTranslate[ii].Handle; variable.Value = null; variable.StatusCode = StatusCodes.BadNotSupported; if (StatusCode.IsBad(results[ii].StatusCode) || results[ii].Targets.Count == 0) { continue; } if (results[ii].Targets[0].RemainingPathIndex == UInt32.MaxValue && !results[ii].Targets[0].TargetId.IsAbsolute) { variable.NodeId = (NodeId)results[ii].Targets[0].TargetId; ReadValueId valueToRead = new ReadValueId(); valueToRead.NodeId = variable.NodeId; valueToRead.AttributeId = Attributes.Value; valueToRead.Handle = variable; valuesToRead.Add(valueToRead); } } // read the values. if (valuesToRead.Count > 0) { DataValueCollection values = null; m_session.Read( null, 0, TimestampsToReturn.Neither, valuesToRead, out values, out diagnosticInfos); ClientBase.ValidateResponse(values, valuesToRead); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, valuesToRead); for (int ii = 0; ii < valuesToRead.Count; ii++) { BaseVariableState variable = (BaseVariableState)valuesToRead[ii].Handle; variable.WrappedValue = values[ii].WrappedValue; variable.StatusCode = values[ii].StatusCode; } } return configuration; }