Вы находитесь на странице: 1из 9

Contents Page

Training aims ...................................................................................................................................... 2


Global Script editors ............................................................................................................................ 3
Global Script C editor .......................................................................................................................... 4
Global Script C editor Example of a function ...................................................................................... 5
Global Script C editor Example of an action ....................................................................................... 6
Global Script VBS editor Example of a function .................................................................................. 7
Global Script VBS editor Example of an action ................................................................................... 8
Exercise 1 (optional): Global Script .................................................................................................... 9

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 1 Global Script
The participant will:

Get to know the differences between the various types of function


Be able to create simple functions
Be able to create actions for background processing

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 2 Global Script
General Global Script is a generic term for functions and actions with ANSI-C and VBS.
A separate editor exists for each of the two programming languages.

Actions are scripts that run in the background and that are independent of the
currently selected picture. With actions, a trigger therefore needs to be defined.

Many functions are made available as soon as WinCC is installed. With the
Global Script editors, however, you can write your own functions. Functions
contain tasks that are repeated, for example calculating a mean value. These
functions are then called in other scripts. For this reason, no trigger can be defined
here.
In the figure above, you can see two simple functions for the addition of 2 values.

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 3 Global Script
Password Self-created functions or actions can be given a password to protect your own
know-how. The entry of the password is made in the Info/Trigger box (ctrl + I or
click on the clock symbol).

Actions For the actions, there are two subfolders in the figure above. One folder with the
computer name of the single-user station and "Global actions". With WinCC
server-client configurations, there is one folder per computer. This means it is
possible to specify for an action that it should, for example, only run on a specific
computer.

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 4 Global Script
Creation In the Global Script C editor, you can create your own functions. The example
above has two parameters "a" and "b", both are of the type integer. The function
has a return value also of the type integer:
int Add_Function(int a, int b)
If the function did not have a return value, the first line would appear as follows:
void FunctionXYZ(int a, int b)
With the return command, the result is returned to the calling location.

Use The function can be called up in pictures or global C actions.

In the example above, the call is at an I/O field in a picture.

Copying functions between WinCC projects


Project functions are stored in the "Library" subfolder of the WinCC project with the
file extension *.fct. Similar to the pictures, they can be copied from one WinCC
project to another. In this case, the function "Options/Regenerate Header" must be
called in the target project in the Global Script C editor. Only after this are the
copied functions visible in the editor.

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 5 Global Script
Global action In the example above, a variable is incremented to 100 depending on the WinCC
tag SimOnOff, the value then jumps back to zero.

Since the trigger is fixed at one second, this action is started every second. In this
case this is wanted and a tag trigger cannot be used here.

Computer properties
When global actions need to be started, the component "Global Script Runtime"
must be activated in the computer properties.

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 6 Global Script
Project modules
Here, configuration engineers themselves can create new functions.
Several functions can be contained in one module. The module
VBS_Module1.bmo is located in the subfolder "ScriptLib" of the WinCC project.
Standard modules
Once again, the configuration engineer can create new functions here. In contrast
to project functions, cross-project standard procedures are available in all the
projects located on the PC.
Several functions can be contained in one module.

Actions See following page

Code templates As in the VBS editor in the Graphics Designer

Example of a function The function above calculates the sum of the transferred parameters.

With the line "MyAddFunction = value1 + value2 the sum is returned to the calling
location.

Sub or Function Sub name1(Item) Function procedure1



End Sub End Function
-> without return value -> with return value

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 7 Global Script
Actions: VB scripts that can run independently in the background of WinCC Runtime.
The file extension for VB actions is *.bac. These files are located in the subfolder
"ScriptAct" of the WinCC project.

Computer properties
When global actions need to be started, the component "Global Script Runtime"
must be activated in the computer properties.

SITRAIN Training for ST-BWINCCS


Automation and Industrial Solutions Page 8 Global Script
SITRAIN Training for ST-BWINCCS
Automation and Industrial Solutions Page 9 Global Script

Вам также может понравиться