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


C# Subscription.ApplyChanges方法代码示例

本文整理汇总了C#中Subscription.ApplyChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.ApplyChanges方法的具体用法?C# Subscription.ApplyChanges怎么用?C# Subscription.ApplyChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


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

示例1: Subscribe

        /// <summary>
        /// Adds a item to a subscription.
        /// </summary>
        private void Subscribe(Subscription subscription, ReferenceDescription reference)
        {    
            MonitoredItem monitoredItem = new MonitoredItem(subscription.DefaultItem);

            monitoredItem.DisplayName      = subscription.Session.NodeCache.GetDisplayText(reference);
            monitoredItem.StartNodeId      = (NodeId)reference.NodeId;
            monitoredItem.NodeClass        = (NodeClass)reference.NodeClass;
            monitoredItem.AttributeId      = Attributes.Value;
            monitoredItem.SamplingInterval = 0;
            monitoredItem.QueueSize        = 1;

            // add condition fields to any event filter.
            EventFilter filter = monitoredItem.Filter as EventFilter;

            if (filter != null)
            {
                monitoredItem.AttributeId = Attributes.EventNotifier;
				monitoredItem.QueueSize = 0;
            }
            
            subscription.AddItem(monitoredItem);
            subscription.ApplyChanges();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:26,代码来源:BrowseTreeCtrl.cs

示例2: Server_ConnectComplete

        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                // check for disconnect.
                if (m_session == null)
                {
                    if (m_auditEventForm != null)
                    {
                        m_auditEventForm.Close();
                        m_auditEventForm = null;
                    }

                    return;
                }

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    m_connectedOnce = true;
                }

                // create the default subscription.
                m_subscription = new Subscription();

                m_subscription.DisplayName = null;
                m_subscription.PublishingInterval = 1000;
                m_subscription.KeepAliveCount = 10;
                m_subscription.LifetimeCount = 100;
                m_subscription.MaxNotificationsPerPublish = 1000;
                m_subscription.PublishingEnabled = true;
                m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

                m_session.AddSubscription(m_subscription);
                m_subscription.Create();

                // must specify the fields that the form is interested in.
                m_filter.SelectClauses = m_filter.ConstructSelectClauses(
                    m_session,
                    NodeId.Parse("ns=2;s=4:2"),
                    NodeId.Parse("ns=2;s=4:1"),
                    ObjectTypeIds.DialogConditionType,
                    ObjectTypeIds.ExclusiveLimitAlarmType,
                    ObjectTypeIds.NonExclusiveLimitAlarmType);

                // create a monitored item based on the current filter settings.
                m_monitoredItem = m_filter.CreateMonitoredItem(m_session);

                // set up callback for notifications.
                m_monitoredItem.Notification += m_MonitoredItem_Notification;

                m_subscription.AddItem(m_monitoredItem);
                m_subscription.ApplyChanges();

                // send an initial refresh.
                Conditions_RefreshMI_Click(sender, e);

                ConditionsMI.Enabled = true;
                ViewMI.Enabled = true;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:70,代码来源:MainForm.cs

