ae08 system vb_script

Post on 07-May-2015

130 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

treinamento automação siemens,supervisorio wincc

TRANSCRIPT

Date: 11.04.23File: System_VBSc_8.1

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Flexibility

Date: 11.04.23File: System_VBSc_8.2

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Flexibility with Standard Programs

Date: 11.04.23File: System_VBSc_8.3

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Overview of VBScript

Tags These can be either ProTool tags or internal (local) VBScript tagsLocal VBScript tags (defined with the Dim statement, the tag type is matched dynamically)

VBScript constants (numbers and string constants) VBScript operators (+, -, *, /, \, =, <, >, And, Or,.....) VBScript conditional statements (If...Then...Else, Select Case) VBScript looping through code

(Do...Loop, While... Wend, For...Next, For Each...Next) VBScript procedures (Sub, Function) Integrated VBScript procedures

(Date, Sin, Sqr,...)

Date: 11.04.23File: System_VBSc_8.4

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Standard Types

Format Data type

8 bits with sign CHAR, CHAR_ARRAY 8 bits without sign BYTE, BYTE_ARRAY16 bits with sign INT, INT_ARRAY16 bits without sign UINT, UINT_ARRAY32 bits with sign LONGINT, LONGINT_ARRAY32 bits floating point FLOAT, FLOAT_ARRAY64 bits floating point DOUBLE, DOUBLE_ARRAY 1 bit BOOL, BOOL_ARRAYCharacter strings STRING

Date: 11.04.23File: System_VBSc_8.5

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Procedures

Different types of procedure are used in VBScript:

Sub (subroutine) procedures do not have a return value.The syntax for a Sub procedure is as follows:

Sub procedure name (arguments)Statements (these can contain constants, tags or expressions or

an empty pair of parentheses () ).End-Sub

Every time the procedure is called, the statements between Sub and End-Sub are executed Function procedures have a return value.

The syntax of a Function procedure is as follows:Function procedure name (arguments) [PLC type]: Celsius (degrees F)Statements: Celsius = (degrees F – 32) x 5/9End Function

Like a Sub procedure, a Function procedure is a separate procedure which can contain arguments, execute statements and change the value of its arguments. Unlike a Sub procedure, a Function procedure can return a value to the procedure that called it.

Date: 11.04.23File: System_VBSc_8.6

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Limitations of VBScript 1/2

Assignment of symbolic names

Processing of multiple scripts

Date: 11.04.23File: System_VBSc_8.7

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Limitations of VBScript 2/2

No value assignment to script parameters

Date: 11.04.23File: System_VBSc_8.8

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Flexibility with VBScript (Addition)

Date: 11.04.23File: System_VBSc_8.9

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts (Without Parameters) 1/3

Date: 11.04.23File: System_VBSc_8.10

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts (Without Parameters) 2/3

Date: 11.04.23File: System_VBSc_8.11

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Graphics (Without Parameters) 3/3

Date: 11.04.23File: System_VBSc_8.12

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts (With Parameters) 1/3

Date: 11.04.23File: System_VBSc_8.13

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts (With Parameters) 2/3

Date: 11.04.23File: System_VBSc_8.14

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Graphics (With Parameters) 3/3

Date: 11.04.23File: System_VBSc_8.15

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Flexibility with VBScript - Example: Square Root 1/3

Date: 11.04.23File: System_VBSc_8.16

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: Square Root 2/3

Date: 11.04.23File: System_VBSc_8.17

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Tags - Example: Square Root 3/3

Date: 11.04.23File: System_VBSc_8.18

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Flexibility with VBScript - Example: System Window 1/3

When an input is made in Automaticmode, the system window appears

Date: 11.04.23File: System_VBSc_8.19

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: System Window 2/3

If Auto=1ThenWert_Kontrol=InputElseWert_Kontrol=99Call PtFct.Display_system_message("Plant in Automatic mode: Setpoint change not possible")End If

Date: 11.04.23File: System_VBSc_8.20

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Tags - Example: System Window 3/3

Date: 11.04.23File: System_VBSc_8.21

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Branches

Branch Remarks

If condition Then statements Conditional branch. Everything must be in one line.[Else statements]------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------If condition1 Then Block structure. If...ElseIf...End Ifstatements Each line must end with Then! [ElseIf condition2 Then Else statements are executed when none of thestatements If or ElseIf conditions apply.ElseIf condition3 Thenstatements.....][Else statements ] End If------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------Select Case expression Block structure. Select Case/Case/ End Select Case expression1 The expression can be a tag or any expressionstatements that is compared with the expressions that follow [Case expression2 the keyword Case. statements .....] [Case Else statements] End Select------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------

Date: 11.04.23File: System_VBSc_8.22

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

Loops

Loop statement Remarks

For counter=initial To final value [Step step] For...Next count loop, statements Terminate with Exit For. Step1 if Step omitted [Exit For]statements

Next [counter] ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------Do [While|Until condition] Do While ... Loop conditional loop,

statements Termination condition at beginning of loop [Exit Do] statements

Loop------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------Do Do...Loop While conditional loop,

statements Termination condition at end of loop [Exit Do] statements

Loop [While|Until condition]------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------While condition Equivalent to Do While ... statements Loop conditional loopWend

Date: 11.04.23File: System_VBSc_8.23

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: Calculation with Operand 1 and Operand 2 1/4

Operand 1

Operand 2VBScript

Date: 11.04.23File: System_VBSc_8.24

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: Calculation withOperand 1 and Operand 2 2/4

Date: 11.04.23File: System_VBSc_8.25

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: Calculation withOperand 1 and Operand 2 3/4

Date: 11.04.23File: System_VBSc_8.26

SIMATIC HMISiemens AG 2002. All rights reserved.

SITRAIN Training for Automation and Drives

VBScript / Scripts - Example: Calculation withOperand 1 and Operand 2 4/4

Operand 1

Operand 2 VBScript

top related