SIMATIC HMI WinCC V7.2 - WinCC: Scripting (VBS, ANSI-C, VBA)

SIMATIC HMI

WinCC V7.2 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/2013

A5E32315920-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 Industry Sector Postfach 48 48 90026 N?RNBERG GERMANY

A5E32315920-AA 02/2013 Technical data subject to change

Copyright ? Siemens AG 2013. 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.................................................................................................37 Creating and Editing Procedures.................................................................................................37 Creating a New Procedure..........................................................................................................40 How to Write Procedure Codes...................................................................................................42 Using Standard and Project Procedures.....................................................................................45 How to add module-related information.......................................................................................46 Protecting a Module with a Password.........................................................................................48 Saving a Procedure.....................................................................................................................49 Renaming a Procedure or Module...............................................................................................51

1.10 Creating and Editing Actions.......................................................................................................53 1.10.1 Creating and Editing Actions.......................................................................................................53 1.10.2 Creating a New Action.................................................................................................................57 1.10.3 How to Edit Actions.....................................................................................................................58 1.10.4 How to add action-related information.........................................................................................62 1.10.5 Protecting an Action with a Password.........................................................................................64 1.10.6 Saving Actions.............................................................................................................................65 1.10.7 Triggers.......................................................................................................................................66 1.10.7.1 Triggers.......................................................................................................................................66 1.10.7.2 Animation trigger.........................................................................................................................70 1.10.7.3 How to add a trigger of the type "Timer"......................................................................................72 1.10.7.4 How to add a trigger of the type "Tag".........................................................................................74 1.10.7.5 How to change a trigger..............................................................................................................76 1.10.7.6 How to delete a trigger................................................................................................................77 1.10.8 How to Rename an Action...........................................................................................................78

1.11 How to activate global actions in Runtime...................................................................................80

1.12 Diagnostics..................................................................................................................................82

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

System Manual, 02/2013, A5E32315920-AA

3

Table of contents

1.12.1 Diagnostics..................................................................................................................................82 1.12.2 GSC Diagnostics.........................................................................................................................83 1.12.2.1 GSC Diagnostics.........................................................................................................................83 1.12.2.2 Inserting the GSC Diagnostics Window into a Picture.................................................................84 1.12.2.3 GSC Diagnostics Attributes.........................................................................................................84 1.12.2.4 GSC Diagnostics Toolbar............................................................................................................85 1.12.3 GSC Runtime..............................................................................................................................86 1.12.3.1 GSC Runtime..............................................................................................................................86 1.12.3.2 How to insert the GSC Runtime Window into a Picture...............................................................87 1.12.3.3 GSC Runtime Attributes..............................................................................................................88 1.12.4 Testing with the Debugger...........................................................................................................89 1.12.4.1 Testing with the Debugger...........................................................................................................89 1.12.4.2 How to Activate the Debugger.....................................................................................................90 1.12.4.3 Principles of Debugging...............................................................................................................92 1.12.4.4 Components of the Microsoft Script Debuggers..........................................................................94 1.12.4.5 Structure of VBScript Files..........................................................................................................95 1.12.4.6 Action and Procedure Names in the Debugger...........................................................................97 1.12.4.7 Selecting a Script for Editing.......................................................................................................99 1.12.4.8 Processing Scripts Step-by-Step...............................................................................................101 1.12.4.9 Setting Breakpoints...................................................................................................................102 1.12.4.10 Deleting Breakpoints............................................................................................................103 1.12.4.11 How to Set Bookmarks in Scripts.........................................................................................104 1.12.4.12 How to Determine and Modify Tag and Property Values.....................................................105 1.12.4.13 Executing Script Commands................................................................................................106

1.13 Printing VBScripts......................................................................................................................108