示例3: Server_ConnectMI_Click

        /// <summary>
        /// Connects to a server.
        /// </summary>
        private void Server_ConnectMI_Click(object sender, EventArgs e)
        {            
            try
            {
                // disconnect any existing session.
                Server_DisconnectMI_Click(sender, e);

                InitialStateTB.Text = "1";
                FinalStateTB.Text = "100";

                // create the session.
                EndpointDescription endpointDescription = SelectEndpoint();
                EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(m_configuration);
                ConfiguredEndpoint endpoint = new ConfiguredEndpoint(null, endpointDescription, endpointConfiguration);
                
                m_session = Session.Create(
                    m_configuration,
                    endpoint,
                    true,
                    m_configuration.ApplicationName,
                    60000,
                    null,
                    null);

                // set up keep alive callback.
                m_session.KeepAliveInterval = 2000;
                m_session.KeepAlive += new KeepAliveEventHandler(Session_KeepAlive);

                // this client has built-in knowledge of the information model used by the server.
                NamespaceTable wellKnownNamespaceUris = new NamespaceTable();
                wellKnownNamespaceUris.Append(Namespaces.Methods);

                string[] browsePaths = new string[] 
                {
                    "1:My Process/1:State",
                    "1:My Process",
                    "1:My Process/1:Start"
                };

                List<NodeId> nodes = FormUtils.TranslateBrowsePaths(
                    m_session,
                    ObjectIds.ObjectsFolder,
                    wellKnownNamespaceUris,
                    browsePaths);
                
                // subscribe to the state if available.
                if (nodes.Count > 0 && !NodeId.IsNull(nodes[0]))
                {
                    m_subscription = new Subscription();

                    m_subscription.PublishingEnabled = true;
                    m_subscription.PublishingInterval = 1000;
                    m_subscription.Priority = 1;
                    m_subscription.KeepAliveCount = 10;
                    m_subscription.LifetimeCount = 20;
                    m_subscription.MaxNotificationsPerPublish = 1000;

                    m_session.AddSubscription(m_subscription);
                    m_subscription.Create();

                    MonitoredItem monitoredItem = new MonitoredItem();
                    monitoredItem.StartNodeId = nodes[0];
                    monitoredItem.AttributeId = Attributes.Value;
                    monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
                    m_subscription.AddItem(monitoredItem);

                    m_subscription.ApplyChanges();
                }
                
                // save the object/method
                if (nodes.Count > 2)
                {
                    m_objectNode = nodes[1];
                    m_methodNode = nodes[2];
                }

                ConnectedLB.Text = "Connected";
                ServerUrlLB.Text = endpointDescription.EndpointUrl;
                LastKeepAliveTimeLB.Text = "---";
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:88,代码来源:MainForm.cs

示例4: BoilerCB_SelectedIndexChanged

        private void BoilerCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                if (m_subscription != null)
                {
                    m_session.RemoveSubscription(m_subscription);
                    m_subscription = null;
                }
                
                ReferenceDescription boiler = (ReferenceDescription)BoilerCB.SelectedItem;

                if (boiler == null)
                {
                    return;
                }
                
                m_subscription = new Subscription();

                m_subscription.PublishingEnabled = true;
                m_subscription.PublishingInterval = 1000;
                m_subscription.Priority = 1;
                m_subscription.KeepAliveCount = 10;
                m_subscription.LifetimeCount = 20;
                m_subscription.MaxNotificationsPerPublish = 1000;

                m_session.AddSubscription(m_subscription);
                m_subscription.Create();

                NamespaceTable wellKnownNamespaceUris = new NamespaceTable();
                wellKnownNamespaceUris.Append(Namespaces.Boiler);

                string[] browsePaths = new string[] 
                {
                    "1:PipeX001/1:FTX001/1:Output",
                    "1:DrumX001/1:LIX001/1:Output",
                    "1:PipeX002/1:FTX002/1:Output",
                    "1:LCX001/1:SetPoint",
                };

                List<NodeId> nodes = ClientUtils.TranslateBrowsePaths(
                    m_session,
                    (NodeId)boiler.NodeId,
                    wellKnownNamespaceUris,
                    browsePaths);

                Control[] controls = new Control[] 
                {
                    InputPipeFlowTB,
                    DrumLevelTB,
                    OutputPipeFlowTB,
                    DrumLevelSetPointTB
                };

                for (int ii = 0; ii < nodes.Count; ii++)
                {
                    controls[ii].Text = "---";

                    if (nodes[ii] != null)
                    {
                        MonitoredItem monitoredItem = new MonitoredItem();
                        monitoredItem.StartNodeId = nodes[ii];
                        monitoredItem.AttributeId = Attributes.Value;
                        monitoredItem.Handle = controls[ii];
                        monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
                        m_subscription.AddItem(monitoredItem);
                    }
                }

                m_subscription.ApplyChanges();
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:81,代码来源:MainForm.cs

示例5: CreateSubscription

        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            m_subscription = new Subscription();
            m_subscription.Handle = this;
            m_subscription.DisplayName = null;
            m_subscription.PublishingInterval = 1000;
            m_subscription.KeepAliveCount = 10;
            m_subscription.LifetimeCount = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled = true;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            m_monitoredItem = new MonitoredItem();
            m_monitoredItem.StartNodeId = m_areaId;
            m_monitoredItem.AttributeId = Attributes.EventNotifier;
            m_monitoredItem.SamplingInterval = 0;
            m_monitoredItem.QueueSize = 1000;
            m_monitoredItem.DiscardOldest = true;

            ChangeFilter(m_filter, false);

            m_monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:32,代码来源:EventListView.cs

示例6: DoQueueSizeTest


//.........这里部分代码省略.........
                            monitoredItem.Filter = null;
                            monitoredItem.MonitoringMode = MonitoringMode.Reporting;
                            monitoredItem.Handle = m_variables[ii];

                            m_variables[ii].Notifications[monitoredItem.ClientHandle] = new List<Notification>();
                            m_monitoredItems[monitoredItem.ClientHandle] = m_variables[ii];

                            subscription.AddItem(monitoredItem);
                        }

                        for (int jj = 2; jj < 8; jj += 2)
                        {
                            MonitoredItem monitoredItem = new MonitoredItem();

                            monitoredItem.StartNodeId = variable.NodeId;
                            monitoredItem.AttributeId = Attributes.Value;
                            monitoredItem.RelativePath = null;
                            monitoredItem.IndexRange = null;
                            monitoredItem.SamplingInterval = 100;
                            monitoredItem.QueueSize = (uint)jj;
                            monitoredItem.DiscardOldest = false;
                            monitoredItem.Filter = null;
                            monitoredItem.MonitoringMode = MonitoringMode.Reporting;
                            monitoredItem.Handle = m_variables[ii];

                            m_variables[ii].Notifications[monitoredItem.ClientHandle] = new List<Notification>();
                            m_monitoredItems[monitoredItem.ClientHandle] = m_variables[ii];

                            subscription.AddItem(monitoredItem);
                        }
                    }
                }

                subscription.ApplyChanges();
                
                // check results.
                foreach (MonitoredItem monitoredItem in subscription.MonitoredItems)
                {
                    if (ServiceResult.IsBad(monitoredItem.Status.Error))
                    {
                        TestVariable variable = monitoredItem.Handle as TestVariable;

                        Log(
                            "Could not create MonitoredItem {0}. NodeId={1}, QueueSize={2}",
                            variable.Variable,
                            variable.Variable.NodeId,
                            monitoredItem.QueueSize);

                        success = false;
                    }
                }
            }

            // modify sampling interval.
            if (success)
            {
                if (modifyQueueSize)
                {
                    if (!ModifyQueueSize(subscription))
                    {
                        success = false;
                    }               
                }
            }

            // wait for first data change.
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:67,代码来源:MonitoredItemTest.cs

