OpcNetApi performs faster reading while MarikonOPC Explorer is open

0

My application performs the reading of 24 tags from a localhost RsLinx Classic server.

However, I noticed that reading the tags is faster when the MatrikonOPC Explorer software is running and reading the same tags from my application.

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

The backgroudworker event used for continuous reading of OPC tags follows:

    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 have already checked the DCOM settings and permissions and found nothing that seemed obvious to me.

If anyone has any suggestions, Thank you in advance.

    
asked by anonymous 27.02.2017 / 18:09

1 answer

0

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

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

Apparently, slow reading appears to occur because of a boot-run-close-loop of the OPC server. When "Explorer" is already active, it appears that this initialization is dispensed with. Remember that OPC is just a standardized interface (just like ODBC is for Windows database), whose implementation is not always the most optimized. Make sure there is no documentation describing how to do batches - there is probably a procedure to keep the "environment open."

In addition, you would run a performance profiler by comparing the two environments to try to understand what the bottleneck of this overhead is. By looking at the source code of the library (via a decompiler ), we can get "tips" on what code is running eventually we can anticipate before a batch execution with that.

Also check with your hardware vendor if there is no specific .NET interface, rather than using OPC. Some vendors offer and even encourage the use of native .NET libraries (eg: Beckhoff ). From my experience (not very wide in this field, I confess), the difference in performance is brutal.

    
27.02.2017 / 18:41