/// <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);
            }
        }
示例#2
0
 private static void Setup()
 {
     _logManager  = new OneLoggerLogManager(new ConsoleAsyncLogger(LogLevel.Debug));
     _nodeManager = new NodeManager(_serializer, _logManager);
     _nodeManager.SwitchUri(new Uri("http://localhost:8545"));
     _engine = new CliEngine();
 }
        public IRelationship CreateRelationship(TransactionFramework.ISoapTransactionLink transactionLink, Guid domainId, Guid rootMapId, Dictionary <ConnectionType, INode> nodes, RelationshipType relationshipType, string originalId)
        {
            FacadeRelationship facadeRelationship = new FacadeRelationship();

            InProcess.InProcessRelationship relationship = new InProcess.InProcessRelationship(MapManager);
            relationship.OriginLink       = transactionLink;
            relationship.Facade           = facadeRelationship;
            relationship.Id               = Guid.NewGuid();
            relationship.DomainId         = domainId;
            relationship.RootMapId        = rootMapId;
            relationship.RelationshipType = relationshipType;
            relationship.OriginalId       = originalId;
            relationship.Status           = LoadState.Full;

            facadeRelationship.BaseRelationship = relationship;

            foreach (KeyValuePair <ConnectionType, INode> relationshipContext in nodes)
            {
                ConnectionSet connection = ConnectionSetFactory.Instance.GetConnection(relationshipContext.Value, facadeRelationship, relationshipContext.Key);

                INodeManager newRelationshipNodes = relationship.Nodes;
                newRelationshipNodes.Load(connection);

                IRelationshipManager nodeRelationships = relationshipContext.Value.Relationships;
                nodeRelationships.Load(connection);
            }

            InProcessRelationships.Add(transactionLink, facadeRelationship);

            return(facadeRelationship);
        }
示例#4
0
 public PeerDiscoveryServiceTests()
 {
     _peerDiscoveryService        = GetRequiredService <IPeerDiscoveryService>();
     _nodeManager                 = GetRequiredService <INodeManager>();
     _discoveredNodeCacheProvider = GetRequiredService <IDiscoveredNodeCacheProvider>();
     _peerDiscoveryJobProcessor   = GetRequiredService <IPeerDiscoveryJobProcessor>();
 }
示例#5
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);
        }
示例#6
0
        internal void UpdateConnection(ConnectionType connectionType, INode node)
        {
            ConnectionSet matchingSet = null;

            foreach (ConnectionSet connectionSet in Connections)
            {
                if (connectionSet.ConnectionType == connectionType)
                {
                    matchingSet = connectionSet;
                    break;
                }
            }

            if (matchingSet != null && matchingSet.ConnectionType != null)
            {
                matchingSet.Node = node;
            }
            else
            {
                // This may occur if the type has just been changed for the relationship to which this NodeSet belongs.
                INodeManager nodeManager = this;

                matchingSet = ConnectionSetFactory.Instance.GetConnection(node, RelationshipContext, connectionType);
                nodeManager.Load(matchingSet);
            }
        }
        /// <summary>
        /// Processes all requests that are currently in the queue.
        /// </summary>
        private void ProcessRequests()
        {
            // Store a list of threads which are resolving SDKs
            List <Task> tasks = new List <Task>(_requests.Count);

            SdkResolverRequest item;

            while (_requests.TryDequeue(out item))
            {
                SdkResolverRequest request = item;

                // Start a thread to resolve an SDK and add it to the list of threads
                tasks.Add(Task.Run(() =>
                {
                    // Create an SdkReference from the request
                    SdkReference sdkReference = new SdkReference(request.Name, request.Version, request.MinimumVersion);

                    ILoggingService loggingService = Host.GetComponent(BuildComponentType.LoggingService) as ILoggingService;

                    // This call is usually cached so is very fast but can take longer for a new SDK that is downloaded.  Other queued threads for different SDKs will complete sooner and continue on which unblocks evaluations
                    SdkResult result = GetSdkResultAndCache(request.SubmissionId, sdkReference, new EvaluationLoggingContext(loggingService, request.BuildEventContext, request.ProjectPath), request.ElementLocation, request.SolutionPath, request.ProjectPath);

                    // Create a response
                    SdkResolverResponse response = new SdkResolverResponse(result.Path, result.Version);

                    // Get the node manager and send the response back to the node that requested the SDK
                    INodeManager nodeManager = Host.GetComponent(BuildComponentType.NodeManager) as INodeManager;

                    nodeManager.SendData(request.NodeId, response);
                }));
            }

            // Wait for all tasks to complete
            Task.WaitAll(tasks.ToArray());
        }
        /// <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);
        }
 public TimedBackgroundService(ILogger <TimedBackgroundService> logger, INodeManager nodemanager, IDbStorageManager dbmanager)
 {
     _logger      = (Logger <TimedBackgroundService>)logger;
     _nodemanager = (NodeManager)nodemanager;
     _db          = (DbStorageManager)dbmanager;
     _logger.LogInformation("Background Service initialized.");
 }