示例7: ModifyDeadband

        /// <summary>
        /// Modifies the deadband.
        /// </summary>
        private bool ModifyDeadband(Subscription subscription)
        {
            if (m_errorEvent.WaitOne(500, false))
            {
                return false;
            }

            lock (m_variables)
            {
                for (int ii = 0; ii < m_variables.Count; ii++)
                {
                    foreach (IList<Notification> notification in m_variables[ii].Notifications.Values)
                    {
                        notification.Clear();
                    }
                }

                foreach (MonitoredItem monitoredItem in subscription.MonitoredItems)
                {
                    DataChangeFilter filter =(DataChangeFilter)monitoredItem.Filter;
                    filter.DeadbandValue /= 2;
                    monitoredItem.Filter = filter;
                }
            }
            
            subscription.ApplyChanges();

            // check results.
            bool success = true;

            foreach (MonitoredItem monitoredItem in subscription.MonitoredItems)
            {
                if (!CheckDeadbandError(monitoredItem))
                {
                    success = false;
                    break;
                }
            }

            if (!success)
            {                
                return false;
            }

            if (m_errorEvent.WaitOne(500, false))
            {
                return false;
            }

            return true;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:54,代码来源:MonitoredItemTest.cs

示例8: CreateSubscription

        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            if (m_subscription != null)
            {
                m_subscription.Dispose();
                m_subscription = null;
            }

            // get the current session.
            Session session = m_server.Session;

            if (session == null)
            {
                return;
            }

            // create the subscription.
            m_subscription = new Subscription();
            m_subscription.PublishingEnabled = Active;
            m_subscription.PublishingInterval = (int)Math.Max(BufferTime, 1000);
            m_subscription.KeepAliveCount = (uint)Math.Max(Math.Ceiling(((double)KeepAlive)/m_subscription.PublishingInterval), 10);
            m_subscription.LifetimeCount = m_subscription.KeepAliveCount*3;
            m_subscription.MaxNotificationsPerPublish = MaxSize;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Neither;
            m_subscription.Priority = 0;
            m_subscription.FastEventCallback = OnEventNotification;
            m_subscription.DisableMonitoredItemCache = true;

            session.AddSubscription(m_subscription);
            m_subscription.Create();

            // update the monitored items.
            EventFilter filter = m_filter.GetFilter();
            MonitoringMode monitoringMode = (Active)?MonitoringMode.Reporting:MonitoringMode.Disabled;

            foreach (MonitoredItem monitoredItem in m_notifiers.Values)
            {
                monitoredItem.Filter = filter;
                monitoredItem.MonitoringMode = monitoringMode;
                m_subscription.AddItem(monitoredItem);
            }

            m_subscription.ApplyChanges();
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:47,代码来源:ComAeSubscription.cs

示例9: AuditEventForm

        /// <summary>
        /// Initializes a new instance of the <see cref="AuditEventForm"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="subscription">The subscription.</param>
        public AuditEventForm(Session session, Subscription subscription)
        {
            InitializeComponent();

            m_session = session;
            m_subscription = subscription;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary<NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.AuditUpdateMethodEventType };

            // find the fields of interest.
            m_filter.SelectClauses = m_filter.ConstructSelectClauses(m_session, ObjectTypeIds.AuditUpdateMethodEventType);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.
            m_monitoredItem = m_filter.CreateMonitoredItem(m_session);

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:38,代码来源:AuditEventForm.cs

示例10: DoDeadbandTest


//.........这里部分代码省略.........

                    for (int ii = 0; ii < m_variables.Count; ii++)
                    {
                        VariableNode variable = m_variables[ii].Variable;

                        for (int jj = 0; jj < filters.Length; jj++)
                        {
                            if (m_variables[ii].EURange == null && filters[jj].DeadbandType == (uint)DeadbandType.Percent)
                            {
                                continue;
                            }

                            MonitoredItem monitoredItem = new MonitoredItem();

                            monitoredItem.StartNodeId = variable.NodeId;
                            monitoredItem.AttributeId = Attributes.Value;
                            monitoredItem.RelativePath = null;
                            monitoredItem.IndexRange = null;
                            monitoredItem.SamplingInterval = 100;
                            monitoredItem.QueueSize = 0;
                            monitoredItem.DiscardOldest = true;
                            monitoredItem.Filter = filters[jj];
                            monitoredItem.MonitoringMode = MonitoringMode.Reporting;
                            monitoredItem.Handle = m_variables[ii];

                            m_variables[ii].Notifications[monitoredItem.ClientHandle] = new List<Notification>();
                            m_monitoredItems[monitoredItem.ClientHandle] = m_variables[ii];

                            subscription.AddItem(monitoredItem);
                        }
                    }
                }

                subscription.ApplyChanges();
                
                // check results.
                foreach (MonitoredItem monitoredItem in subscription.MonitoredItems)
                {
                    if (!CheckDeadbandError(monitoredItem))
                    {
                        success = false;
                        break;
                    }
                }
            }
            
            // modify sampling interval.
            if (success)
            {       
                if (modifyDeadband)
                {
                    if (!ModifyDeadband(subscription))
                    {
                        success = false;
                    }
                }
            }

            // wait for first data change.
            if (m_errorEvent.WaitOne(1000, false))
            {
                success = false;
            }

            lock (m_variables)
            {
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:67,代码来源:MonitoredItemTest.cs

示例11: CreateSubscription

        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            // create the default subscription.
            m_subscription = new Subscription();

            m_subscription.DisplayName = null;
            m_subscription.PublishingInterval = 1000;
            m_subscription.KeepAliveCount = 10;
            m_subscription.LifetimeCount = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled = true;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary<NodeId, NodeId>();

            NodeId knownEventId = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);

            m_knownEventTypes = new Dictionary<NodeId, Type>();
            m_knownEventTypes.Add(knownEventId, typeof(SystemCycleStatusEventState));
            
            TypeDeclaration type = new TypeDeclaration();
            type.NodeId = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);
            type.Declarations = ClientUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

            // the filter to use.
            m_filter = new FilterDeclaration(type, null);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.            
            m_monitoredItem = new MonitoredItem();
            m_monitoredItem.StartNodeId = Opc.Ua.ObjectIds.Server;
            m_monitoredItem.AttributeId = Attributes.EventNotifier;
            m_monitoredItem.SamplingInterval = 0;
            m_monitoredItem.QueueSize = 1000;
            m_monitoredItem.DiscardOldest = true;
            m_monitoredItem.Filter = m_filter.GetFilter();

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:52,代码来源:MainForm.cs

