appendix d: integrating third-party hmi applications …pub/@electrical/documents/cont… · hmi...

32
HMI Applications PowerNet Software Version 3.20 and Greater D-1 Appendix D Integrating Third-Party HMI Applications with PowerNet Software Appendix Contents Overview................................................................................................................................. D-1 ActiveX Capability ................................................................................................................. D-1 ActiveX Control Functions ..................................................................................................... D-2 Integrating Wonderware InTouch Software with PowerNet Software .................................. D-3 Integrating ICONICS Genesis32 Software with PowerNet Software .................................... D-8 Overview PowerNet Software can be integrated with third-party HMI graphical applications so as to handle alarming and to display facility site plans, one-lines, elevations, and trend profiles. Graphical elements, such as breakers and starters, can be animated to indicate an open, closed, or tripped status. Depending on what kind of PowerNet System you purchased, one of two such graphical applications might be bundled with your PowerNet Software on a second CD: either Wonderware InTouch software or ICONICS Genesis32 software. This appendix provides a description of PowerNet's ActiveX capabilities and the basic information necessary to integrate PowerNet with Wonderware or ICONICS. All the necessary script for PowerNet's ActiveX control is included. However, the how-to sections are deliberately only outlines, because the details on how to use Wonderware or ICONICS integration applications are for Wonderware and ICONICS to document in their own users' manuals and on-line help. ActiveX Capability ActiveX controls are standalone software components that perform specific functions in a standard way. ActiveX controls are not separate applications. Instead, they are modules that are placed into a container application. The HMI applications Wonderware InTouch and ICONICS Genesis32 are ActiveX containers. Such third-party HMI applications can contain and thereby allow use of the ActiveX Monitor windows that you received with your purchase of PowerNet Software. The ActiveX windows allow you to link faceplate data from Cutler-Hammer INCOM devices without creating custom screens or using tags for the parameters displayed within those windows. These are the same display plates used by PowerNet Monitor. Security privileges do not need to be recreated within third-party HMI applications. The PowerNet ActiveX component allows the user to log on and off using the user security

Upload: hadien

Post on 30-Jul-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-1

Appendix D Integrating Third-Party HMI Applications with PowerNet Software

Appendix Contents

Overview................................................................................................................................. D-1

ActiveX Capability ................................................................................................................. D-1

ActiveX Control Functions..................................................................................................... D-2

Integrating Wonderware InTouch Software with PowerNet Software .................................. D-3

Integrating ICONICS Genesis32 Software with PowerNet Software.................................... D-8

Overview

PowerNet Software can be integrated with third-party HMI graphical applications so as to

handle alarming and to display facility site plans, one-lines, elevations, and trend profiles.

Graphical elements, such as breakers and starters, can be animated to indicate an open, closed,

or tripped status.

Depending on what kind of PowerNet System you purchased, one of two such graphical

applications might be bundled with your PowerNet Software on a second CD: either

Wonderware InTouch software or ICONICS Genesis32 software.

This appendix provides a description of PowerNet's ActiveX capabilities and the basic

information necessary to integrate PowerNet with Wonderware or ICONICS. All the

necessary script for PowerNet's ActiveX control is included. However, the how-to sections

are deliberately only outlines, because the details on how to use Wonderware or ICONICS

integration applications are for Wonderware and ICONICS to document in their own users'

manuals and on-line help.

ActiveX Capability

ActiveX controls are standalone software components that perform specific functions in a

standard way. ActiveX controls are not separate applications. Instead, they are modules that

are placed into a container application. The HMI applications Wonderware InTouch and

ICONICS Genesis32 are ActiveX containers.

Such third-party HMI applications can contain and thereby allow use of the ActiveX Monitor

windows that you received with your purchase of PowerNet Software. The ActiveX windows

allow you to link faceplate data from Cutler-Hammer INCOM devices without creating

custom screens or using tags for the parameters displayed within those windows. These are

the same display plates used by PowerNet Monitor.

Security privileges do not need to be recreated within third-party HMI applications. The

PowerNet ActiveX component allows the user to log on and off using the user security

HMI Appl icat ions

D-2 PowerNet Sof tware Vers ion 3 .20 and Greater

defined within the PowerNet System. An inactive terminal can automatically log a user off to

prevent unauthorized access.

By using the PowerNet Monitor ActiveX control, you can do the following:

♦ connect to PowerNet DeviceServers,

♦ display/monitor real-time device data,

♦ display/monitor a device's real-time mix/max values,

♦ execute device control functions, and

♦ show graphical historical trending for selected device attributes.

ActiveX Control Functions

In conjunction with your third-party graphics package, the Cutler-Hammer CHWrapActiveX control allows you to create a graphical user interface with custom buttons for several control

functions. The following table lists the PowerNet ActiveX Control functions that you can call

in your third-party graphics application script.

Function Call (Italics indicate a variable that you will provide using your third-party graphics package.)

Description

ActiveXStartApplication This must be the first function you call in order

to set up the system properly. This function

sets up the system, allocates the necessary

resources, and displays a log-on screen for the

user to log on to the system. Note that the log-

on screen might not appear if you have already

logged on to any PowerNet Software

applications. Returns a 0 if the function worked

properly.

ActiveXIsAutoLogoffSet Returns a 1 (i.e., true) if the auto-logoff feature

is enabled.

ActiveXIsViewOnly Returns a 1 (i.e., true) if the current user has

only view-only privileges

ActiveXLogOff Logs the current user off, meaning that the user

can only perform operations associated with

view-only security privileges from then on.

ActiveXLogOn Displays the log on dialog box so that a user

can log on or re-log on to the system. The

user's access privileges will accord with those

granted them in the PowerNet System at large.

Returns a 0 if the function worked properly.

ActiveXLogOnEx(userid, password) Uses the specified user ID and password to log

on or re-log on automatically to the system

without displaying the log-on screen. Returns a

0 if the function worked properly.

ActiveXSetAutoLogoff(boolean value) Enables (boolean value = 1) or disables

(boolean value = 0) the auto-logoff feature.

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-3