示例#10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode(
#if !FEATURE_NAMED_PIPES_FULL_DUPLEX
            string clientToServerPipeHandle,
            string serverToClientPipeHandle
#endif
            )
        {
            s_isOutOfProcNode = true;

#if FEATURE_APPDOMAIN_UNHANDLED_EXCEPTION
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);
#endif

#if !FEATURE_NAMED_PIPES_FULL_DUPLEX
            _clientToServerPipeHandle = clientToServerPipeHandle;
            _serverToClientPipeHandle = serverToClientPipeHandle;
#endif

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets     = new ConcurrentQueue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine  = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache   = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node
            OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket);

            ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance);

            _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService;

            if (s_projectRootElementCache == null)
            {
                s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException         += new EngineExceptionDelegate(OnEngineException);
            _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _buildRequestEngine.OnRequestBlocked          += new RequestBlockedDelegate(OnNewRequest);
            _buildRequestEngine.OnRequestComplete         += new RequestCompleteDelegate(OnRequestComplete);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResolverResponse.FactoryForDeserialization, _sdkResolverService as INodePacketHandler);
        }
示例#11
0
        public virtual void Init(IMapController mapController, INodeManager nodeManager)
        {
            _mapController = mapController;
            _nodeManager   = nodeManager;

            _mapController.OnNodeClicked += OnNodeClicked;
            _input.OnInputUpdate         += OnInput;
        }
示例#12
0
 public PeerDiscoveryJobProcessorTests()
 {
     _peerDiscoveryJobProcessor = GetRequiredService <IPeerDiscoveryJobProcessor>();
     _peerPool    = GetRequiredService <IPeerPool>();
     _nodeManager = GetRequiredService <INodeManager>();
     _discoveredNodeCacheProvider = GetRequiredService <IDiscoveredNodeCacheProvider>();
     _networkOptions = GetRequiredService <IOptionsSnapshot <NetworkOptions> >().Value;
 }
示例#13
0
        public PeerDiscoveryService(IPeerPool peerPool, INodeManager nodeManager, IAccountService accountService)
        {
            _peerPool       = peerPool;
            _nodeManager    = nodeManager;
            _accountService = accountService;

            Logger = NullLogger <PeerDiscoveryService> .Instance;
        }
 /// <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;
 }
示例#15
0
 /// <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;
 }
示例#16
0
        /// <summary>
        /// Creates a set of monitored items.
        /// </summary>
        public MonitoredItem CreateMonitoredItem(
            OperationContext context,
            INodeManager nodeManager,
            object handle,
            uint subscriptionId,
            uint monitoredItemId,
            TimestampsToReturn timestampsToReturn,
            double publishingInterval,
            MonitoredItemCreateRequest itemToCreate,
            EventFilter filter)
        {
            lock (m_lock)
            {
                // calculate sampling interval.
                double samplingInterval = itemToCreate.RequestedParameters.SamplingInterval;

                if (samplingInterval < 0)
                {
                    samplingInterval = publishingInterval;
                }

                // limit the queue size.
                uint queueSize = itemToCreate.RequestedParameters.QueueSize;

                if (queueSize > m_maxEventQueueSize)
                {
                    queueSize = m_maxEventQueueSize;
                }

                // create the monitored item.
                MonitoredItem monitoredItem = new MonitoredItem(
                    m_server,
                    nodeManager,
                    handle,
                    subscriptionId,
                    monitoredItemId,
                    context.Session,
                    itemToCreate.ItemToMonitor,
                    context.DiagnosticsMask,
                    timestampsToReturn,
                    itemToCreate.MonitoringMode,
                    itemToCreate.RequestedParameters.ClientHandle,
                    filter,
                    filter,
                    null,
                    samplingInterval,
                    queueSize,
                    itemToCreate.RequestedParameters.DiscardOldest,
                    MinimumSamplingIntervals.Continuous);

                // save the monitored item.
                m_monitoredItems.Add(monitoredItemId, monitoredItem);

                return(monitoredItem);
            }
        }
示例#17
0
 /// <summary>
 /// Initializes the instance with the context for the node being monitored.
 /// </summary>
 public void InitializeMonitoring(
     IServerInternal server,
     INodeManager nodeManager)
 {
     lock (_dataLock) {
         Server                  = server;
         NodeManager             = nodeManager;
         _nonValueMonitoredItems = new Dictionary <uint, MemoryBufferMonitoredItem>();
     }
 }
示例#18
0
            public void AddRoot()
            {
                this.RegisterDependencies();
                INode <string> node = new SimpleNode <string>("Somestring", null);
                INodeManager <INode <string>, string> nodeManager = DiManager.GetInstance().Resolve <INodeManager <INode <string>, string> >();

                nodeManager.AddRoot(node);

                Assert.IsNotNull(nodeManager.Root);
                Assert.AreEqual(node.Id, nodeManager.Root.Id);
            }
