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.

Subscribe method 5.23

More
05 Jul 2014 18:40 #2056 by support
Replied by support on topic Subscribe method 5.23
In general, subscriptions are preferred over repeated reads, for performance reasons. With 30 tags, however, and relatively slow scan rate, repeated reads may be just fine.

I strongly recommend, however, that you use the ReadMultipleItems method, instead of calling the ReadItem in a foreach loop.

BTW, the call to UnsubscribeAllItems is unnecessary with this code (unless there is more to it than posted here).

Best regards

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

More
04 Jul 2014 11:34 #2055 by support
Replied by support on topic Subscribe method 5.23
SubscribeItem returns an integer handle. You can use it in the call to UnsubscribeItem.

I would be, however, surprised, if subscriptions worked but ReadItem does not. Thes error from ReadItem looks like DCOM-config related.

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

More
04 Jul 2014 10:42 #2054 by rickonJJ
Replied by rickonJJ on topic Subscribe method 5.23
This is my second approach:
private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
 
                var client = new EasyDAClient();
 
                DAVtq vtg = client.ReadItem(textBox1.Text, textBox2.Text, textBox5.Text);
 
                if (vtg.Quality.IsGood() == true)
                {
 
                    if (vtg.HasValue() == true)
                    {
 
                        textBox4.AppendText(vtg.Timestamp.ToString() + " ----> " + vtg.Value.ToString());
                        textBox4.AppendText(Environment.NewLine);
                    }
                    else
                    {
 
                        textBox4.AppendText("No Value");
                        textBox4.AppendText(Environment.NewLine);
 
                    }
 
                }
                else
                {
                    textBox4.AppendText("Bad Quality");
                    textBox4.AppendText(Environment.NewLine);
                }
 
                client.UnsubscribeAllItems();
                client = null;
 
 
            }
            catch (Exception ex)
            {
                textBox3.AppendText(DateTime.Now.ToString() + " ----> " + ex.ToString());
            }
        }


it's ok for a long period of working? Using around 30 tags (using a foreach tag => read item)? Because for each timestamp i need to store the value in a DB but also to compute it in a math expression.

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

More
04 Jul 2014 09:53 #2053 by rickonJJ
Hi All,

Im coding some methods with this approach in C#:
        private void button1_Click(object sender, EventArgs e)
        {
 
            var client = new EasyDAClient();
            client.ItemChanged += new System.EventHandler<OpcLabs.EasyOpc.DataAccess.EasyDAItemChangedEventArgs>(this.easyDAClient1_ItemChanged);
            client.SubscribeItem(textBox1.Text, textBox2.Text, textBox5.Text, 5000)
 
        }

private void easyDAClient1_ItemChanged(object sender, OpcLabs.EasyOpc.DataAccess.EasyDAItemChangedEventArgs rgs)
        {
            textBox4.AppendText(rgs.Vtq.Value.ToString() + " ----> " + rgs.Vtq.Quality.ToString() + " ----> " + rgs.Vtq.Timestamp.ToString());
            textBox4.AppendText(Environment.NewLine);
        }


However I would like to have an button to Unsubscribe the items. How can I do it? Its possible in the button1 to subscribe, read and then unsubscribe? Because for my approach I need only to read an item and don't need to subscribe it. My initial idea is to have an timer and then read some items with specific timespan and then process it.

I'm trying this approach because the ReadItem returns me after a few days an unhanded exceptions e.g.:

OpcLabs.EasyOpc.OpcException: An OPC operation failure with error code -2147024891 (0x80070005) occurred, originating from 'OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient'. The inner exception contains details about the problem. ---> System.UnauthorizedAccessException: Access is denied.

OpcLabs.EasyOpc.OpcException: An OPC operation failure with error code -1073430509 (0xC004C013) occurred, originating from 'OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient'. The inner exception contains details about the problem. ---> System.Runtime.InteropServices.COMException: 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).
--- End of inner exception stack trace ---
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.CheckSuccess(OperationResult operationResult)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(ServerDescriptor serverDescriptor, DAItemDescriptor itemDescriptor, DAReadParameters readParameters)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(ServerDescriptor serverDescriptor, DAItemDescriptor itemDescriptor)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(String machineName, String serverClass, String itemId, VarType dataType)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(String machineName, String serverClass, String itemId)

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

Moderators: support
Time to create page: 0.142 seconds