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.

IOPCSyncIO.Read when trying to read a value from a OPC server

More
03 Oct 2017 01:55 #5566 by brian.p.pearson@gmail.com
Hi ZZ,

Thanks for your help and I understand that this forum is meant to help improve the code provided by the OPC Foundation but it is very difficult for developers like myself who cannot afford to become full members and then get access to the documentation and example code that would help develop our skills in the use of the OPC DA .Net libraries.

I now have managed to get an application working using the groups and subscription but I would like to do a lot more as I am sure I am just scratching the surface of the capabilities of the libraries. Any further guidance would be appreciated.

Best regards,

Brian

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

More
30 Sep 2017 08:47 - 30 Sep 2017 08:52 #5560 by support
Hello and welcome.

This is a forum for development related to OPC Labs QuickOPC components. So, from our point of view, the answer to "where I am going wrong" is "The wrong thing is trying to use the OPC Foundation library and not QuickOPC, especially if you have already tried QuickOPC and it works".

Kidding aside, things are actually more complicated than you may think. I cannot tell with 100% certainty just from your code what the issue is, but I have an educated guess. The problem is that in OPC Data Access 1.0x and OPC Data Access 2.0x, you always need to create a so-called OPCGroup, then Add items to it, and only then you can Read them. Then, the newest OPC Data Access 3.0x specification has added an IOPCItemIO interface that allows to do the Read directly the way you do. Few servers implement this newest specification, and even then this interface is optional I think (it is also quite inefficient for repeated reads, anyway). So, in order to resolve your issue with OPC Foundation libraries, I suggest you look into how to create OPCGroup first and add items to it.

QuickOPC hides these complexities from you. The OPC-DA handling code in it is reaching 15 years of maturity, and our experience with OPC will be soon 20 years, and that goes with active involvement *within* OPC Foundation, attending Interoperability Workshops, undergoing compliance certification, etc. While it is certainly possible to put together a small working piece of code with just the interface definitions or OPC Foundation libraries, you will never be able to get close to what a commercial component (not just QuickOPC) provides.

Best regards
ZZ
Last edit: 30 Sep 2017 08:52 by support.

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

More
30 Sep 2017 08:08 - 30 Sep 2017 08:31 #5559 by brian.p.pearson@gmail.com
I am trying to develop an OPC client to read a Thermo Fisher OPC server. I have used the OPC Foundation library to connect to the server, browse the elements and they try to read the first element but I get an IOPCSyncIO.Read error. I have tried the evaluation version of OPC Labs EasyOPC library and it can read the values correctly. Can any please advise where I am going wrong.

The code below has been taken from my client development and I have documented as best I can.
        private void browseThermoTree()
        {
            Opc.ItemIdentifier itemId = null;
            BrowseFilters filters = new BrowseFilters() { BrowseFilter = browseFilter.all };
            BrowsePosition position;
 
            // initialise item array to hold a single item
            Opc.Da.Item[] items = new Opc.Da.Item[1];
            for (int i = 0; i < items.Length; i++)
                items[i] = new Opc.Da.Item();
 
            // initialise url to local server
            Opc.URL url = new Opc.URL("opcda://" + "localhost" + "/" + "EGS.OPCServer.Line10.1");
            _server = new Opc.Da.Server(_fact, null);
 
            try
            {
                //  try to connect to the server
                _server.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential()));
 
                if (_server.IsConnected)
                {
                    // browse the server for all the items - 295 elements returned
                    BrowseElement[] elements = _server.Browse(itemId, filters, out position);
 
                    // of the 295 elements returned, pick the first one to read, ItemName is FRAME1\\Heartbeat
                    items[0].ItemName = elements[0].ItemName;
 
                    // read call causes an exception E_FAIL IOPCSyncIO.Read
                    itemValueResults = _server.Read(items);
 
                    // never get to this code due to exception
                    for (int i = 0; i < itemValueResults.Length; i++)
                    {
                        if (itemValueResults[i].Value != null)
                            tbDebug.AppendText(itemValueResults[i].Value.ToString() + "\n");
                        else
                            tbDebug.AppendText("Item not valid\n");
                    }
 
                    tbDebug.AppendText("\n");
 
                    _server.Disconnect();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 

Thanks for any assistance

Brian Pearson
Last edit: 30 Sep 2017 08:31 by support.

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

Moderators: support
Time to create page: 0.058 seconds