CitectSCADA 7.20 Cicode Reference Guide.pdf - v7.20 Cicode Reference Guide October 2010 Legal Notice DISCLAIMER Schneider Electric(Australia Pty Ltd

CitectSCADA 7.20 Cicode Reference Guide.pdf - v7.20 Cicode...

This preview shows page 1 out of 1284 pages.

Unformatted text preview: v7.20 Cicode Reference Guide October 2010 Legal Notice DISCLAIMER Schneider Electric (Australia) Pty. Ltd. makes no representations or warranties with respect to this manual and, to the maximum extent permitted by law, expressly limits its liability for breach of any warranty that may be implied to the replacement of this manual with another. Further, Schneider Electric (Australia) Pty. Ltd. reserves the right to revise this publication at any time without incurring an obligation to notify any person of the revision. COPYRIGHT © Copyright 2010 Schneider Electric (Australia) Pty. Ltd. All rights reserved. TRADEMARKS Schneider Electric (Australia) Pty. Ltd. has made every effort to supply trademark information about company names, products and services mentioned in this manual. Citect, CitectHMI, and CitectSCADA are registered trademarks of Schneider Electric (Australia) Pty. Ltd. IBM, IBM PC and IBM PC AT are registered trademarks of International Business Machines Corporation. MS-DOS, Windows, Windows NT, Microsoft, and Excel are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. DigiBoard, PC/Xi and Com/Xi are trademarks of Digi International Inc. Novell, Netware and Netware Lite are either registered trademarks or trademarks of Novell, Inc. in the United States and other countries.. dBASE is a trademark of dataBased Intelligence, Inc. All other brands and products referenced in this document are acknowledged to be the trademarks or registered trademarks of their respective holders. GENERAL NOTICE Some product names used in this manual are used for identification purposes only and may be trademarks of their respective companies. October 2010 edition for CitectSCADA Version v7.20 Manual Revision Version v7.20. Contact Schneider Electric (Australia) Pty. Ltd. today at Contents Legal Notice 2 Contents 3 Introduction 11 Safety Information 13 Chapter: 1 Introducing Cicode 15 Getting Started Using Cicode Files Using Cicode Chapter: 2 Using Cicode Commands Setting Variables Performing Calculations Using Multiple Command Statements Using Include (Text) Files Getting Runtime Operator Input Chapter: 3 Using Cicode Expressions 15 16 17 19 19 20 21 21 23 25 Displaying Data Using Expressions Decision-Making Logging Expression Data Triggering Events Using Expressions 25 26 26 27 Chapter: 4 Using Cicode Functions 29 3 Contents Calling Functions from Commands and Expressions Triggering Functions via Runtime Operator Input Evaluating Functions Combining Functions with Other Statements Passing Data to Functions (Arguments) Using String Arguments String assignment Using the Caret Escape Sequence Character Using Multiple Arguments Using Numeric Arguments Using Variable Arguments Using Operator Input in Functions Returning Data from Functions Chapter: 5 Working with Commonly Used Functions Alarm Functions Page Functions Keyboard Functions Report Functions Time/date Functions Miscellaneous Functions Chapter: 6 Writing Functions Cicode Function Structure Function Uses Writing Groups of Functions Cicode Function Libraries Creating a Function Outline Pseudocode Using Comments in Cicode Using Comments for Debugging Functions Tag Reference /TagReadEx() behavior in Cicode Expressions Following Cicode Syntax Cicode Function Syntax End of line markers Function Scope Declaring the Return Data Type Declaring Functions Naming Functions Function Argument Structure Declaring Argument Data Type Naming Arguments Setting Default Values for Arguments Returning Values from Functions Chapter: 7 Using Variables Declaring Variable Properties 4 29 29 30 30 31 31 32 32 33 33 33 34 34 35 35 36 37 37 37 37 39 39 40 41 41 42 42 43 44 44 45 46 48 48 49 50 51 52 54 55 56 58 61 61 Contents Declaring the Variable Data Type QUALITY Data Type TIMESTAMP Data Type Naming Variables Setting Default Variable Values Using Variable Scope Using Database Variables Chapter: 8 Using Arrays Declaring Array Properties Declaring the Array Data Type Naming Arrays Declaring the Variable Array Size Setting Default (Initial) Array Values Passing Array Elements as Function Arguments Using One-dimensional Arrays Using Two-dimensional Arrays Using Three-dimensional Arrays Using Array Elements in Loops Using the Table (Array) Functions Chapter: 9 Using Cicode Macros IFDEF IFDEFAdvAlm IFDEFAnaAlm IFDEFDigAlm Macro Arguments Chapter: 10 Converting and Formatting Cicode Variables Converting Variable Integers to Strings Converting Real Numbers to Strings Converting Strings to Integers Converting Strings to Real Numbers Formatting Text Strings Escape Sequences (String Formatting Commands) Chapter: 11 Working with Operators Using Mathematical Operators Using Bit Operators Using Relational Operators Using Logical Operators Order of Precedence of Operators Chapter: 12 Working with Conditional Executors Setting IF ... THEN Conditions 62 62 63 63 64 64 66 67 67 68 68 68 69 70 70 70 71 72 72 73 73 74 75 77 78 79 79 80 81 81 81 83 85 85 87 88 89 90 91 91 5 Contents Using FOR ... DO Loops Using WHILE ... DO Conditional Loops Nested Loops Using the SELECT CASE statement Chapter: 13 Performing Advanced Tasks Handling Events How Cicode is Executed Multitasking Foreground and background tasks Controlling tasks Pre-emptive multitasking Chapter: 14 Editing and Debugging Code The Cicode Editor Starting the Cicode Editor Changing the default Cicode Editor Creating Cicode files Creating functions Saving files Opening Cicode files Deleting Cicode files Finding text in Cicode files Compiling Cicode files Viewing errors detected by the Cicode Compiler Cicode Editor Options Docking the Windows and Toolbars Displaying the Editor Options Properties dialog Windows and Bars Tab Toolbar options Window options Viewing Editor windows Options Properties Tab Language Formatter Properties Tab Debugging Cicode Using debug mode Debugging functions Debugging functions remotely Using breakpoints Inserting or removing breakpoints Enabling/disabling breakpoints Stepping through code Chapter: 15 Using Cicode Programming Standards Variable Declaration Standards Variable Scope Standards Variable Naming Standards 6 92 93 93 94 97 97 98 99 99 100 100 103 103 104 105 106 106 106 107 108 108 108 109 109 109 110 111 111 111 112 117 119 120 120 120 121 122 122 122 123 125 126 126 127 Contents Standards for Constants, Variable Tags, and Labels Formatting Simple Declarations Formatting Executable Statements Formatting Expressions Cicode Comments Formatting Functions Format Templates Function Naming Standards Modular Programming Defensive Programming Function Error handling Debug Error Trapping Functions Reference Chapter: 16 Accumulator Functions Accumulator Functions Chapter: 17 ActiveX Functions ActiveX Functions Chapter: 18 Alarm Functions Alarm Functions Chapter: 19 Clipboard Functions Clipboard Functions Chapter: 20 Cluster Functions Cluster Functions Chapter: 21 Color Functions Color Functions Chapter: 22 Communication Functions Communication Functions Chapter: 23 Dynamic Data Exchange Functions DDE Functions Chapter: 24 Device Functions 128 129 130 131 132 132 134 136 138 141 142 145 147 149 149 157 157 171 171 281 281 285 285 285 293 293 299 299 307 307 323 7 Contents Device Functions Chapter: 25 Display Functions Display Functions Chapter: 26 DLL Functions DLL Functions Equipment Database Functions Chapter: 27 Error Functions Error Functions Chapter: 28 Event Functions Event Functions Chapter: 29 File Functions File Functions Chapter: 30 Form Functions Form Functions Chapter: 31 Format Functions Format Functions Chapter: 32 FTP Functions FTP Functions Chapter: 33 FuzzyTech Functions FuzzyTech Functions Chapter: 34 Group Functions Group Functions Chapter: 35 I/O Device Functions I/O Device Functions Chapter: 36 Keyboard Functions Keyboard Functions Chapter: 37 Mail Functions 8 323 353 353 447 447 452 461 461 475 475 493 493 513 513 553 553 563 563 569 569 577 577 587 587 599 599 615 Contents Mail Functions Chapter: 38 Math and Trigonometry Functions Math/Trigonometry Functions Chapter: 39 Menu Functions Menu Functions Chapter: 40 Miscellaneous Functions Miscellaneous Functions Chapter: 41 Page Functions Page Functions Chapter: 42 Plot Functions Plot Functions Chapter: 43 Process Analyst Functions Process Analyst Functions Chapter: 44 Quality Functions Quality Functions Chapter: 45 Report Functions Report Functions Chapter: 46 Security Functions Security Functions Chapter: 47 Server Functions Server Functions Chapter: 48 Statistical Process Control Functions SPC Functions Chapter: 49 SQL Functions SQL Functions Chapter: 50 String Functions 615 621 621 639 640 657 657 711 711 751 751 773 773 781 781 795 795 801 801 827 827 843 843 859 859 885 9 Contents String Functions Chapter: 51 Super Genie Functions Super Genie Functions Chapter: 52 Table (Array) Functions Table (Array) Functions Chapter: 53 Tag Functions Tag Functions Chapter: 54 Task Functions Task Functions Chapter: 55 Time and Date Functions Time/Date Functions Chapter: 56 Timestamp Functions Timestamp Functions Chapter: 57 Trend Functions Trend Functions Chapter: 58 Window Functions Window Functions Technical Reference Chapter: 59 Cicode Errors Hardware/Cicode Errors Cicode and General Errors MAPI Errors Chapter: 60 Browse Function Field Reference Server Browse Function Fields Index 10 885 915 915 951 951 957 957 999 999 1041 1041 1063 1063 1079 1079 1177 1177 1215 1217 1217 1218 1238 1241 1253 1255 Part: 1 Introduction This section provides some introductory material for CitectSCADA: Introducing Cicode 11 12 Safety Information Safety Information Hazard categories and special symbols The following symbols and special messages may appear in this manual or on the product to warn of potential hazards or to call attention to information that clarifies or simplifies a procedure. A lightning bolt or ANSI man symbol in a "Danger" or "Warning" safety label on the product indicates an electrical hazard which, as indicated below, can or will result in personal injury if the instructions are not followed. The exclamation point symbol in a safety message in a manual indicates potential personal injury hazards. Obey all safety messages introduced by this symbol to avoid possible injury or death. Symbol Name Lightning Bolt ANSI man Exclamation Point DANGER indicates an imminently hazardous situation, which, if not avoided, will result in death or serious injury. WARNING indicates a potentially hazardous situation, which, if not avoided, can result in death or serious injury. CAUTION indicates a potentially hazardous situation which, if not avoided, can result in minor or moderate injury. 13 Safety Information CAUTION CAUTION used without the safety alert symbol, indicates a potentially hazardous situation which, if not avoided, can result in property damage. Please Note Electrical equipment should be installed, operated, serviced, and maintained only by qualified personnel. No responsibility is assumed by Schneider Electric (Australia) Pty. Ltd. for any consequences arising out of the use of this material. Before You Begin CitectSCADA is a Supervisory Control and Data Acquisition (SCADA) solution. It facilitates the creation of software to manage and monitor industrial systems and processes. Due to CitectSCADA's central role in controlling systems and processes, you must appropriately design, commission, and test your CitectSCADA project before implementing it in an operational setting. Observe the following: UNINTENDED EQUIPMENT OPERATION Do not use CitectSCADA or other SCADA software as a replacement for PLC-based control programs. SCADA software is not designed for direct, high-speed system control. Failure to follow these instructions can result in death, serious injury, or equipment damage. LOSS OF CONTROL l l l l The designer of any control scheme must consider the potential failure modes of control paths and, for certain critical control functions, provide a means to achieve a safe state during and after a path failure. Examples of critical control functions are emergency stop and overtravel stop. Separate or redundant control paths must be provided for critical control functions. System control paths may include communication links. Consideration must be given to the implications of unanticipated transmission delays or failures of the link.* Each implementation of a control system created using CitectSCADA must be individually and thoroughly tested for proper operation before being placed into service. Failure to follow these instructions can result in death, serious injury, or equipment damage. * For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety Guidelines for the Application, Installation, and Maintenance of Solid State Control". 14 Chapter: 1 Introducing Cicode Cicode is a programming language designed for use in CitectSCADA to monitor and control plant equipment. It is a structured language similar to Visual Basic or 'C'. You need no previous programming experience to use it. Using Cicode, you can access real-time data (variables) in the CitectSCADA project, and CitectSCADA facilities: variable tags, alarms, trends, reports, and so on. You can use Cicode to interface to various facilities on the computer, such as the operating system and communication ports. Cicode supports advanced features including pre-empted multitasking, multi threads, and remote procedure calls. Getting Started Use the following sections as a quick start to using Cicode in your CitectSCADA projects: l Cicode can be stored in procedures called functions for multiple reuse and centralized maintenance. For details, see Using Cicode Files. l Cicode can be typed directly into command fields in online CitectSCADA forms. For details, see Using Cicode Commands. l Cicode expressions are used to display and log data for monitoring and analysis, and to trigger various elements in your system, such as alarms, events, reports, and data logging. For information on using expressions, see Using Cicode Expressions. l A Cicode function is a small program, a collection of statements, variables, operators, conditional executors, and other functions. A Cicode function can perform complex tasks and give you access to CitectSCADA graphics pages, alarms, trend data, and so on. For information on using functions, see the section titled Using Cicode Functions. Cicode has many pre-defined functions that perform a variety of tasks. For details on commonly used functions, see the section titled Working with Commonly Used Functions. Where system functionality cannot be achieved with built-in functions, you can write your own functions. See Writing Functions. l The Cicode Editor is the code editing tool provided with CitectSCADA for the writing, editing and debugging of your Cicode code. For details, see The Cicode Editor. See Also Performing Advanced Tasks Using Cicode Programming Standards 15 Chapter: 1 Introducing Cicode Using Cicode Files You write your Cicode functions in Cicode source files, stored on your hard disk. Cicode files are identified by having a *.CI extension. To minimize potential future difficulties with maintaining your Cicode files, adopt a programming standard as early as possible (see Using Cicode Programming Standards). Maintain structured Cicode files, by logically grouping your Cicode functions within the files, and by choosing helpful descriptive names. For details about modular programming methods, see Modular Programming. For details about using and debugging Cicode functions, see Formatting Functions and Debugging Cicode respectively. When you compile your CitectSCADA project, the compiler reads the functions in your Cicode source files. Your system can then use these functions in the same way as it uses built-in functions. You can use as many Cicode files as required. Cicode files reside in the same directory as your CitectSCADA project. When you back up your project, the Cicode source files in the project directory are also backed up. See Also The Cicode Editor Creating Cicode files Opening Cicode files 16 Part: 2 Using Cicode This section contains information for Users and describes the following: Using Cicode Commands Using Cicode Macros Using Cicode Expressions Converting and Formatting Cicode Variables Using Cicode Functions Working with Operators Working with Commonly Used Functions Working with Conditional Executors Writing Functions Performing Advanced Tasks Using Variables Editing and Debugging Code Using Arrays Using Cicode Programming Standards 17 18 Chapter: 2 Using Cicode Commands Cicode commands extend the control element of a CitectSCADA control and monitoring system. You use commands to control your CitectSCADA system and therefore the processes in your plant. Each command has a mechanism to activate it. Commands can be issued manually, through an operator typing a key sequence, or by clicking on a button (or object) on a graphics page. You can also configure commands to execute automatically: l When an operator logs into or out of the runtime system l When a graphics page is displayed or closed l When an alarm is triggered l In a report l When an event is triggered To define a Cicode command, you enter a statement (or group of statements) in the command field (Input category) for an object. Each statement in a command usually performs a single task, such as setting a variable to a value, calculating a value, displaying a message on the screen, or running a report. For information on using variables, see the section titled Using Variables. If you want to evaluate a condition, like checking the state of your plant rather than perform an action or command upon your plant, use an expression instead. See the section titled Using Cicode Expressions. See Also Using Cicode Programming Standards Setting Variables You can set a Variable in CitectSCADA within a Command field, an Expression field, or in a Cicode Function, by using the mathematical 'equals' sign ( = ) assignment operator. The value on the right is assigned (set) to the variable on the left, as shown in the following Cicode example : <VAR_TAG> = Val; where: 19 Chapter: 2 Using Cicode Commands <VAR_TAG> is the name of the variable, and Val is the value being assigned to the variable. Examples To set a digital variable (named BIT_1) to ON (1), use the command: BIT_1 = 1; To set a digital variable (named BIT_1) to OFF (0), use the command: BIT_1 = 0; To set a digital variable (named B1_PUMP_101_M) to ON (1), use the command: B1_PUMP_101_M = 1; To set a digital variable (named B1_PUMP_101_M) to OFF (0), use the command: B1_PUMP_101_M = 0; To set an analog variable (named B1_TIC_101_SP) to a value of ten (10), use the command: B1_TIC_101_SP = 10; You can copy a variable to another by assigning (setting) the value of a variable to the value of another variable, for example: B1_PUMP_101_COUNT = B1_PUMP_101_CLIMIT; The value of B1_PUMP_101_COUNT is set to the value of B1_PUMP_101_CLIMIT only when that command is issued. Note: The value of B1_PUMP_101_CLIMIT could change immediately after, but B1_ PUMP_101_COUNT remains unchanged and storing the original value, until this command is issued again. Performing Calculations Mathematical calculations can be performed between variables in a Cicode statement. For example: 20 Chapter: 2 Using Cicode Commands B1_TIC_101_SP = B1_TIC_101_PV + B1_TIC_102_PV - 100; When this command is executed, the variable B1_TIC_101_SP is set to a value that is the sum of variables B1_TIC_101_PV and B1_TIC_102_PV minus 100. Using Multiple Command Statements A single statement in a Cicode command usually performs a single task. When the CitectSCADA runtime system is in operation, the statement executes whenever the command is requested. For example, if the statement is linked to a keyboard command, the task is performed when an operator presses the keyboard key defined as that command. To perform several tasks at the same time, yo...
View Full Document

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture