Sunteți pe pagina 1din 78

MicroSCADA

P287 SCIL Programming


Basics

ABB Oy Distribution Automation


NAME RESP.DEPT. PREPARED
SCIL Programming Basics FISUB/RAE 24.08.2007 H.H.
COURSE ID LANGUAGE CHECKED
P287 En 05.09.2007 R.K.
REVISION APPROVED
A 05.09.2007 M.M.

© ABB Oy P287 EN
1MRS751492-MTR
Table of Contents

1 General Information

2 Introduction

3 Programming Environment

4 SCIL Tools

5 Data Types and Objects

6 Variables and Expressions

7 Commands and Functions

8 The SCIL Compiler

9 Exercises
Contents of Chapter 1

1 General Information
1.1 Course Schedule
1.2 Notice
1.3 Definitions and Abbreviations
1.4 Course Presentation
Course Schedule

Day 1
9:00 Introduction
Programming environment
SCIL tools
Data types and objects
Variables and expressions
Exercises 1 - 3
11:45 Lunch
13:00 Commands and functions
Exercises 4 - 8
SCIL compiler
16:00 Course ends
Notice

These documents have been assembled and produced for


educational purposes. The contents of your course binder will not be
updated to include future amendments.

We appreciate your comments on our course documents. On the


basis of practical experience and your feedback we can improve our
courses in the future.

The information in this document is subject to change without notice


and should not be construed as a commitment by ABB. ABB
assumes no responsibility for any errors that may appear in this
document.

This document and parts thereof must not be reproduced or copied


without ABB’s written permission, and the contents thereof must not
be imparted to a third party nor be used for any unauthorized
purpose.

Participation in a course is not only passive receiving of information


but it requires activity on your part. Our courses contain several
practical exercises. Make use of these opportunities to test and
acquire familiarity with the equipment and aids used.

As a user of our training equipment, you must follow carefully the


instructions given during the course.

In no event shall ABB be liable for direct, indirect, special, incidental


or consequential damages of any nature arising from the use of this
document, nor shall ABB be liable for incidental or consequential
damages arising from the use of any software or hardware described
in this document.

With best wishes for a rewarding course.

ABB Oy Distribution Automation


Training Team

Copyright © ABB Oy Distribution Automation


Definitions and Abbrevations

The following concepts and abbreviations appear in the course material.

CAP 501 Relay Setting Tool Package

CAP 505 Relay Configuration and Setting Tools Package

COM 500 COM 500 communication server (gateway)

DCP-NET Communication card with own processor, memory and communicaton


software

DDE Dynamic Data Exchange

DMS Distribution Management System

DTU Disconnector Terminal Unit for remotely controllable disconnector


substations

EDM Energy Data Management System

FA Feeder Automation

HMI Human-machine interface. The front panel of the relay

IT Information Technology

LAN Local Area Network

LIB 500 Standard Application Library, platform supporting the process-specific LIB
5xx packages

LIB 510 Standard Application Library for medium voltage level

LMS Load Management System

LNT 505 LON Network Tool for installing and configuring devices to the LonWorks
network

LON Local Operating Network

MicroSCADA The name of the technology used in most of the System and Engineering
products by ABB Oy Distribution Automation, “common denominator” in
the software kernel

MMC Man-machine communication

MV Medium voltage

NCS Network Control System

NET Communication unit which can be either software running on the operating
system or software running on a separate communication card

ODBC Open Database Connectivity


OLE Object Linking and Embedding

OPC OLE for Process Control is an industry standard based on the


OLE/COM/DCOM technology of Microsoft Inc. The standard creates a
common interface for communication between various devices controlling
technological processes

PCLTA PC LonTalk Adapter card which functions as a LonWorks network


interface card for a PC

PC-NET Communication software running on the Windows operating system

PLC Programmable Logic Controller

RAS Remote Access Service

RED A relay product family provided by ABB Oy, Distribution Automation

REF 543 Feeder terminal for the protection, control, measurement and supervision
of medium voltage networks

RTU Remote Terminal Unit

SA Substation Automation System

SCADA Supervisory control and data acquisition system

SCIL Supervisory Control Implementation Language

SM On-Line Substation Monitoring

SMS Substation Monitoring System

SPA Strömberg Protection Acquisition. Communication protocol developed for


SPACOM relays

SPACOM A relay product family provided by ABB Oy, Distribution Automation

SRIO SRIO 500M/1000M is a data communication and reporting unit for the
SPACOM system. The task of the SRIO unit is to form the master unit of
the SPA bus and connect the SPACOM system to a host computer

SYS 500 SYS 500 System Server is a system product based on the MicroSCADA
technology. The system server contains data acquisition, supervising and
controlling functions

TCP/IP Transmission Control Protocol/Internet Protocol

Visual SCIL The method for designing and programming user interface dialogs with
Visual SCIL objects and commands is named “Visual SCIL”
Course Presentation

The aim of the course is to familiarize the participants with the SCIL syntax and basic
programming techniques.

Objectives Prerequisites
After this course the participant will be Basic knowledge of MicroSCADA and
able to: programming techniques.

„ use SCIL in object handling and


Topics
calculations
„ write simple programs in SCIL „ SCIL programming environment
„ SCIL commands and functions
„ Data types and objects
Participant profile „ Variables and expressions
System engineers, maintenance „ Programming exercises
engineers and persons who edit, build
or maintain MicroSCADA systems.
Contents of Chapter 2

2 Introduction
2.1 What is SCIL?
2.2 What can you do with SCIL?
2.3 SCIL related manuals
Introduction
2.1 What is SCIL?
„ SCIL is a high level language especially designed for the application
engineering of the supervisory control system MicroSCADA.

Supervisory
Control
Implementation
Language
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Introduction
2.2 What can you do with SCIL?
„ With SCIL,
SCIL it is basically possible to control the entire MicroSCADA
system.
„ Application related features
„ Configuration related features
„ Communication related features

„ Some examples of what you can do with MicroSCADA:


„ Design various forms of process control
„ Configure, supervise and handle system components
„ Build process simulations
287(En), 2
92-MTR
ABB Oy, P2
1MR751 49
Introduction
2.3 SCIL related manuals
„ The main manual when dealing with SCIL
programming is the SYS 600 Programming
Language SCIL manual
„ There are also two manuals dealing with
Visual SCIL programming, Visual SCIL
Application
pp Design
g and Visual SCIL Objects
j
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 3

3 Programming Environment
3.1 Occurrence of SCIL programs
3.2 SCIL program structure
3.3 SCIL program components
3.4 Programming in SCIL
3.5 Activating SCIL programs
3.6 Special characters
3.7 SCIL names
Programming Environment
3.1 Occurrence of SCIL Programs
„ In MicroSCADA Pro applications SCIL programs mainly appear in:
„ Command procedures
„ Dialogs
g and dialog
g items ((Visual SCIL))

„ In Classic Monitor applications,


