Example #1
0
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Utils.Trace("Creating the Node Managers.");

            List<INodeManager> nodeManagers = new List<INodeManager>();

            // create the custom node managers.
            nodeManagers.Add(new TutorialNodeManager(server, configuration));

            #region Task #C4 - Add Support for COM Wrapper
            // manually configure the COM server to prevent unapproved wrappers.
            ComDaClientConfiguration wrapperConfig = new ComDaClientConfiguration();

            wrapperConfig.ServerName = "COM";
            wrapperConfig.ServerUrl = "opc.com://localhost/OPCSample.OpcDaServer";
            wrapperConfig.MaxReconnectWait = 10000;
            wrapperConfig.SeperatorChars = null;
            wrapperConfig.BrowseToNotSupported = false;
            wrapperConfig.ItemIdParser = new ItemIdParser();

            // create an instance of the wrapper node manager.
            TutorialDaComNodeManager manager = new TutorialDaComNodeManager(
                server,
                wrapperConfig.ServerUrl,
                wrapperConfig,
                true);

            nodeManagers.Add(manager);
            #endregion

            // create master node manager.
            return new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());
        }
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public CoreNodeManager(
            IServerInternal          server,
            ApplicationConfiguration configuration,
            ushort                   dynamicNamespaceIndex)
        {
            if (server == null)        throw new ArgumentNullException("server");
            if (configuration == null) throw new ArgumentNullException("configuration");
                  
            m_server                         = server;
            m_nodes                          = new NodeTable(server.NamespaceUris, server.ServerUris, server.TypeTree);
            m_monitoredItems                 = new Dictionary<uint,MonitoredItem>();
            m_defaultMinimumSamplingInterval = 1000;
            m_namespaceUris                  = new List<string>();
            m_dynamicNamespaceIndex          = dynamicNamespaceIndex; 
            
            #if LEGACY_CORENODEMANAGER
            m_eventSources = new Dictionary<object,IEventSource>();
            #endif

            // use namespace 1 if out of range.
            if (m_dynamicNamespaceIndex == 0 || m_dynamicNamespaceIndex >= server.NamespaceUris.Count)
            {
                m_dynamicNamespaceIndex = 1;
            }

            m_samplingGroupManager = new SamplingGroupManager(
                server, 
                this,
                (uint)configuration.ServerConfiguration.MaxNotificationQueueSize,
                configuration.ServerConfiguration.AvailableSamplingRates);
        }
Example #3
0
        /// <summary>
        /// Creates a new instance of a sampling group.
        /// </summary>
        public SamplingGroup(
            IServerInternal         server,
            INodeManager            nodeManager,
            List<SamplingRateGroup> samplingRates,
            OperationContext        context,
            double                  samplingInterval)
        {
            if (server == null)        throw new ArgumentNullException("server");
            if (nodeManager == null)   throw new ArgumentNullException("nodeManager");
            if (samplingRates == null) throw new ArgumentNullException("samplingRates");

            m_server           = server;
            m_nodeManager      = nodeManager;
            m_samplingRates    = samplingRates;
            m_session          = context.Session;
            m_diagnosticsMask  = (DiagnosticsMasks)context.DiagnosticsMask & DiagnosticsMasks.OperationAll;
            m_samplingInterval = AdjustSamplingInterval(samplingInterval);

            m_itemsToAdd    = new List<ISampledDataChangeMonitoredItem>();
            m_itemsToRemove = new List<ISampledDataChangeMonitoredItem>();
            m_items         = new Dictionary<uint, ISampledDataChangeMonitoredItem>();

            // create a event to signal shutdown.
            m_shutdownEvent = new ManualResetEvent(true);
        }
 /// <summary>
 /// Initializes the node manager.
 /// </summary>
 protected QuickstartNodeManager(
     IServerInternal server,
     params string[] namespaceUris)
 :
     this(server, (ApplicationConfiguration)null, namespaceUris)
 {            
 }
        /// <summary>
        /// Initializes the manager with its configuration.
        /// </summary>
        public SubscriptionManager(
            IServerInternal          server,
            ApplicationConfiguration configuration)
        {
            if (server == null)        throw new ArgumentNullException("server");
            if (configuration == null) throw new ArgumentNullException("configuration");
            
            m_server = server;
            
            m_minPublishingInterval      = configuration.ServerConfiguration.MinPublishingInterval;
            m_maxPublishingInterval      = configuration.ServerConfiguration.MaxPublishingInterval;
            m_publishingResolution       = configuration.ServerConfiguration.PublishingResolution;
            m_maxSubscriptionLifetime    = (uint)configuration.ServerConfiguration.MaxSubscriptionLifetime;
            m_minSubscriptionLifetime    = (uint)configuration.ServerConfiguration.MinSubscriptionLifetime;
            m_maxMessageCount            = (uint)configuration.ServerConfiguration.MaxMessageQueueSize;
            m_maxNotificationsPerPublish = (uint)configuration.ServerConfiguration.MaxNotificationsPerPublish;
            m_maxPublishRequestCount     = configuration.ServerConfiguration.MaxPublishRequestCount;
            m_maxSubscriptionCount       = configuration.ServerConfiguration.MaxSubscriptionCount;

            m_subscriptions           = new Dictionary<uint,Subscription>();
            m_publishQueues           = new Dictionary<NodeId,SessionPublishQueue>();
            m_statusMessages          = new Dictionary<NodeId, Queue<StatusMessage>>();
            
            // create a event to signal shutdown.
            m_shutdownEvent = new ManualResetEvent(true);
        }
 /// <summary>
 /// Called after the server has been started.
 /// </summary>
 protected override void OnServerStarted(IServerInternal server)
 {
     base.OnServerStarted(server);
     
     // request notifications when the user identity is changed. all valid users are accepted by default.
     server.SessionManager.ImpersonateUser += new ImpersonateEventHandler(SessionManager_ImpersonateUser);
 }
