在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → 分享Pcs7 APL.pdf

实例介绍

【实例简介】WinCC_Programming_en-US_en-US (1).pdf 
【实例截图】

【核心代码】

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 VBScript Editors.....................................................................................................................26
1.8.1 VBScript Editors.....................................................................................................................26
1.8.2 Global Script Editor................................................................................................................27
1.8.3 Working in an Editing Window...............................................................................................30
1.8.4 Working with the Toolbars......................................................................................................33
1.8.5 Deleting Actions or Procedures..............................................................................................35
1.9 Creating and Editing Procedures...........................................................................................36
1.9.1 Creating and Editing Procedures...........................................................................................36
1.9.2 Creating a New Procedure.....................................................................................................39
1.9.3 How to Write Procedure Codes..............................................................................................41
1.9.4 Using Standard and Project Procedures................................................................................44
1.9.5 How to add module-related information.................................................................................45
1.9.6 Protecting a Module with a Password....................................................................................47
1.9.7 Saving a Procedure................................................................................................................48
1.9.8 Renaming a Procedure or Module.........................................................................................50
1.10 Creating and Editing Actions..................................................................................................52
1.10.1 Creating and Editing Actions..................................................................................................52
1.10.2 Creating a New Action...........................................................................................................56
1.10.3 How to Edit Actions................................................................................................................57
1.10.4 How to add action-related information...................................................................................60
1.10.5 Protecting an Action with a Password....................................................................................62
1.10.6 Saving Actions.......................................................................................................................63
1.10.7 Triggers..................................................................................................................................64
1.10.7.1 Triggers..................................................................................................................................64
1.10.7.2 Animation trigger....................................................................................................................68
1.10.7.3 How to add a trigger of the type "Timer"................................................................................70
1.10.7.4 How to add a trigger of the type "Tag"...................................................................................72
1.10.7.5 How to change a trigger.........................................................................................................74
1.10.7.6 How to delete a trigger...........................................................................................................75
1.10.8 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/2017, A5E40812536-AA 3
1.12.1 Diagnostics.............................................................................................................................80
1.12.2 GSC Diagnostics....................................................................................................................81
1.12.2.1 GSC Diagnostics....................................................................................................................81
1.12.2.2 Inserting the GSC Diagnostics Window into a Picture...........................................................82
1.12.2.3 GSC Diagnostics Attributes....................................................................................................82
1.12.2.4 GSC Diagnostics Toolbar.......................................................................................................83
1.12.3 GSC Runtime.........................................................................................................................84
1.12.3.1 GSC Runtime.........................................................................................................................84
1.12.3.2 How to insert the GSC Runtime Window into a Picture.........................................................85
1.12.3.3 GSC Runtime Attributes.........................................................................................................86
1.12.4 Testing with the Debugger.....................................................................................................87
1.12.4.1 Testing with the Debugger.....................................................................................................87
1.12.4.2 How to Activate the Debugger...............................................................................................89
1.12.4.3 Principles of Debugging.........................................................................................................90
1.12.4.4 Structure of VBScript Files.....................................................................................................92
1.12.4.5 Action and Procedure Names in the Debugger......................................................................94
1.12.4.6 Selecting a Script for Editing..................................................................................................96
1.12.4.7 Processing Scripts Step-by-Step...........................................................................................97
1.12.4.8 Setting Breakpoints................................................................................................................98
1.12.4.9 Deleting Breakpoints..............................................................................................................99
1.12.4.10 How to Set Bookmarks in Scripts.........................................................................................100
1.12.4.11 How to Determine and Modify Tag and Property Values.....................................................101
1.12.4.12 Executing Script Commands................................................................................................102
1.13 Printing VBScripts................................................................................................................104
1.14 VBS Reference....................................................................................................................105
1.14.1 VBS Reference....................................................................................................................105
1.14.2 Objects and Lists..................................................................................................................107
1.14.2.1 Objects and Lists..................................................................................................................107
1.14.2.2 Alarm object.........................................................................................................................110
1.14.2.3 Alarms object (list)................................................................................................................110
1.14.2.4 AlarmLogs Object.................................................................................................................112
1.14.2.5 DataItem Object...................................................................................................................113
1.14.2.6 DataLogs Object..................................................................................................................114
1.14.2.7 DataSet Object (List)............................................................................................................115
1.14.2.8 HMIRuntime Object..............................................................................................................118
1.14.2.9 Item Object...........................................................................................................................119
1.14.2.10 Layer Object.........................................................................................................................120
1.14.2.11 Layers Object (Listing).........................................................................................................121
1.14.2.12 Logging Object.....................................................................................................................122
1.14.2.13 ProcessValue Object............................................................................................................123
1.14.2.14 ProcessValues Object (List).................................................................................................124
1.14.2.15 Project Object.......................................................................................................................124
1.14.2.16 ScreenItem Object...............................................................................................................125
1.14.2.17 ScreenItems Object (List).....................................................................................................129
1.14.2.18 Screen Object......................................................................................................................131
1.14.2.19 Screens Object (List)............................................................................................................134
1.14.2.20 SmartTags Object................................................................................................................136
1.14.2.21 Tag Object............................................................................................................................137
1.14.2.22 Tags Object (List).................................................................................................................139
1.14.2.23 TagSet Object (List).............................................................................................................141
1.14.3 Object types of the ScreenItem object.................................................................................143
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
4 System Manual, 02/2017, A5E40812536-AA
1.14.3.1 Object types of the ScreenItem object.................................................................................143
1.14.3.2 Standard objects..................................................................................................................144
1.14.3.3 Smart objects.......................................................................................................................169
1.14.3.4 Windows objects..................................................................................................................200
1.14.3.5 Tube objects.........................................................................................................................214
1.14.3.6 Controls................................................................................................................................217
1.14.3.7 Customized Object...............................................................................................................295
1.14.3.8 Group...................................................................................................................................297
1.14.4 Properties.............................................................................................................................298
1.14.4.1 Properties.............................................................................................................................298
1.14.4.2 A...........................................................................................................................................298
1.14.4.3 B...........................................................................................................................................318
1.14.4.4 C...........................................................................................................................................360
1.14.4.5 D...........................................................................................................................................394
1.14.4.6 E...........................................................................................................................................404
1.14.4.7 F...........................................................................................................................................415
1.14.4.8 G..........................................................................................................................................437
1.14.4.9 H...........................................................................................................................................442
1.14.4.10 I............................................................................................................................................450
1.14.4.11 L...........................................................................................................................................456
1.14.4.12 M..........................................................................................................................................487
1.14.4.13 N...........................................................................................................................................508
1.14.4.14 O..........................................................................................................................................510
1.14.4.15 P...........................................................................................................................................527
1.14.4.16 Q..........................................................................................................................................545
1.14.4.17 R...........................................................................................................................................546
1.14.4.18 S...........................................................................................................................................556
1.14.4.19 T...........................................................................................................................................593
1.14.4.20 U...........................................................................................................................................670
1.14.4.21 V...........................................................................................................................................679
1.14.4.22 W..........................................................................................................................................696
1.14.4.23 X - Z.....................................................................................................................................701
1.14.5 Methods...............................................................................................................................709
1.14.5.1 Methods...............................................................................................................................709
1.14.5.2 Methods A to E.....................................................................................................................711
1.14.5.3 Get methods.........................................................................................................................719
1.14.5.4 Methods H to M....................................................................................................................768
1.14.5.5 Methods N to R....................................................................................................................778
1.14.5.6 Methods S to T.....................................................................................................................796
1.14.5.7 Methods U to Z.....................................................................................................................811
1.14.6 Appendix..............................................................................................................................819
1.14.6.1 Error Messages from Database Area...................................................................................819
1.15 Examples of VBScript..........................................................................................................822
1.15.1 Examples of VBScript..........................................................................................................822
1.15.2 Examples in WinCC.............................................................................................................822
1.15.2.1 Examples in WinCC.............................................................................................................822
1.15.2.2 Example: Accessing objects in Graphics Designer..............................................................823
1.15.2.3 Example: Defining the color of objects.................................................................................824
1.15.2.4 Example: How to Configure Language Changes.................................................................824
1.15.2.5 Example: Deactivating Runtime...........................................................................................825
1.15.2.6 Example: Configuring change picture globally.....................................................................825
1.15.2.7 Example: Configuring Change Picture Via Property............................................................826
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 02/2017, A5E40812536-AA 5
1.15.2.8 Example: Configuring diagnostics output via Trace.............................................................826
1.15.2.9 Example: Writing tag values.................................................................................................827
1.15.2.10 Example: How to Read Tag Values.....................................................................................829
1.15.2.11 Example: Writing Object Properties.....................................................................................832
1.15.2.12 Example: How to Start an Action on the Server (Logging Object).......................................835
1.15.2.13 Example: You connect or disconnect a database backup with VBS....................................837
1.15.2.14 Dynamization of Controls.....................................................................................................840
1.15.3 General Examples................................................................................................................854
1.15.3.1 General examples for VBScript............................................................................................854
1.15.3.2 Example: Configuring a Database Connection with VBS.....................................................855
1.15.3.3 Example: Using the MS Automation interface......................................................................857
1.15.3.4 Example: Starting an external application............................................................................858
1.16 Basic Principles of VBScript.................................................................................................860
1.16.1 Basic Principles of VBScript.................................................................................................860
1.16.2 VBScript Basics....................................................................................................................860
2 ANSI-C for Creating Functions and Actions.............................................................................................861
2.1 Creating Functions and Actions with ANSI-C.......................................................................861
2.2 Creating Functions and Actions...........................................................................................862
2.3 Characteristics of Project Functions.....................................................................................865
2.4 Characteristics of Standard Functions.................................................................................866
2.5 Characteristics of Internal Functions....................................................................................868
2.6 Characteristics of Local Actions...........................................................................................869
2.7 Characteristics of Global Actions.........................................................................................870
2.8 How to Add Global Script Runtime to a Project's Startup List..............................................871
2.9 Use of Global C-Tags...........................................................................................................872
2.10 Use of DLLs in Functions and Actions.................................................................................874
2.11 The Global Script Editor.......................................................................................................876
2.11.1 The Global Script Editor.......................................................................................................876
2.11.2 Working in the Edit Window.................................................................................................878
2.11.2.1 Working in the Edit Window.................................................................................................878
2.11.2.2 Editing Functions with the Keyboard....................................................................................879
2.11.2.3 Editing Functions with the Mouse........................................................................................880
2.11.3 Working with the Toolbars....................................................................................................881
2.11.4 How to Set Different Views..................................................................................................883
2.11.5 How to Set the Font Style....................................................................................................884
2.11.6 How to Use "Save As...".......................................................................................................884
2.11.7 How to Delete Actions or Project and Standard Functions..................................................885
2.11.8 How to Generate a New Header..........................................................................................886
2.11.9 How to Compile All Functions..............................................................................................886
2.11.10 How to Search in Files.........................................................................................................887
2.11.11 Printing Functions and Actions.............................................................................................888
2.11.11.1 Printing Functions and Actions.............................................................................................888
2.11.11.2 How to Set the Print Parameters..........................................................................................888
2.11.11.3 How to Open Page View......................................................................................................889
2.11.11.4 How to Print the Project Documentation..............................................................................889
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
6 System Manual, 02/2017, A5E40812536-AA
2.12 Creating and Editing Functions............................................................................................890
2.12.1 Creating and Editing Functions............................................................................................890
2.12.2 How to Create a New Function............................................................................................893
2.12.3 How to Write Function Code................................................................................................894
2.12.4 How to Use Internal Functions.............................................................................................895
2.12.5 How to Use Standard and Project Functions.......................................................................895
2.12.6 Inserting Additional Function-Related Information...............................................................896
2.12.7 How to Protect a Function Against Unauthorized Access....................................................898
2.12.8 How to Compile and Save a Function..................................................................................899
2.12.9 How to Rename a Function..................................................................................................900
2.12.10 How to Use Functions from Other Sources..........................................................................901
2.13 Creating and Editing Actions................................................................................................903
2.13.1 How To Create and Edit Actions..........................................................................................903
2.13.2 WinCC Coding Rule.............................................................................................................906
2.13.3 How to Create a New Action................................................................................................907
2.13.4 How to Edit Actions..............................................................................................................908
2.13.5 How to add action-related information.................................................................................908
2.13.6 How to Protect an Action Against Unauthorized Access......................................................910
2.13.7 How to Compile and Save an Action....................................................................................911
2.13.8 Triggers................................................................................................................................912
2.13.8.1 Triggers................................................................................................................................912
2.13.8.2 How to Add a New Trigger of the "Timer" Type...................................................................915
2.13.8.3 How to Add a New Trigger of the "Tag" Type......................................................................916
2.13.8.4 How to change a trigger.......................................................................................................918
2.13.8.5 How to delete a trigger.........................................................................................................919
2.13.9 How to Assign Authorizations..............................................................................................920
2.13.10 How to Export an Action.......................................................................................................920
2.13.11 How to Import an Action.......................................................................................................921
2.13.12 How to Rename an Action...................................................................................................922
2.13.13 How to Use Actions From Other Sources............................................................................923
2.14 Runtime Behavior of Actions................................................................................................925
2.14.1 Runtime Behavior of Actions................................................................................................925
2.14.2 GSC Runtime.......................................................................................................................926
2.14.2.1 GSC Runtime.......................................................................................................................926
2.14.2.2 How to Place GSC Runtime in a Process Picture................................................................929
2.14.2.3 Attributes of GSC Runtime...................................................................................................930
2.14.2.4 How to Edit Actions..............................................................................................................930
2.14.3 GSC Diagnose.....................................................................................................................931
2.14.3.1 GSC Diagnose.....................................................................................................................931
2.14.3.2 How to Place GSC Diagnose in a Process Picture?............................................................932
2.14.3.3 Attributes of GSC Diagnose.................................................................................................933
2.14.3.4 The Toolbar of GSC Diagnose.............................................................................................933
2.15 ANSI-C function descriptions...............................................................................................935
2.15.1 lpszPictureName..................................................................................................................935
2.15.2 Standard functions...............................................................................................................935
2.15.2.1 Standard functions - short description..................................................................................935
2.15.2.2 Alarm....................................................................................................................................936
2.15.2.3 Graphics...............................................................................................................................941
2.15.2.4 Obsolete functions...............................................................................................................947
2.15.2.5 Report..................................................................................................................................999
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 02/2017, A5E40812536-AA 7
2.15.2.6 WinCC................................................................................................................................1002
2.15.2.7 Windows.............................................................................................................................1009
2.15.3 Internal functions................................................................................................................1010
2.15.3.1 Internal functions - short description..................................................................................1010
2.15.3.2 allocate...............................................................................................................................1010
2.15.3.3 c_bib...................................................................................................................................1011
2.15.3.4 graphics..............................................................................................................................1095
2.15.3.5 tag......................................................................................................................................1408
2.15.3.6 WinCC................................................................................................................................1510
2.15.4 Examples...........................................................................................................................1518
2.15.4.1 Examles - A to G................................................................................................................1518
2.15.4.2 Examples - GetAlarmHigh to GetPropChar.......................................................................1519
2.15.4.3 Examples - GetRangeMax to GetWidth.............................................................................1535
2.15.4.4 Examples - H to S..............................................................................................................1558
2.15.4.5 Examples - SetAlarmHigh to SetPropChar........................................................................1560
2.15.4.6 Examples - SetRangeMax to SetWidth..............................................................................1570
2.15.4.7 Examples of WinCC controls.............................................................................................1580
2.15.4.8 Examples - Obsolete functions..........................................................................................1583
2.15.5 Lists....................................................................................................................................1591
2.15.5.1 Bar direction.......................................................................................................................1591
2.15.5.2 Bar Scaling.........................................................................................................................1591
2.15.5.3 Flash frequencies...............................................................................................................1591
2.15.5.4 I/O field, output format........................................................................................................1592
2.15.5.5 I/O field, data type of the field content................................................................................1593
2.15.5.6 I/O field, field type..............................................................................................................1593
2.15.5.7 Element alignment in check boxes and radio boxes..........................................................1593
2.15.5.8 Color chart..........................................................................................................................1593
2.15.5.9 Format descriptors.............................................................................................................1594
2.15.5.10 Fill pattern..........................................................................................................................1595
2.15.5.11 Line styles..........................................................................................................................1596
2.15.5.12 Line end style.....................................................................................................................1596
2.15.5.13 List types............................................................................................................................1597
2.15.5.14 Language ID.......................................................................................................................1597
2.15.5.15 Text alignment....................................................................................................................1598
2.15.5.16 Tag statuses.......................................................................................................................1599
2.15.6 Structure definitions...........................................................................................................1599
2.15.6.1 Structure definition CCAPErrorExecute.............................................................................1599
2.15.6.2 Structure definition CCAPTime..........................................................................................1601
2.15.6.3 Structure definition CMN_ERROR.....................................................................................1602
2.15.6.4 Structure definition DM_TYPEREF....................................................................................1602
2.15.6.5 Structure definition DM_VAR_UPDATE_STRUCT.............................................................1603
2.15.6.6 Structure definition DM_VAR_UPDATE_STRUCTEX........................................................1604
2.15.6.7 Structure definition DM_VARKEY......................................................................................1605
2.15.6.8 Structure definition LINKINFO............................................................................................1606
2.15.6.9 Structure definition MSG_FILTER_STRUCT.....................................................................1607
2.15.6.10 Structure definition MSG_RTDATA_STRUCT...................................................................1610
3 VBA for Automated Configuration..........................................................................................................1613
3.1 Automated configuration....................................................................................................1613
3.2 Introduction: Using VBA in WinCC.....................................................................................1614
3.2.1 Introduction: Using VBA in WinCC.....................................................................................1614
3.2.2 Differentiation: Using VBA..................................................................................................1614
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
8 System Manual, 02/2017, A5E40812536-AA
3.2.3 Organizing VBA Code in a WinCC Project.........................................................................1615
3.2.4 How to export and import VBA code..................................................................................1618
3.2.5 Executing VBA Macros in Graphics Designer....................................................................1619
3.3 VBA in the Graphics Designer...........................................................................................1621
3.3.1 VBA in the Graphics Designer...........................................................................................1621
3.3.2 Adapting the Graphics Designer with VBA.........................................................................1623
3.3.2.1 Adapting the Graphics Designer with VBA.........................................................................1623
3.3.2.2 Language-Dependent Configuration with VBA..................................................................1624
3.3.2.3 Creating Customized Menus and Toolbars........................................................................1626
3.3.2.4 Accessing the component library with VBA........................................................................1646
3.3.3 Editing Pictures with VBA...................................................................................................1654
3.3.3.1 Editing Pictures with VBA...................................................................................................1654
3.3.3.2 How to Create Picture-specific Menus and Toolbars.........................................................1655
3.3.3.3 Editing Layers with VBA.....................................................................................................1657
3.3.3.4 Editing a Copy of a Picture with VBA.................................................................................1658
3.3.4 Editing Objects with VBA...................................................................................................1660
3.3.4.1 Editing Objects with VBA...................................................................................................1660
3.3.4.2 Default objects, Smart objects, Windows objects and Tube objects..................................1662
3.3.4.3 Group Objects....................................................................................................................1672
3.3.4.4 Customized Objects...........................................................................................................1680
3.3.5 Creating Dynamics with VBA.............................................................................................1684
3.3.5.1 Creating Dynamics with VBA.............................................................................................1684
3.3.5.2 Configuring Dynamics in the Properties of Pictures and Objects.......................................1685
3.3.5.3 Configuring Event-Driven Actions with VBA.......................................................................1697
3.3.5.4 Editing Triggers..................................................................................................................1705
3.3.6 Event Handling...................................................................................................................1707
3.3.7 Accessing External Applications with VBA.........................................................................1711
3.3.7.1 Accessing External Applications with VBA.........................................................................1711
3.3.7.2 Example: Accessing MS Excel with VBA...........................................................................1712
3.4 VBA in the WinCC Configuration Studio............................................................................1723
3.4.1 VBA in the WinCC Configuration Studio............................................................................1723
3.4.2 Example: VBA in the WinCC Configuration Studio............................................................1724
3.5 AddIns................................................................................................................................1732
3.5.1 AddIns................................................................................................................................1732
3.5.2 Linking Add Ins...................................................................................................................1732
3.5.3 How to Configure an AddIn in the Graphics Designer.......................................................1735
3.5.4 Example: Creating Add Ins................................................................................................1736
3.5.4.1 Example: Creating Add Ins................................................................................................1736
3.5.4.2 Example: Creating an Add In with Visual Basic 6.0...........................................................1737
3.6 VBA Reference..................................................................................................................1743
3.6.1 The object model of the Graphics Designer.......................................................................1743
3.6.1.1 VBA Reference..................................................................................................................1743
3.6.1.2 VBA Reference: ActionDynamic........................................................................................1745
3.6.1.3 VBA Reference: HMIObjects..............................................................................................1747
3.6.1.4 VBA Reference: Languages...............................................................................................1749
3.6.1.5 Events................................................................................................................................1750
3.6.1.6 Methods.............................................................................................................................1783
3.6.1.7 Objects and Lists................................................................................................................1891
3.6.1.8 Properties...........................................................................................................................2103
3.6.2 VBA in Other WinCC Editors..............................................................................................2548
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 02/2017, A5E40812536-AA 9
3.6.2.1 VBA in Other WinCC Editors..............................................................................................2548
3.6.2.2 VBA in Tag Management...................................................................................................2550
3.6.2.3 VBA im Tag Logging..........................................................................................................2561
3.6.2.4 VBA in the Text Library......................................................................................................2595
3.6.2.5 VBA in Alarm Logging........................................................................................................2609
Index.......................................................................................................................................................2623

标签: PcS7 AP Pc S7 cs

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警