pp
SCIL programs can also occur
in picture programs.
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Programming Environment
3.2 SCIL Program Structure
„ A SCIL program can contain up to 1000000 lines
lines, and each line up to
65535 characters (including spaces).
„ A minus sign (-) at the end of a SCIL line indicates that the statement
continues on the next line.
„ A line may be divided anywhere
where spaces are allowed
allowed, but not ;comment 1
within text constants. #loop_with- ;comment 2
i = 1..10
„ Comments are preceded with a :
semicolon ( ; ), which indicates :
that the rest of the line is a comment. #loop_end
„ If a semicolon is enclosed quotation
marks (“;”) it is regarded as text.
287(En), 2
92-MTR
ABB Oy, P2
1MR751 49
Programming Environment
3.2 SCIL Program Structure
„ Statements are not numbered and empty lines are allowed anywhere in
the program.
„ Upper and lower case letters may be freely intermixed.
„ The SCIL programs do not demand any initiating or terminating
statements, neither any kind of declarations.

@i_Number=123

#iF %i_nUMBER>100 #Then #bLoCk


:
:
#block_END
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49

Programming Environment
3.3 SCIL Program Components
„ A SCIL program is composed of some or all of the following components:
„ Commands
„ These are words with a pre-declared meaning constituting
orders to the system about steps to be taken
„ Objects
„ System application and user interface objects
System,
„ Variables
„ Variables are facilities for the temporary storage
and use of changing data
„ Function calls
„ Expressions
„ Expressions are formulas which can contain constants,
287(En), 4
92-MTR

object notations, variables, function calls and operators


ABB Oy, P2
1MR751 49
Programming Environment
3.4 Programming in SCIL
„ Most SCIL programming is carried out while the MicroSCADA system is
running.
„ During program editing the system does not perform any SCIL syntax
error control.
„ The Test Dialog is the main tool for testing SCIL programs, statements
and expressions.
expressions
287(En), 5
92-MTR

SCIL editor Test Dialog


ABB Oy, P2
1MR751 49

Programming Environment
3.5 Activating SCIL Programs
„ There are a number of ways in which a SCIL program can be started.
started
Some of the more common are:
„ Command procedures started automatically by real or simulated process
events, by time or from other SCIL programs
„ Visual SCIL dialogs can contain programs which are started automatically
g is entered or exited,, periodically
when a dialog p y with a certain time interval,, and
on the occurrence of a process event
„ User activated function keys in displays or buttons in Visual SCIL dialogs
287(En), 6
92-MTR
ABB Oy, P2
1MR751 49
Programming Environment
3.6 Special characters

- continuation of program line + plus sign


* multiplication
p ** exponential
p operator
p
/ separator in picture paths \ separator in Visual SCIL object paths
( left bracket ) right bracket
, marks an enumeration . marks graphics or Motif command
.. marks an index interval “ encloses text
@ precedes a variable name by % precedes a variable name by use
assignment ‘ indicates variable expansion
# precedes a control command : follows an object name
! precedes a picture
p p command ; starts a comment
= assignment == equal to
> greater than >= greater than or equal to
< less than <= less than or equal to
<> not equal
q to ^ marks an octal number
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

