Getting Started with QuickOPC

Page 2 of 14

Contents Introduction............................................................................................................................................3 Getting Started with QuickOPC.NET .....................................................................................................3 Making a first QuickOPC.NET application using Live Binding .....................................................................3 Making a first QuickOPC.NET application using traditional coding ..............................................................5 Where do I go from here? ................................................................................................................................6 Getting Started with QuickOPC-UA for .NET........................................................................................7 Making a first QuickOPC-UA application using Live Binding .......................................................................7 Making a first QuickOPC-UA application using traditional coding ................................................................9 Where do I go from here? ............................................................................................................................. 10 Getting Started with QuickOPC-COM ................................................................................................. 11 Making a first QuickOPC-COM application ................................................................................................ 11 Where do I go from here? ............................................................................................................................. 12 Getting Started with QuickOPC-UA for COM ..................................................................................... 13 Making a first application ............................................................................................................................. 13 Where do I go from here? ............................................................................................................................. 14

Page 3 of 14

Introduction This document consists of three parts:    

GETTING STARTED WITH QUICKOPC.NET, GETTING STARTED WITH QUICKOPC-UA, GETTING STARTED WITH QUICKOPC-COM, and GETTING STARTED WITH QUICKOPC-UA FOR COM.

Depending on whether you develop OPC “Classic” applications for Microsoft .NET, or using Microsoft COM, or application for OPC Unified Architecture, please refer to the corresponding part.

Getting Started with QuickOPC.NET QuickOPC.NET allows you to develop using various models. In this Getting Started chapter, we will present two of them:  

MAKING A FIRST QUICKOPC.NET APPLICATION USING LIVE BINDING (without any coding), and MAKING A FIRST QUICKOPC.NET APPLICATION USING TRADITIONAL CODING (procedural).

Other models available are live mapping, and reactive programming (Rx).

Making a first QuickOPC.NET application using Live Binding In this Getting Started procedure, we will create a Windows Forms application in C# or Visual Basic that subscribes to OPC Data Access (OPC-DA) item and continuously displays it changes. The live binding model allows achieving this functionality by simply configuring the QuickOPC components, without any manual coding. 1. 2.

Install QuickOPC.NET. If you are reading this text, chances are that you have already done this. Start Microsoft Visual Studio 2012, 2013 or 2015, and create new Visual C# or Visual Basic project, selecting “Windows Forms Application” template. Make sure that in the upper part of the “New Project” dialog, the target framework is set to “.NET Framework 4.5” or later.

Page 4 of 14

3.

Drag the DAConnectivity component from the “QuickOPC” tab of the Toolbox to the form’s design surface.

4. 5.

Notice that three icons will appear below the form: One labeled “daConnectivity1”, the second labeled “pointBinder1”, and the third labeled “bindingExtender1”. Drag a standard TextBox from the Toolbox to the form. Right-click on the text box control on the form, and choose “Bind to Point” command. Alternatively, you can select the text box control first, and then choose the “Bind to Point” command in the Properties window; for this to work, however, the commands must be displayed in the Properties window.

If you do not see these commands, display them by right-clicking in the Properties window, and checking “Commands” in the menu.

Page 5 of 14

6.

In the “Point Editor” dialog, select Computers -> Local Computer -> OPC Labs Kit Server -> Demo -> Ramp, and press OK.

7.

Build and run your application. You will see live OPC data changing in the text box. It is also possible to verify the effects of live binding without building the application: On the bindingExtender component placed on the form, select the “Design Online” command. This will cause Visual Studio to perform the live binding immediately. Use the “Design Offline” command to revert back to normal mode.

Making a first QuickOPC.NET application using traditional coding If you are interested in QuickOPC.NET, your task will most certainly involve reading data from an OPC server. Here are a few steps that illustrate how to achieve that, using Microsoft Visual Studio 2012, 2013 o 2015, and a simple Windows Forms application in C#. The steps are quite similar if you are using other tools or a different programming language. We will create a form that will read a float value from the OPC server when loaded, and immediately display the formatted value in the text box on the form.

Page 6 of 14

1. 2. 3.

4.

5.

6.

Install QuickOPC.NET. If you are reading this text, chances are that you have already done this. Start Microsoft Visual Studio 2012, 2013 or 2015, and create new Visual C# project, selecting “Windows Forms Application” template. Instantiate the EasyDAClient component in the form: Drag the EasyDAClient component from the “QuickOPC” tab of the Toolbox to the form’s design surface.

An icon labeled “easyDAClient1” will appear below the form. Add a textbox to the form: Drag the TextBox component from the Toolbox to the form’s design surface. The text box should appear on the form, and in the Properties window, you will see that it has been given a “textBox1” name. Add handler for the Load event of the form: Select the form by clicking on its design surface. Then, in the Properties window, choose the “Events” view (orange lightning icon), and double-click the line with “Load” event (it is under Behavior group). A “Form1_Load” text in bold font will appear next to the event name, and a new event handler will be created for the Load event. The text editor will open for the code, and the caret will be placed into the Form1_Load method. Write the event handler implementation. Add the following code to the body of Form1_Load method: textBox1.Text = easyDAClient1.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single").ToString();

