WinCC V7.4 WinCC: Scripting (VBS, ANSI-C, - Siemens

SIMATIC HMI

WinCC V7.4 WinCC: Scripting (VBS, ANSI-C, VBA)

System Manual

VBS for Creating Procedures and Actions

1

ANSI-C for Creating Functions and Actions

2

VBA for Automated Configuration

3

Print of the Online Help

02/2016

A5E37536061-AA

Legal information

Warning notice system This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are graded according to the degree of danger.

DANGER indicates that death or severe personal injury will result if proper precautions are not taken.

WARNING indicates that death or severe personal injury may result if proper precautions are not taken.

CAUTION indicates that minor personal injury can result if proper precautions are not taken.

NOTICE indicates that property damage can result if proper precautions are not taken. If more than one degree of danger is present, the warning notice representing the highest degree of danger will be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property damage.

Qualified Personnel The product/system described in this documentation may be operated only by personnel qualified for the specific task in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualified personnel are those who, based on their training and experience, are capable of identifying risks and avoiding potential hazards when working with these products/systems.

Proper use of Siemens products Note the following:

WARNING Siemens products may only be used for the applications described in the catalog and in the relevant technical documentation. If products and components from other manufacturers are used, these must be recommended or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and maintenance are required to ensure that the products operate safely and without any problems. The permissible ambient conditions must be complied with. The information in the relevant documentation must be observed.

Trademarks All names identified by ? are registered trademarks of Siemens AG. The remaining trademarks in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.

Disclaimer of Liability We have reviewed the contents of this publication to ensure consistency with the hardware and software described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in this publication is reviewed regularly and any necessary corrections are included in subsequent editions.

Siemens AG Division Digital Factory Postfach 48 48 90026 N?RNBERG GERMANY

A5E37536061-AA 03/2016 Subject to change

Copyright ? Siemens AG 2016. All rights reserved

Table of contents

1 VBS for Creating Procedures and Actions.................................................................................................11

1.1

VBS for creating procedures and actions...............................................................................11

1.2

Using Visual Basic Script in WinCC.......................................................................................12

1.3

Modules and Procedures.......................................................................................................15

1.4

Actions...................................................................................................................................18

1.5

Multiple Use of Procedures and Actions................................................................................20

1.6

Use of CrossReference..........................................................................................................22

1.7

Using Global Tags in VBS......................................................................................................24

1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5

VBScript Editors.....................................................................................................................26 VBScript Editors.....................................................................................................................26 Global Script Editor................................................................................................................27 Working in an Editing Window...............................................................................................30 Working with the Toolbars......................................................................................................33 Deleting Actions or Procedures..............................................................................................35

1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8

Creating and Editing Procedures...........................................................................................36 Creating and Editing Procedures...........................................................................................36 Creating a New Procedure.....................................................................................................39 How to Write Procedure Codes..............................................................................................41 Using Standard and Project Procedures................................................................................44 How to add module-related information.................................................................................45 Protecting a Module with a Password....................................................................................47 Saving a Procedure................................................................................................................48 Renaming a Procedure or Module.........................................................................................50

1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.10.6 1.10.7 1.10.7.1 1.10.7.2 1.10.7.3 1.10.7.4 1.10.7.5 1.10.7.6 1.10.8

Creating and Editing Actions..................................................................................................52 Creating and Editing Actions..................................................................................................52 Creating a New Action...........................................................................................................56 How to Edit Actions................................................................................................................57 How to add action-related information...................................................................................60 Protecting an Action with a Password....................................................................................62 Saving Actions.......................................................................................................................63 Triggers..................................................................................................................................64 Triggers..................................................................................................................................64 Animation trigger....................................................................................................................68 How to add a trigger of the type "Timer"................................................................................70 How to add a trigger of the type "Tag"...................................................................................72 How to change a trigger.........................................................................................................74 How to delete a trigger...........................................................................................................75 How to Rename an Action.....................................................................................................76

1.11

How to activate global actions in Runtime.............................................................................78

1.12

Diagnostics.............................................................................................................................80

WinCC: Scripting (VBS, ANSI-C, VBA)

System Manual, 02/2016, A5E37536061-AA

3

Table of contents

1.12.1 1.12.2 1.12.2.1 1.12.2.2 1.12.2.3 1.12.2.4 1.12.3 1.12.3.1 1.12.3.2 1.12.3.3 1.12.4 1.12.4.1 1.12.4.2 1.12.4.3 1.12.4.4 1.12.4.5 1.12.4.6 1.12.4.7 1.12.4.8 1.12.4.9 1.12.4.10 1.12.4.11 1.12.4.12

1.13

1.14 1.14.1 1.14.2 1.14.2.1 1.14.2.2 1.14.2.3 1.14.2.4 1.14.2.5 1.14.2.6 1.14.2.7 1.14.2.8 1.14.2.9 1.14.2.10 1.14.2.11 1.14.2.12 1.14.2.13 1.14.2.14 1.14.2.15 1.14.2.16 1.14.2.17 1.14.2.18 1.14.2.19 1.14.2.20 1.14.2.21 1.14.2.22 1.14.2.23 1.14.3

Diagnostics.............................................................................................................................80 GSC Diagnostics....................................................................................................................81 GSC Diagnostics....................................................................................................................81 Inserting the GSC Diagnostics Window into a Picture...........................................................82 GSC Diagnostics Attributes....................................................................................................82 GSC Diagnostics Toolbar.......................................................................................................83 GSC Runtime.........................................................................................................................84 GSC Runtime.........................................................................................................................84 How to insert the GSC Runtime Window into a Picture.........................................................85 GSC Runtime Attributes.........................................................................................................86 Testing with the Debugger.....................................................................................................87 Testing with the Debugger.....................................................................................................87 How to Activate the Debugger...............................................................................................89 Principles of Debugging.........................................................................................................90 Structure of VBScript Files.....................................................................................................92 Action and Procedure Names in the Debugger......................................................................94 Selecting a Script for Editing..................................................................................................96 Processing Scripts Step-by-Step...........................................................................................97 Setting Breakpoints................................................................................................................98 Deleting Breakpoints..............................................................................................................99 How to Set Bookmarks in Scripts.........................................................................................100 How to Determine and Modify Tag and Property Values.....................................................101 Executing Script Commands................................................................................................102

Printing VBScripts................................................................................................................104

VBS Reference....................................................................................................................105 VBS Reference....................................................................................................................105 Objects and Lists..................................................................................................................107 Objects and Lists..................................................................................................................107 Alarm object.........................................................................................................................110 Alarms object (list)................................................................................................................110 AlarmLogs Object.................................................................................................................112 DataItem Object...................................................................................................................113 DataLogs Object..................................................................................................................114 DataSet Object (List)............................................................................................................116 HMIRuntime Object..............................................................................................................118 Item Object...........................................................................................................................119 Layer Object.........................................................................................................................120 Layers Object (Listing).........................................................................................................121 Logging Object.....................................................................................................................122 ProcessValue Object............................................................................................................123 ProcessValues Object (List).................................................................................................124 Project Object.......................................................................................................................124 ScreenItem Object...............................................................................................................125 ScreenItems Object (List).....................................................................................................129 Screen Object......................................................................................................................131 Screens Object (List)............................................................................................................134 SmartTags Object................................................................................................................136 Tag Object............................................................................................................................137 Tags Object (List).................................................................................................................140 TagSet Object (List).............................................................................................................141 Object types of the ScreenItem object.................................................................................143

WinCC: Scripting (VBS, ANSI-C, VBA)

4

System Manual, 02/2016, A5E37536061-AA

Table of contents

1.14.3.1 1.14.3.2 1.14.3.3 1.14.3.4 1.14.3.5 1.14.3.6 1.14.3.7 1.14.3.8 1.14.4 1.14.4.1 1.14.4.2 1.14.4.3 1.14.4.4 1.14.4.5 1.14.4.6 1.14.4.7 1.14.4.8 1.14.4.9 1.14.4.10 1.14.4.11 1.14.4.12 1.14.4.13 1.14.4.14 1.14.4.15 1.14.4.16 1.14.4.17 1.14.4.18 1.14.4.19 1.14.4.20 1.14.4.21 1.14.4.22 1.14.4.23 1.14.5 1.14.5.1 1.14.5.2 1.14.5.3 1.14.5.4 1.14.5.5 1.14.5.6 1.14.5.7 1.14.6 1.14.6.1

1.15 1.15.1 1.15.2 1.15.2.1 1.15.2.2 1.15.2.3 1.15.2.4 1.15.2.5 1.15.2.6 1.15.2.7

Object types of the ScreenItem object.................................................................................143 Standard objects..................................................................................................................144 Smart objects.......................................................................................................................169 Windows objects..................................................................................................................201 Tube objects.........................................................................................................................215 Controls................................................................................................................................218 Customized Object...............................................................................................................298 Group...................................................................................................................................300 Properties.............................................................................................................................301 Properties.............................................................................................................................301 A...........................................................................................................................................302 B...........................................................................................................................................321 C...........................................................................................................................................362 D...........................................................................................................................................397 E...........................................................................................................................................407 F...........................................................................................................................................416 G..........................................................................................................................................438 H...........................................................................................................................................442 I............................................................................................................................................451 L...........................................................................................................................................457 M..........................................................................................................................................488 N...........................................................................................................................................509 O..........................................................................................................................................512 P...........................................................................................................................................528 Q..........................................................................................................................................546 R...........................................................................................................................................547 S...........................................................................................................................................557 T...........................................................................................................................................595 U...........................................................................................................................................671 V...........................................................................................................................................680 W..........................................................................................................................................697 X - Z.....................................................................................................................................702 Methods...............................................................................................................................710 Methods...............................................................................................................................710 Methods A to E.....................................................................................................................712 Get methods.........................................................................................................................720 Methods H to M....................................................................................................................769 Methods N to R....................................................................................................................779 Methods S to T.....................................................................................................................797 Methods U to Z.....................................................................................................................812 Appendix..............................................................................................................................820 Error Messages from Database Area...................................................................................820

Examples of VBScript..........................................................................................................823 Examples of VBScript..........................................................................................................823 Examples in WinCC.............................................................................................................823 Examples in WinCC.............................................................................................................823 Example: Accessing objects in Graphics Designer..............................................................824 Example: Defining the color of objects.................................................................................825 Example: How to Configure Language Changes.................................................................825 Example: Deactivating Runtime...........................................................................................826 Example: Configuring change picture globally.....................................................................826 Example: Configuring Change Picture Via Property............................................................827

WinCC: Scripting (VBS, ANSI-C, VBA)

System Manual, 02/2016, A5E37536061-AA

5

Table of contents

1.15.2.8 1.15.2.9 1.15.2.10 1.15.2.11 1.15.2.12 1.15.2.13 1.15.2.14 1.15.3 1.15.3.1 1.15.3.2 1.15.3.3 1.15.3.4

Example: Configuring diagnostics output via Trace.............................................................827 Example: Writing tag values.................................................................................................828 Example: How to Read Tag Values.....................................................................................830 Example: Writing Object Properties.....................................................................................833 Example: How to Start an Action on the Server (Logging Object).......................................836 Example: You connect or disconnect a database backup with VBS....................................838 Dynamization of Controls.....................................................................................................841 General Examples................................................................................................................855 General examples for VBScript............................................................................................855 Example: Configuring a Database Connection with VBS.....................................................856 Example: Using the MS Automation interface......................................................................858 Example: Starting an external application............................................................................859

1.16 1.16.1 1.16.2

Basic Principles of VBScript.................................................................................................861 Basic Principles of VBScript.................................................................................................861 VBScript Basics....................................................................................................................861

2 ANSI-C for Creating Functions and Actions.............................................................................................863

2.1

Creating Functions and Actions with ANSI-C.......................................................................863

2.2

Creating Functions and Actions...........................................................................................864

2.3

Characteristics of Project Functions.....................................................................................867

2.4

Characteristics of Standard Functions.................................................................................868

2.5

Characteristics of Internal Functions....................................................................................870

2.6

Characteristics of Local Actions...........................................................................................871

2.7

Characteristics of Global Actions.........................................................................................872

2.8

How to Add Global Script Runtime to a Project's Startup List..............................................873

2.9

Use of Global C-Tags...........................................................................................................874

2.10

Use of DLLs in Functions and Actions.................................................................................876

2.11 2.11.1 2.11.2 2.11.2.1 2.11.2.2 2.11.2.3 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.11.10 2.11.11 2.11.11.1 2.11.11.2 2.11.11.3 2.11.11.4

The Global Script Editor.......................................................................................................878 The Global Script Editor.......................................................................................................878 Working in the Edit Window.................................................................................................880 Working in the Edit Window.................................................................................................880 Editing Functions with the Keyboard....................................................................................881 Editing Functions with the Mouse........................................................................................882 Working with the Toolbars....................................................................................................882 How to Set Different Views..................................................................................................885 How to Set the Font Style....................................................................................................885 How to Use "Save As...".......................................................................................................886 How to Delete Actions or Project and Standard Functions..................................................887 How to Generate a New Header..........................................................................................887 How to Compile All Functions..............................................................................................888 How to Search in Files.........................................................................................................889 Printing Functions and Actions.............................................................................................890 Printing Functions and Actions.............................................................................................890 How to Set the Print Parameters..........................................................................................890 How to Open Page View......................................................................................................891 How to Print the Project Documentation..............................................................................891

WinCC: Scripting (VBS, ANSI-C, VBA)

6

System Manual, 02/2016, A5E37536061-AA

Table of contents

2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.12.5 2.12.6 2.12.7 2.12.8 2.12.9 2.12.10

2.13 2.13.1 2.13.2 2.13.3 2.13.4 2.13.5 2.13.6 2.13.7 2.13.8 2.13.8.1 2.13.8.2 2.13.8.3 2.13.8.4 2.13.8.5 2.13.9 2.13.10 2.13.11 2.13.12 2.13.13

2.14 2.14.1 2.14.2 2.14.2.1 2.14.2.2 2.14.2.3 2.14.2.4 2.14.3 2.14.3.1 2.14.3.2 2.14.3.3 2.14.3.4

2.15 2.15.1 2.15.2 2.15.2.1 2.15.2.2 2.15.2.3 2.15.2.4 2.15.2.5

Creating and Editing Functions............................................................................................892 Creating and Editing Functions............................................................................................892 How to Create a New Function............................................................................................895 How to Write Function Code................................................................................................896 How to Use Internal Functions.............................................................................................897 How to Use Standard and Project Functions.......................................................................897 Inserting Additional Function-Related Information...............................................................898 How to Protect a Function Against Unauthorized Access....................................................900 How to Compile and Save a Function..................................................................................901 How to Rename a Function..................................................................................................902 How to Use Functions from Other Sources..........................................................................903

Creating and Editing Actions................................................................................................905 How To Create and Edit Actions..........................................................................................905 WinCC Coding Rule.............................................................................................................908 How to Create a New Action................................................................................................909 How to Edit Actions..............................................................................................................910 How to add action-related information.................................................................................910 How to Protect an Action Against Unauthorized Access......................................................912 How to Compile and Save an Action....................................................................................913 Triggers................................................................................................................................914 Triggers................................................................................................................................914 How to Add a New Trigger of the "Timer" Type...................................................................917 How to Add a New Trigger of the "Tag" Type......................................................................918 How to change a trigger.......................................................................................................920 How to delete a trigger.........................................................................................................921 How to Assign Authorizations..............................................................................................922 How to Export an Action.......................................................................................................922 How to Import an Action.......................................................................................................923 How to Rename an Action...................................................................................................924 How to Use Actions From Other Sources............................................................................925

Runtime Behavior of Actions................................................................................................927 Runtime Behavior of Actions................................................................................................927 GSC Runtime.......................................................................................................................928 GSC Runtime.......................................................................................................................928 How to Place GSC Runtime in a Process Picture................................................................931 Attributes of GSC Runtime...................................................................................................932 How to Edit Actions..............................................................................................................932 GSC Diagnose.....................................................................................................................933 GSC Diagnose.....................................................................................................................933 How to Place GSC Diagnose in a Process Picture?............................................................934 Attributes of GSC Diagnose.................................................................................................935 The Toolbar of GSC Diagnose.............................................................................................935

ANSI-C function descriptions...............................................................................................937 lpszPictureName..................................................................................................................937 Standard functions...............................................................................................................937 Standard functions - short description..................................................................................937 Alarm....................................................................................................................................938 Graphics...............................................................................................................................942 Obsolete functions...............................................................................................................947 Report..................................................................................................................................999

WinCC: Scripting (VBS, ANSI-C, VBA)

System Manual, 02/2016, A5E37536061-AA

7

Table of contents

2.15.2.6 2.15.2.7 2.15.3 2.15.3.1 2.15.3.2 2.15.3.3 2.15.3.4 2.15.3.5 2.15.3.6 2.15.4 2.15.4.1 2.15.4.2 2.15.4.3 2.15.4.4 2.15.4.5 2.15.4.6 2.15.4.7 2.15.4.8 2.15.5 2.15.5.1 2.15.5.2 2.15.5.3 2.15.5.4 2.15.5.5 2.15.5.6 2.15.5.7 2.15.5.8 2.15.5.9 2.15.5.10 2.15.5.11 2.15.5.12 2.15.5.13 2.15.5.14 2.15.5.15 2.15.5.16 2.15.6 2.15.6.1 2.15.6.2 2.15.6.3 2.15.6.4 2.15.6.5 2.15.6.6 2.15.6.7 2.15.6.8 2.15.6.9 2.15.6.10

WinCC................................................................................................................................1002 Windows.............................................................................................................................1009 Internal functions................................................................................................................1010 Internal functions - short description..................................................................................1010 allocate...............................................................................................................................1010 c_bib...................................................................................................................................1011 graphics..............................................................................................................................1095 tag......................................................................................................................................1408 WinCC................................................................................................................................1510 Examples...........................................................................................................................1517 Examles - A to G................................................................................................................1517 Examples - GetAlarmHigh to GetPropChar.......................................................................1518 Examples - GetRangeMax to GetWidth.............................................................................1534 Examples - H to S..............................................................................................................1557 Examples - SetAlarmHigh to SetPropChar........................................................................1559 Examples - SetRangeMax to SetWidth..............................................................................1569 Examples of WinCC controls.............................................................................................1579 Examples - Obsolete functions..........................................................................................1582 Lists....................................................................................................................................1590 Bar direction.......................................................................................................................1590 Bar Scaling.........................................................................................................................1590 Flash frequencies...............................................................................................................1590 I/O field, output format........................................................................................................1591 I/O field, data type of the field content................................................................................1592 I/O field, field type..............................................................................................................1592 Element alignment in check boxes and radio boxes..........................................................1592 Color chart..........................................................................................................................1592 Format descriptors.............................................................................................................1593 Fill pattern..........................................................................................................................1594 Line styles..........................................................................................................................1595 Line end style.....................................................................................................................1595 List types............................................................................................................................1596 Language ID.......................................................................................................................1596 Text alignment....................................................................................................................1597 Tag statuses.......................................................................................................................1598 Structure definitions...........................................................................................................1599 Structure definition CCAPErrorExecute.............................................................................1599 Structure definition CCAPTime..........................................................................................1600 Structure definition CMN_ERROR.....................................................................................1601 Structure definition DM_TYPEREF....................................................................................1602 Structure definition DM_VAR_UPDATE_STRUCT.............................................................1603 Structure definition DM_VAR_UPDATE_STRUCTEX........................................................1604 Structure definition DM_VARKEY......................................................................................1605 Structure definition LINKINFO............................................................................................1605 Structure definition MSG_FILTER_STRUCT.....................................................................1607 Structure definition MSG_RTDATA_STRUCT...................................................................1610

3 VBA for Automated Configuration..........................................................................................................1613

3.1

Automated configuration....................................................................................................1613

3.2 3.2.1 3.2.2

Introduction: Using VBA in WinCC.....................................................................................1614 Introduction: Using VBA in WinCC.....................................................................................1614 Differentiation: Using VBA..................................................................................................1614

WinCC: Scripting (VBS, ANSI-C, VBA)

8

System Manual, 02/2016, A5E37536061-AA

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download