Programming Environment
3.7 SCIL names
„ Names (e.g.
(e g variable and object names) in SCIL can be freely chosen
chosen.
„ There are however a few naming rules:
„ Names may be up to 63 characters long (except for names of pictures,
windows and logical paths which may only be up to 10 characters).
„ Allowed characters are A-Z, 0-9 and underscore ( _ ).
„ The first character of the name must be a letter (A - Z).
„ Application object names can also include periods ( . ) and start with a digit
(this however is not recommended).
287(En), 8
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 4

4 SCIL Tools
4.1 SCIL editor
4.2 Test dialog
4.3 Other tools
SCIL Tools
4.1 SCIL Editor
„ The SCIL editor is a text editor designed for editing text files and SCIL
programs.
„ In addition to the ordinary text editing functions, there are tools for
assisting design of
SCIL program code.
„ The SCIL editor is accessed
from the tool manager or
from different tools (Command
P
Procedure
d Edit
Editor,
Dialog Editor, etc.)
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

SCIL Tools
4.1 SCIL Editor

Indent / Comment /
Unindent Uncomment
287(En), 2
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.1 SCIL Editor

Insert SCIL Commands,


F
Functions
i & Objects
Obj
287(En), 3

Check Syntax
92-MTR
ABB Oy, P2
1MR751 49

SCIL Tools
4.1 SCIL Editor
„ The Find Block function searches for the following Block commands
downwards in the program starting from the cursor:
„ #BLOCK .... #BLOCK_END
„ #LOOP .... #LOOP_END
„ #CASE .... #CASE_END

Find Block
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.1 SCIL Editor
„ The Compilation in Use function is available
only when the calling tool supports program
compilation.
„ Toggling the item turns the auto-
compilation on and off.
287(En), 5
92-MTR
ABB Oy, P2
1MR751 49

SCIL Tools
4.2 Test Dialog
„ The Test Dialog is used for testing purposes (examining data structures
structures,
finding out variable values and executing
SCIL programs).
„ The Test Dialog has several
notebook pages for different
gp
testing purposes.
p
287(En), 6
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.2 Test Dialog
„ When an error appears in the Test Dialog
Dialog, the status code and and
message is displayed on the status line.
„ The status line also contains information about how many variables are
being updated and how many programs are being executed.
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

SCIL Tools
4.2 Test Dialog
„ The command lines are used for
executing SCIL commands.
„ The commands are executed by pressing
the execute button or by pressing enter.

„ The fields are used for examining the data


type and value of SCIL expressions
expressions.
„ The expressions can be automatically
updated
p once a second byy checking
g
the Update check box.
287(En), 8
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.2 Test Dialog
„ The multifield is used for examining values of multivariables (vectors and
byte strings).
„ The index column contains the vector index, the value column contains
the value for the specific index.
„ The status column displays the validity information of the value
(OK STATUS(0) NOT_SAMPLED_STATUS(10)).
(OK_STATUS(0), NOT SAMPLED STATUS(10))
287(En), 9
92-MTR
ABB Oy, P2
1MR751 49

SCIL Tools
4.2 Test Dialog
„ The programs page is used for creating and executing SCIL programs
programs.
„ The programs are executed once by pressing the Do Once button and
sequentially by entering a value in the Interval/s field and checking the
Update check box.
„ The SCIL editor for the selected program is opened with the Edit button
on the same line as the program
program.
287(En), 10
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.2 Test Dialog
„ The examine page is used for examining all types of SCIL expressions
expressions.
„ Vector and list type expressions are displayed as nodes in the text box.
„ The following icons indicates different data types:

Integer List

Text Bit String

Time Boolean

Real Byte String


287(En), 11
92-MTR

Vector
ABB Oy, P2
1MR751 49

SCIL Tools
4.2 Test Dialog
„ The objects page displays the SCIL context hierarchy in the current
windows system.
„ For each Visual SCIL object, the object name and object type is
displayed.
„ Test Dialog itself with its variables, including its child objects and their
user defined and predefined attributes
attributes, are removed from the tree
structure.
287(En), 12
92-MTR
ABB Oy, P2
1MR751 49
SCIL Tools
4.3 Other Tools

Dialog Editor
(Visual SCIL)

Picture Editor
((classic monitor))
287(En), 13
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 5

5 Data Types and Objects


5.1 General
5.2 Integer
5.3 Real
5.4 Boolean
5.5 Time
5.6 Text
5.7 Bit string
5.8 Byte string
5.9 Vector
5.10 List
5.11 Object categories
5.12 Attributes and methods
5.13 Object handling
5.14 Object notation
Data Types and Objects
5.1 General
„ In SCIL there are six types of simple data Integer
(data constituted of single values): Real
Boolean
„ The data type vector represents a string
Time
of data items, and the data type list Text
represents a list of attributes and Bit String
attribute values.
Vector
„ Every SCIL expression is associated
List
with one of these eight data types.
Byte String
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.2 Integer
„ The integer data type expresses positive and
negative integer values ranging from -2.147.483.648 to
2.147.483.647.
„ Numbers outside the integer limits are automatically regarded as real
numbers.
„ Integer constants can be typed in decimal and octal form (octal digits 0 ...
7 followed by a trailing up arrow, ^).
„ Integer
g values without any
y sign
g are regarded
g as p
positive.

Examples:
256 000123
0 -5
287(En), 2
92-MTR

777^ (octal)
ABB Oy, P2
1MR751 49
Data Types and Objects
5.3 Real
„ Real numbers are written using digits
digits, decimal points
and signs.
„ The ranges of real numbers are determined by the base system computer.
„ Since the internal representation of a real number is generally not exact
(limited to seven digits), care should be taken when comparing two real
numbers.
numbers

Examples:
34.7589472 in MicroSCADA → 34.75895
1234567 123
1234567.123 in MicroSCADA → 1234567
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.4 Boolean
„ Boolean values are gained as the result from testing
the truth of expressions (TRUE or FALSE).
„ Internally, FALSE is represented by the value 0 and TRUE
by the value 1 (FALSE < TRUE).

#if %i_Counter>10 #then ...

Examples:
5 == 5 TRUE
“AB” == “CD” FALSE
%V == FALSE TRUE (if boolean
b l variable
i bl
%V is FALSE)
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.5 Time
„ Data of type time is obtained with the SCIL function
CLOCK and various time stamp attributes of objects.
„ Time data exists only internally (32-bit unsigned integer) and consists of
the number of seconds passed since the beginning of 1978.
„ Time data can be given a readable representation by using the time
functions (e
(e.g.
g TIMES
TIMES, HOUR)
HOUR).

;Current time: 20
20-08-02
08 02 10:29
@i_Hour = hour(clock) ; => 10
@t_Time = time(clock) ; => “02-08-20 10:29”
@
@t_Time_2
i 2 = time(100)
i (100) ; => “78-01-01
“78 01 01 00
00:01”
01”
287(En), 5
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.6 Text
„ Text data is composed of one or more
more, up to 65535
characters (all characters are allowed).
„ In Visual SCIL objects a text can be up to 1023
characters.
„ In expressions text data must be enclosed in quotation marks ( “ ).
„ A single
i l quotet ( ‘ ) or d
double
bl quotes
t ( “ ) contained
t i d iin a
text must be typed as two single or double quotes.

@t_String = “Example text”


@t_String_2 = “What’’s this?”
@t Upper = upper
@t_Upper upper_case(“string”);
case(“string”); => “STRING”
287(En), 6
92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.7 Bit String
„ The length of a bit string (number of bits) may be
anything from 0 to 65535.
„ The bits in a string are numbered from 1 to 65535 counting
from left to right.
„ Bit strings have no visible representation, but they can be read as text
with the BIN function.
function

@g_BS = bit_scan(“011001”) ; => 011001


@g_BS2 = bit_string(5,1,3,5); => 10101
@t BS = bin(%g_BS2)
@t_BS bin(%g BS2) ; =>
> ”10101”
10101
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.8 Byte String
„ A byte string is a sequence of consecutive
8-bit bytes.
„ The length of a byte string may be anything
between 0 and 8388600 bytes.
„ Byte strings can be constructed by the PACK_STR function.
„ Byte strings may be used to exchange binary data between SYS 600 and
other (external) applications.

@y_BS = pack_str((“a”,”b”,”cd”),”text”)
; => “abcd” (text)
@y_BS2 = unpack_str(“abcde”,2)
287(En), 8

; => (“ab”,”cd”,”e”) (vector)


92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.9 Vector
„ A vector is a string of data
data.
„ All data types are allowed in vectors, even so that
different types are included in the same vector.
„ A vector may contain up to 1000000 elements numbered from 1 to
1000000 (indexes).
„ In Visual SCIL objects the maximum vector length remains at 10000 elements.

Syntax:
VECTOR [([element1 [,element], …)]

@v_Data = vector(1,1.25,4,”text”)
@v_Data2 = (1,1.25,4,”text”)
287(En), 9

@v_Data3 = vector(10) ;One element


92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.10 List
„ A list consists of attribute names and attribute
values.
„ A list can hold up to 1000000 attributes and the
attributes can be of any data type.

Syntax:
LIST(attribute=expression, attribute=expression, ...)

@l_Attr = list(iu = 1,- ;In use


oa = 14000,- ;Object addr.
ss = 1) ;Switch state
287(En), 10
92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.11 Object Categories
„ In MicroSCADA there are three categories of objects which represent
three levels of system engineering:
„ System Objects (system configuration and communication)
„ Base system objects (B)
„ Communication system objects (S)

„ User interface objects


„ Pictures
„ Visual SCIL objects
287(En), 11
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.11 Object Categories
„ Application objects (forms the functional portion of the application)
„ Process Objects (P)
„ Event Handling Object (H)
„ Scale Objects (X)
„ Data Objects (D)
„ Command Procedures (C)
„ Time Channels (T)
„ Event Channels (A)
„ Free Type Objects (F)
„ Event Objects (E)
„ Variable Obejcts (V)
287(En), 12
92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.12 Attributes and Methods
„ Most object types have attributes which represent the values
and features of the objects.
„ Through the attributes the SCIL
programmer can use and
change the object properties.
„ The Visual SCIL objects may
also have a number of methods
which are predefined programs
or user defined
d fi d programs
written in SCIL.
287(En), 13
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.13 Object Handling
„ The values and properties of the objects can be read as SCIL attributes
attributes.
„ Provided that write access is allowed, the values and properties can also
be written by means of SCIL commands.
„ Object attributes are accessed through an object notation.
„ The system objects and most of the application objects are accessible
within the entire system (global objects).
„ Visual SCIL objects are accessible from SCIL only within the same dialog
system.
system
287(En), 14
92-MTR
ABB Oy, P2
1MR751 49
Data Types and Objects
5.14 Object Notation

System object notation:


name:{application}type attribute{index}

Application object notation:


name:{application}type{attribute}{index}

N
Name: System
S t objects
bj t have
h predefined
d fi d names whichhi h are composed d
of three letters and a sequence number. Application object
names can be freely chosen.
Application: The logical number of the application where the object is
stored. Generally not needed for system objects.
Type: A character indicating object type (B,S,P,H,X,D,C,T,A,E,V,F)
Attribute: The attribute to be read or written by the notation. Generally
t
two letter
l tt combinations
bi ti
Index: A number or a range of numbers.
287(En), 15
92-MTR
ABB Oy, P2
1MR751 49

Data Types and Objects


5.14 Object Notation

;Object Notation Examples

APL1:BAC ;Number of active alarms in


;application 1
SYS:BUV(2) ;User defined global variable
;index
i d 2 (
(of
f 10)
CB1:P10 ;Process object value, index 10

DATA:D ;Latest registered value in data


;object
TASK:COS ;Program execution state
;0 = successful
287(En), 16
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 6

6 Variables and Expressions


6.1 Variables – General
6.2 Global variables
6.3 Local variables
6.4 Variable naming
6.5 SCIL context
6.6 Variable expansion
6.7 Expressions – General
6.8 Expression composition
6.9 Arithmetical operators
6.10 Relational operators
6.11 Logical operators
Variables and Expressions
6.1 Variables - General
„ A variable is a name (named according to SCIL naming rules) which may
be assigned any value.
„ A variable has no fixed value and can be of any data type.
„ Variable value and data type can be changed at any time.
„ SCIL has two types of variables:
„ Global
„ Local
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.2 Global Variables
„ Global variables do not need any declaration
declaration.
„ A global variable is created the
first time a value is assigned to it.
Syntax:
„ A global variable exists as @name[component] = expression
long as the SCIL context %name[component]
where it was defined is active.
active
„ Global variables are assigned new @i_Value = 123
g the @ character
values using @t_Text
_ = “Text”
and referred to with the % character.
%i_Value + 321
287(En), 2
92-MTR
ABB Oy, P2
1MR751 49
Variables and Expressions
6.3 Local Variables
„ Local variable are declared at the beginning of a SCIL program with the
#LOCAL statement.
„ Local variables are destroyed
when the program is terminated.
Syntax:
„ Identical variable names can be #LOCAL name [= value] [.name[=value]]
used in several programs since
a local variable is only visible in the #local i_Value = 100
program it is declared. #local b_Value
„ Within a SCIL program the variable is
b_Value = FALSE
referred to by its name (no special
characters are needed)
needed).
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.4 Variable Naming
„ The SCIL variable naming convention is based on the Hungarian naming
convention.

<variable name::=<data type identifier>_<variable identifier>

i Integer e Time
r Real y Byte string
v Vector g Bit string
t Text l List
b B l
Boolean x V i t
Variant

Variable identifier = character string (words separated by ‘_’


and capitalized
capitalized.
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
Variables and Expressions
6.4 Variable Naming
„ A suitable length for a variable name is between 5 and 15 characters
characters.
„ The variable name should resemble its purpose as much as possible.
„ It is preferred to use the identifier ‘i’i in the SCIL loop structure (‘j’
( j , ‘k’
k , etc.
etc
should be used when multiple inner loops are used).

%i_Application_Number ;Integer containing the application number.


%v_Object_Names ;A vector containing the object names.
%l_Station:Vi_Address ;Address of the station.
287(En), 5
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.5 SCIL Context
„ A SCIL context is an internal data structure that contains the global
variables.
„ A SCIL context is created when certain objects start their execution and
deleted when they terminate.
„ SCIL contexts are:
„ Dialog systems (Visual SCIL)
„ A command procedure and data object started with
#EXEC or #EXEC_AFTER or byy an event channel
„ A time channel (Data objects and command
procedures run by the time channel share the
SCIL context of the time channel)
„ Pictures (Classic Monitor)
287(En), 6
92-MTR
ABB Oy, P2
1MR751 49
Variables and Expressions
6.6 Variable Expansion
„ With variable expansion variables can be used to form text strings and
names.
„ Both variables and object attributes can be used.
„ The value must be of type integer, real,
text, Boolean or time. Syntax:
name[.attribute]
‘name[.attribute]’
„ If a local and a global
variable exists the local @t_LN = ”cb1”
variable will be used. @i IX = 10
@i_IX

@i_Value = ’t_LN’:POV’i_IX’
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.7 Expressions - General
„ In SCIL expressions are used:
„ For value assignments (objects, attributes, variables)
„ As arguments
g for functions and commands
„ As operands in expressions
„ From external applications through DDE

@i_IX = 10 + 5 * 7 ;assignment
#pause 10 ;argument
(123 + 321)
( ) * 500 ;operand
; p
287(En), 8
92-MTR
ABB Oy, P2
1MR751 49
Variables and Expressions
6.8 Expression Composition
„ In SCIL expressions are composed using operators and operands
operands.

@i_Value = (10 + %a) * cb1:POV10

Operands: Operators:
- constants - arithmetical (+, -, *, /, etc.)
- variables - relational (>, <, ==, etc.)
- object
bj t attributes
tt ib t - logical
l i l (AND
(AND, OROR, etc.)
t )
- function calls
- vector and list aggregates
- program return values
- expressions
i
287(En), 9
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.9 Arithmetical Operators
„ Arithmetical operators are used in
numerical calculations.
Arithmetical operators:
„ As operands arithmetical operators + addition positive sign
require numeric value - subtraction, negative sign
(except addition). * multiplication
/ division
** exponential operator
DIV integer division
MOD modulus operatorp
Priority order:
1) **
123 + 321 ;=> 444
2) //, **, DIV
DIV, MOD 2.17 * 5.33 ;=>
; > 11.56610
3) +, - 10 MOD 3 ;=> 1
287(En), 10
92-MTR
ABB Oy, P2
1MR751 49
Variables and Expressions
6.10 Relational Operators
„ Relational operators are used for
comparing expressions. Relational operators:
„ The result of a comparison is == equal to
always a Boolean value. > greater
t than
th
< less than
„ The relational operators have <> unequal
a lower order of priority than <
<= less than or equal to
the arithmetical. >= greater than or equal to

123 > 321 ;=> FALSE


2.17 <= 5.33 ;=> TRUE
” ” == ”
”A” ”B”” ;=> FALSE
287(En), 11
92-MTR
ABB Oy, P2
1MR751 49

Variables and Expressions


6.11 Logical Operators
„ Logical operators are used for operating
on Boolean values.
„ If an expression contains two or more different Logical operators:
logical operators parentheses are required to AND conjunction
j ti
specify the order. OR disjunction
XOR exclusive or
„ All logical operators expect operands NOT logical negation
of type Boolean.
„ The result of logical
g operations
p
are of Boolean type. A B A AND B A OR B A XOR B NOT A
TRUE FALSE FALSE TRUE TRUE FALSE
FALSE TRUE FALSE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE FALSE FALSE
FALSE FALSE FALSE FALSE FALSE TRUE
287(En), 12
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 7

7 Commands and Functions


7.1 SCIL command categories
7.2 Conditional statements
7.3 Loops
7.4 Compound statements
7.5 Object handling commands
7.6 Error handling policies
7.7 Functions
7.8 Examples
Commands and Functions
7.1 SCIL Command Categories
„ There are five different types of SCIL commands:
„ General SCIL commands
„ characterized by a starting # and can be used in all types of SCIL programs.
„ Visual SCIL commands
„ characterized by a starting dot (.) and can be used in dialogs and pictures
„ Picture commands
„ characterized by a starting ! and allowed only in pictures
„ Primitive graphics commands
„ can be used in pictures and Visual SCIL objects
„ Motif widget commands
„ can be used in pictures and Motif widgets displayed in a X monitor
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Commands and Functions


7.2 Conditional Statements
„ SCIL provides both conditional (#if) and multibranch (#case) conditional
executions.

#case #if
@i_Obj_Val = TUTOUT6_B1:P10 @i_Obj_Val = TUTOUT6_B1:P10

#case %i_Obj_Val #if %i_Obj_Val==0 #then -


#when 0 - @i_Text = “Intermediate”
@i_Text = “Intermediate” #else_if %i_Obj_Val==1 #then -
#when 1 -
# @i_Text = “Closed”
@
@i_Text = “Closed” #else_if %i_Obj_Val==2 #then -
#when 2 - @i_Text = “Open”
@i_Text = “Open” #else @i_Text = “Faulty”
#when 3 -
@i_Text = “Faulty”
287(En), 2

#case_end
92-MTR
ABB Oy, P2
1MR751 49
Commands and Functions
7.3 Loops
„ SCIL has two types of loops
loops, one with a counter variable (#loop
(#loop_with)
with) and
one without (#loop).

#loop #loop_with
#local i_Number = 0 #loop_with i = 1..10
@i_Number = 0
@ @v_Vector(%i)
@ ( ) = -
“value_” + dec(%i)
#loop #loop_end
@i_Number = %i_Number + 1
#if %i_Number > 50 #
# #then –
#loop_exit
#loop_end 100

#loop
p (
(even(second))
( ))
i_Number = i_Number + 1
287(En), 3

#loop_end ;default value 1000


92-MTR
ABB Oy, P2
1MR751 49

Commands and Functions


7.4 Compound Statements
„ By using #block and #block_end
#block end a number of statements can be compund
into one statement.

#block #block
#if %var1 == 10 #then #block #on cb1:E10 #block
@var2=%var1+5 @var2=%var1+15
@var3=%var1+10 @var3=%var1+25
#block_end #block_end
#else #block
@var2=%var1+15
@var3=%var1+25
#block_end
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
Commands and Functions
7.5 Object Handling Commands
„ SCIL commands #set,
#set #modify,
#modify #create and #delete are used for handling
system and application objects.

#create, #set, #modify, #delete


@l_Attributes = list(IU = 1,- ;In use
OX = “Breaker”,-
Breaker , ;Object text
SS = 1,- ;Switch state
PT = 1) ;Process object type

#create CB1:P10 = %l_Attributes


%l Attributes ;Create object

#set CB1:PIU10=0

@l_Modified
@l Modified = list(OX = “Disconnector”,
Disconnector , SS = 0)
#modify CB1:P10 = %l_Modified
287(En), 5
92-MTR

#delete CB1:P10 ;Delete object


ABB Oy, P2
1MR751 49

Commands and Functions


7.6 Error handling policies
„ SCIL has four different error handling policies which are defined with the
#error command.
#error ignore #on error –
ERROR @i_Status = -
#do … console_output(“Error”)

#error continue
ERROR Error message displayed
#do …

#error stop
ERROR If no error handling policy is
#do …
defined a default policy is
pp
applied ((SCIL manual p
p.86).)
#error event
# t
ERROR
287(En), 6

#do …
92-MTR
ABB Oy, P2
1MR751 49
Commands and Functions
7.7 Functions
„ SCIL provides a number of standard functions
functions, which return values
according to a predetermined algorithm.
„ The argument list contains one or more
Syntax:
expressions separated by commas. function(argument(s))
„ The expected data types of the
arguments as well as the data
arguments,
type of the result, are fixed by LENGTH(“ABC”) == 3
the function. MAX(1.0, 5, 3) == 5.0
TIME == ”07
07-08-20
08 20 13:03”
13:03
„ Function calls are used as
operands in expressions.
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

Commands and Functions


7.7 Functions
„ There are around 500 functions in SCIL grouped in 25 different categories
according to their functionality. E.g.:
„ Generic Functions
„ Arithmetic Functions
„ Time Functions
„ String Functions
„ Bit Functions
„ Vector Handling Functions
287(En), 8
92-MTR
ABB Oy, P2
1MR751 49
Commands and Functions
7.8 Examples
„ Print possible error code in SYS 600 Notification window
window.

@i_ECode = status
#error ignore

** Error on this line**

@i ECode = status
@i_ECode

#if %i_ECode<>0 #then-


@i_Status = console_output("Error code:"+dec(%i_ECode))
287(En), 9
92-MTR
ABB Oy, P2
1MR751 49

Commands and Functions


7.8 Examples
„ Get logical names of all process objects and write the result in a text file
file.

@v_Names = vector()
#search 1 0 “P”
P “A”
A

#loop
@l_Attr = next(1)
#if l
l_Attr:VIU
Attr:VIU == -1 #then #loop
#loop_exit
exit
@v_Names = append(%v_Names, l_Attr:VLN)
#loop_end

@i Status = write
@i_Status write_text(
text(”PO
PO_Names.txt
Names txt”,%v_Names,0)
%v Names 0)

If there are no more objects to


be found in the object database
287(En), 10

the next function returns only


92-MTR

the IU attribute with the value -1


ABB Oy, P2
1MR751 49
Commands and Functions
7.8 Examples
„ Calculate the total number of application objects in the application
application.

@v_Obj_Type = vector(“P”,”H”,”X”,”F”,”D”,”C”,”T”,”A”)
@i Count=0
@i_Count=0

#loop_with i=1.. Length(%v_Obj_Type)


@i_Count=%i_Count+application_object_count(0,%v_Obj_Type(%i))
#loop end
#loop_end

@i_Status = console_output(dec(%i_Count))
287(En), 11
92-MTR
ABB Oy, P2
1MR751 49

Commands and Functions


7.8 Examples
„ Create a command procedure based on an existing command procedure
procedure.

@l_Attr = fetch(0,”C”,”bgu_al”)

#if l_Attr:VIU<>-1 #then #block


#set l_Attr:VLN = ”bgu_al_new”
#set l_Attr:VCM = ”New bgu_al command procedure”

@l_temp = fetch(0,”c”,”bgu_al_new”)
#if l_Temp:VIU==-1 #then #create bgu_al_new:c = %l_Attr
#block_end
287(En), 12
92-MTR
ABB Oy, P2
1MR751 49
Contents of Chapter 8

8 SCIL Compiler
8.1 General
8.2 Performance improvement
8.3 Impact on SCIL programs
8.4 Avoiding problems with SCIL compiler
SCIL Compiler
8.1 General
„ The SCIL programs of pictures and
command procedures can be compiled
for better performance.
„ Once a SCIL program is compiled, the
compiled version is automatically used
instead of the original
g SCIL code.
„ The compilation function is selected
from the picture editor or from the
command d procedure
d ttool.
l
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

SCIL Compiler
8.2 Performance Improvement
„ Depending on the program contents
contents, the performance improvement varies
between no improvement at all and
up to 50 times faster.
„ The average picture change time of a typical LIB 500 picture is reduced to
about 2/3.

#loop_with i = 1..1000 #pause 10


: :
: :
#loop_end :
About 50 times faster when No performance improvement
287(En), 2

compiled. although compiled.


92-MTR
ABB Oy, P2
1MR751 49
SCIL Compiler
8.3 Impact on SCIL Programs
„ In most cases compiled SCIL programs execute exactly like uncompiled
programs (except for the performance).
„ There are however a few cases when compiled programs execute
differently compared to uncompiled programs:
„ A valid SCIL program may be impossible to compile.
„ A SCIL program may compile
il but
b t generates
t a run-time
ti
error when executed.
„ A SCIL programs
g produces different results when
compiled compared to the uncompiled program.
„ Due to these possible incompatibilities the compiled SCIL program has to
be properly retested.
retested
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49

SCIL Compiler
8.4 Avoiding Problems with Compilation
„ In most cases problems with compilation arises from incorrect usage of
variable expansion.
„ To avoid potential problems the following recommendations on the use of
variable expansion are given:
„ Use direct variable access instead of expansion whenever possible.
Instead of 'A'
A + 'B'
B , write %A + %B
Instead of "'A'", write %A ( if A has a text value )
Instead of "X'A'Z", write "X" + %A + "Z" ( if A has a text value )
„ Use variable expansion mainly for generating various identifiers
identifiers.
„ When variable expansions are used as recommended above, the
p
compiled and uncompiled
p p
program
g always
y behave identically.
y
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
ABB Oy, P2
287(En), 5
1MR751 4992-MTR
Contents of Chapter 9

9 Exercises
9.1 Exercise 1
9.2 Exercise 2
9.3 Exercise 3
9.4 Exercise 4
9.5 Exercise 5
9.6 Exercise 6
9.7 Exercise 7
9.8 Exercise 8
Exercises
Exercise 1

1 Experiment with different data


types and objects using the
Test Dialog.

Open the Test Dialog from the Tool Manager

Write 123 first line on the Fields page and press the Inspect button
button.
After pressing the inspect button, the data type and value of the expression
appears beneath the line.

Change
g the contents of the line to -2147483647 and p
press the inspect
p button.
The integer range is from -2147483647 to 2147483647.

Change the last digit (7) to 8 (-> -2147483648) and press the inspect button.
The data type changes from Integer to Real.

Change the contents of the line to 321.123 and press the inspect button.
287(En), 1
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 1

Ch
Change the
th ddecimals
i l tto .11111
11111 (->
( > 321.11111)
321 11111) and
d press th
the iinspectt b
button.
tt
Beneath the line the value 321.1111 is shown. A real number can only have seven significant digits.

Change the decimals to .77777 (-> 321.77777) and press the inspect button.
Beneath the line the value 321
321.7778
7778 is shown
shown. The seventh digit is rounded
rounded.

Change the contents of the line to TRUE and press the inspect button.
Beneath the line the data type (Boolean) and the value (TRUE) is show.

Change the contents of the line to CLOCK and check the Update check box.
When the check box is checked the line will be updated every second. The CLOCK function shows
the number of seconds passed since the beginning of 1978. The Test Dialog converts the value into a
readable format (yy-mm-dd hh:mm:ss).

Uncheck the check box, change the contents of the line to “Exercise” the inspect button.
Beneath the line the data type (TEXT), the length (8) and the value is shown.

Change the contents of the line to UPPER_CASE(


UPPER CASE(“Exercise”)
Exercise ) and press the inspect button
button.
All the lower case letters are converted in to upper case letters.
287(En), 2
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 1

Ch
Change the
th contents
t t off the
th line
li tto BIT_SCAN(“101011”)
BIT SCAN(“101011”) and
d press th
the iinspectt b
button.
tt
The BIT_SCAN function converts character strings to bit strings. The data
type is BIT_STRING and the value is 101011.

Change the contents of the line to BIN(BIT_SCAN(


BIN(BIT SCAN(“101011”))
101011 )) and press the inspect button
button.
The BIN function converts bit strings, integers and vectors to texts and text vectors.

Change the contents of the line to BIT_STRING(4,1,4) and press the inspect button.
A bit string with the value 1001 is created. The first argument is the number of bits in the bit string and
the following are the numbers of the bits that are to be set to one.

Change the contents of the line to PACK_STR((“1”,”AB”,”34”),”TEXT”) and press the


inspect button.
The data type will be TEXT and the value will be “1AB34”. The PACK_STR function converts text
vector to text or integer vector to bit or byte string.

Change the contents of the line to UNPACK_STR(“ABCDEFG”,2) and press the inspect
button.
button
The UNPACK_STR function creates a vector with the following elements : “AB”,”CD”,EF”,”G”.
287(En), 3
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 1

Ch
Change the
th contents
t t off the
th line
li tto VECTOR(“A”,”B”,”C”,1,2,3)
VECTOR(“A” ”B” ”C” 1 2 3) and
d press th
the iinspectt b
button.
tt
A vector with 6 different elements is created.

Change the contents of the line to (“A”,”B”,”C”,1,2,3) and press the inspect button.
The result is the same as with the VECTOR function.
function

Go to the Examine page and write (“A”,”B”,”C”,1,2,3) on the command line and press the
examine button.

Change the contents of the line on the Examine page to LIST(LN="CB2",IX=11,OA=5) and
press the inspect button.
A list with attributes and their expressions appear below the line.
287(En), 4
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 2

2 Experiment with variables and


expressions using the Test Dialog.

Create the following two variables on lines 1 and 2 on the Commands page :

@i_A=1234
@i A=1234 Integer
@v_B=(2,4,6,8,10) Vector

Press the Execute button for each line.

Write %i_A on line 1 on the Fields page and check the update check box.

Change the value for i_A to 4321 and press the execute button.
Now the value changes automatically on the field page because the
update check box is checked.
287(En), 5
92-MTR

Write %v_B on line 2 on the fields page and press the inspect button.
ABB Oy, P2
1MR751 49

Exercises
Exercise 2

Ch
Change the
th contents
t t off line
li 2 tto %v_B(3)
% B(3) and
d press th
the iinspectt b
button.
tt
This will show the third element in vector v_B.

Change the contents of line 2 to %v_B(1..3) and press the inspect button.
This will show elements 1 to 3 in vector vv_B.
B

Create the following variables on lines 1 and 2 on the Commands page :

@t_A
@t A exercise
@t_B=“exercise”

Remember to press the execute button after each line.

Write %t_A on line 1 and %t_B on line 2 on the fields page, then press the inspect button on
both lines.
Both variables are of data type TEXT, but the letters in variable t_A are in upper case.

Change the value of t_B to 4 and on line 3 on the commands page. Write
287(En), 6
92-MTR

@t_C=“’t_A’_’t_B’” on line 4 on the commands page.


ABB Oy, P2
1MR751 49
Exercises
Exercise 2

W it %t_C
Write %t C on line
li 3 on th
the fi
fields
ld page and
d press th
the iinspectt b
button.
tt
By using the variable expansion a text variable with the value EXERCISE_4 has been created.

Select New from the file menu of the Test Dialog or press Ctrl-N.

Evaluate the following arithmetical expressions on the Fields page :

“Exer”+”cise”
2 8
2**8
100 DIV 3
100 MOD 3
5*10-10/2
(5*10
(5 10-10)/2
10)/2
287(En), 7
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 2

E l t the
Evaluate th following
f ll i relational
l ti l operators
t on th
the Fi
Fields
ld page :

“A”==“B”
“A”<“B”
30<>10

Create the variable i_A and give it the integer value 20. Write the 10<%i_A AND %i_A<30 on
the Fields page and check the corresponding check box.

Change the value for i_A to 40.


287(En), 8
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 3

3 In this exercise the attribute values describing the


hardware and software information will be displayed
in the Notification Window.
287(En), 9
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 3
1. 2.

3
3. 4
4.

1) Open the Test Dialog from the Miscellaneous page


in the Tool Manager.
2) Select the Programs page in the Test Dialog.
3) Select the first program (out of six) and write a
brief description on the Comments line
(eg. Exercise 3).
4) By pressing the Edit button on the same line a
SCIL Editor will open.
p
287(En), 10
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 3