7. 8.

Build the project. Run the application and observe the results. The text box on the form will be filled with a float value we have read from the OPC server, using a single code line!

If you are targeting an environment different from Windows Forms (such as console application, Web, or WPF), your steps will be similar. In place of Step 3, simply reference the OpcLabs.EasyOpcClassic assembly, and create a new instance of OpcLabs.EasyOpc.DataAccess.EasyDAClient object.

Where do I go from here? You now have the basic idea of how to use the QuickOPC.NET. There are many additional resources that you can use to gain additional knowledge about the product. Here are some of them:    

Play with the Demo applications (accessible from the Start menu) and explore the various functionalities that the product provides. Read the Concepts document (accessible from the Start menu). Study the Reference documentation. Review the additional examples and tools included with the product.

Page 7 of 14

Getting Started with QuickOPC-UA for .NET QuickOPC-UA allows you to develop using various models. In this Getting Started procedure, we will present two of them:  

MAKING A FIRST QUICKOPC-UA APPLICATION USING LIVE BINDING (without any coding), and MAKING A FIRST QUICKOPC-UA APPLICATION USING TRADITIONAL CODING (procedural).

Making a first QuickOPC-UA application using Live Binding In this Getting Started procedure, we will create a Windows Forms application in C# or Visual Basic that subscribes to OPC Data Access (OPC-DA) item and continuously displays it changes. The live binding model allows achieving this functionality by simply configuring the QuickOPC components, without any manual coding. 1. 2.

3.

8. 9.

Install QuickOPC-UA. If you are reading this text, chances are that you have already done this. Start Microsoft Visual Studio 2012, 2013 or 2015, and create new Visual C# or Visual Basic project, selecting “Windows Forms Application” template. Make sure that in the upper part of the “New Project” dialog, the target framework is set to “.NET Framework 4.5” or later. Drag the UAConnectivity component from the “QuickOPC” tab of the Toolbox to the form’s design surface.

Notice that three icons will appear below the form: One labeled “daConnectivity1”, the second labeled “pointBinder1”, and the third labeled “bindingExtender1”. Drag a standard TextBox from the Toolbox to the form. Right-click on the text box control on the form, and choose “Bind to Point” command. Alternatively, you can select the text box control first, and then choose the “Bind to Point” command in the Properties window; for this to work, however, the commands must be displayed in the Properties window.

Page 8 of 14

If you do not see these commands, display them by right-clicking in the Properties window, and checking “Commands” in the menu. 4.

In the “Point Editor” dialog, select Hosts -> opcua.demo-this.com -> http:// opcua.demothis.com:51211/UA/Sample Server (UA Sample Server) -> Data -> Dynamic -> Scalar -> Int32Value, and press OK.

5.

Build and run your application. You will see live OPC-UA data changing in the text box. It is also possible to verify the effects of live binding without building the application: On the bindingExtender component placed on the form, select the “Design Online” command. This will cause Visual Studio to perform the live binding immediately. Use the “Design Offline” command to revert back to normal mode.

Page 9 of 14

Making a first QuickOPC-UA application using traditional coding If you are interested in QuickOPC-UA, your task will most certainly involve reading data from an OPC server. Here are a few steps that illustrate how to achieve that, using Microsoft Visual Studio 2012, 2013 or 2015, and a simple Windows Forms application in C#. The steps are quite similar if you are using other tools or a different programming language. We will create a form that will read a float value from the OPC server when loaded, and immediately display the formatted value in the text box on the form. 1. 2. 3.

4.

5.

6.

7. 8.

Install QuickOPC-UA. If you are reading this text, chances are that you have already done this. Start Microsoft Visual Studio 2012, 2013 or 2015, and create new Visual C# project, selecting “Windows Forms Application” template. Instantiate the EasyUAClient component in the form: Drag the EasyUAClient component from the “QuickOPC” tab of the Toolbox to the form’s design surface.

An icon labeled “easyUAClient1” will appear below the form. Add a textbox to the form: Drag the TextBox component from the Toolbox to the form’s design surface. The text box should appear on the form, and in the Properties window, you will see that it has been given a “textBox1” name. Add handler for the Load event of the form: Select the form by clicking on its design surface (make sure that you do not have any other control selected). Then, in the Properties window, choose the “Events” view (orange lightning icon), and double-click the line with “Load” event (it is under Behavior group). A “Form1_Load” text in bold font will appear next to the event name, and a new event handler will be created for the Load event. The text editor will open for the code, and the caret will be placed into the Form1_Load method. Write the event handler implementation. Add the following code to the body of Form1_Load method: textBox1.Text = easyUAClient1.ReadValue("http://localhost:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853").ToString(); Build the project. Run the application and observe the results. The text box on the form will be filled with a float value we have read from the OPC server, using a single code line!