示例12: CreateSubscription

        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            if (m_session == null)
            {
                return;
            }

            m_subscription = new Subscription();
            m_subscription.Handle = this;
            m_subscription.DisplayName = null;
            m_subscription.PublishingInterval = 500;
            m_subscription.KeepAliveCount = 10;
            m_subscription.LifetimeCount = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled = true;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            MonitoredItem monitoredItem = new MonitoredItem();
            monitoredItem.StartNodeId = m_nodeId;
            monitoredItem.AttributeId = Attributes.Value;
            monitoredItem.SamplingInterval = 1000;
            monitoredItem.QueueSize = 1000;
            monitoredItem.DiscardOldest = true;

            monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            m_subscription.AddItem(monitoredItem);
            m_subscription.ApplyChanges();

            // verify that the item was created successfully.
            if (ServiceResult.IsBad(monitoredItem.Status.Error))
            {
                throw new ServiceResultException(monitoredItem.Status.Error);
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:41,代码来源:SubscribeDataDlg.cs

示例13: CreateSubscription

        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            if (m_session == null)
            {
                return;
            }

            m_subscription = new Subscription();
            m_subscription.Handle = this;
            m_subscription.DisplayName = null;
            m_subscription.PublishingInterval = 1000;
            m_subscription.KeepAliveCount = 10;
            m_subscription.LifetimeCount = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled = true;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            m_monitoredItem = new MonitoredItem();
            m_monitoredItem.StartNodeId = m_nodeId;
            m_monitoredItem.AttributeId = Attributes.Value;
            m_monitoredItem.SamplingInterval = (int)SamplingIntervalNP.Value;
            m_monitoredItem.QueueSize = 1000;
            m_monitoredItem.DiscardOldest = true;

            // specify aggregate filter.
            if (AggregateCB.SelectedItem != null)
            {
                AggregateFilter filter = new AggregateFilter();

                if (StartTimeCK.Checked)
                {
                    filter.StartTime = StartTimeDP.Value.ToUniversalTime();
                }
                else
                {
                    filter.StartTime = DateTime.UtcNow;
                }

                filter.ProcessingInterval = (double)ResampleIntervalNP.Value;
                filter.AggregateType = ((AvailableAggregate)AggregateCB.SelectedItem).NodeId;

                if (filter.AggregateType != null)
                {
                    m_monitoredItem.Filter = filter;
                }
            }

            m_monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
            SubscriptionStateChanged();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:59,代码来源:HistoryDataListView.cs

示例14: Server_ConnectComplete

        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                if (m_session == null)
                {
                    StartBTN.Enabled = false;
                    return;
                }

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    m_connectedOnce = true;
                }

                // this client has built-in knowledge of the information model used by the server.
                NamespaceTable wellKnownNamespaceUris = new NamespaceTable();
                wellKnownNamespaceUris.Append(Namespaces.Methods);

                string[] browsePaths = new string[] 
                {
                    "1:My Process/1:State",
                    "1:My Process",
                    "1:My Process/1:Start"
                };

                List<NodeId> nodes = ClientUtils.TranslateBrowsePaths(
                    m_session,
                    ObjectIds.ObjectsFolder,
                    wellKnownNamespaceUris,
                    browsePaths);

                // subscribe to the state if available.
                if (nodes.Count > 0 && !NodeId.IsNull(nodes[0]))
                {
                    m_subscription = new Subscription();

                    m_subscription.PublishingEnabled = true;
                    m_subscription.PublishingInterval = 1000;
                    m_subscription.Priority = 1;
                    m_subscription.KeepAliveCount = 10;
                    m_subscription.LifetimeCount = 20;
                    m_subscription.MaxNotificationsPerPublish = 1000;

                    m_session.AddSubscription(m_subscription);
                    m_subscription.Create();

                    MonitoredItem monitoredItem = new MonitoredItem();
                    monitoredItem.StartNodeId = nodes[0];
                    monitoredItem.AttributeId = Attributes.Value;
                    monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
                    m_subscription.AddItem(monitoredItem);

                    m_subscription.ApplyChanges();
                }

                // save the object/method
                if (nodes.Count > 2)
                {
                    m_objectNode = nodes[1];
                    m_methodNode = nodes[2];
                }

                InitialStateTB.Text = "1";
                FinalStateTB.Text = "100";
                StartBTN.Enabled = true;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:78,代码来源:MainForm.cs

