Вы находитесь на странице: 1из 78

MicroSCADA

P287 SCIL Programming Basics

MicroSCADA P287 SCIL Programming Basics ABB Oy Distribution Automation NAME RESP.DEPT. PREPARED SCIL

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

© 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

4 SCIL Tools 5 Data Types and Objects 6 Variables and Expressions 7 Commands and Functions

Contents of Chapter 1

1 General Information

1.1 Course Schedule

1.2 Notice

1.3 Definitions and Abbreviations

1.4 Course Presentation

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

Course Schedule

Day 1

9:00

Introduction Programming environment SCIL tools Data types and objects Variables and expressions Exercises 1 - 3 Lunch Commands and functions Exercises 4 - 8 SCIL compiler Course ends

11:45

13:00

16:00

Exercises 1 - 3 Lunch Commands and functions Exercises 4 - 8 SCIL compiler 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

wishes for a rewarding course. ABB Oy Distribution Automation Training Team Copyright © ABB Oy Distribution

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

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”

for designing and programming user interface dialogs with Visual SCIL objects and comm ands is named

Course Presentation

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

Objectives

After this course the participant will be able to:

use SCIL in object handling and calculations write simple programs in SCIL

use SCIL in object handling and calculations write simple programs in SCIL

Participant profile

System engineers, maintenance engineers and persons who edit, build or maintain MicroSCADA systems.

Prerequisites

Basic knowledge of MicroSCADA and programming techniques.

Topics

SCIL programming environment

SCIL commands and functions

Data types and objects

Variables and expressions

Programming exercises

SCIL commands and functions Data types and objects Variables and expressions Programming exercises

Contents of Chapter 2

2 Introduction

2.1 What is SCIL?

2.2 What can you do with SCIL?

2.3 SCIL related manuals

Contents of Chapter 2 2 Introduction 2.1 What is SCIL? 2.2 What can you do with

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

Introduction

2.1 What is SCIL?

SCIL is a high level language especially designed for the application engineering of the supervisory control system MicroSCADA.

S upervisory

Control I mplementation
Control
I mplementation

L

anguage

MicroSCADA. S upervisory Control I mplementation L anguage Introduction   2.2 What can you do with

Introduction

 

2.2

What can you do with SCIL?

With 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

Design various forms of process control Configure, supervise and handle system components Build process simulations

Introduction

2.3 SCIL related manuals The main manual when dealing with SCIL programming is the SYS
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 Design and Visual SCIL Objects
ABB Oy, P 287(En), 3
1MR751 49 2-MTR

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

3.3 SCIL program components 3.4 Programming in SCIL 3.5 Activating SCIL programs 3.6 Special characters 3.7

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

Programming Environment

3.1 Occurrence of SCIL Programs In MicroSCADA Pro applications SCIL programs mainly appear in: Command
3.1
Occurrence of SCIL Programs
In MicroSCADA Pro applications SCIL programs mainly appear in:
Command procedures
Dialogs and dialog items (Visual SCIL)
In Classic Monitor applications,
SCIL programs can also occur
in picture programs.
ABB Oy, P 287(En), 1
1MR751 49 2-MTR

Programming Environment

 

3.2

SCIL Program Structure

 

A SCIL program can contain up to 1000000 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 s aces are allowed within text constants.

p

,

but not

;comment 1 #loop_with- ;comment 2

 

i

= 1

10

 

:

:

Comments are preceded with a semicolon ( ; ), which indicates that the rest of the line is a comment.

If a semicolon is enclosed quotation marks (“;”) it is regarded as text.

#loop_end
#loop_end
the rest of the line is a comment. If a semicolon is enclosed quotation marks (“;”)

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

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
@i_Number=123
#iF %i_nUMBER>100 #Then #bLoCk
:
:
#block_END
#iF %i_nUMBER>100 #Then #bLoCk : : #block_END Programming Environment 3.3 SCIL Program Components A SCIL

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

Variables

Variables are facilities for the temporary storage and use of changing data

Function calls

Function calls

E

i

xpress ons

use of changing data Function calls E i xpress ons Expressions are formulas which can contain

Expressions are formulas which can contain constants, object notations, variables, function calls and operators

ons Expressions are formulas which can contain constants, object notations, variables, function calls and operators

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

ABB Oy, P 287(En), 6 1MR751 49 2-MTR

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.

fo r testing SCIL programs, statements and expressions . SCIL editor Test Dialog Programming Environment 3.5

SCIL editor

SCIL programs, statements and expressions . SCIL editor Test Dialog Programming Environment 3.5 Activating SCIL

Test Dialog

statements and expressions . SCIL editor Test Dialog Programming Environment 3.5 Activating SCIL Programs There

Programming Environment

3.5 Activating SCIL Programs

There are a number of ways in which a SCIL program can be 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 when a dialog is entered or exited, periodically 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

, and on the occurrence of a process event User activated function keys in displa ys
, and on the occurrence of a process event User activated function keys in displa ys

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

ABB Oy, P 287(En), 8 1MR751 49 2-MTR

Programming Environment

3.6 Special characters - continuation of program line + * multiplication ** / separator in
3.6
Special characters
-
continuation of program line
+
*
multiplication
**
/
separator in picture paths
\
(
left bracket
)
,
marks an enumeration
marks an index interval
.
@
precedes a variable name by
assignment
%
#
precedes a control command
:
!
precedes a picture command
;
=
assignment
==
>
greater than
>=
<
<=
<>
less than
not equal to
^
plus sign
exponential operator
separator in Visual SCIL object paths
right bracket
marks graphics or Motif command
encloses text
precedes a variable name by use
indicates variable expansion
follows an object name
starts a comment
equal to
greater than or equal to
less than or equal to
marks an octal number
or equal to less than or equal to marks an octal number Programming Environment 3.7 SCIL

Programming Environment

3.7 SCIL names

Names (e.g. variable and object names) in SCIL can be freely chosen. There are however a few naming rules:

Names (e .g. variable and object names) in SCIL can be freel y chosen . There

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).

- Z). Application object names can also include periods ( . ) and start with a

Contents of Chapter 4

4 SCIL Tools

4.1 SCIL editor

4.2 Test dialog

4.3 Other tools

Contents of Chapter 4 4 SCIL Tools 4.1 SCIL editor 4.2 Test dialog 4.3 Other tools

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

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 Procedure Editor, Dialog Editor, etc.)

tools (Command P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor
tools (Command P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor

SCIL Tools

4.1 SCIL Editor

4.1 SCIL Editor Indent / Unindent Comment / Uncomment

Indent /

Unindent

4.1 SCIL Editor Indent / Unindent Comment / Uncomment

Comment /

Uncomment

P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor Indent /
P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor Indent /
P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor Indent /
P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor Indent /
P roce d ure Edit or, Dialog Editor, etc.) SCIL Tools 4.1 SCIL Editor Indent /

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

SCIL Tools

4.1 SCIL Editor

4.1 SCIL Editor
P 2 87(En), 3 1MR751 4 9 2-MTR SCIL Tools 4.1 SCIL Editor Insert SCIL Commands,
P 2 87(En), 3 1MR751 4 9 2-MTR SCIL Tools 4.1 SCIL Editor Insert SCIL Commands,
P 2 87(En), 3 1MR751 4 9 2-MTR SCIL Tools 4.1 SCIL Editor Insert SCIL Commands,
P 2 87(En), 3 1MR751 4 9 2-MTR SCIL Tools 4.1 SCIL Editor Insert SCIL Commands,
P 2 87(En), 3 1MR751 4 9 2-MTR SCIL Tools 4.1 SCIL Editor Insert SCIL Commands,

Insert SCIL Commands, Functions & Objects

Editor Insert SCIL Commands, F unct i ons & Obj ects Check Syntax SCIL Tools 4.1

Check Syntax

SCIL Commands, F unct i ons & Obj ects Check Syntax SCIL Tools 4.1 SCIL Editor

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

  #LOOP #LOOP_END
  #LOOP #LOOP_END
  #LOOP #LOOP_END

#CASE

#CASE_END

ABB Oy, P 287(En), 4 1MR751 49 2-MTR
ABB Oy, P 287(En), 4
1MR751 49 2-MTR

Find Block

#BLOCK_END   #LOOP #LOOP_END #CASE #CASE_END ABB Oy, P 287(En), 4 1MR751 49 2-MTR Find Block
#BLOCK_END   #LOOP #LOOP_END #CASE #CASE_END ABB Oy, P 287(En), 4 1MR751 49 2-MTR Find Block
#BLOCK_END   #LOOP #LOOP_END #CASE #CASE_END ABB Oy, P 287(En), 4 1MR751 49 2-MTR Find Block

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

SCIL Tools

4.1 SCIL Editor

The Compilation in Use function is available only when the calling tool supports program compilation.

4.1 SCIL Editor The Com p ilation in Use function is available only when the calling

Toggling the item turns the auto- compilation on and off.

Toggling the item turns the auto- compilation on and off. SCIL Tools 4.2 Test Dialog The
Toggling the item turns the auto- compilation on and off. SCIL Tools 4.2 Test Dialog The
Toggling the item turns the auto- compilation on and off. SCIL Tools 4.2 Test Dialog The
Toggling the item turns the auto- compilation on and off. SCIL Tools 4.2 Test Dialog The
Toggling the item turns the auto- compilation on and off. SCIL Tools 4.2 Test Dialog The

SCIL Tools

4.2 Test Dialog The Test Dialog is used for testing purposes (examining data structures, finding
4.2
Test Dialog
The Test Dialog is used for testing purposes (examining data structures,
finding out variable values and executing
SCIL programs).
The Test Dialog has several
notebook pages for different
testing purposes.
ABB Oy, P 287(En), 6
1MR751 49 2-MTR

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

ABB Oy, P 287(En), 8 1MR751 49 2-MTR

SCIL Tools

 

4.2

Test Dialog

When an error appears in the Test 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.

are being updated and how many programs are being executed. SCIL Tools 4.2 Test Dialog The
are being updated and how many programs are being executed. SCIL Tools 4.2 Test Dialog The

SCIL Tools

4.2 Test Dialog The command lines are used for executing SCIL commands. The commands are
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.

The expressions can be automatically updated once a second by checking the Update check box.

of SCIL expressions. The expressions can be automatically up dated once a second b y checkin
of SCIL expressions. The expressions can be automatically up dated once a second b y checkin

ABB Oy, P 287(En), 9 1MR751 49 2-MTR

ABB Oy, P 287(En), 10 1MR751 49 2-MTR

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)).

of the value (OK _ STATUS(0) , NOT _SAMPLED_ STATUS(10)) . SCIL Tools   4.2 Test
of the value (OK _ STATUS(0) , NOT _SAMPLED_ STATUS(10)) . SCIL Tools   4.2 Test

SCIL Tools

 

4.2

Test Dialog

The programs page is used for creating and executing SCIL 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.

box. The SCIL editor for the selected program is opened with the Edit button on the
box. The SCIL editor for the selected program is opened with the Edit button on the

ABB Oy, P 287(En), 11 1MR751 49 2-MTR

ABB Oy, P 287(En), 12 1MR751 49 2-MTR