示例#19
0
 public GrpcServerServiceTests()
 {
     _networkServer     = GetRequiredService <IAElfNetworkServer>();
     _serverService     = GetRequiredService <GrpcServerService>();
     _blockchainService = GetRequiredService <IBlockchainService>();
     _peerPool          = GetRequiredService <IPeerPool>();
     _eventBus          = GetRequiredService <ILocalEventBus>();
     _nodeManager       = GetRequiredService <INodeManager>();
     _osTestHelper      = GetRequiredService <OSTestHelper>();
     _handshakeProvider = GetRequiredService <IHandshakeProvider>();
 }
示例#20
0
 public GraphServices(
     IMind mind,
     IConnectionManager connectionManager,
     IPathFinder pathFinder,
     INodeManager nodeManager)
 {
     _mind = mind;
     _connectionManager = connectionManager;
     _pathFinder = pathFinder;
     _nodeManager = nodeManager;
 }
示例#21
0
        public GrpcServerService(ISyncStateService syncStateService, IConnectionService connectionService,
                                 IBlockchainService blockchainService, INodeManager nodeManager)
        {
            _syncStateService  = syncStateService;
            _connectionService = connectionService;
            _blockchainService = blockchainService;
            _nodeManager       = nodeManager;

            EventBus = NullLocalEventBus.Instance;
            Logger   = NullLogger <GrpcServerService> .Instance;
        }
示例#22
0
        private static void Setup()
        {
            _serializer.RegisterConverter(new ParityLikeTxTraceConverter());
            _serializer.RegisterConverter(new ParityAccountStateChangeConverter());
            _serializer.RegisterConverter(new ParityTraceActionConverter());
            _serializer.RegisterConverter(new ParityTraceResultConverter());

            _logManager  = new OneLoggerLogManager(new ConsoleAsyncLogger(LogLevel.Trace));
            _nodeManager = new NodeManager(_serializer, _logManager);
            _nodeManager.SwitchUri(new Uri("http://localhost:8545"));
            _engine = new CliEngine();
        }
        public PeerDiscoveryJobProcessor(INodeManager nodeManager,
                                         IDiscoveredNodeCacheProvider discoveredNodeCacheProvider, IAElfNetworkServer networkServer,
                                         IAccountService accountService)
        {
            _nodeManager = nodeManager;
            _discoveredNodeCacheProvider = discoveredNodeCacheProvider;
            _networkServer  = networkServer;
            _accountService = accountService;
            CreatePeerDiscoveryDataflow();

            Logger = NullLogger <PeerDiscoveryJobProcessor> .Instance;
        }
        public PeerDiscoveryService(IPeerPool peerPool, INodeManager nodeManager,
                                    IDiscoveredNodeCacheProvider discoveredNodeCacheProvider, IAElfNetworkServer aelfNetworkServer,
                                    IPeerDiscoveryJobProcessor peerDiscoveryJobProcessor)
        {
            _peerPool    = peerPool;
            _nodeManager = nodeManager;
            _discoveredNodeCacheProvider = discoveredNodeCacheProvider;
            _aelfNetworkServer           = aelfNetworkServer;
            _peerDiscoveryJobProcessor   = peerDiscoveryJobProcessor;

            Logger = NullLogger <PeerDiscoveryService> .Instance;
        }
示例#25
0
        public bool LoadRelationship(SoapNodeManager nodeManager)
        {
            Metadata.Clear();
            INodeManager nodeSetManager = Nodes;

            nodeSetManager.Clear();

            foreach (KeyValuePair <ServerObjects.MetadataContext, ServerObjects.Metadata> metadataPair in ServiceRelationship.Metadata)
            {
                if (metadataPair.Value.NodeUid.HasValue)
                {
                    INode node = nodeManager.FindNode(metadataPair.Value.NodeUid.Value);
                    Metadata.Load(metadataPair.Value, node);
                }
                else if (metadataPair.Value.RelationshipUid.HasValue)
                {
                    Metadata.Load(metadataPair.Value, null);
                }
            }

            foreach (KeyValuePair <Guid, Guid> relationship in ServiceRelationship.Nodes)
            {
                Guid descriptorTypeId = relationship.Key;
                Guid nodeId           = relationship.Value;

                // TODO: There needs to be a proper check for the ConnectionType that will perform an appropriate operation if none exists.
                if (MapManager.ConnectionTypes.ContainsKey(descriptorTypeId))
                {
                    INode          node;
                    ConnectionType connectionType = MapManager.ConnectionTypes[descriptorTypeId];

                    node = nodeManager.FindNode(nodeId);

                    ConnectionSet connectionSet = ConnectionSetFactory.Instance.GetConnection(node, this, connectionType);

                    if (node.Status != LoadState.None)
                    {
                        IRelationshipManager relationshipSetManager = node.Relationships;

                        relationshipSetManager.Load(connectionSet);
                    }

                    nodeSetManager.Load(connectionSet);
                }
            }

            Status = LoadState.Full;

            ProcessDelayedActions();

            return(true);
        }
示例#26
0
 public NodePairManager(string xmlFilePath, INodeManager nodemanager)
 {
     XmlFilePath = xmlFilePath;
     if(!File.Exists(xmlFilePath))
     {
         var xmlWriterSettings = new XmlWriterSettings { OmitXmlDeclaration = false, Indent = true };
         var xw = XmlWriter.Create(xmlFilePath, xmlWriterSettings);
         xw.WriteStartDocument();
         xw.WriteStartElement("NodePairs");
         xw.WriteEndElement();
         xw.WriteEndDocument();
         xw.Close();
     }
     _nodeManager = nodemanager;
 }
