当前位置: 首页>>代码示例>>C#>>正文


C# Server.OperationContext类代码示例

本文整理汇总了C#中Opc.Ua.Server.OperationContext的典型用法代码示例。如果您正苦于以下问题:C# OperationContext类的具体用法?C# OperationContext怎么用?C# OperationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OperationContext类属于Opc.Ua.Server命名空间,在下文中一共展示了OperationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SamplingGroup

        /// <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);
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:28,代码来源:SamplingGroup.cs

示例2: ServerSystemContext

 /// <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;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:13,代码来源:ServerSystemContext.cs

示例3: AsyncPublishOperation

 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncPublishOperation"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="request">The request.</param>
 /// <param name="server">The server.</param>
 public AsyncPublishOperation(
      OperationContext context,
      IEndpointIncomingRequest request,
      StandardServer server)
 {
     m_context = context;
     m_request = request;
     m_server = server;
     m_response = new PublishResponse();
     m_request.Calldata = this;
 }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:17,代码来源:AsyncPublishOperation.cs

示例4: OnGetWheels

        /// <summary>
        /// Handles the GetWheels test method.
        /// </summary>
        public Wheel[] OnGetWheels(OperationContext context, NodeSource target, Vehicle vehicle)
        {
            GenericEvent e = GenericEvent.Construct(Server, new NodeId(ObjectTypes.MaintenanceEventType, GetNamespaceIndex(Namespaces.Sample)));
            
            e.InitializeNewEvent();
            e.Message.Value = "Some unknown problem.";
            e.SetProperty(new QualifiedName(BrowseNames.MustCompleteByDate, GetNamespaceIndex(Namespaces.Sample)), new DateTime(1987,2,3));
            
            ReportEvent(e);

            return vehicle.Wheels.ToArray();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:15,代码来源:Boiler.cs

示例5: Publish

		/// <summary>
		/// Publishes all available data change notifications.
		/// </summary>
		public virtual bool Publish(
            OperationContext                 context, 
            Queue<MonitoredItemNotification> notifications,
            Queue<DiagnosticInfo>            diagnostics)
		{
            if (context == null)       throw new ArgumentNullException("context");
            if (notifications == null) throw new ArgumentNullException("notifications");
            if (diagnostics == null)   throw new ArgumentNullException("diagnostics");
            
			lock (m_lock)
		    {
                // check if the item reports data changes.
                if ((m_typeMask & MonitoredItemTypeMask.DataChange) == 0)
                {
					return false;
                }

                // only publish if reporting.
                if (!IsReadyToPublish)
                {
                    return false;
                }

                // pull any unprocessed data.
                if (m_calculator != null)
                {
                    if (m_calculator.HasEndTimePassed(DateTime.UtcNow))
                    {
                        DataValue processedValue = m_calculator.GetProcessedValue(false);

                        while (processedValue != null)
                        {
                            AddValueToQueue(processedValue, null);
                        }

                        processedValue = m_calculator.GetProcessedValue(true);
                        AddValueToQueue(processedValue, null);
                    }
                }

                // go to the next sampling interval.
                IncrementSampleTime();
                
                // check if queueing enabled.
                if (m_queue != null)
                {
                    DataValue value = null;
                    ServiceResult error = null;

                    while (m_queue.Publish(out value, out error))
                    {
                        Publish(context, notifications, diagnostics, value, error);
                    }
                }

                // publish last value if no queuing.
                else
                {
                    Utils.Trace("DEQUEUE VALUE: Value={0} CODE={1}<{1:X8}> OVERFLOW={2}", m_lastValue.WrappedValue, m_lastValue.StatusCode.Code, m_lastValue.StatusCode.Overflow);
                    Publish(context, notifications, diagnostics, m_lastValue, m_lastError);
                }
                
				// reset state variables.
				m_overflow = false;
                m_readyToPublish = false;
                m_readyToTrigger = false;
                m_triggered = false;

                return false;
			}
		}
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:74,代码来源:MonitoredItem.cs

示例6: Modify

		/// <summary>
		/// Updates the publishing parameters for the subscription.
		/// </summary>
        public void Modify(
            OperationContext context,
            double           publishingInterval,
            uint             maxLifetimeCount,
            uint             maxKeepAliveCount,
            uint             maxNotificationsPerPublish,
            byte             priority)
        {
            lock (m_lock)
            {
                // check session.
                VerifySession(context);

                // clear lifetime counter.
                ResetLifetimeCount();

                m_maxLifetimeCount = maxLifetimeCount;

                // update publishing interval.
                if (publishingInterval != m_publishingInterval)
                {
                    m_publishingInterval = publishingInterval;
                    m_publishTimerExpiry = (HiResClock.UtcNow.Ticks/TimeSpan.TicksPerMillisecond) + (long)publishingInterval;
                    ResetKeepaliveCount();
                }
                
                // update keep alive count.
                if (maxKeepAliveCount != m_maxKeepAliveCount)
                {
                    m_maxKeepAliveCount = maxKeepAliveCount;
                }

                m_maxNotificationsPerPublish = maxNotificationsPerPublish;

                // update priority.
                m_priority = priority;

                // update diagnostics
                lock (m_diagnostics)
                {   
                    m_diagnostics.ModifyCount++;
                    m_diagnostics.PublishingInterval = m_publishingInterval;
                    m_diagnostics.MaxKeepAliveCount = m_maxKeepAliveCount;
                    m_diagnostics.MaxLifetimeCount = m_maxLifetimeCount;
                    m_diagnostics.Priority = m_priority;
                    m_diagnostics.MaxNotificationsPerPublish = m_maxNotificationsPerPublish;
                }
                
                // TraceState("MODIFIED");
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:54,代码来源:Subscription.cs

示例7: InnerPublish

        /// <summary>
        /// Returns all available notifications.
        /// </summary>
        private NotificationMessage InnerPublish(
            OperationContext      context, 
            out UInt32Collection  availableSequenceNumbers, 
            out bool              moreNotifications)
        {   
            // check session.
            VerifySession(context);

            // TraceState("PUBLISH");

            // check if a keep alive should be sent if there is no data.
            bool keepAliveIfNoData = (m_keepAliveCounter >= m_maxKeepAliveCount);

            availableSequenceNumbers = new UInt32Collection();

            moreNotifications = false;

            if (m_lastSentMessage < m_sentMessages.Count)
            {
                // return the available sequence numbers.
                for (int ii = 0; ii <= m_lastSentMessage && ii < m_sentMessages.Count; ii++)
                {
                    availableSequenceNumbers.Add(m_sentMessages[ii].SequenceNumber);
                }
                
                moreNotifications = m_waitingForPublish = m_lastSentMessage < m_sentMessages.Count-1;

                // TraceState("PUBLISH QUEUED MESSAGE");
                return m_sentMessages[m_lastSentMessage++];
            }
            
            List<NotificationMessage> messages = new List<NotificationMessage>();

            if (m_publishingEnabled)
            {                
                DateTime start1 = DateTime.UtcNow;

                // collect notifications to publish.
                Queue<EventFieldList> events = new Queue<EventFieldList>();
                Queue<MonitoredItemNotification> datachanges = new Queue<MonitoredItemNotification>();
                Queue<DiagnosticInfo> datachangeDiagnostics = new Queue<DiagnosticInfo>();
                
                // check for monitored items that are ready to publish.
                LinkedListNode<IMonitoredItem> current = m_itemsToPublish.First;
                
                while (current != null)
                {
                    LinkedListNode<IMonitoredItem> next = current.Next;
                    IMonitoredItem monitoredItem = current.Value;

                    if ((monitoredItem.MonitoredItemType & MonitoredItemTypeMask.DataChange) != 0)
                    {
                        ((IDataChangeMonitoredItem)monitoredItem).Publish(context, datachanges, datachangeDiagnostics);
                    }
                    else
                    {
                        ((IEventMonitoredItem)monitoredItem).Publish(context, events);                        
                    }

                    // add back to list to check.
                    m_itemsToPublish.Remove(current);
                    m_itemsToCheck.AddLast(current);
                                    
                    // check there are enough notifications for a message.
                    if (m_maxNotificationsPerPublish > 0 && events.Count + datachanges.Count > m_maxNotificationsPerPublish)
                    {
                        // construct message.
                        int notificationCount;
                        int eventCount = events.Count;
                        int dataChangeCount = datachanges.Count;
                                           
                        NotificationMessage message = ConstructMessage(
                             events, 
                             datachanges, 
                             datachangeDiagnostics, 
                             out notificationCount);

                        // add to list of messages to send.
                        messages.Add(message);

                        lock (m_diagnostics)
                        {
                            m_diagnostics.DataChangeNotificationsCount += (uint)(dataChangeCount - datachanges.Count);
                            m_diagnostics.EventNotificationsCount += (uint)(eventCount - events.Count);
                            m_diagnostics.NotificationsCount += (uint)notificationCount;
                        }
                    }
                                        
                    current = next;
                }
                    
                // pubish the remaining notifications.
                while (events.Count + datachanges.Count > 0)
                {
                    // construct message.
                    int notificationCount;
                    int eventCount = events.Count;
//.........这里部分代码省略.........
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:101,代码来源:Subscription.cs

示例8: Acknowledge

        /// <summary>
		/// Removes a message from the message queue.
		/// </summary>
        public ServiceResult Acknowledge(OperationContext context, uint sequenceNumber)
        {
            lock (m_lock)
            {
                // check session.
                VerifySession(context);

                // clear lifetime counter.
                ResetLifetimeCount();

                // find message in queue.
                for (int ii = 0; ii < m_sentMessages.Count; ii++)
                {
                    if (m_sentMessages[ii].SequenceNumber == sequenceNumber)
                    {
                        if (m_lastSentMessage > ii)
                        {
                            m_lastSentMessage--;
                        }

                        m_sentMessages.RemoveAt(ii);
                        return null;
                    }
                }

                if (sequenceNumber == 0)
                {
                    return StatusCodes.BadSequenceNumberInvalid;
                }

                // TraceState("ACK " + sequenceNumber.ToString());

                // message not found.
                return StatusCodes.BadSequenceNumberUnknown;
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:39,代码来源:Subscription.cs

示例9: VerifySession

        /// <summary>
        /// Throws an exception if the session is not the owner.
        /// </summary>
        private void VerifySession(OperationContext context)
        {
            if (m_expired)
            {
                throw new ServiceResultException(StatusCodes.BadSubscriptionIdInvalid);
            }

            if (!Object.ReferenceEquals(context.Session, m_session))
            {
                throw new ServiceResultException(StatusCodes.BadSessionIdInvalid, "Session no longer owns the subscription.");
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:15,代码来源:Subscription.cs

示例10: ValidateConditionRefresh

        /// <summary>
        /// Verifies that a condition refresh operation is permitted.
        /// </summary>
        public void ValidateConditionRefresh(OperationContext context)
        {
            lock (m_lock)
            {  
                VerifySession(context);

                if (m_refreshInProgress)
                {
                    throw new ServiceResultException(StatusCodes.BadRefreshInProgress);
                }
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:15,代码来源:Subscription.cs

示例11: ReportAuditEvent

        /// <summary>
        /// Reports an audit event for the cause.
        /// </summary>
        protected virtual void ReportAuditEvent(OperationContext context, Transition transition, QualifiedName cause, Exception exception)
        {
            AuditUpdateStateEvent e = CreateAuditEvent(context, transition, cause, exception);
                        
            e.InitializeNewEvent();
            
            e.Message.Value            = Utils.Format("Method {0} was called.", cause);
            e.SourceNode.Value         = NodeId;
            e.SourceName.Value         = "Method/Call";
            e.Severity.Value           = 1;
            e.ReceiveTime.Value        = DateTime.UtcNow;
            e.ActionTimeStamp.Value    = DateTime.UtcNow;
            e.OldStateId.Value         = m_currentStateName.StateNumber;
            e.NewStateId.Value         = m_currentStateName.StateNumber;  

            if (context != null)
            {
                e.ClientAuditEntryId.Value = context.AuditEntryId;
                e.ClientUserId.Value       = context.Session.Identity.DisplayName;
            }

            if (transition != null)
            {
                e.OldStateId.Value = transition.FromState.StateNumber;
                e.NewStateId.Value = transition.ToState.StateNumber;
            }

            ReportEvent(e);
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:32,代码来源:StateMachine.cs

示例12: ReportEffect

        /// <summary>
        /// Reports an effect which is an effect of a transition.
        /// </summary>
        protected virtual void ReportEffect(
            OperationContext context, 
            Transition       transition, 
            QualifiedName    cause,
            NodeId           effectId)
        {
            if (effectId == ObjectTypes.TransitionEventType)
            {
                TransitionEvent e = TransitionEvent.Construct(Server);

                e.InitializeNewEvent();
                
                e.Message.Value       = Utils.Format("StateMachine has moved to the {0} state.", transition.ToState.DisplayName);
                e.SourceNode.Value    = NodeId;
                e.SourceName.Value    = BrowseName.Name;
                e.Severity.Value      = 10;
                e.ReceiveTime.Value   = DateTime.UtcNow;
                e.FromState.Value     = transition.FromState.DisplayName;
                e.ToState.Value       = transition.ToState.DisplayName;

                ReportEvent(e);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:26,代码来源:StateMachine.cs

示例13: EndTransition

        /// <summary>
        /// Ends a transition (reports events for all effects).
        /// </summary>
        protected virtual void EndTransition(OperationContext context, Transition transition, QualifiedName cause)
        {
            if (transition != null)
            {
                foreach (NodeId effectId in transition.Effects)
                {
                    // check if the effects are being surpressed.
                    if (m_suppressEffects)
                    {
                        m_unreportedEffect = true;
                        return;
                    }

                    ReportEffect(context, transition, cause, effectId);
                }
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:20,代码来源:StateMachine.cs

示例14: OnAfterTransition

        /// <summary>
        /// Does any processing after a transition occurs.
        /// </summary>
        protected virtual void OnAfterTransition(OperationContext context, Transition transition, QualifiedName cause)
        {
            // raise a notification that a transition has occurred.
            if (m_TransitionCompleted != null)
            {
                StateMachineTransitionEventArgs args = new StateMachineTransitionEventArgs(
                    transition.FromState.BrowseName, 
                    transition.ToState.BrowseName, 
                    cause);

                m_TransitionCompleted(context, this, args);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:16,代码来源:StateMachine.cs

示例15: OnBeforeTransition

        /// <summary>
        /// Does any processing before a transition occurs.
        /// </summary>
        protected virtual void OnBeforeTransition(OperationContext context, Transition transition, QualifiedName cause)
        {
            // raise a notification that a transition is about to occur.
            if (m_TransitionInitiated != null)
            {
                StateMachineTransitionEventArgs args = new StateMachineTransitionEventArgs(transition.FromState.BrowseName, transition.ToState.BrowseName, cause);
                
                m_TransitionInitiated(context, this, args);

                if (args.Cancel)
                {
                    throw ServiceResultException.Create(StatusCodes.Bad, "Transition to State '{0}' was cancelled because: '{1}'.", transition.ToState.DisplayName, args.CancelReason);
                }
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:18,代码来源:StateMachine.cs


注:本文中的Opc.Ua.Server.OperationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。