Getting Started – .NET WinForm HMI

  • 00:00 – Introduction
  • 00:10 – How to Create an HMI Presentation using OPC Controls.NET
  • 00:30 – How to Use the Controls without Writing any Code
  • 00:36 – Create a Winform Application
  • 01:11 – Select OPC Controls Components
  • 01:33 – Label Control
  • 01:47 – Network Node
  • 02:21 – Set the Formatting
  • 02:32 – OPC Controls Button
  • 02:40 – Set the Color of the Button
  • 02:47 – Set the Pump Value
  • 03:20 – Test the Application
  • 03:47 – More Questions

If you do not have a copy of Visual Studio you can download a free version of Visual Studio Community (formerly Visual Basic Express or C# Express) from visualstudio.microsoft.com/vs/community.  You can choose whether to use Visual Basic or C#, but if you have no experience with either language, Visual Basic is easier for new developers.  No programming is required to use OPC .NET WinForm HMI .NET.

The following steps can be used to add visualization to a C#, C++, or Visual Basic.NET application. Refer to the VB.NET example for programmatic interface of using the OPC Controls components. All properties are programmatically accessible.

The following example demonstrates the use of OPC .NET WinForm HMI .NET with no code required. The components can also be used with Visual Studio 2003. But you will need to download the older 1.1 Framework version of OAS.

Step 1

Load the default DemoTags Tag configuration file if you have replaced your tag configuration with your own tags.

Start Visual Studio and select File->New->Project to create a new C#, C++, or VB project.

.NET WinForm HMI 292

Step 2

Select Windows Application as the project type.

.NET WinForm HMI 293

Step 3

From the Toolbox if OPCControls components are not available right click in the Toolbox and select Choose Items. If it is available to Step 4.

Note: If you have installed Visual Studio after Open Automation Software you can either Browse and include the OPCControls.dll assembly from C:\Program Files\Open Automation Software\OAS\ or uninstall Open Automation Software and reinstall to register the OPCControls.dll assembly with Visual Studio.

.NET WinForm HMI 294

From the .NET Framework Components select all of the OPC Controls components and then select OK.

.NET WinForm HMI 295

Step 4

Add an OPCControlsLabel component onto the Form.

.NET WinForm HMI 296

Right click on the OPCControlsLabel window and select Properties.

.NET WinForm HMI 297

Select the TextOPCSystems_Tag property and use the browse button at the right to set the Open Automation Software Tag to Ramp.Value.

.NET WinForm HMI 298

Note: If you wish to run this application on remote PCs make sure to include the Network Node or IP Address of the OAS Engine.  Select your Network Node or IP Address in the Browse Tags window.

Value is the most commonly used Variable.  See Tag Variables for a complete list of all variables possible.

Local Tag

myGroup.myTag.Value

Basic Networking

\\192.168.0.1\myGroup.myTag.Value

Live Data Cloud Networking from local OAS Engine

RemoteSCADAHosting.myLiveDataCloudNode.myGroup.myTag.Value

Live Data Cloud Networking though remote OAS Engine

\\192.168.0.1\RemoteSCADAHosting.myLiveDataCloudNode.myGroup.myTag.Value

The following is an example of accessing an element of an array as a read only variable.

myGroup.myTag.Value[0]

Note: All Tag names are case sensitive. Ramp.Value is valid, ramp.value is not.

Step 5

Add an OPCControlsButton to the Form.

.NET WinForm HMI 299

Set the TextOPCSystems_Tag to Pump.Value. If the Pump Tag does not exist create a Boolean Tag using Configure-Tags with the name Pump.

Set the Format fields as defined below.

.NET WinForm HMI 300

Set the BackColorOPCSystems_Tag to Pump.Value.

.NET WinForm HMI 301

Set the SetValueOPCSystems_Tag to Pump.Value and the SetValueOPCSystems property to True.

.NET WinForm HMI 302

Step 6

Add an OPCControlsTextBox to the Form.

.NET WinForm HMI 303

Set the TextOPCSystems_Tag property to Pump.Value.  The Format properties for Boolean to Off and On.

.NET WinForm HMI 304

Step 7

Set the compile mode on the Visual Studio toolbar to Release.

.NET WinForm HMI 305

Step 8

Select Build from the VS menu and select to Build the application.

.NET WinForm HMI 306

Step 9

Use Windows Explorer to browse for the application located in the bin\Release directory and run the application.

.NET WinForm HMI 307

Step 10

To deploy the application to remote nodes first make sure the Tags as described in steps 4, 5, and 6 are set to a Network Node or IP Address. Then simply copy the files in the bin\Release directory to the target systems or follow the Smart Client deployment section in this help file to deploy your application using Click Once Deployment.

Note: You can also use the OPCControlsNetworkNodes component and assign a network node alias to change all “localhost” tags to the desired remote node.  This is done with the AddNetworkNodeAlias method. Refer to the VB.NET Example on the exact syntax of how to use this method. Notice how all OPC Controls data sources for a particular node can be reassigned to a remote node with one simple call.

Step 11

There are many different properties to each control.  ImageIndex is available in many of the controls to display different images based on analog or discrete data.

The OPC Controls Data component can be used to access data via code with very simple methods. Refer to the .NET Real Time Data Access Programmatic Interface.