Назад
4.4.7.2 D-I............................................................................................................................................1841
4.4.7.3 L-Q...........................................................................................................................................1889
4.4.7.4 R-Z...........................................................................................................................................1939
4.4.8 Properties................................................................................................................................1995
4.4.8.1 A..............................................................................................................................................1995
4.4.8.2 B..............................................................................................................................................2016
4.4.8.3 C..............................................................................................................................................2053
4.4.8.4 D..............................................................................................................................................2089
4.4.8.5 E..............................................................................................................................................2096
4.4.8.6 F..............................................................................................................................................2104
4.4.8.7 G-H..........................................................................................................................................2134
4.4.8.8 I - K..........................................................................................................................................2144
4.4.8.9 L...............................................................................................................................................2157
4.4.8.10 M..............................................................................................................................................2206
4.4.8.11 N-O..........................................................................................................................................2228
4.4.8.12 P-Q..........................................................................................................................................2241
4.4.8.13 R..............................................................................................................................................2268
4.4.8.14 S..............................................................................................................................................2276
4.4.8.15 T..............................................................................................................................................2299
4.4.8.16 U..............................................................................................................................................2324
4.4.8.17 V..............................................................................................................................................2331
4.4.8.18 W - Z........................................................................................................................................2406
4.5 AddIns.....................................................................................................................................2414
4.5.1 AddIns.....................................................................................................................................2414
4.5.2 Linking Add Ins........................................................................................................................2415
4.5.3 Loading an Addin in the Graphics Designer............................................................................2417
4.5.4 Example: Creating Add Ins......................................................................................................2418
4.5.4.1 Example: Creating Add Ins......................................................................................................2418
4.5.4.2 Example: Creating an Add In with Visual Basic 6.0.................................................................2419
4.6 VBA in Other WinCC Editors...................................................................................................2424
4.6.1 VBA in Other WinCC Editors...................................................................................................2424
4.6.2 VBA in Tag Management........................................................................................................2426
4.6.2.1 VBA in Tag Management........................................................................................................2426
4.6.2.2 CloseTag Function..................................................................................................................2429
4.6.2.3 CommitTag Function...............................................................................................................2430
4.6.2.4 CreateTag Function.................................................................................................................2432
4.6.2.5 DeleteTag Function.................................................................................................................2434
4.6.2.6 GetTag Function......................................................................................................................2435
4.6.2.7 ListTag function.......................................................................................................................2436
4.6.3 VBA im Tag Logging................................................................................................................2438
4.6.3.1 VBA in Tag Logging.................................................................................................................2438
4.6.3.2 CloseTlgArchive-Funktion.......................................................................................................2442
4.6.3.3 CloseTlgTag Function.............................................................................................................2443
4.6.3.4 CommitTlgArchive Function....................................................................................................2445
4.6.3.5 CommitTlgTag Function..........................................................................................................2446
4.6.3.6 CreateTlgArchive Function......................................................................................................2448
4.6.3.7 CreateTlgTag Function............................................................................................................2451
4.6.3.8 DeleteTlgArchive Function......................................................................................................2455
4.6.3.9 DeleteTlgTag Function............................................................................................................2457
4.6.3.10 GetTlgArchive Function...........................................................................................................2458
4.6.3.11 GetTlgTag Function.................................................................................................................2459
Table of contents
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
11
4.6.3.12 ListTlgArchive Function...........................................................................................................2461
4.6.3.13 ListTlgTag Function.................................................................................................................2463
4.6.4 VBA in the Text Library............................................................................................................2465
4.6.4.1 VBA in the Text Library............................................................................................................2465
4.6.4.2 CreateTextLanguage Function................................................................................................2466
4.6.4.3 CreateText Function................................................................................................................2467
4.6.4.4 DeleteText Function................................................................................................................2468
4.6.4.5 DeleteTextLanguage Function................................................................................................2470
4.6.4.6 GetText Function.....................................................................................................................2471
4.6.4.7 GetTextID Function.................................................................................................................2473
4.6.4.8 ListText Function.....................................................................................................................2475
4.6.4.9 ModifyText Function................................................................................................................2476
4.6.5 VBA in Alarm Logging.............................................................................................................2478
4.6.5.1 VBA in Alarm Logging.............................................................................................................2478
4.6.5.2 CloseSingleAlarm Function.....................................................................................................2481
4.6.5.3 CommitSingleAlarm Function..................................................................................................2482
4.6.5.4 CreateSingleAlarm Function....................................................................................................2483
4.6.5.5 DeleteSingleAlarm Function....................................................................................................2487
4.6.5.6 GetSingleAlarm Function.........................................................................................................2488
4.6.5.7 ListSingleAlarm Function.........................................................................................................2489
Index.......................................................................................................................................................2493
Table of contents
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
12
System Manual, 11/2008,
VBS for Creating Procedures and Actions
1
1 Resources
1.1 VBS for Creating Procedures and Actions
Contents
WinCC provides the possibility of dynamizing the Runtime environment using the Visual Basic
Script. It is possible to use VBS to program global actions and procedures as well as
dynamizing graphic objects and triggering actions in Runtime.
This chapter will show you
How to work with VBScript editors
How to create and edit procedures
How to create and edit actions
How to activate VBScripts in Runtime
How to execute diagnostics on scripts in Runtime
The object model of graphic Runtime system
Detailed examples on using VBScript
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
13
1.2 Using Visual Basic Script in WinCC
Introduction
In addition to the C script, WinCC also provides the VBScript program language as a
programming interface in order to make the WinCC Runtime environment dynamic.
Target Group of the Documentation
This documentation is aimed at project engineers with experience of Visual Basic or WinCC
Scriptings (C) used to date.
Application Options
VBScript (VBS) provides access to tags and objects of the graphical Runtime system at
Runtime and can execute picture-independent functions:
Tags: Tag values can be read and written in order, for example, to specify tag values for
the PLC by clicking the mouse when positioned on a button.
Objects: Object properties can be made dynamic using actions and actions can be triggered
by events influencing objects.
Picture-independent Actions: Picture-independent actions can be triggered cyclically or
according to tag values, e.g. for the daily transfer of values into an Excel table.
VBS for Creating Procedures and Actions
1.2 Using Visual Basic Script in WinCC
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
14
System Manual, 11/2008,
VBS can be used at the following points in WinCC:
In the Global Script Editor: This is used to configure picture-independent actions and
procedures. The procedures can be used in picture-dependent and picture-independent
actions. Several procedures are compiled in a topic-related module.
In Graphics Designer: Picture-dependent actions can be configured with which the
properties of graphic objects can be made dynamic or caused to respond to events in
Runtime.
In user-defined menus and toolbars: Here you configure procedures called in Runtime using
the menu and toolbars.
Note
Updating Changed Configuration in Runtime
A changed VB script that is connected with "Menus and toolbars" is only updated after
Runtime is restarted.
If you change the properties of "Menus and toolbars" in Runtime, the changes are only
applied in the following cases:
After a picture change, if the configuration change does not affect the basic picture.
When you load another configuration file and reload the modified configuration file.
Registered Tags in Menus and Toolbars
The registered tags in the scripts of "Menus and toolbars" remain registered when you unselect
the picture. If you read indirectly from a process mapping the tags are registered and
unregistered again when you unselect the picture. However, registered tags in the scripts of
"Menus and toolbars" remain registered when you unselect the picture.
Application Scenarios
VBS can be used in Runtime, for example:
to configure setpoint value specification for tags for the operation of a graphic object in
order to define a value for the PLC by clicking a mouse, for example.
to configure switching the Runtime language for the operation of a graphic object.
to configure the change of color, e.g. cyclically (flashing) or to display statuses (motor on).
Apart from the specific WinCC applications, the general functionality of VBS can also be used
to customize the Windows environment, e.g.:
to transfer data to another application (e.g. Excel).
to start external applications from WinCC.
to create files and folders.
The automation objects in your environment are available with which to customize the Windows
environment.
VBS for Creating Procedures and Actions
1.2 Using Visual Basic Script in WinCC
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
15
Note
All the objects supplied with the Windows Script Host (WSH) from Microsoft can be integrated
in
the environment using the standard VBS method CreateObject. However, there is no direct
access to the WSH object itself using VBS from WinCC.
There is no guarantee nor WinCC support for the VBS functionality with regard to its
adaptation to the Windows environment.
Limits to Other Programming Languages in WinCC
VBS and C
VBScript can be used in WinCC parallel to C-Script, but do not mix the script types:
VBScripts and C-scripts can be configured within a picture and project.
C-scripts cannot be invoked in VBScripts and vice versa.
VBS provides internal interfaces to tags and picture objects while the C environment
enables access to other WinCC subsystems (e.g. the report system).
VBS and VBA
VBA is used in WinCC Configuration during the configuration in order to adapt Graphics
Designer to your individual requirements and to simplify and automate configuration. VBA
programs only run in the WinCC configuration environment.
As opposed to VBA, VB scripts only run in WinCC Runtime and, from there, enable access to
graphic objects and tags. Objects and pictures can be neither created nor modified on a
permanent basis in VBS, as opposed to VBA.
The main language-related differences between VBA and VBS are e.g.:
VBS was developed for use in Internet, VBA for the automation of software applications.
The data type of VBS tags is always VARIANT. VBA, on the other hand, differentiates the
individual data types such as INT, DOUBLE, STRING, etc.
Certain language constructs from VBA have been removed from or added to VBS.
Errors are handled differently in VBS compared to VBA.
A complete list of the differences between VBA and VBS is provided in the Appendix in "Basic
Principles of VBScript".
VBS for Creating Procedures and Actions
1.2 Using Visual Basic Script in WinCC
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
16
System Manual, 11/2008,
Procedures, Modules and Actions
VBS in WinCC allows the use of procedures, modules and actions to make the Runtime
environment dynamic:
Procedures: Codes are stored in procedures which are then used at several points in the
configuration. Retrieve the code or another procedure in an action by invoking the
procedure name. Procedures can be created in WinCC with or without return values.
Procedures do not have their own trigger, they are always retrieved by an action.
Modules: It is advantageous to compile related procedures to units in modules. Create
modules for procedures, for example, which must be used in a specific picture or belong
to a specific topic, such as auxiliary mathematical functions or database access functions.
Actions: Actions are always activated by a trigger, namely a triggering event. Actions are
configured
in graphic object properties, in events which occur on a graphic object or globally
in a project. Codes used several times can be called, in the form of procedures, in actions.
VBS for Creating Procedures and Actions
1.2 Using Visual Basic Script in WinCC
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
17
1.3 Modules and Procedures
Introduction
Procedures are used to make code, created only once, available at several points in a project.
Instead of entering the code several times, simply call in the corresponding procedure. The
code is clearer and easier to maintain.
Related procedures should be stored in modules. When a certain procedure is retrieved via
an action in Runtime, the module that contains that procedure is loaded. Observe the following
when structuring the modules and procedures:
The more modules that must be loaded when a picture is called in, the worse the
performance in Runtime.
The larger a module, the more procedures are contained and, thus, the longer the loading
time for the module.
Organize the modules sensibly, e.g. a module with procedures for a specific system part/
picture.
Another type of structuring of procedures in modules is the functional structuring, e.g. a module
containing
mathematical functions. Use this structure, for example, for modules which should
be used globally for projects. The following example illustrates a module containing
mathematical functions derived from the standard functions:
VBS for Creating Procedures and Actions
1.3 Modules and Procedures
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
18
System Manual, 11/2008,
Procedure Features
The procedures in WinCC have the following properties:
They are created and modified by the user.
They can be protected against modification and viewing by means of a password.
They do not have a trigger.
They are stored in a module.
WinCC does not provide predefined procedures, but does provide code templates and
Intellisense, for example, to simplify programming. Procedures differ according to module
assignment in:
Standard procedures apply globally to projects located on the computer on which they were
created.
Project procedures can only be used within the project in which they were created.
VBS for Creating Procedures and Actions
1.3 Modules and Procedures
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
19
Module Features
A module is a file in which one or procedures is stored. The modules in WinCC have the
following properties:
They can be protected against modification and viewing by means of a password.
The have the file extension *.bmo.
Modules differ according to the validity of their procedures in:
Standard Modules: Contain procedures which are globally available to the project. Standard
modules are stored in the WinCC file system under: <WinCC-Installationsverzeichnis>
\ApLib\ScriptLibStd\<Modulname>.bmo
Project Modules: Contain project-specific procedures. Project modules are stored in the
WinCC file system under: <Projektverzeichnis>\ScriptLib\<Modulname>.bmo. Since the
project
modules are stored in the project directory, they are copied when the WinCC project
is copied.
Note
If WinCC must be reinstalled and the standard procedures and modules need to be used
again,
save the module files prior to the reinstallation in a different directory and copy them
in the relevant WinCC directory after the reinstallation has been completed. Otherwise,
the standard modules in the WinCC installation directory are deleted during the installation
routine.
Using Procedures and Modules
Procedures are used in:
Actions (in Graphics Designer and Global Script)
Other procedures (in Global Script)
User-defined menus and toolbars
Procedures are structured in modules.
See also
Creating and Editing Procedures (Page 39)
VBScript Editors (Page 28)
Basic Principles of VBScript (Page 760)
Actions (Page 21)
Using Visual Basic Script in WinCC (Page 14)
VBS for Creating Procedures and Actions
1.3 Modules and Procedures
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
20
System Manual, 11/2008,