Click here to Skip to main content
15,900,816 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 221.8K   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

 
AnswerRe: SCADA project to C# Pin
earl the dead cat3-Sep-13 3:12
earl the dead cat3-Sep-13 3:12 
Questionusing ptacc.dll under Windows 7 x64 Pin
lodimax30-May-13 21:15
lodimax30-May-13 21:15 
QuestionRe: using ptacc.dll under Windows 7 x64 Pin
earl the dead cat1-Jun-13 21:56
earl the dead cat1-Jun-13 21:56 
AnswerRe: using ptacc.dll under Windows 7 x64 Pin
lodimax1-Jun-13 22:25
lodimax1-Jun-13 22:25 
GeneralRe: using ptacc.dll under Windows 7 x64 Pin
arcus21213-Aug-13 4:20
arcus21213-Aug-13 4:20 
QuestionRe: using ptacc.dll under Windows 7 x64 Pin
Member 99570142-Oct-13 2:46
Member 99570142-Oct-13 2:46 
AnswerRe: using ptacc.dll under Windows 7 x64 Pin
earl the dead cat2-Oct-13 23:26
earl the dead cat2-Oct-13 23:26 
AnswerRe: using ptacc.dll under Windows 7 x64 Pin
bumblebee28-May-14 2:43
bumblebee28-May-14 2:43 

Tech Note 1029

IDEA Toolkit Application Hangs on PtAccInit() on 64-bit Operating Systems



All Tech Notes, Tech Alerts and KBCD documents and software are provided "as is"
without warranty of any kind. See the <a
href="t000792.htm" target="blank">Terms of
Use for more information.



Topic#: 002866

Created: April 2014



Introduction


InTouch Database External Access Toolkit – also called as IDEA Toolkit is used to write external applications to read or write InTouch runtime values.


When an application written with IDEA Toolkit is executed on 64-bit Operating System (eg: Windows 7 64-bit), it hangs on method PtAccInit().


Other Symptoms:



  1. The GUI of IDEA application may not be seen and high CPU usage is observed.
  2. The IDEA application throws following messages in logger:



    Info WWHEAP Assertion Error: File u:\alarmmgrdev\src\systools\wwheap\wheap.c Code {B61E38E9-4E70-11d2-8070-00A0C90055CE}

    Info WWHEAP (0003) HShareInternal: Could not map @80030000. Error 487

    Info WWHEAP (0003) HShareInternal: Attempt to access invalid address.

    Info WWHEAP (0003) pid = 3, T = 5312, Registered = 1

    Info WWHEAP Assertion Error: File u:\alarmmgrdev\src\systools\wwheap\wheap.c Code {B61E38E9-4E70-11d2-8070-00A0C90055CE}

    Info WWHEAP (0003) HShareInternal: Could not map @80040000. Error 487

    Info WWHEAP (0003) HShareInternal: Attempt to access invalid address.

    Info WWHEAP (0003) pid = 3, T = 5312, Registered = 1

Operating System Versions



  • 64-bit Operating Systems (Windows 7 64-bit, Windows 2008 R2 64-bit etc.)

Cause


These messages are because of running the IDEA application on a 64-bit machine.


On 64-bit machines when the IDEA application is run, the GUI of the IDEA application (eg: cideaapp.exe, one of sample applications) is not seen and there is high CPU usage observed. This happens because the application is not supported in the 64-bit environment.


To make this application work on a 64-bit environment, the "/LARGEADDRESSWARE" option must be added to the EXE file in order for the application to handle addresses larger than 2 gigabytes.


wwHeap has a built-in limited range of 2 GB coverage. That 2 GB range can be anywhere legitimately, within the virtual address space of the application.


The virtual address space of a 32-bit /LARGEADDRESSAWARE application is:



  1. 32-bit system /3GB switch is DISABLED = 2 GB
  2. 32-bit system /3GB switch is ENALBED = 3 GB
  3. 64-bit system = 4 GB

When a 32-bit application is Large Address Aware, it can access up to 4 GB on x64 operating systems and up to 3 GB on x86. This can be done by completing the following steps.


Solution



  1. Copy ideaapp.exe to a machine that has Visual Studio 2003 or later installed.
  2. Click Start/All programs/Microsoft Visual Studio 2010(or 2003/2005/2008) and click Visual Studio Tools/Visual Studio 2010 Command prompt.



    Figure 1 (below) shows the Visual Studio 2005 Command prompt:





    Figure 1: Visual Studio 2005 Command Prompt
  3. In the command prompt type editbin /LARGEADDRESSAWARE <IDEA app exe with complete path>(Figure 2 below).





    Figure 2: Editbin Command

  4. Press Enter. A successful editbin command looks like Figure 3 (below):


  5. Figure 3: Successful EditBin Command



  6. Take the new EXE file and replace the existing file in the 64-bit machines.
  7. In post-Vista 64-bit machines change the User Account Control (UAC) to never notify (turn off UAC) from Control Panel/User Accounts/User Accounts, and restart the machine.
  8. Run the application.


After this there should be no high CPU usage and the EXE will work as intended.


Questionneed help Pin
Member 999349622-Apr-13 22:01
Member 999349622-Apr-13 22:01 
AnswerRe: need help Pin
earl the dead cat24-Apr-13 2:57
earl the dead cat24-Apr-13 2:57 
Questiondll call help Pin
Member 863701214-Mar-12 7:46
Member 863701214-Mar-12 7:46 
AnswerRe: dll call help Pin
Member 863701214-Mar-12 9:30
Member 863701214-Mar-12 9:30 
GeneralRe: dll call help Pin
Member 863701214-Mar-12 10:51
Member 863701214-Mar-12 10:51 
GeneralRe: dll call help Pin
earl the dead cat14-Mar-12 14:20
earl the dead cat14-Mar-12 14:20 
GeneralRe: dll call help Pin
Member 863701215-Mar-12 2:46
Member 863701215-Mar-12 2:46 
QuestionRe: dll call help Pin
Member 863701216-Mar-12 4:32
Member 863701216-Mar-12 4:32 
AnswerRe: dll call help Pin
earl the dead cat16-Mar-12 16:05
earl the dead cat16-Mar-12 16:05 
GeneralRe: dll call help Pin
Member 863701219-Mar-12 2:33
Member 863701219-Mar-12 2:33 
GeneralRe: dll call help Pin
Member 836175413-Jan-14 13:07
Member 836175413-Jan-14 13:07 
GeneralRe: dll call help Pin
earl the dead cat13-Jan-14 15:16
earl the dead cat13-Jan-14 15:16 
GeneralRe: dll call help Pin
earl the dead cat16-Mar-12 16:03
earl the dead cat16-Mar-12 16:03 
Questionthanks! Pin
Lanssens8-Feb-12 6:55
Lanssens8-Feb-12 6:55 
AnswerRe: thanks! Pin
earl the dead cat8-Feb-12 13:57
earl the dead cat8-Feb-12 13:57 
GeneralMy vote of 4 Pin
spectr20117-Nov-11 23:24
spectr20117-Nov-11 23:24 
GeneralRe: My vote of 4 Pin
earl the dead cat8-Nov-11 1:13
earl the dead cat8-Nov-11 1:13 

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.