Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Subscribing to a non-existent item

More
08 Jul 2021 12:57 #9963 by lamar
Sorry, I pasted the wrong "solution" . The working code is:
If StrToIntDef(EventArgs.VTQ.Value,99999) <> 99999 Then ...
I use 16 bit unsigned integer values, thefore 99999 is out of range. Works perfect.
However I did not understand why FlotToStrDef did not work...

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

More
08 Jul 2021 12:55 #9962 by support
I do not pretend to understand what is happening under the hoods, but I am glad that you have found a solution nevertheless.

Best regards

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

More
08 Jul 2021 12:47 #9961 by lamar
There is the solution. So easy as it can be.
If StrToFloatDef(EventArgs.VTQ.Value, NaN) <> NaN Then ...

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

More
08 Jul 2021 12:17 #9960 by lamar
No, the main app that calls the DLL accepts only numerical values.
But as I wrote in my 08 Jul 2021 09:27 comment, I tried to avoid
empty string values inside the DLL without any success.

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

More
08 Jul 2021 12:14 #9959 by support
I am on to something.

What does not really work are the comparisons you have given as examplea:

I tried testing If EventArgs.VTQ.Value <> '' Then ...
I tried testing If EventArgs.VTQ.Value <> null Then ...


It looks like that since the Value is OleVariant, the compiled code ends up calling methods like System.Variants.VarCompareSimple, and they throw an exception in case the variant types are not equal, and it halts the program. And the variant types are often not equal, because if you are dealing with generic&multiple OPC items, they will have different type, so comparing e.g. against a string will fail with a Double, comparing against a number will fail with a string, etc.

Anyway, this underlines the fact that in order to address this, if you do not find the cause yourself, I need to have a code for the repro, and not just "guess" how exactly your code looks like.

Best regards

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

More
08 Jul 2021 12:03 #9958 by support
Is it possible that it has to do with the fact that a String has been returned for that item?
Have you tried any other String-typed item?

One from our server, OPCLabs.KitServer.2 : Simulation.Register_BSTR

One from Matrikon server, Matrikon.OPC.Simulation.1 : Random.String

Regards

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

More
08 Jul 2021 11:55 #9957 by lamar
Absolutely right.

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

More
08 Jul 2021 11:51 #9956 by support
Please clarify: "...any kind of touching EventArgs.VTQ.Value will cause freezing".
The above only applies to certain "problematic" item(s), such as 'Bucket Brigade.UIntqa', right? In other cases, you can access EventArgs.VTQ.Value without an issue?

Regards

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

More
08 Jul 2021 10:32 #9955 by lamar
I got the same result.
However, in the DLL, any kind of touching EventArgs.VTQ.Value will cause freezing.
Do you have any ideas for preventing this?
Are there any other flags to check?
Or maybe checking the event timestamp?

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

More
08 Jul 2021 10:03 #9954 by support
Ok I see, I misunderstood the purpose of the last test app.

Regarding the freezing: I changed both my test example, and this app of yours, to access and use the EventArgs.VTQ.Value for 'Bucket Brigade.UIntqa', and it works OK in both cases.

The updated code in my example looks like this:
      // Handle the notification event
      if eventArgs.Succeeded then
      begin
        WriteLn(eventArgs.Arguments.ItemDescriptor.ItemId, ': ', eventArgs.Vtq.ToString);
        if (eventArgs.Vtq.HasValue) then
          WriteLn('  <', eventArgs.Vtq.Value, '>');
      end
      else
        WriteLn(eventArgs.Arguments.ItemDescriptor.ItemId, ' *** Failure: ', eventArgs.ErrorMessageBrief);

The updated code in your example looks like this:
Edit3.text := 'Edit3 text changed unexpectedly <' + EventArgs.VTQ.Value + '>';

Regards

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

Moderators: support
Time to create page: 0.073 seconds