Click here to Skip to main content
Licence GPL3
First Posted 18 Aug 2010
Views 35,261
Downloads 424
Bookmarked 17 times

Using .NET with Wonderware

By | 24 Aug 2010 | Article
This article will show how to read and write to Wonderware from VB

Introduction

This article is born out of several projects I have had extending Wonderware by calling VB.NET applications. Wonderware is an HMI/SCADA front end made by Wonderware. Wonderware is fairly easy to use, although I am not a huge fan of it, I don't have much against it either. It is just a common program in the SCADA industry. This will show you how to write applications that communicate with Wonderware. I usually have to do this to extend the functionality or to fill in the gaps between what Wonderware can do and what the customer requires.

Background

I write HMI/SCADA software mostly for the oil and gas industry. In this industry, many companies use a product called Wonderware. I have also come across it in waste water plants as well as food processing plants (Cheese Cake to be exact!!!). At most of these facilities, they need a function in the Wonderware application, but Wonderware can't do it. This will give you another option. I have seen other options using DDE. However, DDE is no longer supported so we will be using the Wonderware Toolkit. This code will contact the Wonderware running on the same computer.

Using the Code

Using the code will be pretty easy. We will create 2 VB files that are required to call the Wonderware toolkit (ptacc.dll and wwheap.dll). After that, all that will be left is your application to call the read/write functions of the Wonderare Toolkit. These files were created based on information from Wonderware West and my experience with using the 2 DLLs.

To do this, you need to copy the Intouch.vb and the Ptacc.vb into your project as well as reference the wwheap.dll and the ptacc.dll. Doing this will allow you to communicate with the Wonderware database.

The Ptacc.vb file will contain everything necessary to communicate with Wonderware. However it isn't very pretty, so that is why we use the Intouch.vb file. It is just the basic level.

The Intouch.vb file is going to contain our commands for reading and writing values with the Wonderware database. This will allow you to read/write Strings, Floats, Booleans(Discrete), and Integers.

So if you want to read the first 132 characters from the string variable with the tag SBuffer, then you call IntouchToolkit.ReadString("SBuffer", 132) or you can use ReadInteger, ReadDiscrete and ReadFloat for the respective types. Also, the similar is true but the functions is WriteString, WriteFloat, WriteInteger and WriteDiscrete. The Tag name is always a string.

Now that we got the basics out of the way, you need to call this from your application. This is pretty simple. In your main VB file, whether it is Windows Form or console application doesn't matter. I have not tried this with a web form, but I would like to hear your experience with it if you do try it.

Public Class Form1
    Dim accid As Integer
    Dim hPt As Integer
    Dim SB As String
    Dim IntouchToolkit As Intouch

    '------------------------------------------------
    'Form1_Load
    '------------------------------------------------
    Private Sub Form1_Load(ByVal sender As System.Object, _
		ByVal e As System.EventArgs) Handles MyBase.Load

        IntouchToolkit = New Intouch(0, 0)
        SB = IntouchToolkit.ReadString("SBuffer", 132)	'SBuffer is the Tag 
						'I want to read in Wonderware

    End Sub
    
    Private Sub btnOpen_Click(ByVal sender As System.Object, _
		ByVal e As System.EventArgs) Handles btnOpen.Click
        IntouchToolkit = New Intouch(0, 0)
        IntouchToolkit.WriteDiscrete("SomeTag", 1)
    End Sub
End Class

These are the write functions available to call:

  • IntouchToolkit.WriteString("SomeTag", "FooBar")

    This is to write a string value.

  • IntouchToolkit.WriteFloat("SomeTag", 3.1415)

    This is to write a float value.

  • IntouchToolkit.WriteInteger("SomeTag", 10)

    This is to write an integer value.

  • IntouchToolkit.WriteDiscrete("SomeTag", 1)

    This is to write a boolean value.

These are the read functions available to call:

  • IntouchToolkit.ReadString("SomeTag")

    This is to read a string value.

  • IntouchToolkit.ReadFloat("SomeTag")

    This is to read a float value.

  • IntouchToolkit.ReadInteger("SomeTag")

    This is to read a integer value.

  • IntouchToolkit.ReadDiscrete("SomeTag")

    This is to read a boolean value.

*NOTE: Replace "SomeTag" with the tagname you want to read or write from.

Points of Interest

As you can see, this is pretty simple. I have used this code several times on Wonderware 7.1 to 10.0. I usually put in some code that starts my application when an icon in Wonderware is clicked. This is the reason why I get the x and y values from Wonderware. It took me about a week with Wonderware support to find this information, and they do not support the Wonderware toolkit, but it has been reliable for me.

History

Well, this is the initial version.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

earl the dead cat

Software Developer (Senior)
National Oilwell Varco
United States United States

Member

I am a Developer and Electrical Engineer. I work mostly on HMI and SCADA systems in the Houston area. I have worked mostly around oil and gas industry. I have also spent time in Indiana working on automotive assembly plants.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questiondll call help PinmemberMember 86370127:46 14 Mar '12  
AnswerRe: dll call help PinmemberMember 86370129:30 14 Mar '12  
GeneralRe: dll call help PinmemberMember 863701210:51 14 Mar '12  
GeneralRe: dll call help Pinmemberearl the dead cat14:20 14 Mar '12  
GeneralRe: dll call help PinmemberMember 86370122:46 15 Mar '12  
QuestionRe: dll call help PinmemberMember 86370124:32 16 Mar '12  
AnswerRe: dll call help Pinmemberearl the dead cat16:05 16 Mar '12  
GeneralRe: dll call help PinmemberMember 86370122:33 19 Mar '12  
GeneralRe: dll call help Pinmemberearl the dead cat16:03 16 Mar '12  
Questionthanks! PinmemberLanssens6:55 8 Feb '12  
AnswerRe: thanks! Pinmemberearl the dead cat13:57 8 Feb '12  
GeneralMy vote of 4 [modified] Pinmemberspectr201123:24 7 Nov '11  
GeneralRe: My vote of 4 Pinmemberearl the dead cat1:13 8 Nov '11  
GeneralMessage Removed Pinmemberspectr20111:28 8 Nov '11  
GeneralRe: My vote of 4 Pinmemberearl the dead cat1:42 8 Nov '11  
GeneralMy vote of 4 PinmemberMember 81834275:19 13 Sep '11  
GeneralAck an Alarm using VB Pinmembermartinergb5:07 19 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmemberearl the dead cat2:32 20 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmembermartinergb3:59 21 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmemberearl the dead cat5:25 21 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmembermartinergb21:01 21 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmembermartinergb14:54 26 Dec '10  
GeneralRe: Ack an Alarm using VB Pinmemberearl the dead cat12:00 28 Dec '10  
QuestionDLL problems PinmemberMr Fontenot3:00 10 Nov '10  
AnswerRe: DLL problems Pinmemberearl the dead cat10:45 10 Nov '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120515.1 | Last Updated 24 Aug 2010
Article Copyright 2010 by earl the dead cat
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid