Professional OPC
Development Tools

logos

× If you are developing in .NET, but are using the OPC-UA (OPC Unified Architecture), please post in the QuickOPC-UA category instead.

QUICKopc Client application missing the values and not retaining back

More
13 Feb 2018 03:04 #6039 by SENTHILKUMAR
Dear Z,

we had gone through your forum on subscription. we identified below code based on subscription

kb.opclabs.com/QuickOPC.NET:_How_to_log_OPC_Data_Access_item...ges_into_a_SQL_Server_database

for understanding purpose, please confirm, the subscription works only on change of OPC Tag values.

if yes, please confirm below statement.

our system has counter, the counter will be running every seconds. it will starts from 0 to 59 and resets to zer0 and cycle continues.

is it possible to subscribe 1000 tags with reference to system counter (0 - 59 ) explained above?

and also we had a new requirement of OPC server values need to log in database. we need to log 1000 data ( from OPC Server) in database for every 10 seconds . so we are planning to subscribe 1000 tags at ten seconds interval with reference to system Counter (0 -59 explained above).

please guide us how to proceed?.
whether above logic will work out (without any queue error or PP Error).
do you have any other suggestion, please let us know.

Please Log in or Create an account to join the conversation.

More
13 Feb 2018 00:27 #6038 by SENTHILKUMAR
you are right. we would like to use subscription concept.

please confirm whether subscription will have the queue size issue?
if yes whats maximum size of the queue we need to define?
How subscription differs from ReadMultipleMethod?
whether *pp error was handled in Subscription concept?

Please Log in or Create an account to join the conversation.

More
12 Feb 2018 07:25 #6027 by support
Hello,
here are my responses.

if any modification required on the code , please do the same and share to us?

Not really (except for a recommendation to rewrite the code using subscriptions, see further below).

Also please share the COM / DCOM settings that should be strictly followed for Quick OPCwe are using generic document for COM/ DCOM Settings?

There are no specific settings prescribed just for QuickOPC. Follow the procedures for OPC that are to be found on the Web. The precise procedure, however, isn't documented anywhere, because it depends highly on many factors - among others, OS versions and installed updates. Most importantly, however, when you are able to read initially, you have no need to suspect that COM/DCOM settings are causing any of these problems. Just keep them as they are now.

whether the issue is may be too high tag values?

My understanding is that you are reading approx. 1000 tags once per 10-60 seconds. That's not too high.

is it ok that can we create 2 instance to easy easyopcDAclient?

Yes that's OK. You can even create many instances. You should, however, avoid creating new and new ones perpetually.

whats the maximum OPC tags that Quick OPC can Handle?

There is no absolute limit, it all depends on resource limitations (memory, CPU, network etc.). If the numbers are as I mentioned above, it's certainly OK.

in your reply,observed that reproducing of the error?

If the question is whether we were able to reproduce the error, the answer is No. That is the biggest issue. If we could reproduce it, we would be able to fix it. We cannot use your code directly, but we have tested with equivalent code (doing repeated reads). If you could at least provide a code that sometimes shows the issue with some OPC server available to us, we could then try it on several computers and hopefully it would show up. Or, if you had a virtual machine image with the server+client that shows the issue and can be transferred to us, we again should then be able to diagnose it and fix it.

is there any possible method to compare the previous occurence?

I do not understand this question. Please try to re-formulate.

are we clearing the instance properly?

I think I cannot tell because I do not have that piece of code. Can you please send it or point me to it. In general, however, no clean-up is actually necessary.

But in one piece of your original code, you were calling .Reset - you should not do this at all, and you were also setting some parameters *after* you have already used the EasyDAClient instance for some OPC operations - that is also wrong; any parameters settings should be *before* you call first OPC operation. I already wrote that this should be fixed, so I hope it was.

for clearing we simply dispose method.

Yes that's fine.

is there any steps need to follow apart from dispose?

No

is it possible to check available queue data before reading via DAVtq? so that we change can our logic according to the message available

I do not understand this question. Please try to re-formulate.

last option, if there is any possibility to change our Read OPC Function and share to us?

No - not just because it's our proprietary code, but also because it's not just "a function", its tens or hundreds of files and the whole component code that is involved.

IMPORTANT:
Why precisely are you doing repeated reads? Do you have a reason for not using OPC subscriptions instead?
Can you describe, in very general terms, the purpose and "flow of operations" of your application?

Regards

Please Log in or Create an account to join the conversation.

More
12 Feb 2018 00:49 #6024 by SENTHILKUMAR
Dear Z,

i understood your difficulty. is there any other way to read OPC tag values?
what about subscription option? how it differs from ReadMultipleItem Method?
if there is any bug in the code, please convey the area of code to rectify?