Example #7
0
 /// <summary>
 /// Adds the source to the type table.
 /// </summary>
 public ObjectSource(
     IServerInternal server,
     NodeSource      parent)
 : 
     base(server, parent)
 {
 }
        /// <summary>
        /// Creates a new instance of a sampling group.
        /// </summary>
        public SamplingGroupManager(
            IServerInternal                server,
            INodeManager                   nodeManager,
            uint                           maxQueueSize,
            IEnumerable<SamplingRateGroup> samplingRates)
        {
            if (server == null)      throw new ArgumentNullException("server");
            if (nodeManager == null) throw new ArgumentNullException("nodeManager");

            m_server          = server;
            m_nodeManager     = nodeManager;
            m_samplingGroups  = new List<SamplingGroup>();
            m_sampledItems    = new Dictionary<ISampledDataChangeMonitoredItem,SamplingGroup>();
            m_maxQueueSize    = maxQueueSize;

            if (samplingRates != null)
            {
                m_samplingRates = new List<SamplingRateGroup>(samplingRates);
            
                if (m_samplingRates.Count == 0)
                {
                    m_samplingRates = new List<SamplingRateGroup>(s_DefaultSamplingRates);
                }
            }

            if (m_samplingRates == null)
            {
                m_samplingRates = new List<SamplingRateGroup>(s_DefaultSamplingRates);
            }
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public ComHdaClientNodeManager(IServerInternal server, string namespaceUri, ComHdaClientConfiguration configuration, bool ownsTypeModel)
        :
            base(server, namespaceUri, ownsTypeModel)
        {
            SystemContext.SystemHandle = m_system = new ComHdaClientManager();
            SystemContext.NodeIdFactory = this;

            // save the configuration for the node manager.
            m_configuration = configuration;

            // set the alias root.
            AliasRoot = m_configuration.ServerName;

            if (String.IsNullOrEmpty(AliasRoot))
            {
                AliasRoot = "HDA";
            }

            // set the default parser if none provided.
            if (configuration.ItemIdParser == null)
            {
                configuration.ItemIdParser = new ComItemIdParser();
            }

            // set default parameters.
            if (m_configuration.AttributeSamplingInterval == 0)
            {
                m_configuration.AttributeSamplingInterval = 1000;
            }

            // create the list of subscriptions.
            m_subscriptionManagers = new Dictionary<int, HdaSubscribeRequestManager>();
            m_subscriptionManagers[ComUtils.LOCALE_SYSTEM_DEFAULT] = new HdaSubscribeRequestManager(SystemContext, ComUtils.LOCALE_SYSTEM_DEFAULT, m_configuration);
            m_monitoredItems = new Dictionary<uint, HdaSubscribeRequestManager>();
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public ComDaClientNodeManager(IServerInternal server, string namespaceUri, ComDaClientConfiguration configuration, bool ownsTypeModel)
        :
            base(server, namespaceUri, ownsTypeModel)
        {
            SystemContext.SystemHandle = m_system = new ComDaClientManager();
            SystemContext.NodeIdFactory = this;

            // save the configuration for the node manager.
            m_configuration = configuration;

            // set the alias root.
            AliasRoot = m_configuration.ServerName;

            if (String.IsNullOrEmpty(AliasRoot))
            {
                AliasRoot = "DA";
            }

            // set the default parser if none provided.
            if (configuration.ItemIdParser == null)
            {
                configuration.ItemIdParser = new ComItemIdParser();
            }

            // create the list of subscriptions.
            m_subscriptionManagers = new Dictionary<string, SubscribeRequestManager>();
            m_subscriptionManagers[String.Empty] = new SubscribeRequestManager(SystemContext, null, 1000);
            m_monitoredItems = new Dictionary<uint, SubscribeRequestManager>();
        }
Example #11
0
        /// <summary>
        /// Creates a new instance of a sampling group.
        /// </summary>
        public EventManager(IServerInternal server, uint maxQueueSize)
        {
            if (server == null) throw new ArgumentNullException("server");

            m_server = server;
            m_monitoredItems = new Dictionary<uint,IEventMonitoredItem>();
            m_maxEventQueueSize = maxQueueSize;
        }
Example #12
0
 /// <summary>
 /// Fetches the event type information from the AE server.
 /// </summary>
 public void LoadTypes(Opc.Ua.Client.Session client, IServerInternal server, NamespaceMapper mapper)
 {
     TypeNodes = new NodeIdDictionary<ReferenceDescription>();
     LoadTypes(client, server, mapper, Opc.Ua.ObjectTypeIds.BaseObjectType);
     LoadTypes(client, server, mapper, Opc.Ua.VariableTypeIds.BaseVariableType);
     LoadTypes(client, server, mapper, Opc.Ua.DataTypeIds.BaseDataType);
     LoadTypes(client, server, mapper, Opc.Ua.ReferenceTypeIds.References);
 }
Example #13
0
 /// <summary>
 /// Initializes the resource manager with the server instance that owns it.
 /// </summary>
 public ResourceManager(IServerInternal server, ApplicationConfiguration configuration)
 {
     if (server == null) throw new ArgumentNullException("server");    
     if (configuration == null) throw new ArgumentNullException("configuration");
    
     m_server = server;
     m_translationTables = new List<TranslationTable>();
 }
        /// <summary>
        /// Initilizes the manager.
        /// </summary>
        /// <param name="server"></param>
        public RequestManager(IServerInternal server)
        {
            if (server == null) throw new ArgumentNullException("server");

            m_server       = server;
            m_requests     = new Dictionary<uint,OperationContext>();
            m_requestTimer = null;
        }
Example #15
0
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public MethodSource(IServerInternal server, MethodArguments arguments) : base(server, null)
        {
            if (arguments == null) throw new ArgumentNullException("arguments");

            m_arguments = arguments;
            m_callbacks = new Dictionary<NodeId,CallbackParameters>();
            m_executable = m_userExecutable = true;
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemContext"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="context">The context.</param>
 public ServerSystemContext(IServerInternal server, OperationContext context)
 {
     OperationContext = context;
     NamespaceUris = server.NamespaceUris;
     ServerUris = server.ServerUris;
     TypeTable = server.TypeTree;
     EncodeableFactory = server.Factory;
 }
 /// <summary>
 /// Initializes the instance with the context for the node being monitored.
 /// </summary>
 public MonitoredNode(
     IServerInternal server,
     INodeManager nodeManager,
     NodeState node)
 {
     m_server = server;
     m_nodeManager = nodeManager;
     m_node = node;
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemContext"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="session">The session.</param>
 public ServerSystemContext(IServerInternal server, Session session)
 {
     OperationContext = null;
     SessionId = session.Id;
     UserIdentity = session.Identity;
     PreferredLocales = session.PreferredLocales;
     NamespaceUris = server.NamespaceUris;
     ServerUris = server.ServerUris;
     TypeTable = server.TypeTree;
     EncodeableFactory = server.Factory;
 }
Example #19
0
 /// <summary>
 /// Creates a new instance of the node.
 /// </summary>
 public static MethodSource Construct(
     IServerInternal server, 
     NodeSource      parent, 
     NodeId          referenceTypeId,
     NodeId          nodeId,
     QualifiedName   browseName,
     uint            numericId)
 {
     MethodSource instance = new MethodSource(server, parent);
     instance.Initialize(referenceTypeId, nodeId, browseName, numericId, null);
     return instance;
 }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public AggregationNodeManager(IServerInternal server, ApplicationConfiguration configuration, ConfiguredEndpoint endpoint, bool ownsTypeModel)
        :
            base(server, configuration, Namespaces.Aggregation, AggregationModel.Namespaces.Aggregation)
        {
            SystemContext.NodeIdFactory = this;

            m_configuration = configuration;
            m_endpoint = endpoint;
            m_ownsTypeModel = ownsTypeModel;
            m_clients = new Dictionary<NodeId, Opc.Ua.Client.Session>();
            m_mapper = new NamespaceMapper();
        }
Example #21
0
 /// <summary>
 /// Creates a new instance of the node.
 /// </summary>
 public static ObjectSource Construct(
     IServerInternal server, 
     NodeSource      parent, 
     NodeId          referenceTypeId,
     NodeId          nodeId,
     QualifiedName   browseName,
     uint            numericId)
 {
     ObjectSource instance = new ObjectSource(server, parent);
     instance.Initialize(referenceTypeId, nodeId, browseName, numericId, ObjectTypes.BaseObjectType);
     return instance;
 }
        /// <summary>
        /// Creates a new queue.
        /// </summary>
        public SessionPublishQueue(IServerInternal server, Session session, int maxPublishRequests)
        {
            if (server == null)  throw new ArgumentNullException("server");
            if (session == null) throw new ArgumentNullException("session");

            m_server              = server;
            m_session             = session;
            m_publishEvent        = new ManualResetEvent(false);
            m_queuedRequests      = new LinkedList<QueuedRequest>();
            m_queuedSubscriptions = new List<QueuedSubscription>();
            m_maxPublishRequests  = maxPublishRequests;
        }
Example #23
0
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Utils.Trace("Creating the Node Managers.");

            List<INodeManager> nodeManagers = new List<INodeManager>();

            // create the custom node managers.
            nodeManagers.Add(new PerfTestNodeManager(server, configuration));
            
            // create master node manager.
            return new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());
        }
Example #24
0
 /// <summary>
 /// Initializes the node manager.
 /// </summary>
 public ComClientNodeManager(IServerInternal server, string namespaceUri, bool ownsTypeModel)
 :
     base(server)
 {
     // check if this node manager owns the COM Interop type model.
     if (ownsTypeModel)
     {
         SetNamespaces(namespaceUri, Namespaces.ComInterop);
     }
     else
     {
         SetNamespaces(namespaceUri);
     }
 }
Example #25
0
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public MethodsNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        :
            base(server, configuration, Namespaces.Methods)
        {
            SystemContext.NodeIdFactory = this;

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension<MethodsServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new MethodsServerConfiguration();
            }
        }
Example #26
0
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public ViewsNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        :
            base(server, configuration, Quickstarts.Views.Namespaces.Views, Quickstarts.Views.Namespaces.Engineering, Quickstarts.Views.Namespaces.Operations)
        {
            SystemContext.NodeIdFactory = this;

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension<ViewsServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new ViewsServerConfiguration();
            }
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        protected QuickstartNodeManager(
            IServerInternal server,
            ApplicationConfiguration configuration,
            params string[] namespaceUris)
        {
            // set defaults.
            m_maxQueueSize = 1000;

            if (configuration != null)
            {
                if (configuration.ServerConfiguration != null)
                {
                    m_maxQueueSize = (uint)configuration.ServerConfiguration.MaxNotificationQueueSize;
                }
            }

            // save a reference to the UA server instance that owns the node manager.
            m_server = server;

            // all operations require information about the system 
            m_systemContext = m_server.DefaultSystemContext.Copy();

            // the node id factory assigns new node ids to new nodes. 
            // the strategy used by a NodeManager depends on what kind of information it provides.
            m_systemContext.NodeIdFactory = this;

            // create the table of namespaces that are used by the NodeManager.
            m_namespaceUris = namespaceUris;

            // add the uris to the server's namespace table and cache the indexes.
            if (namespaceUris != null)
            {
                m_namespaceIndexes = new ushort[m_namespaceUris.Length];

                for (int ii = 0; ii < m_namespaceUris.Length; ii++)
                {
                    m_namespaceIndexes[ii] = m_server.NamespaceUris.GetIndexOrAppend(m_namespaceUris[ii]);
                }
            }

            // create the table of monitored items.
            // these are items created by clients when they subscribe to data or events.
            m_monitoredItems = new Dictionary<uint, IDataChangeMonitoredItem>();

            // create the table of monitored nodes.
            // these are created by the node manager whenever a client subscribe to an attribute of the node.
            m_monitoredNodes = new Dictionary<NodeId, MonitoredNode>();
        }
 /// <summary>
 /// Associates the object with a server (mandatory) and its model parent (optional).
 /// </summary>
 protected NodeSource(
     IServerInternal server,
     NodeSource      parent)
 {
     if (server == null) throw new ArgumentNullException("server");
     
     m_server     = server;
     m_parent     = parent;
     m_references = new ReferenceCollection();
     
     if (parent != null)
     {
         m_lock = parent.m_lock;
         parent.AddChild(this);
     }
 }
Example #29
0
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public PerfTestNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        :
            base(server, configuration, Namespaces.PerfTest)
        {
            SystemContext.NodeIdFactory = this;
            SystemContext.SystemHandle = m_system = new UnderlyingSystem();

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension<PerfTestServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new PerfTestServerConfiguration();
            }
        }
