Opcnetapi performs faster reading while Marikonopc Explorer is open

Asked

Viewed 54 times

0

My application performs reading 24 tags from a Rslinx Classic localhost server.

However, I started to notice that the reading of the tags are faster when the Matrikonopc Explorer software is running and reading the same tags of my application.

When the Matrikonopc Explorer is closed the reading of the 24 tags lasts from around 180ms to 220ms. But when the same is open and running the reading of the same tags simultaneously the reading time of my application is around 30ms!

Here is the backgroudworker event used for continuous reading of OPC tags:

    void workerGroupRead_DoWork(object sender, DoWorkEventArgs e)
    {
        BackgroundWorker _worker = (BackgroundWorker)sender;
        ItemValueResult[] values;

        if (listOPCItems != null && listOPCItems.Count > 0)
        {
            if (items != null && items.Length > 0)
            {
                while (!_worker.CancellationPending)
                {
                    stopwatchReader.Restart();

                    System.Threading.Thread.Sleep(10)

                    try
                    {
                        if (IsConnected && !_worker.CancellationPending)
                        {
                            values = server.Read(items);                                

                            ReadValuesResult(values);
                        }

                        TempoLeitura = stopwatchReader.ElapsedMilliseconds;
                    }
                    catch 
                    { 
                        stopwatchReader.Reset();
                        break;
                    }
                }
            }
        }
    }

I already checked the DCOM settings and permissions and found nothing that seemed obvious to me.

In case anyone has any suggestions, thank you in advance.

1 answer

0


Complicated to give a conclusive answer to this kind of question, as it is a difficult situation to reproduce (even more because it involves specialized external hardware).

Still, I want to leave some suggestions (speculation):

Apparently, it seems that slow reading occurs due to a boot-run-close cycle of the OPC server. When "Explorer" is already active, it seems that this boot is waived. Remember that OPC is just a standardized interface (just like ODBC is for Windows databases), whose implementation is not always the most optimized. Make sure there is no documentation describing how to perform batch readings (batches) - there is probably a procedure to keep the "environment open".

Plus, I’d execute a performance profiler comparing the two environments to try to understand which is the bottleneck of this overhead. Analyzing library source code (via a compile), we can get "hints" on what code is running that we can eventually anticipate before a batch execution with this.

Also check with your hardware provider if there is no specific . NET interface instead of using OPC. Some providers offer and even encourage the use of native libraries . NET (Ex: Beckhoff). In my experience (not very vast in this field, I confess), the difference in performance is brutal.

  • The error actually occurred in the boot process. No Opc tags were being initialized in my application. The reading group was created by Matrikonopc when it was opened and configured to read the same set of tags as my application. Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.