1.14 VBS Reference..........................................................................................................................109 1.14.1 VBS Reference..........................................................................................................................109 1.14.2 Objects and Lists.......................................................................................................................113 1.14.2.1 Objects and Lists.......................................................................................................................113 1.14.2.2 Alarm object...............................................................................................................................115 1.14.2.3 Alarms object (list).....................................................................................................................116 1.14.2.4 AlarmLogs Object......................................................................................................................117 1.14.2.5 DataItem Object.........................................................................................................................118 1.14.2.6 DataLogs Object........................................................................................................................120 1.14.2.7 DataSet-Objekt (List).................................................................................................................121 1.14.2.8 HMIRuntime Object...................................................................................................................123 1.14.2.9 Item Object................................................................................................................................124 1.14.2.10 Layer Object.........................................................................................................................125 1.14.2.11 Layers Object (Listing).........................................................................................................126 1.14.2.12 Logging Object.....................................................................................................................127 1.14.2.13 ProcessValue Object............................................................................................................128 1.14.2.14 ProcessValues Object (List).................................................................................................129 1.14.2.15 Project Object.......................................................................................................................129 1.14.2.16 ScreenItem Object................................................................................................................130 1.14.2.17 ScreenItems Object (List).....................................................................................................133 1.14.2.18 Screen Object.......................................................................................................................135 1.14.2.19 Screens Object (List)............................................................................................................138 1.14.2.20 SmartTags Object................................................................................................................140 1.14.2.21 Tag Object............................................................................................................................141 1.14.2.22 Tags Object (List).................................................................................................................144 1.14.2.23 TagSet Object (List).............................................................................................................146

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

4

System Manual, 02/2013, A5E32315920-AA

Table of contents

1.14.3 Object types of the ScreenItem object.......................................................................................147 1.14.3.1 Object types of the ScreenItem object.......................................................................................147 1.14.3.2 Standard objects........................................................................................................................148 1.14.3.3 Smart objects.............................................................................................................................176 1.14.3.4 Windows objects........................................................................................................................207 1.14.3.5 Tube objects..............................................................................................................................219 1.14.3.6 Controls.....................................................................................................................................221 1.14.3.7 Customized Object....................................................................................................................287 1.14.3.8 Group.........................................................................................................................................288 1.14.4 Properties..................................................................................................................................289 1.14.4.1 Properties..................................................................................................................................289 1.14.4.2 A................................................................................................................................................290 1.14.4.3 B................................................................................................................................................309 1.14.4.4 C................................................................................................................................................335 1.14.4.5 D................................................................................................................................................369 1.14.4.6 E................................................................................................................................................378 1.14.4.7 F................................................................................................................................................388 1.14.4.8 G................................................................................................................................................410 1.14.4.9 H................................................................................................................................................414 1.14.4.10 I............................................................................................................................................422 1.14.4.11 L...........................................................................................................................................428 1.14.4.12 M..........................................................................................................................................459 1.14.4.13 N...........................................................................................................................................480 1.14.4.14 O...........................................................................................................................................482 1.14.4.15 P...........................................................................................................................................499 1.14.4.16 Q...........................................................................................................................................516 1.14.4.17 R...........................................................................................................................................517 1.14.4.18 S...........................................................................................................................................528 1.14.4.19 T...........................................................................................................................................565 1.14.4.20 U...........................................................................................................................................640 1.14.4.21 V...........................................................................................................................................649 1.14.4.22 W..........................................................................................................................................665 1.14.4.23 X - Z......................................................................................................................................670 1.14.5 Methods.....................................................................................................................................678 1.14.5.1 Methods.....................................................................................................................................678 1.14.5.2 Methods A to E..........................................................................................................................680 1.14.5.3 Get methods..............................................................................................................................688 1.14.5.4 Methods H to M.........................................................................................................................736 1.14.5.5 Methods N to R..........................................................................................................................747 1.14.5.6 Methods S to T..........................................................................................................................765 1.14.5.7 Methods U to Z..........................................................................................................................779 1.14.6 Appendix....................................................................................................................................787 1.14.6.1 Error Messages from Database Area........................................................................................787

1.15 Examples of VBScript................................................................................................................789 1.15.1 Examples of VBScript................................................................................................................789 1.15.2 Examples in WinCC...................................................................................................................789 1.15.2.1 Examples in WinCC...................................................................................................................789 1.15.2.2 Example: Accessing objects in Graphics Designer...................................................................790 1.15.2.3 Example: Defining the color of objects......................................................................................791 1.15.2.4 Example: How to Configure Language Changes......................................................................791 1.15.2.5 Example: Deactivating Runtime................................................................................................792 1.15.2.6 Example: Configuring change picture globally..........................................................................792

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

System Manual, 02/2013, A5E32315920-AA

5

Table of contents

1.15.2.7 Example: Configuring Change Picture Via Property..................................................................793 1.15.2.8 Example: Configuring diagnostics output via Trace..................................................................793 1.15.2.9 Example: Writing tag values......................................................................................................794 1.15.2.10 Example: How to Read Tag Values.....................................................................................796 1.15.2.11 Example: Writing Object Properties.....................................................................................799 1.15.2.12 Example: How to Start an Action on the Server (Logging Object).......................................801 1.15.2.13 Dynamization of Controls.....................................................................................................803 1.15.3 General Examples.....................................................................................................................816 1.15.3.1 General examples for VBScript.................................................................................................816 1.15.3.2 Example: Configuring a Database Connection with VBS..........................................................817 1.15.3.3 Example: Using the MS Automation interface...........................................................................819 1.15.3.4 Example: Starting an external application.................................................................................820