CONSOLE OUTPUT(te t)
CONSOLE_OUTPUT(text)
Writes a message into the notification window.

’text’ Any text value.


Value: The status code of the operation
operation. 0 = OK
OK.
It is not recommended to use control characters
(for example CR or LF) in the text sent to the
notification window. If control characters are used,
the behaviour is undefined.

5) Write the SCIL program below in the SCIL Editor


(the Console_Output function can either be written
man all or inserted from the Insert SCIL Commands,
manually Commands
Functions & Objects dialog).

@ _Status=console_output("Hardware
@i p ( and Software Information")
)
@i_Status=console_output("---------------------------------") 5
5.
287(En), 11

@i_Status=console_output("Hardware: "+SYS:BHW)
@i_Status=console_output("Operating System: "+SYS:BOS)
92-MTR

@i_Status=console_output("Program Revision: "+SYS:BRE)


ABB Oy, P2
1MR751 49

Exercises
Exercise 3

SYS BHW Hardware


SYS:BHW Hard are
6. The type of the base system computer.
Data type: Text
Value: "PC/AT“
Access: Read-only

7. SYS:BOS Operating System


The operating system running in the base system
computer.

8. Data type: Text


Value: "NT" = Windows NT
Access: Read-only
6) After writing the SCIL program in the SCIL SYS:BRE Program Revision
Editor select the Update function from the The revision number of the running MicroSCADA
File menu. kernel software, for example 8.4.5
7) The next step is to exit the SCIL Editor.
Data type: Text
8) To test the program press the inspect button Value: Program revision
(make sure that the Notification Window is Access: Read-only
287(En), 12

open when testing the program).


