Test Tools

From OPC Labs Knowledge Base
Jump to navigation Jump to search

Introduction

QuickOPC test tools are of interest to advanced users.

The test application contains functionality related to both OPC “Classic” and OPC Unified Architecture specifications. The tool allows exploration of various API objects and members, testing of the UI dialogs, live data view with multiple items, etc.

The test tools are not installed by default; you need to select “Custom Install”, and then specifically enable them on the “Select Components” page in in the installation wizards. After installation, the test tools can be reached through the Start menu, in the “Test Tools” group under product menu.

The test tool starts with a “switchboard” dialog that allow you to select the particular type of test.

Testtools-switchboard.png

Note that most tests are modeless, meaning that you can open multiple test forms of the same type concurrently, or even combine them with test forms of other types.

The following paragraphs describe certain particular types of tests available.

Main Switchboard Commands

Dialogs

This test allows you to pick one of the OPC common dialogs, provide inputs for it, run it, and then explore its outputs.

Testtools-dialogs.png

Select the dialog in the “Available dialogs” list. Then, use the property grid to enter the dialog inputs, if any are needed. When all the inputs are entered, press the “Show…” button. This will run the dialog. After you close the dialog, you can use the property grid again to view any modified (output) arguments.

Live Data

This test allow you to monitor multiple items concurrently.

Testtools-opcualivedata.png

There are following commands available in this test:

  • Edit Items: Displays a collection editor, where all the items can be viewed and edited, and items can be added or removed individually.
  • Bulk add: Display a multi-selection browse dialog, where you can select the items to be monitored, and add them all at once.
  • Online: Toggles whether the items are subscribed or not.

Object Testbed

The Object Testbed is a very general test form. It allows testing of any .NET object as if you were using it inside a programming language. It allows you to interactively create instances of various objects, explore and modify their properties, call methods, and observe the generated events.

Testtools-objecttestbed.png

The form allows you to work with one object instance at a time. You create this instance by selecting a type from the list or tree of available types, and then pressing the “Instantiate” button. You can later replace the instance by a new one, by repeating this sequence.

After the form is first open, it comes up with an initial instance of the most common type in the API, if defined, to make your life easier. The most commonly used types are offered on the “Favorite Types” tab. You can also select from the full list of available types, on the “All Types” tab.

It is also possible to work just with the static members of any type, without creating an object instance. To work with just the static members of the type, select the type, and press the “Use type” button.

When you have selected the instance (or type), its properties appear in the “Arguments” property grid. You can explore the property values, or enter new ones.

In order to call a method on the instance (or type), select it from the “Method” drop-down. The method arguments (inputs and output, and possibly its return value) appear in the “Arguments” property grid as well. You can now enter the input arguments for the method call. When you are finished, press the “Invoke” button. The method will be called, and the modified arguments (and possibly the return value) will appear in the “Arguments” property grid again. If the method call throws an exception, you will be presented with a dialog box that allows you to view all the exception details.

The test automatically hooks to all events available on the instance (or type), and captures them for inspection in the “Events” box. You can also individually choose which events will be hooked to, using a small button with “event” icon above the “Events” box.

The Object Testbed form also keeps a list of named instances, and allows you to load and save instances from/to this list. This is useful e.g. when you want to use a result of one method call as a new instance under test, or for use as a property value or input argument of another method call.

Selected Usage Scenarios

This chapter describes how to use the Test Tools in specific usage scenarios.

OPC-UA Attribute Services

Read a Single Node

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. In “Method” drop-down, select the following method: Read(UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor): UAAttributeData
  4. In the “Arguments” property grid, select the row “endpointDescriptor: UAEndpointDescriptor”, and click the “…” button on the right.
  5. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  6. In the “Arguments” property grid, select the row “nodeDescriptor: UANodeDescriptor”, and click the “…” button on the right.
  7. From the “Browse for OPC-UA Data” dialog, select the OPC-UA node to read, and press OK.
  8. Press the “Invoke” button to read the data.
  9. If an errors occurs, a box with the exception details will appear. In case of success, the data read will be in the “Arguments” property grid. You can view the data in the row “return: UAAttributeData”; click the “+” sign to expand the row.

Read Multiple Nodes

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. In “Method” drop-down, select the following method: ReadMultiple(UAReadArguments[] readArgumentsArray): UAAttributeDataResult[]
  4. In the “Arguments” property grid, select the row “readArgumentsArray: UAReadArguments[]”, and click the “…” button on the right.
  5. In the “UAReadArguments Collection Editor”, press the “Add” button.
  6. In the property grid, select the “EndpointDescriptor” row, and click the “…” button on the right.
  7. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  8. In the property grid, select the “NodeDescriptor” row, and click the “…” button on the right.
  9. From the “Browse for OPC-UA Data” dialog, select the OPC-UA node to read, and press OK.
  10. Repeat steps 5 to 9 as needed.
  11. Press the OK button to close the collection editor.
  12. Press the “Invoke” button to read the data.
  13. You can view the results in the row “return: UAAttributeDataResult[]” of the “Arguments” property grid; click the “+” sign to expand the row. For each element, in case of success, the AttributeData property will contain the data read. In case of an error, the Exception and other related properties will contain information the problem.

