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.

How can I use "WaitForItemValue" in a correct way?

More
11 Mar 2024 07:01 #12630 by mut9bu
Hello

You are absolutely right. That was definitly my fault. Yes I get an Error in the case when the OPC DA server has not the requested item (not quality bad). It's just working as you have described. Yes this WaitForItemValues has spared me a lot of time. Really Great :-)

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

More
09 Mar 2024 14:06 #12629 by support
Hello, before we get to the coding part, I'd like to clarify some things.

1. The WaitXXXX are designed primarily for servers that, upon a first, "unexpected" Read (or right after startup of the server), return Bad or Uncertain quality, because they do not have the data at hand. Subsequent Read-s later then actually return Good data. This is a nasty situation for the client, because extra code logic needs to be put in place to make the repeated reads (or use a subscription). The WaitXXXX methods encapsulate this logic.

I am not sure if what you described falls under this category. The presence/absence of an item for a particular CNC machine is a permanent thing, not transient. Is that correct?

2. Normally, if an item is "not present", the OPC server should report as an error ("unknown Item ID") when reading or trying to subscribe. "Error" is a case different from "quality not Good". What is the behavior of your server, if you do a Read of such item?

Thank you

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

More
09 Mar 2024 08:01 #12628 by mut9bu
Thanks for the detailed answer. Defining the minimum quality for each item seperately would be great because of my following use case:
I am reading lets say 50 items from different CNC machines.45 of them are present in all CNC machines, but 5 of them are present related to the Software version of the CNC. So I would define for 45 items min. quality good, for the rest a much lower quality level. Otherwise I cannot read all of them in one request with waitforitemvalue.

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

More
08 Mar 2024 16:30 #12627 by support
Hello.

Yes, WaitXXX method will subscribe just for the duration of the call. They will unsubscribe upon exiting. (If you have your own explicit subscriptions to the same item, they are not unsubscribed, of course).

You *can* specify the minimum quality with WaitForMultipleItemValues (and it would be DAQualities.GoodNonspecific in your case). However, this case is also the default, and there are method overloads *without* the minimumQuality too, so if you were fine with DAQualities.GoodNonspecific, you can just specify a list/array of DAItemGroupArguments, and a timeout.

If you wanted to have different criteria (e.g. minimum quality) for each item, that is doable too, but would require a small piece of code; let me know if you need that.

I hope this helps
Best regards
The following user(s) said Thank You: mut9bu

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

More
07 Mar 2024 16:09 #12626 by mut9bu
OK got you. Two questions then:

1) Will the "WaitForMultipleItemValues" subscribe just until all the item values have quality "good"? Or will it proceed to subscribe after all item values have quality "good"?
2) When I use "WaitForMultipleItemValues" as below, I see that it has 3 arguments: argumentlist, minimum quality, timeout. Should I write for the second argument 192 for "good"?

ValueResult[] valueResults = client.WaitForMultipleItemValues(dAItemGroupArguments, ??? ,10000);

Kind regards

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

More
07 Mar 2024 14:23 #12624 by support
Hello.

Have you read this?: opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...ng%20for%20OPC-DA%20Items.html

The WaitXXXX use subscriptions internally. So, do not hook the data change notification handler for them. Instead, the result is (/results are) returned via the return values of the WaitXXXX method itself.

The article I pointed to has an example for single item. It does not have an example for multiple values, but since WaitXXXX is quite similar to ReadXXXX, you can use the ReadXXXX example(s) and just replace the method name.

Such as in
opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...0multiple%20item%20values.html

Best regards

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

More
06 Mar 2024 14:03 - 07 Mar 2024 14:15 #12619 by mut9bu
Hello

I am subscribing to multiple values with following code. As you have also mentioned in your documentation, The first values of the items, after subscription started, come sometimes with quality values "bad" or "uncertain", and then with quality good. I want to use "WaitForItemValue" for waiting that all the items get in quality level "good".

I have written following code, but in the item change event I still get item values with uncertain quallity level at the beginning, later they all change to good. What is wrong in my code? Where do I have to define the quality level that has to be waited for? In my case "good". Is it possible to define the minimum quality level for each item seperate?
 List<DAItemGroupArguments> dAItemGroupArguments = new List<DAItemGroupArguments>();
 public void subscribe_items(string ip)
        {             
            dAItemGroupArguments.Add(new DAItemGroupArguments(ip, "OPC.IwSCP.1", "!BSTR," + OPC_device_name + ",System.HardwareDescription", 1000, null));
            dAItemGroupArguments.Add(new DAItemGroupArguments(ip, "OPC.IwSCP.1", "!BSTR," + OPC_device_name + ",Plc.FirmwareVersion", 1000, null));
            // adding some other items
            using (client = new EasyDAClient())
            {
                client.ItemChanged += client_Main1_ItemChanged;
                client.WaitForMultipleItemValues(dAItemGroupArguments.ToArray());          
                Thread.Sleep(10 * 1000);              
            }
        }
 public void client_Main1_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
 {
       if(e.Succeeded==true)
       {
           item_value = e.Vtq.ToString();
           Console.WriteLine(item_value);
       }
Last edit: 07 Mar 2024 14:15 by support.

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

Moderators: support
Time to create page: 0.062 seconds