/* ======================================================================== * Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System; using System.Collections.Generic; using System.Text; namespace Opc.Ua.Server { /// /// An interface to an object that manages a set of nodes in the address space. /// public interface INodeManager { /// /// Returns the NamespaceUris for the Nodes belonging to the NodeManager. /// /// /// By default the MasterNodeManager uses the namespaceIndex to determine who owns an Node. /// /// Servers that do not wish to partition their address space this way must provide their own /// implementation of MasterNodeManager.GetManagerHandle(). /// /// NodeManagers which depend on a custom partitioning scheme must return a null value. /// IEnumerable NamespaceUris { get; } /// /// Creates the address space by loading any configuration information an connecting to an underlying system (if applicable). /// /// A table of references that need to be added to other node managers. /// /// A node manager owns a set of nodes. These nodes may be known in advance or they may be stored in an /// external system are retrived on demand. These nodes may have two way references to nodes that are owned /// by other node managers. In these cases, the node managers only manage one half of those references. The /// other half of the reference should be returned to the MasterNodeManager. /// void CreateAddressSpace(IDictionary> externalReferences); /// /// Deletes the address by releasing all resources and disconnecting from any underlying system. /// void DeleteAddressSpace(); /// /// Returns an opaque handle identifying to the node to the node manager. /// /// A node handle, null if the node manager does not recognize the node id. /// /// The method must not block by querying an underlying system. If the node manager wraps an /// underlying system then it must check to see if it recognizes the syntax of the node id. /// The handle in this case may simply be a partially parsed version of the node id. /// object GetManagerHandle(NodeId nodeId); /// /// Adds references to the node manager. /// /// /// The node manager checks the dictionary for nodes that it owns and ensures the associated references exist. /// void AddReferences(IDictionary> references); /// /// Deletes a reference. /// ServiceResult DeleteReference( object sourceHandle, NodeId referenceTypeId, bool isInverse, ExpandedNodeId targetId, bool deleteBidirectional); /// /// Returns the metadata associated with the node. /// /// /// Returns null if the node does not exist. /// NodeMetadata GetNodeMetadata( OperationContext context, object targetHandle, BrowseResultMask resultMask); /// /// Returns the set of references that meet the filter criteria. /// /// The context to used when processing the request. /// The continuation point that stores the state of the Browse operation. /// The list of references that meet the filter criteria. /// /// NodeManagers will likely have references to other NodeManagers which means they will not be able /// to apply the NodeClassMask or fill in the attributes for the target Node. In these cases the /// NodeManager must return a ReferenceDescription with the NodeId and ReferenceTypeId set. The caller will /// be responsible for filling in the target attributes. /// The references parameter may already contain references when the method is called. The implementer must /// include these references when calculating whether a continutation point must be returned. /// /// Thrown if the context, continuationPoint or references parameters are null. /// Thrown if an error occurs during processing. void Browse( OperationContext context, ref ContinuationPoint continuationPoint, IList references); /// /// Finds the targets of the relative path from the source node. /// /// The context to used when processing the request. /// The handle for the source node. /// The relative path to follow. /// The NodeIds for any target at the end of the relative path. /// The NodeIds for any local target that is in another NodeManager. /// /// A null context indicates that the server's internal logic is making the call. /// The first target in the list must be the target that matches the instance declaration (if applicable). /// Any local targets that belong to other NodeManagers are returned as unresolvedTargetIds. /// The caller must check the BrowseName to determine if it matches the relativePath. /// The implementor must not throw an exception if the source or target nodes do not exist. /// /// Thrown if the sourceHandle, relativePath or targetIds parameters are null. void TranslateBrowsePath( OperationContext context, object sourceHandle, RelativePathElement relativePath, IList targetIds, IList unresolvedTargetIds); /// /// Reads the attribute values for a set of nodes. /// /// /// The MasterNodeManager pre-processes the nodesToRead and ensures that: /// - the AttributeId is a known attribute. /// - the IndexRange, if specified, is valid. /// - the DataEncoding and the IndexRange are not specified if the AttributeId is not Value. /// /// The MasterNodeManager post-processes the values by: /// - sets values[ii].StatusCode to the value of errors[ii].Code /// - creates a instance of DataValue if one does not exist and an errors[ii] is bad. /// - removes timestamps from the DataValue if the client does not want them. /// /// The node manager must ignore ReadValueId with the Processed flag set to true. /// The node manager must set the Processed flag for any ReadValueId that it processes. /// void Read( OperationContext context, double maxAge, IList nodesToRead, IList values, IList errors); /// /// Reads the history of a set of items. /// void HistoryRead( OperationContext context, HistoryReadDetails details, TimestampsToReturn timestampsToReturn, bool releaseContinuationPoints, IList nodesToRead, IList results, IList errors); /// /// Writes a set of values. /// /// /// Each node manager should only process node ids that it recognizes. If it processes a value it /// must set the Processed flag in the WriteValue structure. /// void Write( OperationContext context, IList nodesToWrite, IList errors); /// /// Updates the history for a set of nodes. /// void HistoryUpdate( OperationContext context, Type detailsType, IList nodesToUpdate, IList results, IList errors); /// /// Calls a method defined on a object. /// void Call( OperationContext context, IList methodsToCall, IList results, IList errors); /// /// Tells the NodeManager to report events from the specified notifier. /// /// /// This method may be called multiple times for the name monitoredItemId if the /// context for that MonitoredItem changes (i.e. UserIdentity and/or Locales). /// ServiceResult SubscribeToEvents( OperationContext context, object sourceId, uint subscriptionId, IEventMonitoredItem monitoredItem, bool unsubscribe); /// /// Tells the NodeManager to report events all events from all sources. /// /// /// This method may be called multiple times for the name monitoredItemId if the /// context for that MonitoredItem changes (i.e. UserIdentity and/or Locales). /// ServiceResult SubscribeToAllEvents( OperationContext context, uint subscriptionId, IEventMonitoredItem monitoredItem, bool unsubscribe); /// /// Tells the NodeManager to refresh any conditions. /// ServiceResult ConditionRefresh( OperationContext context, IList monitoredItems); /// /// Creates a set of monitored items. /// void CreateMonitoredItems( OperationContext context, uint subscriptionId, double publishingInterval, TimestampsToReturn timestampsToReturn, IList itemsToCreate, IList errors, IList filterErrors, IList monitoredItems, ref long globalIdCounter); /// /// Modifies a set of monitored items. /// void ModifyMonitoredItems( OperationContext context, TimestampsToReturn timestampsToReturn, IList monitoredItems, IList itemsToModify, IList errors, IList filterErrors); /// /// Deletes a set of monitored items. /// void DeleteMonitoredItems( OperationContext context, IList monitoredItems, IList processedItems, IList errors); /// /// Changes the monitoring mode for a set of monitored items. /// void SetMonitoringMode( OperationContext context, MonitoringMode monitoringMode, IList monitoredItems, IList processedItems, IList errors); } /// /// An interface to an object that manages a set of nodes in the address space. /// public interface INodeManager2 : INodeManager { /// /// Called when the session is closed. /// void SessionClosing(OperationContext context, NodeId sessionId, bool deleteSubscriptions); /// /// Returns true if the node is in the view. /// bool IsNodeInView(OperationContext context, NodeId viewId, object nodeHandle); } /// /// Stores metadata required to process requests related to a node. /// public class NodeMetadata { #region Constructors /// /// Initializes the object with its handle and NodeId. /// public NodeMetadata(object handle, NodeId nodeId) { m_handle = handle; m_nodeId = nodeId; } #endregion #region Public Properties /// /// The handle assigned by the NodeManager that owns the Node. /// public object Handle { get { return m_handle; } } /// /// The canonical NodeId for the Node. /// public NodeId NodeId { get { return m_nodeId; } } /// /// The NodeClass for the Node. /// public NodeClass NodeClass { get { return m_nodeClass; } set { m_nodeClass = value; } } /// /// The BrowseName for the Node. /// public QualifiedName BrowseName { get { return m_browseName; } set { m_browseName = value; } } /// /// The DisplayName for the Node. /// public LocalizedText DisplayName { get { return m_displayName; } set { m_displayName = value; } } /// /// The type definition for the Node (if one exists). /// public ExpandedNodeId TypeDefinition { get { return m_typeDefinition; } set { m_typeDefinition = value; } } /// /// The modelling for the Node (if one exists). /// public NodeId ModellingRule { get { return m_modellingRule; } set { m_modellingRule = value; } } /// /// Specifies which attributes are writeable. /// public AttributeWriteMask WriteMask { get { return m_writeMask; } set { m_writeMask = value; } } /// /// Whether the Node can be used with event subscriptions or for historial event queries. /// public byte EventNotifier { get { return m_eventNotifier; } set { m_eventNotifier = value; } } /// /// Whether the Node can be use to read or write current or historical values. /// public byte AccessLevel { get { return m_accessLevel; } set { m_accessLevel = value; } } /// /// Whether the Node is a Method that can be executed. /// public bool Executable { get { return m_executable; } set { m_executable = value; } } /// /// The DataType of the Value attribute for Variable or VariableType nodes. /// public NodeId DataType { get { return m_dataType; } set { m_dataType = value; } } /// /// The ValueRank for the Value attribute for Variable or VariableType nodes. /// public int ValueRank { get { return m_valueRank; } set { m_valueRank = value; } } /// /// The ArrayDimensions for the Value attribute for Variable or VariableType nodes. /// public IList ArrayDimensions { get { return m_arrayDimensions; } set { m_arrayDimensions = value; } } /// /// Specifies the AccessRestrictions that apply to a Node. /// public AccessRestrictionType AccessRestrictions { get { return m_accessRestrictions; } set { m_accessRestrictions = value; } } /// /// The value reflects the DefaultAccessRestrictions Property of the NamespaceMetadata Object for the Namespace /// to which the Node belongs. /// public AccessRestrictionType DefaultAccessRestrictions { get { return m_defaultAccessRestrictions; } set { m_defaultAccessRestrictions = value; } } /// /// The RolePermissions for the Node. /// Specifies the Permissions that apply to a Node for all Roles which have access to the Node. /// public RolePermissionTypeCollection RolePermissions { get { return m_rolePermissions; } set { m_rolePermissions = value; } } /// /// The DefaultRolePermissions of the Node's name-space meta-data /// The value reflects the DefaultRolePermissions Property from the NamespaceMetadata Object associated with the Node. /// public RolePermissionTypeCollection DefaultRolePermissions { get { return m_defaultRolePermissions; } set { m_defaultRolePermissions = value; } } /// /// The UserRolePermissions of the Node. /// Specifies the Permissions that apply to a Node for all Roles granted to current Session. /// public RolePermissionTypeCollection UserRolePermissions { get { return m_userRolePermissions; } set { m_userRolePermissions = value; } } /// /// The DefaultUserRolePermissions of the Node. /// The value reflects the DefaultUserRolePermissions Property from the NamespaceMetadata Object associated with the Node. /// public RolePermissionTypeCollection DefaultUserRolePermissions { get { return m_defaultUserRolePermissions; } set { m_defaultUserRolePermissions = value; } } #endregion #region Private Fields private object m_handle; private NodeId m_nodeId; private NodeClass m_nodeClass; private QualifiedName m_browseName; private LocalizedText m_displayName; private ExpandedNodeId m_typeDefinition; private NodeId m_modellingRule; private AttributeWriteMask m_writeMask; private byte m_eventNotifier; private byte m_accessLevel; private bool m_executable; private NodeId m_dataType; private int m_valueRank; private IList m_arrayDimensions; private AccessRestrictionType m_accessRestrictions; private AccessRestrictionType m_defaultAccessRestrictions; private RolePermissionTypeCollection m_rolePermissions; private RolePermissionTypeCollection m_defaultRolePermissions; private RolePermissionTypeCollection m_userRolePermissions; private RolePermissionTypeCollection m_defaultUserRolePermissions; #endregion } }