Citect™ SCADA
Programming with Cicode
Study Guide
2016
Schneider-Electric Pty (Australia) Ltd
78 Waterloo Road
Macquarie Park
NSW 2113
Australia
DISCLAIMER
Schneider Electric makes no representations or warranties with respect to this study guide 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 study guide with another. Furthermore, Schneider Electric reserves the right to revise this
publication at any time without incurring an obligation to notify any person of the revision.
The information provided in this documentation contains general descriptions and/or technical characteristics of the performance of the products contained herein.
This documentation is not intended as a substitute for and is not to be used for determining suitability or reliability of these products for specific user applications. It is
the duty of any such user or integrator to perform the appropriate and complete risk analysis, evaluation and testing of the products with respect to the relevant specific
application or use thereof. Neither Schneider Electric nor any of its affiliates or subsidiaries shall be responsible or liable for misuse of the information that is
contained herein. If you have any suggestions for improvements or amendments or have found errors in this publication, please notify us.
All pertinent state, regional, and local safety regulations must be observed when installing and using this product. For reasons of safety and to help ensure compliance
with documented system data, only the manufacturer should perform repairs to components.
When devices are used for applications with technical safety requirements, the relevant instructions must be followed.
Failure to use Schneider Electric software or approved software with our hardware products may result in injury, harm, or improper operating results.
Failure to observe this information can result in injury or equipment damage.
© 2016 Schneider Electric. All rights reserved.
INTRODUCTION AND LEGAL NOTICE
Satisfactory completion of the course evaluation is mandatory for you to obtain a Schneider Electric certificate of completion of the training course.
The contents of this study guide are proprietary to Schneider Electric and all rights, including copyright, are reserved by Schneider Electric. No part of this document
may be reproduced in any form or by any means, electronic or mechanical, including photocopying, without express written permission of Schneider Electric.
Schneider Electric will not accept any liability for action taken in reliance on this training study guide.
TRADEMARKS
Schneider Electric has made every effort to supply trademark information about company names, products and services mentioned in this study guide. Trademarks
shown below were derived from various sources.
Vijeo Citect, Citect SCADA, CitectSCADA, Cicode, Vijeo Historian, CitectHistorian, and Ampla are trademarks owned by Schneider Electric Industry SAS or its
affiliated companies. All other trademarks are the property of their respective owners.
ActiveX, Excel, Internet Explorer, Microsoft .NET, SQL Server, Windows, Windows Server, Windows XP, Windows Vista, Windows 7 and Windows 8 are either
registered trademarks or trademarks of Microsoft® Corporation in the United States and/or other countries.
SafeNet Sentinel is a trademark of Sentinel, Inc.
VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions.
General Notice:
Some product names used in this study guide are used for identification purposes only and may be trademarks of their respective companies.
Validity Note
The present documentation is intended for qualified technical personnel responsible for the implementation, operation and maintenance of the products described. It
contains information necessary for the proper use of the products.
Electrical equipment should be installed, operated, serviced, and maintained only by qualified personnel. No responsibility is assumed by Schneider Electric for any
consequences arising out of the use of this material.
A qualified person is one who has skills and knowledge related to the construction and operation of the electrical equipment and installations and has received safety
training to recognize and avoid the hazards involved.
November 2016 Edition for Citect SCADA 2016
ii Citect SCADA 2016 - Cicode Exam
Contents
CHAPTER 1: 2016 CICODE PROGRAMMING EXAM TOPICS OVERVIEW .............. 1-1
Cicode Development Environment ................................................................................ 1-2
Function Structure.......................................................................................................... 1-3
Variables, Datatypes and Data Structures...................................................................... 1-4
Logic .............................................................................................................................. 1-5
Statements ...................................................................................................................... 1-6
Input and Output ............................................................................................................ 1-7
Flow Control .................................................................................................................. 1-8
Programming Standards ................................................................................................. 1-9
Citect SCADA 2016 - Cicode Exam iii
Chapter 1: 2016 Cicode Programming Exam Topics
Overview
Introduction
Cicode Programming is the second of the CSCE exams. This exam is based around
information that is covered in the Cicode Programming Course.
This Chapter Covers These Topics:
The Cicode Development Environment
Introduction to Programming
Function Structure
Variables and Datatypes
Logic and Statements
Input and Output
Flow Control
Complex Data Structures
Programming Standards
Citect SCADA 2016 - Cicode Exam 1-1
Cicode Development Environment
Programming Language
Cicode is a simple, easy-to-use computer programming language designed especially for
plant monitoring and control applications. It is a structured language similar to Visual Basic
or 'C', however you need no previous programming experience to use it.
Using Cicode, you have access to all real-time data (variables) in the Citect SCADA project,
and all Citect SCADA facilities - variable tags, alarms, trends, reports, and so on. You can
use Cicode to interface to various resources on the computer, such as the operating system
and communication ports.
Cicode supports advanced features including pre-emptive multi-tasking, multi-threads, and
remote procedure calls that will be discussed later in this course.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Create and save Cicode function libraries.
Experiment with the automated layout functionality within the editor.
Use comments to disable sections of cicode.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - The Cicode Editor.
1-2 Citect SCADA 2016 - Cicode Exam
Function Structure
User Functions
Citect SCADA is supplied with over 600 in-built functions. One or a combination of these
functions can usually perform most tasks in your system. However, where system
functionality cannot be achieved with in-built functions, you can write your own functions.
A Cicode function is a small program that may contain a collection of statements, variables,
operators, conditional executors, and functions, in fact, of all the elements of Cicode.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Revise the syntax of Cicode functions.
Make a small Cicode program to create a standard Microsoft ActiveX Listbox at
runtime, and fill this listbox with three items, and then select one of these items,
and then store the value of the item in a DiskPLC variable.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Cicode Function syntax.
Citect SCADA Help Topic - Converting and Formatting Cicode Variables.
Citect SCADA 2016 - Cicode Exam 1-3
Variables, Datatypes and Data Structures
Operators
Cicode is used to manipulate data and perform tasks. Data manipulation is achieved using
five classes of operators. These are the Mathematical, Bit, Logical, Relational and Format
operators.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Review the Cicode Programming Training manual.
Create Global, Module and Local variable declarations along with assigning
default values to the declared variables.
Determine maximum array size limits.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Using Variables.
Citect SCADA Help Topic - Using Arrays.
Citect SCADA Help Topic - Variable declaration.
1-4 Citect SCADA 2016 - Cicode Exam
Logic
Use of Logic in Cicode
Cicode supports the use of all major Logical operators: AND, OR, XOR, NOT.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Create simple logic statements to test the order of precedence and also to be sure
that you understand how statements are executed.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Using Logical Operators
Citect SCADA 2016 - Cicode Exam 1-5
Statements
Doing the Work
Statements are used to execute Cicode Functions and also to assign values (or the results of
Cicode Functions) to variables and to Variable Tags.
Statements also include the ability to exchange information between variable of differing
datatypes - for instance converting an Integer to a String or vice versa.
The various operators (addition, subtraction, multiplication etc) have an order of precedence
(they are not executed left-to-right or right-to-left)
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Review the Order of Precedence of Operators.
Create Cicode fragments to assign values and call functions.
Confirm your knowledge of datatype conversion functions.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Working with Operators.
Citect SCADA Help Topic - Converting and Formatting Cicode Variables.
Citect SCADA Help Topic - Order of Precedence of Operators.
1-6 Citect SCADA 2016 - Cicode Exam
Input and Output
Interact with the Operator
In addition to acting on data sourced from the plant via Variable Tags, there are occasions
when it is necessary to interact with the operator in order to either request values (perhaps
the name of the next recipe or the adjusted setpoint value for some parameter) or to provide
other information - often via the prompt field on the screen.
Generally, the Input and the Prompt Cicode functions are used for this, although others are
also available.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Understand the datatype of the various input and output functions and be
familiar with how to ensure data is sent or received in the necessary datatype.
Be familiar with key sequences for data input.
Test the use of the ArgX and ArgValueX items.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Defining Key Sequences for Commands.
Citect SCADA Help Topic - Input.
Citect SCADA Help Topic - Prompt.
Citect SCADA Help Topic - FormNumPad.
Citect SCADA 2016 - Cicode Exam 1-7
Flow Control
Four Conditional Executors
The statements that control decisions and loops in your functions are called conditional
executors. Cicode uses four conditional executors: IF, FOR, WHILE and SELECT CASE.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Review the syntax of the four types of Conditional Executor in Cicode.
Create functions that test the functionality of the Conditional Executors.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Working with Conditional Executors.
1-8 Citect SCADA 2016 - Cicode Exam
Programming Standards
Fundamentals of Good Design
One of the critical aspects to follow on from the earlier concepts of Error Handling and
Defensive Programming is "Good Design."
the better designed your software is, the easier it will be to deal with errors and exceptions.
Software should be written with as much of the code hidden as PRIVATE functions in order
to not accidentally call functions which have not been configured for global use. Similarly,
unless a variable must be made available globally, it should be declared as a MODULE
variable or even kept local to a function.
Suggested Exercises
Use these suggested exercises to increase your understanding of the topic.
Experiment with declaring PUBLIC and PRIVATE Functions.
Investigate the difference between Blocking and Non-Blocking functions.
Read widely on programming techniques.
Further Reading
Use the following references to assist your understanding of the topic.
Citect SCADA Help Topic - Function Scope.
Citect SCADA Help Topic - Formatting Functions.
Citect SCADA 2016 - Cicode Exam 1-9