Opc.Ua.Com.Server.ComDaGroup.SetActive C# (CSharp) Method

SetActive() public method

Sets the active state for the group,
public SetActive ( bool active ) : void
active bool if set to true the group is activated.
return void
        public void SetActive(bool active)
        {
            TraceState("SetActive", this.m_serverHandle, active);
            ThrowIfDisposed();

            lock (m_lock)
            {
                // do nothing if no change.
                if (m_active == active)
                {
                    CheckUpdateTimerStatus();
                    return;
                }

                bool areUpdatesRequired = AreUpdatesRequired;

                // turn publishing on.
                try
                {
                    m_subscription.SetPublishingMode(active);
                }
                catch (Exception e)
                {
                    throw ComUtils.CreateComException(e, ResultIds.E_FAIL);
                }

                m_active = active;

                // get net monitoring mode.
                MonitoringMode monitoringMode = MonitoringMode.Disabled;

                if (m_active)
                {
                    monitoringMode = MonitoringMode.Reporting;
                }

                // validate the handles.
                int activeItemCount = 0;
                List<MonitoredItem> monitoredItems = new List<MonitoredItem>();

                for (int ii = 0; ii < m_items.Count; ii++)
                {
                    ComDaGroupItem item = m_items[ii];

                    // check if the item is deactivated.
                    if (!item.Active)
                    {
                        continue;
                    }

                    activeItemCount++;

                    // flag the last set value for resending.
                    if (monitoringMode == MonitoringMode.Reporting && item.CacheEntry != null)
                    {
                        item.CacheEntry.Changed = true;
                    }

                    // nothing to do if already in the correct state.
                    if (item.MonitoredItem.Status.MonitoringMode == monitoringMode)
                    {
                        continue;
                    }

                    monitoredItems.Add(item.MonitoredItem);
                }

                // update the subscription.
                if (monitoredItems.Count > 0)
                {
                    try
                    {
                        m_subscription.SetMonitoringMode(monitoringMode, monitoredItems);
                    }
                    catch (Exception)
                    {
                        // ignore errors updating individual items.
                    }
                }

                // resend the contents of the cache.
                if (!areUpdatesRequired && AreUpdatesRequired)
                {
                    int cancelId = 0;
                    Refresh(0, 0, true, out cancelId);
                }

                // update timer status.
                CheckUpdateTimerStatus();
            }
        }

Same methods

ComDaGroup::SetActive ( int serverHandles, bool active ) : int[]