we had a strong belief that issue could be resolved your end until reading the reply.

if any modification required on the code , please do the same and share to us?

Also please share the COM / DCOM settings that should be strictly followed for Quick OPCwe are using generic document for COM/ DCOM Settings?

whether the issue is may be too high tag values?

is it ok that can we create 2 instance to easy easyopcDAclient? whats the maximum OPC tags that Quick OPC can Handle?

in your reply,observed that reproducing of the error?

is there any possible method to compare the previous occurence?

are we clearing the instance properly?

for clearing we simply dispose method.

is there any steps need to follow apart from dispose?

is it possible to check available queue data before reading via DAVtq? so that we change can our logic according to the message available

last option, if there is any possibility to change our Read OPC Function and share to us?

with regards,
senthil

Please Log in or Create an account to join the conversation.

More
11 Feb 2018 13:45 #6022 by support
Thank you for the new information.

The "Invalid *ppErrors returned..." error may be caused by
- a bug in the OPC Server
- some kind of problem in OPC proxies/stubs or the related system code,
- a bug (memory corruption?) in QuickOPC.

The timeout errors may then be a consequence of the "Invalid *ppErrors returned...". Normally, QuickOPC should be able to recover from transient errors, including timeouts. It is my understanding that this is not happening, i.e. that once you receive a timeout, you keep receiving timeouts "for ever", at least on the same EasyDAClient instance. It looks like that a memory corruption and/or an abnormal thread termination in QuickOPC caused an inability to recover.

So, in the end, I have no good news for you. Your code, although not ideal, is OK in principle. It could be a bug in QuickOPC that is causing this, but we are unable to tell more without actually being able to reproduce it here (can you reproduce something like e.g. with the OPC server that we distribute with the toolkit, or some other server that we can get hold of? If so, we could try to reproduce it here, too).

With this, you could only "mitigate" the negative effects - try to detect the problem and work around it. It looks like that you are already doing so, by creating a new instance of the EasyDAClient. That will work for some time, but it is not clear whether the old instances will not leave behind some memory or threads or other resources. So over time, it would be advisable to restart the process.

I know these are unfortunate news, but without having ability to reproduce and debug the problem here, we cannot determine the precise cause, and therefore we cannot fix it.

Regards

Please Log in or Create an account to join the conversation.

More
11 Feb 2018 13:10 #6021 by support
Hello,

I agree with the first part of the changes (with the reservation that the actual ReadItem timeout value depends on the requirements), but *not* with this one:
//set queue size is 90000 since we have to read 1000 OPC Values and each one length is about 80. so instaed of 80000, we are planning to 10000 additional space. sototally 90000.
 
easyOPCClient.PullItemChangedQueueCapacity = 90000;
Doing so is unnecessary, because you are not using the event pull mechanism at all, so the end result would be just increased memory consumption and CPU usage.

I will also reply to your first post, separately.

Please Log in or Create an account to join the conversation.

More
11 Feb 2018 00:23 #6020 by SENTHILKUMAR
Dear Z,

we are panning to introduce the below line in our code during our initialization of the code.

please find below our initialization module.

//for avoiding restart

EasyDAClient.SharedParameters.TopicParameters.SlowdownWeight = 0.0f;
EasyDAClient.SharedParameters.TopicParameters.SpeedupWeight = 0.0f;
easyOPCClient.InstanceParameters.Timeouts.ReadItem = 6000;//set 8 seconds timeout for read item
easyOPCClient.InstanceParameters.Mode.AllowAsynchronousMethod = false;
easyOPCClient.InstanceParameters.UpdateRates.ReadAutomatic = Timeout.Infinite;
easyOPCClient.InstanceParameters.UpdateRates.WriteAutomatic = Timeout.Infinite;


//set queue size is 90000 since we have to read 1000 OPC Values and each one length is about 80. so instaed of 80000, we are planning to 10000 additional space. sototally 90000.

easyOPCClient.PullItemChangedQueueCapacity = 90000;

please confirm any other initialize function need to add.








Invalid *ppErrors returned by IOPCSyncIO/IOPCAsyncIO/IOPCAsyncIO2/IOPCSyncIO2/IOPCAsyncIO3:

Please Log in or Create an account to join the conversation.

More
10 Feb 2018 00:31 - 11 Feb 2018 10:55 #6019 by SENTHILKUMAR
Dear Z
thanks for your input..
please find attached log files. two types error attached reading OPC server (Vtqresult.vtq). the error were captured using vtq.exception.

type 1 error:
Error while extracting the values from OPC Server Read not completed. This error indicates that it could not be verified that the requested read operation was completed during the timeout period. It is possible that the read operation will actually succeed or fail, but later. Increase the timeout period if you want to obtain positive or negative indication of the operation outcome. Other reason for this error may be that under heavy loads, topic request or response queue is overflowing. Check the event log for queue overflow errors (if event logging is supported by the product and enabled).