示例#27
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode()
        {
            s_isOutOfProcNode = true;

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets     = new ConcurrentQueue <INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent       = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine  = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache   = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node
            OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket);

            ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance);

            _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService;

            if (s_projectRootElementCacheBase == null)
            {
                s_projectRootElementCacheBase = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException         += OnEngineException;
            _buildRequestEngine.OnNewConfigurationRequest += OnNewConfigurationRequest;
            _buildRequestEngine.OnRequestBlocked          += OnNewRequest;
            _buildRequestEngine.OnRequestComplete         += OnRequestComplete;
            _buildRequestEngine.OnResourceRequest         += OnResourceRequest;

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResourceResponse, ResourceResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResult.FactoryForDeserialization, _sdkResolverService as INodePacketHandler);
        }
示例#28
0
        private void Awake()
        {
            MapDependencyContainer.RegisterSingleton <IMapController>(this);

            _nodeManager = GetComponentInChildren <INodeManager>();
            if (_nodeManager == null)
            {
                Debug.LogError($"NodeManager Component required for {GetType().Name}! [On GameObject {name} or it's children]");
                return;
            }
            _inputDelegate.Init(this, _nodeManager);

            _nodeManager.OnNodeClicked  += OnClicked;
            _nodeManager.OnNodeSelected += OnSelected;

            Bind();
        }
示例#29
0
 /// <summary>
 /// Clear selections between tab changes.
 /// </summary>
 /// <param name="sender">Object that raised the event.</param>
 /// <param name="e">Event arguments.</param>
 private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (_tabControl.SelectedItem != null)
         {
             INodeManager manager = (_tabControl.SelectedItem as TabItem).Tag as INodeManager;
             manager.SelectedNodes.Clear();
             manager.ActiveNode = null;
         }
         OnActiveNodeChanged(EventArgs.Empty);
     }
     catch (Exception err)
     {
         App.HandleException(err);
     }
 }
示例#30
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parameters">Parameters.</param>
        public LogViewerDocument(Project project, LogListener parameters)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Project = project;
            View    = new LogViewerControl();
            View.SelectedLogChanged += View_SelectedLogChanged;
            _logNodeManager          = new TreeViewNodeManager(View.LogContentData);
            Parameters = parameters;
        }
示例#31
0
        public async Task UnregisterNamespaceManagerInCollection(int totalManagers, int indexToRemove)
        {
            var fixture = new ServerFixture <StandardServer>();

            try
            {
                //-- Arrange
                const string ns            = "http://test.org/UA/Data/";
                var          namespaceUris = new List <string> {
                    ns
                };

                var additionalManagers = new INodeManager[totalManagers];
                for (int ii = 0; ii < totalManagers; ii++)
                {
                    var nodeManager = new Mock <INodeManager>();
                    nodeManager.Setup(x => x.NamespaceUris).Returns(namespaceUris);

                    additionalManagers[ii] = nodeManager.Object;
                }

                var nodeManagerToRemove = additionalManagers[indexToRemove];

                //-- Act
                var server = await fixture.StartAsync(TestContext.Out).ConfigureAwait(false);

                var sut = new MasterNodeManager(
                    server.CurrentInstance,
                    fixture.Config,
                    null,
                    additionalManagers);
                var result = sut.UnregisterNamespaceManager(ns, nodeManagerToRemove);

                //-- Assert
                Assert.IsTrue(result);
                Assert.Contains(ns, server.CurrentInstance.NamespaceUris.ToArray());
                var registeredManagers = sut.NamespaceManagers[server.CurrentInstance.NamespaceUris.GetIndex(ns)];
                Assert.AreEqual(totalManagers - 1, registeredManagers.Length);
                Assert.That(registeredManagers, Has.No.Member(nodeManagerToRemove));
            }
            finally
            {
                await fixture.StopAsync().ConfigureAwait(false);
            }
        }
示例#32
0
        /// <summary>
        /// Remove all managers.
        /// </summary>
        private void RemoveAllManagers()
        {
            List <INode> nodes = new List <INode>(Nodes);

            foreach (TabItem item in _tabControl.Items)
            {
                INodeManager manager = item.Tag as INodeManager;
                if (manager.Nodes.Count > 0)
                {
                    nodes.Add(manager.Nodes[0]);
                }
            }

            foreach (INode node in nodes)
            {
                RemoveManager(node);
            }
        }
示例#33
0
        /// <summary>
        /// Remove a manager.
        /// </summary>
        /// <param name="node">The node to remove the manager for.</param>
        private void RemoveManager(INode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            for (int i = 0; i < _tabControl.Items.Count; i++)
            {
                INodeManager manager = (_tabControl.Items[i] as TabItem).Tag as INodeManager;
                if (manager.Nodes.Count > 0 && manager.Nodes[0] == node)
                {
                    manager.ActiveNodeChanged -= manager_ActiveNodeChanged;
                    _tabControl.Items.RemoveAt(i);
                    break;
                }
            }
        }
