You are on page 1of 12

Background Processing (Global Script)

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.1 Automation and Drives
© Siemens AG 2003. All rights reserved.
Objectives

- Project Functions
- Standard Functions

- Internal Functions

- Project-wide Actions

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.2 Automation and Drives
© Siemens AG 2003. All rights reserved.
Global Script C Actions and Functions

Project functions
Standard functions
Internal functions

Output field for:


Actions -Search files
-Compile All Functions

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.3 Automation and Drives
© Siemens AG 2003. All rights reserved.
Example of a Project Function and/or Standard Function
Switching on a motor:
Events/ Mouse/ Left mouse button/ C function...
BitSet ( 1, "MotorStatus", 2);
0 /*Bit 2 is set in the “MotorStatus” tag, to reset the
bit use: BitSet ( 0, “MotorStatus”, 2)*/

A function defined in the Global Script (Standard Functions:


void BitSet(BOOL OnOff, char* lpszWordtag, WORD wbitnumber)
{

WORD winput = 0; // Create local tags


int iscreen = 1;

winput = GetTagWord ( lpszWordtag ) ; // Read process tags


iscreen <<= ( wbitnumber ); // Create bit mask
if (OnOff == 0 ) { // Reset bit ?
winput = (WORD) ( winput & (~iscreen) ); // Reset bit
}
else {
winput = (WORD) ( winput | iscreen ); // Set bit
}
SetTagWord ( lpszWordtag, winput); // Rewrite process tag
}

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.4 Automation and Drives
© Siemens AG 2003. All rights reserved.
Internal Functions: Example of Graphics 1/3

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.5 Automation and Drives
© Siemens AG 2003. All rights reserved.
Internal Functions: Example of Graphics 2/3
20

20

Event/ Button/ Mouse/ Press left/ C-Action...


Box_mit_Pos1 (lpszPictureName, lpszObjectName,
"Bildfenster1", ”Motor.pdl");

Activate dialog box

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.6 Automation and Drives
© Siemens AG 2003. All rights reserved.
Internal Functions: Example of Graphics 3/3
Events/ Button/ Mouse/ Press left/ C action...
Box_mit_Pos2 (lpszPictureName, lpszObjectName,
Activate dialog box ”Bildfenster1", ”Motor.pdl");

You can place dialog screen windows where you want them on the screen. To establish a
reference to the operated object, it is advantageous if the dialog box appears where it
is used. You can attain this positioning with the following steps:

- Scanning the properties of the operated object and the entire screen
- Scanning the size and stretching the dialog window
- Specifying the appearance location of the dialog window (to the right or left next
to the operated object)

These functions are combined in a standard function that can then be used from
any location (each screen and operating object).

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.7 Automation and Drives
© Siemens AG 2003. All rights reserved.
Background Processing (Actions) with Global Script

Operating hours.PAS
WORD HOUR, MINUTE;
BYTE Z_ON;

Z_ON = GetTagByte ("Z_On");

if (Z_ON) {
MINUTE = GetTagWord ("Minutes");
MINUTE = MINUTE + 1;
SetTagWord ("Minutes", MINUTE);

HOUR = MINUTE / 60;


SetTagWord ("operating hours", HOUR);
}
return(HOUR);

Note: Global Script must be activated in the computer startup list

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.8 Automation and Drives
© Siemens AG 2003. All rights reserved.
Example with Functions from DLLs
Counting with the DLL function

Events/ Button/ Mouse/ Press left/ C action...


#pragma
code("c:\a_WinCC_Kurs_Prj_301_00\ab_pas\library\demo_dll.dll")
int CountingDll(int start, int end);
#pragma code()

int result, start, end, partial step;

partial step = GetTagDWord("partial step");


printf("\r\n\r\noutput of 10 partial steps with DLL function ");
printf("to max. value: %d",partial step*10);
for (start=0;start<10;start++) {
end = start * partial step + partial step;
result = countingDll(start*partial step,end);
printf("\r\nReturn value DLL function: (%d) %d",start,result);
}

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.9 Automation and Drives
© Siemens AG 2003. All rights reserved.
Global Script VBS Actions and Procedures 1/2

Procedures
(Function)

To be created by the user


(empty)

Output window for compiling

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.10 Automation and Drives
© Siemens AG 2003. All rights reserved.
Global Script VBS Actions and Procedures 2/2

In the project

Module

Procedure A
Procedure B

Procedure C
Action
Instruction 1 Instruction a
Instruction 2 Instruction b

Trigger Procedure C
….
Instruction n

Procedure D

Procedure E

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.11 Automation and Drives
© Siemens AG 2003. All rights reserved.
Example of a VBS Project Function
.pdl

Call

SIMATIC HMI Date: 04/25/21 SITRAIN Training for


File: SWINCC_09e.12 Automation and Drives
© Siemens AG 2003. All rights reserved.

You might also like