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

SetUpdateRate() public method

Sets the update rate for the group,
public SetUpdateRate ( int updateRate ) : int
updateRate int The update rate.
return int
        public int SetUpdateRate(int updateRate)
        {
            TraceState("SetUpdateRate", updateRate);
            ThrowIfDisposed();

            lock (m_lock)
            {
                // upate the publishing interval.
                m_subscription.PublishingInterval = updateRate/2;

                // modify the subscription.
                try
                {
                    m_subscription.Modify();
                }
                catch (Exception e)
                {
                    throw ComUtils.CreateComException(e, ResultIds.E_FAIL);
                }

                int actualUpdateRate = (int)m_subscription.CurrentPublishingInterval*2;

                // restart timer.
                if (actualUpdateRate != m_actualUpdateRate)
                {
                    m_actualUpdateRate = actualUpdateRate;

                    // adjust keep alive.
                    if (m_keepAliveTime != 0 && m_keepAliveTime < m_actualUpdateRate)
                    {
                        m_keepAliveTime = m_actualUpdateRate;
                    }
                    
                    ScheduleNextUpdate();

                    if (m_updateTimer != null)
                    {
                        m_updateTimer.Dispose();
                        m_updateTimer = null;
                    }

                    CheckUpdateTimerStatus();
                }

                // update the filter for analog items that have not overriden the deadband.
                for (int ii = 0; ii < m_items.Count; ii++)
                {
                    if (m_items[ii].SamplingRate == -1)
                    {
                        m_items[ii].MonitoredItem.SamplingInterval = updateRate/2;
                    }
                }

                // update the items on the server.
                try
                {
                    m_subscription.ApplyChanges();
                }
                catch (Exception e)
                {
                    throw ComUtils.CreateComException(e, ResultIds.E_FAIL);
                }

                // return the revised update rate.
                return m_actualUpdateRate;
            }
        }