SCIL Tools

4.2 Test Dialog

The examine page is used for examining all types of SCIL expressions.

Vector and list type expressions are displayed as nodes in the text box.

The following icons indicates different data types:

IntegerThe followin g icons indicates different data t yp es: Text Time Real V ector List

Textfollowin g icons indicates different data t yp es: Integer Time Real V ector List Bit

Timeg icons indicates different data t yp es: Integer Text Real V ector List Bit String

Realg icons indicates different data t yp es: Integer Text Time V ector List Bit String

Vector ector

Listdifferent data t yp es: Integer Text Time Real V ector Bit String Boolean Byte String

Bit String String

Booleant yp es: Integer Text Time Real V ector List Bit String Byte String SCIL Tools

Byte Stringes: Integer Text Time Real V ector List Bit String Boolean SCIL Tools   4.2 Test

Text Time Real V ector List Bit String Boolean Byte String SCIL Tools   4.2 Test
Text Time Real V ector List Bit String Boolean Byte String SCIL Tools   4.2 Test

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, are removed from the tree structure.

its child objects and their user defined and predefined attributes , are removed from the tree
its child objects and their user defined and predefined attributes , are removed from the tree

SCIL Tools

4.3 Other Tools Dialog Editor (Visual SCIL) Picture Editor (classic monitor) ABB Oy, P 287(En),
4.3 Other Tools
Dialog Editor
(Visual SCIL)
Picture Editor
(classic monitor)
ABB Oy, P 287(En), 13
1MR751 49 2-MTR

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

string 5.9 Vector 5.10 List 5.11 Object categories 5.12 Attributes and methods 5.13 Object handling 5.14

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

Data Types and Objects

5.1 General In SCIL there are six types of simple data (data constituted of single
5.1
General
In SCIL there are six types of simple data
(data constituted of single values):
Integer
Real
Boolean
The data type vector represents a string
of data items, and the data type list
represents a list of attributes and
attribute values.
Ti me
Text
Bit String
Vector
List

Every SCIL expression is associated with one of these eight data types.

is associated with one of these eight data types. Byte String Data Types and Objects 5.2

Byte Stringis associated with one of these eight data types. Data Types and Objects 5.2 Integer  

associated with one of these eight data types. Byte String Data Types and Objects 5.2 Integer

Data Types and Objects

5.2

Integer

 
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 values without any sign are regarded as positive.

 
Examples: 256 000123 0 -5 777^ (octal)
Examples:
256
000123
0
-5
777^ (octal)
Inte g er values without an y si g n are re g arded as p

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

Data Types and Objects

5.3 Real

5.3 Real Real numbers are written usin g di g its , decimal points and signs.

Real numbers are written using 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.

Examples: 34.7589472 in MicroSCADA → 34.75895 1234567 123 . in MicroSCADA → 1234567
Examples:
34.7589472 in
MicroSCADA →
34.75895
1234567 123
.
in MicroSCADA →
1234567
→ 34.75895 1234567 123 . in MicroSCADA → 1234567 Data Types and Objects 5.4 Boolean Boolean

Data Types and Objects

5.4 Boolean

Boolean values are gained as the result from testing the truth of expressions (TRUE or FALSE).

5.4 Boolean Boolean values are g ained as the result from testin g the truth of

Internally, FALSE is represented by the value 0 and TRUE by the value 1 (FALSE < TRUE).

#if %i_Counter>10 #then
#if %i_Counter>10 #then
Examples: 5 == 5 “AB” == “CD” %V == FALSE TRUE FALSE TRUE (if boolean
Examples:
5 == 5
“AB” == “CD”
%V == FALSE
TRUE
FALSE
TRUE (if boolean variable
%V is FALSE)
#then Examples: 5 == 5 “AB” == “CD” %V == FALSE TRUE FALSE TRUE (if boolean

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

ABB Oy, P 287(En), 6 1MR751 49 2-MTR

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.

5.5 Time Data of t yp e time is obtained with the SCIL function CLOCK and

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.g. TIMES, HOUR).

;Current time: 20-08-02 10:29 @i_Hour = hour(clock) @t_Time = time(clock) @t_Time_2 = time(100) ; =>
;Current time: 20-08-02 10:29
@i_Hour = hour(clock)
@t_Time = time(clock)
@t_Time_2 = time(100)
; => 10
; => “02-08-20 10:29”
; => “78-01-01 00:01”
; => “02-08-20 10:29” ; => “78-01-01 00:01” Data Types and Objects 5.6 Text Text data

Data Types and Objects

5.6 Text

Text data is composed of one or more, up to 65535 characters (all characters are allowed).

, u p to 65535 characters (all characters are allowed). In Visual SCIL objects a text

In Visual SCIL objects a text can be up to 1023 characters.

In expressions text data must be enclosed in quotation marks ( “ ).

A single quote ( ‘ ) or double quotes ( “ ) contained in a text must be typed as two single or double quotes.

@t_String = “Example text” @t_String_2 = “What’’s this?” @t_Upper = upper_case( string ); => STRING
@t_String = “Example text”
@t_String_2 = “What’’s this?”
@t_Upper = upper_case( string ); => STRING
text” @t_String_2 = “What’’s this?” @t_Upper = upper_case( string ); => STRING “ ” “ ”

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

Data Types and Objects

5.7 Bit String

The length of a bit string (number of bits) may be anything from 0 to 65535.

5.7 Bit String The len g th of a bit strin g (number of bits) ma

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.

@g_BS = bit_scan(“011001”) ; => 011001 @g_BS2 = bit_string(5,1,3,5); => 10101 @t BS = bin(%g
@g_BS = bit_scan(“011001”) ; => 011001
@g_BS2 = bit_string(5,1,3,5); => 10101
@t BS = bin(%g BS2)
_
_
; => ”10101”
10101 @t BS = bin(%g BS2) _ _ ; => ”10101” Data Types and Objects  

Data Types and Objects

 

5.8

Byte String

  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)
@y_BS = pack_str((“a”,”b”,”cd”),”text”)
;
=> “abcd” (text)
@y_BS2 = unpack_str(“abcde”,2)
;
=> (“ab”,”cd”,”e”) (vector)
ABB Oy, P 287(En), 8
1MR751 49 2-MTR
@y_BS2 = unpack_str(“abcde”,2) ; => (“ab”,”cd”,”e”) (vector) ABB Oy, P 287(En), 8 1MR751 49 2-MTR

Data Types and Objects

5.9 Vector

A vector is a string of data.

All data types are allowed in vectors, even so that different types are included in the same vector.

a strin g of data . All data types are allowed in vectors, even so that

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], …)]
Syntax:
VECTOR [([element1 [,element], …)]
@v_Data = vector(1,1.25,4,”text”) @v_Data2 = (1,1.25,4,”text”) @v_Data3 = vector(10) ;One element ABB Oy, P
@v_Data = vector(1,1.25,4,”text”)
@v_Data2 = (1,1.25,4,”text”)
@v_Data3 = vector(10)
;One element
ABB Oy, P 287(En), 9
1MR751 49 2-MTR
;One element ABB Oy, P 287(En), 9 1MR751 49 2-MTR Data Types and Objects 5.10 List

Data Types and Objects

5.10 List

A list consists of attribute names and attribute values.

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, )
Syntax:
LIST(attribute=expression, attribute=expression,
)
@l_Attr = list(iu = 1,- ;In use oa = 14000,- ;Object addr. ss = 1)
@l_Attr = list(iu = 1,-
;In use
oa = 14000,- ;Object addr.
ss = 1)
;Switch state
ABB Oy, P 287(En), 10
1MR751 49 2-MTR
= list(iu = 1,- ;In use oa = 14000,- ;Object addr. ss = 1) ;Switch state

ABB Oy, P 287(En), 11 1MR751 49 2-MTR

ABB Oy, P 287(En), 12 1MR751 49 2-MTR

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

(S) User interface objects Pictures Visual SCIL objects Data Types and Objects 5.11 Object Categories
(S) User interface objects Pictures Visual SCIL objects Data Types and Objects 5.11 Object Categories

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)

(C) Time Channels (T) Event Channels (A) Free Type Objects (F) Event Objects (E) Variable Obejcts

ABB Oy, P 287(En), 14 1MR751 49 2-MTR

Data Types and Objects

5.12 Attributes and Methods Most object types have attributes which represent the values and features
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 programs
written in SCIL.
ABB Oy, P 287(En), 13
1MR751 49 2-MTR

Data Types and Objects

 

5.13

Object Handling

The values and properties of the objects can be read as SCIL 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.

the entire system (global objects). Visual SCIL objects are accessible from SCIL only within the same

Data Types and Objects

5.14 Object Notation System object notation: name:{application}type attribute{index} Application object notation:
5.14
Object Notation
System object notation:
name:{application}type attribute{index}
Application object notation:
name:{application}type{attribute}{index}
N ame:
Application:
Type:
Attribute:
Index:
System objects have predefined names which are composed
of three letters and a sequence number. Application object
names can be freely chosen.
The logical number of the application where the object is
stored. Generally not needed for system objects.
A character indicating object type (B,S,P,H,X,D,C,T,A,E,V,F)
The attribute to be read or written by the notation. Generally
two letter combinations
A number or a range of numbers.
ABB Oy, P 287(En), 15
1MR751 49 2-MTR

Data Types and Objects

5.14 Object Notation ;Object Notation Examples APL1:BAC ;Number of active alarms in ;application 1 SYS:BUV(2)
5.14
Object Notation
;Object Notation Examples
APL1:BAC
;Number of active alarms in
;application 1
SYS:BUV(2) ;User defined global variable
;index 2 (of 10)
CB1:P10
;Process object value, index 10
DATA:D
TASK:COS
;Latest registered value in data
;object
;Program execution state
;0 = successful
ABB Oy, P 287(En), 16
1MR751 49 2-MTR

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

– General 6.8 Expression composition 6.9 Arithmetical operators 6.10 Relational operators 6.11 Logical operators

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

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

Global

Local

SCIL has two types of variables: Global Local Variables and Expressions 6.2 Global Variables Global

Variables and Expressions

6.2 Global Variables Global variables do not need any declaration. A global variable is created
6.2
Global Variables
Global variables do not need any declaration.
A global variable is created the
first time a value is assigned to it.
Syntax:
A global variable exists as
long as the SCIL context
where it was defined is active.
@name[component] = expression
%name[component]

Global variables are assigned new values using the @ character and referred to with the % character.

@i_Value = 123 @t_Text = “Text” %i_Value + 321
@i_Value = 123
@t_Text = “Text”
%i_Value + 321
usin g the @ character and referred to with the % character. @i_Value = 123 @t_Text

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

Variables and Expressions

6.3 Local Variables Local variable are declared at the beginning of a SCIL program with
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
used in several programs since
a local variable is only visible in the
program it is declared.
#LOCAL name [= value] [.name[=value]]
#local i_Value = 100
#local b_Value

Within a SCIL program the variable is referred to by its name (no special characters are needed) .