Example #30
0
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Utils.Trace("Creating the Node Managers.");

            // add the types defined in the quickstart information model library to the factory.
            server.Factory.AddEncodeableTypes(typeof(Quickstarts.DataTypes.Types.VehicleType).Assembly);
            server.Factory.AddEncodeableTypes(this.GetType().Assembly);

            List<INodeManager> nodeManagers = new List<INodeManager>();

            // create the custom node managers.
            nodeManagers.Add(new DataTypesNodeManager(server, configuration));

            // create master node manager.
            return new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());
        }
Example #31
0
        /// <summary>
        /// Initializes the configuration and diagnostics manager.
        /// </summary>
        public ConfigurationNodeManager(
            IServerInternal server,
            ApplicationConfiguration configuration
            )
            :
            base(server, configuration)
        {
            m_rejectedStorePath = configuration.SecurityConfiguration.RejectedCertificateStore.StorePath;
            m_certificateGroups = new List <ServerCertificateGroup>();
            m_configuration     = configuration;
            // TODO: configure cert groups in configuration
            ServerCertificateGroup defaultApplicationGroup = new ServerCertificateGroup
            {
                BrowseName             = Opc.Ua.BrowseNames.DefaultApplicationGroup,
                CertificateTypes       = new NodeId[] { ObjectTypeIds.RsaSha256ApplicationCertificateType },
                ApplicationCertificate = configuration.SecurityConfiguration.ApplicationCertificate,
                IssuerStorePath        = configuration.SecurityConfiguration.TrustedIssuerCertificates.StorePath,
                TrustedStorePath       = configuration.SecurityConfiguration.TrustedPeerCertificates.StorePath
            };

            m_certificateGroups.Add(defaultApplicationGroup);
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public TetrisNodeManager(IServerInternal server, ApplicationConfiguration configuration)
            :
            base(server, configuration, Namespaces.Tetris)
        {
            SystemContext.NodeIdFactory = this;

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension <TetrisServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new TetrisServerConfiguration();
            }

            //----------------- Initialize the Tetris Functionality --------------------
            m_TetrisSimulation   = new TetrisSimulation();
            m_TetrisGame         = new TetrisGame();
            m_TetrisControlsForm = new TetrisServerControlsForm(m_TetrisGame);
            //m_TetrisControlsForm.Show();
            //--------------------------------------------------------------------------
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public AlarmConditionServerNodeManager(IServerInternal server, ApplicationConfiguration configuration)
            :
            base(server, configuration, Namespaces.AlarmCondition)
        {
            SystemContext.SystemHandle  = m_system = new UnderlyingSystem();
            SystemContext.NodeIdFactory = this;

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension <AlarmConditionServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new AlarmConditionServerConfiguration();
            }

            // create the table to store the available areas.
            m_areas = new Dictionary <string, AreaState>();

            // create the table to store the available sources.
            m_sources = new Dictionary <string, SourceState>();
        }
 /// <summary>
 /// Creates a new monitored item.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="nodeManager">The node manager.</param>
 /// <param name="managerHandle">The manager handle.</param>
 /// <param name="subscriptionId">The subscription id.</param>
 /// <param name="id">The id.</param>
 /// <param name="session">The session.</param>
 /// <param name="itemToMonitor">The item to monitor.</param>
 /// <param name="diagnosticsMasks">The diagnostics masks.</param>
 /// <param name="timestampsToReturn">The timestamps to return.</param>
 /// <param name="monitoringMode">The monitoring mode.</param>
 /// <param name="clientHandle">The client handle.</param>
 /// <param name="originalFilter">The original filter.</param>
 /// <param name="filterToUse">The filter to use.</param>
 /// <param name="range">The range.</param>
 /// <param name="samplingInterval">The sampling interval.</param>
 /// <param name="queueSize">Size of the queue.</param>
 /// <param name="discardOldest">if set to <c>true</c> [discard oldest].</param>
 /// <param name="minimumSamplingInterval">The minimum sampling interval.</param>
 /// <returns>The monitored item.</returns>
 protected virtual MonitoredItem CreateMonitoredItem(
     IServerInternal server,
     INodeManager nodeManager,
     object managerHandle,
     uint subscriptionId,
     uint id,
     Session session,
     ReadValueId itemToMonitor,
     DiagnosticsMasks diagnosticsMasks,
     TimestampsToReturn timestampsToReturn,
     MonitoringMode monitoringMode,
     uint clientHandle,
     MonitoringFilter originalFilter,
     MonitoringFilter filterToUse,
     Range range,
     double samplingInterval,
     uint queueSize,
     bool discardOldest,
     double minimumSamplingInterval)
 {
     return(new MonitoredItem(
                server,
                nodeManager,
                managerHandle,
                subscriptionId,
                id,
                itemToMonitor,
                diagnosticsMasks,
                timestampsToReturn,
                monitoringMode,
                clientHandle,
                originalFilter,
                filterToUse,
                range,
                samplingInterval,
                queueSize,
                discardOldest,
                minimumSamplingInterval));
 }