Function Call (Italics indicate a variable that you will provide using your third-party graphics package.)

Description

ActiveXEnd Disconnects all the PowerNet DeviceServers

and releases all the allocated resources. This

must be the last function you call in an

application.

ActiveXShowDevice(IP, Device_Number) Displays the real-time device values

monitor/control screen for the device with the

specified IP address and device number.

Returns a 0 if the function failed.

ActiveXShowDeviceMinMax(IP,

Device_Number)

Displays the real-time device min/max values

monitor/control screen for the device with the

specified IP address and device number.

Returns a 0 if the function failed.

ActiveXShow(IP) Manually reconnects to the DeviceServer

whose IP address is specified in the

parentheses and restarts all of the displayed

attribute connections. Note that to use this

function, the device has to already be

connected to the DeviceServer using either the

ActivXShowDevice or

ActivXShowDeviceMinMax functions.

0=Failed to connect to DeviceServer.

1=DeviceServer is still connected.

-1=DeviceServer or IP address not found.

ActiveXSetAutoReconnectTime(Seconds) Sets the auto reconnect time in seconds.

The range is 30-300 seconds (5 minutes).

Default is 60 seconds.

0=disable.

Integrating Wonderware InTouch Software with PowerNet Software

This section discusses the capabilities of Wonderware InTouch software when it is integrated

with PowerNet Software and provides an example of the application script you will need to

compose in order to integrate the two of them.

PowerNet DDE Interface

Wonderware InTouch most often receives information through PowerNet DDE Server. DDE

Server must first be running on a computer before information can be viewed from the

PowerNet network through Wonderware InTouch software. If you cannot guarantee that a

user will first start DDE Server before starting Wonderware InTouch, it is recommended that

you place DDE Server in your startup script within Wonderware.

Setting Up the PowerNet Monitor ActiveX Control in Wonderware InTouch

You can install and configure the Monitor ActiveX control that came with your purchase of

PowerNet using the Wonderware applications called InTouch and WindowMaker.

HMI Appl icat ions

D-4 PowerNet Sof tware Vers ion 3 .20 and Greater

Note

This documentation limits itself to providing only the most basic information about Wonderware

applications, the information necessary to integrate them with PowerNet. For detailed documentation

and for updates about those applications, you should refer to Wonderware's own web site, users'

manuals, and on-line help.

The following tasks are involved in installing your PowerNet ActiveX control:

♦ creating a blank application using Wonderware's InTouch application,

♦ installing the PowerNet ActiveX control in the application,

♦ creating two windows for the application,

♦ adding PowerNet script to control each of the windows,

♦ creating control buttons for one of the windows,

♦ adding PowerNet script to control each of the buttons, and

♦ testing your application.

The following sections include the steps necessary to accomplish these various tasks. The

sections describe a minimalist application consisting of two windows and the four most

commonly used PowerNet ActiveX control functions (Show Values, Show MinMax, Log On,

and Log Off). For information about the other functions available with your PowerNet

ActiveX control, see the earlier section, ActiveX Control Functions. You can create more

windows and buttons to suit your application users' needs.

Creating a New, Blank Application

To create a blank application file for scripting, complete the following steps.

1. From the Windows Start menu, select Programs and then, from the submenus that pop

up Wonderware FactorySuite and InTouch.

Note

If InTouch has never before been run on the PC you are using, the Welcome to InTouch Application

Manager wizard window displays. If it does display, click the Cancel button.

The InTouch Application Manager window displays.

2. From the File menu, select New.

The first dialog box of the Create New Application wizard displays.

3. Follow the wizard prompts to create a new application in its own folder.

InTouch creates a new application and displays the new application in the Application

Manager list.

You are now ready to install the PowerNet ActiveX control.

Installing the PowerNet ActiveX Control

To install the PowerNet ActiveX Control in your InTouch application, complete the following

steps.

1. In the Application Manager window of InTouch, select the new application you

created.

2. From the File menu, select WindowMaker.

The WindowMaker application starts and displays the new application in a development

environment.

5. From the Special menu, select Configure and, from the submenu that pops up, select

Wizard/ActiveX Installation.

The Wizard/ActiveXInstallation dialog box displays.

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-5

6. Click on the ActiveX Control Installation tab.

The tab displays both installed and still available ActiveX controls.

7. Scroll through the Available ActiveX controls list box; find and select

CHWrapActiveX.

8. Click the Install button.

WindowMaker installs the selected control into your application. The control displays in

the list box above the one from which you selected it.

9. Click the OK button.

The Wizard/ActivXInstallation dialog box closes.

You are now ready to create and script the Startup window.

Creating and Scripting the Startup Window

The Startup window will not be seen by the end user of your InTouch application. Its purpose

is simply to house the PowerNet ActiveX control.

To create and script the Startup window, complete the following steps.

1. In the WindowMaker environment for your new application, select New Window

from the File menu.

The Window Properties dialog box displays.

2. Click in the Name field to position the cursor there and type a name, such as Startup,

for the new window.

3. Click the OK button.

The Window Properties dialog box closes and the form for your new window displays.

4. Click the Wizard icon on the toolbar.

The Wizard Selection dialog box displays.

5. From the list of wizards in the Wizard Selection dialog box, click the ActiveX Controls category, if it is not already selected.

All available ActiveX controls display in the box to the right of the list.

6. Select the ocx icon for the CHWrapActiveXCtrl control and then click the OK button.

(Alternatively, you can double-click the ocx icon.)

The Wizard Selection dialog box closes.

7. Move your mouse over the form for your window.

The mouse pointer displays as a corner symbol.

8. Click the location in your window where you want to paste the control.

The control is pasted where you clicked.

Note

The squares surrounding a control are sizing handles and indicate that it is currently selected.

9. Right-click on the new ActiveX object and select Properties.

The Properties dialog box for the Active object displays.

10. In the Properties dialog box, select the Control Name tab, enter a unique name for

your control in the ControlName field, and then click the OK button.

HMI Appl icat ions

D-6 PowerNet Sof tware Vers ion 3 .20 and Greater