1.16 1.16.1 1.16.2

Basic Principles of VBScript......................................................................................................822 Basic Principles of VBScript......................................................................................................822 VBScript Basics.........................................................................................................................822

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

2.1

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

2.2

Creating Functions and Actions.................................................................................................824

2.3

Characteristics of Project Functions..........................................................................................827

2.4

Characteristics of Standard Functions.......................................................................................828

2.5

Characteristics of Internal Functions.........................................................................................830

2.6

Characteristics of Local Actions................................................................................................831

2.7

Characteristics of Global Actions...............................................................................................832

2.8

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

2.9

Use of Global C-Tags................................................................................................................834

2.10 Use of DLLs in Functions and Actions.......................................................................................836

2.11 The Global Script Editor............................................................................................................838 2.11.1 The Global Script Editor............................................................................................................838 2.11.2 Working in the Edit Window.......................................................................................................840 2.11.2.1 Working in the Edit Window.......................................................................................................840 2.11.2.2 Editing Functions with the Keyboard.........................................................................................841 2.11.2.3 Editing Functions with the Mouse..............................................................................................842 2.11.3 Working with the Toolbars.........................................................................................................843 2.11.4 How to Set Different Views........................................................................................................845 2.11.5 How to Set the Font Style..........................................................................................................846 2.11.6 How to Use "Save As..."............................................................................................................846 2.11.7 How to Delete Actions or Project and Standard Functions........................................................847 2.11.8 How to Generate a New Header...............................................................................................848 2.11.9 How to Compile All Functions....................................................................................................848 2.11.10 How to Search in Files...............................................................................................................849 2.11.11 Printing Functions and Actions..................................................................................................850 2.11.11.1 Printing Functions and Actions.............................................................................................850 2.11.11.2 How to Set the Print Parameters..........................................................................................850 2.11.11.3 How to Open Page View......................................................................................................851 2.11.11.4 How to Print the Project Documentation..............................................................................851

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

6

System Manual, 02/2013, A5E32315920-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

Creating and Editing Functions.................................................................................................852 Creating and Editing Functions.................................................................................................852 How to Create a New Function..................................................................................................855 How to Write Function Code......................................................................................................856 How to Use Internal Functions..................................................................................................857 How to Use Standard and Project Functions.............................................................................858 Inserting Additional Function-Related Information.....................................................................859 How to Protect a Function Against Unauthorized Access.........................................................860 How to Compile and Save a Function.......................................................................................861 How to Rename a Function.......................................................................................................862 How to Use Functions from Other Sources...............................................................................863

2.13 Creating and Editing Actions.....................................................................................................865 2.13.1 How To Create and Edit Actions...............................................................................................865 2.13.2 WinCC Coding Rule..................................................................................................................868 2.13.3 How to Create a New Action.....................................................................................................869 2.13.4 How to Edit Actions...................................................................................................................870 2.13.5 How to add action-related information.......................................................................................870 2.13.6 How to Protect an Action Against Unauthorized Access...........................................................872 2.13.7 How to Compile and Save an Action.........................................................................................873 2.13.8 Triggers.....................................................................................................................................874 2.13.8.1 Triggers.....................................................................................................................................874 2.13.8.2 How to Add a New Trigger of the "Timer" Type.........................................................................877 2.13.8.3 How to Add a New Trigger of the "Tag" Type............................................................................878 2.13.8.4 How to change a trigger............................................................................................................880 2.13.8.5 How to delete a trigger..............................................................................................................881 2.13.9 How to Assign Authorizations....................................................................................................882 2.13.10 How to Export an Action............................................................................................................882 2.13.11 How to Import an Action............................................................................................................883 2.13.12 How to Rename an Action.........................................................................................................884 2.13.13 How to Use Actions From Other Sources..................................................................................885