Example #35
0
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public MemoryBufferNodeManager(IServerInternal server, ApplicationConfiguration configuration)
            :
            base(server)
        {
            List <string> namespaceUris = new List <string>();

            namespaceUris.Add(Namespaces.MemoryBuffer);
            namespaceUris.Add(Namespaces.MemoryBuffer + "/Instance");

            NamespaceUris = namespaceUris;

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension <MemoryBufferConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new MemoryBufferConfiguration();
            }

            m_buffers = new Dictionary <string, MemoryBufferState>();
        }
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodesManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            var nodeManagers = new List <INodeManager>();

            if (!string.IsNullOrEmpty(NodesFileName) && !File.Exists(NodesFileName))
            {
                string errorMessage = $"The user node configuration file {NodesFileName} does not exist.";
                Logger.Error(errorMessage);
                throw new Exception(errorMessage);
            }

            // Add encodable complex types.
            server.Factory.AddEncodeableTypes(Assembly.GetExecutingAssembly());

            PlcNodeManager = new PlcNodeManager(server, configuration, NodesFileName);
            nodeManagers.Add(PlcNodeManager);

            if (PlcSimulation.AddSimpleEventsSimulation)
            {
                SimpleEventsNodeManager = new SimpleEventsNodeManager(server, configuration);
                nodeManagers.Add(SimpleEventsNodeManager);
            }

            if (PlcSimulation.AddAlarmSimulation)
            {
                AlarmNodeManager = new AlarmConditionServerNodeManager(server, configuration);
                nodeManagers.Add(AlarmNodeManager);
            }

            if (PlcSimulation.AddReferenceTestSimulation)
            {
                SimulationNodeManager = new ReferenceNodeManager(server, configuration);
                nodeManagers.Add(SimulationNodeManager);
            }

            var masterNodeManager = new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());

            return(masterNodeManager);
        }
Example #37
0
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Utils.LogInfo(Utils.TraceMasks.StartStop, "Creating the Reference Server Node Managers.");

            List <INodeManager> nodeManagers = new List <INodeManager>();

            // create the custom node managers.
            nodeManagers.Add(new ReferenceNodeManager(server, configuration));

            if (m_nodeManagerFactory == null || m_nodeManagerFactory.Count == 0)
            {
                AddDefaultFactories();
            }

            foreach (var nodeManagerFactory in m_nodeManagerFactory)
            {
                nodeManagers.Add(nodeManagerFactory.Create(server, configuration));
            }

            // create master node manager.
            return(new MasterNodeManager(server, configuration, null, nodeManagers.ToArray()));
        }
Example #38
0
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public CreateObjectMethodSource(IServerInternal server) : base(server, (NodeSource)null)
        {
            Argument arg = new Argument();

            arg.Name        = "ParentId";
            arg.Description = "The NodeId of the Parent Node.";
            arg.DataType    = DataTypes.NodeId;
            arg.ValueRank   = ValueRanks.Scalar;

            Arguments.Input.Add(arg);

            arg = new Argument();

            arg.Name        = "ReferenceTypeId";
            arg.Description = "The NodeId of the ReferenceTypeId from the Parent Node.";
            arg.DataType    = DataTypes.NodeId;
            arg.ValueRank   = ValueRanks.Scalar;

            Arguments.Input.Add(arg);

            arg = new Argument();

            arg.Name        = "BrowseName";
            arg.Description = "The BrowseName of the Object to create.";
            arg.DataType    = DataTypes.QualifiedName;
            arg.ValueRank   = ValueRanks.Scalar;

            Arguments.Input.Add(arg);

            arg = new Argument();

            arg.Name        = "NodeId";
            arg.Description = "The NodeId of the Object created.";
            arg.DataType    = DataTypes.NodeId;
            arg.ValueRank   = ValueRanks.Scalar;

            Arguments.Output.Add(arg);
        }
 /// <summary>
 /// Initializes the object with its node type.
 /// </summary>
 public ComMonitoredItem(
     IServerInternal server,
     INodeManager nodeManager,
     object mangerHandle,
     uint subscriptionId,
     uint id,
     Session session,
     ReadValueId itemToMonitor,
     DiagnosticsMasks diagnosticsMasks,
     TimestampsToReturn timestampsToReturn,
     MonitoringMode monitoringMode,
     uint clientHandle,
     MonitoringFilter originalFilter,
     MonitoringFilter filterToUse,
     Range range,
     double samplingInterval,
     uint queueSize,
     bool discardOldest,
     double sourceSamplingInterval)
     : base(server,
            nodeManager,
            mangerHandle,
            subscriptionId,
            id,
            itemToMonitor,
            diagnosticsMasks,
            timestampsToReturn,
            monitoringMode,
            clientHandle,
            originalFilter,
            filterToUse,
            range,
            samplingInterval,
            queueSize,
            discardOldest,
            sourceSamplingInterval)
 {
 }
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Utils.Trace("Creating the Node Managers.");

            List <INodeManager> nodeManagers = new List <INodeManager>();

            bool ownsTypeModel = true;
            ConfiguredEndpointCollection endpoints = configuration.ParseExtension <ConfiguredEndpointCollection>();

            // start the reverse connect host
            ReverseConnectManager reverseConnectManager = null;

            if (configuration.ClientConfiguration?.ReverseConnect != null)
            {
                var reverseConnect = configuration.ClientConfiguration.ReverseConnect;
                // start the reverse connection manager
                reverseConnectManager = new Opc.Ua.Client.ReverseConnectManager();
                foreach (var endpoint in reverseConnect.ClientEndpoints)
                {
                    reverseConnectManager.AddEndpoint(new Uri(endpoint.EndpointUrl));
                }
                // start the server even if no endpoint is configured, because
                // app config can change during operation  and the manager object
                // is needed
                reverseConnectManager.StartService(configuration);
            }

            foreach (ConfiguredEndpoint endpoint in endpoints.Endpoints)
            {
                nodeManagers.Add(new AggregationNodeManager(server, configuration, endpoint, reverseConnectManager, ownsTypeModel));
                ownsTypeModel = false;
            }



            // create master node manager.
            return(new MasterNodeManager(server, configuration, null, nodeManagers.ToArray()));
        }