b_Value = FALSE
b_Value = FALSE
name (no special characters are needed) . b_Value = FALSE Variables and Expressions 6.4 Variable Naming

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
<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
Boolean
x
Variant
Variable
identifier = character string (words separated by ‘_’
and capitalized.
l List b Boolean x Variant Variable identifier = character string (words separated by ‘_’ and

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

ABB Oy, P 287(En), 6 1MR751 49 2-MTR

Variables and Expressions

 

6.4

Variable Naming

A suitable length for a variable name is between 5 and 15 characters.

The variable name should resemble its purpose as much as possible.

 

It is preferred to use the identifier ‘i’ in the SCIL loop structure (‘j’, ‘k’, etc. should be used when multiple inner loops are used).

%i_Application_Number %v_Object_Names %l_Station:Vi_Address ;Integer containing the application number. ;A vector
%i_Application_Number
%v_Object_Names
%l_Station:Vi_Address
;Integer containing the application number.
;A vector containing the object names.
;Address of the station.
containing the object names. ;Address of the station. Variables and Expressions   6.5 SCIL Context A

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 by an event channel

A time channel (Data objects and command procedures run by the time channel share the e

Pictures (Classic Monitor)

SCIL

f th

ti

h

con ex o

t

t

l

me c anne )

procedures run by the time channel share the e Pictures (Classic Monitor) SCIL f th ti
procedures run by the time channel share the e Pictures (Classic Monitor) SCIL f th ti

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

ABB Oy, P 287(En), 8 1MR751 49 2-MTR

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]’
Syntax:
‘name[.attribute]’

If a local and a global variable exists the local variable will be used.

@t_LN = ”cb1” @i_IX = 10 @i_Value = ’t_LN’:POV’i_IX’
@t_LN = ”cb1”
@i_IX = 10
@i_Value = ’t_LN’:POV’i_IX’
= ”cb1” @i_IX = 10 @i_Value = ’t_LN’:POV’i_IX’ Variables and Expressions 6.7 Expressions - General In

Variables and Expressions

6.7 Expressions - General

In SCIL expressions are used:

For value assignments (objects, attributes, variables)

As arguments for functions and commands

As operands in expressions

From external applications through DDE

@i_IX = 10 + 5 * 7 ;assignment #pause 10 ;argument (123 + 321) *
@i_IX = 10 + 5 * 7
;assignment
#pause 10
;argument
(123 + 321) * 500
;operand
From external applications through DDE @i_IX = 10 + 5 * 7 ;assignment #pause 10 ;argument

ABB Oy, P 287(En), 9 1MR751 49 2-MTR

ABB Oy, P 287(En), 10 1MR751 49 2-MTR

Variables and Expressions

6.8 Expression Composition

In SCIL expressions are composed using operators and operands.

@i_Value = (10 + %a) * cb1:POV10
@i_Value = (10 + %a) * cb1:POV10
Operands: - constants - variables - object attributes - function calls - vector and list
Operands:
- constants
- variables
- object attributes
- function calls
- vector and list aggregates
- program return values
- expressions
Operators: - arithmetical (+, -, *, /, etc.) - relational (>, <, ==, etc.) -
Operators:
- arithmetical (+, -, *, /, etc.)
- relational (>, <, ==, etc.)
- logical (AND, OR, etc.)
(>, <, ==, etc.) - logical (AND, OR, etc.) Variables and Expressions 6.9 Arithmetical Operators

Variables and Expressions

6.9 Arithmetical Operators Arithmetical operators are used in numerical calculations. Arithmetical operators: As
6.9
Arithmetical Operators
Arithmetical operators are used in
numerical calculations.
Arithmetical operators:
As operands arithmetical operators
require numeric value
(except addition).
+
addition
p
ositive si n
g
-
subtraction, negative sign
*
multiplication
/
division
**
exponential operator
DIV
integer division
MOD
modulus operator
Priority order: 1) ** 2) /, * , DIV, MOD 3) +, -
Priority order:
1) **
2) /,
* , DIV, MOD
3) +, -
123 + 321 2 17 * 5 33 10 MOD 3 . . ;=> 444
123 + 321
2 17 * 5 33
10 MOD 3
.
.
;=> 444
;=> 11 56610
;=> 1
.
1) ** 2) /, * , DIV, MOD 3) +, - 123 + 321 2 17

ABB Oy, P 287(En), 11 1MR751 49 2-MTR

ABB Oy, P 287(En), 12 1MR751 49 2-MTR

Variables and Expressions

6.10 Relational Operators Relational operators are used for comparing expressions. Relational operators: The result
6.10
Relational Operators
Relational operators are used for
comparing expressions.
Relational operators:
The result of a comparison is
always a Boolean value.
==
equal to
>
greater than
<
The relational operators have
a lower order of priority than
the arithmetical.
<>
<=
>=
less than
unequal
less than or equal to
greater than or equal to
123 > 321 2.17 <= 5.33 ”A” == ”B” ;=> FALSE ;=> TRUE ;=> FALSE
123 > 321
2.17 <= 5.33
”A” == ”B”
;=> FALSE
;=> TRUE
;=> FALSE
== ”B” ;=> FALSE ;=> TRUE ;=> FALSE Variables and Expressions 6.11 Logical Operators Logical

Variables and Expressions

6.11 Logical Operators Logical operators are used for operating on Boolean values. If an expression
6.11
Logical Operators
Logical operators are used for operating
on Boolean values.
If an expression contains two or more different
logical operators parentheses are required to
specify the order.
Logical operators:
AND conjunction
OR
XOR
All logical operators expect operands
of type Boolean.
NOT
disjunction
exclusive or
logical negation

The result of logical operations are of Boolean type.

