Click here to Skip to main content
15,881,173 members
Articles / Desktop Programming / Windows Forms

Using .NET with Wonderware

Rate me:
Please Sign up or sign in to vote.
3.75/5 (9 votes)
24 Aug 2010GPL33 min read 219.7K   3.1K   22   113
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.

VB.NET
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:

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

    This is to write a string value.

  • VB.NET
    IntouchToolkit.WriteFloat("SomeTag", 3.1415)

    This is to write a float value.

  • VB.NET
    IntouchToolkit.WriteInteger("SomeTag", 10)

    This is to write an integer value.

  • VB.NET
    IntouchToolkit.WriteDiscrete("SomeTag", 1)

    This is to write a boolean value.

These are the read functions available to call:

  • VB.NET
    IntouchToolkit.ReadString("SomeTag")

    This is to read a string value.

  • VB.NET
    IntouchToolkit.ReadFloat("SomeTag")

    This is to read a float value.

  • VB.NET
    IntouchToolkit.ReadInteger("SomeTag")

    This is to read a integer value.

  • VB.NET
    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)


Written By
Software Developer Chemex Modular
United States United States
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.

Comments and Discussions

 
QuestionGreat Work! How to know if InTouch-Variable exists? Pin
Member 140456839-Apr-19 21:03
Member 140456839-Apr-19 21:03 
QuestionUnable to install DAServer toolkit! Pin
Member 1412714023-Jan-19 0:32
Member 1412714023-Jan-19 0:32 
QuestionThank you very much for the great job ! Pin
willimann alain11-Nov-18 23:37
willimann alain11-Nov-18 23:37 
Questionc# function to read/write intouch tag Pin
Member 1181022526-Mar-17 22:38
Member 1181022526-Mar-17 22:38 
QuestionWhere to wite this code?? Urgently requiret help Pin
Member 1181022526-Mar-17 16:45
Member 1181022526-Mar-17 16:45 
AnswerRe: Where to wite this code?? Urgently requiret help Pin
earl the dead cat9-Apr-18 11:34
earl the dead cat9-Apr-18 11:34 
QuestionDid you have "Wonderare Toolkit"application install File? Pin
Liu Jason8-Sep-16 2:14
Liu Jason8-Sep-16 2:14 
AnswerRe: Did you have "Wonderare Toolkit"application install File? Pin
earl the dead cat9-Apr-18 11:35
earl the dead cat9-Apr-18 11:35 
QuestionUsing this code with Intouch 12 and Windows 7 Pin
Member 1239838323-Jun-16 13:55
Member 1239838323-Jun-16 13:55 
Questionnot work function ReadString Pin
Member 1157202819-Jun-16 19:34
Member 1157202819-Jun-16 19:34 
Hi!

I can not understand how you use function.

ReadString(ByVal strTagName As String, ByVal intStringLength As Integer) As String

The body of the function you call a function that returns int

Function PtAccReadM Lib "ptacc.dll" (ByVal accid As Integer, ByVal hPt As Integer, ByVal nm As String, ByVal nMax As Integer) As Integer

but You write:
ReadString = PtAccReadM(accid, hPt, strStringTag, intStringLength)
String == Int???

Thanks for the answer!
AnswerRe: not work function ReadString Pin
Steve Evanson4-Aug-16 23:11
Steve Evanson4-Aug-16 23:11 
AnswerRe: not work function ReadString Pin
Member 1412218523-Jan-19 10:45
Member 1412218523-Jan-19 10:45 
BugRe: not work function ReadString Pin
Member 1404568318-Mar-19 23:49
Member 1404568318-Mar-19 23:49 
PraiseRe: not work function ReadString Pin
Member 1434127928-Apr-19 10:30
Member 1434127928-Apr-19 10:30 
QuestionGreat solution Pin
gerrishp27-Mar-16 14:24
gerrishp27-Mar-16 14:24 
AnswerRe: Great solution Pin
Member 1181022523-Mar-17 16:51
Member 1181022523-Mar-17 16:51 
GeneralRe: Great solution Pin
Member 1181022523-Mar-17 17:12
Member 1181022523-Mar-17 17:12 
AnswerRe: Great solution Pin
earl the dead cat9-Apr-18 11:37
earl the dead cat9-Apr-18 11:37 
Suggestioncan't register DLL- FIX Pin
Luc@Judd1-Feb-16 7:50
Luc@Judd1-Feb-16 7:50 
QuestionIs possible to use VB.Net in ArchestrA IDE objects? Pin
douglasfcx3-Jun-15 3:12
douglasfcx3-Jun-15 3:12 
Questionwhere can i find the Intouch.vb and Ptacc.vb file Pin
Liu Jason28-Jan-15 2:48
Liu Jason28-Jan-15 2:48 
AnswerRe: where can i find the Intouch.vb and Ptacc.vb file Pin
earl the dead cat28-Jan-15 3:24
earl the dead cat28-Jan-15 3:24 
GeneralRe: where can i find the Intouch.vb and Ptacc.vb file Pin
Liu Jason28-Jan-15 15:04
Liu Jason28-Jan-15 15:04 
GeneralRe: where can i find the Intouch.vb and Ptacc.vb file Pin
Member 141111697-Jan-19 19:38
Member 141111697-Jan-19 19:38 
GeneralRe: where can i find the Intouch.vb and Ptacc.vb file Pin
earl the dead cat6-Jan-20 10:19
earl the dead cat6-Jan-20 10:19 

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

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