示例#34
0
        public KnowledgeTreeManager(string xmlFilePath, INodeManager nodeManager)
        {
            XmlFilePath = xmlFilePath;
            _nodeManager = nodeManager;

            Root = new TreeNode(null);
            try
            {
                ReloadTree();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);

                // Simply reset the Root object if load failed.
                ResetTree();
            }
        }
示例#35
0
 /// <summary>
 /// Initializes the object with its node type.
 /// </summary>
 public MemoryBufferMonitoredItem(
     IServerInternal server,
     INodeManager nodeManager,
     object mangerHandle,
     uint offset,
     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)
     :
     base(
         server,
         nodeManager,
         mangerHandle,
         subscriptionId,
         id,
         session,
         itemToMonitor,
         diagnosticsMasks,
         timestampsToReturn,
         monitoringMode,
         clientHandle,
         originalFilter,
         filterToUse,
         range,
         samplingInterval,
         queueSize,
         discardOldest,
         minimumSamplingInterval)
 {
     m_offset = offset;
 }
示例#36
0
 /// <summary>
 /// Handles execution of the TabItemClose command.
 /// </summary>
 /// <param name="sender">Object that raised the event.</param>
 /// <param name="e">Event arguments.</param>
 private void CloseTabItemCommandExecute(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         TabItem tabItem = VisualHelper.GetAncestor <TabItem>(e.OriginalSource as DependencyObject);
         if (tabItem != null)
         {
             INodeManager manager = tabItem.Tag as INodeManager;
             if (manager.Nodes.Count > 0)
             {
                 RemoveManager(manager.Nodes[0]);
             }
         }
     }
     catch (Exception err)
     {
         App.HandleException(err);
     }
 }
		/// <summary>
		/// Initializes the object with its node type.
		/// </summary>
        public MemoryBufferMonitoredItem(
            IServerInternal     server,
            INodeManager        nodeManager,
            object              mangerHandle,
            uint                offset,
            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)
        :
            base(
                server,
                nodeManager,
                mangerHandle,
                subscriptionId,
                id,
                session,
                itemToMonitor,
                diagnosticsMasks,
                timestampsToReturn,
                monitoringMode,
                clientHandle,
                originalFilter,
                filterToUse,
                range,
                samplingInterval,
                queueSize,
                discardOldest,
                minimumSamplingInterval)
		{
            m_offset = offset;
        }
示例#38
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OutOfProcNode()
        {
            s_isOutOfProcNode = true;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);

            _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1");

            _receivedPackets = new Queue<INodePacket>();
            _packetReceivedEvent = new AutoResetEvent(false);
            _shutdownEvent = new ManualResetEvent(false);
            _legacyThreadingData = new LegacyThreadingData();

            _componentFactories = new BuildComponentFactoryCollection(this);
            _componentFactories.RegisterDefaultFactories();
            _packetFactory = new NodePacketFactory();

            _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine;
            _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache;
            _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager;

            if (s_projectRootElementCache == null)
            {
                s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */);
            }

            _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException);
            _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest);
            _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest);
            _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete);

            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this);
            (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this);
        }
示例#39
0
 public MainViewModel(INodeManager nodeManager, INodeMetadataManager nodeMetadataManager,
                      IKnowledgeTreeManager knowledgeTreeManager, INodePairManager nodePairManager)
 {
     if (nodeManager == null) throw new ArgumentNullException("nodeManager");
     if (nodeMetadataManager == null) throw new ArgumentNullException("nodeMetadataManager");
     if (knowledgeTreeManager == null) throw new ArgumentNullException("knowledgeTreeManager");
     if (nodePairManager == null) throw new ArgumentNullException("nodePairManager");
     _nodeManager = nodeManager;
     _nodeMetadataManager = nodeMetadataManager;
     _knowledgeTreeManager = knowledgeTreeManager;
     _nodePairManager = nodePairManager;
     _treeRoot = new TreeNodeViewModel(_knowledgeTreeManager.Root);
 }
示例#40
0
 /// <summary>
 /// Initializes the instance with the context for the node being monitored.
 /// </summary>
 public void InitializeMonitoring(
     IServerInternal server,
     INodeManager nodeManager)
 {
     lock (m_dataLock)
     {
         m_server = server;
         m_nodeManager = nodeManager;
         m_nonValueMonitoredItems = new Dictionary<uint, MemoryBufferMonitoredItem>();
     }
 }
示例#41
0
 public MonitoredItem CreateMonitoredItem(
     OperationContext           context,
     INodeManager               nodeManager,
     object                     handle,
     uint                       subscriptionId,
     uint                       monitoredItemId,
     TimestampsToReturn         timestampsToReturn,
     MonitoredItemCreateRequest itemToCreate,
     EventFilter                filter)
 {
     return CreateMonitoredItem(
         context,
         nodeManager,
         handle,
         subscriptionId,
         monitoredItemId,
         timestampsToReturn,
         0,
         itemToCreate,
         filter);
 }