Example #41
0
        /// <summary>
        /// Creates a new instance of a sampling group.
        /// </summary>
        public EventManager(IServerInternal server, uint maxQueueSize)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            m_server            = server;
            m_monitoredItems    = new Dictionary <uint, IEventMonitoredItem>();
            m_maxEventQueueSize = maxQueueSize;

            m_ServerAuditing = new Lazy <bool>(() => {
                // Extract the value of the Server_Auditing node
                // Note: The value is cached and it is not updated dynamically
                BaseVariableState auditing = m_server.NodeManager.DiagnosticsNodeManager.FindPredefinedNode(VariableIds.Server_Auditing,
                                                                                                            typeof(BaseVariableState)) as BaseVariableState;
                if (auditing != null)
                {
                    return(Convert.ToBoolean(auditing.Value, System.Globalization.CultureInfo.InvariantCulture));
                }
                return(false);
            });
        }
        /// <summary>
        /// Creates the node managers for the server.
        /// </summary>
        /// <remarks>
        /// This method allows the sub-class create any additional node managers which it uses. The SDK
        /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
        /// Any additional NodeManagers are expected to handle application specific nodes.
        ///
        /// Applications with small address spaces do not need to create their own NodeManagers and can add any
        /// application specific nodes to the CoreNodeManager. Applications should use custom NodeManagers when
        /// the structure of the address space is stored in another system or when the address space is too large
        /// to keep in memory.
        /// </remarks>
        protected override MasterNodeManager CreateMasterNodeManager(IServerInternal server, ApplicationConfiguration configuration)
        {
            Debug.WriteLine("Creating the Node Managers.");

            List <INodeManager> nodeManagers = new List <INodeManager>();

            // create the custom node managers.
            var aasnm = new global::AasOpcUaServer.AasNodeManager(server, configuration, thePackageEnv, theServerOptions);

            nodeManagers.Add(aasnm);

            // create master node manager.
            var x = new MasterNodeManager(server, configuration, null, nodeManagers.ToArray());

            // try to do some fixes
            if (x.NodeManagers.Count > 0)
            {
                var cm = x.NodeManagers[0] as CustomNodeManager2;
            }

            // ok
            return(x);
        }
        /// <summary>
        /// Initializes the node manager.
        /// </summary>
        public HistoricalEventsNodeManager(IServerInternal server, ApplicationConfiguration configuration)
            :
            base(server, configuration)
        {
            SystemContext.NodeIdFactory = this;

            // set one namespace for the type model and one names for dynamically created nodes.
            string[] namespaceUrls = new string[1];
            namespaceUrls[0] = Namespaces.HistoricalEvents;
            SetNamespaces(namespaceUrls);

            // get the configuration for the node manager.
            m_configuration = configuration.ParseExtension <HistoricalEventsServerConfiguration>();

            // use suitable defaults if no configuration exists.
            if (m_configuration == null)
            {
                m_configuration = new HistoricalEventsServerConfiguration();
            }

            // initilize the report generator.
            m_generator = new ReportGenerator();
            m_generator.Initialize();
        }