92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 4

4 Write a program with errors and see how


the different error handling policies works.
The programs in this exercise will be written in
the Test Dialog on the Programs pagepage.
1.
Error Handler #Error Ignore

#On Error @i_Status=Console_Output(“Error handler activated.”)

Erroneous line; This line will cause an error

@i_Status=Console_Output(“Program execution continued.”)

1) Open the Test Dialog and write the SCIL


program above in a SCIL editor on the
287(En), 13

Programs page.
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 4
#Error Ignore
Program execution stopped: No
Error message shown: No
Error handler executed: No

2) After writing the SCIL program


in the Test Dialoggp
press the
Execute button. Make sure
2. that the MicroSCADA Notify
window is open before
executing the program.
Notification Window.
287(En), 14
92-MTR
ABB Oy, P2
1MR751 49
Exercises
3-6) Test the remaining error handling policies (continue, stop, event) Exercise 4
by changing the first line of the SCIL program.

#Error Continue 3) Set the error handling policy


3. to Continue by changing the
#O E
#On Error @i
@i_Status=Console_Output(“Error
St t C l O t t(“E h
handler
dl activated.”)
ti t d ”)
first line of the SCIL program.
Erroneous line; This line will cause an error

@i_Status=Console_Output(“Program execution continued.”)

4
4. #Error Continue
Program execution stopped: No
Error message shown: Yes
Error handler executed: No Error Message
287(En), 15
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 4
5. #Error Stop
Program execution stopped: Yes
Error message shown: Yes
Error handler executed: Yes