A B A AND B A OR B A XOR B NOT A TRUE FALSE
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
TR
U
E
TR
U
E
TR
U
E
TR
U
E
FALSE
FALSE
FALSE
FALSE
FALSE
FALSE
FALSE
TRUE
FALSE TRUE TRUE TRUE TR U E TR U E TR U E TR U E

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

7.3 Loops 7.4 Compound statements 7.5 Object handling commands 7.6 Error handling policies 7.7 Functions 7.8

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

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

used in pictures and Motif wi dgets displayed in a X monitor Commands and Functions 7.2

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 #case %i_Obj_Val #when 0 - @i_Text = “Intermediate” #when 1 - @i_Text
@i_Obj_Val = TUTOUT6_B1:P10
#case %i_Obj_Val
#when 0 -
@i_Text = “Intermediate”
#when 1 -
@i_Text = “Closed”
#when 2 -
@i_Text = “Open”
#when 3 -
@i_Text = “Faulty”
#case_end
ABB Oy, P 287(En), 2
1MR751 49 2-MTR
@i_Obj_Val = TUTOUT6_B1:P10 #if %i_Obj_Val==0 #then - @i_Text = “Intermediate” #else_if %i_Obj_Val==1 #then - @i
@i_Obj_Val = TUTOUT6_B1:P10
#if %i_Obj_Val==0 #then -
@i_Text = “Intermediate”
#else_if %i_Obj_Val==1 #then -
@i Text = “Closed”
_
#else_if %i_Obj_Val==2 #then -
@i_Text = “Open”
#else @i_Text = “Faulty”
#then - @i Text = “Closed” _ #else_if %i_Obj_Val==2 #then - @i_Text = “Open” #else @i_Text

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

Commands and Functions

7.3 Loops