If you are targeting an environment different from Windows Forms (such as console application, Web, or WPF), your steps will be similar. In place of Step 4, simply reference the OpcLabs.EasyOpcUA assembly, and create a new instance of OpcLabs.EasyOpc.UA.EasyUAClient object.

Page 10 of 14

Where do I go from here? You now have the basic idea of how to use the QuickOPC-UA. There are many additional resources that you can use to gain additional knowledge about the product. Here are some of them:    

Play with the Demo application (accessible from the Start menu) and explore the various functionalities that the product provides. Read the Concepts document (accessible from the Start menu). Study the Reference documentation. Review the additional examples and tools included with the product.

Page 11 of 14

Getting Started with QuickOPC-COM Making a first QuickOPC-COM application If you are interested in QuickOPC-COM, your task will most certainly involve reading data from an OPC server. Here are a few steps that illustrate how to achieve that, using Visual Basic 6.0. The steps are similar if you are using other tools or a different programming language. We will create a form that will read a float value from the OPC server when loaded, and immediately display the formatted value in the text box on the form. 1. 2. 3.

Install QuickOPC. If you are reading this text, chances are that you have already done this. Start Visual Basic 6.0, and create new project, selecting “Standard EXE” project type. Reference the EasyOPC-DA component: Select Project -> References from the menu, and look for “OPC Labs EasyOPC.NET Type Library” in the list of available references. Check the box next to it, and press OK.

Page 12 of 14

4.

Place a Text Box onto the form’s surface. Keep the name Text1.

5.

Add handler for the Load event of the form: Switch to Code View, and select the Form object and then its Load member. Visual Basic will add the handler’s skeleton as follows:

6.

Write the event handler implementation. Add the following code to the body of Form_Load method: ' Create EasyOPC-DA component Dim EasyDAClient As New EasyDAClient ' Read item value and display it Me.Text1 = EasyDAClient.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single")

7.

Build and run the application by selecting Run -> Start from the menu, and observe the results. The text box on the form will be filled with a float value we have read from the OPC server.

If you are using a tool that does not have a referencing mechanism similar to Visual basic, you may need to create the EasyOPC-DA component directly. To do so, use the tool’s mechanism to create instance of a COM object, passing it a ProgID string “OpcLabs.EasyOpc.DataAccess.EasyDAClient”.

Where do I go from here? You now have the basic idea of how to use the QuickOPC-COM. There are many additional resources that you can use to gain additional knowledge about the product. Here are some of them:    

Play with the Demo application (accessible from the Start menu) and try obtaining data from the included Simulation OPC server, but also from other OPC servers on your computer or your network. Read the Concepts document (accessible from the Start menu). Study the Reference documentation. Review the additional examples and tools included with the product.

Page 13 of 14

Getting Started with QuickOPC-UA for COM Making a first application If you are interested in QuickOPC-UA, your task will most certainly involve reading data from an OPC UA server. Here are a few steps that illustrate how to achieve that, using Visual Basic 6.0. The steps are similar if you are using other tools or a different programming language. We will create a form that will read a float value from the OPC UA server when loaded, and immediately display the formatted value in the text box on the form. 8. Install QuickOPC. If you are reading this text, chances are that you have already done this. 9. Start Visual Basic 6.0, and create new project, selecting “Standard EXE” project type. 10. Reference the EasyOPC component: Select Project -> References from the menu, and look for “OPC Labs EasyOPC-UA Type Library” in the list of available references. Check the box next to it, and press OK.

Page 14 of 14

11. Place a Text Box onto the form’s surface. Keep the name Text1. 12. Add handler for the Load event of the form: Switch to Code View, and select the Form object and then its Load member. Visual Basic will add the handler’s skeleton as follows:

13. Write the event handler implementation. Add the following code to the body of Form_Load method: ' Create EasyOPC-UA component Dim Client As New EasyUAClient ' Read node value and display it Me.Text1 = Client.ReadValue("http://localhost:51211/UA/SampleServer", _ "nsu=http://test.org/UA/Data/;i=10853")

14. Build and run the application by selecting Run -> Start from the menu, and observe the results. The text box on the form will be filled with a float value we have read from the OPC UA server.

If you are using a tool that does not have a referencing mechanism similar to Visual basic, you may need to create the EasyOPC-UA component directly. To do so, use the tool’s mechanism to create instance of a COM object, passing it a ProgID string “OpcLabs.EasyOpc.UA.EasyUAClient”.

Where do I go from here? You now have the basic idea of how to use the QuickOPC-COM. There are many additional resources that you can use to gain additional knowledge about the product. Here are some of them:    

Play with the Demo application (accessible from the Start menu) and explore the various functionalities that the product provides. Read the Concepts document (accessible from the Start menu). Study the Reference documentation. Review the additional examples and tools included with the product.