The message ”Error in error handler” is confusing, but the error


handler seems to work correctly according to the message
shown in the Notification Window. (The reason for the
message
g is the behaviour of the Test Dialog).
g)

You can test #Error Stop in the other way:


Create a command procedure having the same SCIL code
Run the command p procedure from Test Dialog
g
See the result in the Notification Window
287(En), 16
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 4

6
6. #Error Event
Program execution stopped: Yes
Error message shown: No
Error handler executed: Yes
287(En), 17
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 5

5 Create Process Objects with data read from a text file


by using SCIL.
287(En), 18
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 5

1. @v_Data=read_columns("object_data.txt",vector(1,11,21,31,41),-
vector(10,10,10,10,10),3)

Read the data from the text file


(Object_Data.txt) with the Read_Columns
funtion.

READ_COLUMNS(file, pos, width [,start [,count]])


287(En), 19
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 5

2
2. @v_Data=read_columns("object_data.txt",vector(1,10,20,30,40),-
vector(9,9,9,9,9),3)

#loop_with i=1.. length(%v_Data(1))

#loop_end

Create a loop that executes once for each element in the data vector.
The length of the vector is determined with the length function.

3. @v_Data=read_columns("object_data.txt",vector(1,10,20,30,40),-
vector(9,9,9,9,9),3)