The Properties dialog box closes.

Important

You must define a unique name for each ActiveX control in your InTouch application. The name will

be used to identify the control in the scripts you write for this and the MainScreen window, as well as

for the buttons you create.

11. From the Special menu, select Scripts and, from the submenu that pops up, Window Scripts.

The application's Script window displays.

12. From the Condition Type drop-down menu, select On Show and then enter the

following script into the scripting window, replacing CHWrapActiveXCtrl with the

control name you designated in the properties box in step 10.

#CHWrapActiveXCtrl.ActiveXStartApplication();

13. Click OK to save this script.

You are now ready to create and script the window that end users of your application will

see.

Creating and Scripting the MainScreen Window

The MainScreen window is the one the end users of your InTouch application will see. In this

documentation, it is called MainScreen; but you can give it any name you think will be

meaningful to your end users.

1. In the WindowMaker environment for your new application, select New Window

from the File menu.

A dialog box displays asking if you want to copy the scripts from the Startup window you

just created to the new one you are creating.

2. Click the No button.

The Window Properties dialog box displays.

3. Click in the Name field to position the cursor there and type a name, such as

MainScreen, for the second window.

4. Click the OK button.

The Window Properties dialog box closes and the form for your new window displays.

Note

The new form displays directly on top of the Startup window you created previously. You can click

and drag the new form around the environment, if you want to see the Startup window.

5. From the Special menu, select Scripts and, from the submenu that pops up, Application Scripts.

The application's Script dialog box displays.

6. From the Condition Type drop-down menu in the Script dialog box, select On Shutdown and type the following script into the script box below the drop-down menu.

Replace CHWrapActiveXCtrl with the control name you entered when creating the

Startup window (see Creating and Scripting the Startup Window). And replace

MainScreen with the window name you entered in step 3 above (but keep the double

quotation marks).

#CHWrapActiveXCtrl.ActiveXEnd();

SHOW "MainScreen";

7. Click OK to save this script.

You are now ready to add control buttons to your MainScreen window.

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-7

Creating and Scripting Control Buttons

This section describes how to create and script buttons for the four most commonly used

PowerNet ActiveX functions: Show Values, Show MinMax, Log On, and Log Off.

To create and script these buttons, complete the following steps.

1. With the form for your MainScreen window open in WindowMaker, click the button tool icon on the Drawing toolbar.

2. Move your mouse back over the form for your MainScreen window.

The mouse pointer displays as crosshairs.

3. Click, drag, and release the mouse to draw a button.

The button displays with the default label, Text.

4. To change the label, right-click on the button, select Substitute and, from the submenu

that pops up, Substitute Strings.

The Substitute Strings dialog box displays.

5. In the New String text box, type the desired label for this button and then click the OK button.

The Substitute Strings dialog box closes and your button displays its new label.

6. Repeat steps 1 to 5 until you have created a total of four buttons.

7. Double-click one of the buttons you created.

The Animation Links dialog box displays.

8. In the Touch Links section of the Animation Links dialog box, click the Action

button.

The Action button's check box is selected and the Action Script window displays.

9. From the Condition Type drop-down menu, select On Key Down and enter one of the

following scripts.

Replace CHWrapActiveXCtrl with the control name you entered when creating the

Startup window (see Creating and Scripting the Startup Window).

Replace the letters IP used here with the DeviceServer's actual IP address, but keep the

double quotation marks.

For a Show Values button, enter the following script.

#CHWrapActiveXCtrl.ActiveXShowDevice("IP", 1);

For a Show MinMax button, enter the following script.

#CHWrapActiveXCtrl.ActiveXShowDeviceMinMax("IP", 1);

For a Logon button, enter this script.

#CHWrapActiveXCtrl.ActiveXLogOn();

For a Logoff button, enter this script.

#CHWrapActiveXCtrl.ActiveXLogOff();

10. Click the OK button.

The Action Script dialog box closes and the Animation Links dialog box redisplays.

11. Click the OK button.

The Animation Links dialog box closes and your script is saved.

HMI Appl icat ions

D-8 PowerNet Sof tware Vers ion 3 .20 and Greater

12. Repeat steps 7-11 to configure each of the other three buttons you created in the form for

your MainScreen window.

Note

The Action Script dialog box may display script from the last-scripted button. If so, be sure to delete or

edit this script to suit the button you are currently designing.

Setting the Window Loading Property

InTouch window loading properties include a setting that would prevent your application

from being saved in RAM memory when you close it and force it to be loaded from a disk at

each startup.

To ensure that your application can be started without a disk, complete the following steps.

1. With the form for your MainScreen window open in WindowMaker, select

Configure from the Special menu and, from the submenu that pops up, select

WindowViewer.

The WindowViewer Properties dialog box displays.

2. Uncheck the Always load windows from disk checkbox.

3. Click the OK button.

The WindowViewer Properties dialog box closes.

Testing Your Application