Example #44
0
        /// <summary>
        /// Creates a new instance of a sampling group.
        /// </summary>
        public SamplingGroupManager(
            IServerInternal server,
            INodeManager nodeManager,
            uint maxQueueSize,
            IEnumerable <SamplingRateGroup> samplingRates)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (nodeManager == null)
            {
                throw new ArgumentNullException("nodeManager");
            }

            m_server         = server;
            m_nodeManager    = nodeManager;
            m_samplingGroups = new List <SamplingGroup>();
            m_sampledItems   = new Dictionary <ISampledDataChangeMonitoredItem, SamplingGroup>();
            m_maxQueueSize   = maxQueueSize;

            if (samplingRates != null)
            {
                m_samplingRates = new List <SamplingRateGroup>(samplingRates);

                if (m_samplingRates.Count == 0)
                {
                    m_samplingRates = new List <SamplingRateGroup>(s_DefaultSamplingRates);
                }
            }

            if (m_samplingRates == null)
            {
                m_samplingRates = new List <SamplingRateGroup>(s_DefaultSamplingRates);
            }
        }
Example #45
0
 /// <summary>
 /// Initilizes the manager.
 /// </summary>
 public AggregateManager(IServerInternal server)
 {
     m_server    = server;
     m_factories = new Dictionary <NodeId, AggregatorFactory>();
     m_minimumProcessingInterval = 1000;
 }
Example #46
0
 /// <inheritdoc/>
 public INodeManager Create(IServerInternal server,
                            ApplicationConfiguration configuration)
 {
     return(new MemoryBufferNodeManager(server, configuration));
 }
 /// <inheritdoc/>
 public INodeManager Create(IServerInternal server,
                            ApplicationConfiguration configuration)
 {
     return(new AlarmConditionServerNodeManager(server, configuration));
 }
 /// <summary>
 /// Initializes the node manager.
 /// </summary>
 public TutorialDaComNodeManager(IServerInternal server, string namespaceUri, ComDaClientConfiguration configuration, bool ownsTypeModel)
     :
     base(server, namespaceUri, configuration, ownsTypeModel)
 {
 }
Example #49
0
 /// <inheritdoc/>
 protected override void OnNodeManagerStarted(IServerInternal server)
 {
     _logger.Information("The NodeManagers have started.");
     base.OnNodeManagerStarted(server);
 }
Example #50
0
 // Called after the server has been started.
 protected override void OnServerStarted(IServerInternal server)
 {
     base.OnServerStarted(server);
 }
Example #51
0
 /// <summary>
 /// Initializes the object with default values.
 /// </summary>
 public MethodSource(IServerInternal server, NodeSource parent) : base(server, parent)
 {
     m_arguments  = new MethodArguments();
     m_callbacks  = new Dictionary <NodeId, CallbackParameters>();
     m_executable = m_userExecutable = true;
 }
 public PlcNodeManager(IServerInternal server, ApplicationConfiguration configuration, string nodeFileName = null)
     : base(server, configuration, new string[] { Namespaces.OpcPlcApplications, Namespaces.OpcPlcBoiler, Namespaces.OpcPlcBoilerInstance, })
 {
     _nodeFileName = nodeFileName;
     SystemContext.NodeIdFactory = this;
 }
 public PlcNodeManagerFromFile(IServerInternal server, ApplicationConfiguration configuration, string nodeFile)
     : base(server, configuration)
 {
     this._nodeFile = nodeFile;
     SystemContext.NodeIdFactory = this;
 }
 /// <inheritdoc/>
 public INodeManager Create(IServerInternal server, ApplicationConfiguration configuration)
 {
     return(new BoilerNodeManager(server, configuration, NamespacesUris.ToArray()));
 }
        protected override void OnServerStarted(IServerInternal server)
        {
            // start the simulation

            base.OnServerStarted(server);
        }