#loop_with i=1.. length(%v_Data(1))


@t_LN=edit(%v_Data(1)(%i),"COLLAPSE")
@i_IX=dec_scan(edit(%v_Data(2)(%i),"COLLAPSE"))

#l
#loop_end
d
287(En), 20

Extract the LN and IX attribute values from the vector. All spaces are
92-MTR

removed from the text with the Edit function. The Dec_scan function
converts a text to an integer.
integer
ABB Oy, P2
1MR751 49
Exercises
Exercise 5

4. @v_Data=read_columns("object_data.txt",vector(1,10,20,30,40),-
vector(9,9,9,9,9),3)

#loop_with i=1.. length(%v_Data(1))


@t_LN=edit(%v_Data(1)(%i),"COLLAPSE")
@i_IX=dec_scan(edit(%v_Data(2)(%i),"COLLAPSE"))

@l_Proc_Obj=list(PT=dec_scan(edit(%v_Data(3)(%i),"COLLAPSE")),-
IU=dec
IU dec_scan(edit(%v_Data(4)(%i),
scan(edit(%v Data(4)(%i),"COLLAPSE")),-
COLLAPSE )),
SS=dec_scan(edit(%v_Data(5)(%i),"COLLAPSE")))

#create 't_LN':P'i_IX'=%l_Proc_Obj

#loop end
#loop_end

Create a list containing the PT, IU and SS attributes. The Process


Objects are created with the #create command. The object notation
(<name>:P<index>) is built up using single data variables and variable
expansion.
287(En), 21
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 5

5.

Use the Object Navigator to make sure


that all five process objects were
created properly.

This program can


be executed only
once.
287(En), 22
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 6

6 Search for all Command Procedures in the current application