type 2 error

Error while extracting the values from OPC ServerInvalid *ppErrors returned by IOPCSyncIO/IOPCAsyncIO/IOPCAsyncIO2/IOPCSyncIO2/IOPCAsyncIO3::Read(...)/Write(...).

after your discussion we modified our code as per below

modified code :

static void ReadOPCTagValues()
        {
 
            int count = GloabalVariables.TagCollection.ToArray().Length;
            string[] TagSubArray = GloabalVariables.TagCollection.ToArray();
            DAItemDescriptor[] subarray = new DAItemDescriptor[GloabalVariables.TagCollection.ToArray().Length];
            var ServerDetail = new OpcLabs.EasyOpc.ServerDescriptor();
            string string1;
            DAVtqResult[] vtqResults;
 
            //var easyOPCClient = new EasyDAClient();
            //EasyDAClient easyOPCClient = new EasyDAClient();
 
 
 
            Console.WriteLine("Variable initialization Completed");
            LogWriter(" OPC Funtion : Varibale initialization completed");
 
 
            try
            {
                for (int i = 0; i < count; i++)
                    subarray[i] = new DAItemDescriptor(TagSubArray[i]);
 
 
 
                Console.WriteLine("Deccriptor creation Completed");
                LogWriter(" OPC Funtion : Deccriptor creation completed");
 
 
                ServerDetail.MachineName = HostName;
                ServerDetail.ObjectId = ServerClass;
                EasyDAClient.SharedParameters.ClientParameters.UseCustomSecurity = false;
            }
            catch(Exception e)
            {
                Console.WriteLine("Deccriptor creation Exception" + e.Message);
                ErrorLogWriter(" OPC Funtion : Deccriptor creation Exception" + e.Message);
            }
            try
            {
 
 
                StreamWriter WriteTagName = new StreamWriter(System.IO.Directory.GetCurrentDirectory().ToString() + @"\TagNamesWithDomain.txt", true);
                WriteTagName.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:fff") + " Start Cycle : " + countCycle.ToString());
 
               // Client. = true;
                Console.WriteLine("OPC Funtion : Trying to connect");
                LogWriter("OPC Funtion : Trying to connect");
 
 
                //iterate over tagarray and create //TagSubArray
                try
                {
 
 
 
                        vtqResults = easyOPCClient.ReadMultipleItems(ServerDetail, subarray);
                        Console.WriteLine("OPC Funtion :OPC Buffer reading Completed with mesage length " + vtqResults.Length);
                        LogWriter("OPC Funtion :OPC Buffer reading Completed with mesage length " + vtqResults.Length);
 
 
 
 
                    //   OperationException.
 
 
                   // bool test1234 = vtqResults[0].Vtq.HasValue;
 
 
 
 
 
                    for (int i = 0; i < vtqResults.Length; i++)
                    {
                            try
                            {
                                Debug.Assert(vtqResults[i] != null);
 
 
 
 
 
                                if (vtqResults[i].Succeeded)
                                {
 
                                    string1 = Convert.ToString(vtqResults[i].Vtq);
                                    Console.WriteLine("Tag index [{0}].Tag Value:{1}", i, vtqResults[i].Vtq);
                                    //Console.WriteLine(" lENGTH OF REC MESSAGE : " + string1.Length);
                                    LogWriter(Convert.ToString(i) + " " + string1);
 
 
 
                                    if (string1.Length > 30)
                                    {
                                        string[] splitString1 = string1.Split(' ');
                                        GloabalVariables.QualityCollection.Add("GOOD");
                                        GloabalVariables.ReadableTags.Add(i);
 
 
                                        if (splitString1[1] == "{System.Boolean}")
                                        {
                                            //splitString1[0] = splitString1[0].Substring(0, 1);
                                            if (splitString1[0] == "False")
                                                GloabalVariables.BooleanValueCollection.Add(false);
                                            else
                                                GloabalVariables.BooleanValueCollection.Add(true);
 
                                            // Console.WriteLine(" The Boolean is " + GloabalVariables.BooleanValueCollection[GloabalVariables.BooleanValueCollection.Count-1]);
                                        }
                                        else
                                        {
 
                                            GloabalVariables.DoubleValueCollection.Add(Convert.ToDouble(splitString1[0]));
                                            // Console.WriteLine("the real value is " + RealValue);
                                        }
 
                                        Console.WriteLine(i + ". " + TagSubArray[i] + ": " + splitString1[0]);
                                        WriteTagName.WriteLine(i + ". " + TagSubArray[i] + ": " + splitString1[0]);
 
                                    }
                                    else
                                    {
                                        GloabalVariables.QualityCollection.Add("BAD");
                                        GloabalVariables.ErrorMessageCount++;
 
                                    }
                                }
                                else
                                {
                                    Console.WriteLine(" Error while  extracting the values from OPC Server" + vtqResults[i].Exception.Message);
                                    ErrorLogWriter(" Error while  extracting the values from OPC Server" + vtqResults[i].Exception.Message);
                                    GloabalVariables.ErrorMessageCount++;
 
                                }
 
                            }
 
                            catch(OperationException e)
                            {
                                Console.WriteLine(" Operation exception :" + e.Message);
                                ErrorLogWriter("OPC Funtion :" + "Operation exception Exception" + e.Message);
                            }
                            catch (IndexOutOfRangeException e)
                            {
                               // GloabalVariables.ErrorMessageCount++;
                                Console.WriteLine("Index out of range exception " + TagSubArray[i] + "  " + e.Message);
                                Console.WriteLine("Recived Message : " + vtqResults[i].Vtq + "LENGTH OF MESSAGE = " + vtqResults[i].Vtq.ToString().Length);
                                ErrorLogWriter("OPC Funtion :" + "IndexOutOfRangeException" + e.Message );
                            }
                            catch (Exception e)
                            {
                              //  GloabalVariables.ErrorMessageCount++;
                                Console.WriteLine(e.Message);
                                ErrorLogWriter("OPC Funtion :" + "General Exception" + e.Message);
                            }
                            finally
                            {
 
                             if (GloabalVariables.ErrorMessageCount > GloabalVariables.TagCollection.Count)
                             {
                                 GloabalVariables.ErrorMessageCount = 0;
                                 GloabalVariables.QualityCollection.Clear();
                                 GloabalVariables.ReadableTags.Clear();
                                 GloabalVariables.BooleanValueCollection.Clear();
                                 GloabalVariables.DoubleValueCollection.Clear();
                                 easyOPCClient.Reset();                                 
                                 easyOPCClient.Isolated = true;
                                 easyOPCClient.InstanceParameters.Timeouts.ReadItem = 30000;//set 20 seconds timeout for read item
                                 easyOPCClient.InstanceParameters.Mode.AllowAsynchronousMethod = false;
                                 easyOPCClient.InstanceParameters.UpdateRates.ReadAutomatic = Timeout.Infinite;
                                 easyOPCClient.InstanceParameters.UpdateRates.WriteAutomatic = Timeout.Infinite;
 
 
                                //clearBuffers();
                                GloabalVariables.ReInitialise = true;                               
 
                             }
 
 
 
                            }         
 
 
 
                    }
                }
 
                catch(OperationException e)
                {
                    Console.WriteLine("OPC exception " + e.Message);
                    ErrorLogWriter(" Read OPC Value : Operational Exception" + e.Message);
 
                }
                catch (FileNotFoundException e)
                {
                    Console.WriteLine("OPC exception " + e.Message);
                    ErrorLogWriter(" Read OPC Value : FileNotFoundException" + e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("OPC exception " + e.Message);
                    ErrorLogWriter(" Read OPC Value : General Exception" + e.Message);
                }
 
                WriteTagName.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:fff") + " End Cycle :" + countCycle.ToString());
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:fff") + "  End Cycle :" + countCycle.ToString());
                Console.WriteLine(" the license of Quick OPC {0}", easyOPCClient.LicenseInfo);
                WriteTagName.Close();
                countCycle++;
               // System.Threading.Thread.Sleep(1300);
 
 
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                ErrorLogWriter(" Read OPC Value : General Exception" + e.Message);
 
            }
            finally
            {
 
 
            }
            return;
 
 
 
        }

we included operation exception and vtq exception in our code to get the error.please guide us how to overcome the issue
Attachments:
Last edit: 11 Feb 2018 10:55 by support.

Please Log in or Create an account to join the conversation.

More
09 Feb 2018 08:12 - 09 Feb 2018 08:12 #6012 by support
Yes, you have done it right. There has been a name change in some past version, and I have taken the recommendation that is obsolete, by mistake.

The current name is TopicParameters indeed.

Regards
Last edit: 09 Feb 2018 08:12 by support.

Please Log in or Create an account to join the conversation.

More
09 Feb 2018 07:51 #6011 by SENTHILKUMAR
dear Z,

sorry for late info.

we introduced below line in the code as you guided

EasyDAClient.SharedParameters.TopicParameters.SlowdownWeight = 0.0f;
EasyDAClient.SharedParameters.TopicParameters.SpeedupWeight = 0.0f;


we dont have "topic" in our EasyDAClient.Sharedparameters. instead of that we are using "TopicParameters"

whether it will affect any of our Process?

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.264 seconds

      

 Recommend this on Google