示例15: DoSamplingIntervalTest


//.........这里部分代码省略.........
                    for (int ii = 0; ii < m_variables.Count; ii++)
                    {
                        // servers that sample data values may not pick up boolean value changes.
                        if (m_variables[ii].DataType == BuiltInType.Boolean)
                        {
                            continue;
                        }

                        VariableNode variable = m_variables[ii].Variable;

                        for (int jj = 2000; jj <= 10000; jj += 1000)
                        {
                            MonitoredItem monitoredItem = new MonitoredItem();

                            monitoredItem.StartNodeId = variable.NodeId;
                            monitoredItem.AttributeId = Attributes.Value;
                            monitoredItem.RelativePath = null;
                            monitoredItem.IndexRange = null;
                            monitoredItem.SamplingInterval = jj;
                            monitoredItem.QueueSize = 0;
                            monitoredItem.DiscardOldest = true;
                            monitoredItem.Filter = null;
                            monitoredItem.MonitoringMode = MonitoringMode.Reporting;
                            monitoredItem.Handle = m_variables[ii];

                            m_variables[ii].Notifications[monitoredItem.ClientHandle] = new List<Notification>();
                            m_monitoredItems[monitoredItem.ClientHandle] = m_variables[ii];

                            subscription.AddItem(monitoredItem);
                        }
                    }
                }

                subscription.ApplyChanges();
                
                // check results.
                foreach (MonitoredItem monitoredItem in subscription.MonitoredItems)
                {
                    if (ServiceResult.IsBad(monitoredItem.Status.Error))
                    {
                        TestVariable variable = monitoredItem.Handle as TestVariable;

                        Log(
                            "Could not create MonitoredItem {0}. NodeId={1}, SamplingInterval={2}",
                            variable.Variable,
                            variable.Variable.NodeId,
                            monitoredItem.SamplingInterval);

                        success = false;
                    }
                }
            }

            // modify sampling interval.
            if (success)
            {      
                if (modifySamplingInterval)
                {
                    if (!ModifySamplingInterval(subscription))
                    {
                        success = false;
                    }
                }
            }

            // wait for first data change.
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:67,代码来源:MonitoredItemTest.cs


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