Opc.Ua.ServerTest.SubscribeTest.DoPublishingIntervalTest C# (CSharp) Method

DoPublishingIntervalTest() private method

Reads an verifies all of the nodes.
private DoPublishingIntervalTest ( ) : bool
return bool
        private bool DoPublishingIntervalTest()
        {
            // follow tree from each starting node.
            bool success = true;
                     
            Log("Starting PublishingIntervalTest. PipelineDepth = {0}, OutstandingRequests = {1}", m_publishPipelineDepth, m_outstandingPublishRequests);
            
            double increment = MaxProgress/6;
            double position  = 0;
            ReportProgress(position);

            // create subscription.
            Interlocked.Exchange(ref m_publishCount, 0);
            Interlocked.Exchange(ref m_stopped, 0);
                        
            for (int ii = 0; ii < 10; ii++)
            {
                try
                {
                    CreateSubscription(
                        1000,
                        60,
                        (uint)(ii%6)+2,
                        0,
                        true,
                        0);
                }
                catch (Exception e)
                {
                    success = false;
                    Log(e, "KeepAliveTest Failed while creating subsciptions.");
                }
            }
            
            position += increment;
            ReportProgress(position);
            Log("Created {0} subscriptions.", m_subscriptions.Count);

            m_errorEvent.Reset();

            double publishingInterval = 1000;

            for (int ii = 0; ii < 3; ii++)
            {
                if (m_errorEvent.WaitOne(10000, false))
                {
                    success = false;
                    Log("KeepAliveTest exiting because of an error during publishing.", null);
                    break;
                }

                Log("{0} publish responses received. Publishing Interval = {1}", m_publishCount, publishingInterval);
                
                // change publishing interval.
                publishingInterval = (publishingInterval == 1000)?2000:1000;
                
                List<Subscription> subscriptions = new List<Subscription>();

                lock (m_subscriptions)
                {
                    subscriptions = new List<Subscription>(m_subscriptions);
                }

                for (int jj = 0; jj < subscriptions.Count; jj++)
                {
                    if (!ModifySubscription(subscriptions[jj], publishingInterval))
                    {
                        success = false;
                    }
                }
            
                position += increment;
                ReportProgress(position);
            }

            // delete.
            if (!DeleteSubscriptions())
            {
                success = false;
            }

            // stop publish threads.
            Interlocked.CompareExchange(ref m_stopped, 1, 0);
            Log("Deleted subscriptions.");

            // verify test results.
            lock (m_subscriptions)
            {
                if (success)
                {
                    for (int ii = 0; ii < m_subscriptions.Count; ii++)
                    {
                        Subscription subscription = m_subscriptions[ii];

                        lock (subscription)
                        {
                            if (!VerifyKeepAliveTestResults(subscription))
                            {
                                success = false;
                            }
                        }
                    }
                }

                m_subscriptions.Clear();
            }

            position += increment;
            ReportProgress(position);

            return success;
        }