示例#42
0
        /// <summary>
        /// Creates a set of monitored items.
        /// </summary>
        public MonitoredItem CreateMonitoredItem(
            OperationContext           context,
            INodeManager               nodeManager,
            object                     handle,
            uint                       subscriptionId,
            uint                       monitoredItemId,
            TimestampsToReturn         timestampsToReturn,
            double                     publishingInterval,
            MonitoredItemCreateRequest itemToCreate,
            EventFilter                filter)
        {
            lock (m_lock)
            {
                // calculate sampling interval.
                double samplingInterval = itemToCreate.RequestedParameters.SamplingInterval;
                
                if (samplingInterval < 0)
                {
                    samplingInterval = publishingInterval;
                }
                
                // limit the queue size.
                uint queueSize = itemToCreate.RequestedParameters.QueueSize;

                if (queueSize > m_maxEventQueueSize)
                {
                    queueSize = m_maxEventQueueSize;
                }
                
                // create the monitored item.
                MonitoredItem monitoredItem = new MonitoredItem(
                    m_server,
                    nodeManager,
                    handle,
                    subscriptionId,
                    monitoredItemId,
                    context.Session,
                    itemToCreate.ItemToMonitor,
                    context.DiagnosticsMask,
                    timestampsToReturn,
                    itemToCreate.MonitoringMode,
                    itemToCreate.RequestedParameters.ClientHandle,
                    filter,
                    filter,
                    null,
                    samplingInterval,
                    queueSize,
                    itemToCreate.RequestedParameters.DiscardOldest,
                    MinimumSamplingIntervals.Continuous);

                // save the monitored item.
                m_monitoredItems.Add(monitoredItemId, monitoredItem);

                return monitoredItem;
            }
        }
示例#43
0
        /// <summary>
        /// Registers the node manager as the node manager for Nodes in the specified namespace.
        /// </summary>
        /// <param name="namespaceUri">The URI of the namespace.</param>
        /// <param name="nodeManager">The NodeManager which owns node in the namespacee.</param>
        /// <remarks>
        /// Multiple NodeManagers may register interest in a Namespace. 
        /// The order in which this method is called determines the precedence if multiple NodeManagers exist.
        /// This method adds the namespaceUri to the Server's Namespace table if it does not already exist.
        /// 
        /// This method is thread safe and can be called at anytime.
        /// 
        /// This method does not have to be called for any namespaces that were in the NodeManager's 
        /// NamespaceUri property when the MasterNodeManager was created.
        /// </remarks>
        /// <exception cref="ArgumentNullException">Throw if the namespaceUri or the nodeManager are null.</exception>
        public void RegisterNamespaceManager(string namespaceUri, INodeManager nodeManager)
        {
            if (String.IsNullOrEmpty(namespaceUri)) throw new ArgumentNullException("namespaceUri");
            if (nodeManager == null) throw new ArgumentNullException("nodeManager");

            // look up the namespace uri.
            int index = m_server.NamespaceUris.GetIndex(namespaceUri);

            if (index < 0)
            {
                index = m_server.NamespaceUris.Append(namespaceUri);
            }

            // allocate a new table (using arrays instead of collections because lookup efficiency is critical).
            INodeManager[][] namespaceManagers = new INodeManager[m_server.NamespaceUris.Count][];

            lock (m_namespaceManagers)
            {
                // copy existing values.
                for (int ii = 0; ii < m_namespaceManagers.Length; ii++)
                {
                    if (m_namespaceManagers.Length >= ii)
                    {
                        namespaceManagers[ii] = m_namespaceManagers[ii];
                    }
                }

                // allocate a new array for the index being updated.
                INodeManager[] registeredManagers = namespaceManagers[index];

                if (registeredManagers == null)
                {
                    registeredManagers = new INodeManager[1];
                }
                else
                {
                    registeredManagers = new INodeManager[registeredManagers.Length+1];
                    Array.Copy(namespaceManagers[index], registeredManagers, namespaceManagers[index].Length);
                }

                // add new node manager to the end of the list.
                registeredManagers[registeredManagers.Length-1] = nodeManager;
                namespaceManagers[index] = registeredManagers;

                // replace the table.
                m_namespaceManagers = namespaceManagers;
            }
        }
示例#44
0
        /// <summary>
        /// Returns node handle and its node manager.
        /// </summary>
        public virtual object GetManagerHandle(NodeId nodeId, out INodeManager nodeManager)
        {
            nodeManager = null;
            object handle = null;

            // null node ids have no manager.
            if (NodeId.IsNull(nodeId))
            {
                return null;
            }

            // use the namespace index to select the node manager.
            int index = nodeId.NamespaceIndex;

            lock (m_namespaceManagers)
            {
                // check if node managers are registered - use the core node manager if unknown.
                if (index >= m_namespaceManagers.Length || m_namespaceManagers[index] == null)
                {
                    handle = m_nodeManagers[1].GetManagerHandle(nodeId);

                    if (handle != null)
                    {
                        nodeManager = m_nodeManagers[1];
                        return handle;
                    }

                    return null;
                }

                // check each of the registered node managers.
                INodeManager[] nodeManagers = m_namespaceManagers[index];

                for (int ii = 0; ii < nodeManagers.Length; ii++)
                {
                    handle = nodeManagers[ii].GetManagerHandle(nodeId);

                    if (handle != null)
                    {
                        nodeManager =  nodeManagers[ii];
                        return handle;
                    }
                }
            }

            // node not recognized.
            return null;
        }