Example #56
0
        public Session(
            OperationContext context,
            IServerInternal server,
            X509Certificate2 serverCertificate,
            NodeId authenticationToken,
            byte[]                  serverNonce,
            string sessionName,
            ApplicationDescription clientDescription,
            string endpointUrl,
            X509Certificate2 clientCertificate,
            double sessionTimeout,
            uint maxResponseMessageSize,
            double maxRequestAge,
            int maxBrowseContinuationPoints,
            int maxHistoryContinuationPoints)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // verify that a secure channel was specified.
            if (context.ChannelContext == null)
            {
                throw new ServiceResultException(StatusCodes.BadSecureChannelIdInvalid);
            }

            m_server = server;
            m_authenticationToken          = authenticationToken;
            m_serverNonce                  = serverNonce;
            m_sessionName                  = sessionName;
            m_serverCertificate            = serverCertificate;
            m_clientCertificate            = clientCertificate;
            m_secureChannelId              = context.ChannelContext.SecureChannelId;
            m_maxResponseMessageSize       = maxResponseMessageSize;
            m_maxRequestAge                = maxRequestAge;
            m_maxBrowseContinuationPoints  = maxBrowseContinuationPoints;
            m_maxHistoryContinuationPoints = maxHistoryContinuationPoints;
            m_endpoint = context.ChannelContext.EndpointDescription;

            // use anonymous the default identity.
            m_identity = new UserIdentity();

            // initialize diagnostics.
            m_diagnostics = new SessionDiagnosticsDataType();

            m_diagnostics.SessionId                          = null;
            m_diagnostics.SessionName                        = sessionName;
            m_diagnostics.ClientDescription                  = clientDescription;
            m_diagnostics.ServerUri                          = null;
            m_diagnostics.EndpointUrl                        = endpointUrl;
            m_diagnostics.LocaleIds                          = new StringCollection();
            m_diagnostics.ActualSessionTimeout               = sessionTimeout;
            m_diagnostics.ClientConnectionTime               = DateTime.UtcNow;
            m_diagnostics.ClientLastContactTime              = DateTime.UtcNow;
            m_diagnostics.CurrentSubscriptionsCount          = 0;
            m_diagnostics.CurrentMonitoredItemsCount         = 0;
            m_diagnostics.CurrentPublishRequestsInQueue      = 0;
            m_diagnostics.TotalRequestCount                  = new ServiceCounterDataType();
            m_diagnostics.UnauthorizedRequestCount           = 0;
            m_diagnostics.ReadCount                          = new ServiceCounterDataType();
            m_diagnostics.HistoryReadCount                   = new ServiceCounterDataType();
            m_diagnostics.WriteCount                         = new ServiceCounterDataType();
            m_diagnostics.HistoryUpdateCount                 = new ServiceCounterDataType();
            m_diagnostics.CallCount                          = new ServiceCounterDataType();
            m_diagnostics.CreateMonitoredItemsCount          = new ServiceCounterDataType();
            m_diagnostics.ModifyMonitoredItemsCount          = new ServiceCounterDataType();
            m_diagnostics.SetMonitoringModeCount             = new ServiceCounterDataType();
            m_diagnostics.SetTriggeringCount                 = new ServiceCounterDataType();
            m_diagnostics.DeleteMonitoredItemsCount          = new ServiceCounterDataType();
            m_diagnostics.CreateSubscriptionCount            = new ServiceCounterDataType();
            m_diagnostics.ModifySubscriptionCount            = new ServiceCounterDataType();
            m_diagnostics.SetPublishingModeCount             = new ServiceCounterDataType();
            m_diagnostics.PublishCount                       = new ServiceCounterDataType();
            m_diagnostics.RepublishCount                     = new ServiceCounterDataType();
            m_diagnostics.TransferSubscriptionsCount         = new ServiceCounterDataType();
            m_diagnostics.DeleteSubscriptionsCount           = new ServiceCounterDataType();
            m_diagnostics.AddNodesCount                      = new ServiceCounterDataType();
            m_diagnostics.AddReferencesCount                 = new ServiceCounterDataType();
            m_diagnostics.DeleteNodesCount                   = new ServiceCounterDataType();
            m_diagnostics.DeleteReferencesCount              = new ServiceCounterDataType();
            m_diagnostics.BrowseCount                        = new ServiceCounterDataType();
            m_diagnostics.BrowseNextCount                    = new ServiceCounterDataType();
            m_diagnostics.TranslateBrowsePathsToNodeIdsCount = new ServiceCounterDataType();
            m_diagnostics.QueryFirstCount                    = new ServiceCounterDataType();
            m_diagnostics.QueryNextCount                     = new ServiceCounterDataType();
            m_diagnostics.RegisterNodesCount                 = new ServiceCounterDataType();
            m_diagnostics.UnregisterNodesCount               = new ServiceCounterDataType();

            // initialize security diagnostics.
            m_securityDiagnostics = new SessionSecurityDiagnosticsDataType();

            m_securityDiagnostics.SessionId               = m_sessionId;
            m_securityDiagnostics.ClientUserIdOfSession   = m_identity.DisplayName;
            m_securityDiagnostics.AuthenticationMechanism = m_identity.TokenType.ToString();
            m_securityDiagnostics.Encoding = context.ChannelContext.MessageEncoding.ToString();

            m_securityDiagnostics.ClientUserIdHistory = new StringCollection();
            m_securityDiagnostics.ClientUserIdHistory.Add(m_identity.DisplayName);

            EndpointDescription description = context.ChannelContext.EndpointDescription;

            if (description != null)
            {
                m_securityDiagnostics.TransportProtocol = new Uri(description.EndpointUrl).Scheme;
                m_securityDiagnostics.SecurityMode      = m_endpoint.SecurityMode;
                m_securityDiagnostics.SecurityPolicyUri = m_endpoint.SecurityPolicyUri;
            }

            if (clientCertificate != null)
            {
                m_securityDiagnostics.ClientCertificate = clientCertificate.RawData;
            }

            ServerSystemContext systemContext = m_server.DefaultSystemContext.Copy(context);

            // create diagnostics object.
            m_sessionId = server.DiagnosticsNodeManager.CreateSessionDiagnostics(
                systemContext,
                m_diagnostics,
                OnUpdateDiagnostics,
                m_securityDiagnostics,
                OnUpdateSecurityDiagnostics);

            // report the audit event.
            ReportAuditCreateSessionEvent(systemContext);

            TraceState("CREATED");
        }
 /// <inheritdoc/>
 public INodeManager Create(IServerInternal server,
                            ApplicationConfiguration configuration)
 {
     return(new TestDataNodeManager(server, configuration));
 }
 /// <inheritdoc/>
 public INodeManager CreateNodeManager(IServerInternal server,
                                       ApplicationConfiguration configuration)
 {
     return(new ReferenceNodeManager(server, configuration));
 }
 /// <summary>
 /// Adds the source to the type table.
 /// </summary>
 public VariableTypeSource(IServerInternal server) : base(server)
 {
 }
 /// <inheritdoc/>
 public INodeManager CreateNodeManager(IServerInternal server,
                                       ApplicationConfiguration configuration)
 {
     return(new HistoricalEventsNodeManager(server, configuration));
 }