Write Value into a Single Node

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. In “Method” drop-down, select the following method: WriteValue(UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor, Object value): Void
  4. In the “Arguments” property grid, select the row “endpointDescriptor: UAEndpointDescriptor”, and click the “…” button on the right.
  5. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  6. In the “Arguments” property grid, select the row “nodeDescriptor: UANodeDescriptor”, and click the “…” button on the right.
  7. From the “Browse for OPC-UA Data” dialog, select the OPC-UA node to read, and press OK.
  8. In the “Arguments” property grid, select the “value: Object” row, and enter the value to be written.
  9. Press the “Invoke” button to write the value.
  10. If an errors occurs, a box with the exception details will appear. Otherwise, the data will be written.

OPC-UA Data Access

Obtain a Variable Node

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. In the “Instances” list, select the “ModelClientWithServerModel: UAModelClient” instance, and press the “Instance to ‘this’” button. Confirm the warning box about cloning (you may uncheck the “Show cloning-related warnings” box in order to prevent further warnings).
  4. In “Method” drop-down, select the following method: GetNode(UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor): Object
  5. In the “Arguments” property grid, select the row “endpointDescriptor: UAEndpointDescriptor”, and click the “…” button on the right.
  6. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  7. In the “Arguments” property grid, select the row “nodeDescriptor: UANodeDescriptor”, and click the “…” button on the right.
  8. From the “Browse for OPC-UA Data” dialog, select the OPC-UA node to read, and press OK.
  9. Press the “Invoke” button to obtain the variable node.
  10. The variable node appears in the “Attributes” property grid in the “return: Object” row. Note that the node contains default values. See e.g. the “Read Variable Node” for further operations with the node.

Read Variable Node

  1. Perform steps described under “Obtain a Variable Node”.
  2. In the “Arguments” property grid, select the “return: Object” row, and press “Save as new >” button. Press OK to confirm the “Instance name” box, and the warning box about cloning.
  3. In “Method” drop-down, select the following method: ReadNode(Object node): Void
  4. In the “Arguments” property grid, select the “node: Object” row. In the “Instances” list, select the instance created in step 2, and then press the “Load instance >” button. Confirm the warning box about cloning.
  5. Press the “Invoke” button to read the node.
  6. You can view the updated node data in the “Arguments” property grid, under the “node: Object” row. Expand it as needed to view the details.

OPC-UA Discovery Services

Discover Server Endpoints

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. If you want to discover server endpoints on other than the local computer: In the “Arguments” property grid, expand the “EasyUAClient” row, then expand the “Host Parameters” row. Select the “DiscoveryHost” row, and enter the name of the discovery host, or click the “…” button on the right, and select the computer interactively.
  4. In “Method” drop-down, select the following method: DiscoverServers(): UAApplicationElementCollection
  5. Press the “Invoke” button to discover the server endpoints.
  6. In the “Arguments” property grid, select the “return: UAApplicationElementCollection” row, and click the “…” button on the right. A “UAApplicationElement Collection Editor” appears.
  7. You can select any element in the “Members” list, and view its details in the property grid.

OPC-UA Subscription Services, and Monitored Items

Subscribe to a Single Node and View Notifications

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “UA.ObjectTestbed” command. The “Object Testbed” form appears.
  3. In “Method” drop-down, select the following method: SubscribeMonitoredItem(UAEndpointDescriptor endpointDescriptor, UANodeDescriptor nodeDescriptor, Int32 samplingInterval): Int32
  4. In the “Arguments” property grid, select the row “endpointDescriptor: UAEndpointDescriptor”, and click the “…” button on the right.
  5. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  6. In the “Arguments” property grid, select the row “nodeDescriptor: UANodeDescriptor”, and click the “…” button on the right.
  7. From the “Browse for OPC-UA Data” dialog, select the OPC-UA node to read, and press OK.
  8. In the “Arguments” property grid, select the row “samplingInterval: Int32”, and enter the sampling interval (in milliseconds), e.g. 1000.
  9. Press the “Invoke” button to subscribe to the data.
  10. The notifications about data changes will appear in the “Events” part of the Object Testbed form, as “MonitoredItemChanged” events. You can expand the events and view its details as needed.

Subscribe to a Multiple Nodes and Observe Results

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “LiveData” command. The “OPC-UA Live Data” form appears.
  3. On the toolbar, press the “Bulk Add…” button.
  4. From the “Browse for OPC-UA Data” dialog, select the OPC-UA nodes to subscribe. When you focus any node, you can select it by pressing the button with the “down arrow” above the “Selected nodes” list. Multiple nodes from the same parent node can be selected as well.
  5. When you are finished selecting the nodes, and press OK.
  6. The live results now appear on the “OPC-UA Live Data Form”. You can hover over items in the list to view more details, where available.

OPC-UA View Services

Browse for Nodes Interactively

  1. Start the “EasyOPC Forms Test Application”.
  2. Select and perform the “Dialogs” command. The “Dialogs” form appears.
  3. From the “Available dialogs” list, select the “UADataDialog” item.
  4. In the “Dialog properties” property grid, select the “EndpointDescriptor” row, and click the “…” button on the right.
  5. From the “Browse for Host and OPC-UA Server” dialog, select the OPC-UA server endpoint, and press OK.
  6. Press the “Show…” button.
  7. Use the “Browse for OPC-UA Data” to explore the nodes in the server.