示例#45
0
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public MasterNodeManager(
            IServerInternal          server,
            ApplicationConfiguration configuration,
            string                   dynamicNamespaceUri,
            params INodeManager[]    additionalManagers)
        {
            if (server == null) throw new ArgumentNullException("server");
            if (configuration == null) throw new ArgumentNullException("configuration");

            m_server = server;
            m_nodeManagers = new List<INodeManager>();
            m_maxContinuationPointsPerBrowse = (uint)configuration.ServerConfiguration.MaxBrowseContinuationPoints;

            // ensure the dynamic namespace uris.
            int dynamicNamespaceIndex = 1;
            
            if (!String.IsNullOrEmpty(dynamicNamespaceUri))
            {
                dynamicNamespaceIndex = server.NamespaceUris.GetIndex(dynamicNamespaceUri);

                if (dynamicNamespaceIndex == -1)
                {
                    dynamicNamespaceIndex = server.NamespaceUris.Append(dynamicNamespaceUri);
                }
            }

            // need to build a table of NamespaceIndexes and their NodeManagers.
            List<INodeManager> registeredManagers = null;
            Dictionary<int,List<INodeManager>> namespaceManagers = new Dictionary<int,List<INodeManager>>();
            
            namespaceManagers[0] = registeredManagers = new List<INodeManager>();            
            namespaceManagers[1] = registeredManagers = new List<INodeManager>();

            // always add the diagnostics node manager to the start of the list.
            DiagnosticsNodeManager diagnosticsManager = new DiagnosticsNodeManager(server, configuration);
            RegisterNodeManager(diagnosticsManager, registeredManagers, namespaceManagers);
                        
            // add the core node manager second because the diagnostics node manager takes priority.
            // always add the core node manager to the second of the list.
            m_nodeManagers.Add(new CoreNodeManager(m_server, configuration, (ushort)dynamicNamespaceIndex));
            
            // register core node manager for default UA namespace.
            namespaceManagers[0].Add(m_nodeManagers[1]);

            // register core node manager for built-in server namespace.
            namespaceManagers[1].Add(m_nodeManagers[1]);

            // add the custom NodeManagers provided by the application.
            if (additionalManagers != null)
            {
                foreach (INodeManager nodeManager in additionalManagers)
                {
                    RegisterNodeManager(nodeManager, registeredManagers, namespaceManagers);
                }

                // build table from dictionary.
                m_namespaceManagers = new INodeManager[m_server.NamespaceUris.Count][];

                for (int ii = 0; ii < m_namespaceManagers.Length; ii++)
                {
                    if (namespaceManagers.TryGetValue(ii, out registeredManagers))
                    {
                        m_namespaceManagers[ii] = registeredManagers.ToArray();
                    }
                }
            }
        }