To test your application, click Runtime on the menu bar. (It's at the far right of your screen.)

Your application starts in runtime mode and the Runtime menu option toggles to read

Development.

To return to the InTouch development environment to edit your application, click

Development on the menu bar.

Integrating ICONICS Genesis32 Software with PowerNet Software

This section discusses the capabilities of ICONICS Genesis32 software when it is integrated

with PowerNet Software and provides an example of the application script you will need to

compose in order to integrate the two of them.

PowerNet OPC Interface

ICONICS Genesis32 most often receives information through PowerNet OPC Server. OPC

Server must first be running on a computer before information can be viewed from the

PowerNet network through ICONICS Genesis32 software. If you cannot guarantee that a user

will first start OPC Server before starting ICONICS Genesis32, it is recommended that you

place OPC Server in your startup script within ICONICS.

Sample ICONICS Graphic

Included on your PowerNet CD in the Graphics folder is a sample ICONICS Genesis32

graphics screen. This graphics screen includes buttons for most of the ActiveX control

functions enabled by the CHWrapActiveX control and, thus, can be used as an example in

the creation of your own screens.

Setting Up the PowerNet Monitor ActiveX Control in ICONICS Genesis32

You can install the Monitor ActiveX control that came with your purchase of PowerNet using

the ICONICS Genesis32 suite of applications.

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-9

Note

This documentation limits itself to providing only the most basic information about ICONICS

Genesis32, the information necessary to integrate it with PowerNet. For detailed documentation and for

updates about Genesis32, you should refer to ICONICS's own web site, users' manuals, and on-line

help.

The following tasks are involved in installing your PowerNet ActiveX control:

♦ creating blank ActiveX.gdf, Startup.gdf, and any other .gdf files using ICONICS's

GraphWorX32 application,

♦ adding PowerNet script to the ActiveX.gdf file,

♦ adding PowerNet script to the Startup.gdf file,

♦ adding PowerNet script to any other .gdf files you want to create,

♦ creating a .ini file documenting the DeviceServers referred to in your script,

♦ creating control buttons with specific parameters using GraphWorX32, and

♦ testing the buttons you create.

The following sections detail the steps necessary to accomplish these various tasks.

Creating the ActiveX.gdf and the Startup.gdf Files

To create blank ActiveX.gdf and Startup.gdf files for scripting, complete the following steps.

1. From the Programs group on your Start menu, select ICONICS Genesis32 and,

from the submenu that pops up, ScriptWorX32.

The ScriptWorX32 application starts and displays its main window.

2. Minimize the ScriptWorX32 main window to your task bar.

Note

You will not do anything in the ScriptWorX32 application window; but it must be running in the

background in order for what you do below to work.

3. From the Programs group on your Start menu, select ICONICS Genesis—32 and,

from the submenus that pop up, GraphWorX32 and (again) GraphWorX32.

The GraphWorX32 application starts and displays its main window open to a blank

document.

4. To create the first empty gdf file that you will script later, select Save as from the File

menu.

The Save as dialog box displays.

5. In the Save in field, create or select the directory in which you want to save the file you

will create. Then, in the Filename field, type ActiveX.gdf and click the Save button.

GraphWorX32 saves the empty gdf file.

6. To create the second empty gdf file that you will script later, select Save as from the

File menu again.

The Save as dialog box displays.

7. In the Save in field, create or select the directory in which you want to save the file you

will create. Then, in the Filename field, type Startup.gdf and click the Save button.

GraphWorX32 saves the empty gdf file.

You are now ready to script the ActiveX.gdf file.

HMI Appl icat ions

D-10 PowerNet Sof tware Vers ion 3 .20 and Greater

Scripting the ActiveX.gdf File

To script the ActiveX.gdf file, complete the following steps.

1. In the main window of GraphWorX32, select Open from the File menu.

The Open dialog box displays.

2. Browse to the directory containing the ActiveX.gdf file, then select and open the file.

GraphWorX32 opens the file.

3. To display the first active object, select Insert New Object from the Edit menu.

The Insert Object dialog box displays.

4. In the Insert Object dialog box, select CHWrapActiveXControl from the scrollable list

of objects and select the Create Control radio button.

5. Click OK.

The active object displays in the main window.

6. Right-click on the active object.

A pop-up menu displays.

7. From the pop-up menu, select Application Property Inspector.

The Property Inspector dialog box displays.

8. Click in the Object Name field and type CHWrapActiveX1.

Important

Case matters: the object name must be typed exactly as shown above.

9. Click the Apply button.

10. Click the OK button.

The Property Inspector dialog box closes.

11. From the Tools menu, select Macros and, from the submenu that pops up, Visual Basic Editor.

The Visual Basic Editor displays.

12. From the Tools menu in Visual Basic Editor, select References.

The References—Project dialog box displays.

13. Scroll through the Available references list and select the ICONICS ScriptWorx32 6.1 checkbox.

14. Click the OK button.

The References—Project dialog box closes.

15. In the Project Explorer window, select ThisDisplay(GwxDisplay).

The ThisDisplay(code) window displays.

16. In the code text box, type the following script, which sets up references for the ActiveX

control.

Note

A text file containing all the code for scripting the PowerNet ActiveX control in ICONICS is available

on your PowerNet CD in the Graphics directory. You can scroll through the file, spot the heading

identifying the following code, then copy and paste it directly into the code text box.

Dim swx As ScriptWorX32.Application

Private Sub GwxDisplay_DisplayLoad()

' Register yourself in ScriptWorX32!

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-11

' So other GWX instances will have reference to this display

Set swx = New ScriptWorX32.Application

If swx Is Nothing Then

MsgBox "Registration of Global display failed!"

Exit Sub

End If

' create global reference to this instance if not there yet

If Not swx.VariableExists("GwxInstance") Then

swx.CreateVariable ("GwxInstance")

End If

' set the global reference to point to ThisDisplay

Call swx.SetVariable("GwxInstance", ThisDisplay)

End Sub

Private Sub GwxDisplay_DisplayUnload()

'Now it is time to remove the reference to global display

' from ScriptWorX application

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

swx.DestroyVariable ("GwxInstance")

' From now on, any other GWX instances won't have a chance to access

' global display because it was remove (reference destroyed)

End Sub

Private Sub GwxDisplay_PostRuntimeStart()

ThisDisplay.CHWrapActiveX1.ActiveXStartApplication

End Sub

Private Sub GwxDisplay_PostRuntimeStop()

ThisDisplay.CHWrapActiveX1.ActiveXEnd

End Sub

17. From the File menu, select Close and Return to Gwx32.

The main window of GraphWorX32 displays.

18. From the File menu, select Save.

GraphWorX32 saves the script you have entered thus far.

You are now ready to script the Startup.gdf file.

HMI Appl icat ions

D-12 PowerNet Sof tware Vers ion 3 .20 and Greater

Scripting the Startup.gdf File

To script the Startup.gdf file, complete the following steps.

Note

For any other .gdf files you create, you can copy the script from Startup.gdf as long as you delete the

PostRunTimeStart subroutine—the first half of the script in step 14 below. The simplest way to create a

new .gdf file is, thus, to open the Startup.gdf file, click Save as, give it a new name, and click Save;

then delete the unwanted subroutine from the new file.

1. In the main window of GraphWorX32, select Open from the File menu.

The Open dialog box displays.

2. Browse to the directory containing the Startup.gdf file, then select and open the file.

GraphWorX32 opens the file.

3. From the Tools menu, select Macros and, from the submenu that popus up, Visual Basic Editor.

The Visual Basic Editor displays.

4. From the Tools menu in Visual Basic Editor, select References.

The References—Project dialog box displays.

5. Scroll through the Available references list and select the ICONICS ScriptWorX32 6.1 checkbox.

6. Still in the References—Project dialog box, click the Browse button.

The Browse dialog box displays.

7. Browse to your PowerNet directory.

8. Click the arrow at the right of the Files of Type field.

9. Scroll to and select the type ActiveX Controls (*.ocx).

10. From the displayed files, select CHWrapActiveX.ocx.

11. Click the Open button.

The .ocx file is inserted into the Available references list in the References—Project

dialog box. Its checkbox is automatically selected.

12. Click the OK button.

The References—Project dialog box closes.

Important

The process of finding and selecting the CHWrapActiveX.ocx file described in steps 6 through 12 is

necessary when creating the Startup.gdf file and any other .gdf files you create. It is only unnecessary

when creating the ActiveX.gdf.

13. In the Project Explorer window, select ThisDisplay(GwxDisplay).

The ThisDisplay(code) window displays.

14. In the code text box, type the following script, which controls the ActiveX.gdf display.

Note

A text file containing all the code for scripting the PowerNet ActiveX control in ICONICS is available

on your PowerNet CD in the Graphics directory. You can scroll through the file, spot the heading

identifying the following code, then copy and paste it directly into the code text box.

Dim swx As ScriptWorX32.Application

Dim gwx As Gwx32.GwxDisplay

'This should be on the main display and starts everything at Runtime

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-13

'Therefore, delete this function for any subsequent displays you create

Private Sub GwxDisplay_PostRuntimeStart()

'Create gwx for the ActiveX.gdf

Set gwx = New Gwx32.GwxDisplay

gwx.ShowWindow

'Create New instance of GraphWorX

gwx.FileNew

'Opens up the window with all CH ActiveX

If Not gwx.FileOpen("C:\Graphics\ActiveX.gdf") Then

MsgBox "Failed to open .gdf file"

End If

'Create instance in ScriptWorx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

'Get the instance of the ActiveX control window

Set gwx = swx.GetVariable("GwxInstance")

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

gwx.ToggleRuntime

'Put the ActiveX.gdf into runtime to start the ActiveX

End If

End Sub

'This should be on every display in the Application and stops everything after runtime

Private Sub GwxDisplay_PostRuntimeStop()

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'This ends background instance of Graphics.

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

'Closes ActiveX.gdf

gwx.CloseWindow

HMI Appl icat ions

D-14 PowerNet Sof tware Vers ion 3 .20 and Greater

End If

End Sub

15. From the Insert menu, select Module.

A new module is added to the Project Explorer.

16. Right-click the Module in the Project Explorer.

17. From the View menu, select Properties Window.

The Properties—Module window displays below the Project Explorer.

18. In the Name field, type the name ActiveX.

19. Press the Enter key to establish the name.

20. In the code text box, type the following script, which makes calls on the ActiveX control

in the ActiveX.gdf display.

Important

In order for all functions to work, this module must include all of the following script.

Note

A text file containing all the code for scripting the PowerNet ActiveX control in ICONICS is available

on your PowerNet CD in the Graphics directory. You can scroll through the file, spot the heading

identifying the following code, then copy and paste it directly into the code text box.

Declare Function GetPrivateProfileString Lib "kernel32" _

Alias "GetPrivateProfileStringA" _

(ByVal lpSectionName As String, _

ByVal lpKeyName As Any, ByVal lpDefault As String, _

ByVal lpReturnedString As String, _

ByVal nSize As Long, _

ByVal lpFileName As String) As Long

'Used to get the DeviceServers configured from DeviceServer.ini

Dim Device_Number 'Device Number

Dim DeviceServer 'DeviceServer number

Dim IP As String 'IP address

Dim nSize As Long 'Size

Dim retVal As Long 'Return value for showing Devices

Dim Username As String 'Username for login

Dim Password As String 'Password for login

Dim Seconds As Integer 'Seconds for AutoReconnect

Dim YesNo As String 'Variable for Setting AutoLogOff

Dim swx As ScriptWorX32.Application

Dim gwx As Gwx32.GwxDisplay

'ActiveX VBA code to access "ActiveXShowDevice" ActiveX

Sub ShowDevice(Device_Number, DeviceServer)

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-15

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Depending on the DeviceServer, open the appropriate device

Dim TempDS As String

TempDS = Format(DeviceServer) 'Turn Integer into String with no spaces

nSize = 256 'Size for IP

IP = Space(nSize) 'Empty space for IP address of DeviceServer

retVal = GetPrivateProfileString("DeviceServers", TempDS, "-1", IP, nSize, "c:\Graphics\DeviceServer.ini")

If retVal = -1 Then 'If default value, no DeviceServers exist

MsgBox "DeviceServer.ini has no DeviceServers configured!"

Else

Call ch.ActiveXShowDevice(IP, Device_Number)

End If

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXShowDeviceMinMax" ActiveX

Sub ShowDeviceMinMax(Device_Number, DeviceServer)

'Creates GwxInstance in Scriptworx

HMI Appl icat ions

D-16 PowerNet Sof tware Vers ion 3 .20 and Greater

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Depending on the DeviceServer, open the appropriate device

Dim TempDS As String

TempDS = Format(DeviceServer) 'Turn Integer into String with no spaces

nSize = 256 'Size for IP

IP = Space(nSize) 'Empty space for IP address of DeviceServer

retVal = GetPrivateProfileString("DeviceServers", TempDS, "-1", IP, nSize, "c:\Graphics\DeviceServer.ini")

If retVal = -1 Then 'If default value, no DeviceServers exist

MsgBox "DeviceServer.ini has no DeviceServers configured!"

Else

Call ch.ActiveXShowDeviceMinMax(IP, Device_Number)

End If

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXLogOn" ActiveX

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-17

Sub LogOn()

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Show LogOn dialog

Call ch.ActiveXLogOn

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXLogOff" ActiveX

Sub LogOff()

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

HMI Appl icat ions

D-18 PowerNet Sof tware Vers ion 3 .20 and Greater

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'LogOff

Call ch.ActiveXLogOff

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXLogOnEx" ActiveX

Sub LogOnEx(Username, Password)

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-19

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Log On with given username and password

Call ch.ActiveXLogOnEx(Username, Password)

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXSetAutoReconnect" ActiveX

Sub SetAutoReconnect(Seconds)

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Set the number of seconds for auto reconnect

HMI Appl icat ions

D-20 PowerNet Sof tware Vers ion 3 .20 and Greater

Call ch.ActiveXSetAutoReconnectTime(Seconds)

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXAutoLogOff" ActiveX

Sub SetAutoLogOff(YesNo)

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Set Auto Logoff to be true or false

If UCase(YesNo) = "Y" Then

Call ch.ActiveXSetAutoLogoff(1)

ElseIf UCase(YesNo) = "N" Then

Call ch.ActiveXSetAutoLogoff(0)

Else

MsgBox "You did not enter a proper value!"

End If

End If

End If

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-21

End If

End Sub

'ActiveX VBA code to access "ActiveXShow" ActiveX

Sub ManualReconnect(IP)

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Manually reconnect to given IP

Dim lret As Long

lret = ch.ActiveXShow(IP)

If lret = 0 Then

MsgBox "Failed to connect to DeviceServer!"

ElseIf lret = 1 Then

MsgBox "DeviceServer is still connected!"

ElseIf lret = -1 Then

MsgBox "A DeviceServer or IP address was not found!"

Else

MsgBox "Successfully connected"

End If

HMI Appl icat ions

D-22 PowerNet Sof tware Vers ion 3 .20 and Greater

End If

End If

End If

End Sub

'ActiveX VBA code to access "ActiveXIsAutoLogOffSet" ActiveX

Sub IsAutoLogOffSet()

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Check if AutoLogOff is set

Dim lret As Boolean

lret = ch.ActiveXIsAutoLogoffSet

If lret Then 'If return value is not 0

MsgBox "Auto-Logoff is enabled"

Else

MsgBox "Auto-Logoff is disabled"

End If

End If

End If

End If

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-23

End Sub

'ActiveX VBA code to access "ActiveXIsViewOnly" ActiveX

Sub IsViewOnly()

'Creates GwxInstance in Scriptworx

If swx Is Nothing Then

Set swx = New ScriptWorX32.Application

End If

If swx Is Nothing Then Exit Sub

If Not swx.VariableExists("GwxInstance") Then Exit Sub

Set gwx = swx.GetVariable("GwxInstance")

'Get the instance of the ActiveX window

If gwx Is Nothing Then

MsgBox "Error! Couldn't get reference to gwx!"

Else

Dim obj As Gwx32.GwxOleObject 'Create the object

Set obj = gwx.GetVisibleObjectFromName("CHWrapActiveX1")

If obj Is Nothing Then

MsgBox "Couldn't find CHWrap in display!"

Else

'Get the ActiveX object local on the display

Dim CHWrap As CHWRAPACTIVEXLib.CHWrapActiveX

Dim ch As Object

'Refer CHWrap to ch

Set ch = obj.GetOLEObject

If ch Is Nothing Then

MsgBox "Couldn't access CHWrap directly!"

Else 'Check if View-Only or not (logged in)

Dim lret As Boolean

lret = ch.ActiveXIsViewOnly

If lret Then 'If return value is not 0

MsgBox "You have View-Only privileges"

Else

MsgBox "You have all privileges"

End If

End If

End If

End If

End Sub

21. From the Insert menu, select Module.

A new module is added to the Project Explorer.

HMI Appl icat ions

D-24 PowerNet Sof tware Vers ion 3 .20 and Greater

22. Right-click the new Module in the Project Explorer window.

23. From the View menu, select Properties Window.

The Properties—Module window displays.

24. In the Name field, type the name GwxDS_Main.

25. Press the Enter key to establish the name.

26. In the code text box, type the following script, which sends device information to the

ActiveX wrapper.

Note

A text file containing all the code for scripting the PowerNet ActiveX control in ICONICS is available

on your PowerNet CD in the Graphics directory. You can scroll through the file, spot the heading

identifying the following code, then copy and paste it directly into the code text box.

Dim Device_Number

Dim DeviceServer

Dim CallType As String

' All functions and subroutines related to the subroutine DS should

' reside in this module or in modules GwxDS_<CustomName>.

Sub DS(o As GwxPick)

If o Is Nothing Then Exit Sub ' Return if input object is not valid

Dim strParameters As String

' Copy parameters from UserCustomData to strParameters

strParameters = o.UserCustomData

'Get the type of function called

CallType = GwxTools.GetParameterByIndex(strParameters, 2)

'Check to see if the type is LogOnEx

If UCase(CallType) = "LOGONEX" Then

Dim pass As String

Dim user As String

'Get the username and password parameters

user = GwxTools.GetParameterByIndex(strParameters, 0)

pass = GwxTools.GetParameterByIndex(strParameters, 1)

Call LogOnEx(user, pass)

ElseIf UCase(CallType) = "LOGON" Then

Call LogOn

ElseIf UCase(CallType) = "LOGOFF" Then

Call LogOff

Else

'Get Device Number and DeviceServer index parameters (Val changes the string to int

Device_Number = Val(GwxTools.GetParameterByIndex(strParameters, 0))

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-25

DeviceServer = Val(GwxTools.GetParameterByIndex(strParameters, 1))

If UCase(CallType) = "SHOWDEVICE" Then

'ShowDevice function

Call ShowDevice(Device_Number, DeviceServer)

ElseIf UCase(CallType) = "SHOWMIN/MAX" Then

'ShowDeviceMinMax function

Call ShowDeviceMinMax(Device_Number, DeviceServer)

ElseIf UCase(CallType) = "SETAUTORECON" Then

Dim Seconds As Long

'Get seconds input from user

Seconds = InputBox("Enter a value for the seconds between 30 and 300 (disable is 0):", "Set Auto-Reconnect", "60")

'SetAutoReconnect function

If Val(Seconds) = 0 Or (Val(Seconds) >= 30 And Val(Seconds) <= 300) Then

Call SetAutoReconnect(Seconds)

ElseIf Val(Seconds) > 300 Or (Val(Seconds) > 0 And Val(Seconds) < 30) Or Val(Seconds) < 0 Then

MsgBox "Invalid Value!"

End If

ElseIf UCase(CallType) = "SETAUTOLOGOFF" Then

Dim YesNo As String

'Get input from user

YesNo = InputBox("Type Y to enable Auto-LogOff, N to disable:", "Set Auto-LogOff", "Y")

'SetAutoLogOff function

If UCase(YesNo) = "N" Or UCase(YesNo) = "Y" Then

Call SetAutoLogOff(YesNo)

Else

MsgBox "Invalid Value!"

End If

ElseIf UCase(CallType) = "DOMANUAL" Then

Dim IP As String

'Get IP Address input from user

IP = InputBox("Type in the IP address of the DeviceServer you wish to manually reconnect to:", "Manual Reconnect")

'ManualReconnect function

Call ManualReconnect(IP)

ElseIf UCase(CallType) = "ISAUTOLOGOFF" Then

'IsAutoLogOffSet function

Call IsAutoLogOffSet

ElseIf UCase(CallType) = "ISVIEWONLY" Then

'IsViewOnly function

Call IsViewOnly

Else

HMI Appl icat ions

D-26 PowerNet Sof tware Vers ion 3 .20 and Greater

'Problem!

MsgBox "Illegal Parameter!"

End If

End If

End Sub

27. From the Insert menu, select Module.

A new module is added to the Project Explorer.

28. Right-click the new Module in the Project Explorer window.

29. From the View menu, select Properties Window.

The Properties—Module window displays.

30. In the Name field, type the name GwxTools.

31. Press the Enter key to establish the name.

32. In the code text box, type the following script, which sends device number information to

the ActiveX.gdf display.

Note

A text file containing all the code for scripting the PowerNet ActiveX control in ICONICS is available

on your PowerNet CD in the Graphics directory. You can scroll through the file, spot the heading

identifying the following code, then copy and paste it directly into the code text box.

'-------------------------------------------------------------------------------

' GraphWorX32 public routines to parse and compose parameters from/to CustomData

' (Inserted automatically by Script Wizard when necessary)

'-------------------------------------------------------------------------------

' Get parameters from CustomData in one string. We assume the parameters

' are in following format: "... Parameters=<custom_parameters> ..."

Function GetParametersFromCustomData(ByRef strCustomData As String) As String

Dim posBeg As Integer, posEnd As Integer, retVal As String

retVal = ""

posBeg = InStr(1, strCustomData, "Parameters", vbTextCompare)

If posBeg > 0 Then

posBeg = InStr(posBeg, strCustomData, "<", vbTextCompare)

If posBeg > 0 Then

posEnd = InStr(posBeg, strCustomData, ">", vbTextCompare)

If posEnd > posBeg Then

retVal = Right(strCustomData, Len(strCustomData) - posBeg)

retVal = Left(retVal, posEnd - posBeg - 1)

End If

End If

End If

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-27

GetParametersFromCustomData = retVal

End Function

' Compose new CustomData from given parameters and return as a string.

' This string can be used to assign new value to UserCustomData property.

Function GetCustomDataFromParameters(ByRef strCustomData As String, _

ByRef strParameters As String) As String

Dim posBeg As Integer, posEnd As Integer, strOut As String

posBeg = InStr(1, strCustomData, "Parameters", vbTextCompare)

If posBeg > 0 Then

posBeg = InStr(posBeg, strCustomData, "<", vbTextCompare)

If posBeg > 0 Then

posEnd = InStr(posBeg, strCustomData, ">", vbTextCompare)

If posEnd > posBeg Then

strOut = Left(strCustomData, posBeg)

strOut = strOut + strParameters

strOut = strOut + Right(strCustomData, Len(strCustomData) - posEnd + 1)

strCustomData = strOut

End If

End If

End If

GetCustomDataFromParameters = strCustomData

End Function

' Giving a string with all parameters, return number of parameters

' The delimitier is <space><comma>: ', '

Function GetNumberOfParameters(ByRef strParameters As String) As Integer

Dim n As Integer, pos As Integer, strDelimit As String

If Len(strParameters) = 0 Then GetNumberOfParameters = 0 ' return

strDelimit = ", "

n = 1

pos = 0

Do

pos = InStr(pos + 1, strParameters, strDelimit, vbTextCompare)

If pos > 0 Then n = n + 1

Loop While pos > 0

GetNumberOfParameters = n

HMI Appl icat ions

D-28 PowerNet Sof tware Vers ion 3 .20 and Greater

End Function

' From a string with all parameters return a parameter on given position.

Function GetParameterByIndex(ByVal strParameters As String, index As Integer) As String

Dim i As Integer, n As Integer, pos As Integer, strDelimit As String

Dim lenDelimit As Integer

If Len(strParameters) = 0 Then GetParameterByIndex = Empty ' return

strDelimit = ", "

lenDelimit = Len(strDelimit)

pos = 0

' Find begin of the parameter

While i < index

i = i + 1

pos = InStr(1, strParameters, strDelimit, vbTextCompare)

If pos > 0 Then

strParameters = Right(strParameters, Len(strParameters) - pos - 1)

Else

GetParameterByIndex = strParameters ' return

End If

Wend

' find end of the parameter

pos = InStr(1, strParameters, strDelimit, vbTextCompare)

If pos > 0 Then

GetParameterByIndex = Left(strParameters, pos - 1) ' return

Else

GetParameterByIndex = strParameters ' return

End If

End Function

33. From the File menu, select Close and Return to Gwx32.

The main (blank) window of GraphWorX32 displays.

34. From the File menu, select Save.

GraphWorX32 saves your script.

You are now ready to script other .gdf files or create the DeviceServer .ini file.

Scripting Other .GDF Files

For any other .gdf files you want to create besides the ActiveX.gdf and the Startup.gdf, you

can copy the script from Startup.gdf as long as you delete the PostRunTimeStart subroutine—

the first half of the script in step 14 of the previous section, Scripting the Startup.gdf File.

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-29

The simplest way to create a new .gdf file is to complete the following steps.

1. Script the Startup.gdf file, following the steps in Scripting the Startup.gdf File.

2. With the Startup.gdf file open in GraphWorX32, click Save as.

The Save as dialog box displays.

3. Use the Save in field's drop-down arrow to browse to and select the directory in which

you want to save the new .gdf file.

4. Enter a new name for the new .gdf file in the File name field.

5. Click the Save button.

6. From the Tools menu, select Macros and, from the submenu that pops up, Visual Basic Editor.

The Visual Basic Editor displays.

7. In the code text box, find and delete the PostRunTimeStart subroutine from the new

file.

8. Make any other changes you want to the .gdf file (e.g., add new buttons and/or graphics).

9. Save your changes.

You are now ready to create the DeviceServer .ini file.

Creating the DeviceServer.ini File

You need to create a .ini file documenting the DeviceServers referred to in your script for the

PowerNet ActiveX control.

To create the DeviceServer.ini file, complete the following steps.

1. Open Windows Explorer and C:\Graphics.

2. From the File menu, select New and then Text document.

A new file displays in Explorer with a generic name already entered and selected.

3. Type the new file name DeviceServer.ini and press the Enter key.

The new file is created.

4. Double-click the DeviceServer.ini file in Explorer.

The file opens in Microsoft Notepad.

5. Type the numbers and IP addresses of the DeviceServers you want to control using

PowerNet's ActiveX control in the following format.

Note

The IP addresses below are just for example, so replace them with those of your own DeviceServers.

But do observe the line breaks and lack of spaces in this example in your own .ini file.

[DeviceServers]

1=166.99.29.181

2=166.99.29.9

3=166.99.29.106

6. From the File menu, select Save, then close the file and the text editor by clicking the X

icon in the window's upper right corner.

You are now ready to create control buttons.

Creating a Control Button (All the Steps)

To draw and set parameters for a control button, complete the following steps.

1. Using the GraphWorX32 button interface, draw a button.

HMI Appl icat ions

D-30 PowerNet Sof tware Vers ion 3 .20 and Greater

A button displays; and the Property Inspector dialog box displays over top of the button.

2. From the Action drop-down menu in the Property Inspector dialog box, select Run VBA Script.

3. In the Script Name field in the Property Inspector dialog box, type

GwxDS_Main.DS.

4. In the Custom Data field in the Property Inspector dialog box, enter the parameters

for this button in the following format: P1, P2, CallType. Replace P1, P2, and

CallType with the appropriate parameters. For the list of parameters for each function

call, see the next section, Creating a Control Button (Control-Specific Parameters).

Important

Case does not matter in the Custom Data field. Spacing, however, does matter: be sure to include one

space after each comma.

5. Click the Apply button.

6. Click the OK button.

The Property Inspector dialog box closes. Your new button control is ready for use.

7. Repeat steps 1 through 6 for each control button function you wish to create.

You are now ready to test your control button(s).

Creating a Control Button (Control-Specific Parameters)

ICONICS's GraphWorX32 program uses a field of parameters to specify which devices,

DeviceServers, and control functions are associated with each button control that you create.

You enter these parameters in the Custom Data field within the Property Inspector

dialog box of GraphWorX32.

For steps detailing how to create a button in GraphWorX32 and its Property Inspector dialog

box, see the previous section, Creating a Control Button (All the Steps).

The standard formula is P1, P2, CallType.

Important

Case does not matter in the Custom Data field. Spacing, however, does matter: be sure to include one

space after each comma.

In the following table, italics indicate a variable (user name, password, device number, or

DeviceServer number) that you should fill in based on what you have set it to be in PowerNet.

NR designates parameters that are not read by the program: if you prefer, you can enter a zero

or some other character(s) here; but you must enter something as a placeholder.

Note

Two function calls—the ActiveXStartApplication and the ActiveXEnd—are not mentioned in this

table, because they are not themselves button controls but calls included in the script at the very start

and end of your application.

Function Call Parameters Statement for the Custom Data Field

ActiveXIsAutoLogoffSet NR, NR, IsAutoLogOff

ActiveXIsViewOnly NR, NR, IsViewOnly

ActiveXLogOff NR, NR, LogOff

ActiveXLogOn NR, NR, LogOn

ActiveXLogOnEx Username, Password, LogOnEx

HMI Appl icat ions

PowerNet Sof tware Vers ion 3 .20 and Greater D-31

Function Call Parameters Statement for the Custom Data Field

ActiveXSetAutoLogoff NR, NR, SetAutoLogoff

ActiveXShowDevice Device#, DeviceServer#, ShowDevice

ActiveXShowDeviceMinMax Device#, DeviceServer#, ShowMin/Max

ActiveXShow NR, NR, DoManual

ActiveXSetAutoReconnectTime NR, NR, SetAutoRecon

Testing A Control Button

To test a PowerNet ActiveX control that you have created using ICONICS software, complete

the following steps.

1. Redisplay the ScriptWorX32 window. (This is the window that you opened and then

minimized at the beginning of the button-creation process.)

2. On the menu bar, click Runtime.

The Save as dialog box displays.

3. Save the configuration, giving it any name and putting it in whichever directory you

prefer.

4. Minimize the ScriptWorX32 window again.

5. Back in GraphWorX32, in the Startup.gdf window, click Runtime on the menu bar.

The ActiveX control should start; and clicking your newly created buttons should call the

proper function to access the ActiveX control.