SCIL has two types of loops, one with a counter variable (#loop_with) and one without (#loop).

#loop

#loop_with

#local i_Number = 0 @i Number = 0 _ #loop @i_Number = %i_Number + 1
#local i_Number = 0
@i Number = 0
_
#loop
@i_Number = %i_Number + 1
#if %i Number > 50 #then –
#loop_exit
#loop_end 100
_
#loop (even(second))
i_Number = i_Number + 1
#loop_end ;default value 1000
ABB Oy, P 287(En), 3
1MR751 49 2-MTR
#loop_with i = 1 10 @v Vector(%i) = - “value_” + dec(%i) #loop_end _
#loop_with i = 1 10
@v Vector(%i) = -
“value_” + dec(%i)
#loop_end
_
10 @v Vector(%i) = - “value_” + dec(%i) #loop_end _ Commands and Functions 7.4 Compound Statements

Commands and Functions

7.4 Compound Statements

By using #block and #block_end a number of statements can be compund into one statement.

#block

#if %var1 == 10 #then #block @var2=%var1+5 @var3=%var1+10 #block_end #else #block 2 % @var =
#if %var1 == 10 #then #block
@var2=%var1+5
@var3=%var1+10
#block_end
#else #block
2 %
@var = var +
1 15
@var3=%var1+25
#block_end

#block

#on cb1:E10 #block @var2=%var1+15 @var3=%var1+25 #block_end
#on cb1:E10 #block
@var2=%var1+15
@var3=%var1+25
#block_end
2 % @var = var + 1 15 @var3=%var1+25 #block_end #block #on cb1:E10 #block @var2=%var1+15 @var3=%var1+25

Commands and Functions

7.5 Object Handling Commands

SCIL commands #set, #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”,- ;Object text SS = 1,-
@l_Attributes = list(IU = 1,-
;In use
OX = “Breaker”,- ;Object text
SS = 1,-
PT = 1)
;Switch state
;Process object type
#create CB1:P10 = %l_Attributes
;Create object
#set CB1:PIU10=0
@l Modified = list(OX = “Disconnector” SS = 0)
#modify CB1:P10 = %l_Modified
_
,
#delete CB1:P10
;Delete object
ABB Oy, P 287(En), 5
1MR751 49 2-MTR

Commands and Functions

7.6 Error handling policies SCIL has four different error handling policies which are defined with
7.6
Error handling policies
SCIL has four different error handling policies which are defined with the
#error command.
#error ignore
ERROR
#do …
#on error –
@i_Status = -
console_output(“Error”)
#error continue
ERROR
#do …
Error message displayed
#error sto p
ERROR
#do …
If no error handling policy is
defined a default policy is
applied (SCIL manual p.86).
#error event
ERROR
#do …
ABB Oy, P 287(En), 6
1MR751 49 2-MTR

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

ABB Oy, P 287(En), 8 1MR751 49 2-MTR

Commands and Functions

7.7 Functions SCIL provides a number of standard functions, which return values according to a
7.7
Functions
SCIL provides a number of standard functions, which return values
according to a predetermined algorithm.
The argument list contains one or more
expressions separated by commas.
S ntax
y
:
function(argument(s))
The expected data types of the
arguments, as well as the data
type of the result, are fixed by
the function.
LENGTH(“ABC”) == 3
MAX(1.0, 5, 3) == 5.0
TIME == 07-08-20 13:03

Function calls are used as operands in expressions.

” Function calls are used as operands in expressions. Commands and Functions 7.7 Functions There are

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

E.g.: Generic Functions Arithmetic Functions Time Functions String Functions Bit Functions Vector Handling Functions
E.g.: Generic Functions Arithmetic Functions Time Functions String Functions Bit Functions Vector Handling Functions

ABB Oy, P 287(En), 9 1MR751 49 2-MTR

Commands and Functions

7.8 Examples

Print possible error code in SYS 600 Notification window.

@i_ECode = status #error ignore

** Error on this line** @i_ECode = status #if %i_ECode<>0 #then- @i_Status = console_output("Error
** Error on this line**
@i_ECode = status
#if %i_ECode<>0 #then-
@i_Status = console_output("Error code:"+dec(%i_ECode))
= console_output("Error code:"+dec(%i_ECode)) Commands and Functions 7.8 Examples Get logical names of
= console_output("Error code:"+dec(%i_ECode)) Commands and Functions 7.8 Examples Get logical names of

Commands and Functions

7.8 Examples

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

@v_Names = vector() #search 1 0 “P” “A” #loop @l_Attr = next(1) #if l_Attr:VIU ==
@v_Names = vector()
#search 1 0 “P” “A”
#loop
@l_Attr = next(1)
#if l_Attr:VIU == -1 #then #loop_exit
@v_Names = append(%v_Names, l_Attr:VLN)
#loop_end
@i_Status = write_text(”PO_Names.txt”,%v_Names,0)
ABB Oy, P 287(En), 10 1MR751 49 2-MTR
ABB Oy, P 287(En), 10
1MR751 49 2-MTR

If there are no more objects to be found in the object database the next function returns only the IU attribute with the value -1

no more objects to be found in the object database the next function returns only the
no more objects to be found in the object database the next function returns only the

ABB Oy, P 287(En), 11 1MR751 49 2-MTR

ABB Oy, P 287(En), 12 1MR751 49 2-MTR

Commands and Functions

7.8 Examples Calculate the total number of application objects in the application. @v_Obj_Type =
7.8
Examples
Calculate the total number of application objects in the application.
@v_Obj_Type = vector(“P”,”H”,”X”,”F”,”D”,”C”,”T”,”A”)
@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
@i_Status = console_output(dec(%i_Count))
#loop_end @i_Status = console_output(dec(%i_Count)) Commands and Functions 7.8 Examples Create a command p
#loop_end @i_Status = console_output(dec(%i_Count)) Commands and Functions 7.8 Examples Create a command p

Commands and Functions

7.8 Examples

Create a command procedure based on an existing command 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 = 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
@l_temp = fetch(0,”c”,”bgu_al_new”) #if l_Temp:VIU==-1 #then #create bgu_al_new:c = %l_Attr #block_end
@l_temp = fetch(0,”c”,”bgu_al_new”) #if l_Temp:VIU==-1 #then #create bgu_al_new:c = %l_Attr #block_end

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 8.2 Performance improvement 8.3 Impact on SCIL programs 8.4 Avoiding problems with

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

SCIL Compiler

8.1 General The SCIL programs of pictures and command procedures can be compiled for better
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 SCIL code.

The compilation function is selected from the picture editor or from the command procedure tool.

picture editor or from the comman d proce d ure t oo l. SCIL Compiler  
picture editor or from the comman d proce d ure t oo l. SCIL Compiler  

SCIL Compiler

 

8.2

Performance Improvement

Depending on the program 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 : : #loop_end
#loop_with i = 1
1000
:
:
#loop_end

About 50 times faster when compiled.

#pause 10 : : :
#pause 10
:
:
:

No performance improvement although compiled.

: : #loop_end About 50 times faster when compiled. #pause 10 : : : No performance

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

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 valid SCIL program may be impossible to compile.

A SCIL program may compile but generates a run-time error when executed.

A SCIL programs produces different results when compiled compared to the uncompiled program.

Due to these possible incompatibilities the compiled SCIL program has to be properly retested.

the compiled SCIL program has to be properly retested . SCIL Compiler   8.4 Avoiding Problems

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' + '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.

When variable expansions are used as recommended above, the compiled and uncompiled program always behave identically.

expansions are used as recommended above, the com p iled and uncom p iled p ro

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-MTR
ABB Oy, P 2 87(En), 5 1MR751 4 9 2-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

9.1 Exercise 1 9.2 Exercise 2 9.3 Exercise 3 9.4 Exercise 4 9.5 Exercise 5 9.6

ABB Oy, P 287(En), 1 1MR751 49 2-MTR

ABB Oy, P 287(En), 2 1MR751 49 2-MTR

Exercises

1
1

Experiment with different data types and objects using the Test Dialog.

Exercise 1
Exercise 1

Open the Test Dialog from the Tool Manager

Write 123 first line on the Fields page and press the Inspect button.

After pressing the inspect button, the data type and value of the expression appears beneath the line.

Change the contents of the line to -2147483647 and press the inspect 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.

of the line to 321.123 and press the inspect button. Exercises Exercise 1 Change the deci

Exercises

Exercise 1
Exercise 1

Change the decimals to .11111 (-> 321.11111) and press the inspect button.

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.7778 is shown. The seventh digit is 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.

Ch

th

t

t

f th

li

t

UPPER CASE “E

i

d

th

i

t b

tt

 

ange

e con en s o

 

e

ne

o

_

(

xerc se ) an

 

press

e nspec

u

on.

All the lower case letters are converted in to upper case letters.

xerc se ) an   press e nspec u on. All the lower case letters are

ABB Oy, P 287(En), 3 1MR751 49 2-MTR

ABB Oy, P 287(En), 4 1MR751 49 2-MTR

Exercises

Exercise 1
Exercise 1

Change the contents of the line to BIT_SCAN( 101011”) and press the inspect button.

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(“101011”)) and press the inspect 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.

The UNPACK_STR function creates a vector with the following elements : “AB”,”CD”,EF”,”G”.

the following elements : “AB”,”CD”,EF”,”G”. Exercises Exercise 1 “ Change the contents of the

Exercises

Exercise 1
Exercise 1

Change the contents of the line to VECTOR( A”,”B”,”C”,1,2,3) and press the inspect button.

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.

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.