示例#46
0
        /// <summary>
        /// Recursively processes the elements in the RelativePath starting at the specified index.
        /// </summary>
        private void TranslateBrowsePath(
            OperationContext           context,
            INodeManager               nodeManager,
            object                     sourceHandle,
            RelativePath               relativePath,
            BrowsePathTargetCollection targets,
            int                        index)
        {
            Debug.Assert(nodeManager != null);
            Debug.Assert(sourceHandle != null);
            Debug.Assert(relativePath != null);
            Debug.Assert(targets != null);

            // check for end of list.
            if (index < 0 || index >= relativePath.Elements.Count)
            {
                return;
            }
            
            // follow the next hop.
            RelativePathElement element = relativePath.Elements[index];

            // check for valid reference type.
            if (!element.IncludeSubtypes && NodeId.IsNull(element.ReferenceTypeId))
            {
                return;
            }

            // check for valid target name.
            if (QualifiedName.IsNull(element.TargetName))
            {
                throw new ServiceResultException(StatusCodes.BadBrowseNameInvalid);
            }

            List<ExpandedNodeId> targetIds = new List<ExpandedNodeId>();
            List<NodeId> externalTargetIds = new List<NodeId>();

            try
            {
                nodeManager.TranslateBrowsePath(
                    context,
                    sourceHandle,
                    element,
                    targetIds,
                    externalTargetIds);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error translating browse path.");
                return;
            }

            // must check the browse name on all external targets.
            for (int ii = 0; ii < externalTargetIds.Count; ii++)
            {
                // get the browse name from another node manager.
                ReferenceDescription description = new ReferenceDescription();

                UpdateReferenceDescription(
                    context,
                    externalTargetIds[ii],
                    NodeClass.Unspecified,
                    BrowseResultMask.BrowseName,
                    description);    
                
                // add to list if target name matches.
                if (description.BrowseName == element.TargetName)
                {
                    bool found = false;

                    for (int jj = 0; jj < targetIds.Count; jj++)
                    {
                        if (targetIds[jj] == externalTargetIds[ii])
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        targetIds.Add(externalTargetIds[ii]);
                    }
                }
            }

            // check if done after a final hop.
            if (index == relativePath.Elements.Count-1)
            {
                for (int ii = 0; ii < targetIds.Count; ii++)
                {
                    BrowsePathTarget target = new BrowsePathTarget();   
                 
                    target.TargetId = targetIds[ii];
                    target.RemainingPathIndex = UInt32.MaxValue;

                    targets.Add(target);
                }

                return;
            }

            // process next hops.
            for (int ii = 0; ii < targetIds.Count; ii++)
            {
                ExpandedNodeId targetId = targetIds[ii];

                // check for external reference.
                if (targetId.IsAbsolute)
                {
                    BrowsePathTarget target = new BrowsePathTarget();   
                 
                    target.TargetId = targetId;
                    target.RemainingPathIndex = (uint)(index+1);

                    targets.Add(target);
                    continue;
                }

                // check for valid start node.   
                sourceHandle = GetManagerHandle((NodeId)targetId, out nodeManager);

                if (sourceHandle == null)
                {
                    continue;
                }
            
                // recusively follow hops.
                TranslateBrowsePath(
                    context,
                    nodeManager,
                    sourceHandle,
                    relativePath,
                    targets,
                    index+1);
            }
        }
		/// <summary>
		/// Initializes the object with its node type.
		/// </summary>
        public MonitoredItem(
            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)
		{
            if (itemToMonitor == null) throw new ArgumentNullException("itemToMonitor");
            
			Initialize();
            
            m_server                  = server;
            m_nodeManager             = nodeManager;
            m_managerHandle           = mangerHandle;
            m_subscriptionId          = subscriptionId;
            m_id                      = id;
            m_session                 = session;
            m_nodeId                  = itemToMonitor.NodeId;
            m_attributeId             = itemToMonitor.AttributeId;
            m_indexRange              = itemToMonitor.IndexRange;
            m_parsedIndexRange        = itemToMonitor.ParsedIndexRange;
            m_encoding                = itemToMonitor.DataEncoding;
            m_diagnosticsMasks        = diagnosticsMasks;
            m_timestampsToReturn      = timestampsToReturn;
            m_monitoringMode          = monitoringMode;
            m_clientHandle            = clientHandle;
            m_originalFilter          = originalFilter;
            m_filterToUse             = filterToUse;
            m_range                   = 0;
            m_samplingInterval        = samplingInterval;
            m_queueSize               = queueSize;
            m_discardOldest           = discardOldest;
            m_sourceSamplingInterval  = (int)sourceSamplingInterval;
            m_calculator              = null;
            m_nextSamplingTime        = DateTime.UtcNow.Ticks;
            m_alwaysReportUpdates     = false;
            
            m_typeMask = MonitoredItemTypeMask.DataChange;

            if (originalFilter is EventFilter)
            {
                m_typeMask = MonitoredItemTypeMask.Events;

                if (itemToMonitor.NodeId == Objects.Server)
                {
                    m_typeMask |= MonitoredItemTypeMask.AllEvents;
                }
            }

            // create aggregate calculator.
            ServerAggregateFilter aggregateFilter = filterToUse as ServerAggregateFilter;

            if (filterToUse is ServerAggregateFilter)
            {
                m_calculator = m_server.AggregateManager.CreateCalculator(
                    aggregateFilter.AggregateType,
                    aggregateFilter.StartTime,
                    DateTime.MaxValue,
                    aggregateFilter.ProcessingInterval,
                    aggregateFilter.Stepped,
                    aggregateFilter.AggregateConfiguration);
            }

            if (range != null)
            {
                m_range = range.High - range.Low;
            }

            // report change to item state.
            ServerUtils.ReportCreateMonitoredItem(
                m_nodeId,
                m_id,
                m_samplingInterval,
                m_queueSize,
                m_discardOldest,
                m_filterToUse,
                m_monitoringMode);

            InitializeQueue();
		}
示例#48
0
        /// <summary>
        /// Registers the node manager with the master node manager.
        /// </summary>
        private void RegisterNodeManager(
            INodeManager nodeManager,
            List<INodeManager> registeredManagers,
            Dictionary<int, List<INodeManager>> namespaceManagers)
        {
            m_nodeManagers.Add(nodeManager);

            // ensure the NamespaceUris supported by the NodeManager are in the Server's NamespaceTable.
            if (nodeManager.NamespaceUris != null)
            {
                foreach (string namespaceUri in nodeManager.NamespaceUris)
                {
                    // look up the namespace uri.
                    int index = m_server.NamespaceUris.GetIndex(namespaceUri);

                    if (index == -1)
                    {
                        index = m_server.NamespaceUris.Append(namespaceUri);
                    }

                    // add manager to list for the namespace.
                    if (!namespaceManagers.TryGetValue(index, out registeredManagers))
                    {
                        namespaceManagers[index] = registeredManagers = new List<INodeManager>();
                    }

                    registeredManagers.Add(nodeManager);
                }
            }
        }