and save the values of the LN and CM attributes to a text file.
287(En), 23
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 6
APPLICATION OBJECT LIST(apl type [,order
APPLICATION_OBJECT_LIST(apl, [ order [,direction
[ direction [,start
[ start [,condition
[ condition [,attributes
[ attributes [,max]]]]])
[ max]]]]])

1. @l_Com_Proc=application_object_list(0,”c”)

The application_object_list function returns


a list containing the number of objects found
(in this case Command Procedures) and the
logical names of the objects.

2
2. @l_Com_Proc=application
pp
@v_LN_CM=vector()
_object
j _list(0,”c”) Create an empty vector and a loop
(#loop_with) that executes once for every
#loop_with i=1.. l_Com_Proc:VCount
object found.

#loop_end
287(En), 24
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 6
@l_Com_Proc=application_object_list(0,
@l Com Proc=application object list(0 ”c”)
c ) Get all attributes and attribute values
3
3. @v_LN_CM=vector() for each Command Procedure by using
#loop_with i=1.. l_Com_Proc:VCount
the Fetch function.
@l_Obj_Data=fetch(0,"c",l_Com_Proc:VLN(%i))

#loop_end

FETCH(apl, type, name [,index])

4. @l_Com_Proc=application_object_list(0,”c”)
@v_LN_CM=vector()

#loop_with i=1.. l_Com_Proc:VCount


@l_Obj_Data=fetch(0,"c",l_Com_Proc:VLN(%i))
@v_LN_CM=append(%v_LN_CM,l_Obj_Data:VLN+" - "+l_Obj_Data:VCM)
#loop_end
287(En), 25

Add the Logical Name (LN) and the Comment (CM)


92-MTR

attributes to the vector with the Append function.


ABB Oy, P2
1MR751 49

Exercises
Exercise 6

@l_Com_Proc=application_object_list(0,”c”)
5. @v_LN_CM=vector()

#loop_with i=1.. l_Com_Proc:VCount


@l Obj Data=fetch(0 "c"
@l_Obj_Data=fetch(0, c ,l_Com_Proc:VLN(%i))
l Com Proc:VLN(%i))
@v_LN_CM=append(%v_LN_CM,l_Obj_Data:VLN+" - "+l_Obj_Data:VCM)
#loop_end

@i_Status=write_text("Com_Proc.txt",%v_LN_CM)

WRITE_TEXT(file, text [,append]) Save the contents of the vector to a text file
(Com_Proc.txt) with the Write_Text
function. The text file is saved in the PICT
directory of the current application.
287(En), 26
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 6
EXTRA

Modify the program so that only Command Procedures with a logical


name beginning with the letter B are included.

Also include the Modification Time (ZT) attribute in the data that is
saved to the text file. Note that the data type of the ZT attribute is time.
287(En), 27
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 7

7 In this exercise a SCIL database


file will be created using the
DATA_MANAGER function. Data will
be inserted to and extracted from this
file. ”Text”
12345
DATA MANAGER(function[ argument])
DATA_MANAGER(function[,argument])
Functions: ”a”,1,”b”
(“CREATE”,file)
(“OPEN”,file)
(“CLOSE”,handler)
(“LIST_SECTIONS”,handle)
(“CREATE_SECTION”,handle,section)
(“DELETE_SECTION”,handle,section)
(“GET”,handle,section[,component])
287(En), 28

(“PUT”,handle,section[,component])
92-MTR

(“DELETE”,handle,section[,component])
ABB Oy, P2
1MR751 49
Exercises
Exercise 7

1
1. 2
2. A file with
ith the name scil_db.scl
scil db scl
will be created. In this case the
default path (PICT) will be used.

@i Status=data manager(“CREATE”
@i_Status=data_manager( CREATE ,”scil
scil_db.sdb
db sdb”)
)

%i_Status

1) Open the Test Dialog


3
3.
2) Create the SCIL database file using
the CREATE function with the Handle
DATA MANAGER function.
DATA_MANAGER
287(En), 29

3) Examine the return variable (%i_Status)


92-MTR

of the DATA_MANAGER function.


ABB Oy, P2
1MR751 49

Exercises
Exercise 7
4.

@i_Status=data_manager(“CREATE_SECTION”,1,”Current_Time”)

@i Status=data manager(“CREATE
@i_Status=data_manager( CREATE_SECTION
SECTION”,1,
1 ”Release”)
Release )

data_manager(“LIST_SECTIONS”,1)

5.
4) Create two sections in the SCIL
database with the CREATE_SECTION Sections
function.
287(En), 30

5) View the sections in the SCIL database


92-MTR

with the LIST_SECTIONS function.


ABB Oy, P2
1MR751 49
Exercises
Exercise 7
6.

@i_Status=data_manager(“PUT”,1,”Current_Time”,time)

@i_Status=data_manager(“PUT”,1,”Release”,SYS:BRE)

data_manager(“GET”,1,”Current_Time”)

7
7.
6) Set values for the sections created on
the prevoius page by using the PUT
function.
287(En), 31

7) View the section values separately by with


92-MTR

the GET the function.


ABB Oy, P2
1MR751 49

Exercises
Exercise 7
8) Close the SCIL database with the
CLOSE function.

@i_Status=data_manager(“CLOSE”,1)

@i_Status=data_manager(“OPEN”,”scil_db.sdb”)
There can be a maximum of
The SCIL database can be re-opened with 10 databases open within a
the OPEN function. SCIL context. When trying to
open more then 10 databases
@i
@i_Status=data_manager(“DELETE_SECTION”,1,”Release”)
d ( 1 l ) status code 662 will be shown
shown.

A section can be deleted from the SCIL database with the


DELETE_SECTION function.

@i_Status=data_manager(“DELETE”,1,”Release”)
287(En), 32
92-MTR

A section value can be deleted from the SCIL database


with the DELETE function.
function
ABB Oy, P2
1MR751 49
Exercises
Exercise 8

8 In this exercise information will be retrieved


from the history database by using the
HISTORY_DATABASE_MANAGER function.

The name of the


Modification
object
j ((LN).
)
Time (ZT)
(ZT).
287(En), 33
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 8

1. #local e_Begin=pack_time(2009,1,1,0,0,0),-
e End pack time(2009 6 30 0 0 0)
e_End=pack_time(2009,6,30,0,0,0),-
Define the local variables. The end and
begin limits for the search are defined
l_Val, l_Hist, l_Stat, l_Que, l_Data,-
t_Line
as (Y,M,D,H,M,S).

@v_Result=vector() Define an g
global empty
p y vector.

2. #local e_Begin=pack_time(2007,1,1,0,0,0),-
e_End=pack_time(2007,6,30,0,0,0),-
Opens a handle to the history database.
The function returns a list where the
l_Val,
, l_Hist,
, l_Stat,
, l_Que,
, l_Data,-
,
t_Line
Session attribute is a integer number
indicating the session number.
@v_Result=vector()
Note that there can be only 10 open
l Val=history database manager("OPEN"
l_Val=history_database_manager( OPEN ,0)
0) sessions to the history databse at a time
time.
287(En), 34
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 8

:
: (Program continues from previous page)

3
3. l Hist=history database manager("SET
l_Hist=history_database_manager( SET_PERIOD
PERIOD",l_Val.Session,e_Begin,e_End)
l Val Session e Begin e End)

Sets the time limits for the database search (see variable definition above). The session
number defined in a previous step is used to identify the specific session.

4. l_Hist=history_database_manager("SET_PERIOD",l_Val.Session,e_Begin,e_End)

_ _ _ _
l_Que=history_database_manager("QUERY",l_Val.Session,1000)

Performs the search with the previously


defined conditions. The integer value
1000 indicates the maximum number of
events that will be returned by the search.
287(En), 35
92-MTR
ABB Oy, P2
1MR751 49

Exercises
Exercise 8
:
: (Program continues from previous page)

5. l_Data=l_Que.DATA The DATA attribute from the list returned by the search is copied
to another list ((l_Data).
_ )

l_Data=l_Que.DATA The loop creates a text consisting


6. of the logical name (LN),
(LN) the
#loop_with i=1.. l_Que.COUNT
t_Line=l_Data.LN(%i)+" - "+time(l_Data.ET(%i))
Event Time (ET). The text is
@v_Result=append(%v_Result,t_Line) appended to the global vector
#loop_end v_Result.

7. 8.
287(En), 36
92-MTR
ABB Oy, P2
1MR751 49
Exercises
Exercise 8
EXTRA

Modify the program so that also the Object Text (OX) attribute
is included in the text that is appended to the vector.

Hint! Have a look at the SET_ATTRIBUTES option for the


HISTORY_DATABASE_MANAGER function.
287(En), 37
92-MTR
ABB Oy, P2
1MR751 49

S-ar putea să vă placă și