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

Background Processing (Global Script)

SITRAIN
ST-BWINCCS /GlobalScript Page 1 Siemens AG 2007

Objectives

- Project Functions

- Standard Functions

- Internal Functions

- Project-wide Actions

- Project Modules

SITRAIN
ST-BWINCCS /GlobalScript Page 2 Siemens AG 2007

1
Global Script C Actions and Functions

Output field for


- Search files
- Compile all functions

SITRAIN
ST-BWINCCS /GlobalScript Page 3 Siemens AG 2007

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
}
SITRAIN
ST-BWINCCS /GlobalScript Page 4 Siemens AG 2007

2
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

SITRAIN
ST-BWINCCS /GlobalScript Page 5 Siemens AG 2007

Example with Functions from DLLs

Counting with the DLL function

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


#pragma code (d:\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);
}

SITRAIN
ST-BWINCCS /GlobalScript Page 6 Siemens AG 2007

3
Global Script VBS Actions and Procedures 1/2

Procedures
(Function)

To be created by the user


(empty)

Output window for compiling

SITRAIN
ST-BWINCCS /GlobalScript Page 7 Siemens AG 2007

Global Script VBS Actions and Procedures 2/2

In the project
Module

Procedure A

Procedure B

Procedure C

Instruction a
Action Instruction b
Instruction 1
Instruction 2
Trigger Procedure C
.
Instruction n
Procedure D

Procedure E

SITRAIN
ST-BWINCCS /GlobalScript Page 8 Siemens AG 2007

4
Example of a VBS Project Function

.pdl

Call

SITRAIN
ST-BWINCCS /GlobalScript Page 9 Siemens AG 2007

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