2.14 Runtime Behavior of Actions.....................................................................................................887 2.14.1 Runtime Behavior of Actions.....................................................................................................887 2.14.2 GSC Runtime............................................................................................................................888 2.14.2.1 GSC Runtime............................................................................................................................888 2.14.2.2 How to Place GSC Runtime in a Process Picture.....................................................................891 2.14.2.3 Attributes of GSC Runtime........................................................................................................892 2.14.2.4 How to Edit Actions...................................................................................................................892 2.14.3 GSC Diagnose...........................................................................................................................893 2.14.3.1 GSC Diagnose...........................................................................................................................893 2.14.3.2 How to Place GSC Diagnose in a Process Picture?.................................................................894 2.14.3.3 Attributes of GSC Diagnose......................................................................................................895 2.14.3.4 The Toolbar of GSC Diagnose..................................................................................................895

2.15 ANSI-C function descriptions.....................................................................................................897 2.15.1 lpszPictureName.......................................................................................................................897 2.15.2 Standard functions.....................................................................................................................897 2.15.2.1 Standard functions - short description.......................................................................................897 2.15.2.2 Alarm.........................................................................................................................................898 2.15.2.3 Graphics....................................................................................................................................903 2.15.2.4 Obsolete functions.....................................................................................................................908 2.15.2.5 Report........................................................................................................................................965

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

System Manual, 02/2013, A5E32315920-AA

7

Table of contents

2.15.2.6 WinCC.......................................................................................................................................967 2.15.2.7 Windows....................................................................................................................................974 2.15.3 Internal functions.......................................................................................................................975 2.15.3.1 Internal functions - short description..........................................................................................975 2.15.3.2 allocate......................................................................................................................................976 2.15.3.3 c_bib..........................................................................................................................................977 2.15.3.4 graphics...................................................................................................................................1061 2.15.3.5 tag............................................................................................................................................1387 2.15.3.6 WinCC.....................................................................................................................................1499 2.15.4 Examples.................................................................................................................................1506 2.15.4.1 Examles - A to G.....................................................................................................................1506 2.15.4.2 Examples - GetAlarmHigh to GetPropChar.............................................................................1509 2.15.4.3 Examples - GetRangeMax to GetWidth..................................................................................1525 2.15.4.4 Examples - H to S....................................................................................................................1546 2.15.4.5 Examples - SetAlarmHigh to SetPropChar..............................................................................1548 2.15.4.6 Examples - SetRangeMax to SetWidth...................................................................................1558 2.15.4.7 Examples - T to Z....................................................................................................................1568 2.15.4.8 Examples of WinCC controls...................................................................................................1573 2.15.5 Lists.........................................................................................................................................1575 2.15.5.1 Bar direction............................................................................................................................1575 2.15.5.2 Bar Scaling..............................................................................................................................1576 2.15.5.3 Flash frequencies....................................................................................................................1576 2.15.5.4 I/O field, output format.............................................................................................................1576 2.15.5.5 I/O field, data type of the field content.....................................................................................1577 2.15.5.6 I/O field, field type....................................................................................................................1578 2.15.5.7 Element alignment in check boxes and radio boxes...............................................................1578 2.15.5.8 Color chart...............................................................................................................................1578 2.15.5.9 Format descriptors...................................................................................................................1579 2.15.5.10 Fill pattern...........................................................................................................................1580 2.15.5.11 Line styles..........................................................................................................................1581 2.15.5.12 Line end style.....................................................................................................................1581 2.15.5.13 List types............................................................................................................................1582 2.15.5.14 Language ID.......................................................................................................................1582 2.15.5.15 Text alignment....................................................................................................................1583 2.15.5.16 Tag statuses.......................................................................................................................1583 2.15.6 Structure definitions.................................................................................................................1584 2.15.6.1 Structure definition CCAPErrorExecute...................................................................................1584 2.15.6.2 Structure definition CCAPTime................................................................................................1586 2.15.6.3 Structure definition CMN_ERROR...........................................................................................1587 2.15.6.4 Structure definition DM_TYPEREF..........................................................................................1587 2.15.6.5 Structure definition DM_VAR_UPDATE_STRUCT..................................................................1588 2.15.6.6 Structure definition DM_VAR_UPDATE_STRUCTEX.............................................................1589 2.15.6.7 Structure definition DM_VARKEY............................................................................................1590 2.15.6.8 Structure definition LINKINFO.................................................................................................1591 2.15.6.9 Structure definition MSG_FILTER_STRUCT...........................................................................1592 2.15.6.10 Structure definition MSG_RTDATA_STRUCT....................................................................1595

3 VBA for Automated Configuration...........................................................................................................1597

3.1

Automated configuration..........................................................................................................1597

3.2 3.2.1 3.2.2

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

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

8

System Manual, 02/2013, A5E32315920-AA

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

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

Google Online Preview   Download