and press the inspect button. A list with attributes and their expressions appear below the line.

ABB Oy, P 287(En), 5 1MR751 49 2-MTR

ABB Oy, P 287(En), 6 1MR751 49 2-MTR

Exercises

2
2

Experiment with variables and expressions using the Test Dialog.

Exercise 2
Exercise 2

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

@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 chan es automaticall update check box is checked.

g

y

on the field

p

a e because the

g

Write %v_B on line 2 on the fields page and press the inspect button.

on line 2 on the fields page and press the inspect button. Exercises Exercise 2 Change

Exercises

Exercise 2
Exercise 2

Change the contents of line 2 to %v_B(3) and press the inspect button.

This will show the third element in vector v_B.

Change the contents of line 2 to %v_B(1

3)

This will show elements 1 to 3 in vector v_B.

and press the inspect button.

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

@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

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

of t_B to 4 and on line 3 on the commands page. Write @t_C=“’t_A’_’t_B’” on line

ABB Oy, P 287(En), 7 1MR751 49 2-MTR

ABB Oy, P 287(En), 8 1MR751 49 2-MTR

Exercises

Exercise 2
Exercise 2

Write %t_C on line 3 on the fields page and press the inspect button.

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

100

DIV 3

100

MOD 3

5*10-10/2

(5*10-10)/2

2**8 100 DIV 3 100 MOD 3 5*10-10/2 (5*10-10)/2 Exercises Exercise 2 Evaluate the following relational

Exercises

Exercise 2
Exercise 2

Evaluate the following relational operators on the Fields 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.

10<%i_A AND %i_A<30 on the Fields page and check the corresponding check box. Change the value

ABB Oy, P 287(En), 9 1MR751 49 2-MTR

ABB Oy, P 287(En), 10 1MR751 49 2-MTR

Exercises

3
3
Exercise 3
Exercise 3

In this exercise the attribute values describing the hardware and software information will be displayed in the Notification Window.

information will be displayed in the Notification Window. Exercises 1 . 2. Exercise 3 3. 4.
information will be displayed in the Notification Window. Exercises 1 . 2. Exercise 3 3. 4.
information will be displayed in the Notification Window. Exercises 1 . 2. Exercise 3 3. 4.

Exercises

1.

1 . 2. Exercise 3 3. 4.
1 . 2. Exercise 3 3. 4.

2.

Exercise 3
Exercise 3

3.

4.

Window. Exercises 1 . 2. Exercise 3 3. 4. 1) Open the Test Dialog from the
Window. Exercises 1 . 2. Exercise 3 3. 4. 1) Open the Test Dialog from the
Window. Exercises 1 . 2. Exercise 3 3. 4. 1) Open the Test Dialog from the

1)

Open the Test Dialog from the Miscellaneous page

2)

in the Tool Manager. Select the Programs page in the Test Dialog.

3)

Select the first program (out of six) and write a

4)

brief description on the Comments line (eg. Exercise 3). By pressing the Edit button on the same line a SCIL Editor will open.

on the Comments line (eg. Exercise 3). By pressing the Edit button on the same line

Exercises

Exercise 3
Exercise 3
Exercises Exercise 3 5) CONSOLE_OUTPUT( text ) Writes a message into the notification window. ’text’ Any
Exercises Exercise 3 5) CONSOLE_OUTPUT( text ) Writes a message into the notification window. ’text’ Any

5)

CONSOLE_OUTPUT( text ) Writes a message into the notification window. ’text’ Any text value. Value:
CONSOLE_OUTPUT( text )
Writes a message into the notification window.
’text’ Any text value.
Value: The status code of the operation. 0 = 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.

Write the SCIL program below in the SCIL Editor (the Console_Output function can either be written manually or inserted from the Insert SCIL Commands, Functions & Objects dialog).

@i Status=console output("Hardware and Software Information") _
@i Status=console output("Hardware and Software Information")
_
@i_Status=console_output("---------------------------------")
@i_Status=console_output("Hardware: "+SYS:BHW)
@i_Status=console_output("Operating System: "+SYS:BOS)
@i_Status=console_output("Program Revision: "+SYS:BRE)
_
ABB Oy, P 287(En), 11
1MR751 49 2-MTR

5.

"+SYS:BRE) _ ABB Oy, P 287(En), 11 1MR751 49 2-MTR 5. Exercises Exercise 3 SYS:BHW Hardware

Exercises

Exercise 3 SYS:BHW Hardware 6. The type of the base system computer. Data type: Text
Exercise 3
SYS:BHW Hardware
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
)
Aft
e
Editor select the Update function from the
File menu.
The next step is to exit the SCIL Editor.
p
(make sure that the Notification Window is
open when testing the program).
e
r
w
ritin
g
th
e
SCIL
p og a
r
r
m in th
SCIL
SYS:BRE Program Revision
The revision number of the running MicroSCADA
kernel software, for example 8.4.5
7)
8)
To test the
p
ro ram
g
p
ress the ins ect button
Data type: Text
Value: Program revision
Access: Read-only
ABB Oy, P 287(En), 12
1MR751 49 2-MTR

ABB Oy, P 287(En), 14 1MR751 49 2-MTR

Exercises

4
4
Exercise 4
Exercise 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 page.

be written in the Test Dialo g on the Programs p a g e . 1.

1.

Error Handler #Error Ignore #On Error @i_Status=Console_Output(“Error handler activated.”) Erroneous line; This
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
)
O
pen t
h
e
T
est
Di
a og an
l
d
wr te t
i
h
e
SCIL
program above in a SCIL editor on the
Programs page.
ABB Oy, P 287(En), 13
1MR751 49 2-MTR

Exercises

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