ITScriptsAndLogic.pdf

(1945 KB) Pobierz
InTouch HMI Scripting and Logic Guide
InTouch ® HMI Scripting and Logic
Guide
Invensys Systems, Inc.
Revision A
Last Revision: 7/25/07
671724734.001.png
Copyright
© 2007 Invensys Systems, Inc. All Rights Reserved.
All rights reserved. No part of this documentation shall be reproduced, stored in a
retrieval system, or transmitted by any means, electronic, mechanical,
photocopying, recording, or otherwise, without the prior written permission of
Invensys Systems, Inc. No copyright or patent liability is assumed with respect to
the use of the information contained herein. Although every precaution has been
taken in the preparation of this documentation, the publisher and the author
assume no responsibility for errors or omissions. Neither is any liability assumed
for damages resulting from the use of the information contained herein.
The information in this documentation is subject to change without notice and does
not represent a commitment on the part of Invensys Systems, Inc. The software
described in this documentation is furnished under a license or nondisclosure
agreement. This software may be used or copied only in accordance with the terms
of these agreements.
Invensys Systems, Inc.
26561 Rancho Parkway South
Lake Forest, CA 92630 U.S.A.
(949) 727-3200
http://www.wonderware.com
For comments or suggestions about the product documentation, send an e-mail
message to productdocs@wonderware.com.
Trademarks
All terms mentioned in this documentation that are known to be trademarks or
service marks have been appropriately capitalized. Invensys Systems, Inc. cannot
attest to the accuracy of this information. Use of a term in this documentation
should not be regarded as affecting the validity of any trademark or service mark.
Alarm Logger, ActiveFactory, ArchestrA, Avantis, DBDump, DBLoad, DT Analyst,
FactoryFocus, FactoryOffice, FactorySuite, FactorySuite A 2 , InBatch, InControl,
IndustrialRAD, IndustrialSQL Server, InTouch, MaintenanceSuite, MuniSuite, QI
Analyst, SCADAlarm, SCADASuite, SuiteLink, SuiteVoyager, WindowMaker,
WindowViewer, Wonderware, and Wonderware Logger are trademarks of Invensys
plc, its subsidiaries and affiliates. All other brands may be trademarks of their
respective owners.
3
Contents
Welcome............................................ 9
Documentation Conventions...............................................9
Technical Support .............................................................10
Chapter 1 Introduction to Scripting....................... 11
Basic Scripting Concepts...................................................12
Types of Scripts .................................................................12
Editing and Creating Scripts ............................................13
Advanced Scripting Concepts ...........................................14
OLE Objects ....................................................................14
Scripting with ActiveX Controls ....................................14
Chapter 2 Creating and Editing Scripts................... 15
Opening a Script for Editing.............................................16
Saving or Discarding Changes to a Script .......................18
Copying, Cutting and Pasting Text ..................................18
Finding and/or Replacing Text .........................................18
Inserting Code Elements...................................................19
Accessing Help for Script Functions.................................20
Validating Scripts for Correct Syntax ..............................21
Printing Scripts .................................................................21
Deleting Scripts .................................................................22
InTouch HMI Scripting and Logic Guide
671724734.002.png
4 Contents
Chapter 3 Script Triggers ....................................23
Types of Script Triggers .................................................... 24
Using Multiple Triggers.................................................... 24
Periodic Script Execution.................................................. 25
Configuring Application Scripts ....................................... 25
Limitations of Application Scripts................................. 26
Configuring Window Scripts............................................. 27
Configuring Key Scripts.................................................... 28
Configuring Condition Scripts .......................................... 31
Configuring Data Change Scripts .................................... 33
Configuring Action Scripts ............................................... 34
Configuring ActiveX Event Scripts .................................. 38
Pausing Script Execution at Run Time............................ 40
$LogicRunning System Tag ........................................... 41
Chapter 4 The Script Language .............................43
Basic Syntax Rules............................................................ 44
Subroutines..................................................................... 44
Statements...................................................................... 44
Indentation ..................................................................... 44
Comments ....................................................................... 44
Tag References ............................................................... 45
Literal Data Values........................................................ 45
Value Expressions .......................................................... 45
Syntax Validation........................................................... 45
Calling Standard Functions.............................................. 45
Syntax for Calling Standard Functions ........................ 46
Passing Parameters to a Function ................................ 47
Calling Custom Functions (QuickFunctions) .................. 48
Passing Parameters to a QuickFunction ...................... 49
Value Assignments and Operators................................... 49
Supported Operators ...................................................... 50
Setting the Evaluation Order of Operators .................. 57
Implicit Data Type Conversion...................................... 58
Examples for Expressions.............................................. 59
Using Conditional Program Branching Structures......... 60
Simple Conditional Structure........................................ 61
Nested Conditional Structure........................................ 61
Invalid Scripting Example (Missing ENDIF) ............... 61
Invalid Scripting Example (Incorrect Nesting) ............ 62
InTouch HMI Scripting and Logic Guide
671724734.003.png
Contents 5
Using Program Loops ........................................................62
Forcing the End of a Loop ..............................................64
Effect of Loops on other Run-Time Processes ...............64
Time Limit for Loop Execution ......................................65
Examples of Loops ..........................................................65
Using Local Variables .......................................................66
Declaring a Local Variable.............................................66
Naming Conflicts between Local Variables and Tags ..67
Chapter 5 Custom Script Functions ....................... 69
About QuickFunctions ......................................................69
Configuring QuickFunctions.............................................70
Calling QuickFunctions ....................................................72
Creating Asynchronous QuickFunctions .........................72
Limitations of Asynchronous QuickFunctions..............72
Checking if any Asynchronous QuickFunctions
are Running................................................................73
Stopping Asynchronous QuickFunctions from
Running ......................................................................74
Chapter 6 Built-In Functions ............................... 75
Forcing Updates in Animation Display Links .................75
Mathematical Calculations ...............................................76
Rounding, Truncating, and Determining Sign .............76
Using Trigonometric Functions .....................................79
Returning the Value of Pi ..............................................82
Calculating Logarithms .................................................82
Calculating the Square Root..........................................84
String Operations ..............................................................85
Returning Parts of Strings.............................................85
Changing Case of Strings...............................................87
Removing Spaces from Strings ......................................87
Formatting Strings with Spaces....................................89
Converting Between Characters and ASCII Codes ......89
Searching and Replacing Text in Strings .....................90
Returning Information about Strings ...........................94
Comparing Strings .........................................................96
Converting Data Types .....................................................98
Text() Function ...............................................................99
StringFromIntg() Function ..........................................100
StringFromReal() Function..........................................101
InTouch HMI Scripting and Logic Guide
671724734.004.png
Zgłoś jeśli naruszono regulamin